Pyrogenesis trunk
Variables
anonymous_namespace{CCmpUnitMotion_System.cpp} Namespace Reference

Variables

constexpr int PUSHING_GRID_SIZE = 20
 Units push within their square and neighboring squares (except diagonals). More...
 
constexpr entity_pos_t PUSHING_CORRECTION = entity_pos_t::FromFraction(5, 7)
 For pushing, treat the clearances as a circle - they're defined as squares, so we'll take the circumscribing square (approximately). More...
 
constexpr int PUSHING_REDUCTION_FACTOR = 2
 Arbitrary constant used to reduce pushing to levels that won't break physics for our turn length. More...
 
constexpr entity_pos_t MAX_DISTANCE_FACTOR = entity_pos_t::FromFraction(5, 2)
 Maximum distance-related multiplier. More...
 
constexpr int MAX_PUSHING_MULTIPLIER = 4
 Maximum pushing multiplier for a single push calculation. More...
 
constexpr entity_pos_t PERPENDICULAR_NUDGE_THRESHOLD = entity_pos_t::FromFraction(-1, 10)
 When two units collide, if their movement dot product is below this value, give them a perpendicular nudge instead of trying to push in the regular way. More...
 
constexpr int MAX_PUSH_DAMPING_PRESSURE = 160
 Pushing is dampened by pushing pressure, but this is capped so that units still get pushed. More...
 
constexpr int MIN_PRESSURE_IF_OBSTRUCTED = 80
 When units are obstructed because they're being pushed away from where they want to go, raise the pushing pressure to at least this value. More...
 
constexpr entity_pos_t PRESSURE_STATIC_FACTOR = entity_pos_t::FromInt(2)
 These two numbers are used to calculate pushing pressure between two units. More...
 
constexpr int PRESSURE_DISTANCE_FACTOR = 5
 

Variable Documentation

◆ MAX_DISTANCE_FACTOR

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion_System.cpp}::MAX_DISTANCE_FACTOR = entity_pos_t::FromFraction(5, 2)
constexpr

Maximum distance-related multiplier.

NB: this value interacts with the "minimal pushing" force, as two perfectly overlapping units exert MAX_DISTANCE_FACTOR * Turn length in ms / REDUCTION_FACTOR of force on each other each turn. If this is below the minimal pushing force, any 2 units can entirely overlap.

◆ MAX_PUSH_DAMPING_PRESSURE

constexpr int anonymous_namespace{CCmpUnitMotion_System.cpp}::MAX_PUSH_DAMPING_PRESSURE = 160
constexpr

Pushing is dampened by pushing pressure, but this is capped so that units still get pushed.

◆ MAX_PUSHING_MULTIPLIER

constexpr int anonymous_namespace{CCmpUnitMotion_System.cpp}::MAX_PUSHING_MULTIPLIER = 4
constexpr

Maximum pushing multiplier for a single push calculation.

This exists for numerical stability of the system between a lightweight and a heavy unit.

◆ MIN_PRESSURE_IF_OBSTRUCTED

constexpr int anonymous_namespace{CCmpUnitMotion_System.cpp}::MIN_PRESSURE_IF_OBSTRUCTED = 80
constexpr

When units are obstructed because they're being pushed away from where they want to go, raise the pushing pressure to at least this value.

◆ PERPENDICULAR_NUDGE_THRESHOLD

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion_System.cpp}::PERPENDICULAR_NUDGE_THRESHOLD = entity_pos_t::FromFraction(-1, 10)
constexpr

When two units collide, if their movement dot product is below this value, give them a perpendicular nudge instead of trying to push in the regular way.

◆ PRESSURE_DISTANCE_FACTOR

constexpr int anonymous_namespace{CCmpUnitMotion_System.cpp}::PRESSURE_DISTANCE_FACTOR = 5
constexpr

◆ PRESSURE_STATIC_FACTOR

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion_System.cpp}::PRESSURE_STATIC_FACTOR = entity_pos_t::FromInt(2)
constexpr

These two numbers are used to calculate pushing pressure between two units.

◆ PUSHING_CORRECTION

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion_System.cpp}::PUSHING_CORRECTION = entity_pos_t::FromFraction(5, 7)
constexpr

For pushing, treat the clearances as a circle - they're defined as squares, so we'll take the circumscribing square (approximately).

Clerances are also full-width instead of half, so we want to divide by two. sqrt(2)/2 is about 0.71 < 5/7.

◆ PUSHING_GRID_SIZE

constexpr int anonymous_namespace{CCmpUnitMotion_System.cpp}::PUSHING_GRID_SIZE = 20
constexpr

Units push within their square and neighboring squares (except diagonals).

This is the size of each square (in meters). I have tested grid sizes from 10 up to 80 and overall it made little difference to the performance, mostly, I suspect, because pushing is generally dwarfed by regular motion costs. However, the algorithm remains n^2 in comparisons so it's probably best to err on the side of smaller grids, which will have lower spikes. The balancing act is between comparisons, unordered_set insertions and unordered_set iterations. For these reasons, a value of 20 which is rather small but not overly so was chosen.

◆ PUSHING_REDUCTION_FACTOR

constexpr int anonymous_namespace{CCmpUnitMotion_System.cpp}::PUSHING_REDUCTION_FACTOR = 2
constexpr

Arbitrary constant used to reduce pushing to levels that won't break physics for our turn length.