18#ifndef INCLUDED_LONGPATHFINDER
19#define INCLUDED_LONGPATHFINDER
112 return ((
i32)
data << 15) >> 17;
116 inline void SetPred(
int pi,
int pj,
int i,
int j)
120 ASSERT(-16384 <= di && di < 16384);
121 ASSERT(-16384 <= dj && dj < 16384);
123 data |= (((
u32)di & 0x7FFF) << 17) | (((
u32)dj & 0x7FFF) << 2);
PriorityQueueHeap< TileID, PathCost, PathCost > PriorityQueue
Definition: LongPathfinder.h:133
SparseGrid< PathfindTile > PathfindTileGrid
Definition: LongPathfinder.h:134
u16 pass_class_t
Definition: Pathfinding.h:29
A simple fixed-point number class.
Definition: Fixed.h:120
u16 m_H
Definition: Grid.h:249
u16 m_W
Definition: Grid.h:249
Definition: HierarchicalPathfinder.h:61
Jump point cache.
Definition: LongPathfinder.cpp:65
Terrain overlay for pathfinder debugging.
Definition: LongPathfinder.cpp:1058
Definition: LongPathfinder.h:165
int HasJumpedVert(int i, int j, int dj, PathfinderState &state, bool detectGoal) const
Definition: LongPathfinder.cpp:624
void GetDebugDataJPS(u32 &steps, double &time, Grid< u8 > &grid) const
Definition: LongPathfinder.cpp:974
LongPathfinder()
Definition: LongPathfinder.cpp:381
Grid< NavcellData > * m_Grid
Definition: LongPathfinder.h:224
void SetDebugOverlay(bool enabled)
Definition: LongPathfinder.cpp:1143
void ComputePath(const HierarchicalPathfinder &hierPath, entity_pos_t x0, entity_pos_t z0, const PathGoal &origGoal, pass_class_t passClass, WaypointPath &path) const
Compute a tile-based path from the given point to the goal, and return the set of waypoints.
Definition: LongPathfinder.cpp:1000
~LongPathfinder()
Definition: LongPathfinder.cpp:1151
int HasJumpedHoriz(int i, int j, int di, PathfinderState &state, bool detectGoal) const
Definition: LongPathfinder.cpp:546
bool m_UseJPSCache
Definition: LongPathfinder.h:280
void AddJumpedVert(int i, int j, int dj, PathCost g, PathfinderState &state, bool detectGoal) const
Definition: LongPathfinder.cpp:582
void AddJumpedDiag(int i, int j, int di, int dj, PathCost g, PathfinderState &state) const
Definition: LongPathfinder.cpp:664
void Update(Grid< NavcellData > *passabilityGrid)
Definition: LongPathfinder.h:193
u16 m_GridSize
Definition: LongPathfinder.h:225
void ComputeJPSPath(const HierarchicalPathfinder &hierPath, entity_pos_t x0, entity_pos_t z0, const PathGoal &origGoal, pass_class_t passClass, WaypointPath &path) const
See LongPathfinder.cpp for implementation details TODO: cleanup documentation.
Definition: LongPathfinder.cpp:715
PathCost CalculateHeuristic(int i, int j, int iGoal, int jGoal) const
Definition: LongPathfinder.cpp:391
void GenerateSpecialMap(pass_class_t passClass, std::vector< CircularRegion > excludedRegions)
Generate a passability map, stored in the 16th bit of navcells, based on passClass,...
Definition: LongPathfinder.cpp:1026
void ProcessNeighbour(int pi, int pj, int i, int j, PathCost pg, PathfinderState &state) const
Definition: LongPathfinder.cpp:400
std::map< pass_class_t, std::shared_ptr< JumpPointCache > > m_JumpPointCache
Definition: LongPathfinder.h:285
void GetDebugData(u32 &steps, double &time, Grid< u8 > &grid) const
Definition: LongPathfinder.h:219
void ImprovePathWaypoints(WaypointPath &path, pass_class_t passClass, entity_pos_t maxDist, entity_pos_t x0, entity_pos_t z0) const
Given a path with an arbitrary collection of waypoints, updates the waypoints to be nicer.
Definition: LongPathfinder.cpp:922
void AddJumpedHoriz(int i, int j, int di, PathCost g, PathfinderState &state, bool detectGoal) const
JPS algorithm helper functions.
Definition: LongPathfinder.cpp:504
void SetDebugPath(const HierarchicalPathfinder &hierPath, entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass)
Definition: LongPathfinder.h:172
void Reload(Grid< NavcellData > *passabilityGrid)
Definition: LongPathfinder.h:184
struct LongPathfinder::Debug m_Debug
Pathfinder goal.
Definition: PathGoal.h:33
Similar to Grid, except optimised for sparse usage (the grid is subdivided into buckets whose content...
Definition: Grid.h:311
#define SAFE_DELETE(p)
delete memory ensuing from new and set the pointer to zero (thus making double-frees safe / a no-op)
Definition: code_generation.h:111
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
Definition: debug.h:305
Definition: LongPathfinder.h:128
CircularRegion(entity_pos_t x, entity_pos_t z, entity_pos_t r)
Definition: LongPathfinder.h:129
entity_pos_t z
Definition: LongPathfinder.h:130
entity_pos_t x
Definition: LongPathfinder.h:130
entity_pos_t r
Definition: LongPathfinder.h:130
Definition: LongPathfinder.h:229
double Time
Definition: LongPathfinder.h:236
WaypointPath * Path
Definition: LongPathfinder.h:239
PathGoal Goal
Definition: LongPathfinder.h:237
u32 Steps
Definition: LongPathfinder.h:235
PathfindTileGrid * Grid
Definition: LongPathfinder.h:234
std::atomic< LongOverlay * > Overlay
Definition: LongPathfinder.h:231
pass_class_t PassClass
Definition: LongPathfinder.h:240
Represents the cost of a path consisting of horizontal/vertical and diagonal movements over a uniform...
Definition: Pathfinding.h:77
Tile data for A* computation.
Definition: LongPathfinder.h:67
u8 GetStatus() const
Definition: LongPathfinder.h:93
@ STATUS_OPEN
Definition: LongPathfinder.h:71
@ STATUS_CLOSED
Definition: LongPathfinder.h:72
@ STATUS_UNEXPLORED
Definition: LongPathfinder.h:70
bool IsOpen() const
Definition: LongPathfinder.h:76
int GetPredI(int i) const
Definition: LongPathfinder.h:82
int GetPredJ(int j) const
Definition: LongPathfinder.h:83
PathCost g
Definition: LongPathfinder.h:89
u32 data
Definition: LongPathfinder.h:90
void SetStatus(u8 s)
Definition: LongPathfinder.h:98
int GetPredDI() const
Definition: LongPathfinder.h:105
void SetCost(PathCost cost)
Definition: LongPathfinder.h:86
void SetPred(int pi, int pj, int i, int j)
Definition: LongPathfinder.h:116
bool IsClosed() const
Definition: LongPathfinder.h:77
int GetPredDJ() const
Definition: LongPathfinder.h:110
void SetStatusClosed()
Definition: LongPathfinder.h:79
void SetStatusOpen()
Definition: LongPathfinder.h:78
PathCost GetCost() const
Definition: LongPathfinder.h:85
bool IsUnexplored() const
Definition: LongPathfinder.h:75
Definition: LongPathfinder.h:139
PathCost hBest
Definition: LongPathfinder.h:154
u16 iGoal
Definition: LongPathfinder.h:144
const JumpPointCache * jpc
Definition: LongPathfinder.h:157
u16 iBest
Definition: LongPathfinder.h:155
Grid< NavcellData > * terrain
Definition: LongPathfinder.h:152
PriorityQueue open
Definition: LongPathfinder.h:148
u32 steps
Definition: LongPathfinder.h:140
PathfindTileGrid * tiles
Definition: LongPathfinder.h:151
pass_class_t passClass
Definition: LongPathfinder.h:146
u16 jGoal
Definition: LongPathfinder.h:144
u16 jBest
Definition: LongPathfinder.h:155
PathGoal goal
Definition: LongPathfinder.h:142
Represents the 2D coordinates of a tile.
Definition: LongPathfinder.h:39
TileID()
Definition: LongPathfinder.h:40
u16 i() const
Definition: LongPathfinder.h:55
TileID(u16 i, u16 j)
Definition: LongPathfinder.h:42
u16 j() const
Definition: LongPathfinder.h:56
bool operator<(const TileID &b) const
Returns lexicographic order over (i,j)
Definition: LongPathfinder.h:50
bool operator==(const TileID &b) const
Definition: LongPathfinder.h:44
u32 data
Definition: LongPathfinder.h:59
Returned path.
Definition: Pathfinding.h:67
int32_t i32
Definition: types.h:34
uint8_t u8
Definition: types.h:37
uint16_t u16
Definition: types.h:38
uint32_t u32
Definition: types.h:39