Changeset View
Changeset View
Standalone View
Standalone View
0ad/source/simulation2/helpers/Rasterize.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | void SimRasterize::RasterizeRectWithClearance(Spans& spans, | ||||
// Also: the code detecting foundation obstruction in CcmpObstructionManager had to be changed similarly. | // Also: the code detecting foundation obstruction in CcmpObstructionManager had to be changed similarly. | ||||
entity_pos_t rasterClearance = clearance + Pathfinding::CLEARANCE_EXTENSION_RADIUS; | entity_pos_t rasterClearance = clearance + Pathfinding::CLEARANCE_EXTENSION_RADIUS; | ||||
// Get the bounds of cells that might possibly be within the shape | // Get the bounds of cells that might possibly be within the shape | ||||
// (We'll then test each of those cells more precisely) | // (We'll then test each of those cells more precisely) | ||||
CFixedVector2D shapeHalfSize(CFixedVector2D(shape.hw, shape.hh)); | CFixedVector2D shapeHalfSize(CFixedVector2D(shape.hw, shape.hh)); | ||||
CFixedVector2D halfSize(shape.hw + rasterClearance, shape.hh + rasterClearance); | CFixedVector2D halfSize(shape.hw + rasterClearance, shape.hh + rasterClearance); | ||||
CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(shape.u, shape.v, halfSize); | CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(shape.u, shape.v, halfSize); | ||||
i16 i0 = ((shape.x - halfBound.X) / cellSize).ToInt_RoundToNegInfinity(); | i16 i0 = ((shape.x - halfBound.getX()) / cellSize).ToInt_RoundToNegInfinity(); | ||||
i16 j0 = ((shape.z - halfBound.Y) / cellSize).ToInt_RoundToNegInfinity(); | i16 j0 = ((shape.z - halfBound.getY()) / cellSize).ToInt_RoundToNegInfinity(); | ||||
i16 i1 = ((shape.x + halfBound.X) / cellSize).ToInt_RoundToInfinity(); | i16 i1 = ((shape.x + halfBound.getX()) / cellSize).ToInt_RoundToInfinity(); | ||||
i16 j1 = ((shape.z + halfBound.Y) / cellSize).ToInt_RoundToInfinity(); | i16 j1 = ((shape.z + halfBound.getY()) / cellSize).ToInt_RoundToInfinity(); | ||||
if (j1 <= j0) | if (j1 <= j0) | ||||
return; // empty bounds - this shouldn't happen | return; // empty bounds - this shouldn't happen | ||||
rasterClearance = rasterClearance.Multiply(rasterClearance); | rasterClearance = rasterClearance.Multiply(rasterClearance); | ||||
spans.reserve(j1 - j0); | spans.reserve(j1 - j0); | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator