(built on top of D13 and some other changes, seeOn Github: https://github.com/wraitii/0ad/tree/D1490_unit_pushing)motionmanager
This implements (somewhat//very// naively) unit pushing each other when moving, instead of relying entirely on the short-range pathfinder for avoidance.
The short-range pathfinder isn't removed, as it can still be useful inside UnitMotion.
Main benefits:Design goals:
- Movement looks more natural in crowds.
- Less short path requests probably makes this overall faster, though I haven't profiled a lot of casesFewer short path requests making the game faster in general (despite pushing taking some time to compute - I think it's an easy win overall).
- Less reliance on the short-pathfinder reducing the # of issues with it.
- Formation units can no longer phas- Ideally be through each otheread-able.
- Fundamentally might make it harder to avoid units "phasing" through each other.
- Fundamentally introduces more movement in units, which might look odd sometimes.
- Still needs the short range pathfinder to exist to get around some types of obstacle.
Open design questions:
- Units are way more huddled together (test out Combat Demo Huge), though that's dependent on- How much to pushing settings.?
- Might lead to- Should some bouncing at the moment,units be unpushable? needs toShould enemy units be sorted out.un-pushable?
The currentOpen implementation is not threaded,questions:
- How to know when we can't "push through" and need to trigger an "obstructed" call. and not perfectIt looks weird when ordering many units to clump together.
Implementation-wise, as Ithis has two main compareonents:
- A units in their own subdivision and not next to them.MotionManager that splits unit Motion in phases, This is incorrect, but looks good enough and is faster since my implementation is currently O(N^2) on N=number of units to compare toso that we can have a "middle" phase where units don't send messages and can be used for pushing safely and quickly.
- Actually pushing stuff.
The pushing function itself can be improvedMy current implementation is braindead, and basically compares all units with all other units (once), essentially a n^2 algorithm. It remains pretty fast however. I think some subdivision will be necessary to avoid the n^2 exploding too much, but since the short-pathfinder is n^3+ we have a fairly good margin to work with.