0ad/source
wraitii 592453c62f Add a simple 'pushing' logic to unit motion to improve movement.
This implements a form of crowd movement that I've generally called
'unit pushing' in the last few years.
Essentially, any two units will push each other away when they're too
close. This makes it possible to ignore unit-unit obstructions, and thus
makes movement much smoother in crowds.
This first iteration of this system only allows pushing between idle
units and between moving units (i.e. a moving unit does not affect an
idle one).
This is because the unitMotion logic to detect it is stuck & needs to
use the pathfinders starts breaking: units can fail to move because they
are pushed away from their intended movement, and the current logic
fails to handle this gracefully.
Thankfully, the most value of this patch in terms of player experience
is found in the improvements to group movements and shuttling.

Other impacts:
- As the short pathfinder is called less often, we can increase the
starting search range & reduce the # of max turns, both improving
collision recovery.
- The performance of idle units is slightly worsened, as they must be
checked for idle-idle collisions. If needed a 'sleeping' system, as used
in physics engine, could be implemented.
- In general, however, expect slight performance improvements, as fewer
short paths are computed.
- Gathering efficiency should increase slightly, since shuttling times
are likely reduced slightly.
- As a sanity change to improve some edge cases (units that say they're
moving, i.e. pushable, but don't actually move), the 'going straight'
logic is turned off if a short path has been computed. This requires a
few cascading changes to work correctly.

Technical notes:
- To reduce the cost of the n^2 comparisons that pushing requires, units
are only compared within a small square on a grid which is lazily
reconstructed each turn. The overhead seems rather small, and this is
much simpler than keeping an up-to-date grid.
- The design is intended to be parallelisable if needed someday.
- The pathfinder's CheckMovement ignores moving units in UnitMotion, as
that is now the spec. Idle units are not ignored, which is required for
the 'collision' detection to work correctly (see above).

Refs #3442 (not fixed - idle units are not pushed by moving units).
Fixes #5084 (the overlap can still happen, but units will push each
other away).

Differential Revision: https://code.wildfiregames.com/D1490
This was SVN commit r25182.
2021-04-02 16:30:59 +00:00
..
collada Refactors smart pointers creation, reduces code duplication and improves exception safety. 2021-02-13 23:53:40 +00:00
graphics Moves CRect from ps to maths to related geometric primitives. 2021-03-30 21:14:36 +00:00
gui Fix console not preventing hotkeys from firing / Clean up hotkey-input conflict. 2021-04-02 14:18:20 +00:00
i18n Moves CreateDateTimeInstance from the public L10n header to its implementation. 2021-03-12 09:11:22 +00:00
lib Fix console not preventing hotkeys from firing / Clean up hotkey-input conflict. 2021-04-02 14:18:20 +00:00
lobby Fix typos in log and warn messages 2021-03-10 16:50:15 +00:00
maths Moves CRect from ps to maths to related geometric primitives. 2021-03-30 21:14:36 +00:00
mocks More FreeBSD build fixes. 2012-01-30 06:21:11 +00:00
network Remember OOS on a per-client basis. 2021-03-31 15:55:19 +00:00
pch Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
ps Don't error in the network delay notifier. 2021-04-02 14:20:37 +00:00
renderer Moves Frustum from graphics to maths to more related geometric primitives like bounding ones. 2021-03-29 17:28:13 +00:00
rlinterface Increase MP Command delay to 4 turns, decrease MP turns to 200ms. 2021-03-03 21:02:57 +00:00
scriptinterface Replaces CPos by more a consistent CVector2D, reduces geometry code duplication. 2021-03-28 21:55:13 +00:00
simulation2 Add a simple 'pushing' logic to unit motion to improve movement. 2021-04-02 16:30:59 +00:00
soundmanager Fix compilation with --without-audio 2021-03-04 17:36:24 +00:00
third_party Optimization for include resolving in PreprocessorWrapper. 2021-01-20 23:05:15 +00:00
tools Moves CRect from ps to maths to related geometric primitives. 2021-03-30 21:14:36 +00:00
main.cpp Make real directory paths on the VFS predictable (retry) 2021-03-23 12:46:59 +00:00
test_setup.cpp Introduce C++ templates replacements for DEFINE_INTERFACE_X and RegisterFunction macros 2021-03-01 20:52:24 +00:00