Pyrogenesis  trunk
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
LongPathfinder Class Reference

#include <LongPathfinder.h>

Collaboration diagram for LongPathfinder:
Collaboration graph
[legend]

Public Member Functions

 LongPathfinder ()
 
 ~LongPathfinder ()
 
void SetDebugOverlay (bool enabled)
 
void SetHierDebugOverlay (bool enabled, const CSimContext *simContext)
 
void SetDebugPath (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass)
 
void Reload (Grid< NavcellData > *passabilityGrid, const std::map< std::string, pass_class_t > &nonPathfindingPassClassMasks, const std::map< std::string, pass_class_t > &pathfindingPassClassMasks)
 
void Update (Grid< NavcellData > *passabilityGrid, const Grid< u8 > &dirtinessGrid)
 
void HierarchicalRenderSubmit (SceneCollector &collector)
 
void ComputePath (entity_pos_t x0, entity_pos_t z0, const PathGoal &origGoal, pass_class_t passClass, WaypointPath &path)
 Compute a tile-based path from the given point to the goal, and return the set of waypoints. More...
 
void ComputePath (entity_pos_t x0, entity_pos_t z0, const PathGoal &origGoal, pass_class_t passClass, std::vector< CircularRegion > excludedRegions, WaypointPath &path)
 Compute a tile-based path from the given point to the goal, excluding the regions specified in excludedRegions (which are treated as impassable) and return the set of waypoints. More...
 
Grid< u16GetConnectivityGrid (pass_class_t passClass)
 
void GetDebugData (u32 &steps, double &time, Grid< u8 > &grid) const
 

Public Attributes

Grid< NavcellData > * m_Grid
 
u16 m_GridSize
 
LongOverlaym_DebugOverlay
 
PathfindTileGridm_DebugGrid
 
u32 m_DebugSteps
 
double m_DebugTime
 
PathGoal m_DebugGoal
 
WaypointPathm_DebugPath
 
pass_class_t m_DebugPassClass
 

Private Member Functions

PathCost CalculateHeuristic (int i, int j, int iGoal, int jGoal)
 
void ProcessNeighbour (int pi, int pj, int i, int j, PathCost pg, PathfinderState &state)
 
void AddJumpedHoriz (int i, int j, int di, PathCost g, PathfinderState &state, bool detectGoal)
 JPS algorithm helper functions. More...
 
int HasJumpedHoriz (int i, int j, int di, PathfinderState &state, bool detectGoal)
 
void AddJumpedVert (int i, int j, int dj, PathCost g, PathfinderState &state, bool detectGoal)
 
int HasJumpedVert (int i, int j, int dj, PathfinderState &state, bool detectGoal)
 
void AddJumpedDiag (int i, int j, int di, int dj, PathCost g, PathfinderState &state)
 
void ComputeJPSPath (entity_pos_t x0, entity_pos_t z0, const PathGoal &origGoal, pass_class_t passClass, WaypointPath &path)
 See LongPathfinder.cpp for implementation details TODO: cleanup documentation. More...
 
void GetDebugDataJPS (u32 &steps, double &time, Grid< u8 > &grid) const
 
void ImprovePathWaypoints (WaypointPath &path, pass_class_t passClass, entity_pos_t maxDist, entity_pos_t x0, entity_pos_t z0)
 Given a path with an arbitrary collection of waypoints, updates the waypoints to be nicer. More...
 
void GenerateSpecialMap (pass_class_t passClass, std::vector< CircularRegion > excludedRegions)
 Generate a passability map, stored in the 16th bit of navcells, based on passClass, but with a set of impassable circular regions. More...
 

Private Attributes

bool m_UseJPSCache
 
std::map< pass_class_t, shared_ptr< JumpPointCache > > m_JumpPointCache
 
HierarchicalPathfinder m_PathfinderHier
 

Constructor & Destructor Documentation

LongPathfinder::LongPathfinder ( )
LongPathfinder::~LongPathfinder ( )

Member Function Documentation

void LongPathfinder::AddJumpedDiag ( int  i,
int  j,
int  di,
int  dj,
PathCost  g,
PathfinderState state 
)
private
void LongPathfinder::AddJumpedHoriz ( int  i,
int  j,
int  di,
PathCost  g,
PathfinderState state,
bool  detectGoal 
)
private

JPS algorithm helper functions.

