diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-11-19 11:10:03 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-11-19 18:00:43 +0100 |
| commit | 49fd861083a0b6055ac8b9ea7aa69b9207b2c030 (patch) | |
| tree | 62d9c2aacadcb295ae39384101f16a74b5bc3f4b | |
| parent | 0d49a809746bade39f844a13f74a2fc03fc1d21f (diff) | |
| download | rapier-49fd861083a0b6055ac8b9ea7aa69b9207b2c030.tar.gz rapier-49fd861083a0b6055ac8b9ea7aa69b9207b2c030.tar.bz2 rapier-49fd861083a0b6055ac8b9ea7aa69b9207b2c030.zip | |
Allow a rigid-body to be initialized asleep.
| -rw-r--r-- | src/dynamics/rigid_body.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 303d1a0..6704c51 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -388,6 +388,7 @@ pub struct RigidBodyBuilder { body_status: BodyStatus, mass_properties: MassProperties, can_sleep: bool, + sleeping: bool, user_data: u128, } @@ -403,6 +404,7 @@ impl RigidBodyBuilder { body_status, mass_properties: MassProperties::zero(), can_sleep: true, + sleeping: false, user_data: 0, } } @@ -531,6 +533,12 @@ impl RigidBodyBuilder { self } + /// Sets whether or not the rigid-body is to be created asleep. + pub fn sleeping(mut self, sleeping: bool) -> Self { + self.sleeping = sleeping; + self + } + /// Build a new rigid-body with the parameters configured with this builder. pub fn build(&self) -> RigidBody { let mut rb = RigidBody::new(); @@ -544,6 +552,10 @@ impl RigidBodyBuilder { rb.linear_damping = self.linear_damping; rb.angular_damping = self.angular_damping; + if self.can_sleep && self.sleeping { + rb.sleep(); + } + if !self.can_sleep { rb.activation.threshold = -1.0; } |
