Pyrogenesis  trunk
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CCmpPathfinder Class Reference

Implementation of ICmpPathfinder. More...

#include <CCmpPathfinder_Common.h>

Inheritance diagram for CCmpPathfinder:
Inheritance graph
[legend]
Collaboration diagram for CCmpPathfinder:
Collaboration graph
[legend]

Public Member Functions

virtual int GetComponentTypeId () const
 
virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
template<typename S >
void SerializeCommon (S &serialize)
 
virtual void Serialize (ISerializer &serialize)
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
virtual pass_class_t GetPassabilityClass (const std::string &name) const
 Get the tag for a given passability class name. More...
 
virtual void GetPassabilityClasses (std::map< std::string, pass_class_t > &passClasses) const
 Get the list of all known passability classes. More...
 
virtual void GetPassabilityClasses (std::map< std::string, pass_class_t > &nonPathfindingPassClasses, std::map< std::string, pass_class_t > &pathfindingPassClasses) const
 Get the list of passability classes, separating pathfinding classes and others. More...
 
const PathfinderPassabilityGetPassabilityFromMask (pass_class_t passClass) const
 
virtual entity_pos_t GetClearance (pass_class_t passClass) const
 
virtual entity_pos_t GetMaximumClearance () const
 Get the larger clearance in all passability classes. More...
 
virtual const Grid< NavcellData > & GetPassabilityGrid ()
 
virtual const GridUpdateInformationGetDirtinessData () const
 Passes the lazily-stored dirtiness data collected from the obstruction manager during the previous grid update. More...
 
virtual Grid< u16ComputeShoreGrid (bool expandOnWater=false)
 Get a grid representing the distance to the shore of the terrain tile. More...
 
virtual void ComputePath (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass, WaypointPath &ret)
 Compute a tile-based path from the given point to the goal, and return the set of waypoints. More...
 
virtual u32 ComputePathAsync (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass, entity_id_t notify)
 Asynchronous version of ComputePath. More...
 
virtual void ComputeShortPath (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t clearance, entity_pos_t range, const PathGoal &goal, pass_class_t passClass, WaypointPath &ret)
 Compute a precise path from the given point to the goal, and return the set of waypoints. More...
 
virtual u32 ComputeShortPathAsync (entity_pos_t x0, entity_pos_t z0, entity_pos_t clearance, entity_pos_t range, const PathGoal &goal, pass_class_t passClass, bool avoidMovingUnits, entity_id_t controller, entity_id_t notify)
 Asynchronous version of ComputeShortPath (using ControlGroupObstructionFilter). More...
 
virtual void SetDebugPath (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass)
 If the debug overlay is enabled, render the path that will computed by ComputePath. More...
 
virtual void SetDebugOverlay (bool enabled)
 Toggle the storage and rendering of debug info. More...
 
virtual void SetHierDebugOverlay (bool enabled)
 Toggle the storage and rendering of debug info for the hierarchical pathfinder. More...
 
virtual void GetDebugData (u32 &steps, double &time, Grid< u8 > &grid) const
 Returns some stats about the last ComputePath. More...
 
virtual void SetAtlasOverlay (bool enable, pass_class_t passClass=0)
 Sets up the pathfinder passability overlay in Atlas. More...
 
virtual bool CheckMovement (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) const
 Check whether the given movement line is valid and doesn't hit any obstructions or impassable terrain. More...
 
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint) const
 Check whether a unit placed here is valid and doesn't hit any obstructions or impassable terrain. More...
 
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass) const
 Check whether a building placed here is valid and doesn't hit any obstructions or impassable terrain. More...
 
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement (const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) const
 Check whether a building placed here is valid and doesn't hit any obstructions or impassable terrain. More...
 
virtual void FinishAsyncRequests ()
 Finish computing asynchronous path requests and send the CMessagePathResult messages. More...
 
void ProcessLongRequests (const std::vector< AsyncLongPathRequest > &longRequests)
 
void ProcessShortRequests (const std::vector< AsyncShortPathRequest > &shortRequests)
 
