18 #ifndef INCLUDED_CCMPPATHFINDER_COMMON
19 #define INCLUDED_CCMPPATHFINDER_COMMON
45 #define PATHFIND_DEBUG 0
47 #define PATHFIND_DEBUG 1
88 m_MinDepth = std::numeric_limits<fixed>::min();
93 m_MaxDepth = std::numeric_limits<fixed>::max();
98 m_MaxSlope = std::numeric_limits<fixed>::max();
103 m_MinShore = std::numeric_limits<fixed>::min();
108 m_MaxShore = std::numeric_limits<fixed>::max();
134 #define IS_TERRAIN_PASSABLE(item, classmask) (((item) & (classmask)) == 0)
135 #define IS_PASSABLE(item, classmask) (((item) & ((classmask) | 1)) == 0)
136 #define GET_COST_CLASS(item) ((item) >> (PASS_CLASS_BITS + 2))
137 #define COST_CLASS_MASK(id) ( (TerrainTile) ((id) << (PASS_CLASS_BITS + 2)) )
222 return "<a:component type='system'/><empty/>";
307 #endif // INCLUDED_CCMPPATHFINDER_COMMON
ICmpPathfinder::pass_class_t m_Mask
An entity initialisation parameter node.
void SubscribeToMessageType(MessageTypeId mtid)
Subscribe the current component type to the given message type.
std::vector< SOverlayLine > m_DebugOverlayShortPathLines
A simple fixed-point number class.
PathfinderPassability(ICmpPathfinder::pass_class_t mask, const CParamNode &node)
ICmpPathfinder::pass_class_t passClass
Interface for ICmpObstructionManager Test functions to filter out unwanted shapes.
static void ClassInit(CComponentManager &componentManager)
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.
Implementation of ICmpPathfinder.
void UpdateGrid()
Regenerates the grid based on the current obstruction list, if necessary.
Similar to Grid, except optimised for sparse usage (the grid is subdivided into buckets whose content...
virtual void HandleMessage(const CMessage &msg, bool global)
Line-based overlay, with world-space coordinates, rendered in the world potentially behind other obje...
static fixed DistanceToGoal(CFixedVector2D pos, const CCmpPathfinder::Goal &goal)
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
virtual void ResetDebugPath()
static std::string GetSchema()
std::vector< PathfinderPassability > m_PassClasses
std::map< std::string, cost_class_t > m_TerrainCostClassTags
bool IsOk() const
Returns true if this is a valid CParamNode, false if it represents a non-existent node...
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...
Serialization interface; see serialization overview.
virtual void ProcessSameTurnMoves()
Process moves during the same turn they were created in to improve responsiveness.
virtual std::map< std::string, pass_class_t > GetPassabilityClasses()
Get the list of all known passability classes.
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...
void NearestTile(entity_pos_t x, entity_pos_t z, u16 &i, u16 &j)
Returns the tile containing the given position.
Grid< u8 > * m_ObstructionGrid
std::vector< std::vector< u32 > > m_MoveCosts
Basic 2D array, intended for storing tile data, plus support for lazy updates by ICmpObstructionManag...
Grid< TerrainTile > * m_Grid
void RenderSubmit(SceneCollector &collector)
ICmpPathfinder::pass_class_t passClass
std::vector< AsyncShortPathRequest > m_AsyncShortPathRequests
This interface accepts renderable objects.
fixed ToFixed() const
Parses the content of this node as a fixed-point number.
Terrain overlay for pathfinder debugging.
const CParamNode & GetChild(const char *name) const
Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none...
virtual void Serialize(ISerializer &serialize)
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.
std::vector< std::vector< fixed > > m_MoveSpeeds
void ProcessLongRequests(const std::vector< AsyncLongPathRequest > &longRequests)
PathfindTileGrid * m_DebugGrid
std::map< std::string, cost_class_t > m_UnitCostClassTags
Tile data for A* computation.
std::vector< AsyncLongPathRequest > m_AsyncLongPathRequests
virtual void ComputePath(entity_pos_t x0, entity_pos_t z0, const Goal &goal, pass_class_t passClass, cost_class_t costClass, Path &ret)
ICmpPathfinder::Goal goal
#define DEFAULT_COMPONENT_ALLOCATOR(cname)
virtual void SetDebugOverlay(bool enabled)
Toggle the storage and rendering of debug info.
const int COST_CLASS_BITS
virtual pass_class_t GetPassabilityClass(const std::string &name)
Get the tag for a given passability class name.
std::map< std::string, pass_class_t > m_PassClassMasks
SparseGrid< PathfindTile > PathfindTileGrid
virtual void Init(const CParamNode ¶mNode)
static CFixed FromInt(int n)
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...
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).
PathfinderOverlay * m_DebugOverlay
ICmpPathfinder::Goal goal
ICmpPathfinder::cost_class_t costClass
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...
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.
void ProcessShortRequests(const std::vector< AsyncShortPathRequest > &shortRequests)
bool IsPassable(fixed waterdepth, fixed steepness, fixed shoredist)
virtual cost_class_t GetCostClass(const std::string &name)
Get the tag for a given movement cost class name.
u32 entity_id_t
Entity ID type.
virtual const Grid< u16 > & GetPassabilityGrid()
const int PASS_CLASS_BITS
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)
T clamp(T value, T min, T max)
Helper functions related to geometry algorithms.
virtual void FinishAsyncRequests()
Finish computing asynchronous path requests and send the CMessagePathResult messages.
Deserialization interface; see serialization overview.
pass_class_t m_DebugPassClass
virtual void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize)
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...