0ad/source/simulation2/helpers
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
..
CinemaPath.cpp Move CinemaPath class to the simulation helper directory, because it contains predominantly simulation data that is already serialized. 2017-04-14 23:20:49 +00:00
CinemaPath.h Move CinemaPath class to the simulation helper directory, because it contains predominantly simulation data that is already serialized. 2017-04-14 23:20:49 +00:00
Geometry.cpp Avoid overflow in UnitMotion. 2020-11-09 13:25:50 +00:00
Geometry.h Implements correct distance to edges for the building snapping feature. 2020-08-17 20:13:18 +00:00
Grid.h Use templates to replace explicit serialization helpers. 2020-12-19 09:10:37 +00:00
HierarchicalPathfinder.cpp Replaces UNICODE characters in the code by consistent ASCII characters. 2021-01-15 10:07:36 +00:00
HierarchicalPathfinder.h Fixes revealed missed includes after e104b41be2. 2021-03-03 22:38:59 +00:00
LongPathfinder.cpp Fix a m_JumpPointCache assertion failure in debug mode, refs fa726867f1. 2019-06-04 08:29:47 +00:00
LongPathfinder.h Add a simple 'pushing' logic to unit motion to improve movement. 2021-04-02 16:30:59 +00:00
Los.h Decouple LOS resolution from terrain resolution 2021-03-02 16:44:40 +00:00
MapEdgeTiles.h Unify the magic number indicating the number of impassable tiles at the map edge redundant in the Pathfinder, RangeManager and MapGenerator. 2019-07-12 16:38:51 +00:00
Pathfinding.cpp Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
Pathfinding.h Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
PathGoal.cpp Consider that the point could be inside the goal area in some PathGoal functions 2018-01-16 02:15:04 +00:00
PathGoal.h Consider that the point could be inside the goal area in some PathGoal functions 2018-01-16 02:15:04 +00:00
Player.h Set svn:eol-style=native, fix some inconsistent line endings 2013-12-06 00:42:50 +00:00
Position.h Rename CELL_SIZE to TERRAIN_TILE_SIZE, to free up the term "cell" for other concepts. 2012-01-12 12:51:10 +00:00
PriorityQueue.h New long-range pathfinder. 2015-06-12 18:58:24 +00:00
Rasterize.cpp Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
Rasterize.h Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
Render.cpp Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
Render.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
Selection.cpp RangeManager: Grid for 2D array, enum cleanups. 2020-06-13 09:05:40 +00:00
Selection.h Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
SimulationCommand.h Clean up header includes, add new forward declarations. 2020-11-21 11:20:29 +00:00
Spatial.h Use templates to replace explicit serialization helpers. 2020-12-19 09:10:37 +00:00
VertexPathfinder.cpp Improve UnitMotion behaviour when working around obstructions. 2020-12-19 10:45:07 +00:00
VertexPathfinder.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00