Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:
ICmpPathfinder IComponent

Public Member Functions

virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
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)
 Get the tag for a given passability class name. More...
 
virtual std::map< std::string,
pass_class_t
GetPassabilityClasses ()
 Get the list of all known passability classes. More...
 
virtual cost_class_t GetCostClass (const std::string &name)
 Get the tag for a given movement cost class name. More...
 
virtual const Grid< u16 > & GetPassabilityGrid ()
 
virtual void ComputePath (entity_pos_t x0, entity_pos_t z0, const Goal &goal, pass_class_t passClass, cost_class_t costClass, Path &ret)
 
virtual u32 ComputePathAsync (entity_pos_t x0, entity_pos_t z0, const Goal &goal, pass_class_t passClass, cost_class_t costClass, 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 r, entity_pos_t range, const Goal &goal, pass_class_t passClass, Path &ret)
 
virtual u32 ComputeShortPathAsync (entity_pos_t x0, entity_pos_t z0, entity_pos_t r, entity_pos_t range, const Goal &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 Goal &goal, pass_class_t passClass, cost_class_t costClass)
 If the debug overlay is enabled, render the path that will computed by ComputePath. More...
 
virtual void ResetDebugPath ()
 
virtual void SetDebugOverlay (bool enabled)
 Toggle the storage and rendering of debug info. More...
 
virtual fixed GetMovementSpeed (entity_pos_t x0, entity_pos_t z0, cost_class_t costClass)
 Find the speed factor (typically around 1.0) for a unit of the given cost class at the given position. More...
 
virtual CFixedVector2D GetNearestPointOnGoal (CFixedVector2D pos, const Goal &goal)
 Returns the coordinates of the point on the goal that is closest to pos in a straight line. 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)
 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)
 Check whether a unit placed here 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)
 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)
 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)
 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...
 
void NearestTile (entity_pos_t x, entity_pos_t z, u16 &i, u16 &j)
 Returns the tile containing the given position. More...
 
void UpdateGrid ()
 Regenerates the grid based on the current obstruction list, if necessary. More...
 
void RenderSubmit (SceneCollector &collector)
 
- Public Member Functions inherited from ICmpPathfinder
virtual void ComputePath (entity_pos_t x0, entity_pos_t z0, const Goal &goal, pass_class_t passClass, cost_class_t costClass, Path &ret)=0
 Compute a tile-based path from the given point to the goal, and return the set of waypoints. More...
 
virtual void ComputeShortPath (const IObstructionTestFilter &filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t r, entity_pos_t range, const Goal &goal, pass_class_t passClass, Path &ret)=0
 Compute a precise path from the given point to the goal, and return the set of waypoints. More...
 
- 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 JSClass * GetJSClass () const
 
virtual jsval GetJSInstance () const
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (ScriptInterface &, jsval)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
static void TileCenter (u16 i, u16 j, entity_pos_t &x, entity_pos_t &z)
 Returns the position of the center of the given tile. More...
 
static fixed DistanceToGoal (CFixedVector2D pos, const CCmpPathfinder::Goal &goal)
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static u8 GetSerializationVersion ()
 

Public Attributes

std::map< std::string,
pass_class_t
m_PassClassMasks
 
std::vector
< PathfinderPassability
m_PassClasses
 
std::map< std::string,
cost_class_t
m_TerrainCostClassTags
 
std::map< std::string,
cost_class_t
m_UnitCostClassTags
 
std::vector< std::vector< u32 > > m_MoveCosts
 
std::vector< std::vector< fixed > > m_MoveSpeeds
 
std::vector< AsyncLongPathRequestm_AsyncLongPathRequests
 
std::vector
< AsyncShortPathRequest
m_AsyncShortPathRequests
 
u32 m_NextAsyncTicket
 
u16 m_SameTurnMovesCount
 
u16 m_MapSize
 
Grid< TerrainTile > * m_Grid
 
Grid< u8 > * m_ObstructionGrid
 
bool m_TerrainDirty
 
u16 m_MaxSameTurnMoves
 
PathfindTileGridm_DebugGrid
 
u32 m_DebugSteps
 
Pathm_DebugPath
 
PathfinderOverlaym_DebugOverlay
 
pass_class_t m_DebugPassClass
 
std::vector< SOverlayLinem_DebugOverlayShortPathLines
 

Additional Inherited Members

- Public Types inherited from ICmpPathfinder
typedef u16 pass_class_t
 
typedef u8 cost_class_t
 

Detailed Description

Implementation of ICmpPathfinder.

Definition at line 169 of file CCmpPathfinder_Common.h.

Member Function Documentation

static IComponent* CCmpPathfinder::Allocate ( ScriptInterface ,
jsval   
)
inlinestatic

