Ticket #3471: FixStuckUnits.patch

File FixStuckUnits.patch, 4.8 KB (added by wraitii, 9 years ago)
  • binaries/data/mods/public/simulation/data/pathfinder.xml

     
    1111      <Obstructions>pathfinding</Obstructions>
    1212      <MaxWaterDepth>2</MaxWaterDepth>
    1313      <MaxTerrainSlope>1.0</MaxTerrainSlope>
    14       <Clearance>1.0</Clearance>
     14      <Clearance>0.8</Clearance>
    1515    </default>
    1616    <large>
    1717      <Obstructions>pathfinding</Obstructions>
  • source/simulation2/components/CCmpPathfinder_Vertex.cpp

     
    127127// When computing vertexes to insert into the search graph,
    128128// add a small delta so that the vertexes of an edge don't get interpreted
    129129// as crossing the edge (given minor numerical inaccuracies)
    130 static const entity_pos_t EDGE_EXPAND_DELTA = entity_pos_t::FromInt(1)/4;
     130static const entity_pos_t EDGE_EXPAND_DELTA = entity_pos_t::FromInt(1)/16;
    131131
    132132/**
    133133 * Check whether a ray from 'a' to 'b' crosses any of the edges.
  • source/simulation2/components/CCmpPathfinder.cpp

     
    793793    if (!cmpObstructionManager || cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r))
    794794        return false;
    795795
    796     // Then test against the passability grid.
    797     return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_Grid);
     796    // Then test against the terrain grid. This should not be necessary
     797    // But in case we allow terrain to change it will become so.
     798    return Pathfinding::CheckLineMovement(x0, z0, x1, z1, passClass, *m_TerrainOnlyGrid);
    798799}
    799800
    800801ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter,
  • source/simulation2/helpers/Rasterize.cpp

     
    2525    const ICmpObstructionManager::ObstructionSquare& shape,
    2626    entity_pos_t clearance, entity_pos_t cellSize)
    2727{
     28    entity_pos_t realClearance = clearance + entity_pos_t::FromInt(1);
    2829    // Get the bounds of cells that might possibly be within the shape
    2930    // (We'll then test each of those cells more precisely)
    30     CFixedVector2D halfSize(shape.hw + clearance, shape.hh + clearance);
     31    CFixedVector2D halfSize(shape.hw + realClearance, shape.hh + realClearance);
    3132    CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(shape.u, shape.v, halfSize);
    3233    i16 i0 = ((shape.x - halfBound.X) / cellSize).ToInt_RoundToNegInfinity();
    3334    i16 j0 = ((shape.z - halfBound.Y) / cellSize).ToInt_RoundToNegInfinity();
     
    4142
    4243    for (i16 j = j0; j < j1; ++j)
    4344    {
    44         // Find the min/max range of cells that are strictly inside the square+clearance.
    45         // (Since the square+clearance is a convex shape, we can just test each
     45        // Find the min/max range of cells that are strictly inside the square+realClearance.
     46        // (Since the square+realClearance is a convex shape, we can just test each
    4647        // corner of each cell is inside the shape.)
    4748        // (TODO: This potentially does a lot of redundant work.)
    4849        i16 spanI0 = std::numeric_limits<i16>::max();
     
    5152        {
    5253            if (Geometry::DistanceToSquare(
    5354                CFixedVector2D(cellSize*i, cellSize*j) - CFixedVector2D(shape.x, shape.z),
    54                 shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > clearance)
     55                shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > realClearance)
    5556            {
    5657                continue;
    5758            }
     
    5859
    5960            if (Geometry::DistanceToSquare(
    6061                CFixedVector2D(cellSize*(i+1), cellSize*j) - CFixedVector2D(shape.x, shape.z),
    61                 shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > clearance)
     62                shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > realClearance)
    6263            {
    6364                continue;
    6465            }
     
    6566
    6667            if (Geometry::DistanceToSquare(
    6768                CFixedVector2D(cellSize*i, cellSize*(j+1)) - CFixedVector2D(shape.x, shape.z),
    68                 shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > clearance)
     69                shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > realClearance)
    6970            {
    7071                continue;
    7172            }
     
    7273
    7374            if (Geometry::DistanceToSquare(
    7475                CFixedVector2D(cellSize*(i+1), cellSize*(j+1)) - CFixedVector2D(shape.x, shape.z),
    75                 shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > clearance)
     76                shape.u, shape.v, CFixedVector2D(shape.hw, shape.hh), true) > realClearance)
    7677            {
    7778                continue;
    7879            }