0ad/source/simulation2/helpers
wraitii 70ec7812de Improve UnitMotion behaviour when working around obstructions.
This improves behaviour when units need to go around a concave obstacle.
They would tend to clump inside the 'dead-end' before realising they
needed to go around. This was rather easy to trigger on Acropolis. See
included Unit Motion Integration Test.

The cause is the logic that removed the next long waypoint when
obstructed. While that behaviour is desirable, removing too many
waypoints means the unit tries to short-path, using a small domain
range, to a goal that's impassable, meaning they go as close as they can
in Euclidian distance, i.e. towards the dead end.

This changes that behaviour by only deleting waypoints within a certain
distance from the entity, scaling with search-space range. It's tricky
to find a good compromise between performance and behaviour here, but
the values I've picked seem OK.

However, the fact that the entity would ultimately remove all waypoints
and thus trigger a full path recomputation was actually a feature,
inherited from D2754 / 892f97743b. This diff therefore handles that
explicitly, doing so on a more regular basis to behave better overall.

As a further cleanup, "m_FailedPathComputations" is incremented in
HandleObstructedMove, as it is quite possible to never increment it in
PathResult despite not getting actionnable paths. This thus renames it
to m_FailedMovements, and uses the opportunity to clean up PathResult(),
by only having one path for both short and long-range paths. Further,
PathResult now does not immediately request new paths, leaving that to
Move(), to avoid requesting transient paths that aren't actionnable.
This also makes it possible to revert 9e41ff39fc. It requires increasing
the MAX_FAILED variable, or more units get stuck as they reach the max
more often.

The search-space expansion is slightly slowed, and with a little more
delay, as a performance optimisation. From testing, this doesn't impact
real movement much as units short paths tend to be invalidated by the
next turn, as other units move, anyways.

Clarify comment around the vertex-pathfinder search-space bounds hack,
and ensure it isn't used for the very worst cases of units being stuck,
as it could be a pessimisation then.

Finally, this explicits a 2011 hack where if the long-pathfinder fails
to return a valid path the goal's center is used directly. This happens
when the goal is unreachable to the long-pathfinder, which may be
because it is actually unreachable or because only the short-pathfinder
can reach it. In those situations, the hack allows a last-ditch attempt
at reaching it before failing to move entirely. Performance wise, this
is faster overall for actually unreachable goals, since it skips all the
intermediate steps. For reachable goals, it might be occasionally
slower, but that case is quite rare (certainly rarer than unreachable
goals).

Reported By: Angen
Fixes #5795

Differential Revision: https://code.wildfiregames.com/D3203
This was SVN commit r24429.
2020-12-19 10:45:07 +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 Fix most of the new vs2017 induced warnings. 2020-11-26 22:28:50 +00:00
HierarchicalPathfinder.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +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 Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
Los.h Move LOS to a los helper header and cleanup Grid.h includes. 2020-06-14 20:39:03 +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