Definition at line 180 of file CCmpPathfinder_Common.h.

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 
)
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.

Definition at line 707 of file CCmpPathfinder.cpp.

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 
)
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.

Definition at line 715 of file CCmpPathfinder.cpp.

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 
)
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.

Definition at line 853 of file CCmpPathfinder_Vertex.cpp.

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

Check whether a unit 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.

Definition at line 659 of file CCmpPathfinder.cpp.

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 
)
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.

Definition at line 665 of file CCmpPathfinder.cpp.

static void CCmpPathfinder::ClassInit ( CComponentManager componentManager)
inlinestatic

Definition at line 172 of file CCmpPathfinder_Common.h.

void CCmpPathfinder::ComputePath ( entity_pos_t  x0,
entity_pos_t  z0,
const Goal goal,
pass_class_t  passClass,
cost_class_t  costClass,
Path ret 
)
virtual

Definition at line 366 of file CCmpPathfinder_Tile.cpp.

u32 CCmpPathfinder::ComputePathAsync ( entity_pos_t  x0,
entity_pos_t  z0,
const Goal goal,
pass_class_t  passClass,
cost_class_t  costClass,
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.

Definition at line 545 of file CCmpPathfinder.cpp.

void CCmpPathfinder::ComputeShortPath ( const IObstructionTestFilter filter,
entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  r,
entity_pos_t  range,
const Goal goal,
pass_class_t  passClass,
Path ret 
)
virtual

Definition at line 496 of file CCmpPathfinder_Vertex.cpp.

u32 CCmpPathfinder::ComputeShortPathAsync ( entity_pos_t  x0,
entity_pos_t  z0,
entity_pos_t  r,
entity_pos_t  range,
const Goal 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.

Definition at line 552 of file CCmpPathfinder.cpp.

static void CCmpPathfinder::Deallocate ( IComponent cmp)
inlinestatic

Definition at line 180 of file CCmpPathfinder_Common.h.

void CCmpPathfinder::Deinit ( )
virtual

Implements IComponent.

Definition at line 150 of file CCmpPathfinder.cpp.

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

Implements IComponent.

Definition at line 200 of file CCmpPathfinder.cpp.

fixed CCmpPathfinder::DistanceToGoal ( CFixedVector2D  pos,
const CCmpPathfinder::Goal goal 
)
static

Definition at line 278 of file CCmpPathfinder.cpp.

void CCmpPathfinder::FinishAsyncRequests ( )
virtual

Finish computing asynchronous path requests and send the CMessagePathResult messages.

Implements ICmpPathfinder.

Definition at line 559 of file CCmpPathfinder.cpp.

ICmpPathfinder::cost_class_t CCmpPathfinder::GetCostClass ( const std::string &  name)
virtual

Get the tag for a given movement cost class name.

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

Implements ICmpPathfinder.

Definition at line 267 of file CCmpPathfinder.cpp.

fixed CCmpPathfinder::GetMovementSpeed ( entity_pos_t  x0,
entity_pos_t  z0,
cost_class_t  costClass 
)
virtual

Find the speed factor (typically around 1.0) for a unit of the given cost class at the given position.

Implements ICmpPathfinder.

Definition at line 241 of file CCmpPathfinder.cpp.

CFixedVector2D CCmpPathfinder::GetNearestPointOnGoal ( CFixedVector2D  pos,
const Goal goal 
)
virtual

Returns the coordinates of the point on the goal that is closest to pos in a straight line.

Implements ICmpPathfinder.

Definition at line 320 of file CCmpPathfinder_Vertex.cpp.

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

Get the tag for a given passability class name.

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

Implements ICmpPathfinder.

Definition at line 251 of file CCmpPathfinder.cpp.

std::map< std::string, ICmpPathfinder::pass_class_t > CCmpPathfinder::GetPassabilityClasses ( )
virtual

Get the list of all known passability classes.

Implements ICmpPathfinder.

Definition at line 262 of file CCmpPathfinder.cpp.

const Grid< u16 > & CCmpPathfinder::GetPassabilityGrid ( )
virtual

Implements ICmpPathfinder.

Definition at line 301 of file CCmpPathfinder.cpp.

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

Definition at line 220 of file CCmpPathfinder_Common.h.

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

Reimplemented from IComponent.

Definition at line 210 of file CCmpPathfinder.cpp.

void CCmpPathfinder::Init ( const CParamNode paramNode)
virtual

Implements IComponent.

Definition at line 45 of file CCmpPathfinder.cpp.

void CCmpPathfinder::NearestTile ( entity_pos_t  x,
entity_pos_t  z,
u16 i,
u16 j 
)
inline

Returns the tile containing the given position.

Definition at line 282 of file CCmpPathfinder_Common.h.

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

Definition at line 577 of file CCmpPathfinder.cpp.

void CCmpPathfinder::ProcessSameTurnMoves ( )
virtual

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

Implements ICmpPathfinder.

Definition at line 602 of file CCmpPathfinder.cpp.

void CCmpPathfinder::ProcessShortRequests ( const std::vector< AsyncShortPathRequest > &  shortRequests)

Definition at line 589 of file CCmpPathfinder.cpp.

void CCmpPathfinder::RenderSubmit ( SceneCollector collector)

Definition at line 234 of file CCmpPathfinder.cpp.

void CCmpPathfinder::ResetDebugPath ( )
virtual

Definition at line 175 of file CCmpPathfinder_Tile.cpp.

void CCmpPathfinder::Serialize ( ISerializer serialize)
virtual

Implements IComponent.

Definition at line 192 of file CCmpPathfinder.cpp.

void CCmpPathfinder::SetDebugOverlay ( bool  enabled)
virtual

Toggle the storage and rendering of debug info.

Implements ICmpPathfinder.

Definition at line 149 of file CCmpPathfinder_Tile.cpp.

void CCmpPathfinder::SetDebugPath ( entity_pos_t  x0,
entity_pos_t  z0,
const Goal goal,
pass_class_t  passClass,
cost_class_t  costClass 
)
virtual

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

Implements ICmpPathfinder.

Definition at line 162 of file CCmpPathfinder_Tile.cpp.

static void CCmpPathfinder::TileCenter ( u16  i,
u16  j,
entity_pos_t x,
entity_pos_t z 
)
inlinestatic

Returns the position of the center of the given tile.

Definition at line 291 of file CCmpPathfinder_Common.h.

void CCmpPathfinder::UpdateGrid ( )

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

Definition at line 307 of file CCmpPathfinder.cpp.

Member Data Documentation

std::vector<AsyncLongPathRequest> CCmpPathfinder::m_AsyncLongPathRequests

Definition at line 194 of file CCmpPathfinder_Common.h.

std::vector<AsyncShortPathRequest> CCmpPathfinder::m_AsyncShortPathRequests

Definition at line 195 of file CCmpPathfinder_Common.h.

PathfindTileGrid* CCmpPathfinder::m_DebugGrid

Definition at line 212 of file CCmpPathfinder_Common.h.

PathfinderOverlay* CCmpPathfinder::m_DebugOverlay

Definition at line 215 of file CCmpPathfinder_Common.h.

std::vector<SOverlayLine> CCmpPathfinder::m_DebugOverlayShortPathLines

Definition at line 218 of file CCmpPathfinder_Common.h.

pass_class_t CCmpPathfinder::m_DebugPassClass

Definition at line 216 of file CCmpPathfinder_Common.h.

Path* CCmpPathfinder::m_DebugPath

Definition at line 214 of file CCmpPathfinder_Common.h.

u32 CCmpPathfinder::m_DebugSteps

Definition at line 213 of file CCmpPathfinder_Common.h.

Grid<TerrainTile>* CCmpPathfinder::m_Grid

Definition at line 202 of file CCmpPathfinder_Common.h.

u16 CCmpPathfinder::m_MapSize

Definition at line 201 of file CCmpPathfinder_Common.h.

u16 CCmpPathfinder::m_MaxSameTurnMoves

Definition at line 208 of file CCmpPathfinder_Common.h.

std::vector<std::vector<u32> > CCmpPathfinder::m_MoveCosts

Definition at line 189 of file CCmpPathfinder_Common.h.

std::vector<std::vector<fixed> > CCmpPathfinder::m_MoveSpeeds

Definition at line 190 of file CCmpPathfinder_Common.h.

u32 CCmpPathfinder::m_NextAsyncTicket

Definition at line 196 of file CCmpPathfinder_Common.h.

Grid<u8>* CCmpPathfinder::m_ObstructionGrid

Definition at line 203 of file CCmpPathfinder_Common.h.

std::vector<PathfinderPassability> CCmpPathfinder::m_PassClasses

Definition at line 185 of file CCmpPathfinder_Common.h.

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

Definition at line 184 of file CCmpPathfinder_Common.h.

u16 CCmpPathfinder::m_SameTurnMovesCount

Definition at line 197 of file CCmpPathfinder_Common.h.

std::map<std::string, cost_class_t> CCmpPathfinder::m_TerrainCostClassTags

Definition at line 187 of file CCmpPathfinder_Common.h.

bool CCmpPathfinder::m_TerrainDirty

Definition at line 204 of file CCmpPathfinder_Common.h.

std::map<std::string, cost_class_t> CCmpPathfinder::m_UnitCostClassTags

Definition at line 188 of file CCmpPathfinder_Common.h.


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