Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpUnitMotion.cpp
Show First 20 Lines • Show All 828 Lines • ▼ Show 20 Lines | void CCmpUnitMotion::PathResult(u32 ticket, const WaypointPath& path) | ||||
// it might be obstructed (e.g. by idle entities which the long-range pathfinder doesn't see). | // it might be obstructed (e.g. by idle entities which the long-range pathfinder doesn't see). | ||||
if (!m_LongPath.m_Waypoints.empty()) | if (!m_LongPath.m_Waypoints.empty()) | ||||
{ | { | ||||
m_LongPath.m_Waypoints.pop_back(); | m_LongPath.m_Waypoints.pop_back(); | ||||
if (!m_LongPath.m_Waypoints.empty()) | if (!m_LongPath.m_Waypoints.empty()) | ||||
{ | { | ||||
// Get close enough - this will likely help the short path efficiency, and if we end up taking a wrong way | // Get close enough - this will likely help the short path efficiency, and if we end up taking a wrong way | ||||
// we'll easily be able to revert it using a long path. | // we'll easily be able to revert it using a long path. | ||||
PathGoal goal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) }; | PathGoal closeGoal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) }; | ||||
RequestShortPath(pos, goal, true); | RequestShortPath(pos, closeGoal, true); | ||||
wraitii: I think it'd be better to just re-use goal directly. | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
ComputePathToGoal(pos, goal); | ComputePathToGoal(pos, goal); | ||||
} | } | ||||
void CCmpUnitMotion::Move(fixed dt) | void CCmpUnitMotion::Move(fixed dt) | ||||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | if (!InShortPathRange(goal, pos)) | ||||
// Assume the next waypoint is impassable and pop it. This helps unstuck entities in some cases, and we'll just | // Assume the next waypoint is impassable and pop it. This helps unstuck entities in some cases, and we'll just | ||||
// end up recomputing a long path if we pop all of them, so it's safe. | // end up recomputing a long path if we pop all of them, so it's safe. | ||||
if (m_LongPath.m_Waypoints.size() >= 1) | if (m_LongPath.m_Waypoints.size() >= 1) | ||||
m_LongPath.m_Waypoints.pop_back(); | m_LongPath.m_Waypoints.pop_back(); | ||||
if (!m_LongPath.m_Waypoints.empty()) | if (!m_LongPath.m_Waypoints.empty()) | ||||
{ | { | ||||
// Get close enough - this will likely help the short path efficiency, and if we end up taking a wrong way | // Get close enough - this will likely help the short path efficiency, and if we end up taking a wrong way | ||||
// we'll easily be able to revert it using a long path. | // we'll easily be able to revert it using a long path. | ||||
PathGoal goal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) }; | PathGoal closeGoal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) }; | ||||
RequestShortPath(pos, goal, true); | RequestShortPath(pos, closeGoal, true); | ||||
Done Inline Actionslikewise, reuse goal wraitii: likewise, reuse goal | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
// Else, just entirely recompute. This will ensure we occasionally run a long path so avoid getting stuck | // Else, just entirely recompute. This will ensure we occasionally run a long path so avoid getting stuck | ||||
// in the short pathfinder, which can happen when an entity is right ober an obstruction's edge. | // in the short pathfinder, which can happen when an entity is right ober an obstruction's edge. | ||||
ComputePathToGoal(pos, goal); | ComputePathToGoal(pos, goal); | ||||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
I think it'd be better to just re-use goal directly.