diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-11-19 16:05:46 +0100 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2022-12-11 15:20:33 +0100 |
| commit | 46d976d97bc9334004a58a19bc9cab3ea78e9569 (patch) | |
| tree | 0437f81f4c7882c89aafa685b2822b8c3e462b3c /src/dynamics/joint/multibody_joint | |
| parent | c600549aacbde1361eba862b34a23f63d806d6a9 (diff) | |
| download | rapier-46d976d97bc9334004a58a19bc9cab3ea78e9569.tar.gz rapier-46d976d97bc9334004a58a19bc9cab3ea78e9569.tar.bz2 rapier-46d976d97bc9334004a58a19bc9cab3ea78e9569.zip | |
Allow disabling colliders, rigid-bodies and impulse joints
Diffstat (limited to 'src/dynamics/joint/multibody_joint')
| -rw-r--r-- | src/dynamics/joint/multibody_joint/multibody_joint_set.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs index c25de73..a4b338a 100644 --- a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs +++ b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs @@ -372,7 +372,7 @@ impl MultibodyJointSet { } /// Iterate through the handles of all the rigid-bodies attached to this rigid-body - /// by an multibody_joint. + /// by a multibody_joint. pub fn attached_bodies<'a>( &'a self, body: RigidBodyHandle, @@ -384,6 +384,21 @@ impl MultibodyJointSet { .map(move |inter| crate::utils::select_other((inter.0, inter.1), body)) } + /// Iterate through the handles of all the rigid-bodies attached to this rigid-body + /// by an enabled multibody_joint. + pub fn bodies_attached_with_enabled_joint<'a>( + &'a self, + body: RigidBodyHandle, + ) -> impl Iterator<Item = RigidBodyHandle> + 'a { + self.attached_bodies(body).filter(move |other| { + if let Some((_, _, link)) = self.joint_between(body, *other) { + link.joint.data.is_enabled() + } else { + false + } + }) + } + /// Iterates through all the multibodies on this set. pub fn multibodies(&self) -> impl Iterator<Item = &Multibody> { self.multibodies.iter().map(|e| e.1) |
