Recast Navigation  1.0.35
DetourPathCorridor.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 DETOUTPATHCORRIDOR_H
20 #define DETOUTPATHCORRIDOR_H
21 
22 #include "DetourNavMeshQuery.h"
23 
27 {
28  float m_pos[3];
29  float m_target[3];
30 
31  dtPolyRef* m_path;
32  int m_npath;
33  int m_maxPath;
34 
35 public:
38 
42  bool init(const int maxPath);
43 
47  void reset(dtPolyRef ref, const float* pos);
48 
59  int findCorners(float* cornerVerts, unsigned char* cornerFlags,
60  dtPolyRef* cornerPolys, const int maxCorners,
61  dtNavMeshQuery* navquery, const dtQueryFilter* filter,
62  int options );
63 
69  void optimizePathVisibility(const float* next, const float pathOptimizationRange,
70  dtNavMeshQuery* navquery, const dtQueryFilter* filter);
71 
75  bool optimizePathTopology(dtNavMeshQuery* navquery, const dtQueryFilter* filter);
76 
77  bool moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRef* refs,
78  float* startPos, float* endPos,
79  dtNavMeshQuery* navquery);
80 
81  bool fixPathStart(dtPolyRef safeRef, const float* safePos);
82 
83  bool trimInvalidPath(dtPolyRef safeRef, const float* safePos,
84  dtNavMeshQuery* navquery, const dtQueryFilter* filter);
85 
90  bool isValid(const int maxLookAhead, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
91 
98  bool movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
99 
106  bool moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
107 
112  void setCorridor(const float* target, const dtPolyRef* polys, const int npath);
113 
116  inline const float* getPos() const { return m_pos; }
117 
120  inline const float* getTarget() const { return m_target; }
121 
124  inline dtPolyRef getFirstPoly() const { return m_npath ? m_path[0] : 0; }
125 
128  inline dtPolyRef getLastPoly() const { return m_npath ? m_path[m_npath-1] : 0; }
129 
132  inline const dtPolyRef* getPath() const { return m_path; }
133 
136  inline int getPathCount() const { return m_npath; }
137 
138  inline int getMaxPathCount() const { return m_maxPath; }
139 };
140 
141 int dtMergeCorridorStartMoved(dtPolyRef* path, const int npath, const int maxPath,
142  const dtPolyRef* visited, const int nvisited);
143 
144 int dtMergeCorridorEndMoved(dtPolyRef* path, const int npath, const int maxPath,
145  const dtPolyRef* visited, const int nvisited);
146 
147 int dtMergeCorridorStartShortcut(dtPolyRef* path, const int npath, const int maxPath,
148  const dtPolyRef* visited, const int nvisited);
149 
150 #endif // DETOUTPATHCORRIDOR_H
bool fixPathStart(dtPolyRef safeRef, const float *safePos)
Definition: DetourPathCorridor.cpp:523
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition: DetourNavMesh.h:44
Represents a dynamic polygon corridor used to plan agent movement.
Definition: DetourPathCorridor.h:26
bool init(const int maxPath)
Allocates the corridor's path buffer.
Definition: DetourPathCorridor.cpp:215
dtPathCorridor()
Definition: DetourPathCorridor.cpp:200
int findCorners(float *cornerVerts, unsigned char *cornerFlags, dtPolyRef *cornerPolys, const int maxCorners, dtNavMeshQuery *navquery, const dtQueryFilter *filter, int options)
Finds the corners in the corridor from the position toward the target.
Definition: DetourPathCorridor.cpp:251
const float * getPos() const
Gets the current position within the corridor.
Definition: DetourPathCorridor.h:116
bool trimInvalidPath(dtPolyRef safeRef, const float *safePos, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Definition: DetourPathCorridor.cpp:544
Defines polygon filtering and traversal costs for navigation mesh query operations.
Definition: DetourNavMeshQuery.h:35
void reset(dtPolyRef ref, const float *pos)
Resets the path corridor to the specified position.
Definition: DetourPathCorridor.cpp:230
void setCorridor(const float *target, const dtPolyRef *polys, const int npath)
Loads a new path and target into the corridor.
Definition: DetourPathCorridor.cpp:512
const dtPolyRef * getPath() const
The corridor's path.
Definition: DetourPathCorridor.h:132
~dtPathCorridor()
Definition: DetourPathCorridor.cpp:207
int dtMergeCorridorStartMoved(dtPolyRef *path, const int npath, const int maxPath, const dtPolyRef *visited, const int nvisited)
Definition: DetourPathCorridor.cpp:27
bool optimizePathTopology(dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Attempts to optimize the path using a local area search.
Definition: DetourPathCorridor.cpp:354
int dtMergeCorridorStartShortcut(dtPolyRef *path, const int npath, const int maxPath, const dtPolyRef *visited, const int nvisited)
Definition: DetourPathCorridor.cpp:110
void optimizePathVisibility(const float *next, const float pathOptimizationRange, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Attempts to optimize the path if the specified point is visible from the current position.
Definition: DetourPathCorridor.cpp:311
int getPathCount() const
The number of polygons in the current corridor path.
Definition: DetourPathCorridor.h:136
const float * getTarget() const
Gets the current target within the corridor.
Definition: DetourPathCorridor.h:120
int getMaxPathCount() const
Definition: DetourPathCorridor.h:138
int next(int i, int n)
Definition: DetourTileCacheBuilder.cpp:1072
bool moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRef *refs, float *startPos, float *endPos, dtNavMeshQuery *navquery)
Definition: DetourPathCorridor.cpp:381
bool movePosition(const float *npos, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Moves the position from the current location to the desired location, adjusting the corridor as neede...
Definition: DetourPathCorridor.cpp:440
bool isValid(const int maxLookAhead, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Checks the current corridor path to see if its polygon references remain valid.
Definition: DetourPathCorridor.cpp:587
bool moveTargetPosition(const float *npos, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Moves the target from the curent location to the desired location, adjusting the corridor as needed t...
Definition: DetourPathCorridor.cpp:478
dtPolyRef getLastPoly() const
The polygon reference id of the last polygon in the corridor, the polygon containing the target...
Definition: DetourPathCorridor.h:128
Provides the ability to perform pathfinding related queries against a navigation mesh.
Definition: DetourNavMeshQuery.h:195
int dtMergeCorridorEndMoved(dtPolyRef *path, const int npath, const int maxPath, const dtPolyRef *visited, const int nvisited)
Definition: DetourPathCorridor.cpp:72
dtPolyRef getFirstPoly() const
The polygon reference id of the first polygon in the corridor, the polygon containing the position...
Definition: DetourPathCorridor.h:124