Ticket #3405: ticket3405-improv.diff
File ticket3405-improv.diff, 1.6 KB (added by , 9 years ago) |
---|
-
source/simulation2/components/CCmpUnitMotion.cpp
1590 1590 { 1591 1591 // Too close to the square - need to move away 1592 1592 1593 // TODO: maybe we should do the ShouldTreatTargetAsCircle thing here? 1593 // Circumscribe the square 1594 entity_pos_t circleRadius = halfSize.Length(); 1594 1595 1595 1596 entity_pos_t goalDistance = minRange + Pathfinding::GOAL_DELTA; 1597 // ensure it's far enough to not intersect the building itself (TODO is it really needed for inverted move ?) 1598 goalDistance = std::max(goalDistance, m_Clearance + entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/16); 1596 1599 1597 goal.type = PathGoal::INVERTED_SQUARE; 1598 goal.u = obstruction.u; 1599 goal.v = obstruction.v; 1600 entity_pos_t delta = std::max(goalDistance, m_Clearance + entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/16); // ensure it's far enough to not intersect the building itself 1601 goal.hw = obstruction.hw + delta; 1602 goal.hh = obstruction.hh + delta; 1600 if (ShouldTreatTargetAsCircle(minRange, obstruction.hw, obstruction.hh, circleRadius)) 1601 { 1602 // The target is small relative to our range, so pretend it's a circle 1603 goal.type = PathGoal::INVERTED_CIRCLE; 1604 goal.hw = goalDistance; 1605 } 1606 else 1607 { 1608 goal.type = PathGoal::INVERTED_SQUARE; 1609 goal.u = obstruction.u; 1610 goal.v = obstruction.v; 1611 goal.hw = obstruction.hw + goalDistance; 1612 goal.hh = obstruction.hh + goalDistance; 1613 } 1603 1614 } 1604 1615 else if (maxRange < entity_pos_t::Zero() || distance < maxRange || previousDistance < maxRange) 1605 1616 {