Ticket #3471: FixStuckUnits.patch
File FixStuckUnits.patch, 4.8 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/data/pathfinder.xml
11 11 <Obstructions>pathfinding</Obstructions> 12 12 <MaxWaterDepth>2</MaxWaterDepth> 13 13 <MaxTerrainSlope>1.0</MaxTerrainSlope> 14 <Clearance> 1.0</Clearance>14 <Clearance>0.8</Clearance> 15 15 </default> 16 16 <large> 17 17 <Obstructions>pathfinding</Obstructions> -
source/simulation2/components/CCmpPathfinder_Vertex.cpp
127 127 // When computing vertexes to insert into the search graph, 128 128 // add a small delta so that the vertexes of an edge don't get interpreted 129 129 // as crossing the edge (given minor numerical inaccuracies) 130 static const entity_pos_t EDGE_EXPAND_DELTA = entity_pos_t::FromInt(1)/ 4;130 static const entity_pos_t EDGE_EXPAND_DELTA = entity_pos_t::FromInt(1)/16; 131 131 132 132 /** 133 133 * Check whether a ray from 'a' to 'b' crosses any of the edges. -
source/simulation2/components/CCmpPathfinder.cpp
793 793 if (!cmpObstructionManager || cmpObstructionManager->TestLine(filter, x0, z0, x1, z1, r)) 794 794 return false; 795 795 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); 798 799 } 799 800 800 801 ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, -
source/simulation2/helpers/Rasterize.cpp
25 25 const ICmpObstructionManager::ObstructionSquare& shape, 26 26 entity_pos_t clearance, entity_pos_t cellSize) 27 27 { 28 entity_pos_t realClearance = clearance + entity_pos_t::FromInt(1); 28 29 // Get the bounds of cells that might possibly be within the shape 29 30 // (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); 31 32 CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(shape.u, shape.v, halfSize); 32 33 i16 i0 = ((shape.x - halfBound.X) / cellSize).ToInt_RoundToNegInfinity(); 33 34 i16 j0 = ((shape.z - halfBound.Y) / cellSize).ToInt_RoundToNegInfinity(); … … 41 42 42 43 for (i16 j = j0; j < j1; ++j) 43 44 { 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 each45 // 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 46 47 // corner of each cell is inside the shape.) 47 48 // (TODO: This potentially does a lot of redundant work.) 48 49 i16 spanI0 = std::numeric_limits<i16>::max(); … … 51 52 { 52 53 if (Geometry::DistanceToSquare( 53 54 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) 55 56 { 56 57 continue; 57 58 } … … 58 59 59 60 if (Geometry::DistanceToSquare( 60 61 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) 62 63 { 63 64 continue; 64 65 } … … 65 66 66 67 if (Geometry::DistanceToSquare( 67 68 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) 69 70 { 70 71 continue; 71 72 } … … 72 73 73 74 if (Geometry::DistanceToSquare( 74 75 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) 76 77 { 77 78 continue; 78 79 }