virtual void ProcessSameTurnMoves ()
 Process moves during the same turn they were created in to improve responsiveness. More...
 
virtual void UpdateGrid ()
 Regenerates the grid based on the current obstruction list, if necessary. More...
 
void MinimalTerrainUpdate ()
 Updates the terrain-only grid without updating the dirtiness informations. More...
 
void TerrainUpdateHelper (bool expandPassability=true)
 Regenerates the terrain-only grid. More...
 
void RenderSubmit (SceneCollector &collector)
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual bool NewJSObject (ScriptInterface &scriptInterface, JS::MutableHandleObject out) const
 Returns false by default, indicating that a scripted wrapper of this IComponent is not supported. More...
 
virtual JS::Value GetJSInstance () const
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static u8 GetSerializationVersion ()
 

Public Attributes

std::map< std::string, pass_class_tm_PassClassMasks
 
std::vector< PathfinderPassabilitym_PassClasses
 
std::vector< AsyncLongPathRequestm_AsyncLongPathRequests
 
std::vector< AsyncShortPathRequestm_AsyncShortPathRequests
 
u32 m_NextAsyncTicket
 
u16 m_SameTurnMovesCount
 
u16 m_MapSize
 
Grid< NavcellData > * m_Grid
 
Grid< NavcellData > * m_TerrainOnlyGrid
 
GridUpdateInformation m_ObstructionsDirty
 
bool m_TerrainDirty
 
bool m_PreserveUpdateInformations
 
LongPathfinder m_LongPathfinder
 
u16 m_MaxSameTurnMoves
 
std::vector< EdgeedgesUnaligned
 
std::vector< EdgeAAedgesLeft
 
std::vector< EdgeAAedgesRight
 
std::vector< EdgeAAedgesBottom
 
std::vector< EdgeAAedgesTop
 
std::vector< Vertexvertexes
 
std::vector< Edgeedges
 
std::vector< SquareedgeSquares
 
bool m_DebugOverlay
 
std::vector< SOverlayLinem_DebugOverlayShortPathLines
 
AtlasOverlaym_AtlasOverlay
 

Detailed Description

Implementation of ICmpPathfinder.

Member Function Documentation

static IComponent* CCmpPathfinder::Allocate ( ScriptInterface ,
JS::HandleValue   
)
inlinestatic
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement ( const IObstructionTestFilter filter,
entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  a,
entity_pos_t  w,
entity_pos_t  h,
entity_id_t  id,
pass_class_t  passClass 
) const
virtual

Check whether a building placed here is valid and doesn't hit any obstructions or impassable terrain.

Returns
ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else a value describing the type of failure.

Implements ICmpPathfinder.

ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement ( const IObstructionTestFilter filter,
entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  a,
entity_pos_t  w,
entity_pos_t  h,
entity_id_t  id,
pass_class_t  passClass,
bool  onlyCenterPoint 
) const
virtual

Check whether a building placed here is valid and doesn't hit any obstructions or impassable terrain.

when onlyCenterPoint = true, only check the center tile of the building

Returns
ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else a value describing the type of failure.

Implements ICmpPathfinder.

bool CCmpPathfinder::CheckMovement ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  x1,
entity_pos_t  z1,
entity_pos_t  r,
pass_class_t  passClass 
) const
virtual

Check whether the given movement line is valid and doesn't hit any obstructions or impassable terrain.

Returns true if the movement is okay.

Implements ICmpPathfinder.

ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement ( const IObstructionTestFilter filter,
entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  r,
pass_class_t  passClass,
bool  onlyCenterPoint 
) const
virtual

Check whether a unit placed here is valid and doesn't hit any obstructions or impassable terrain.

When onlyCenterPoint = true, only check the center tile of the unit

Returns
ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else a value describing the type of failure.

Implements ICmpPathfinder.

static void CCmpPathfinder::ClassInit ( CComponentManager componentManager)
inlinestatic
virtual void CCmpPathfinder::ComputePath ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal goal,
pass_class_t  passClass,
WaypointPath ret 
)
inlinevirtual

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.

