IntegrationParameters

Struct IntegrationParameters 

Source
pub struct IntegrationParameters {
Show 13 fields pub dt: f32, pub min_ccd_dt: f32, pub contact_softness: SpringCoefficients<f32>, pub warmstart_coefficient: f32, pub length_unit: f32, pub normalized_allowed_linear_error: f32, pub normalized_max_corrective_velocity: f32, pub normalized_prediction_distance: f32, pub num_solver_iterations: usize, pub num_internal_pgs_iterations: usize, pub num_internal_stabilization_iterations: usize, pub min_island_size: usize, pub max_ccd_substeps: usize,
}
Expand description

Configuration parameters that control the physics simulation quality and behavior.

These parameters affect how the physics engine advances time, resolves collisions, and maintains stability. The defaults work well for most games, but you may want to adjust them based on your specific needs.

§Key parameters for beginners

  • dt: Timestep duration (default: 1/60 second). Most games run physics at 60Hz.
  • num_solver_iterations: More iterations = more accurate but slower (default: 4)
  • length_unit: Scale factor if your world units aren’t meters (e.g., 100 for pixel-based games)

§Example

// Standard 60 FPS physics with default settings
let mut integration_params = IntegrationParameters::default();

// For a more accurate (but slower) simulation:
integration_params.num_solver_iterations = 8;

// For pixel-based 2D games where 100 pixels = 1 meter:
integration_params.length_unit = 100.0;

Most other parameters are advanced settings for fine-tuning stability and performance.

Fields§

§dt: f32

The timestep length - how much simulated time passes per physics step (default: 1.0 / 60.0).

Set this to 1.0 / your_target_fps. For example:

  • 60 FPS: 1.0 / 60.0 ≈ 0.0167 seconds
  • 120 FPS: 1.0 / 120.0 ≈ 0.0083 seconds

Smaller timesteps are more accurate but require more CPU time per second of simulated time.

§min_ccd_dt: f32

Minimum timestep size when using CCD with multiple substeps (default: 1.0 / 60.0 / 100.0).

When CCD with multiple substeps is enabled, the timestep is subdivided into smaller pieces. This timestep subdivision won’t generate timestep lengths smaller than min_ccd_dt.

Setting this to a large value will reduce the opportunity to performing CCD substepping, resulting in potentially more time dropped by the motion-clamping mechanism. Setting this to an very small value may lead to numerical instabilities.

§contact_softness: SpringCoefficients<f32>

Softness coefficients for contact constraints.

§warmstart_coefficient: f32

The coefficient in [0, 1] applied to warmstart impulses, i.e., impulses that are used as the initial solution (instead of 0) at the next simulation step.

This should generally be set to 1.

(default 1.0).

§length_unit: f32

The scale factor for your world if you’re not using meters (default: 1.0).

Rapier is tuned for human-scale objects measured in meters. If your game uses different units, set this to how many of your units equal 1 meter in the real world.

Examples:

  • Your game uses meters: length_unit = 1.0 (default)
  • Your game uses centimeters: length_unit = 100.0 (100 cm = 1 m)
  • Pixel-based 2D game where typical objects are 100 pixels tall: length_unit = 100.0
  • Your game uses feet: length_unit = 3.28 (approximately)

This automatically scales various internal tolerances and thresholds to work correctly with your chosen units.

§normalized_allowed_linear_error: f32

Amount of penetration the engine won’t attempt to correct (default: 0.001m).

This value is implicitly scaled by IntegrationParameters::length_unit.

§normalized_max_corrective_velocity: f32

Maximum amount of penetration the solver will attempt to resolve in one timestep (default: 10.0).

This value is implicitly scaled by IntegrationParameters::length_unit.

§normalized_prediction_distance: f32

The maximal distance separating two objects that will generate predictive contacts (default: 0.002m).

This value is implicitly scaled by IntegrationParameters::length_unit.

§num_solver_iterations: usize

The number of solver iterations run by the constraints solver for calculating forces (default: 4).

Higher values produce more accurate and stable simulations at the cost of performance.

  • 4 (default): Good balance for most games
  • 8-12: Use for demanding scenarios (stacks of objects, complex machinery)
  • 1-2: Use if performance is critical and accuracy can be sacrificed
§num_internal_pgs_iterations: usize

Number of internal Project Gauss Seidel (PGS) iterations run at each solver iteration (default: 1).

§num_internal_stabilization_iterations: usize

The number of stabilization iterations run at each solver iterations (default: 1).

§min_island_size: usize

Minimum number of dynamic bodies on each active island (default: 128).

§max_ccd_substeps: usize

Maximum number of substeps performed by the solver (default: 1).

Implementations§

Source§

impl IntegrationParameters

Source

pub fn inv_dt(&self) -> f32

The inverse of the time-stepping length, i.e. the steps per seconds (Hz).

This is zero if self.dt is zero.

Source

pub fn set_dt(&mut self, dt: f32)

👎Deprecated: You can just set the IntegrationParams::dt value directly

Sets the time-stepping length.

Source

pub fn set_inv_dt(&mut self, inv_dt: f32)

Sets the inverse time-stepping length (i.e. the frequency).

This automatically recompute self.dt.

Source

pub fn allowed_linear_error(&self) -> f32

Amount of penetration the engine won’t attempt to correct (default: 0.001 multiplied by Self::length_unit).

Source

pub fn max_corrective_velocity(&self) -> f32

Maximum amount of penetration the solver will attempt to resolve in one timestep.

This is equal to Self::normalized_max_corrective_velocity multiplied by Self::length_unit.

Source

pub fn prediction_distance(&self) -> f32

The maximal distance separating two objects that will generate predictive contacts (default: 0.002m multiped by Self::length_unit).

Trait Implementations§

Source§

impl Clone for IntegrationParameters

Source§

fn clone(&self) -> IntegrationParameters

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IntegrationParameters

Source§

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

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

impl Default for IntegrationParameters

Source§

fn default() -> Self

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

impl PartialEq for IntegrationParameters

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for IntegrationParameters

Source§

impl StructuralPartialEq for IntegrationParameters

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = Infallible

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.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,