PhysicsConfig
How a PhysicsWorld moves time. Every value is in world units and seconds, so a world behaves the same however finely it is stepped, except where a value says otherwise. Pass the values by name.
Two configs are equal when every value is. toString gives every value in constructor order, as PhysicsConfig(gravity=Vec2(0.0, 1500.0), substeps=4, ...); the format may change.
Throws
if a value is outside the range its description gives.
Samples
// Moon gravity, stiffer solving, and rigid bodies that never fall asleep.
val config = PhysicsConfig(
gravity = Vec2(0f, 250f),
substeps = 8,
timeToSleep = Duration.INFINITE,
)
val world = PhysicsWorld(config)
assertPrints(world.config.substeps, "8")
assertPrints(config == PhysicsConfig(gravity = Vec2(0f, 250f), substeps = 8, timeToSleep = Duration.INFINITE), "true")Properties
Slower than this into a surface, in units per second, nothing bounces, whatever its restitution: resting things settle instead of buzzing. Gravity alone reaches it in a fall of under a unit.
Side of a cell of the broadphases that find which things might touch, in units, or Broadphase.AUTO, the default, to size the cells at every step to what is in them. About the size of a body works best.
How fast motion dies away, per second, finite and not negative: velocity is multiplied by exp(-damping * h) every substep of h seconds, so the same damping loses the same share of speed per second however many substeps there are. 0 keeps all of it; 0.24 loses about a fifth per second.
Number of constraint passes per substep, at least 1, each followed by collision, so walls have the last word.
Slower than this, in units per second, a rigid body counts as still: its speed, plus how fast its farthest point goes round as it turns.
Number of substeps each PhysicsWorld.step is cut into, at least 1. More is stiffer and steadier, and costs more.
How long a rigid body and everything it touches must be still before they fall asleep and stop costing time, more than zero; Duration.INFINITE for never.