diff options
| author | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-04 21:31:02 +0100 |
|---|---|---|
| committer | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-04 21:31:02 +0100 |
| commit | e69f7534d7e80a4158b63783f531576404e06c1b (patch) | |
| tree | 412ca4035198af387929e494c31454a92ccddbf3 /src | |
| parent | 760ea8d498c7dfc99d59342c8ec492de193ffed9 (diff) | |
| parent | 2e929bbcabe49b7b18d4ee8d1fe4e58dc066c5ac (diff) | |
| download | rapier-e69f7534d7e80a4158b63783f531576404e06c1b.tar.gz rapier-e69f7534d7e80a4158b63783f531576404e06c1b.tar.bz2 rapier-e69f7534d7e80a4158b63783f531576404e06c1b.zip | |
Merge branch 'master' into fix-kcc
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynamics/island_manager.rs | 3 | ||||
| -rw-r--r-- | src/dynamics/rigid_body_components.rs | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/dynamics/island_manager.rs b/src/dynamics/island_manager.rs index e196503..ef5d50a 100644 --- a/src/dynamics/island_manager.rs +++ b/src/dynamics/island_manager.rs @@ -176,8 +176,7 @@ impl IslandManager { update_energy(&mut rb.activation, sq_linvel, sq_angvel, dt); - if rb.activation.time_since_can_sleep >= RigidBodyActivation::default_time_until_sleep() - { + if rb.activation.time_since_can_sleep >= rb.activation.time_until_sleep { // Mark them as sleeping for now. This will // be set to false during the graph traversal // if it should not be put to sleep. diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs index 89f6020..2d51901 100644 --- a/src/dynamics/rigid_body_components.rs +++ b/src/dynamics/rigid_body_components.rs @@ -978,6 +978,8 @@ pub struct RigidBodyActivation { pub linear_threshold: Real, /// The angular linear velocity bellow which the body can fall asleep. pub angular_threshold: Real, + /// The amount of time the rigid-body must remain below the thresholds to be put to sleep. + pub time_until_sleep: Real, /// Since how much time can this body sleep? pub time_since_can_sleep: Real, /// Is this body sleeping? @@ -1012,6 +1014,7 @@ impl RigidBodyActivation { RigidBodyActivation { linear_threshold: Self::default_linear_threshold(), angular_threshold: Self::default_angular_threshold(), + time_until_sleep: Self::default_time_until_sleep(), time_since_can_sleep: 0.0, sleeping: false, } @@ -1022,8 +1025,9 @@ impl RigidBodyActivation { RigidBodyActivation { linear_threshold: Self::default_linear_threshold(), angular_threshold: Self::default_angular_threshold(), - sleeping: true, + time_until_sleep: Self::default_time_until_sleep(), time_since_can_sleep: Self::default_time_until_sleep(), + sleeping: true, } } @@ -1055,6 +1059,6 @@ impl RigidBodyActivation { #[inline] pub fn sleep(&mut self) { self.sleeping = true; - self.time_since_can_sleep = Self::default_time_until_sleep(); + self.time_since_can_sleep = self.time_until_sleep; } } |
