Use the publish-subscribe mechanism to handle collider removals across pipelines.

This commit is contained in:
Crozet Sébastien
2020-10-05 19:04:18 +02:00
parent 2d0a888484
commit 93aa7b6e1e
11 changed files with 236 additions and 174 deletions

View File

@@ -84,28 +84,4 @@ impl CollisionPipeline {
bodies.modified_inactive_set.clear();
}
/// Remove a rigid-body and all its associated data.
pub fn remove_rigid_body(
&mut self,
handle: RigidBodyHandle,
broad_phase: &mut BroadPhase,
narrow_phase: &mut NarrowPhase,
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
) -> Option<RigidBody> {
// Remove the body.
let body = bodies.remove_internal(handle)?;
// Remove this rigid-body from the broad-phase and narrow-phase.
broad_phase.remove_colliders(&body.colliders, colliders);
narrow_phase.remove_colliders(&body.colliders, colliders, bodies);
// Remove all colliders attached to this body.
for collider in &body.colliders {
colliders.remove_internal(*collider);
}
Some(body)
}
}