Pyrogenesis  trunk
Classes | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
HierarchicalPathfinder Class Reference

#include <HierarchicalPathfinder.h>

Collaboration diagram for HierarchicalPathfinder:
Collaboration graph
[legend]

Classes

struct  Chunk
 
struct  RegionID
 

Public Member Functions

 HierarchicalPathfinder ()
 
 ~HierarchicalPathfinder ()
 
void SetDebugOverlay (bool enabled, const CSimContext *simContext)
 
void Recompute (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 > *grid, const Grid< u8 > &dirtinessGrid)
 
bool IsChunkDirty (int ci, int cj, const Grid< u8 > &dirtinessGrid) const
 
RegionID Get (u16 i, u16 j, pass_class_t passClass)
 
void MakeGoalReachable (u16 i0, u16 j0, PathGoal &goal, pass_class_t passClass)
 Updates goal so that it's guaranteed to be reachable from the navcell i0, j0 (which is assumed to be on a passable navcell). More...
 
void FindNearestPassableNavcell (u16 &i, u16 &j, pass_class_t passClass)
 Updates i, j (which is assumed to be an impassable navcell) to the nearest passable navcell. More...
 
Grid< u16GetConnectivityGrid (pass_class_t passClass)
 Generates the connectivity grid associated with the given pass_class. More...
 
pass_class_t GetPassabilityClass (const std::string &name) const
 

Public Attributes

std::vector< SOverlayLinem_DebugOverlayLines
 

Private Types

typedef std::map< RegionID, std::set< RegionID > > EdgesMap
 

Private Member Functions

void FindEdges (u8 ci, u8 cj, pass_class_t passClass, EdgesMap &edges)
 Find edges between regions in this chunk and the adjacent below/left chunks. More...
 
void FindReachableRegions (RegionID from, std::set< RegionID > &reachable, pass_class_t passClass)
 
void FindPassableRegions (std::set< RegionID > &regions, pass_class_t passClass)
 
void FindNearestNavcellInRegions (const std::set< RegionID > &regions, u16 &iGoal, u16 &jGoal, pass_class_t passClass)
 Updates iGoal and jGoal to the navcell that is the nearest to the initial goal coordinates, in one of the given regions. More...
 
ChunkGetChunk (u8 ci, u8 cj, pass_class_t passClass)
 
void FillRegionOnGrid (const RegionID &region, pass_class_t passClass, u16 value, Grid< u16 > &grid)
 
void AddDebugEdges (pass_class_t passClass)
 Debug visualisation of graph edges between regions. More...
 

Private Attributes

u16 m_W
 
u16 m_H
 
u16 m_ChunksW
 
u16 m_ChunksH
 
std::map< pass_class_t, std::vector< Chunk > > m_Chunks
 
std::map< pass_class_t, EdgesMapm_Edges
 
std::map< std::string, pass_class_tm_PassClassMasks
 
HierarchicalOverlaym_DebugOverlay
 
const CSimContextm_SimContext
 

Static Private Attributes

static const u8 CHUNK_SIZE = 96
 

Member Typedef Documentation

typedef std::map<RegionID, std::set<RegionID> > HierarchicalPathfinder::EdgesMap
private

Constructor & Destructor Documentation

HierarchicalPathfinder::HierarchicalPathfinder ( )
HierarchicalPathfinder::~HierarchicalPathfinder ( )

Member Function Documentation

void HierarchicalPathfinder::AddDebugEdges ( pass_class_t  passClass)
private

Debug visualisation of graph edges between regions.

void HierarchicalPathfinder::FillRegionOnGrid ( const RegionID region,
pass_class_t  passClass,
u16  value,
Grid< u16 > &  grid 
)
private
void HierarchicalPathfinder::FindEdges ( u8  ci,
u8  cj,
pass_class_t  passClass,
EdgesMap edges 
)
private

Find edges between regions in this chunk and the adjacent below/left chunks.

void HierarchicalPathfinder::FindNearestNavcellInRegions ( const std::set< RegionID > &  regions,
u16 iGoal,
u16 jGoal,
pass_class_t  passClass 
)
private

Updates iGoal and jGoal to the navcell that is the nearest to the initial goal coordinates, in one of the given regions.

(Assumes regions is non-empty.)

void HierarchicalPathfinder::FindNearestPassableNavcell ( u16 i,
u16 j,
pass_class_t  passClass 
)

Updates i, j (which is assumed to be an impassable navcell) to the nearest passable navcell.

void HierarchicalPathfinder::FindPassableRegions ( std::set< RegionID > &  regions,
pass_class_t  passClass 
)
private
void HierarchicalPathfinder::FindReachableRegions ( RegionID  from,
std::set< RegionID > &  reachable,
pass_class_t  passClass 
)
private
HierarchicalPathfinder::RegionID HierarchicalPathfinder::Get ( u16  i,
u16  j,
pass_class_t  passClass 
)
Chunk& HierarchicalPathfinder::GetChunk ( u8  ci,
u8  cj,
pass_class_t  passClass 
)
inlineprivate
Grid< u16 > HierarchicalPathfinder::GetConnectivityGrid ( pass_class_t  passClass)

Generates the connectivity grid associated with the given pass_class.

pass_class_t HierarchicalPathfinder::GetPassabilityClass ( const std::string &  name) const
inline
bool HierarchicalPathfinder::IsChunkDirty ( int  ci,
int  cj,
const Grid< u8 > &  dirtinessGrid 
) const
void HierarchicalPathfinder::MakeGoalReachable ( u16  i0,
u16  j0,
PathGoal goal,
pass_class_t  passClass 
)

Updates goal so that it's guaranteed to be reachable from the navcell i0, j0 (which is assumed to be on a passable navcell).

If the goal is not reachable, it is replaced with a point goal nearest to the goal center.

In the case of a non-point reachable goal, it is replaced with a point goal at the reachable navcell of the goal which is nearest to the starting navcell.

void HierarchicalPathfinder::Recompute ( Grid< NavcellData > *  passabilityGrid,
const std::map< std::string, pass_class_t > &  nonPathfindingPassClassMasks,
const std::map< std::string, pass_class_t > &  pathfindingPassClassMasks 
)
void HierarchicalPathfinder::SetDebugOverlay ( bool  enabled,
const CSimContext simContext 
)
void HierarchicalPathfinder::Update ( Grid< NavcellData > *  grid,
const Grid< u8 > &  dirtinessGrid 
)

Member Data Documentation

const u8 HierarchicalPathfinder::CHUNK_SIZE = 96
staticprivate
std::map<pass_class_t, std::vector<Chunk> > HierarchicalPathfinder::m_Chunks
private
u16 HierarchicalPathfinder::m_ChunksH
private
u16 HierarchicalPathfinder::m_ChunksW
private
HierarchicalOverlay* HierarchicalPathfinder::m_DebugOverlay
private
std::vector<SOverlayLine> HierarchicalPathfinder::m_DebugOverlayLines
std::map<pass_class_t, EdgesMap> HierarchicalPathfinder::m_Edges
private
u16 HierarchicalPathfinder::m_H
private
std::map<std::string, pass_class_t> HierarchicalPathfinder::m_PassClassMasks
private
const CSimContext* HierarchicalPathfinder::m_SimContext
private
u16 HierarchicalPathfinder::m_W
private

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