pathfinder_nav_mesh.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "pathfinder_interface.h"
  3. #include <string>
  4. #include <DetourNavMesh.h>
  5. static const int NAVMESHSET_MAGIC = 'M' << 24 | 'S' << 16 | 'E' << 8 | 'T'; //'MSET';
  6. static const int NAVMESHSET_VERSION = 1;
  7. struct NavMeshSetHeader
  8. {
  9. int magic;
  10. int version;
  11. int numTiles;
  12. dtNavMeshParams params;
  13. };
  14. struct NavMeshTileHeader
  15. {
  16. dtTileRef tileRef;
  17. int dataSize;
  18. };
  19. class PathfinderNavmesh : public IPathfinder
  20. {
  21. public:
  22. PathfinderNavmesh(const std::string &path);
  23. virtual ~PathfinderNavmesh();
  24. virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck, int flags = PathingNotDisabled);
  25. virtual IPath FindPath(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck, const PathfinderOptions& opts);
  26. virtual glm::vec3 GetRandomLocation(const glm::vec3 &start);
  27. private:
  28. void Clear();
  29. void Load(const std::string &path);
  30. void ShowPath(Client *c, const glm::vec3 &start, const glm::vec3 &end);
  31. dtStatus GetPolyHeightNoConnections(dtPolyRef ref, const float *pos, float *height) const;
  32. dtStatus GetPolyHeightOnPath(const dtPolyRef *path, const int path_len, const glm::vec3 &pos, float *h) const;
  33. struct Implementation;
  34. std::unique_ptr<Implementation> m_impl;
  35. };