TrinityCore
PathGenerator Class Reference

#include <PathGenerator.h>

Public Member Functions

 PathGenerator (WorldObject const *owner)
 
 ~PathGenerator ()
 
 PathGenerator (PathGenerator const &right)=delete
 
 PathGenerator (PathGenerator &&right)=delete
 
PathGeneratoroperator= (PathGenerator const &right)=delete
 
PathGeneratoroperator= (PathGenerator &&right)=delete
 
bool CalculatePath (float destX, float destY, float destZ, bool forceDest=false)
 
bool IsInvalidDestinationZ (WorldObject const *target) const
 
void SetUseStraightPath (bool useStraightPath)
 
void SetPathLengthLimit (float distance)
 
void SetUseRaycast (bool useRaycast)
 
G3D::Vector3 const & GetStartPosition () const
 
G3D::Vector3 const & GetEndPosition () const
 
G3D::Vector3 const & GetActualEndPosition () const
 
Movement::PointsArray const & GetPath () const
 
float GetPathLength () const
 
PathType GetPathType () const
 
void ShortenPathUntilDist (G3D::Vector3 const &point, float dist)
 

Private Member Functions

void SetStartPosition (G3D::Vector3 const &point)
 
void SetEndPosition (G3D::Vector3 const &point)
 
void SetActualEndPosition (G3D::Vector3 const &point)
 
void NormalizePath ()
 
void Clear ()
 
bool InRange (G3D::Vector3 const &p1, G3D::Vector3 const &p2, float r, float h) const
 
float Dist3DSqr (G3D::Vector3 const &p1, G3D::Vector3 const &p2) const
 
bool InRangeYZX (float const *v1, float const *v2, float r, float h) const
 
dtPolyRef GetPathPolyByPosition (dtPolyRef const *polyPath, uint32 polyPathSize, float const *Point, float *Distance=nullptr) const
 
dtPolyRef GetPolyByLocation (float const *Point, float *Distance) const
 
bool HaveTile (G3D::Vector3 const &p) const
 
void BuildPolyPath (G3D::Vector3 const &startPos, G3D::Vector3 const &endPos)
 
void BuildPointPath (float const *startPoint, float const *endPoint)
 
void BuildShortcut ()
 
NavTerrainFlag GetNavTerrain (float x, float y, float z) const
 
void CreateFilter ()
 
void UpdateFilter ()
 
uint32 FixupCorridor (dtPolyRef *path, uint32 npath, uint32 maxPath, dtPolyRef const *visited, uint32 nvisited)
 
bool GetSteerTarget (float const *startPos, float const *endPos, float minTargetDist, dtPolyRef const *path, uint32 pathSize, float *steerPos, unsigned char &steerPosFlag, dtPolyRef &steerPosRef)
 
dtStatus FindSmoothPath (float const *startPos, float const *endPos, dtPolyRef const *polyPath, uint32 polyPathSize, float *smoothPath, int *smoothPathSize, uint32 smoothPathMaxSize)
 
void AddFarFromPolyFlags (bool startFarFromPoly, bool endFarFromPoly)
 

Private Attributes

dtPolyRef _pathPolyRefs [MAX_PATH_LENGTH]
 
uint32 _polyLength
 
Movement::PointsArray _pathPoints
 
PathType _type
 
bool _useStraightPath
 
bool _forceDestination
 
uint32 _pointPathLimit
 
bool _useRaycast
 
G3D::Vector3 _startPosition
 
G3D::Vector3 _endPosition
 
G3D::Vector3 _actualEndPosition
 
WorldObject const *const _source
 
dtNavMesh const * _navMesh
 
dtNavMeshQuery const * _navMeshQuery
 
dtQueryFilter _filter
 

Detailed Description

Definition at line 55 of file PathGenerator.h.

Constructor & Destructor Documentation

◆ PathGenerator() [1/3]

PathGenerator::PathGenerator ( WorldObject const *  owner)
explicit

Definition at line 31 of file PathGenerator.cpp.

+ Here is the call graph for this function:

◆ ~PathGenerator()

PathGenerator::~PathGenerator ( )

Definition at line 52 of file PathGenerator.cpp.

