diff options
| author | Sébastien Crozet <developer@crozet.re> | 2020-11-26 13:26:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-26 13:26:07 +0100 |
| commit | 51b7bf9a529175d0c6ec42775f11f16bd7fe719a (patch) | |
| tree | 68795351e593d961c119a86335fbba3e301da528 /src/geometry | |
| parent | bdf2e15fdcff4c4757b4875354b2d6e8b9c6939d (diff) | |
| parent | 340f614d32fbf32b48a63d1c381da67eec97b05d (diff) | |
| download | rapier-51b7bf9a529175d0c6ec42775f11f16bd7fe719a.tar.gz rapier-51b7bf9a529175d0c6ec42775f11f16bd7fe719a.tar.bz2 rapier-51b7bf9a529175d0c6ec42775f11f16bd7fe719a.zip | |
Merge pull request #69 from dimforge/rigid_body_modifications
Track some user-initiated rigid-body modifications
Diffstat (limited to 'src/geometry')
| -rw-r--r-- | src/geometry/broad_phase_multi_sap.rs | 9 | ||||
| -rw-r--r-- | src/geometry/collider.rs | 4 | ||||
| -rw-r--r-- | src/geometry/collider_set.rs | 28 |
3 files changed, 23 insertions, 18 deletions
diff --git a/src/geometry/broad_phase_multi_sap.rs b/src/geometry/broad_phase_multi_sap.rs index 4cea113..863990d 100644 --- a/src/geometry/broad_phase_multi_sap.rs +++ b/src/geometry/broad_phase_multi_sap.rs @@ -586,9 +586,6 @@ impl BroadPhase { let proxy = &mut self.proxies[proxy_index]; - // Push the proxy to infinity, but not beyond the sentinels. - proxy.aabb.mins.coords.fill(SENTINEL_VALUE / 2.0); - proxy.aabb.maxs.coords.fill(SENTINEL_VALUE / 2.0); // Discretize the AABB to find the regions that need to be invalidated. let start = point_key(proxy.aabb.mins); let end = point_key(proxy.aabb.maxs); @@ -615,6 +612,9 @@ impl BroadPhase { } } + // Push the proxy to infinity, but not beyond the sentinels. + proxy.aabb.mins.coords.fill(SENTINEL_VALUE / 2.0); + proxy.aabb.maxs.coords.fill(SENTINEL_VALUE / 2.0); self.proxies.remove(proxy_index); } @@ -631,8 +631,9 @@ impl BroadPhase { self.complete_removals(); for body_handle in bodies - .active_dynamic_set + .modified_inactive_set .iter() + .chain(bodies.active_dynamic_set.iter()) .chain(bodies.active_kinematic_set.iter()) { for handle in &bodies[*body_handle].colliders { diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index 3789cca..c04be35 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -1,7 +1,7 @@ use crate::dynamics::{MassProperties, RigidBodyHandle, RigidBodySet}; use crate::geometry::{ - Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, HeightField, InteractionGraph, - InteractionGroups, Proximity, Segment, Shape, ShapeType, Triangle, Trimesh, + Ball, Capsule, Cuboid, HeightField, InteractionGroups, Segment, Shape, ShapeType, Triangle, + Trimesh, }; #[cfg(feature = "dim3")] use crate::geometry::{Cone, Cylinder, RoundCylinder}; diff --git a/src/geometry/collider_set.rs b/src/geometry/collider_set.rs index 5411ec1..eb09322 100644 --- a/src/geometry/collider_set.rs +++ b/src/geometry/collider_set.rs @@ -1,7 +1,7 @@ use crate::data::arena::Arena; use crate::data::pubsub::PubSub; use crate::dynamics::{RigidBodyHandle, RigidBodySet}; -use crate::geometry::{Collider, ColliderGraphIndex}; +use crate::geometry::Collider; use std::ops::{Index, IndexMut}; /// The unique identifier of a collider added to a collider set. @@ -63,15 +63,17 @@ impl ColliderSet { coll.reset_internal_references(); coll.parent = parent_handle; + + // NOTE: we use `get_mut` instead of `get_mut_internal` so that the + // modification flag is updated properly. let parent = bodies - .get_mut_internal(parent_handle) + .get_mut(parent_handle) .expect("Parent rigid body not found."); coll.position = parent.position * coll.delta; coll.predicted_position = parent.predicted_position * coll.delta; let handle = self.colliders.insert(coll); let coll = self.colliders.get(handle).unwrap(); - parent.add_collider_internal(handle, &coll); - bodies.activate(parent_handle); + parent.add_collider(handle, &coll); handle } @@ -90,7 +92,9 @@ impl ColliderSet { /* * Delete the collider from its parent body. */ - if let Some(parent) = bodies.get_mut_internal(collider.parent) { + // NOTE: we use `get_mut` instead of `get_mut_internal` so that the + // modification flag is updated properly. + if let Some(parent) = bodies.get_mut(collider.parent) { parent.remove_collider_internal(handle, &collider); if wake_up { @@ -147,13 +151,13 @@ impl ColliderSet { self.colliders.get_mut(handle) } - pub(crate) fn get2_mut_internal( - &mut self, - h1: ColliderHandle, - h2: ColliderHandle, - ) -> (Option<&mut Collider>, Option<&mut Collider>) { - self.colliders.get2_mut(h1, h2) - } + // pub(crate) fn get2_mut_internal( + // &mut self, + // h1: ColliderHandle, + // h2: ColliderHandle, + // ) -> (Option<&mut Collider>, Option<&mut Collider>) { + // self.colliders.get2_mut(h1, h2) + // } // pub fn iter_mut(&mut self) -> impl Iterator<Item = (ColliderHandle, ColliderMut)> { // // let sender = &self.activation_channel_sender; |
