From d8dfd864a453a9ead60f970549b2d289d7025364 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 5 Oct 2020 16:51:16 +0200 Subject: Joint set iteration: also yield the joint handle. --- src/dynamics/joint/joint_set.rs | 12 ++++++++---- src_testbed/nphysics_backend.rs | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/dynamics/joint/joint_set.rs b/src/dynamics/joint/joint_set.rs index 90f5190..2b1895f 100644 --- a/src/dynamics/joint/joint_set.rs +++ b/src/dynamics/joint/joint_set.rs @@ -66,17 +66,21 @@ impl JointSet { } /// Iterates through all the joint on this set. - pub fn iter(&self) -> impl Iterator { - self.joint_graph.graph.edges.iter().map(|e| &e.weight) + pub fn iter(&self) -> impl Iterator { + self.joint_graph + .graph + .edges + .iter() + .map(|e| (e.weight.handle, &e.weight)) } /// Iterates mutably through all the joint on this set. - pub fn iter_mut(&mut self) -> impl Iterator { + pub fn iter_mut(&mut self) -> impl Iterator { self.joint_graph .graph .edges .iter_mut() - .map(|e| &mut e.weight) + .map(|e| (e.weight.handle, &mut e.weight)) } // /// The set of joints as an array. diff --git a/src_testbed/nphysics_backend.rs b/src_testbed/nphysics_backend.rs index c9ff2d1..c2a7fb1 100644 --- a/src_testbed/nphysics_backend.rs +++ b/src_testbed/nphysics_backend.rs @@ -66,10 +66,10 @@ impl NPhysicsWorld { } for joint in joints.iter() { - let b1 = BodyPartHandle(rapier2nphysics[&joint.body1], 0); - let b2 = BodyPartHandle(rapier2nphysics[&joint.body2], 0); + let b1 = BodyPartHandle(rapier2nphysics[&joint.1.body1], 0); + let b2 = BodyPartHandle(rapier2nphysics[&joint.1.body2], 0); - match &joint.params { + match &joint.1.params { JointParams::FixedJoint(params) => { let c = FixedConstraint::new( b1, -- cgit