aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-02-20 14:21:59 +0100
committerSébastien Crozet <sebastien@crozet.re>2022-03-20 21:49:16 +0100
commit28cc19d104d986db54d8725e68189070bef31a8a (patch)
treea82eda017e7bf2f8715b10450bcabde841440af4 /src/dynamics
parent412fedf7e30d7d2c4136ee6f6d0818184a539658 (diff)
downloadrapier-28cc19d104d986db54d8725e68189070bef31a8a.tar.gz
rapier-28cc19d104d986db54d8725e68189070bef31a8a.tar.bz2
rapier-28cc19d104d986db54d8725e68189070bef31a8a.zip
Allow removing a rigid-body without auto-removing attached colliders
Diffstat (limited to 'src/dynamics')
-rw-r--r--src/dynamics/rigid_body_set.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/dynamics/rigid_body_set.rs b/src/dynamics/rigid_body_set.rs
index d6999ee..d033839 100644
--- a/src/dynamics/rigid_body_set.rs
+++ b/src/dynamics/rigid_body_set.rs
@@ -141,6 +141,7 @@ impl RigidBodySet {
colliders: &mut ColliderSet,
impulse_joints: &mut ImpulseJointSet,
multibody_joints: &mut MultibodyJointSet,
+ remove_attached_colliders: bool,
) -> Option<RigidBody> {
let rb = self.bodies.remove(handle.0)?;
/*
@@ -151,8 +152,16 @@ impl RigidBodySet {
/*
* Remove colliders attached to this rigid-body.
*/
- for collider in rb.colliders() {
- colliders.remove(*collider, islands, self, false);
+ if remove_attached_colliders {
+ for collider in rb.colliders() {
+ colliders.remove(*collider, islands, self, false);
+ }
+ } else {
+ // If we don’t remove the attached colliders, simply detach them.
+ let colliders_to_detach = rb.colliders().to_vec();
+ for co_handle in colliders_to_detach {
+ colliders.set_parent(co_handle, None, self);
+ }
}
/*