18#ifndef INCLUDED_PATHFINDING
19#define INCLUDED_PATHFINDING
31template<
typename T>
class Grid;
84 :
data(hv * 65536 + d * 92682)
129#define IS_PASSABLE(item, classmask) (((item) & (classmask)) == 0)
130#define PASS_CLASS_MASK_FROM_INDEX(id) ((pass_class_t)(1u << id))
131#define SPECIAL_PASS_CLASS PASS_CLASS_MASK_FROM_INDEX((PASS_CLASS_BITS-1))
166 std::uint16_t w, std::uint16_t h)
T Clamp(T value, T min, T max)
Definition: MathUtil.h:34
constexpr int PASS_CLASS_BITS
Definition: Pathfinding.h:127
std::uint16_t pass_class_t
Definition: Pathfinding.h:33
std::uint16_t NavcellData
Definition: Pathfinding.h:128
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:129
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
Definition: Fixed.h:331
static constexpr CFixed FromInt(int n)
Definition: Fixed.h:149
An entity initialisation parameter node.
Definition: ParamNode.h:153
Basic 2D array, intended for storing tile data, plus support for lazy updates by ICmpObstructionManag...
Definition: Grid.h:46
Pathfinder goal.
Definition: PathGoal.h:34
Definition: Pathfinding.h:219
pass_class_t m_Mask
Definition: Pathfinding.h:228
fixed m_MinShore
Definition: Pathfinding.h:244
PathfinderPassability(pass_class_t mask, const CParamNode &node)
Definition: Pathfinding.cpp:127
fixed m_Clearance
Definition: Pathfinding.h:230
fixed m_MaxSlope
Definition: Pathfinding.h:243
ObstructionHandling
Definition: Pathfinding.h:233
@ NONE
Definition: Pathfinding.h:234
@ FOUNDATION
Definition: Pathfinding.h:236
@ PATHFINDING
Definition: Pathfinding.h:235
fixed m_MinDepth
Definition: Pathfinding.h:241
fixed m_MaxShore
Definition: Pathfinding.h:245
fixed m_MaxDepth
Definition: Pathfinding.h:242
ObstructionHandling m_Obstructions
Definition: Pathfinding.h:238
bool IsPassable(fixed waterdepth, fixed steepness, fixed shoredist) const
Definition: Pathfinding.h:223
Definition: Pathfinding.cpp:31
void NavcellCenter(std::uint16_t i, std::uint16_t j, entity_pos_t &x, entity_pos_t &z)
Definition: Pathfinding.h:185
constexpr fixed NAVCELL_SIZE
The long-range pathfinder operates primarily over a navigation grid (a uniform-cost 2D passability gr...
Definition: Pathfinding.h:145
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:32
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:159
constexpr int NAVCELL_SIZE_INT
Definition: Pathfinding.h:146
void TerrainTileCenter(std::uint16_t i, std::uint16_t j, entity_pos_t &x, entity_pos_t &z)
Returns the position of the center of the given terrain tile.
Definition: Pathfinding.h:178
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:152
void NearestNavcell(entity_pos_t x, entity_pos_t z, std::uint16_t &i, std::uint16_t &j, std::uint16_t w, std::uint16_t h)
Compute the navcell indexes on the grid nearest to a given point w, h are the grid dimensions,...
Definition: Pathfinding.h:165
constexpr int NAVCELL_SIZE_LOG2
Definition: Pathfinding.h:147
std::uint32_t entity_id_t
Entity ID type.
Definition: Entity.h:29
Definition: Pathfinding.h:36
entity_id_t notify
Definition: Pathfinding.h:42
entity_pos_t x0
Definition: Pathfinding.h:38
std::uint32_t ticket
Definition: Pathfinding.h:37
pass_class_t passClass
Definition: Pathfinding.h:41
PathGoal goal
Definition: Pathfinding.h:40
entity_pos_t z0
Definition: Pathfinding.h:39
Represents the cost of a path consisting of horizontal/vertical and diagonal movements over a uniform...
Definition: Pathfinding.h:79
bool operator>(const PathCost &b) const
Definition: Pathfinding.h:116
PathCost operator+(const PathCost &a) const
Definition: Pathfinding.h:100
std::uint32_t ToInt()
Definition: Pathfinding.h:118
std::uint32_t data
Definition: Pathfinding.h:124
PathCost & operator+=(const PathCost &a)
Definition: Pathfinding.h:107
static PathCost horizvert(std::uint16_t n)
Construct for horizontal/vertical movement of given number of steps.
Definition: Pathfinding.h:89
bool operator>=(const PathCost &b) const
Definition: Pathfinding.h:115
static PathCost diag(std::uint16_t n)
Construct for diagonal movement of given number of steps.
Definition: Pathfinding.h:95
bool operator<=(const PathCost &b) const
Definition: Pathfinding.h:113
PathCost()
Definition: Pathfinding.h:80
PathCost(std::uint16_t hv, std::uint16_t d)
Construct from a number of horizontal/vertical and diagonal steps.
Definition: Pathfinding.h:83
bool operator<(const PathCost &b) const
Definition: Pathfinding.h:114
Definition: Pathfinding.h:46
entity_pos_t clearance
Definition: Pathfinding.h:50
pass_class_t passClass
Definition: Pathfinding.h:53
entity_id_t group
Definition: Pathfinding.h:55
PathGoal goal
Definition: Pathfinding.h:52
entity_id_t notify
Definition: Pathfinding.h:56
bool avoidMovingUnits
Definition: Pathfinding.h:54
entity_pos_t range
Definition: Pathfinding.h:51
entity_pos_t x0
Definition: Pathfinding.h:48
std::uint32_t ticket
Definition: Pathfinding.h:47
entity_pos_t z0
Definition: Pathfinding.h:49
Returned path.
Definition: Pathfinding.h:69
std::vector< Waypoint > m_Waypoints
Definition: Pathfinding.h:70
Definition: Pathfinding.h:60
entity_pos_t x
Definition: Pathfinding.h:61
entity_pos_t z
Definition: Pathfinding.h:61