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

Implementation of ICmpPathfinder. More...

#include <CCmpPathfinder_Common.h>

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

Classes

class  PathRequests
 

Public Member Functions

 ~CCmpPathfinder ()
 
int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
template<typename S >
void SerializeCommon (S &serialize)
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
pass_class_t GetPassabilityClass (const std::string &name) const override
 Get the tag for a given passability class name. More...
 
void GetPassabilityClasses (std::map< std::string, pass_class_t > &passClasses) const override
 Get the list of all known passability classes. More...
 
void GetPassabilityClasses (std::map< std::string, pass_class_t > &nonPathfindingPassClasses, std::map< std::string, pass_class_t > &pathfindingPassClasses) const override
 Get the list of passability classes, separating pathfinding classes and others. More...
 
const PathfinderPassabilityGetPassabilityFromMask (pass_class_t passClass) const
 
entity_pos_t GetClearance (pass_class_t passClass) const override
 
entity_pos_t GetMaximumClearance () const override
 Get the larger clearance in all passability classes. More...
 
const Grid< NavcellData > & GetPassabilityGrid () override
 
const GridUpdateInformationGetAIPathfinderDirtinessInformation () const override
 Get the accumulated dirtiness information since the last time the AI accessed and flushed it. More...
 
void FlushAIPathfinderDirtinessInformation () override
 
Grid< u16ComputeShoreGrid (bool expandOnWater=false) override
 Get a grid representing the distance to the shore of the terrain tile. More...
 
void ComputePathImmediate (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass, WaypointPath &ret) const override
 
u32 ComputePathAsync (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass, entity_id_t notify) override
 Asynchronous version of ComputePath. More...
 
WaypointPath ComputeShortPathImmediate (const ShortPathRequest &request) const override
 
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) override
 Request a short path computation, asynchronously. More...
 
bool IsGoalReachable (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass) override
 
void SetDebugPath (entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass) override
 If the debug overlay is enabled, render the path that will computed by ComputePath. More...
 
void SetDebugOverlay (bool enabled) override
 Toggle the storage and rendering of debug info. More...
 
void SetHierDebugOverlay (bool enabled) override
 Toggle the storage and rendering of debug info for the hierarchical pathfinder. More...
 
void GetDebugData (u32 &steps, double &time, Grid< u8 > &grid) const override
 Returns some stats about the last ComputePath. More...
 
void SetAtlasOverlay (bool enable, pass_class_t passClass=0) override
 Sets up the pathfinder passability overlay in Atlas. More...
 
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 override
 Check whether the given movement line is valid and doesn't hit any obstructions or impassable terrain. More...
 
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 override
 Check whether a unit placed here is valid and doesn't hit any obstructions or impassable terrain. More...
 
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 override
 Check whether a building placed here is valid and doesn't hit any obstructions or impassable terrain. More...
 
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 override
 Check whether a building placed here is valid and doesn't hit any obstructions or impassable terrain. More...
 
void SendRequestedPaths () override
 Finish computing asynchronous path requests and send the CMessagePathResult messages. More...
 
void StartProcessingMoves (bool useMax) override
 Tell asynchronous pathfinder threads that they can begin computing paths. More...
 
template<typename T >
std::vector< TGetMovesToProcess (std::vector< T > &requests, bool useMax=false, size_t maxMoves=0)
 
template<typename T >
void PushRequestsToWorkers (std::vector< T > &from)
 
void UpdateGrid () override
 Regenerates the grid based on the current obstruction list, if necessary. More...
 
void MinimalTerrainUpdate (int itile0, int jtile0, int itile1, int jtile1)
 Updates the terrain-only grid without updating the dirtiness informations. More...
 
