Revert most of f240374b28 which was actually bad. It caused units to get stuck because the obstructions won't block the same paths when rasterized on the grid and when directly tested for collisions.

As a general rule, pathfinding-blocking shapes should not be tested
against for movements. Only the passability grid should be considered.
As the algorithm which tests paths on this grid was fixed in 1c9ea56800,
it can be safely used.

Fixes #3376.

This was SVN commit r16971.
This commit is contained in:
Nicolas Auvray 2015-09-02 15:50:16 +00:00
parent 5ff31a1e33
commit f134ac63bb
2 changed files with 10 additions and 7 deletions

View File

@ -794,16 +794,13 @@ 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,
pass_class_t passClass)
{
// Test against obstructions first
// Test against obstructions first. Pathfinding-blocking obstructions are not handled here.
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity());
if (!cmpObstructionManager)
if (!cmpObstructionManager || cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r))
return false;
if (cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r))
return false;
// Then test against the terrain
return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_TerrainOnlyGrid);
// Then test against the passability grid.
return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_Grid);
}
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter,

View File

@ -346,6 +346,12 @@ public:
if (group == m_Group || (group2 != INVALID_ENTITY && group2 == m_Group))
return false;
// If an obstruction already blocks tile-based pathfinding,
// it will be handled as part of the terrain passability handling
// and doesn't need to be matched by this filter
if (flags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING)
return false;
if (!(flags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT))
return false;