+ Here is the call graph for this function:

◆ PathGenerator() [2/3]

PathGenerator::PathGenerator ( PathGenerator const &  right)
delete

◆ PathGenerator() [3/3]

PathGenerator::PathGenerator ( PathGenerator &&  right)
delete

Member Function Documentation

◆ AddFarFromPolyFlags()

void PathGenerator::AddFarFromPolyFlags ( bool  startFarFromPoly,
bool  endFarFromPoly 
)
private

Definition at line 1039 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ BuildPointPath()

void PathGenerator::BuildPointPath ( float const *  startPoint,
float const *  endPoint 
)
private
Todo:
check the exact cases

Definition at line 530 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildPolyPath()

void PathGenerator::BuildPolyPath ( G3D::Vector3 const &  startPos,
G3D::Vector3 const &  endPos 
)
private
Todo:
we can merge it with getPathPolyByPosition() loop
Todo:
play with the values here

Definition at line 160 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildShortcut()

void PathGenerator::BuildShortcut ( )
private

Definition at line 630 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculatePath()

bool PathGenerator::CalculatePath ( float  destX,
float  destY,
float  destZ,
bool  forceDest = false 
)

Definition at line 57 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Clear()

void PathGenerator::Clear ( )
inlineprivate

Definition at line 117 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ CreateFilter()

void PathGenerator::CreateFilter ( )
private

Definition at line 648 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Dist3DSqr()

float PathGenerator::Dist3DSqr ( G3D::Vector3 const &  p1,
G3D::Vector3 const &  p2 
) const
private

Definition at line 964 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ FindSmoothPath()

dtStatus PathGenerator::FindSmoothPath ( float const *  startPos,
float const *  endPos,
dtPolyRef const *  polyPath,
uint32  polyPathSize,
float *  smoothPath,
int *  smoothPathSize,
uint32  smoothPathMaxSize 
)
private

Definition at line 814 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixupCorridor()

uint32 PathGenerator::FixupCorridor ( dtPolyRef *  path,
uint32  npath,
uint32  maxPath,
dtPolyRef const *  visited,
uint32  nvisited 
)
private

Definition at line 732 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetActualEndPosition()

G3D::Vector3 const & PathGenerator::GetActualEndPosition ( ) const
inline

Definition at line 79 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ GetEndPosition()

G3D::Vector3 const & PathGenerator::GetEndPosition ( ) const
inline

Definition at line 78 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ GetNavTerrain()

NavTerrainFlag PathGenerator::GetNavTerrain ( float  x,
float  y,
float  z 
) const
private

Definition at line 700 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPath()

Movement::PointsArray const & PathGenerator::GetPath ( ) const
inline

Definition at line 81 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ GetPathLength()

float PathGenerator::GetPathLength ( ) const

Definition at line 969 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ GetPathPolyByPosition()

dtPolyRef PathGenerator::GetPathPolyByPosition ( dtPolyRef const *  polyPath,
uint32  polyPathSize,
float const *  Point,
float *  Distance = nullptr 
) const
private

Definition at line 94 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ GetPathType()

PathType PathGenerator::GetPathType ( ) const
inline

Definition at line 84 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ GetPolyByLocation()

dtPolyRef PathGenerator::GetPolyByLocation ( float const *  Point,
float *  Distance 
) const
private

Definition at line 125 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetStartPosition()

G3D::Vector3 const & PathGenerator::GetStartPosition ( ) const
inline

Definition at line 77 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ GetSteerTarget()

bool PathGenerator::GetSteerTarget ( float const *  startPos,
float const *  endPos,
float  minTargetDist,
dtPolyRef const *  path,
uint32  pathSize,
float *  steerPos,
unsigned char &  steerPosFlag,
dtPolyRef &  steerPosRef 
)
private

Definition at line 777 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HaveTile()

bool PathGenerator::HaveTile ( G3D::Vector3 const &  p) const
private

Workaround For some reason, often the tx and ty variables wont get a valid value Use this check to prevent getting negative tile coords and crashing on getTileAt

Definition at line 716 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ InRange()

