18#ifndef INCLUDED_PATHFINDING
19#define INCLUDED_PATHFINDING
82 :
data(hv * 65536 + d * 92682)
127#define IS_PASSABLE(item, classmask) (((item) & (classmask)) == 0)
128#define PASS_CLASS_MASK_FROM_INDEX(id) ((pass_class_t)(1u << id))
129#define SPECIAL_PASS_CLASS PASS_CLASS_MASK_FROM_INDEX((PASS_CLASS_BITS-1))
T Clamp(T value, T min, T max)
Definition: MathUtil.h:32
u16 pass_class_t
Definition: Pathfinding.h:29
u16 NavcellData
Definition: Pathfinding.h:126
constexpr int PASS_CLASS_BITS
Definition: Pathfinding.h:125
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
Definition: Terrain.h:40
A simple fixed-point number class.
Definition: Fixed.h:120
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
Definition: Fixed.h:321
static constexpr CFixed FromInt(int n)
Definition: Fixed.h:140
An entity initialisation parameter node.
Definition: ParamNode.h:151
Basic 2D array, intended for storing tile data, plus support for lazy updates by ICmpObstructionManag...
Definition: Grid.h:38
Pathfinder goal.
Definition: PathGoal.h:33
Definition: Pathfinding.h:214
pass_class_t m_Mask
Definition: Pathfinding.h:223
fixed m_MinShore
Definition: Pathfinding.h:239
PathfinderPassability(pass_class_t mask, const CParamNode &node)
Definition: Pathfinding.cpp:124
fixed m_Clearance
Definition: Pathfinding.h:225
fixed m_MaxSlope
Definition: Pathfinding.h:238
ObstructionHandling
Definition: Pathfinding.h:228
@ NONE
Definition: Pathfinding.h:229
@ FOUNDATION
Definition: Pathfinding.h:231
@ PATHFINDING
Definition: Pathfinding.h:230
fixed m_MinDepth
Definition: Pathfinding.h:236
fixed m_MaxShore
Definition: Pathfinding.h:240
fixed m_MaxDepth
Definition: Pathfinding.h:237
ObstructionHandling m_Obstructions
Definition: Pathfinding.h:233
bool IsPassable(fixed waterdepth, fixed steepness, fixed shoredist) const
Definition: Pathfinding.h:218
Definition: Pathfinding.cpp:28
void TerrainTileCenter(u16 i, u16 j, entity_pos_t &x, entity_pos_t &z)
Returns the position of the center of the given terrain tile.
Definition: Pathfinding.h:173
constexpr fixed NAVCELL_SIZE
The long-range pathfinder operates primarily over a navigation grid (a uniform-cost 2D passability gr...
Definition: Pathfinding.h:143
bool CheckLineMovement(entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, pass_class_t passClass, const Grid< NavcellData > &grid)
Definition: Pathfinding.cpp:29
constexpr entity_pos_t CLEARANCE_EXTENSION_RADIUS
To make sure the long-range pathfinder is more strict than the short-range one, we need to slightly o...
Definition: Pathfinding.h:157
constexpr int NAVCELL_SIZE_INT
Definition: Pathfinding.h:144
constexpr int NAVCELLS_PER_TERRAIN_TILE
The terrain grid is coarser, and it is often convenient to convert from one to the other.
Definition: Pathfinding.h:150
void NearestNavcell(entity_pos_t x, entity_pos_t z, u16 &i, u16 &j, u16 w, u16 h)
Compute the navcell indexes on the grid nearest to a given point w, h are the grid dimensions,...
Definition: Pathfinding.h:163
void NavcellCenter(u16 i, u16 j, entity_pos_t &x, entity_pos_t &z)
Definition: Pathfinding.h:180
constexpr int NAVCELL_SIZE_LOG2
Definition: Pathfinding.h:145
u32 entity_id_t
Entity ID type.
Definition: Entity.h:29
Definition: Pathfinding.h:34
entity_id_t notify
Definition: Pathfinding.h:40
entity_pos_t x0
Definition: Pathfinding.h:36
u32 ticket
Definition: Pathfinding.h:35
pass_class_t passClass
Definition: Pathfinding.h:39
PathGoal goal
Definition: Pathfinding.h:38
entity_pos_t z0
Definition: Pathfinding.h:37
Represents the cost of a path consisting of horizontal/vertical and diagonal movements over a uniform...
Definition: Pathfinding.h:77
bool operator>(const PathCost &b) const
Definition: Pathfinding.h:114
PathCost(u16 hv, u16 d)
Construct from a number of horizontal/vertical and diagonal steps.
Definition: Pathfinding.h:81
PathCost operator+(const PathCost &a) const
Definition: Pathfinding.h:98
PathCost & operator+=(const PathCost &a)
Definition: Pathfinding.h:105
u32 ToInt()
Definition: Pathfinding.h:116
bool operator>=(const PathCost &b) const
Definition: Pathfinding.h:113
static PathCost horizvert(u16 n)
Construct for horizontal/vertical movement of given number of steps.
Definition: Pathfinding.h:87
static PathCost diag(u16 n)
Construct for diagonal movement of given number of steps.
Definition: Pathfinding.h:93
bool operator<=(const PathCost &b) const
Definition: Pathfinding.h:111
PathCost()
Definition: Pathfinding.h:78
bool operator<(const PathCost &b) const
Definition: Pathfinding.h:112
u32 data
Definition: Pathfinding.h:122
Definition: Pathfinding.h:44
entity_pos_t clearance
Definition: Pathfinding.h:48
pass_class_t passClass
Definition: Pathfinding.h:51
u32 ticket
Definition: Pathfinding.h:45
entity_id_t group
Definition: Pathfinding.h:53
PathGoal goal
Definition: Pathfinding.h:50
entity_id_t notify
Definition: Pathfinding.h:54
bool avoidMovingUnits
Definition: Pathfinding.h:52
entity_pos_t range
Definition: Pathfinding.h:49
entity_pos_t x0
Definition: Pathfinding.h:46
entity_pos_t z0
Definition: Pathfinding.h:47
Returned path.
Definition: Pathfinding.h:67
std::vector< Waypoint > m_Waypoints
Definition: Pathfinding.h:68
Definition: Pathfinding.h:58
entity_pos_t x
Definition: Pathfinding.h:59
entity_pos_t z
Definition: Pathfinding.h:59
uint16_t u16
Definition: types.h:38
uint32_t u32
Definition: types.h:39