DetourLocalBoundary.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // Copyright (c) 2009-2010 Mikko Mononen [email protected]
  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. // ATOMIC BEGIN
  21. #include "../../Detour/include/DetourNavMeshQuery.h"
  22. // ATOMIC END
  23. class dtLocalBoundary
  24. {
  25. static const int MAX_LOCAL_SEGS = 8;
  26. static const int MAX_LOCAL_POLYS = 16;
  27. struct Segment
  28. {
  29. float s[6]; ///< Segment start/end
  30. float d; ///< Distance for pruning.
  31. };
  32. float m_center[3];
  33. Segment m_segs[MAX_LOCAL_SEGS];
  34. int m_nsegs;
  35. dtPolyRef m_polys[MAX_LOCAL_POLYS];
  36. int m_npolys;
  37. void addSegment(const float dist, const float* seg);
  38. public:
  39. dtLocalBoundary();
  40. ~dtLocalBoundary();
  41. void reset();
  42. void update(dtPolyRef ref, const float* pos, const float collisionQueryRange,
  43. dtNavMeshQuery* navquery, const dtQueryFilter* filter);
  44. bool isValid(dtNavMeshQuery* navquery, const dtQueryFilter* filter);
  45. inline const float* getCenter() const { return m_center; }
  46. inline int getSegmentCount() const { return m_nsegs; }
  47. inline const float* getSegment(int i) const { return m_segs[i].s; }
  48. };
  49. #endif // DETOURLOCALBOUNDARY_H