using Pathfinding.Collections; using Unity.Collections; 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 public UnsafeSpan triangles; /// One vertex per triangle public UnsafeSpan verticesInTileSpace; /// One tag per triangle public UnsafeSpan tags; /// /// Frees the underlaying memory. /// This struct should not be used after this method has been called. /// /// Warning: Only call if you know that the memory is owned by this struct, as it is entirely possible for it to just represent views into other memory. /// public void Dispose (Allocator allocator) { triangles.Free(allocator); verticesInTileSpace.Free(allocator); tags.Free(allocator); } public TileMesh ToManaged () { return new TileMesh { triangles = triangles.ToArray(), verticesInTileSpace = verticesInTileSpace.ToArray(), tags = tags.ToArray(), }; } } } }