Atoms Crowd  7.0.0
DetourNavMeshQuery.h
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 
19 #ifndef DETOURNAVMESHQUERY_H
20 #define DETOURNAVMESHQUERY_H
21 
22 #include <AtomsUtils/Globals.h>
23 #include <AtomsUtils/NavigationMesh/Detour/DetourAlloc.h>
24 #include <AtomsUtils/NavigationMesh/Detour/DetourNavMesh.h>
25 #include <AtomsUtils/NavigationMesh/Detour/DetourCommon.h>
26 
27 namespace AtomsUtils {
28 
29 
30 #define WITH_FIXED_AREA_ENTERING_COST 1
31 
32 #define DT_UNWALKABLE_POLY_COST FLT_MAX
33 
34 
35 // By default dtQueryFilter will use virtual calls.
36 // On certain platforms indirect or virtual function call is expensive. The default
37 // setting is to use non-virtual functions, the actual implementations of the functions
38 // are declared as inline for maximum speed.
39 // To avoid virtual calls create dtQueryFilter with inIsVirtual = false.
40 
41 // Special link filter is custom filter run only for offmesh links with assigned UserId
42 // Used by smart navlinks in UE4
43 //
44 struct ATOMSUTILS_EXPORT dtQuerySpecialLinkFilter
45 {
46  virtual ~dtQuerySpecialLinkFilter() {}
47 
50  virtual bool isLinkAllowed(const int UserId) const { return true; }
51 
53  virtual void initialize() {}
54 };
55 
56 
57 struct ATOMSUTILS_EXPORT dtQueryFilterData
58 {
59  float m_areaCost[DT_MAX_AREAS];
60 #if WITH_FIXED_AREA_ENTERING_COST
61  float m_areaFixedCost[DT_MAX_AREAS];
62 #endif // WITH_FIXED_AREA_ENTERING_COST
64  float lowestAreaCost;
65 
66  unsigned short m_includeFlags;
67  unsigned short m_excludeFlags;
68 
69  bool m_isBacktracking;
70 
76 
77 
79 
80  bool equals(const dtQueryFilterData* other) const;
81  void copyFrom(const dtQueryFilterData* source);
82 };
83 
86 class ATOMSUTILS_EXPORT dtQueryFilter
87 {
88 protected:
89  dtQueryFilterData data;
90  const bool isVirtual;
91 
92 public:
93  dtQueryFilter(bool inIsVirtual = true) : isVirtual(inIsVirtual)
94  {}
95  virtual ~dtQueryFilter() {}
96 
97 protected:
98 
100  inline bool passInlineFilter(const dtPolyRef ref,
101  const dtMeshTile* tile,
102  const dtPoly* poly) const
103  {
104  return (poly->flags & data.m_includeFlags) != 0 && (poly->flags & data.m_excludeFlags) == 0
105  && (data.m_areaCost[poly->getArea()] < DT_UNWALKABLE_POLY_COST)
106 #if WITH_FIXED_AREA_ENTERING_COST
107  && (data.m_areaFixedCost[poly->getArea()] < DT_UNWALKABLE_POLY_COST)
108 #endif // WITH_FIXED_AREA_ENTERING_COST
109  ;
110  }
111 
113  virtual bool passVirtualFilter(const dtPolyRef ref,
114  const dtMeshTile* tile,
115  const dtPoly* poly) const
116  {
117  return passInlineFilter(ref, tile, poly);
118  }
119 
120 public:
125  inline bool passFilter(const dtPolyRef ref,
126  const dtMeshTile* tile,
127  const dtPoly* poly) const
128  {
129  return !isVirtual ? passInlineFilter(ref, tile, poly) : passVirtualFilter(ref, tile, poly);
130  }
131 
132 protected:
133 
135  inline float getInlineCost(const float* pa, const float* pb,
136  const dtPolyRef prevRef, const dtMeshTile* prevTile, const dtPoly* prevPoly,
137  const dtPolyRef curRef, const dtMeshTile* curTile, const dtPoly* curPoly,
138  const dtPolyRef nextRef, const dtMeshTile* nextTile, const dtPoly* nextPoly) const
139  {
140 #if WITH_FIXED_AREA_ENTERING_COST
141  const float areaChangeCost = nextPoly != 0 && nextPoly->getArea() != curPoly->getArea()
142  ? data.m_areaFixedCost[nextPoly->getArea()] : 0.f;
143 
144  return dtVdist(pa, pb) * data.m_areaCost[curPoly->getArea()] + areaChangeCost;
145 #else
146  return dtVdist(pa, pb) * data.m_areaCost[curPoly->getArea()];
147 #endif // #if WITH_FIXED_AREA_ENTERING_COST
148  }
149 
151  virtual float getVirtualCost(const float* pa, const float* pb,
152  const dtPolyRef prevRef, const dtMeshTile* prevTile, const dtPoly* prevPoly,
153  const dtPolyRef curRef, const dtMeshTile* curTile, const dtPoly* curPoly,
154  const dtPolyRef nextRef, const dtMeshTile* nextTile, const dtPoly* nextPoly) const
155  {
156  return getInlineCost(pa, pb,
157  prevRef, prevTile, prevPoly,
158  curRef, curTile, curPoly,
159  nextRef, nextTile, nextPoly);
160  }
161 
162 public:
176  inline float getCost(const float* pa, const float* pb,
177  const dtPolyRef prevRef, const dtMeshTile* prevTile, const dtPoly* prevPoly,
178  const dtPolyRef curRef, const dtMeshTile* curTile, const dtPoly* curPoly,
179  const dtPolyRef nextRef, const dtMeshTile* nextTile, const dtPoly* nextPoly) const
180  {
181  return !isVirtual ? getInlineCost(pa, pb, prevRef, prevTile, prevPoly, curRef, curTile, curPoly, nextRef, nextTile, nextPoly)
182  : getVirtualCost(pa, pb, prevRef, prevTile, prevPoly, curRef, curTile, curPoly, nextRef, nextTile, nextPoly);
183  }
184 
187 
191  inline float getAreaCost(const int i) const { return data.m_areaCost[i]; }
192 
196  inline void setAreaCost(const int i, const float cost) { data.m_areaCost[i] = cost; data.lowestAreaCost = dtMin(data.lowestAreaCost, cost); }
197 
198 
199  inline const float* getAllAreaCosts() const { return data.m_areaCost; }
200 
201 #if WITH_FIXED_AREA_ENTERING_COST
205  inline float getAreaFixedCost(const int i) const { return data.m_areaFixedCost[i]; }
206 
210  inline void setAreaFixedCost(const int i, const float cost) { data.m_areaFixedCost[i] = cost; }
211 
212  inline const float* getAllFixedAreaCosts() const { return data.m_areaFixedCost; }
213 #endif // WITH_FIXED_AREA_ENTERING_COST
214 
215  inline float getModifiedHeuristicScale() const { return data.heuristicScale * ((data.lowestAreaCost > 0) ? data.lowestAreaCost : 1.0f); }
216 
219  inline float getHeuristicScale() const { return data.heuristicScale; }
220 
222  inline void setHeuristicScale(const float newScale) { data.heuristicScale = newScale; }
223 
226  inline bool isValidLinkSide(const unsigned char side) const
227  {
228  return (side & DT_LINK_FLAG_OFFMESH_CON) == 0 || (side & DT_LINK_FLAG_OFFMESH_CON_BIDIR) != 0
229  || (data.m_isBacktracking ? (side & DT_LINK_FLAG_OFFMESH_CON_BACKTRACKER) != 0
230  : (side & DT_LINK_FLAG_OFFMESH_CON_BACKTRACKER) == 0);
231  }
232 
234  inline void setIsBacktracking(const bool isBacktracking) { data.m_isBacktracking = isBacktracking; }
235 
238  inline bool getIsBacktracking() const { return data.m_isBacktracking; }
239 
241  inline void setShouldIgnoreClosedNodes(const bool shouldIgnore) { data.m_shouldIgnoreClosedNodes = shouldIgnore; }
242 
245  inline bool getShouldIgnoreClosedNodes() const { return data.m_shouldIgnoreClosedNodes; }
246 
247 
251  inline unsigned short getIncludeFlags() const { return data.m_includeFlags; }
252 
255  inline void setIncludeFlags(const unsigned short flags) { data.m_includeFlags = flags; }
256 
260  inline unsigned short getExcludeFlags() const { return data.m_excludeFlags; }
261 
264  inline void setExcludeFlags(const unsigned short flags) { data.m_excludeFlags = flags; }
265 
267 
269  inline bool equals(const dtQueryFilter* other) const { return data.equals(&(other->data)); }
270  inline bool equals(const dtQueryFilter& other) const { return data.equals(&(other.data)); }
271 
273  inline void copyFrom(const dtQueryFilter* other) { data.copyFrom(&(other->data)); }
274  inline void copyFrom(const dtQueryFilter& other) { data.copyFrom(&(other.data)); }
275 
276 };
277 
279 {
280  dtPolyRef ref;
281  float cost;
282  float pos[3];
283  unsigned int flag;
284 
285  dtQueryResultPack() : ref(0), cost(0), flag(0) {}
286  dtQueryResultPack(dtPolyRef inRef, float inCost, const float* inPos, unsigned int inFlag);
287 };
288 
289 struct ATOMSUTILS_EXPORT dtQueryResult
290 {
291  inline void reserve(int n) { data.resize(n); data.resize(0); }
292  inline int size() const { return data.size(); }
293 
294  inline dtPolyRef getRef(int idx) const { return data[idx].ref; }
295  inline float getCost(int idx) const { return data[idx].cost; }
296  inline const float* getPos(int idx) const { return data[idx].pos; }
297  inline unsigned int getFlag(int idx) const { return data[idx].flag; }
298  void getPos(int idx, float* pos);
299 
300  void copyRefs(dtPolyRef* refs, int nmax);
301  void copyCosts(float* costs, int nmax);
302  void copyPos(float* pos, int nmax);
303  void copyFlags(unsigned char* flags, int nmax);
304  void copyFlags(unsigned int* flags, int nmax);
305 
306 protected:
308 
309  inline int addItem(dtPolyRef ref, float cost, const float* pos, unsigned int flag) { data.push(dtQueryResultPack(ref, cost, pos, flag)); return data.size() - 1; }
310 
311  inline void setRef(int idx, dtPolyRef ref) { data[idx].ref = ref; }
312  inline void setCost(int idx, float cost) { data[idx].cost = cost; }
313  inline void setFlag(int idx, unsigned int flag) { data[idx].flag = flag; }
314  void setPos(int idx, const float* pos);
315 
316  friend class dtNavMeshQuery;
317 };
318 
322 class ATOMSUTILS_EXPORT dtNavMeshQuery
323 {
324 public:
325  dtNavMeshQuery();
326  ~dtNavMeshQuery();
327 
333  dtStatus init(const dtNavMesh* nav, const int maxNodes, dtQuerySpecialLinkFilter* linkFilter = 0);
334 
337 
339  // /@{
340 
350  dtStatus findPath(dtPolyRef startRef, dtPolyRef endRef,
351  const float* startPos, const float* endPos, const float costLimit,
352  const dtQueryFilter* filter,
353  dtQueryResult& result, float* totalCost) const;
354 
359  dtStatus testClusterPath(dtPolyRef startRef, dtPolyRef endRef) const;
360 
369  dtStatus findStraightPath(const float* startPos, const float* endPos,
370  const dtPolyRef* path, const int pathSize,
371  dtQueryResult& result, const int options = 0) const;
372 
380 
389  dtStatus initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef,
390  const float* startPos, const float* endPos, const float costLimit,
391  const dtQueryFilter* filter);
392 
397  dtStatus updateSlicedFindPath(const int maxIter, int* doneIters);
398 
405  dtStatus finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const int maxPath);
406 
416  dtStatus finalizeSlicedFindPathPartial(const dtPolyRef* existing, const int existingSize,
417  dtPolyRef* path, int* pathCount, const int maxPath);
418 
422 
435  dtStatus findPolysAroundCircle(dtPolyRef startRef, const float* centerPos, const float radius,
436  const dtQueryFilter* filter,
437  dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
438  int* resultCount, const int maxResult) const;
439 
453  dtStatus findPolysAroundShape(dtPolyRef startRef, const float* verts, const int nverts,
454  const dtQueryFilter* filter,
455  dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
456  int* resultCount, const int maxResult) const;
457 
458 
468  dtStatus findPolysInPathDistance(dtPolyRef startRef, const float* centerPos, const float pathDistance,
469  const dtQueryFilter* filter, dtPolyRef* resultRef,
470  int* resultCount, const int maxResult) const;
471 
475 
484  dtStatus findNearestPoly(const float* center, const float* extents,
485  const dtQueryFilter* filter,
486  dtPolyRef* nearestRef, float* nearestPt, const float* referencePt = 0) const;
487 
497  dtStatus findNearestPoly2D(const float* center, const float* extents,
498  const dtQueryFilter* filter,
499  dtPolyRef* outProjectedRef, float* outProjectedPt,
500  const float* referencePt = 0, float tolerance = 0) const;
501 
509  dtStatus findNearestContainingPoly(const float* center, const float* extents,
510  const dtQueryFilter* filter,
511  dtPolyRef* nearestRef, float* nearestPt) const;
512 
513 
522  dtStatus queryPolygons(const float* center, const float* extents,
523  const dtQueryFilter* filter,
524  dtPolyRef* polys, int* polyCount, const int maxPolys) const;
525 
537  dtStatus findLocalNeighbourhood(dtPolyRef startRef, const float* centerPos, const float radius,
538  const dtQueryFilter* filter,
539  dtPolyRef* resultRef, dtPolyRef* resultParent,
540  int* resultCount, const int maxResult) const;
541 
543  dtStatus findWallsInNeighbourhood(dtPolyRef startRef, const float* centerPos, const float radius,
544  const dtQueryFilter* filter,
545  dtPolyRef* neiRefs, int* neiCount, const int maxNei,
546  float* resultWalls, dtPolyRef* resultRefs, int* resultCount, const int maxResult) const;
547 
558  dtStatus moveAlongSurface(dtPolyRef startRef, const float* startPos, const float* endPos,
559  const dtQueryFilter* filter,
560  float* resultPos, dtPolyRef* visited, int* visitedCount, const int maxVisitedSize) const;
561 
576  dtStatus raycast(dtPolyRef startRef, const float* startPos, const float* endPos,
577  const dtQueryFilter* filter,
578  float* t, float* hitNormal, dtPolyRef* path, int* pathCount, const int maxPath) const;
579 
590  dtStatus findDistanceToWall(dtPolyRef startRef, const float* centerPos, const float maxRadius,
591  const dtQueryFilter* filter,
592  float* hitDist, float* hitPos, float* hitNormal) const;
593 
603  dtStatus getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* filter,
604  float* segmentVerts, dtPolyRef* segmentRefs, int* segmentCount,
605  const int maxSegments) const;
606 
614  dtStatus findRandomPoint(const dtQueryFilter* filter, int randomSeed,
615  dtPolyRef* randomRef, float* randomPt) const;
616 
627  dtStatus findRandomPointAroundCircle(dtPolyRef startRef, const float* centerPos, const float maxRadius,
628  const dtQueryFilter* filter, int randomSeed,
629  dtPolyRef* randomRef, float* randomPt) const;
630 
636  dtStatus findRandomPointInCluster(dtClusterRef clusterRef, int randomSeed,
637  dtPolyRef* randomRef, float* randomPt) const;
638 
644  dtStatus closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest) const;
645 
652  dtStatus closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, float* closest) const;
653 
659  dtStatus projectedPointOnPoly(dtPolyRef ref, const float* pos, float* projected) const;
660 
666  dtStatus isPointInsidePoly(dtPolyRef ref, const float* pos, bool& result) const;
667 
673  dtStatus getPolyHeight(dtPolyRef ref, const float* pos, float* height) const;
674 
679  dtStatus getPolyCluster(dtPolyRef polyRef, dtClusterRef& clusterRef) const;
680 
684 
688  bool isValidPolyRef(dtPolyRef ref, const dtQueryFilter* filter) const;
689 
693  bool isInClosedList(dtPolyRef ref) const;
694 
700 
703  class dtNodePool* getNodePool() const { return m_nodePool; }
704 
707  const dtNavMesh* getAttachedNavMesh() const { return m_nav; }
708 
710  void getCurrentBestResult(struct dtNode*& bestNode, float& bestCost) const { bestNode = m_query.lastBestNode; bestCost = m_query.lastBestNodeCost; }
711 
712  int getQueryNodes() const { return m_queryNodes; }
714 
715 private:
716 
718  dtMeshTile* getNeighbourTileAt(int x, int y, int side) const;
719 
721  int queryPolygonsInTile(const dtMeshTile* tile, const float* qmin, const float* qmax, const dtQueryFilter* filter,
722  dtPolyRef* polys, const int maxPolys) const;
724  dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center, const float* extents,
725  const dtQueryFilter* filter, float* nearestPt) const;
727  void closestPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly, const float* pos, float* closest) const;
728 
730  dtStatus projectedPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly, const float* pos, float* projected) const;
731 
732 
733  // exposing function to be able to generate navigation corridors as sequence of point pairs
734 public:
736  dtStatus getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
737  unsigned char& fromType, unsigned char& toType) const;
738  dtStatus getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile,
739  dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile,
740  float* left, float* right) const;
741 
743  dtStatus getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const;
744  dtStatus getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile,
745  dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile,
746  float* mid) const;
747 private:
748 
749 
750  // Appends vertex to a straight path
751  dtStatus appendVertex(const float* pos, const unsigned char flags, const dtPolyRef ref,
752  dtQueryResult& result) const;
753 
754  // Appends intermediate portal points to a straight path.
755  dtStatus appendPortals(const int startIdx, const int endIdx, const float* endPos, const dtPolyRef* path,
756  dtQueryResult& result, const int options) const;
757 
758  inline bool passLinkFilterByRef(const dtMeshTile* tile, const dtPolyRef ref) const
759  {
760  return passLinkFilter(tile, m_nav->decodePolyIdPoly(ref));
761  }
762 
763  inline bool passLinkFilter(const dtMeshTile* tile, const int polyIdx) const
764  {
765  const int linkIdx = polyIdx - tile->header->offMeshBase;
766 
767  return !(m_linkFilter && polyIdx >= tile->header->offMeshBase
768  && linkIdx < tile->header->offMeshConCount
769  && tile->offMeshCons[linkIdx].userId != 0
770  && m_linkFilter->isLinkAllowed(tile->offMeshCons[linkIdx].userId) == false);
771  }
772 
773  const dtNavMesh* m_nav;
774  dtQuerySpecialLinkFilter* m_linkFilter;
775 
776  struct dtQueryData
777  {
778  dtStatus status;
779  struct dtNode* lastBestNode;
780  float lastBestNodeCost;
781  dtPolyRef startRef, endRef;
782  float startPos[3], endPos[3];
783  float costLimit;
784  const dtQueryFilter* filter;
785  };
786  dtQueryData m_query;
787 
788  class dtNodePool* m_tinyNodePool;
789  class dtNodePool* m_nodePool;
790  class dtNodeQueue* m_openList;
791 
792  mutable int m_queryNodes;
793 };
794 
798 ATOMSUTILS_EXPORT dtNavMeshQuery* dtAllocNavMeshQuery();
799 
803 ATOMSUTILS_EXPORT void dtFreeNavMeshQuery(dtNavMeshQuery* query);
804 
805 }
806 
807 #endif // DETOURNAVMESHQUERY_H
A simple dynamic array of integers.
Definition: DetourAlloc.h:147
void push(T item)
Definition: DetourAlloc.h:168
int size() const
The current size of the integer array.
Definition: DetourAlloc.h:185
Definition: DetourNavMesh.h:427
Definition: DetourNavMeshQuery.h:323
dtStatus findPolysAroundCircle(dtPolyRef startRef, const float *centerPos, const float radius, const dtQueryFilter *filter, dtPolyRef *resultRef, dtPolyRef *resultParent, float *resultCost, int *resultCount, const int maxResult) const
dtStatus getPortalPoints(dtPolyRef from, dtPolyRef to, float *left, float *right, unsigned char &fromType, unsigned char &toType) const
Returns portal points between two polygons.
dtStatus raycast(dtPolyRef startRef, const float *startPos, const float *endPos, const dtQueryFilter *filter, float *t, float *hitNormal, dtPolyRef *path, int *pathCount, const int maxPath) const
dtStatus isPointInsidePoly(dtPolyRef ref, const float *pos, bool &result) const
dtStatus getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float *mid) const
Returns edge mid point between two polygons.
dtStatus finalizeSlicedFindPath(dtPolyRef *path, int *pathCount, const int maxPath)
dtStatus projectedPointOnPoly(dtPolyRef ref, const float *pos, float *projected) const
class dtNodePool * getNodePool() const
Definition: DetourNavMeshQuery.h:703
dtStatus findWallsInNeighbourhood(dtPolyRef startRef, const float *centerPos, const float radius, const dtQueryFilter *filter, dtPolyRef *neiRefs, int *neiCount, const int maxNei, float *resultWalls, dtPolyRef *resultRefs, int *resultCount, const int maxResult) const
Finds the wall segments in local neighbourhood.
dtStatus closestPointOnPolyBoundary(dtPolyRef ref, const float *pos, float *closest) const
dtStatus getPolyCluster(dtPolyRef polyRef, dtClusterRef &clusterRef) const
bool wasClusterLinkSearched(dtPolyRef cFrom, dtPolyRef cTo) const
bool isValidPolyRef(dtPolyRef ref, const dtQueryFilter *filter) const
dtStatus findRandomPointAroundCircle(dtPolyRef startRef, const float *centerPos, const float maxRadius, const dtQueryFilter *filter, int randomSeed, dtPolyRef *randomRef, float *randomPt) const
dtStatus moveAlongSurface(dtPolyRef startRef, const float *startPos, const float *endPos, const dtQueryFilter *filter, float *resultPos, dtPolyRef *visited, int *visitedCount, const int maxVisitedSize) const
dtStatus findDistanceToWall(dtPolyRef startRef, const float *centerPos, const float maxRadius, const dtQueryFilter *filter, float *hitDist, float *hitPos, float *hitNormal) const
dtStatus getPolyHeight(dtPolyRef ref, const float *pos, float *height) const
dtStatus findPath(dtPolyRef startRef, dtPolyRef endRef, const float *startPos, const float *endPos, const float costLimit, const dtQueryFilter *filter, dtQueryResult &result, float *totalCost) const
dtStatus getPolyWallSegments(dtPolyRef ref, const dtQueryFilter *filter, float *segmentVerts, dtPolyRef *segmentRefs, int *segmentCount, const int maxSegments) const
dtStatus findNearestPoly(const float *center, const float *extents, const dtQueryFilter *filter, dtPolyRef *nearestRef, float *nearestPt, const float *referencePt=0) const
dtStatus findRandomPoint(const dtQueryFilter *filter, int randomSeed, dtPolyRef *randomRef, float *randomPt) const
const dtNavMesh * getAttachedNavMesh() const
Definition: DetourNavMeshQuery.h:707
dtStatus closestPointOnPoly(dtPolyRef ref, const float *pos, float *closest) const
dtStatus init(const dtNavMesh *nav, const int maxNodes, dtQuerySpecialLinkFilter *linkFilter=0)
dtStatus updateSlicedFindPath(const int maxIter, int *doneIters)
dtStatus findNearestContainingPoly(const float *center, const float *extents, const dtQueryFilter *filter, dtPolyRef *nearestRef, float *nearestPt) const
void getCurrentBestResult(struct dtNode *&bestNode, float &bestCost) const
Gets best node ref and cost from sliced pathfinding data.
Definition: DetourNavMeshQuery.h:710
dtStatus queryPolygons(const float *center, const float *extents, const dtQueryFilter *filter, dtPolyRef *polys, int *polyCount, const int maxPolys) const
dtStatus finalizeSlicedFindPathPartial(const dtPolyRef *existing, const int existingSize, dtPolyRef *path, int *pathCount, const int maxPath)
dtStatus findStraightPath(const float *startPos, const float *endPos, const dtPolyRef *path, const int pathSize, dtQueryResult &result, const int options=0) const
dtStatus findNearestPoly2D(const float *center, const float *extents, const dtQueryFilter *filter, dtPolyRef *outProjectedRef, float *outProjectedPt, const float *referencePt=0, float tolerance=0) const
dtStatus findLocalNeighbourhood(dtPolyRef startRef, const float *centerPos, const float radius, const dtQueryFilter *filter, dtPolyRef *resultRef, dtPolyRef *resultParent, int *resultCount, const int maxResult) const
dtStatus findPolysInPathDistance(dtPolyRef startRef, const float *centerPos, const float pathDistance, const dtQueryFilter *filter, dtPolyRef *resultRef, int *resultCount, const int maxResult) const
bool isInClosedList(dtPolyRef ref) const
dtStatus testClusterPath(dtPolyRef startRef, dtPolyRef endRef) const
dtStatus initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef, const float *startPos, const float *endPos, const float costLimit, const dtQueryFilter *filter)
void updateLinkFilter(dtQuerySpecialLinkFilter *linkFilter)
updates special link filter for this query
dtStatus findPolysAroundShape(dtPolyRef startRef, const float *verts, const int nverts, const dtQueryFilter *filter, dtPolyRef *resultRef, dtPolyRef *resultParent, float *resultCost, int *resultCount, const int maxResult) const
dtStatus findRandomPointInCluster(dtClusterRef clusterRef, int randomSeed, dtPolyRef *randomRef, float *randomPt) const
Definition: DetourNode.h:48
Definition: DetourNavMeshQuery.h:87
void copyFrom(const dtQueryFilter *other)
Copy data values from source filter.
Definition: DetourNavMeshQuery.h:273
float getInlineCost(const float *pa, const float *pb, const dtPolyRef prevRef, const dtMeshTile *prevTile, const dtPoly *prevPoly, const dtPolyRef curRef, const dtMeshTile *curTile, const dtPoly *curPoly, const dtPolyRef nextRef, const dtMeshTile *nextTile, const dtPoly *nextPoly) const
inlined scoring function.
Definition: DetourNavMeshQuery.h:135
void setExcludeFlags(const unsigned short flags)
Definition: DetourNavMeshQuery.h:264
float getAreaFixedCost(const int i) const
Definition: DetourNavMeshQuery.h:205
void setHeuristicScale(const float newScale)
Set euclidean distance heuristic scale.
Definition: DetourNavMeshQuery.h:222
bool getShouldIgnoreClosedNodes() const
Definition: DetourNavMeshQuery.h:245
float getCost(const float *pa, const float *pb, const dtPolyRef prevRef, const dtMeshTile *prevTile, const dtPoly *prevPoly, const dtPolyRef curRef, const dtMeshTile *curTile, const dtPoly *curPoly, const dtPolyRef nextRef, const dtMeshTile *nextTile, const dtPoly *nextPoly) const
Definition: DetourNavMeshQuery.h:176
unsigned short getExcludeFlags() const
Definition: DetourNavMeshQuery.h:260
void setShouldIgnoreClosedNodes(const bool shouldIgnore)
Instruct filter whether it can reopen nodes already on closed list.
Definition: DetourNavMeshQuery.h:241
void setIncludeFlags(const unsigned short flags)
Definition: DetourNavMeshQuery.h:255
void setAreaFixedCost(const int i, const float cost)
Definition: DetourNavMeshQuery.h:210
unsigned short getIncludeFlags() const
Definition: DetourNavMeshQuery.h:251
bool passFilter(const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
Definition: DetourNavMeshQuery.h:125
float getHeuristicScale() const
Definition: DetourNavMeshQuery.h:219
bool equals(const dtQueryFilter *other) const
Check if two filters have the same data values.
Definition: DetourNavMeshQuery.h:269
bool passInlineFilter(const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
inlined filter implementation.
Definition: DetourNavMeshQuery.h:100
virtual bool passVirtualFilter(const dtPolyRef ref, const dtMeshTile *tile, const dtPoly *poly) const
virtual filter implementation (defaults to passInlineFilter).
Definition: DetourNavMeshQuery.h:113
bool isValidLinkSide(const unsigned char side) const
Definition: DetourNavMeshQuery.h:226
void setAreaCost(const int i, const float cost)
Definition: DetourNavMeshQuery.h:196
bool getIsBacktracking() const
Definition: DetourNavMeshQuery.h:238
float getAreaCost(const int i) const
Definition: DetourNavMeshQuery.h:191
void setIsBacktracking(const bool isBacktracking)
Sets up filter for backtracking.
Definition: DetourNavMeshQuery.h:234
virtual float getVirtualCost(const float *pa, const float *pb, const dtPolyRef prevRef, const dtMeshTile *prevTile, const dtPoly *prevPoly, const dtPolyRef curRef, const dtMeshTile *curTile, const dtPoly *curPoly, const dtPolyRef nextRef, const dtMeshTile *nextTile, const dtPoly *nextPoly) const
virtual scoring function implementation (defaults to getInlineCost).
Definition: DetourNavMeshQuery.h:151
ATOMSUTILS_EXPORT dtNavMeshQuery * dtAllocNavMeshQuery()
ATOMSUTILS_EXPORT void dtFreeNavMeshQuery(dtNavMeshQuery *query)
Type_uint64 dtPolyRef
Definition: DetourNavMesh.h:47
AtomsCore namespace.
Definition: Base64.h:13
Type_uint64 dtClusterRef
A handle to a cluster within a navigation mesh tile.
Definition: DetourNavMesh.h:54
ATOMSUTILS_EXPORT float dtVdist(const float *v1, const float *v2)
Definition: DetourCommon.h:221
T dtMin(T a, T b)
Definition: DetourCommon.h:50
int offMeshBase
The index of the first polygon which is an point type off-mesh connection.
Definition: DetourNavMesh.h:356
int offMeshConCount
The number of point type off-mesh connections.
Definition: DetourNavMesh.h:354
Definition: DetourNavMesh.h:374
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:378
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:394
Definition: DetourNode.h:37
unsigned int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built....
Definition: DetourNavMesh.h:293
Definition: DetourNavMesh.h:178
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:190
unsigned char getArea() const
Gets the user defined area id.
Definition: DetourNavMesh.h:206
Definition: DetourNavMeshQuery.h:58
float m_areaFixedCost[DT_MAX_AREAS]
Fixed cost for entering an area type (Used by default implementation.)
Definition: DetourNavMeshQuery.h:61
float heuristicScale
Search heuristic scale.
Definition: DetourNavMeshQuery.h:63
unsigned short m_includeFlags
Flags for polygons that can be visited. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:66
bool m_shouldIgnoreClosedNodes
Definition: DetourNavMeshQuery.h:75
unsigned short m_excludeFlags
Flags for polygons that should not be visited. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:67
float m_areaCost[DT_MAX_AREAS]
Cost per area type. (Used by default implementation.)
Definition: DetourNavMeshQuery.h:59
Definition: DetourNavMeshQuery.h:290
Definition: DetourNavMeshQuery.h:279