Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPathfinder.cpp
Show First 20 Lines • Show All 664 Lines • ▼ Show 20 Lines | for (PathfinderPassability& passability : m_PassClasses) | ||||
if (passability.m_Clearance == fixed::Zero()) | if (passability.m_Clearance == fixed::Zero()) | ||||
continue; | continue; | ||||
int clearance = (passability.m_Clearance / Pathfinding::NAVCELL_SIZE).ToInt_RoundToInfinity(); | int clearance = (passability.m_Clearance / Pathfinding::NAVCELL_SIZE).ToInt_RoundToInfinity(); | ||||
ExpandImpassableCells(*m_TerrainOnlyGrid, clearance, passability.m_Mask); | ExpandImpassableCells(*m_TerrainOnlyGrid, clearance, passability.m_Mask); | ||||
} | } | ||||
} | } | ||||
bool CCmpPathfinder::MakeGoalReachable(entity_pos_t x0, entity_pos_t z0, PathGoal &goal, pass_class_t passClass) | |||||
{ | |||||
u16 i0, j0; | |||||
Pathfinding::NearestNavcell(x0, z0, i0, j0, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); | |||||
if (!IS_PASSABLE(m_Grid->get(i0, j0), passClass)) | |||||
FindNearestPassableNavcell(i0, j0, passClass); | |||||
return m_LongPathfinder.MakeGoalReachable(i0, j0, goal, passClass); | |||||
} | |||||
u32 CCmpPathfinder::FindNearestPassableNavcell(entity_pos_t x, entity_pos_t z, u16& outI, u16& outJ, pass_class_t passClass) | |||||
{ | |||||
Pathfinding::NearestNavcell(x, z, outI, outJ, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); | |||||
u16 i0 = outI; | |||||
u16 j0 = outJ; | |||||
FindNearestPassableNavcell(outI, outJ, passClass); | |||||
return abs(i0 - outI) + abs(j0 - outJ); | |||||
} | |||||
void CCmpPathfinder::FindNearestPassableNavcell(u16& i, u16& j, pass_class_t passClass) | |||||
{ | |||||
m_LongPathfinder.FindNearestPassableNavcell(i, j, passClass); | |||||
} | |||||
bool CCmpPathfinder::NavcellIsReachable(u16 i0, u16 j0, u16 i1, u16 j1, pass_class_t passClass) | |||||
{ | |||||
return m_LongPathfinder.NavcellIsReachable(i0, j0, i1, j1, passClass); | |||||
} | |||||
////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////// | ||||
// Async path requests: | // Async path requests: | ||||
u32 CCmpPathfinder::ComputePathAsync(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass, entity_id_t notify) | u32 CCmpPathfinder::ComputePathAsync(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass, entity_id_t notify) | ||||
{ | { | ||||
AsyncLongPathRequest req = { m_NextAsyncTicket++, x0, z0, goal, passClass, notify }; | AsyncLongPathRequest req = { m_NextAsyncTicket++, x0, z0, goal, passClass, notify }; | ||||
m_AsyncLongPathRequests.push_back(req); | m_AsyncLongPathRequests.push_back(req); | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator