Planeshift

DetourPathCorridor.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2009-2010 Mikko Mononen [email protected]
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 // Permission is granted to anyone to use this software for any purpose,
00008 // including commercial applications, and to alter it and redistribute it
00009 // freely, subject to the following restrictions:
00010 // 1. The origin of this software must not be misrepresented; you must not
00011 //    claim that you wrote the original software. If you use this software
00012 //    in a product, an acknowledgment in the product documentation would be
00013 //    appreciated but is not required.
00014 // 2. Altered source versions must be plainly marked as such, and must not be
00015 //    misrepresented as being the original software.
00016 // 3. This notice may not be removed or altered from any source distribution.
00017 //
00018 
00019 #ifndef DETOUTPATHCORRIDOR_H
00020 #define DETOUTPATHCORRIDOR_H
00021 
00022 #include "DetourNavMeshQuery.h"
00023 
00026 class dtPathCorridor
00027 {
00028         float m_pos[3];
00029         float m_target[3];
00030         
00031         dtPolyRef* m_path;
00032         int m_npath;
00033         int m_maxPath;
00034         
00035 public:
00036         dtPathCorridor();
00037         ~dtPathCorridor();
00038         
00042         bool init(const int maxPath);
00043         
00047         void reset(dtPolyRef ref, const float* pos);
00048         
00058         int findCorners(float* cornerVerts, unsigned char* cornerFlags,
00059                                         dtPolyRef* cornerPolys, const int maxCorners,
00060                                         dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00061         
00067         void optimizePathVisibility(const float* next, const float pathOptimizationRange,
00068                                                                 dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00069         
00073         bool optimizePathTopology(dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00074         
00075         bool moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRef* refs,
00076                                                                    float* startPos, float* endPos,
00077                                                                    dtNavMeshQuery* navquery);
00078 
00079         bool fixPathStart(dtPolyRef safeRef, const float* safePos);
00080 
00081         bool trimInvalidPath(dtPolyRef safeRef, const float* safePos,
00082                                                  dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00083         
00088         bool isValid(const int maxLookAhead, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00089         
00095         void movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00096 
00102         void moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
00103         
00108         void setCorridor(const float* target, const dtPolyRef* polys, const int npath);
00109         
00112         inline const float* getPos() const { return m_pos; }
00113 
00116         inline const float* getTarget() const { return m_target; }
00117         
00120         inline dtPolyRef getFirstPoly() const { return m_npath ? m_path[0] : 0; }
00121 
00124         inline dtPolyRef getLastPoly() const { return m_npath ? m_path[m_npath-1] : 0; }
00125         
00128         inline const dtPolyRef* getPath() const { return m_path; }
00129 
00132         inline int getPathCount() const { return m_npath; }     
00133 };
00134 
00135 int dtMergeCorridorStartMoved(dtPolyRef* path, const int npath, const int maxPath,
00136                                                           const dtPolyRef* visited, const int nvisited);
00137 
00138 int dtMergeCorridorEndMoved(dtPolyRef* path, const int npath, const int maxPath,
00139                                                         const dtPolyRef* visited, const int nvisited);
00140 
00141 int dtMergeCorridorStartShortcut(dtPolyRef* path, const int npath, const int maxPath,
00142                                                                  const dtPolyRef* visited, const int nvisited);
00143 
00144 #endif // DETOUTPATHCORRIDOR_H