Page MenuHomeWildfire Games

Fix ranges when treating a target as a circle
ClosedPublic

Authored by wraitii on Jul 16 2019, 8:44 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP22495: Fix max-range approach when treating a target as a circle.
Trac Tickets
#5512
Summary

As reported by @bb in #5512, catapults and other big-range units might not approach targets correctly when trying to get in range.

The problem is that we can't ask the pathfinder to go in range of a rounded rectangle.
So we approximate the target as a circle. But we pick the circumscribing circle. In cases where we don't approach the corner, the distance "circumscribing-circle" to entity will be higher than the real "square-obstruction" to entity distance, and we won't get in range.

To fix this, we need to get in range of the inscribed circle.

Test Plan

This fixes the replay at #5512.
Review that it makes sense mathematically.

Diff Detail

Event Timeline

wraitii created this revision.Jul 16 2019, 8:44 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/100/display/redirect

bb added a comment.Jul 16 2019, 9:30 PM

Didn't test it, but what happens now if minRange =~ maxRange, then it could be that the circumscribed circle for the minRange is bigger than the inscribed circle for maxRange...

In D2086#86910, @bb wrote:

Didn't test it, but what happens now if minRange =~ maxRange, then it could be that the circumscribed circle for the minRange is bigger than the inscribed circle for maxRange...

Well, as soon as the unit gets in actual range, it will be detected by PossiblyAtDestination, and the entity will warn UnitAI that it's in range, and vice-versa.
So it would still work. Obviously this isn't a perfect situation.

bb added a comment.Jul 16 2019, 9:40 PM

But will it get in range? (I did not test it!!) If the minRange is so large the path might end outside the maxRange area and thus we never get there

This comment was removed by wraitii.
wraitii updated this revision to Diff 8938.Jul 16 2019, 10:07 PM

Add comment clarifying a pathological edge-case that one could run into.

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/103/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Jul 17 2019, 8:08 PM
This revision was automatically updated to reflect the committed changes.