summaryrefslogtreecommitdiff
path: root/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-23 10:08:29 +0800
committerchai <215380520@qq.com>2024-05-23 10:08:29 +0800
commit8722a9920c1f6119bf6e769cba270e63097f8e25 (patch)
tree2eaf9865de7fb1404546de4a4296553d8f68cc3b /Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs
parent3ba4020b69e5971bb0df7ee08b31d10ea4d01937 (diff)
+ astar project
Diffstat (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs')
-rw-r--r--Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/TileMesh.cs41
1 files changed, 41 insertions, 0 deletions
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 {
+ /// <summary>
+ /// 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: <see cref="NavmeshTile"/> for the representation used for pathfinding.
+ /// </summary>
+ public struct TileMesh {
+ public int[] triangles;
+ public Int3[] verticesInTileSpace;
+ /// <summary>One tag per triangle</summary>
+ public uint[] tags;
+
+ /// <summary>Unsafe version of <see cref="TileMesh"/></summary>
+ public struct TileMeshUnsafe {
+ /// <summary>Three indices per triangle, of type int</summary>
+ public Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer triangles;
+ /// <summary>One vertex per triangle, of type Int3</summary>
+ public Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer verticesInTileSpace;
+ /// <summary>One tag per triangle, of type uint</summary>
+ 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<int>(triangles),
+ verticesInTileSpace = Memory.UnsafeAppendBufferToArray<Int3>(verticesInTileSpace),
+ tags = Memory.UnsafeAppendBufferToArray<uint>(tags),
+ };
+ }
+ }
+ }
+}