Skip to main content

SimConfig

Struct SimConfig 

Source
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: f32

Downward acceleration in world units per second squared.

§substeps: u32

Velocity/position passes per step. More substeps buy stiffer stacks at a near-linear cost; below 1 the step does nothing.

§contact_hertz: f32

Contact 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: f32

Contact damping ratio. Above 1 the contact is overdamped, which is what stops a resting stack from breathing.

§joint_hertz: f32

Joint 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: f32

Joint 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: f32

Ceiling on the speed penetration is pushed out at, so a deep overlap resolves over several steps instead of launching.

§linear_slop: f32

Penetration the solver leaves alone. Resting contacts settle just inside the surface, which keeps them from being lost and remade.

§speculative_margin: f32

Gap within which a contact is still created, so an approaching body is slowed before it overlaps rather than after.

§restitution_threshold: f32

Approach speed below which a contact does not bounce, whatever the restitution. Without it a bouncy body never comes to rest.

§allow_sleep: bool

Whether a settled island stops being simulated.

§sleep_linear_velocity: f32

Speed below which a body counts as still, in world units per second.

§sleep_angular_velocity: f32

Spin below which a body counts as still, in radians per second.

§time_to_sleep: f32

How long a whole island must be still before it sleeps, in seconds.

§bounds_margin: f32

Slack added to a body’s bounds, so small motion does not invalidate them.

§ccd_enabled: bool

Whether 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: f32

Fraction 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.

Trait Implementations§

Source§

impl Clone for SimConfig

Source§

fn clone(&self) -> SimConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SimConfig

Source§

impl Debug for SimConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SimConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SimConfig

Source§

fn eq(&self, other: &SimConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SimConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.