Parameters
detectGoalis not used if m_UseJPSCache is true
void LongPathfinder::AddJumpedVert ( int  i,
int  j,
int  dj,
PathCost  g,
PathfinderState state,
bool  detectGoal 
)
private
PathCost LongPathfinder::CalculateHeuristic ( int  i,
int  j,
int  iGoal,
int  jGoal 
)
private
void LongPathfinder::ComputeJPSPath ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal origGoal,
pass_class_t  passClass,
WaypointPath path 
)
private

See LongPathfinder.cpp for implementation details TODO: cleanup documentation.

void LongPathfinder::ComputePath ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal origGoal,
pass_class_t  passClass,
WaypointPath path 
)
inline

Compute a tile-based path from the given point to the goal, and return the set of waypoints.

The waypoints correspond to the centers of horizontally/vertically adjacent tiles along the path.

void LongPathfinder::ComputePath ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal origGoal,
pass_class_t  passClass,
std::vector< CircularRegion excludedRegions,
WaypointPath path 
)

Compute a tile-based path from the given point to the goal, excluding the regions specified in excludedRegions (which are treated as impassable) and return the set of waypoints.

The waypoints correspond to the centers of horizontally/vertically adjacent tiles along the path.

void LongPathfinder::GenerateSpecialMap ( pass_class_t  passClass,
std::vector< CircularRegion excludedRegions 
)
private

Generate a passability map, stored in the 16th bit of navcells, based on passClass, but with a set of impassable circular regions.

Grid<u16> LongPathfinder::GetConnectivityGrid ( pass_class_t  passClass)
inline
void LongPathfinder::GetDebugData ( u32 steps,
double &  time,
Grid< u8 > &  grid 
) const
inline
void LongPathfinder::GetDebugDataJPS ( u32 steps,
double &  time,
Grid< u8 > &  grid 
) const
private
int LongPathfinder::HasJumpedHoriz ( int  i,
int  j,
int  di,
PathfinderState state,
bool  detectGoal 
)
private
int LongPathfinder::HasJumpedVert ( int  i,
int  j,
int  dj,
PathfinderState state,
bool  detectGoal 
)
private
void LongPathfinder::HierarchicalRenderSubmit ( SceneCollector collector)
inline
void LongPathfinder::ImprovePathWaypoints ( WaypointPath path,
pass_class_t  passClass,
entity_pos_t  maxDist,
entity_pos_t  x0,
entity_pos_t  z0 
)
private

Given a path with an arbitrary collection of waypoints, updates the waypoints to be nicer.

Calls "Testline" between waypoints so that bended paths can become straight if there's nothing in between (this happens because A* is 8-direction, and the map isn't actually a grid). If

Parameters
maxDistis non-zero, path waypoints will be espaced by at most
maxDist.In that case the distance between (x0, z0) and the first waypoint will also be made less than maxDist.
void LongPathfinder::ProcessNeighbour ( int  pi,
int  pj,
int  i,
int  j,
PathCost  pg,
PathfinderState state 
)
private
void LongPathfinder::Reload ( Grid< NavcellData > *  passabilityGrid,
const std::map< std::string, pass_class_t > &  nonPathfindingPassClassMasks,
const std::map< std::string, pass_class_t > &  pathfindingPassClassMasks 
)
inline
void LongPathfinder::SetDebugOverlay ( bool  enabled)
void LongPathfinder::SetDebugPath ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal goal,
pass_class_t  passClass 
)
inline
void LongPathfinder::SetHierDebugOverlay ( bool  enabled,
const CSimContext simContext 
)
inline
void LongPathfinder::Update ( Grid< NavcellData > *  passabilityGrid,
const Grid< u8 > &  dirtinessGrid 
)
inline

Member Data Documentation

PathGoal LongPathfinder::m_DebugGoal
PathfindTileGrid* LongPathfinder::m_DebugGrid
LongOverlay* LongPathfinder::m_DebugOverlay
pass_class_t LongPathfinder::m_DebugPassClass
WaypointPath* LongPathfinder::m_DebugPath
u32 LongPathfinder::m_DebugSteps
double LongPathfinder::m_DebugTime
Grid<NavcellData>* LongPathfinder::m_Grid
u16 LongPathfinder::m_GridSize
std::map<pass_class_t, shared_ptr<JumpPointCache> > LongPathfinder::m_JumpPointCache
private
HierarchicalPathfinder LongPathfinder::m_PathfinderHier
private
bool LongPathfinder::m_UseJPSCache
private

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