aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/rigid_body_components.rs
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2024-04-24 22:37:21 +0200
committerSébastien Crozet <sebastien@crozet.re>2024-04-30 23:10:46 +0200
commitc079452a478bb2f5d976cbba162e7f92252b505d (patch)
tree9ecee7655f135a8d916060df95b265f9314a9408 /src/dynamics/rigid_body_components.rs
parent6635d49c8bdaca13011a888d3901436eb79c599e (diff)
downloadrapier-c079452a478bb2f5d976cbba162e7f92252b505d.tar.gz
rapier-c079452a478bb2f5d976cbba162e7f92252b505d.tar.bz2
rapier-c079452a478bb2f5d976cbba162e7f92252b505d.zip
feat: add IntegrationParameters::length_unit to adjust internal threshold based on user-defined length units
Diffstat (limited to 'src/dynamics/rigid_body_components.rs')
-rw-r--r--src/dynamics/rigid_body_components.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs
index 998253c..c03233d 100644
--- a/src/dynamics/rigid_body_components.rs
+++ b/src/dynamics/rigid_body_components.rs
@@ -995,7 +995,10 @@ impl RigidBodyDominance {
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct RigidBodyActivation {
/// The threshold linear velocity bellow which the body can fall asleep.
- pub linear_threshold: Real,
+ ///
+ /// The value is "normalized", i.e., the actual threshold applied by the physics engine
+ /// is equal to this value multiplied by [`IntegrationParameters::length_unit`].
+ pub normalized_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.
@@ -1014,7 +1017,7 @@ impl Default for RigidBodyActivation {
impl RigidBodyActivation {
/// The default linear velocity bellow which a body can be put to sleep.
- pub fn default_linear_threshold() -> Real {
+ pub fn default_normalized_linear_threshold() -> Real {
0.4
}
@@ -1032,7 +1035,7 @@ impl RigidBodyActivation {
/// Create a new rb_activation status initialised with the default rb_activation threshold and is active.
pub fn active() -> Self {
RigidBodyActivation {
- linear_threshold: Self::default_linear_threshold(),
+ normalized_linear_threshold: Self::default_normalized_linear_threshold(),
angular_threshold: Self::default_angular_threshold(),
time_until_sleep: Self::default_time_until_sleep(),
time_since_can_sleep: 0.0,
@@ -1043,7 +1046,7 @@ impl RigidBodyActivation {
/// Create a new rb_activation status initialised with the default rb_activation threshold and is inactive.
pub fn inactive() -> Self {
RigidBodyActivation {
- linear_threshold: Self::default_linear_threshold(),
+ normalized_linear_threshold: Self::default_normalized_linear_threshold(),
angular_threshold: Self::default_angular_threshold(),
time_until_sleep: Self::default_time_until_sleep(),
time_since_can_sleep: Self::default_time_until_sleep(),
@@ -1054,7 +1057,7 @@ impl RigidBodyActivation {
/// Create a new activation status that prevents the rigid-body from sleeping.
pub fn cannot_sleep() -> Self {
RigidBodyActivation {
- linear_threshold: -1.0,
+ normalized_linear_threshold: -1.0,
angular_threshold: -1.0,
..Self::active()
}