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)) // 16th bit, used for special in-place computations 151 static_assert(
TERRAIN_TILE_SIZE % NAVCELL_SIZE_INT == 0,
"Terrain tile size is not a multiple of navcell size");
166 i =
static_cast<u16>(
Clamp((x / NAVCELL_SIZE_INT).ToInt_RoundToNegInfinity(), 0, w - 1));
167 j =
static_cast<u16>(
Clamp((z / NAVCELL_SIZE_INT).ToInt_RoundToNegInfinity(), 0, h - 1));
220 return ((m_MinDepth <= waterdepth && waterdepth <= m_MaxDepth) && (steepness < m_MaxSlope) && (m_MinShore <= shoredist && shoredist <= m_MaxShore));
243 #endif // INCLUDED_PATHFINDING An entity initialisation parameter node.
Definition: ParamNode.h:150
A simple fixed-point number class.
Definition: Fixed.h:119
entity_pos_t z0
Definition: Pathfinding.h:47
u16 pass_class_t
Definition: Pathfinding.h:27
u32 ticket
Definition: Pathfinding.h:35
T Clamp(T value, T min, T max)
Definition: MathUtil.h:32
Definition: Pathfinding.cpp:27
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
Definition: Terrain.h:40
Definition: Pathfinding.h:213
Returned path.
Definition: Pathfinding.h:66
static PathCost diag(u16 n)
Construct for diagonal movement of given number of steps.
Definition: Pathfinding.h:93
Definition: Pathfinding.h:230
uint16_t u16
Definition: types.h:38
bool operator>(const PathCost &b) const
Definition: Pathfinding.h:114
fixed m_MaxSlope
Definition: Pathfinding.h:238
PathGoal goal
Definition: Pathfinding.h:38
std::vector< Waypoint > m_Waypoints
Definition: Pathfinding.h:68
Definition: Pathfinding.h:57
entity_pos_t z0
Definition: Pathfinding.h:37
static PathCost horizvert(u16 n)
Construct for horizontal/vertical movement of given number of steps.
Definition: Pathfinding.h:87
Pathfinder goal.
Definition: PathGoal.h:32
Basic 2D array, intended for storing tile data, plus support for lazy updates by ICmpObstructionManag...
Definition: TerritoryBoundary.h:27
fixed m_MaxShore
Definition: Pathfinding.h:240
ObstructionHandling m_Obstructions
Definition: Pathfinding.h:233
entity_pos_t z
Definition: Pathfinding.h:59
void NavcellCenter(u16 i, u16 j, entity_pos_t &x, entity_pos_t &z)
Definition: Pathfinding.h:180
constexpr int PASS_CLASS_BITS
Definition: Pathfinding.h:125
constexpr fixed NAVCELL_SIZE
The long-range pathfinder operates primarily over a navigation grid (a uniform-cost 2D passability gr...
Definition: Pathfinding.h:143
uint32_t u32
Definition: types.h:39
bool avoidMovingUnits
Definition: Pathfinding.h:52
Definition: Pathfinding.h:43
pass_class_t passClass
Definition: Pathfinding.h:51
constexpr int NAVCELL_SIZE_INT
Definition: Pathfinding.h:144
ObstructionHandling
Definition: Pathfinding.h:227
entity_pos_t x0
Definition: Pathfinding.h:36
fixed m_Clearance
Definition: Pathfinding.h:225
pass_class_t passClass
Definition: Pathfinding.h:39
PathCost & operator+=(const PathCost &a)
Definition: Pathfinding.h:105
entity_pos_t range
Definition: Pathfinding.h:49
entity_id_t notify
Definition: Pathfinding.h:40
fixed m_MinShore
Definition: Pathfinding.h:239
PathGoal goal
Definition: Pathfinding.h:50
PathCost operator+(const PathCost &a) const
Definition: Pathfinding.h:98
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
Definition: Pathfinding.h:33
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
pass_class_t m_Mask
Definition: Pathfinding.h:223
entity_id_t group
Definition: Pathfinding.h:53
u32 ticket
Definition: Pathfinding.h:45
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
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
Definition: Fixed.h:321
bool operator<=(const PathCost &b) const
Definition: Pathfinding.h:111
entity_id_t notify
Definition: Pathfinding.h:54
u16 NavcellData
Definition: Pathfinding.h:126
bool IsPassable(fixed waterdepth, fixed steepness, fixed shoredist) const
Definition: Pathfinding.h:218
constexpr int NAVCELL_SIZE_LOG2
Definition: Pathfinding.h:145
PathCost()
Definition: Pathfinding.h:78
u32 data
Definition: Pathfinding.h:122
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
fixed m_MaxDepth
Definition: Pathfinding.h:237
entity_pos_t x0
Definition: Pathfinding.h:46
u32 ToInt()
Definition: Pathfinding.h:116
Definition: Pathfinding.h:229
static constexpr CFixed FromInt(int n)
Definition: Fixed.h:140
Represents the cost of a path consisting of horizontal/vertical and diagonal movements over a uniform...
Definition: Pathfinding.h:76
u32 entity_id_t
Entity ID type.
Definition: Entity.h:23
fixed m_MinDepth
Definition: Pathfinding.h:236
bool operator>=(const PathCost &b) const
Definition: Pathfinding.h:113
PathCost(u16 hv, u16 d)
Construct from a number of horizontal/vertical and diagonal steps.
Definition: Pathfinding.h:81
bool operator<(const FCDJointWeightPair &a, const FCDJointWeightPair &b)
Definition: GeomReindex.cpp:64
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
entity_pos_t clearance
Definition: Pathfinding.h:48