Implements ICmpPathfinder.

u32 CCmpPathfinder::ComputePathAsync ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal goal,
pass_class_t  passClass,
entity_id_t  notify 
)
virtual

Asynchronous version of ComputePath.

The result will be sent as CMessagePathResult to 'notify'. Returns a unique non-zero number, which will match the 'ticket' in the result, so callers can recognise each individual request they make.

Implements ICmpPathfinder.

Grid< u16 > CCmpPathfinder::ComputeShoreGrid ( bool  expandOnWater = false)
virtual

Get a grid representing the distance to the shore of the terrain tile.

Implements ICmpPathfinder.

void CCmpPathfinder::ComputeShortPath ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  clearance,
entity_pos_t  range,
const PathGoal goal,
pass_class_t  passClass,
WaypointPath ret 
)
virtual

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

The path is based on the full set of obstructions that pass the filter, such that a unit of clearance 'clearance' will be able to follow the path with no collisions. The path is restricted to a box of radius 'range' from the starting point.

Implements ICmpPathfinder.

u32 CCmpPathfinder::ComputeShortPathAsync ( entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  clearance,
entity_pos_t  range,
const PathGoal goal,
pass_class_t  passClass,
bool  avoidMovingUnits,
entity_id_t  group,
entity_id_t  notify 
)
virtual

Asynchronous version of ComputeShortPath (using ControlGroupObstructionFilter).

The result will be sent as CMessagePathResult to 'notify'. Returns a unique non-zero number, which will match the 'ticket' in the result, so callers can recognise each individual request they make.

Implements ICmpPathfinder.

static void CCmpPathfinder::Deallocate ( IComponent cmp)
inlinestatic
void CCmpPathfinder::Deinit ( )
virtual

Implements IComponent.

void CCmpPathfinder::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
virtual

Implements IComponent.

void CCmpPathfinder::FinishAsyncRequests ( )
virtual

Finish computing asynchronous path requests and send the CMessagePathResult messages.

Implements ICmpPathfinder.

virtual entity_pos_t CCmpPathfinder::GetClearance ( pass_class_t  passClass) const
inlinevirtual

Implements ICmpPathfinder.

virtual int CCmpPathfinder::GetComponentTypeId ( ) const
inlinevirtual

Implements IComponent.

virtual void CCmpPathfinder::GetDebugData ( u32 steps,
double &  time,
Grid< u8 > &  grid 
) const
inlinevirtual

Returns some stats about the last ComputePath.

Implements ICmpPathfinder.

const GridUpdateInformation & CCmpPathfinder::GetDirtinessData ( ) const
virtual

Passes the lazily-stored dirtiness data collected from the obstruction manager during the previous grid update.

Implements ICmpPathfinder.

virtual entity_pos_t CCmpPathfinder::GetMaximumClearance ( ) const
inlinevirtual

Get the larger clearance in all passability classes.

Implements ICmpPathfinder.

pass_class_t CCmpPathfinder::GetPassabilityClass ( const std::string &  name) const
virtual

Get the tag for a given passability class name.

Logs an error and returns something acceptable if the name is unrecognised.

Implements ICmpPathfinder.

void CCmpPathfinder::GetPassabilityClasses ( std::map< std::string, pass_class_t > &  passClasses) const
virtual

Get the list of all known passability classes.

Implements ICmpPathfinder.

void CCmpPathfinder::GetPassabilityClasses ( std::map< std::string, pass_class_t > &  nonPathfindingPassClasses,
std::map< std::string, pass_class_t > &  pathfindingPassClasses 
) const
virtual

Get the list of passability classes, separating pathfinding classes and others.

Implements ICmpPathfinder.

const PathfinderPassability * CCmpPathfinder::GetPassabilityFromMask ( pass_class_t  passClass) const
const Grid< NavcellData > & CCmpPathfinder::GetPassabilityGrid ( )
virtual

Implements ICmpPathfinder.

static std::string CCmpPathfinder::GetSchema ( )
inlinestatic
void CCmpPathfinder::HandleMessage ( const CMessage msg,
bool  global 
)
virtual

