aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/rigid_body.rs12
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;
}