Planeshift
DetourPathQueue.h
Go to the documentation of this file.
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 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 
30 {
31  struct PathQuery
32  {
33  dtPathQueueRef ref;
35  float startPos[3], endPos[3];
36  dtPolyRef startRef, endRef;
38  dtPolyRef* path;
39  int npath;
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 
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 };
74 
75 #endif // DETOURPATHQUEUE_H
dtStatus getPathResult(dtPathQueueRef ref, dtPolyRef *path, int *pathSize, const int maxPath)
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition: DetourNavMesh.h:30
bool init(const int maxPathSize, const int maxSearchNodeCount, dtNavMesh *nav)
dtPathQueueRef request(dtPolyRef startRef, dtPolyRef endRef, const float *startPos, const float *endPos, const dtQueryFilter *filter)
dtStatus getRequestStatus(dtPathQueueRef ref) const
Defines polygon filtering and traversal costs for navigation mesh query operations.
unsigned int dtStatus
Definition: DetourStatus.h:22
A navigation mesh based on tiles of convex polygons.
unsigned int dtPathQueueRef
void update(const int maxIters)
const dtNavMeshQuery * getNavQuery() const
Provides the ability to perform pathfinding related queries against a navigation mesh.
static const unsigned int DT_PATHQ_INVALID