pub struct RigidBodyActivation {
pub normalized_linear_threshold: f32,
pub angular_threshold: f32,
pub time_until_sleep: f32,
pub time_since_can_sleep: f32,
pub sleeping: bool,
}Expand description
Controls when a body goes to sleep (becomes inactive to save CPU).
§Sleeping System
Bodies automatically sleep when they’re at rest, dramatically improving performance in scenes with many inactive objects. Sleeping bodies are:
- Excluded from simulation (no collision detection, no velocity integration)
- Automatically woken when disturbed (hit by moving object, connected via joint)
- Woken manually with
body.wake_up()orislands.wake_up()
§How sleeping works
A body sleeps after its linear AND angular velocities stay below thresholds for
time_until_sleep seconds (default: 2 seconds). Set thresholds to negative to disable sleeping.
§When to disable sleeping
Most bodies should sleep! Only disable if the body needs to stay active despite being still:
- Bodies you frequently query for raycasts/contacts
- Bodies with time-based behaviors while stationary
Use RigidBodyBuilder::can_sleep(false) or RigidBodyActivation::cannot_sleep().
Fields§
§normalized_linear_threshold: f32Linear velocity threshold for sleeping (scaled by length_unit).
If negative, body never sleeps. Default: 0.4 (in length units/second).
angular_threshold: f32Angular velocity threshold for sleeping (radians/second).
If negative, body never sleeps. Default: 0.5 rad/s.
time_until_sleep: f32How long the body must be still before sleeping (seconds).
Default: 2.0 seconds. Must be below both velocity thresholds for this duration.
time_since_can_sleep: f32Internal timer tracking how long body has been still.
sleeping: boolIs this body currently sleeping?
Implementations§
Source§impl RigidBodyActivation
impl RigidBodyActivation
Sourcepub fn default_normalized_linear_threshold() -> f32
pub fn default_normalized_linear_threshold() -> f32
The default linear velocity below which a body can be put to sleep.
Sourcepub fn default_angular_threshold() -> f32
pub fn default_angular_threshold() -> f32
The default angular velocity below which a body can be put to sleep.
Sourcepub fn default_time_until_sleep() -> f32
pub fn default_time_until_sleep() -> f32
The amount of time the rigid-body must remain below it’s linear and angular velocity threshold before falling to sleep.
Sourcepub fn active() -> Self
pub fn active() -> Self
Create a new rb_activation status initialised with the default rb_activation threshold and is active.
Sourcepub fn inactive() -> Self
pub fn inactive() -> Self
Create a new rb_activation status initialised with the default rb_activation threshold and is inactive.
Sourcepub fn cannot_sleep() -> Self
pub fn cannot_sleep() -> Self
Create a new activation status that prevents the rigid-body from sleeping.
Trait Implementations§
Source§impl Clone for RigidBodyActivation
impl Clone for RigidBodyActivation
Source§fn clone(&self) -> RigidBodyActivation
fn clone(&self) -> RigidBodyActivation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RigidBodyActivation
impl Debug for RigidBodyActivation
Source§impl Default for RigidBodyActivation
impl Default for RigidBodyActivation
Source§impl PartialEq for RigidBodyActivation
impl PartialEq for RigidBodyActivation
impl Copy for RigidBodyActivation
impl StructuralPartialEq for RigidBodyActivation
Auto Trait Implementations§
impl Freeze for RigidBodyActivation
impl RefUnwindSafe for RigidBodyActivation
impl Send for RigidBodyActivation
impl Sync for RigidBodyActivation
impl Unpin for RigidBodyActivation
impl UnwindSafe for RigidBodyActivation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.