Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPathfinder.cpp
Show First 20 Lines • Show All 887 Lines • ▼ Show 20 Lines | bool CCmpPathfinder::IsGoalReachable(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass) | ||||
if (!IS_PASSABLE(m_Grid->get(i, j), passClass)) | if (!IS_PASSABLE(m_Grid->get(i, j), passClass)) | ||||
m_PathfinderHier->FindNearestPassableNavcell(i, j, passClass); | m_PathfinderHier->FindNearestPassableNavcell(i, j, passClass); | ||||
return m_PathfinderHier->IsGoalReachable(i, j, goal, passClass); | return m_PathfinderHier->IsGoalReachable(i, j, goal, passClass); | ||||
} | } | ||||
bool CCmpPathfinder::CheckMovement(const IObstructionTestFilter& filter, | bool CCmpPathfinder::CheckMovement(const IObstructionTestFilter& filter, | ||||
entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, | entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, | ||||
pass_class_t passClass) const | pass_class_t passClass, bool checkUnits) const | ||||
{ | { | ||||
PROFILE2_IFSPIKE("Check Movement", 0.001); | PROFILE2_IFSPIKE("Check Movement", 0.001); | ||||
// Test against obstructions first. filter may discard pathfinding-blocking obstructions. | // Test against obstructions first. filter may discard pathfinding-blocking obstructions. | ||||
// Use more permissive version of TestLine to allow unit-unit collisions to overlap slightly. | |||||
// This makes movement smoother and more natural for units, overall. | |||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | ||||
if (!cmpObstructionManager || cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r, true)) | if (!cmpObstructionManager || | ||||
(checkUnits ? cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r, true) : cmpObstructionManager->TestStaticLine(filter, x0, z0, x1, z1, r))) | |||||
return false; | return false; | ||||
// Then test against the terrain grid. This should not be necessary | // Then test against the terrain grid. This should not be necessary | ||||
// But in case we allow terrain to change it will become so. | // But in case we allow terrain to change it will become so. | ||||
return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_TerrainOnlyGrid); | return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_TerrainOnlyGrid); | ||||
} | } | ||||
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, | ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator