diff options
| author | fabriceci <fabricecipolla@gmail.com> | 2022-12-21 21:34:06 +0100 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2023-01-01 16:49:52 +0100 |
| commit | 95cd7d5c9c73574cde1d07774b3d0969cda6833e (patch) | |
| tree | ba435570a0c2c80a87bec679abfeb8d57e6ff8e8 /src/dynamics | |
| parent | d482205f02138b8105557d09d315190b7b09a938 (diff) | |
| download | rapier-95cd7d5c9c73574cde1d07774b3d0969cda6833e.tar.gz rapier-95cd7d5c9c73574cde1d07774b3d0969cda6833e.tar.bz2 rapier-95cd7d5c9c73574cde1d07774b3d0969cda6833e.zip | |
Adds methods to retrieve forces added by the user.
Diffstat (limited to 'src/dynamics')
| -rw-r--r-- | src/dynamics/rigid_body.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index bb1e9bf..f9ea519 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -938,6 +938,22 @@ 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. + pub fn user_force(&self) -> Vector<Real> { + if self.body_type == RigidBodyType::Dynamic { + return self.forces.user_force; + } + Vector::zeros() + } + + /// Retrieves the constant torque(s) that the user has added to the body. + pub fn user_torque(&self) -> AngVector<Real> { + if self.body_type == RigidBodyType::Dynamic { + return self.forces.user_torque; + } + AngVector::zero() + } } impl RigidBody { |
