DetourLocalBoundary.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
  3. //
  4. // This software is provided 'as-is', without any express or implied
  5. // warranty. In no event will the authors be held liable for any damages
  6. // arising from the use of this software.
  7. // Permission is granted to anyone to use this software for any purpose,
  8. // including commercial applications, and to alter it and redistribute it
  9. // freely, subject to the following restrictions:
  10. // 1. The origin of this software must not be misrepresented; you must not
  11. // claim that you wrote the original software. If you use this software
  12. // in a product, an acknowledgment in the product documentation would be
  13. // appreciated but is not required.
  14. // 2. Altered source versions must be plainly marked as such, and must not be
  15. // misrepresented as being the original software.
  16. // 3. This notice may not be removed or altered from any source distribution.
  17. //
  18. #ifndef DETOURLOCALBOUNDARY_H
  19. #define DETOURLOCALBOUNDARY_H
  20. #include "DetourNavMeshQuery.h"
  21. class dtLocalBoundary
  22. {
  23. static const int MAX_LOCAL_SEGS = 8;
  24. static const int MAX_LOCAL_POLYS = 16;
  25. struct Segment
  26. {
  27. float s[6]; ///< Segment start/end
  28. float d; ///< Distance for pruning.
  29. };
  30. float m_center[3];
  31. Segment m_segs[MAX_LOCAL_SEGS];
  32. int m_nsegs;
  33. dtPolyRef m_polys[MAX_LOCAL_POLYS];
  34. int m_npolys;
  35. void addSegment(const float dist, const float* s);
  36. public:
  37. dtLocalBoundary();
  38. ~dtLocalBoundary();
  39. void reset();
  40. void update(dtPolyRef ref, const float* pos, const float collisionQueryRange,
  41. dtNavMeshQuery* navquery, const dtQueryFilter* filter);
  42. bool isValid(dtNavMeshQuery* navquery, const dtQueryFilter* filter);
  43. inline const float* getCenter() const { return m_center; }
  44. inline int getSegmentCount() const { return m_nsegs; }
  45. inline const float* getSegment(int i) const { return m_segs[i].s; }
  46. private:
  47. // Explicitly disabled copy constructor and copy assignment operator.
  48. dtLocalBoundary(const dtLocalBoundary&);
  49. dtLocalBoundary& operator=(const dtLocalBoundary&);
  50. };
  51. #endif // DETOURLOCALBOUNDARY_H