Index: source/simulation2/components/CCmpObstructionManager.cpp =================================================================== --- source/simulation2/components/CCmpObstructionManager.cpp +++ source/simulation2/components/CCmpObstructionManager.cpp @@ -849,7 +849,7 @@ // actual radius used for unit-unit collisions. If relaxClearanceForUnits, will be smaller to allow more overlap. entity_pos_t unitUnitRadius = r; if (relaxClearanceForUnits) - unitUnitRadius -= entity_pos_t::FromInt(1)/2; + unitUnitRadius -= entity_pos_t::FromInt(1)/3; std::vector unitShapes; m_UnitSubdivision.GetInRange(unitShapes, posMin, posMax); @@ -1310,7 +1310,7 @@ { m_DebugOverlayLines.push_back(SOverlayLine()); m_DebugOverlayLines.back().m_Color = ((it->second.flags & FLAG_MOVING) ? movingColor : defaultColor); - SimRender::ConstructSquareOnGround(GetSimContext(), it->second.x.ToFloat(), it->second.z.ToFloat(), it->second.clearance.ToFloat()*2, it->second.clearance.ToFloat()*2, 0, m_DebugOverlayLines.back(), true); + SimRender::ConstructSquareOnGround(GetSimContext(), it->second.x.ToFloat(), it->second.z.ToFloat(), it->second.clearance.ToFloat(), it->second.clearance.ToFloat(), 0, m_DebugOverlayLines.back(), true); } for (std::map::iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it) Index: source/simulation2/helpers/VertexPathfinder.cpp =================================================================== --- source/simulation2/helpers/VertexPathfinder.cpp +++ source/simulation2/helpers/VertexPathfinder.cpp @@ -567,7 +567,7 @@ CFixedVector2D v = squares[i].v; if (i >= staticShapesNb) - pathfindClearance = request.clearance - entity_pos_t::FromInt(1)/2; + pathfindClearance = request.clearance - entity_pos_t::FromInt(1)/3; // Expand the vertexes by the moving unit's collision radius, to find the // closest we can get to it @@ -581,7 +581,6 @@ Vertex vert; vert.status = Vertex::UNEXPLORED; vert.quadInward = QUADRANT_NONE; - vert.quadOutward = QUADRANT_ALL; vert.p.X = center.X - hd0.Dot(u); vert.p.Y = center.Y + hd0.Dot(v); @@ -607,6 +606,8 @@ if (vert.p.X >= rangeXMin && vert.p.Y >= rangeZMin && vert.p.X <= rangeXMax && vert.p.Y <= rangeZMax) m_Vertexes.push_back(vert); + vert.quadOutward = (~vert.quadInward) & 0xF; + // Add the edges: CFixedVector2D h0(squares[i].hw + pathfindClearance, squares[i].hh + pathfindClearance); @@ -637,7 +638,7 @@ } // Clip out vertices that are inside an edgeSquare (i.e. trivially unreachable) - for (size_t i = 0; i < m_EdgeSquares.size(); ++i) + for (size_t i = 2; i < m_EdgeSquares.size(); ++i) { // If the start point is inside the square, ignore it if (start.p.X >= m_EdgeSquares[i].p0.X && @@ -720,8 +721,8 @@ // To prevent integer overflows later on, we need to ensure all vertexes are // 'close' to the source. The goal might be far away (not a good idea but // sometimes it happens), so clamp it to the current search range - npos.X = clamp(npos.X, rangeXMin, rangeXMax); - npos.Y = clamp(npos.Y, rangeZMin, rangeZMax); + npos.X = clamp(npos.X, rangeXMin + EDGE_EXPAND_DELTA, rangeXMax - EDGE_EXPAND_DELTA); + npos.Y = clamp(npos.Y, rangeZMin + EDGE_EXPAND_DELTA, rangeZMax - EDGE_EXPAND_DELTA); } else npos = m_Vertexes[n].p; @@ -734,7 +735,7 @@ if (m_Vertexes[curr.id].p.X >= npos.X && m_Vertexes[curr.id].p.Y <= npos.Y) quad |= QUADRANT_BR; // Check that the new vertex is in the right quadrant for the old vertex - if (!(m_Vertexes[curr.id].quadOutward & quad)) + if (!(m_Vertexes[curr.id].quadOutward & quad) && curr.id != START_VERTEX_ID) { // Hack: Always head towards the goal if possible, to avoid missing it if it's // inside another unit @@ -765,13 +766,6 @@ m_Vertexes[n].h = request.goal.DistanceToPoint(npos); m_Vertexes[n].pred = curr.id; - // If this is an axis-aligned shape, the path must continue in the same quadrant - // direction (but not go into the inside of the shape). - // Hack: If we started *inside* a shape then perhaps headed to its corner (e.g. the unit - // was very near another unit), don't restrict further pathing. - if (m_Vertexes[n].quadInward && !(curr.id == START_VERTEX_ID && g < fixed::FromInt(8))) - m_Vertexes[n].quadOutward = ((m_Vertexes[n].quadInward) & quad) & 0xF; - if (n == GOAL_VERTEX_ID) m_Vertexes[n].p = npos; // remember the new best goal position @@ -797,11 +791,6 @@ m_Vertexes[n].g = g; m_Vertexes[n].pred = curr.id; - // If this is an axis-aligned shape, the path must continue in the same quadrant - // direction (but not go into the inside of the shape). - if (m_Vertexes[n].quadInward) - m_Vertexes[n].quadOutward = ((m_Vertexes[n].quadInward) & quad) & 0xF; - if (n == GOAL_VERTEX_ID) m_Vertexes[n].p = npos; // remember the new best goal position