Reimplemented from IComponent.

void CCmpPathfinder::Init ( const CParamNode paramNode)
virtual

Implements IComponent.

void CCmpPathfinder::MinimalTerrainUpdate ( )

Updates the terrain-only grid without updating the dirtiness informations.

Useful for fast passability updates in Atlas.

void CCmpPathfinder::ProcessLongRequests ( const std::vector< AsyncLongPathRequest > &  longRequests)
void CCmpPathfinder::ProcessSameTurnMoves ( )
virtual

Process moves during the same turn they were created in to improve responsiveness.

Implements ICmpPathfinder.

void CCmpPathfinder::ProcessShortRequests ( const std::vector< AsyncShortPathRequest > &  shortRequests)
void CCmpPathfinder::RenderSubmit ( SceneCollector collector)
void CCmpPathfinder::Serialize ( ISerializer serialize)
virtual

Implements IComponent.

template<typename S >
void CCmpPathfinder::SerializeCommon ( S &  serialize)
void CCmpPathfinder::SetAtlasOverlay ( bool  enable,
pass_class_t  passClass = 0 
)
virtual

Sets up the pathfinder passability overlay in Atlas.

Implements ICmpPathfinder.

virtual void CCmpPathfinder::SetDebugOverlay ( bool  enabled)
inlinevirtual

Toggle the storage and rendering of debug info.

Implements ICmpPathfinder.

virtual void CCmpPathfinder::SetDebugPath ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal goal,
pass_class_t  passClass 
)
inlinevirtual

If the debug overlay is enabled, render the path that will computed by ComputePath.

Implements ICmpPathfinder.

virtual void CCmpPathfinder::SetHierDebugOverlay ( bool  enabled)
inlinevirtual

Toggle the storage and rendering of debug info for the hierarchical pathfinder.

Implements ICmpPathfinder.

void CCmpPathfinder::TerrainUpdateHelper ( bool  expandPassability = true)

Regenerates the terrain-only grid.

Atlas doesn't need to have passability cells expanded.

void CCmpPathfinder::UpdateGrid ( )
virtual

Regenerates the grid based on the current obstruction list, if necessary.

Implements ICmpPathfinder.

Member Data Documentation

std::vector<Edge> CCmpPathfinder::edges
std::vector<EdgeAA> CCmpPathfinder::edgesBottom
std::vector<EdgeAA> CCmpPathfinder::edgesLeft
std::vector<Square> CCmpPathfinder::edgeSquares
std::vector<EdgeAA> CCmpPathfinder::edgesRight
std::vector<EdgeAA> CCmpPathfinder::edgesTop
std::vector<Edge> CCmpPathfinder::edgesUnaligned
std::vector<AsyncLongPathRequest> CCmpPathfinder::m_AsyncLongPathRequests
std::vector<AsyncShortPathRequest> CCmpPathfinder::m_AsyncShortPathRequests
AtlasOverlay* CCmpPathfinder::m_AtlasOverlay
bool CCmpPathfinder::m_DebugOverlay
std::vector<SOverlayLine> CCmpPathfinder::m_DebugOverlayShortPathLines
Grid<NavcellData>* CCmpPathfinder::m_Grid
LongPathfinder CCmpPathfinder::m_LongPathfinder
u16 CCmpPathfinder::m_MapSize
u16 CCmpPathfinder::m_MaxSameTurnMoves
u32 CCmpPathfinder::m_NextAsyncTicket
GridUpdateInformation CCmpPathfinder::m_ObstructionsDirty
std::vector<PathfinderPassability> CCmpPathfinder::m_PassClasses
std::map<std::string, pass_class_t> CCmpPathfinder::m_PassClassMasks
bool CCmpPathfinder::m_PreserveUpdateInformations
u16 CCmpPathfinder::m_SameTurnMovesCount
bool CCmpPathfinder::m_TerrainDirty
Grid<NavcellData>* CCmpPathfinder::m_TerrainOnlyGrid
std::vector<Vertex> CCmpPathfinder::vertexes

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