aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/rigid_body.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index bb1e9bf..78132b2 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -938,6 +938,28 @@ impl RigidBody {
self.apply_impulse(impulse, wake_up);
self.apply_torque_impulse(torque_impulse, wake_up);
}
+
+ /// Retrieves the constant force(s) that the user has added to the body.
+ ///
+ /// Returns zero if the rigid-body isn’t dynamic.
+ pub fn user_force(&self) -> Vector<Real> {
+ if self.body_type == RigidBodyType::Dynamic {
+ self.forces.user_force
+ } else {
+ Vector::zeros()
+ }
+ }
+
+ /// Retrieves the constant torque(s) that the user has added to the body.
+ ///
+ /// Returns zero if the rigid-body isn’t dynamic.
+ pub fn user_torque(&self) -> AngVector<Real> {
+ if self.body_type == RigidBodyType::Dynamic {
+ self.forces.user_torque
+ } else {
+ AngVector::zero()
+ }
+ }
}
impl RigidBody {