AzerothCore 3.3.5a
OpenSource WoW Emulator
|
#include "PathGenerator.h"
Public Member Functions | |
PathGenerator (WorldObject const *owner) | |
~PathGenerator () | |
bool | CalculatePath (float destX, float destY, float destZ, bool forceDest=false) |
bool | CalculatePath (float x, float y, float z, float destX, float destY, float destZ, bool forceDest) |
bool | IsInvalidDestinationZ (Unit const *target) const |
bool | IsWalkableClimb (float const *v1, float const *v2) const |
bool | IsWalkableClimb (float x, float y, float z, float destX, float destY, float destZ) const |
bool | IsWaterPath (Movement::PointsArray pathPoints) const |
bool | IsSwimmableSegment (float const *v1, float const *v2, bool checkSwim=true) const |
predict if a certain segment is underwater and the unit can swim Must only be used for very short segments since this check doesn't work on long paths that alternate terrain and water. More... | |
bool | IsSwimmableSegment (float x, float y, float z, float destX, float destY, float destZ, bool checkSwim=true) const |
predict if a certain segment is underwater and the unit can swim Must only be used for very short segments since this check doesn't work on long paths that alternate terrain and water. More... | |
void | SetSlopeCheck (bool checkSlope) |
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 |
PathType | GetPathType () const |
void | ShortenPathUntilDist (G3D::Vector3 const &point, float dist) |
float | getPathLength () const |
void | Clear () |
Static Public Member Functions | |
static bool | IsWalkableClimb (float x, float y, float z, float destX, float destY, float destZ, float sourceHeight) |
Check if a slope can be climbed based on source height This method is meant for short distances or linear paths. More... | |
static float | GetRequiredHeightToClimb (float x, float y, float z, float destX, float destY, float destZ, float sourceHeight) |
Return the height of a slope that can be climbed based on source height This method is meant for short distances or linear paths. More... | |
Private Member Functions | |
void | SetStartPosition (G3D::Vector3 const &point) |
void | SetEndPosition (G3D::Vector3 const &point) |
void | SetActualEndPosition (G3D::Vector3 const &point) |
void | NormalizePath () |
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 () |
NavTerrain | 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 |
bool | _slopeCheck |
uint32 | _pointPathLimit |
bool | _useRaycast |
G3D::Vector3 | _startPosition |
G3D::Vector3 | _endPosition |
G3D::Vector3 | _actualEndPosition |
WorldObject const *const | _source |
dtNavMesh const * | _navMesh |
dtNavMeshQuery const * | _navMeshQuery |
dtQueryFilterExt | _filter |
|
explicit |
References _navMesh, _navMeshQuery, _pathPolyRefs, _source, CreateFilter(), MMAP::MMapFactory::createOrGetMMapMgr(), WorldObject::GetInstanceId(), WorldLocation::GetMapId(), MMAP::MMapMgr::GetNavMesh(), and MMAP::MMapMgr::GetNavMeshQuery().
PathGenerator::~PathGenerator | ( | ) |
|
private |
References _type, PATHFIND_FARFROMPOLY_END, and PATHFIND_FARFROMPOLY_START.
Referenced by BuildPolyPath().
|
private |
References _forceDestination, _navMeshQuery, _pathPoints, _pathPolyRefs, _pointPathLimit, _polyLength, _source, _type, _useRaycast, _useStraightPath, BuildShortcut(), Dist3DSqr(), FindSmoothPath(), GetActualEndPosition(), GetEndPosition(), Object::GetGUID(), GetStartPosition(), InRange(), LOG_ERROR, MAX_POINT_PATH_LENGTH, NormalizePath(), PATHFIND_NOPATH, PATHFIND_NORMAL, PATHFIND_NOT_USING_PATH, PATHFIND_SHORT, SetActualEndPosition(), ObjectGuid::ToString(), and VERTEX_SIZE.
Referenced by BuildPolyPath().
|
private |
References _filter, _navMeshQuery, _pathPoints, _pathPolyRefs, _polyLength, _source, _type, _useRaycast, AddFarFromPolyFlags(), BuildPointPath(), BuildShortcut(), Creature::CanFly(), Creature::CanSwim(), Clear(), WorldObject::GetCollisionHeight(), Object::GetGUID(), Map::GetLiquidData(), WorldObject::GetMap(), WorldObject::GetPhaseMask(), GetPolyByLocation(), GetStartPosition(), INVALID_POLYREF, IsWaterPath(), LIQUID_MAP_UNDER_WATER, LOG_ERROR, MAP_ALL_LIQUIDS, MAP_LIQUID_STATUS_IN_CONTACT, MAX_PATH_LENGTH, NormalizePath(), PATHFIND_INCOMPLETE, PATHFIND_NOPATH, PATHFIND_NORMAL, PATHFIND_NOT_USING_PATH, SetActualEndPosition(), LiquidData::Status, Object::ToCreature(), ObjectGuid::ToString(), Object::ToUnit(), and VERTEX_SIZE.
Referenced by CalculatePath().
|
private |
References _pathPoints, _type, Clear(), GetActualEndPosition(), GetStartPosition(), NormalizePath(), and PATHFIND_SHORTCUT.
Referenced by BuildPointPath(), BuildPolyPath(), and CalculatePath().
bool PathGenerator::CalculatePath | ( | float | destX, |
float | destY, | ||
float | destZ, | ||
bool | forceDest = false |
||
) |
References _source, CalculatePath(), and Position::GetPosition().
Referenced by CalculatePath(), Map::CheckCollisionAndGetValidCoords(), mmaps_commandscript::HandleMmapPathCommand(), mmaps_commandscript::HandleMmapTestArea(), and Movement::MoveSplineInit::MoveTo().
bool PathGenerator::CalculatePath | ( | float | x, |
float | y, | ||
float | z, | ||
float | destX, | ||
float | destY, | ||
float | destZ, | ||
bool | forceDest | ||
) |
References _forceDestination, _navMesh, _navMeshQuery, _source, _type, BuildPolyPath(), BuildShortcut(), Unit::HasUnitState(), HaveTile(), Acore::IsValidMapCoord(), METRIC_DETAILED_EVENT, PATHFIND_NORMAL, PATHFIND_NOT_USING_PATH, SetEndPosition(), SetStartPosition(), Object::ToUnit(), UNIT_STATE_IGNORE_PATHFINDING, and UpdateFilter().
|
inline |
References _pathPoints, and _polyLength.
Referenced by BuildPolyPath(), and BuildShortcut().
|
private |
References _filter, _source, Creature::CanEnterWater(), Creature::CanWalk(), Object::IsCreature(), NAV_GROUND, NAV_MAGMA, NAV_WATER, and UpdateFilter().
Referenced by PathGenerator().
|
private |
Referenced by BuildPointPath().
|
private |
References _filter, _navMesh, _navMeshQuery, _slopeCheck, _source, FixupCorridor(), Object::GetGUID(), GetPathType(), GetSteerTarget(), InRangeYZX(), INVALID_POLYREF, IsSwimmableSegment(), IsWalkableClimb(), LOG_DEBUG, MAX_PATH_LENGTH, MAX_POINT_PATH_LENGTH, PATHFIND_NOT_USING_PATH, SMOOTH_PATH_SLOP, SMOOTH_PATH_STEP_SIZE, ObjectGuid::ToString(), and VERTEX_SIZE.
Referenced by BuildPointPath().
|
private |
Referenced by FindSmoothPath().
|
inline |
References _actualEndPosition.
Referenced by BuildPointPath(), BuildShortcut(), mmaps_commandscript::HandleMmapPathCommand(), IsInvalidDestinationZ(), and MotionMaster::MoveCharge().
|
inline |
References _endPosition.
Referenced by BuildPointPath(), and mmaps_commandscript::HandleMmapPathCommand().
|
private |
References _source, LiquidData::Flags, WorldObject::GetCollisionHeight(), Map::GetLiquidData(), WorldObject::GetMap(), WorldObject::GetPhaseMask(), LIQUID_MAP_NO_WATER, MAP_ALL_LIQUIDS, MAP_LIQUID_TYPE_MAGMA, MAP_LIQUID_TYPE_OCEAN, MAP_LIQUID_TYPE_SLIME, MAP_LIQUID_TYPE_WATER, NAV_GROUND, NAV_MAGMA, NAV_WATER, and LiquidData::Status.
Referenced by IsWaterPath(), and UpdateFilter().
|
inline |
|
inline |
References _pathPoints, and _startPosition.
|
private |
References _navMeshQuery, INVALID_POLYREF, and VERTEX_SIZE.
Referenced by GetPolyByLocation().
|
inline |
References _type.
Referenced by Map::CheckCollisionAndGetValidCoords(), FindSmoothPath(), mmaps_commandscript::HandleMmapPathCommand(), Movement::MoveSplineInit::MoveTo(), and ShortenPathUntilDist().
|
private |
References _filter, _navMeshQuery, _pathPolyRefs, _polyLength, GetPathPolyByPosition(), INVALID_POLYREF, and VERTEX_SIZE.
Referenced by BuildPolyPath().
|
static |
Return the height of a slope that can be climbed based on source height This method is meant for short distances or linear paths.
x | start x coord |
y | start y coord |
z | start z coord |
destX | destination x coord |
destY | destination y coord |
destZ | destination z coord |
sourceHeight | height of the source |
References getSlopeAngleAbs().
Referenced by IsWalkableClimb().
|
inline |
References _startPosition.
Referenced by BuildPointPath(), BuildPolyPath(), BuildShortcut(), Map::CanReachPositionAndGetValidCoords(), and mmaps_commandscript::HandleMmapPathCommand().
|
private |
References _navMeshQuery, InRangeYZX(), and VERTEX_SIZE.
Referenced by FindSmoothPath().
|
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
References _navMesh, and VERTEX_SIZE.
Referenced by CalculatePath().
|
private |
Referenced by BuildPointPath().
|
private |
Referenced by FindSmoothPath(), and GetSteerTarget().
bool PathGenerator::IsInvalidDestinationZ | ( | Unit const * | target | ) | const |
References GetActualEndPosition(), and Position::GetPositionZ().
bool PathGenerator::IsSwimmableSegment | ( | float const * | v1, |
float const * | v2, | ||
bool | checkSwim = true |
||
) | const |
predict if a certain segment is underwater and the unit can swim Must only be used for very short segments since this check doesn't work on long paths that alternate terrain and water.
v1 | |
v2 |
References IsSwimmableSegment().
Referenced by FindSmoothPath(), IsSwimmableSegment(), and ShortenPathUntilDist().
bool PathGenerator::IsSwimmableSegment | ( | float | x, |
float | y, | ||
float | z, | ||
float | destX, | ||
float | destY, | ||
float | destZ, | ||
bool | checkSwim = true |
||
) | const |
predict if a certain segment is underwater and the unit can swim Must only be used for very short segments since this check doesn't work on long paths that alternate terrain and water.
x | |
y | |
z | |
destX | |
destY | |
destZ | |
checkSwim | also check if the unit can swim |
References _source, Creature::CanSwim(), WorldObject::GetCollisionHeight(), WorldObject::GetMap(), WorldObject::GetPhaseMask(), Map::IsInWater(), and Object::ToCreature().
bool PathGenerator::IsWalkableClimb | ( | float const * | v1, |
float const * | v2 | ||
) | const |
References IsWalkableClimb().
Referenced by Map::CanReachPositionAndGetValidCoords(), FindSmoothPath(), IsWalkableClimb(), and ShortenPathUntilDist().
bool PathGenerator::IsWalkableClimb | ( | float | x, |
float | y, | ||
float | z, | ||
float | destX, | ||
float | destY, | ||
float | destZ | ||
) | const |
References _source, WorldObject::GetCollisionHeight(), and IsWalkableClimb().
|
static |
Check if a slope can be climbed based on source height This method is meant for short distances or linear paths.
x | start x coord |
y | start y coord |
z | start z coord |
destX | destination x coord |
destY | destination y coord |
destZ | destination z coord |
sourceHeight | height of the source |
References GetRequiredHeightToClimb().
bool PathGenerator::IsWaterPath | ( | Movement::PointsArray | pathPoints | ) | const |
References GetNavTerrain(), NAV_MAGMA, and NAV_WATER.
Referenced by BuildPolyPath().
|
private |
References _pathPoints, _source, and WorldObject::UpdateAllowedPositionZ().
Referenced by BuildPointPath(), BuildPolyPath(), and BuildShortcut().
|
inlineprivate |
References _actualEndPosition.
Referenced by BuildPointPath(), and BuildPolyPath().
|
inlineprivate |
|
inline |
References _pointPathLimit, MAX_POINT_PATH_LENGTH, and SMOOTH_PATH_STEP_SIZE.
|
inline |
References _slopeCheck.
|
inlineprivate |
|
inline |
References _useRaycast.
Referenced by Map::CheckCollisionAndGetValidCoords(), and mmaps_commandscript::HandleMmapPathCommand().
|
inline |
References _useStraightPath.
Referenced by mmaps_commandscript::HandleMmapPathCommand().
void PathGenerator::ShortenPathUntilDist | ( | G3D::Vector3 const & | point, |
float | dist | ||
) |
References _pathPoints, _slopeCheck, _source, WorldObject::GetCollisionHeight(), WorldObject::GetHitSpherePointFor(), WorldObject::GetMap(), GetPathType(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Map::isInLineOfSight(), IsSwimmableSegment(), IsWalkableClimb(), LINEOFSIGHT_ALL_CHECKS, LOG_ERROR, VMAP::Nothing, PATHFIND_BLANK, and PATHFIND_NOT_USING_PATH.
|
private |
References _filter, _source, GetNavTerrain(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), and Object::ToUnit().
Referenced by CalculatePath(), and CreateFilter().
|
private |
Referenced by GetActualEndPosition(), SetActualEndPosition(), and SetEndPosition().
|
private |
Referenced by GetEndPosition(), and SetEndPosition().
|
private |
Referenced by BuildPolyPath(), CreateFilter(), FindSmoothPath(), GetPolyByLocation(), and UpdateFilter().
|
private |
Referenced by BuildPointPath(), and CalculatePath().
|
private |
Referenced by CalculatePath(), FindSmoothPath(), HaveTile(), and PathGenerator().
|
private |
|
private |
Referenced by BuildPointPath(), BuildPolyPath(), BuildShortcut(), Clear(), GetPath(), getPathLength(), NormalizePath(), and ShortenPathUntilDist().
|
private |
Referenced by BuildPointPath(), BuildPolyPath(), GetPolyByLocation(), and PathGenerator().
|
private |
Referenced by BuildPointPath(), and SetPathLengthLimit().
|
private |
Referenced by BuildPointPath(), BuildPolyPath(), Clear(), and GetPolyByLocation().
|
private |
Referenced by FindSmoothPath(), SetSlopeCheck(), and ShortenPathUntilDist().
|
private |
|
private |
Referenced by getPathLength(), GetStartPosition(), and SetStartPosition().
|
private |
Referenced by AddFarFromPolyFlags(), BuildPointPath(), BuildPolyPath(), BuildShortcut(), CalculatePath(), and GetPathType().
|
private |
Referenced by BuildPointPath(), BuildPolyPath(), and SetUseRaycast().
|
private |
Referenced by BuildPointPath(), and SetUseStraightPath().