Properly take initial sleeping state set by the user when creating a rigid-body

This commit is contained in:
Sébastien Crozet
2022-12-11 17:47:16 +01:00
parent cb9350fd80
commit 0207f8cf96
6 changed files with 46 additions and 21 deletions

View File

@@ -135,7 +135,7 @@ impl RigidBody {
}
/// Sets the type of this rigid-body.
pub fn set_body_type(&mut self, status: RigidBodyType) {
pub fn set_body_type(&mut self, status: RigidBodyType, wake_up: bool) {
if status != self.body_type {
self.changes.insert(RigidBodyChanges::TYPE);
self.body_type = status;
@@ -143,6 +143,10 @@ impl RigidBody {
if status == RigidBodyType::Fixed {
self.vels = RigidBodyVelocity::zero();
}
if self.is_dynamic() && wake_up {
self.wake_up(true);
}
}
}