Add a parameter to indicate if collider removal should wake-up its parent.
This commit is contained in:
@@ -207,7 +207,7 @@ impl RigidBodySet {
|
||||
* Remove colliders attached to this rigid-body.
|
||||
*/
|
||||
for collider in &rb.colliders {
|
||||
colliders.remove(*collider, self);
|
||||
colliders.remove(*collider, self, false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -78,10 +78,14 @@ impl ColliderSet {
|
||||
}
|
||||
|
||||
/// Remove a collider from this set and update its parent accordingly.
|
||||
///
|
||||
/// If `wake_up` is `true`, the rigid-body the removed collider is attached to
|
||||
/// will be woken up.
|
||||
pub fn remove(
|
||||
&mut self,
|
||||
handle: ColliderHandle,
|
||||
bodies: &mut RigidBodySet,
|
||||
wake_up: bool,
|
||||
) -> Option<Collider> {
|
||||
let collider = self.colliders.remove(handle)?;
|
||||
|
||||
@@ -90,7 +94,10 @@ impl ColliderSet {
|
||||
*/
|
||||
if let Some(parent) = bodies.get_mut_internal(collider.parent) {
|
||||
parent.remove_collider_internal(handle, &collider);
|
||||
bodies.wake_up(collider.parent, true);
|
||||
|
||||
if wake_up {
|
||||
bodies.wake_up(collider.parent, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -758,7 +758,7 @@ impl Testbed {
|
||||
for to_delete in &colliders[..num_to_delete] {
|
||||
self.physics
|
||||
.colliders
|
||||
.remove(to_delete[0], &mut self.physics.bodies);
|
||||
.remove(to_delete[0], &mut self.physics.bodies, true);
|
||||
}
|
||||
}
|
||||
WindowEvent::Key(Key::D, Action::Release, _) => {
|
||||
@@ -1576,11 +1576,13 @@ CCD: {:.2}ms
|
||||
}
|
||||
|
||||
if self.state.flags.contains(TestbedStateFlags::DEBUG) {
|
||||
let t = instant::now();
|
||||
let bf = bincode::serialize(&self.physics.broad_phase).unwrap();
|
||||
let nf = bincode::serialize(&self.physics.narrow_phase).unwrap();
|
||||
let bs = bincode::serialize(&self.physics.bodies).unwrap();
|
||||
let cs = bincode::serialize(&self.physics.colliders).unwrap();
|
||||
let js = bincode::serialize(&self.physics.joints).unwrap();
|
||||
let serialization_time = instant::now() - t;
|
||||
let hash_bf = md5::compute(&bf);
|
||||
let hash_nf = md5::compute(&nf);
|
||||
let hash_bodies = md5::compute(&bs);
|
||||
@@ -1588,6 +1590,7 @@ CCD: {:.2}ms
|
||||
let hash_joints = md5::compute(&js);
|
||||
profile = format!(
|
||||
r#"{}
|
||||
Serialization time: {:.2}ms
|
||||
Hashes at frame: {}
|
||||
|_ Broad phase [{:.1}KB]: {:?}
|
||||
|_ Narrow phase [{:.1}KB]: {:?}
|
||||
@@ -1595,6 +1598,7 @@ Hashes at frame: {}
|
||||
|_ Colliders [{:.1}KB]: {:?}
|
||||
|_ Joints [{:.1}KB]: {:?}"#,
|
||||
profile,
|
||||
serialization_time,
|
||||
self.state.timestep_id,
|
||||
bf.len() as f32 / 1000.0,
|
||||
hash_bf,
|
||||
|
||||
Reference in New Issue
Block a user