1
0
forked from 0ad/0ad

The over-rasterization of obstructions introduced in [17161] could in very rare cases lead to an OOS in the passability grid. Fixes #3612.

This was SVN commit r17278.
This commit is contained in:
wraitii 2015-11-16 22:03:10 +00:00
parent 83191580c0
commit 9e35f7d68b
4 changed files with 10 additions and 4 deletions

View File

@ -1029,7 +1029,7 @@ void CCmpObstructionManager::GetUnitsOnObstruction(const ObstructionSquare& squa
if (strict)
SimRasterize::RasterizeRectWithClearance(newSpans, square, shape.clearance, Pathfinding::NAVCELL_SIZE);
else
SimRasterize::RasterizeRectWithClearance(newSpans, square, shape.clearance-Pathfinding::NAVCELL_SIZE, Pathfinding::NAVCELL_SIZE);
SimRasterize::RasterizeRectWithClearance(newSpans, square, shape.clearance-Pathfinding::CLEARANCE_EXTENSION_RADIUS, Pathfinding::NAVCELL_SIZE);
}
SimRasterize::Spans& spans = rasterizedRects[shape.clearance];

View File

@ -167,7 +167,7 @@ public:
if (passability.m_Clearance > max)
max = passability.m_Clearance;
return max;
return max + Pathfinding::CLEARANCE_EXTENSION_RADIUS;
}
virtual const Grid<NavcellData>& GetPassabilityGrid();

View File

@ -132,6 +132,12 @@ namespace Pathfinding
*/
const entity_pos_t GOAL_DELTA = NAVCELL_SIZE/8;
/**
* To make sure the long-range pathfinder is more strict than the short-range one,
* we need to slightly over-rasterize. So we extend the clearance radius by 1.
*/
const entity_pos_t CLEARANCE_EXTENSION_RADIUS = fixed::FromInt(1);
/**
* Compute the navcell indexes on the grid nearest to a given point
* w, h are the grid dimensions, i.e. the number of navcells per side

View File

@ -37,10 +37,10 @@ void SimRasterize::RasterizeRectWithClearance(Spans& spans,
// Since this is a very complicated subject, check out logs on 31/10/2015 for more detailled info.
// or ask wraitii about it.
// If the short-range pathfinder is sufficiently changed, this could become unnecessary and thus removed.
// A side effect is that the basic clearance has been set to 0.8, so removing this line should be done
// A side effect is that the basic clearance has been set to 0.8, so removing this constant should be done
// in parallel with setting clearance back to 1 for the default passability class (though this isn't strictly necessary).
// Also: the code detecting foundation obstruction in CcmpObstructionManager had to be changed similarly.
entity_pos_t rasterClearance = clearance + entity_pos_t::FromInt(1);
entity_pos_t rasterClearance = clearance + Pathfinding::CLEARANCE_EXTENSION_RADIUS;
// Get the bounds of cells that might possibly be within the shape
// (We'll then test each of those cells more precisely)