aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2024-03-23 10:51:50 +0100
committerSébastien Crozet <sebastien@crozet.re>2024-03-23 11:10:57 +0100
commit6886f8f2073b3251e3b080523d8032961b68e52a (patch)
treedaf50ccb82d3b1baf218c614da97e58236e0f92d /src
parentf943fd99734d39de3f45c22e9a06652371446917 (diff)
downloadrapier-6886f8f2073b3251e3b080523d8032961b68e52a.tar.gz
rapier-6886f8f2073b3251e3b080523d8032961b68e52a.tar.bz2
rapier-6886f8f2073b3251e3b080523d8032961b68e52a.zip
feat: add RigidBody::predict_position_using_velocity
Fix #601
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/rigid_body.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index b27b58e..2b07f37 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -817,6 +817,17 @@ impl RigidBody {
.integrate_forces_and_velocities(dt, &self.forces, &self.vels, &self.mprops)
}
+ /// Predicts the next position of this rigid-body, by integrating only its velocity
+ /// by a time of `dt`.
+ ///
+ /// The forces that were applied to this rigid-body since the last physics step will
+ /// be ignored by this function. Use [`Self::predict_position_using_velocity_and_forces`]
+ /// instead to take forces into account.
+ pub fn predict_position_using_velocity(&self, dt: Real) -> Isometry<Real> {
+ self.vels
+ .integrate(dt, &self.pos.position, &self.mprops.local_mprops.local_com)
+ }
+
pub(crate) fn update_world_mass_properties(&mut self) {
self.mprops.update_world_mass_properties(&self.pos.position);
}