NavmeshTile.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. namespace PF {
  2. public class NavmeshTile : INavmeshHolder {
  3. /** Tile triangles */
  4. public int[] tris;
  5. /** Tile vertices */
  6. public Int3[] verts;
  7. /** Tile vertices in graph space */
  8. public Int3[] vertsInGraphSpace;
  9. /** Tile X Coordinate */
  10. public int x;
  11. /** Tile Z Coordinate */
  12. public int z;
  13. /** Width, in tile coordinates.
  14. * \warning Widths other than 1 are not supported. This is mainly here for possible future features.
  15. */
  16. public int w;
  17. /** Depth, in tile coordinates.
  18. * \warning Depths other than 1 are not supported. This is mainly here for possible future features.
  19. */
  20. public int d;
  21. /** All nodes in the tile */
  22. public TriangleMeshNode[] nodes;
  23. /** Bounding Box Tree for node lookups */
  24. public BBTree bbTree;
  25. /** Temporary flag used for batching */
  26. public bool flag;
  27. public NavmeshBase graph;
  28. #region INavmeshHolder implementation
  29. public void GetTileCoordinates (int tileIndex, out int x, out int z) {
  30. x = this.x;
  31. z = this.z;
  32. }
  33. public int GetVertexArrayIndex (int index) {
  34. return index & NavmeshBase.VertexIndexMask;
  35. }
  36. /** Get a specific vertex in the tile */
  37. public Int3 GetVertex (int index) {
  38. int idx = index & NavmeshBase.VertexIndexMask;
  39. return verts[idx];
  40. }
  41. public Int3 GetVertexInGraphSpace (int index) {
  42. return vertsInGraphSpace[index & NavmeshBase.VertexIndexMask];
  43. }
  44. /** Transforms coordinates from graph space to world space */
  45. public GraphTransform transform { get { return graph.transform; } }
  46. #endregion
  47. public void GetNodes (System.Action<GraphNode> action) {
  48. if (nodes == null) return;
  49. for (int i = 0; i < nodes.Length; i++) action(nodes[i]);
  50. }
  51. }
  52. }