NavigationMesh.pkg 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. $#include "NavigationMesh.h"
  2. /// Description of a navigation mesh geometry component, with transform and bounds information.
  3. struct NavigationGeometryInfo
  4. {
  5. /// Component.
  6. Component* component_;
  7. /// Geometry LOD level if applicable.
  8. unsigned lodLevel_;
  9. /// Transform relative to the navigation mesh root node.
  10. Matrix3x4 transform_;
  11. /// Bounding box relative to the navigation mesh root node.
  12. BoundingBox boundingBox_;
  13. };
  14. /// Navigation mesh component. Collects the navigation geometry from child nodes with the Navigable component and responds to path queries.
  15. class NavigationMesh : public Component
  16. {
  17. public:
  18. /// Set tile size.
  19. void SetTileSize(int size);
  20. /// Set cell size.
  21. void SetCellSize(float size);
  22. /// Set cell height.
  23. void SetCellHeight(float height);
  24. /// Set navigation agent height.
  25. void SetAgentHeight(float height);
  26. /// Set navigation agent radius.
  27. void SetAgentRadius(float radius);
  28. /// Set navigation agent max vertical climb.
  29. void SetAgentMaxClimb(float maxClimb);
  30. /// Set navigation agent max slope.
  31. void SetAgentMaxSlope(float maxSlope);
  32. /// Set region minimum size.
  33. void SetRegionMinSize(float size);
  34. /// Set region merge size.
  35. void SetRegionMergeSize(float size);
  36. /// Set edge max length.
  37. void SetEdgeMaxLength(float length);
  38. /// Set edge max error.
  39. void SetEdgeMaxError(float error);
  40. /// Set detail sampling distance.
  41. void SetDetailSampleDistance(float distance);
  42. /// Set detail sampling maximum error.
  43. void SetDetailSampleMaxError(float error);
  44. /// Set padding of the navigation mesh bounding box. Having enough padding allows to add geometry on the extremities of the navigation mesh when doing partial rebuilds.
  45. void SetPadding(const Vector3& padding);
  46. /// Rebuild the navigation mesh. Return true if successful.
  47. bool Build();
  48. /// Rebuild part of the navigation mesh contained by the world-space bounding box. Return true if successful.
  49. bool Build(const BoundingBox& boundingBox);
  50. /// Find a path between world space points. Return non-empty list of points if successful. Extents specifies how far off the navigation mesh the points can be.
  51. void FindPath(PODVector<Vector3>& dest, const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE);
  52. /// Return a random point on the navigation mesh.
  53. Vector3 GetRandomPoint();
  54. /// Return a random point on the navigation mesh within a circle. The circle radius is only a guideline and in practice the returned point may be further away.
  55. Vector3 GetRandomPointInCircle(const Vector3& center, float radius, const Vector3& extents = Vector3::ONE);
  56. /// Return distance to wall from a point. Maximum search radius must be specified.
  57. float GetDistanceToWall(const Vector3& point, float radius, const Vector3& extents = Vector3::ONE);
  58. /// Perform a walkability raycast on the navigation mesh between start and end and return the point where a wall was hit, or the end point if no walls.
  59. Vector3 Raycast(const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE);
  60. /// Return tile size.
  61. int GetTileSize() const;
  62. /// Return cell size.
  63. float GetCellSize() const;
  64. /// Return cell height.
  65. float GetCellHeight() const;
  66. /// Return navigation agent height.
  67. float GetAgentHeight() const;
  68. /// Return navigation agent radius.
  69. float GetAgentRadius() const;
  70. /// Return navigation agent max vertical climb.
  71. float GetAgentMaxClimb() const;
  72. /// Return navigation agent max slope.
  73. float GetAgentMaxSlope() const;
  74. /// Return region minimum size.
  75. float GetRegionMinSize() const;
  76. /// Return region merge size.
  77. float GetRegionMergeSize() const;
  78. /// Return edge max length.
  79. float GetEdgeMaxLength() const;
  80. /// Return edge max error.
  81. float GetEdgeMaxError() const;
  82. /// Return detail sampling distance.
  83. float GetDetailSampleDistance() const;
  84. /// Return detail sampling maximum error.
  85. float GetDetailSampleMaxError() const;
  86. /// Return navigation mesh bounding box padding.
  87. const Vector3& GetPadding() const;
  88. /// Return whether has been initialized with valid navigation data.
  89. bool IsInitialized() const;
  90. /// Return local space bounding box of the navigation mesh.
  91. const BoundingBox& GetBoundingBox() const;
  92. /// Return world space bounding box of the navigation mesh.
  93. BoundingBox GetWorldBoundingBox() const;
  94. /// Return number of tiles.
  95. IntVector2 GetNumTiles() const;
  96. };