Ticket #3577: reverting.patch
File reverting.patch, 1.6 KB (added by , 9 years ago) |
---|
-
source/simulation2/components/CCmpUnitMotion.cpp
1495 1495 // is a round-cornered square which we can approximate as either a circle or as a square. 1496 1496 // Choose the shape that will minimise the worst-case error: 1497 1497 1498 entity_pos_t rSquare = std::min(hw, hh);1499 if (range < rSquare)1500 return false;1501 1502 1498 // For a square, error is (sqrt(2)-1) * (range-rSquare) at the corners 1503 entity_pos_t errSquare = (entity_pos_t::FromInt(4142)/10000).Multiply(range -rSquare);1499 entity_pos_t errSquare = (entity_pos_t::FromInt(4142)/10000).Multiply(range); 1504 1500 1505 1501 // For a circle, error is radius-hw at the sides and radius-hh at the top/bottom 1506 entity_pos_t errCircle = circleRadius - rSquare;1502 entity_pos_t errCircle = circleRadius - std::min(hw, hh); 1507 1503 1508 1504 return (errCircle < errSquare); 1509 1505 } … … 1586 1582 entity_pos_t circleRadius = halfSize.Length(); 1587 1583 1588 1584 entity_pos_t goalDistance = minRange + Pathfinding::GOAL_DELTA; 1589 // ensure it's far enough to not intersect the building itself (TODO is it really needed for inverted move ?)1590 goalDistance = std::max(goalDistance, m_Clearance + entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/16);1591 1585 1592 1586 if (ShouldTreatTargetAsCircle(minRange, obstruction.hw, obstruction.hh, circleRadius)) 1593 1587 { 1594 1588 // The target is small relative to our range, so pretend it's a circle 1595 1589 goal.type = PathGoal::INVERTED_CIRCLE; 1596 goal.hw = goalDistance;1590 goal.hw = circleRadius + goalDistance; 1597 1591 } 1598 1592 else 1599 1593 {