Skip to content

Commit

Permalink
feat: add RigidBody::predict_position_using_velocity
Browse files Browse the repository at this point in the history
Fix #601
  • Loading branch information
sebcrozet committed Mar 23, 2024
1 parent f943fd9 commit fc82687
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
- Fix crash when simulating a spring joint between two dynamic bodies.
- Fix kinematic bodies not being affected by gravity after being switched back to dynamic.

### Added

- Add `RigidBody::predict_position_using_velocity` to predict the next position of the rigid-body
based only on its current velocity.

## v0.18.0 (24 Jan. 2024)

The main highlight of this release is the implementation of a new non-linear constraints solver for better stability
Expand Down
11 changes: 11 additions & 0 deletions src/dynamics/rigid_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fc82687

Please sign in to comment.