bool PathGenerator::InRange ( G3D::Vector3 const &  p1,
G3D::Vector3 const &  p2,
float  r,
float  h 
) const
private

Definition at line 958 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ InRangeYZX()

bool PathGenerator::InRangeYZX ( float const *  v1,
float const *  v2,
float  r,
float  h 
) const
private

Definition at line 950 of file PathGenerator.cpp.

+ Here is the caller graph for this function:

◆ IsInvalidDestinationZ()

bool PathGenerator::IsInvalidDestinationZ ( WorldObject const *  target) const

Definition at line 1034 of file PathGenerator.cpp.

+ Here is the call graph for this function:

◆ NormalizePath()

void PathGenerator::NormalizePath ( )
private

Definition at line 624 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

PathGenerator & PathGenerator::operator= ( PathGenerator &&  right)
delete

◆ operator=() [2/2]

PathGenerator & PathGenerator::operator= ( PathGenerator const &  right)
delete

◆ SetActualEndPosition()

void PathGenerator::SetActualEndPosition ( G3D::Vector3 const &  point)
inlineprivate

Definition at line 114 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ SetEndPosition()

void PathGenerator::SetEndPosition ( G3D::Vector3 const &  point)
inlineprivate

Definition at line 113 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ SetPathLengthLimit()

void PathGenerator::SetPathLengthLimit ( float  distance)
inline

Definition at line 73 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ SetStartPosition()

void PathGenerator::SetStartPosition ( G3D::Vector3 const &  point)
inlineprivate

Definition at line 112 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ SetUseRaycast()

void PathGenerator::SetUseRaycast ( bool  useRaycast)
inline

Definition at line 74 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ SetUseStraightPath()

void PathGenerator::SetUseStraightPath ( bool  useStraightPath)
inline

Definition at line 72 of file PathGenerator.h.

+ Here is the caller graph for this function:

◆ ShortenPathUntilDist()

void PathGenerator::ShortenPathUntilDist ( G3D::Vector3 const &  point,
float  dist 
)

Definition at line 978 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateFilter()

void PathGenerator::UpdateFilter ( )
private

Definition at line 675 of file PathGenerator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _actualEndPosition

G3D::Vector3 PathGenerator::_actualEndPosition
private

Definition at line 104 of file PathGenerator.h.

◆ _endPosition

G3D::Vector3 PathGenerator::_endPosition
private

Definition at line 103 of file PathGenerator.h.

◆ _filter

dtQueryFilter PathGenerator::_filter
private

Definition at line 110 of file PathGenerator.h.

◆ _forceDestination

bool PathGenerator::_forceDestination
private

Definition at line 98 of file PathGenerator.h.

◆ _navMesh

dtNavMesh const* PathGenerator::_navMesh
private

Definition at line 107 of file PathGenerator.h.

◆ _navMeshQuery

dtNavMeshQuery const* PathGenerator::_navMeshQuery
private

Definition at line 108 of file PathGenerator.h.

◆ _pathPoints

Movement::PointsArray PathGenerator::_pathPoints
private

Definition at line 94 of file PathGenerator.h.

◆ _pathPolyRefs

dtPolyRef PathGenerator::_pathPolyRefs[MAX_PATH_LENGTH]
private

Definition at line 91 of file PathGenerator.h.

◆ _pointPathLimit

uint32 PathGenerator::_pointPathLimit
private

Definition at line 99 of file PathGenerator.h.

◆ _polyLength

uint32 PathGenerator::_polyLength
private

Definition at line 92 of file PathGenerator.h.

◆ _source

WorldObject const* const PathGenerator::_source
private

Definition at line 106 of file PathGenerator.h.

◆ _startPosition

G3D::Vector3 PathGenerator::_startPosition
private

Definition at line 102 of file PathGenerator.h.

◆ _type

PathType PathGenerator::_type
private

Definition at line 95 of file PathGenerator.h.

◆ _useRaycast

bool PathGenerator::_useRaycast
private

Definition at line 100 of file PathGenerator.h.

◆ _useStraightPath

bool PathGenerator::_useStraightPath
private

Definition at line 97 of file PathGenerator.h.


The documentation for this class was generated from the following files: