From dbb3c8f43b151e48619ed954b20d44dd9e5c2c55 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 1 Jun 2021 14:56:24 +0200 Subject: CCD: take collision groups into account --- src/geometry/collider_set.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/geometry/collider_set.rs') diff --git a/src/geometry/collider_set.rs b/src/geometry/collider_set.rs index d8603cd..dc0abdc 100644 --- a/src/geometry/collider_set.rs +++ b/src/geometry/collider_set.rs @@ -134,6 +134,7 @@ impl ColliderSet { // Make sure the internal links are reset, they may not be // if this rigid-body was obtained by cloning another one. coll.reset_internal_references(); + coll.co_parent = None; let handle = ColliderHandle(self.colliders.insert(coll)); self.modified_colliders.push(handle); handle @@ -147,12 +148,17 @@ impl ColliderSet { bodies: &mut RigidBodySet, ) -> ColliderHandle { // Make sure the internal links are reset, they may not be - // if this rigid-body was obtained by cloning another one. + // if this collider was obtained by cloning another one. coll.reset_internal_references(); - coll.co_parent = Some(ColliderParent { - handle: parent_handle, - pos_wrt_parent: coll.co_pos.0, - }); + + if let Some(prev_parent) = &mut coll.co_parent { + prev_parent.handle = parent_handle; + } else { + coll.co_parent = Some(ColliderParent { + handle: parent_handle, + pos_wrt_parent: coll.co_pos.0, + }); + } // NOTE: we use `get_mut` instead of `get_mut_internal` so that the // modification flag is updated properly. -- cgit