123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- #ifndef DETOURNAVMESHQUERY_H
- #define DETOURNAVMESHQUERY_H
- #include "DetourNavMesh.h"
- #include "DetourStatus.h"
- class dtQueryFilter
- {
- float m_areaCost[DT_MAX_AREAS];
- unsigned short m_includeFlags;
- unsigned short m_excludeFlags;
-
- public:
- dtQueryFilter();
-
- #ifdef DT_VIRTUAL_QUERYFILTER
- virtual ~dtQueryFilter() { }
- #endif
-
-
-
-
-
- #ifdef DT_VIRTUAL_QUERYFILTER
- virtual bool passFilter(const dtPolyRef ref,
- const dtMeshTile* tile,
- const dtPoly* poly) const;
- #else
- bool passFilter(const dtPolyRef ref,
- const dtMeshTile* tile,
- const dtPoly* poly) const;
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
- #ifdef DT_VIRTUAL_QUERYFILTER
- virtual 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;
- #else
- 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;
- #endif
-
-
-
-
-
- inline float getAreaCost(const int i) const { return m_areaCost[i]; }
-
-
-
- inline void setAreaCost(const int i, const float cost) { m_areaCost[i] = cost; }
-
-
-
- inline unsigned short getIncludeFlags() const { return m_includeFlags; }
-
-
- inline void setIncludeFlags(const unsigned short flags) { m_includeFlags = flags; }
-
-
-
- inline unsigned short getExcludeFlags() const { return m_excludeFlags; }
-
-
- inline void setExcludeFlags(const unsigned short flags) { m_excludeFlags = flags; }
-
- };
- struct dtRaycastHit
- {
-
- float t;
-
-
- float hitNormal[3];
-
-
- dtPolyRef* path;
-
-
- int pathCount;
-
- int maxPath;
-
- float pathCost;
- };
- class dtNavMeshQuery
- {
- public:
- dtNavMeshQuery();
- ~dtNavMeshQuery();
-
-
-
-
-
- dtStatus init(const dtNavMesh* nav, const int maxNodes);
-
-
-
-
-
-
-
-
-
-
-
-
-
- dtStatus findPath(dtPolyRef startRef, dtPolyRef endRef,
- const float* startPos, const float* endPos,
- const dtQueryFilter* filter,
- dtPolyRef* path, int* pathCount, const int maxPath) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
- dtStatus findStraightPath(const float* startPos, const float* endPos,
- const dtPolyRef* path, const int pathSize,
- float* straightPath, unsigned char* straightPathFlags, dtPolyRef* straightPathRefs,
- int* straightPathCount, const int maxStraightPath, const int options = 0) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- dtStatus initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef,
- const float* startPos, const float* endPos,
- const dtQueryFilter* filter, const unsigned int options = 0);
-
-
-
-
- dtStatus updateSlicedFindPath(const int maxIter, int* doneIters);
-
-
-
-
-
-
- dtStatus finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const int maxPath);
-
-
-
-
-
-
-
-
-
-
- dtStatus finalizeSlicedFindPathPartial(const dtPolyRef* existing, const int existingSize,
- dtPolyRef* path, int* pathCount, const int maxPath);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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 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 findNearestPoly(const float* center, const float* extents,
- const dtQueryFilter* filter,
- dtPolyRef* nearestRef, float* nearestPt) const;
-
-
-
-
-
-
-
-
-
- dtStatus queryPolygons(const float* center, const float* extents,
- const dtQueryFilter* filter,
- dtPolyRef* polys, int* polyCount, const int maxPolys) 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 moveAlongSurface(dtPolyRef startRef, const float* startPos, const float* endPos,
- const dtQueryFilter* filter,
- float* resultPos, dtPolyRef* visited, int* visitedCount, const int maxVisitedSize) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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 raycast(dtPolyRef startRef, const float* startPos, const float* endPos,
- const dtQueryFilter* filter, const unsigned int options,
- dtRaycastHit* hit, dtPolyRef prevRef = 0) const;
-
-
-
-
-
-
-
-
-
-
- dtStatus findDistanceToWall(dtPolyRef startRef, const float* centerPos, const float maxRadius,
- const dtQueryFilter* filter,
- float* hitDist, float* hitPos, float* hitNormal) const;
-
-
-
-
-
-
-
-
-
-
- dtStatus getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* filter,
- float* segmentVerts, dtPolyRef* segmentRefs, int* segmentCount,
- const int maxSegments) const;
-
-
-
-
-
-
-
- dtStatus findRandomPoint(const dtQueryFilter* filter, float (*frand)(),
- dtPolyRef* randomRef, float* randomPt) const;
-
-
-
-
-
-
-
-
-
-
- dtStatus findRandomPointAroundCircle(dtPolyRef startRef, const float* centerPos, const float maxRadius,
- const dtQueryFilter* filter, float (*frand)(),
- dtPolyRef* randomRef, float* randomPt) const;
-
-
-
-
-
-
-
- dtStatus closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const;
-
-
-
-
-
-
-
- dtStatus closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, float* closest) const;
-
-
-
-
-
-
- dtStatus getPolyHeight(dtPolyRef ref, const float* pos, float* height) const;
-
-
-
-
-
-
- bool isValidPolyRef(dtPolyRef ref, const dtQueryFilter* filter) const;
-
-
-
- bool isInClosedList(dtPolyRef ref) const;
-
-
-
- class dtNodePool* getNodePool() const { return m_nodePool; }
-
-
-
- const dtNavMesh* getAttachedNavMesh() const { return m_nav; }
-
-
- private:
-
-
- dtMeshTile* getNeighbourTileAt(int x, int y, int side) const;
-
- int queryPolygonsInTile(const dtMeshTile* tile, const float* qmin, const float* qmax, const dtQueryFilter* filter,
- dtPolyRef* polys, const int maxPolys) const;
-
- dtStatus getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
- unsigned char& fromType, unsigned char& toType) const;
- dtStatus getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile,
- dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile,
- float* left, float* right) const;
-
-
- dtStatus getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const;
- dtStatus getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile,
- dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile,
- float* mid) const;
-
-
- dtStatus appendVertex(const float* pos, const unsigned char flags, const dtPolyRef ref,
- float* straightPath, unsigned char* straightPathFlags, dtPolyRef* straightPathRefs,
- int* straightPathCount, const int maxStraightPath) const;
-
- dtStatus appendPortals(const int startIdx, const int endIdx, const float* endPos, const dtPolyRef* path,
- float* straightPath, unsigned char* straightPathFlags, dtPolyRef* straightPathRefs,
- int* straightPathCount, const int maxStraightPath, const int options) const;
-
- const dtNavMesh* m_nav;
- struct dtQueryData
- {
- dtStatus status;
- struct dtNode* lastBestNode;
- float lastBestNodeCost;
- dtPolyRef startRef, endRef;
- float startPos[3], endPos[3];
- const dtQueryFilter* filter;
- unsigned int options;
- float raycastLimitSqr;
- };
- dtQueryData m_query;
- class dtNodePool* m_tinyNodePool;
- class dtNodePool* m_nodePool;
- class dtNodeQueue* m_openList;
- };
- dtNavMeshQuery* dtAllocNavMeshQuery();
- void dtFreeNavMeshQuery(dtNavMeshQuery* query);
- #endif
|