Allow disabling colliders, rigid-bodies and impulse joints

This commit is contained in:
Sébastien Crozet
2022-11-19 16:05:46 +01:00
parent c600549aac
commit 46d976d97b
15 changed files with 408 additions and 107 deletions

View File

@@ -422,6 +422,7 @@ impl PhysicsPipeline {
// Apply modifications.
let mut modified_colliders = colliders.take_modified();
let mut removed_colliders = colliders.take_removed();
super::user_changes::handle_user_changes_to_colliders(
bodies,
colliders,
@@ -433,10 +434,22 @@ impl PhysicsPipeline {
Some(islands),
bodies,
colliders,
impulse_joints,
multibody_joints,
&modified_bodies,
&mut modified_colliders,
);
// Disabled colliders are treated as if they were removed.
// NOTE: this must be called here, after handle_user_changes_to_rigid_bodies to take into
// account colliders disabled because of their parent rigid-body.
removed_colliders.extend(
modified_colliders
.iter()
.copied()
.filter(|h| colliders.get(*h).map(|c| !c.is_enabled()).unwrap_or(false)),
);
// TODO: do this only on user-change.
// TODO: do we want some kind of automatic inverse kinematics?
for multibody in &mut multibody_joints.multibodies {