From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:08:29 +0800 Subject: + astar project --- .../Graphs/Navmesh/TileMesh.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs') diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs new file mode 100644 index 0000000..e5a772a --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs @@ -0,0 +1,41 @@ +using Pathfinding.Util; + +namespace Pathfinding.Graphs.Navmesh { + /// + /// A tile in a navmesh graph. + /// + /// This is an intermediate representation used when building the navmesh, and also in some cases for serializing the navmesh to a portable format. + /// + /// See: for the representation used for pathfinding. + /// + public struct TileMesh { + public int[] triangles; + public Int3[] verticesInTileSpace; + /// One tag per triangle + public uint[] tags; + + /// Unsafe version of + public struct TileMeshUnsafe { + /// Three indices per triangle, of type int + public Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer triangles; + /// One vertex per triangle, of type Int3 + public Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer verticesInTileSpace; + /// One tag per triangle, of type uint + public Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer tags; + + public void Dispose () { + triangles.Dispose(); + verticesInTileSpace.Dispose(); + tags.Dispose(); + } + + public TileMesh ToManaged () { + return new TileMesh { + triangles = Memory.UnsafeAppendBufferToArray(triangles), + verticesInTileSpace = Memory.UnsafeAppendBufferToArray(verticesInTileSpace), + tags = Memory.UnsafeAppendBufferToArray(tags), + }; + } + } + } +} -- cgit v1.1-26-g67d0