Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPathfinder.cpp
Show First 20 Lines • Show All 833 Lines • ▼ Show 20 Lines | |||||
////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////// | ||||
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) 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 unit shapes, so that units cannot ocupy the same position in space. | ||||
// Use more permissive version of TestLine to allow unit-unit collisions to overlap slightly. | // filter may be used to discard some shapes. | ||||
// 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 || cmpObstructionManager->TestLineAgainstUnitShapes(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 and rasterised static obstructions. | ||||
// But in case we allow terrain to change it will become so. | return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_Grid); | ||||
return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_TerrainOnlyGrid); | |||||
} | } | ||||
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, | ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, | ||||
entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool UNUSED(onlyCenterPoint)) const | entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool UNUSED(onlyCenterPoint)) const | ||||
{ | { | ||||
// Check unit obstruction | // Check unit obstruction | ||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | ||||
if (!cmpObstructionManager) | if (!cmpObstructionManager) | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator