Atoms Crowd  7.0.0
DetourPathCorridor.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 DETOUTPATHCORRIDOR_H
20 #define DETOUTPATHCORRIDOR_H
21 
22 #include <AtomsUtils/Globals.h>
23 #include <AtomsUtils/NavigationMesh/Detour/DetourNavMesh.h>
24 
25 namespace AtomsUtils
26 {
27 
28  class dtNavMeshQuery;
29  class dtQueryFilter;
30 
33  class ATOMSUTILS_EXPORT dtPathCorridor
34  {
35  float m_pos[3];
36  float m_target[3];
37  float m_prevMovePoint[3];
38  float m_nextExpectedCorner[3];
39  float m_nextExpectedCorner2[3];
40  float m_moveSegAngle;
41  unsigned int m_hasNextExpectedCorner : 1;
42  unsigned int m_hasNextExpectedCorner2 : 1;
43  unsigned int m_isInSkipRange : 1;
44  unsigned int m_enableEarlyReach : 1;
45 
46  dtPolyRef* m_path;
47  int m_npath;
48  int m_maxPath;
49 
50  public:
52  ~dtPathCorridor();
53 
57  bool init(const int maxPath);
58 
62  void reset(dtPolyRef ref, const float* pos);
63 
76  int findCorners(float* cornerVerts, unsigned char* cornerFlags,
77  dtPolyRef* cornerPolys, const int maxCorners,
78  dtNavMeshQuery* navquery, const dtQueryFilter* filter,
79  float pathOffsetDistance, float earlyReachDistance, bool bAllowEarlyReach = true);
80 
86  bool optimizePathVisibility(const float* next, const float pathOptimizationRange,
87  dtNavMeshQuery* navquery, const dtQueryFilter* filter);
88 
92  bool optimizePathTopology(dtNavMeshQuery* navquery, const dtQueryFilter* filter);
93 
94  bool moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRef* refs,
95  const float* agentPos,
96  float* startPos, float* endPos,
97  dtNavMeshQuery* navquery);
98 
101  const float* agentPos, float* startPos, float* endPos,
102  dtNavMeshQuery* navquery) const;
103 
105  void pruneOffmeshConenction(dtPolyRef offMeshConRef);
106 
107  bool fixPathStart(dtPolyRef safeRef, const float* safePos);
108 
109  bool trimInvalidPath(dtPolyRef safeRef, const float* safePos,
110  dtNavMeshQuery* navquery, const dtQueryFilter* filter);
111 
116  bool isValid(const int maxLookAhead, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
117 
123  bool movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
124 
130  void moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
131 
136  void setCorridor(const float* target, const dtPolyRef* polys, const int npath);
137 
140  inline const float* getPos() const { return m_pos; }
141 
144  inline const float* getTarget() const { return m_target; }
145 
148  inline dtPolyRef getFirstPoly() const { return m_npath ? m_path[0] : 0; }
149 
152  inline dtPolyRef getLastPoly() const { return m_npath ? m_path[m_npath - 1] : 0; }
153 
156  inline const dtPolyRef* getPath() const { return m_path; }
157 
160  inline int getPathCount() const { return m_npath; }
161 
162  inline void setEarlyReachTest(bool enable) { m_enableEarlyReach = enable; }
163 
164  inline float getSegmentAngle() const { return m_moveSegAngle; }
165  inline const float* getNextFixedCorner() const { return &m_nextExpectedCorner[0]; }
166  inline const float* getNextFixedCorner2() const { return &m_nextExpectedCorner2[0]; }
167  inline bool hasNextFixedCorner() const { return m_hasNextExpectedCorner; }
168  inline bool hasNextFixedCorner2() const { return m_hasNextExpectedCorner2; }
169  };
170 
171  int dtMergeCorridorStartMoved(dtPolyRef* path, const int npath, const int maxPath,
172  const dtPolyRef* visited, const int nvisited);
173 
174  int dtMergeCorridorEndMoved(dtPolyRef* path, const int npath, const int maxPath,
175  const dtPolyRef* visited, const int nvisited);
176 
177  int dtMergeCorridorStartShortcut(dtPolyRef* path, const int npath, const int maxPath,
178  const dtPolyRef* visited, const int nvisited);
179 
180 }
181 
182 #endif // DETOUTPATHCORRIDOR_H
Definition: DetourNavMeshQuery.h:323
Definition: DetourPathCorridor.h:34
dtPolyRef getFirstPoly() const
Definition: DetourPathCorridor.h:148
dtPolyRef getLastPoly() const
Definition: DetourPathCorridor.h:152
bool canMoveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRef *refs, const float *agentPos, float *startPos, float *endPos, dtNavMeshQuery *navquery) const
[UE4] check if offmesh connection can be traversed, but don't modify corridor yet
const float * getPos() const
Definition: DetourPathCorridor.h:140
bool optimizePathTopology(dtNavMeshQuery *navquery, const dtQueryFilter *filter)
bool isValid(const int maxLookAhead, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
bool init(const int maxPath)
void moveTargetPosition(const float *npos, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
void setCorridor(const float *target, const dtPolyRef *polys, const int npath)
int findCorners(float *cornerVerts, unsigned char *cornerFlags, dtPolyRef *cornerPolys, const int maxCorners, dtNavMeshQuery *navquery, const dtQueryFilter *filter, float pathOffsetDistance, float earlyReachDistance, bool bAllowEarlyReach=true)
void pruneOffmeshConenction(dtPolyRef offMeshConRef)
[UE4] remove offmesh connection from corridor
const float * getTarget() const
Definition: DetourPathCorridor.h:144
void reset(dtPolyRef ref, const float *pos)
int getPathCount() const
Definition: DetourPathCorridor.h:160
const dtPolyRef * getPath() const
Definition: DetourPathCorridor.h:156
bool optimizePathVisibility(const float *next, const float pathOptimizationRange, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
bool movePosition(const float *npos, dtNavMeshQuery *navquery, const dtQueryFilter *filter)
Definition: DetourNavMeshQuery.h:87
Type_uint64 dtPolyRef
Definition: DetourNavMesh.h:47
AtomsCore namespace.
Definition: Base64.h:13