aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2020-09-08 21:18:17 +0200
committerCrozet Sébastien <developer@crozet.re>2020-09-28 15:27:25 +0200
commit3c85a6ac41397cf95199933c6a93909bc070a844 (patch)
treee7ec95a2a75b8e82a3cea0ab40d60b8381f3bc24 /src/dynamics
parent99f28ba4b4a14254b4160a191cbeb15211cdd2d2 (diff)
downloadrapier-3c85a6ac41397cf95199933c6a93909bc070a844.tar.gz
rapier-3c85a6ac41397cf95199933c6a93909bc070a844.tar.bz2
rapier-3c85a6ac41397cf95199933c6a93909bc070a844.zip
Start implementing ray-casting.
This adds a QueryPipeline structure responsible for scene queries. Currently this structure is able to perform a brute-force ray-cast. This commit also includes the beginning of implementation of a SIMD-based acceleration structure which will be used for these scene queries in the future.
Diffstat (limited to 'src/dynamics')
-rw-r--r--src/dynamics/rigid_body.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index a2fcacc..d32ea46 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -137,6 +137,15 @@ impl RigidBody {
crate::utils::inv(self.mass_properties.inv_mass)
}
+ /// The predicted position of this rigid-body.
+ ///
+ /// If this rigid-body is kinematic this value is set by the `set_next_kinematic_position`
+ /// method and is used for estimating the kinematic body velocity at the next timestep.
+ /// For non-kinematic bodies, this value is currently unspecified.
+ pub fn predicted_position(&self) -> &Isometry<f32> {
+ &self.predicted_position
+ }
+
/// Adds a collider to this rigid-body.
pub(crate) fn add_collider_internal(&mut self, handle: ColliderHandle, coll: &Collider) {
let mass_properties = coll
@@ -201,12 +210,17 @@ impl RigidBody {
self.position = self.integrate_velocity(dt) * self.position;
}
- /// Sets the position of this rigid body.
+ /// Sets the position and `next_kinematic_position` of this rigid body.
+ ///
+ /// This will teleport the rigid-body to the specified position/orientation,
+ /// completely ignoring any physics rule. If this body is kinematic, this will
+ /// also set the next kinematic position to the same value, effectively
+ /// resetting to zero the next interpolated velocity of the kinematic body.
pub fn set_position(&mut self, pos: Isometry<f32>) {
self.position = pos;
// TODO: update the predicted position for dynamic bodies too?
- if self.is_static() {
+ if self.is_static() || self.is_kinematic() {
self.predicted_position = pos;
}
}