Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/helpers/LongPathfinder.cpp
Show All 19 Lines | |||||
#include "LongPathfinder.h" | #include "LongPathfinder.h" | ||||
#include "lib/bits.h" | #include "lib/bits.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "Geometry.h" | #include "Geometry.h" | ||||
#include "HierarchicalPathfinder.h" | #include "HierarchicalPathfinder.h" | ||||
thread_local LongOverlay* LongPathfinder::m_DebugOverlay; | |||||
thread_local PathfindTileGrid* LongPathfinder::m_DebugGrid; | |||||
thread_local u32 LongPathfinder::m_DebugSteps; | |||||
thread_local double LongPathfinder::m_DebugTime; | |||||
Stan: Is it used anywhere ? | |||||
Done Inline ActionsSeems unused in the current implementation, but won't make unrelated changes here. wraitii: Seems unused in the current implementation, but won't make unrelated changes here. | |||||
thread_local PathGoal LongPathfinder::m_DebugGoal; | |||||
thread_local WaypointPath* LongPathfinder::m_DebugPath; | |||||
thread_local pass_class_t LongPathfinder::m_DebugPassClass; | |||||
thread_local std::map<pass_class_t, shared_ptr<JumpPointCache> > LongPathfinder::m_JumpPointCache; | |||||
/** | /** | ||||
* Jump point cache. | * Jump point cache. | ||||
* | * | ||||
* The JPS algorithm wants to efficiently either find the first jump point | * The JPS algorithm wants to efficiently either find the first jump point | ||||
* in some direction from some cell (not counting the cell itself), | * in some direction from some cell (not counting the cell itself), | ||||
* if it is reachable without crossing any impassable cells; | * if it is reachable without crossing any impassable cells; | ||||
* or know that there is no such reachable jump point. | * or know that there is no such reachable jump point. | ||||
* The jump point is always on a passable cell. | * The jump point is always on a passable cell. | ||||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | int GetJumpPointDown(int i, int j, const PathGoal& goal) | ||||
if (goal.NavcellRectContainsGoal(i, j - 1, i, jp + 1, NULL, &jp) || !obstruction) | if (goal.NavcellRectContainsGoal(i, j - 1, i, jp + 1, NULL, &jp) || !obstruction) | ||||
return jp; | return jp; | ||||
return j; | return j; | ||||
} | } | ||||
}; | }; | ||||
////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////// | ||||
LongPathfinder::LongPathfinder() : | LongPathfinder::LongPathfinder() : m_UseJPSCache(false), m_Grid(nullptr), m_GridSize(0) | ||||
m_UseJPSCache(false), | |||||
m_Grid(NULL), m_GridSize(0), | |||||
m_DebugOverlay(NULL), m_DebugGrid(NULL), m_DebugPath(NULL) | |||||
{ | { | ||||
m_DebugOverlay = nullptr; | |||||
m_DebugGrid = nullptr; | |||||
m_DebugPath = nullptr; | |||||
Not Done Inline ActionsWhy the change ? Why not add m_Grid as well ? Stan: Why the change ? Why not add m_Grid as well ? | |||||
Done Inline ActionsThe items are now thread_local global variables, instead of members of LongPathfinder, unlike M_Grid. wraitii: The items are now thread_local global variables, instead of members of LongPathfinder, unlike… | |||||
Not Done Inline ActionsAh I see, could nullptr the last while at it :) Stan: Ah I see, could nullptr the last while at it :) | |||||
} | } | ||||
LongPathfinder::~LongPathfinder() | LongPathfinder::~LongPathfinder() | ||||
{ | { | ||||
SAFE_DELETE(m_DebugOverlay); | SAFE_DELETE(m_DebugOverlay); | ||||
SAFE_DELETE(m_DebugGrid); | SAFE_DELETE(m_DebugGrid); | ||||
SAFE_DELETE(m_DebugPath); | SAFE_DELETE(m_DebugPath); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | while (true) | ||||
ni += di; | ni += di; | ||||
nj += dj; | nj += dj; | ||||
} | } | ||||
} | } | ||||
void LongPathfinder::ComputeJPSPath(const HierarchicalPathfinder& hierPath, entity_pos_t x0, entity_pos_t z0, const PathGoal& origGoal, pass_class_t passClass, WaypointPath& path) const | void LongPathfinder::ComputeJPSPath(const HierarchicalPathfinder& hierPath, entity_pos_t x0, entity_pos_t z0, const PathGoal& origGoal, pass_class_t passClass, WaypointPath& path) const | ||||
{ | { | ||||
PROFILE("ComputePathJPS"); | PROFILE("ComputePathJPS"); | ||||
PROFILE2_IFSPIKE("ComputePathJPS", 0.0002); | PROFILE2_IFSPIKE("ComputePathJPS", 0.0002); | ||||
Not Done Inline Actions?? Stan: ?? | |||||
Done Inline ActionsTis' something I did in the past and was a horrible idea. wraitii: Tis' something I did in the past and was a horrible idea. | |||||
PathfinderState state = { 0 }; | PathfinderState state = { 0 }; | ||||
std::map<pass_class_t, shared_ptr<JumpPointCache> >::const_iterator it = m_JumpPointCache.find(passClass); | std::map<pass_class_t, shared_ptr<JumpPointCache> >::const_iterator it = m_JumpPointCache.find(passClass); | ||||
if (it != m_JumpPointCache.end()) | if (it != m_JumpPointCache.end()) | ||||
state.jpc = it->second.get(); | state.jpc = it->second.get(); | ||||
if (m_UseJPSCache && !state.jpc) | if (m_UseJPSCache && !state.jpc) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 320 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is it used anywhere ?