void TerrainUpdateHelper (bool expandPassability=true, int itile0=-1, int jtile0=-1, int itile1=-1, int jtile1=-1)
 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 (const 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 (const ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static void RegisterComponentType (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static void RegisterComponentTypeScriptWrapper (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static u8 GetSerializationVersion ()
 

Public Attributes

std::map< std::string, pass_class_tm_PassClassMasks
 
std::vector< PathfinderPassabilitym_PassClasses
 
u16 m_MaxSameTurnMoves
 
u16 m_GridSize
 
Grid< NavcellData > * m_Grid
 
Grid< NavcellData > * m_TerrainOnlyGrid
 
GridUpdateInformation m_DirtinessInformation
 
GridUpdateInformation m_AIPathfinderDirtinessInformation
 
bool m_TerrainDirty
 
std::vector< VertexPathfinderm_VertexPathfinders
 
std::unique_ptr< HierarchicalPathfinderm_PathfinderHier
 
std::unique_ptr< LongPathfinderm_LongPathfinder
 
std::vector< Future< void > > m_Futures
 
PathRequests< LongPathRequestm_LongPathRequests
 
PathRequests< ShortPathRequestm_ShortPathRequests
 
u32 m_NextAsyncTicket
 
AtlasOverlaym_AtlasOverlay
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Detailed Description

Implementation of ICmpPathfinder.

Constructor & Destructor Documentation

◆ ~CCmpPathfinder()

CCmpPathfinder::~CCmpPathfinder ( )

Member Function Documentation

◆ Allocate()

static IComponent* CCmpPathfinder::Allocate ( const ScriptInterface ,
JS::HandleValue   
)
inlinestatic

◆ CheckBuildingPlacement() [1/2]

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
overridevirtual

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.

◆ CheckBuildingPlacement() [2/2]

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
overridevirtual

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.

◆ CheckMovement()

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
overridevirtual

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.

◆ CheckUnitPlacement()

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
overridevirtual

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.

◆ ClassInit()

static void CCmpPathfinder::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ ComputePathAsync()

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

Asynchronous version of ComputePath.

Request a long path computation, asynchronously. 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.

◆ ComputePathImmediate()

void CCmpPathfinder::ComputePathImmediate ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal goal,
pass_class_t  passClass,
WaypointPath ret 
) const
overridevirtual

Implements ICmpPathfinder.

◆ ComputeShoreGrid()

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

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

Implements ICmpPathfinder.

◆ ComputeShortPathAsync()

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  controller,
entity_id_t  notify 
)
overridevirtual

Request a short path computation, asynchronously.

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.

◆ ComputeShortPathImmediate()

WaypointPath CCmpPathfinder::ComputeShortPathImmediate ( const ShortPathRequest request) const
overridevirtual

Implements ICmpPathfinder.

◆ Deallocate()

static void CCmpPathfinder::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpPathfinder::Deinit ( )
overridevirtual

Implements IComponent.

◆ Deserialize()

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

Implements IComponent.

◆ FlushAIPathfinderDirtinessInformation()

void CCmpPathfinder::FlushAIPathfinderDirtinessInformation ( )
inlineoverridevirtual

Implements ICmpPathfinder.

◆ GetAIPathfinderDirtinessInformation()

const GridUpdateInformation& CCmpPathfinder::GetAIPathfinderDirtinessInformation ( ) const
inlineoverridevirtual

Get the accumulated dirtiness information since the last time the AI accessed and flushed it.

Implements ICmpPathfinder.

◆ GetClearance()

entity_pos_t CCmpPathfinder::GetClearance ( pass_class_t  passClass) const
inlineoverridevirtual

Implements ICmpPathfinder.

◆ GetComponentTypeId()

int CCmpPathfinder::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetDebugData()

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

Returns some stats about the last ComputePath.

Implements ICmpPathfinder.

◆ GetMaximumClearance()

entity_pos_t CCmpPathfinder::GetMaximumClearance ( ) const
inlineoverridevirtual

Get the larger clearance in all passability classes.

Implements ICmpPathfinder.

◆ GetMovesToProcess()

template<typename T >
std::vector<T> CCmpPathfinder::GetMovesToProcess ( std::vector< T > &  requests,
bool  useMax = false,
size_t  maxMoves = 0 
)

◆ GetPassabilityClass()

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

Get the tag for a given passability class name.

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

Implements ICmpPathfinder.

◆ GetPassabilityClasses() [1/2]

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

Get the list of all known passability classes.

Implements ICmpPathfinder.

◆ GetPassabilityClasses() [2/2]

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

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

Implements ICmpPathfinder.

◆ GetPassabilityFromMask()

const PathfinderPassability * CCmpPathfinder::GetPassabilityFromMask ( pass_class_t  passClass) const

◆ GetPassabilityGrid()

const Grid< NavcellData > & CCmpPathfinder::GetPassabilityGrid ( )
overridevirtual

Implements ICmpPathfinder.

◆ GetSchema()

static std::string CCmpPathfinder::GetSchema ( )
inlinestatic

◆ HandleMessage()

void CCmpPathfinder::HandleMessage ( const CMessage msg,
bool  global 
)
overridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpPathfinder::Init ( const CParamNode paramNode)
overridevirtual

Implements IComponent.

◆ IsGoalReachable()

bool CCmpPathfinder::IsGoalReachable ( entity_pos_t  x0,
entity_pos_t  z0,
const PathGoal goal,
pass_class_t  passClass 
)
overridevirtual
Returns
true if the goal is reachable from (x0, z0) for the given passClass, false otherwise. Warning: this is synchronous, somewhat expensive and not should not be called too liberally.

Implements ICmpPathfinder.

◆ MinimalTerrainUpdate()

void CCmpPathfinder::MinimalTerrainUpdate ( int  itile0,
int  jtile0,
int  itile1,
int  jtile1 
)

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

Useful for fast passability updates in Atlas.

◆ PushRequestsToWorkers()

template<typename T >
void CCmpPathfinder::PushRequestsToWorkers ( std::vector< T > &  from)

◆ RenderSubmit()

void CCmpPathfinder::RenderSubmit ( SceneCollector collector)

◆ SendRequestedPaths()

void CCmpPathfinder::SendRequestedPaths ( )
overridevirtual

Finish computing asynchronous path requests and send the CMessagePathResult messages.

Implements ICmpPathfinder.

◆ Serialize()

void CCmpPathfinder::Serialize ( ISerializer serialize)
overridevirtual

Implements IComponent.

◆ SerializeCommon()

template<typename S >
void CCmpPathfinder::SerializeCommon ( S &  serialize)

◆ SetAtlasOverlay()

void CCmpPathfinder::SetAtlasOverlay ( bool  enable,
pass_class_t  passClass = 0 
)
overridevirtual

Sets up the pathfinder passability overlay in Atlas.

Implements ICmpPathfinder.

◆ SetDebugOverlay()

void CCmpPathfinder::SetDebugOverlay ( bool  enabled)
overridevirtual

Toggle the storage and rendering of debug info.

Implements ICmpPathfinder.

◆ SetDebugPath()

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

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

Implements ICmpPathfinder.

◆ SetHierDebugOverlay()

void CCmpPathfinder::SetHierDebugOverlay ( bool  enabled)
overridevirtual

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

Implements ICmpPathfinder.

◆ StartProcessingMoves()

void CCmpPathfinder::StartProcessingMoves ( bool  useMax)
overridevirtual

Tell asynchronous pathfinder threads that they can begin computing paths.

Implements ICmpPathfinder.

◆ TerrainUpdateHelper()

void CCmpPathfinder::TerrainUpdateHelper ( bool  expandPassability = true,
int  itile0 = -1,
int  jtile0 = -1,
int  itile1 = -1,
int  jtile1 = -1 
)

Regenerates the terrain-only grid.

Atlas doesn't need to have passability cells expanded.

◆ UpdateGrid()

void CCmpPathfinder::UpdateGrid ( )
overridevirtual

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

Implements ICmpPathfinder.

Member Data Documentation

◆ m_AIPathfinderDirtinessInformation

GridUpdateInformation CCmpPathfinder::m_AIPathfinderDirtinessInformation

◆ m_AtlasOverlay

AtlasOverlay* CCmpPathfinder::m_AtlasOverlay

◆ m_DirtinessInformation

GridUpdateInformation CCmpPathfinder::m_DirtinessInformation

◆ m_Futures

std::vector<Future<void> > CCmpPathfinder::m_Futures

◆ m_Grid

Grid<NavcellData>* CCmpPathfinder::m_Grid

◆ m_GridSize

u16 CCmpPathfinder::m_GridSize

◆ m_LongPathfinder

std::unique_ptr<LongPathfinder> CCmpPathfinder::m_LongPathfinder

◆ m_LongPathRequests

PathRequests<LongPathRequest> CCmpPathfinder::m_LongPathRequests

◆ m_MaxSameTurnMoves

u16 CCmpPathfinder::m_MaxSameTurnMoves

◆ m_NextAsyncTicket

u32 CCmpPathfinder::m_NextAsyncTicket

◆ m_PassClasses

std::vector<PathfinderPassability> CCmpPathfinder::m_PassClasses

◆ m_PassClassMasks

std::map<std::string, pass_class_t> CCmpPathfinder::m_PassClassMasks

◆ m_PathfinderHier

std::unique_ptr<HierarchicalPathfinder> CCmpPathfinder::m_PathfinderHier

◆ m_ShortPathRequests

PathRequests<ShortPathRequest> CCmpPathfinder::m_ShortPathRequests

◆ m_TerrainDirty

bool CCmpPathfinder::m_TerrainDirty

◆ m_TerrainOnlyGrid

Grid<NavcellData>* CCmpPathfinder::m_TerrainOnlyGrid

◆ m_VertexPathfinders

std::vector<VertexPathfinder> CCmpPathfinder::m_VertexPathfinders

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