Ticket #3577: reverting.patch

File reverting.patch, 1.6 KB (added by mimo, 9 years ago)
  • source/simulation2/components/CCmpUnitMotion.cpp

     
    14951495    // is a round-cornered square which we can approximate as either a circle or as a square.
    14961496    // Choose the shape that will minimise the worst-case error:
    14971497
    1498     entity_pos_t rSquare = std::min(hw, hh);
    1499     if (range < rSquare)
    1500         return false;
    1501 
    15021498    // 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);
    15041500
    15051501    // 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);
    15071503
    15081504    return (errCircle < errSquare);
    15091505}
     
    15861582        entity_pos_t circleRadius = halfSize.Length();
    15871583
    15881584        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);
    15911585
    15921586        if (ShouldTreatTargetAsCircle(minRange, obstruction.hw, obstruction.hh, circleRadius))
    15931587        {
    15941588            // The target is small relative to our range, so pretend it's a circle
    15951589            goal.type = PathGoal::INVERTED_CIRCLE;
    1596             goal.hw = goalDistance;
     1590            goal.hw = circleRadius + goalDistance;
    15971591        }
    15981592        else
    15991593        {