pub struct SimConfig {Show 17 fields
pub gravity: f32,
pub substeps: u32,
pub contact_hertz: f32,
pub contact_damping_ratio: f32,
pub joint_hertz: f32,
pub joint_damping_ratio: f32,
pub max_push_velocity: f32,
pub linear_slop: f32,
pub speculative_margin: f32,
pub restitution_threshold: f32,
pub allow_sleep: bool,
pub sleep_linear_velocity: f32,
pub sleep_angular_velocity: f32,
pub time_to_sleep: f32,
pub bounds_margin: f32,
pub ccd_enabled: bool,
pub ccd_motion_ratio: f32,
}Expand description
Tuning for one simulation.
SimConfig::default is what the engine runs with; the fields are public
so a caller reproducing a recorded step, or trading stability for speed,
can set them explicitly.
Fields§
§gravity: f32Downward acceleration in world units per second squared.
substeps: u32Velocity/position passes per step. More substeps buy stiffer stacks at
a near-linear cost; below 1 the step does nothing.
contact_hertz: f32Contact stiffness as a frequency in hertz. Clamped against the substep rate, since a contact cannot be stiffer than the rate it is solved at.
contact_damping_ratio: f32Contact damping ratio. Above 1 the contact is overdamped, which is
what stops a resting stack from breathing.
joint_hertz: f32Joint stiffness as a frequency in hertz, clamped against the substep rate the same way the contact one is. Joints are held stiffer than contacts because a contact that sinks a millimetre is still right and a joint that gives a millimetre reads as broken.
joint_damping_ratio: f32Joint damping ratio. Far lower than the contact one, and damped at all only so a joint built out of place settles rather than ringing as it closes: the correction’s damping is what bleeds a pendulum’s swing, so every part of it that is not needed is energy a joint gives back.
max_push_velocity: f32Ceiling on the speed penetration is pushed out at, so a deep overlap resolves over several steps instead of launching.
linear_slop: f32Penetration the solver leaves alone. Resting contacts settle just inside the surface, which keeps them from being lost and remade.
speculative_margin: f32Gap within which a contact is still created, so an approaching body is slowed before it overlaps rather than after.
restitution_threshold: f32Approach speed below which a contact does not bounce, whatever the restitution. Without it a bouncy body never comes to rest.
allow_sleep: boolWhether a settled island stops being simulated.
sleep_linear_velocity: f32Speed below which a body counts as still, in world units per second.
sleep_angular_velocity: f32Spin below which a body counts as still, in radians per second.
time_to_sleep: f32How long a whole island must be still before it sleeps, in seconds.
bounds_margin: f32Slack added to a body’s bounds, so small motion does not invalidate them.
ccd_enabled: boolWhether a body that outruns the step’s own contact test is caught by a sweep. On for every freely simulated and position-driven body, since without it one passes straight through thin geometry.
ccd_motion_ratio: f32Fraction of a body’s thinnest dimension its motion over one step has to exceed before that sweep runs.
At or below 1 nothing can outrun the gate: passing through anything
takes more motion than the mover’s own width, so the sweep is already
armed by the time tunnelling is possible. The margin below 1 covers
the rotation the sweep does not model.