HomeWildfire Games

Adapt unitMotion to edge-edge distance checks.


Adapt unitMotion to edge-edge distance checks.

D981/rP22345 changed IsInXChecks to use edge-to-edge distance instead of centre-to-edge, which broke UnitMotion's min-range movement, which assumed distance to the center.

Since units are represented as squares, the diagonal point may be closer to the target than the "real" clearance by a factor √2, so the delta between minimum range and maximum range should be at least (√2 - 1) * clearance to be safe in all situations (this is generally not a problem for regular units which have a clearance of 0.8, but could be one for catapults or elephants).

Differential Revision: https://code.wildfiregames.com/D1969