18#ifndef INCLUDED_LONGPATHFINDER
19#define INCLUDED_LONGPATHFINDER
59 std::uint16_t
i()
const {
return data >> 16; }
60 std::uint16_t
j()
const {
return data & 0xFFFF; }
111 return static_cast<std::int32_t
>(
data) >> 17;
116 return (
static_cast<std::int32_t
>(
data) << 15) >> 17;
120 inline void SetPred(
int pi,
int pj,
int i,
int j)
124 ASSERT(-16384 <= di && di < 16384);
125 ASSERT(-16384 <= dj && dj < 16384);
127 data |= ((
static_cast<std::uint32_t
>(di) & 0x7FFF) << 17) |
128 ((
static_cast<std::uint32_t
>(dj) & 0x7FFF) << 2);
241 std::atomic<TerrainTextureOverlay*>
Overlay =
nullptr;
PriorityQueueHeap< TileID, PathCost, PathCost > PriorityQueue
Definition: LongPathfinder.h:138
SparseGrid< PathfindTile > PathfindTileGrid
Definition: LongPathfinder.h:139
std::uint16_t pass_class_t
Definition: Pathfinding.h:33
A simple fixed-point number class.
Definition: Fixed.h:129
std::uint16_t m_W
Definition: Grid.h:242
std::uint16_t m_H
Definition: Grid.h:242
Definition: HierarchicalPathfinder.h:71
Jump point cache.
Definition: LongPathfinder.cpp:137
Definition: LongPathfinder.h:170
int HasJumpedVert(int i, int j, int dj, PathfinderState &state, bool detectGoal) const
Definition: LongPathfinder.cpp:715
LongPathfinder()
Definition: LongPathfinder.cpp:454
Grid< NavcellData > * m_Grid
Definition: LongPathfinder.h:229
void SetDebugOverlay(bool enabled)
Definition: LongPathfinder.cpp:467
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:1091
~LongPathfinder()
Definition: LongPathfinder.cpp:460
int HasJumpedHoriz(int i, int j, int di, PathfinderState &state, bool detectGoal) const
Definition: LongPathfinder.cpp:637
bool m_UseJPSCache
Definition: LongPathfinder.h:290
std::uint16_t m_GridSize
Definition: LongPathfinder.h:230
void AddJumpedVert(int i, int j, int dj, PathCost g, PathfinderState &state, bool detectGoal) const
Definition: LongPathfinder.cpp:673
void AddJumpedDiag(int i, int j, int di, int dj, PathCost g, PathfinderState &state) const
Definition: LongPathfinder.cpp:755
void Update(Grid< NavcellData > *passabilityGrid)
Definition: LongPathfinder.h:198
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:806
PathCost CalculateHeuristic(int i, int j, int iGoal, int jGoal) const
Definition: LongPathfinder.cpp:482
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:1117
void ProcessNeighbour(int pi, int pj, int i, int j, PathCost pg, PathfinderState &state) const
Definition: LongPathfinder.cpp:491
std::map< pass_class_t, std::shared_ptr< JumpPointCache > > m_JumpPointCache
Definition: LongPathfinder.h:295
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:1013
void AddJumpedHoriz(int i, int j, int di, PathCost g, PathfinderState &state, bool detectGoal) const
JPS algorithm helper functions.
Definition: LongPathfinder.cpp:595
void SetDebugPath(const HierarchicalPathfinder &hierPath, entity_pos_t x0, entity_pos_t z0, const PathGoal &goal, pass_class_t passClass)
Definition: LongPathfinder.h:177
void Reload(Grid< NavcellData > *passabilityGrid)
Definition: LongPathfinder.h:189
struct LongPathfinder::Debug m_Debug
void GetDebugDataJPS(std::uint32_t &steps, double &time, Grid< std::uint8_t > &grid) const
Definition: LongPathfinder.cpp:1065
void GetDebugData(std::uint32_t &steps, double &time, Grid< std::uint8_t > &grid) const
Definition: LongPathfinder.h:224
Pathfinder goal.
Definition: PathGoal.h:34
Similar to Grid, except optimised for sparse usage (the grid is subdivided into buckets whose content...
Definition: Grid.h:304
Base class for texture-based terrain overlays, with an arbitrary number of texels per terrain tile,...
Definition: TerrainOverlay.h:202
#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:250
enum PS::Loader::anonymous_namespace{Loader.cpp}::@26 state
Definition: LongPathfinder.h:133
CircularRegion(entity_pos_t x, entity_pos_t z, entity_pos_t r)
Definition: LongPathfinder.h:134
entity_pos_t z
Definition: LongPathfinder.h:135
entity_pos_t x
Definition: LongPathfinder.h:135
entity_pos_t r
Definition: LongPathfinder.h:135
Definition: LongPathfinder.h:234
double Time
Definition: LongPathfinder.h:246
WaypointPath * Path
Definition: LongPathfinder.h:249
PathGoal Goal
Definition: LongPathfinder.h:247
PathfindTileGrid * Grid
Definition: LongPathfinder.h:244
std::uint32_t Steps
Definition: LongPathfinder.h:245
pass_class_t PassClass
Definition: LongPathfinder.h:250
std::atomic< TerrainTextureOverlay * > Overlay
Atomic - used to toggle debugging.
Definition: LongPathfinder.h:241
Represents the cost of a path consisting of horizontal/vertical and diagonal movements over a uniform...
Definition: Pathfinding.h:79
Tile data for A* computation.
Definition: LongPathfinder.h:71
bool IsOpen() const
Definition: LongPathfinder.h:80
int GetPredI(int i) const
Definition: LongPathfinder.h:86
int GetPredJ(int j) const
Definition: LongPathfinder.h:87
std::uint32_t data
Definition: LongPathfinder.h:94
PathCost g
Definition: LongPathfinder.h:93
@ STATUS_OPEN
Definition: LongPathfinder.h:75
@ STATUS_CLOSED
Definition: LongPathfinder.h:76
@ STATUS_UNEXPLORED
Definition: LongPathfinder.h:74
int GetPredDI() const
Definition: LongPathfinder.h:109
void SetCost(PathCost cost)
Definition: LongPathfinder.h:90
void SetPred(int pi, int pj, int i, int j)
Definition: LongPathfinder.h:120
bool IsClosed() const
Definition: LongPathfinder.h:81
int GetPredDJ() const
Definition: LongPathfinder.h:114
void SetStatusClosed()
Definition: LongPathfinder.h:83
void SetStatusOpen()
Definition: LongPathfinder.h:82
std::uint8_t GetStatus() const
Definition: LongPathfinder.h:97
PathCost GetCost() const
Definition: LongPathfinder.h:89
void SetStatus(std::uint8_t s)
Definition: LongPathfinder.h:102
bool IsUnexplored() const
Definition: LongPathfinder.h:79
Definition: LongPathfinder.h:144
PathCost hBest
Definition: LongPathfinder.h:159
const JumpPointCache * jpc
Definition: LongPathfinder.h:162
std::uint16_t jBest
Definition: LongPathfinder.h:160
Grid< NavcellData > * terrain
Definition: LongPathfinder.h:157
PriorityQueue open
Definition: LongPathfinder.h:153
std::uint16_t jGoal
Definition: LongPathfinder.h:149
PathfindTileGrid * tiles
Definition: LongPathfinder.h:156
pass_class_t passClass
Definition: LongPathfinder.h:151
std::uint16_t iBest
Definition: LongPathfinder.h:160
std::uint16_t iGoal
Definition: LongPathfinder.h:149
PathGoal goal
Definition: LongPathfinder.h:147
std::uint32_t steps
Definition: LongPathfinder.h:145
Represents the 2D coordinates of a tile.
Definition: LongPathfinder.h:43
TileID(std::uint16_t i, std::uint16_t j)
Definition: LongPathfinder.h:46
TileID()
Definition: LongPathfinder.h:44
std::uint32_t data
Definition: LongPathfinder.h:63
std::uint16_t j() const
Definition: LongPathfinder.h:60
bool operator<(const TileID &b) const
Returns lexicographic order over (i,j)
Definition: LongPathfinder.h:54
bool operator==(const TileID &b) const
Definition: LongPathfinder.h:48
std::uint16_t i() const
Definition: LongPathfinder.h:59
Returned path.
Definition: Pathfinding.h:69