| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef DETOURPATHQUEUE_H |
| 20 |
#define DETOURPATHQUEUE_H |
| 21 |
|
| 22 |
#include "DetourNavMesh.h" |
| 23 |
#include "DetourNavMeshQuery.h" |
| 24 |
|
| 25 |
static const unsigned int DT_PATHQ_INVALID = 0; |
| 26 |
|
| 27 |
typedef unsigned int dtPathQueueRef; |
| 28 |
|
| 29 |
class dtPathQueue |
| 30 |
{ |
| 31 |
struct PathQuery |
| 32 |
{ |
| 33 |
dtPathQueueRef ref; |
| 34 |
|
| 35 |
float startPos[3], endPos[3]; |
| 36 |
dtPolyRef startRef, endRef; |
| 37 |
|
| 38 |
dtPolyRef* path; |
| 39 |
int npath; |
| 40 |
|
| 41 |
dtStatus status; |
| 42 |
int keepAlive; |
| 43 |
const dtQueryFilter* filter; |
| 44 |
}; |
| 45 |
|
| 46 |
static const int MAX_QUEUE = 8; |
| 47 |
PathQuery m_queue[MAX_QUEUE]; |
| 48 |
dtPathQueueRef m_nextHandle; |
| 49 |
int m_maxPathSize; |
| 50 |
int m_queueHead; |
| 51 |
dtNavMeshQuery* m_navquery; |
| 52 |
|
| 53 |
void purge(); |
| 54 |
|
| 55 |
public: |
| 56 |
dtPathQueue(); |
| 57 |
~dtPathQueue(); |
| 58 |
|
| 59 |
bool init(const int maxPathSize, const int maxSearchNodeCount, dtNavMesh* nav); |
| 60 |
|
| 61 |
void update(const int maxIters); |
| 62 |
|
| 63 |
dtPathQueueRef request(dtPolyRef startRef, dtPolyRef endRef, |
| 64 |
const float* startPos, const float* endPos, |
| 65 |
const dtQueryFilter* filter); |
| 66 |
|
| 67 |
dtStatus getRequestStatus(dtPathQueueRef ref) const; |
| 68 |
|
| 69 |
dtStatus getPathResult(dtPathQueueRef ref, dtPolyRef* path, int* pathSize, const int maxPath); |
| 70 |
|
| 71 |
inline const dtNavMeshQuery* getNavQuery() const { return m_navquery; } |
| 72 |
|
| 73 |
private: |
| 74 |
|
| 75 |
dtPathQueue(const dtPathQueue&); |
| 76 |
dtPathQueue& operator=(const dtPathQueue&); |
| 77 |
}; |
| 78 |
|
| 79 |
#endif |