From bccb7d4c669fb3bafa94d90486fa4d9b78f88cf8 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 8 Jun 2021 18:03:33 +0200 Subject: Track the rigid-body graph IDs inside of the JointSet instead of RigidBodyIds --- src/dynamics/island_manager.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/dynamics/island_manager.rs') diff --git a/src/dynamics/island_manager.rs b/src/dynamics/island_manager.rs index 34fa3bd..9763b40 100644 --- a/src/dynamics/island_manager.rs +++ b/src/dynamics/island_manager.rs @@ -1,9 +1,9 @@ use crate::data::{BundleSet, ComponentSet, ComponentSetMut, ComponentSetOption}; use crate::dynamics::{ - Joint, RigidBodyActivation, RigidBodyColliders, RigidBodyHandle, RigidBodyIds, RigidBodyType, - RigidBodyVelocity, + JointSet, RigidBodyActivation, RigidBodyColliders, RigidBodyHandle, RigidBodyIds, + RigidBodyType, RigidBodyVelocity, }; -use crate::geometry::{ColliderParent, InteractionGraph, NarrowPhase}; +use crate::geometry::{ColliderParent, NarrowPhase}; use crate::math::Real; /// Structure responsible for maintaining the set of active rigid-bodies, and @@ -91,12 +91,14 @@ impl IslandManager { pub fn wake_up(&mut self, bodies: &mut Bodies, handle: RigidBodyHandle, strong: bool) where Bodies: ComponentSetMut - + ComponentSet + + ComponentSetOption + ComponentSetMut, { - // TODO: what about kinematic bodies? - let status: RigidBodyType = *bodies.index(handle.0); - if status.is_dynamic() { + // NOTE: the use an Option here because there are many legitimate cases (like when + // deleting a joint attached to an already-removed body) where we could be + // attempting to wake-up a rigid-body that has already been deleted. + let rb_type: Option = bodies.get(handle.0).copied(); + if rb_type == Some(RigidBodyType::Dynamic) { bodies.map_mut_internal(handle.0, |activation: &mut RigidBodyActivation| { activation.wake_up(strong) }); @@ -172,7 +174,7 @@ impl IslandManager { bodies: &mut Bodies, colliders: &Colliders, narrow_phase: &NarrowPhase, - joint_graph: &InteractionGraph, + joints: &JointSet, min_island_size: usize, ) where Bodies: ComponentSetMut @@ -299,7 +301,7 @@ impl IslandManager { // in contact or joined with this collider. push_contacting_bodies(rb_colliders, colliders, narrow_phase, &mut self.stack); - for inter in joint_graph.interactions_with(rb_ids.joint_graph_index) { + for inter in joints.joints_with(handle) { let other = crate::utils::select_other((inter.0, inter.1), handle); self.stack.push(other); } -- cgit