Joint set iteration: also yield the joint handle.
This commit is contained in:
@@ -66,17 +66,21 @@ impl JointSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates through all the joint on this set.
|
/// Iterates through all the joint on this set.
|
||||||
pub fn iter(&self) -> impl Iterator<Item = &Joint> {
|
pub fn iter(&self) -> impl Iterator<Item = (JointHandle, &Joint)> {
|
||||||
self.joint_graph.graph.edges.iter().map(|e| &e.weight)
|
self.joint_graph
|
||||||
|
.graph
|
||||||
|
.edges
|
||||||
|
.iter()
|
||||||
|
.map(|e| (e.weight.handle, &e.weight))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates mutably through all the joint on this set.
|
/// Iterates mutably through all the joint on this set.
|
||||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Joint> {
|
pub fn iter_mut(&mut self) -> impl Iterator<Item = (JointHandle, &mut Joint)> {
|
||||||
self.joint_graph
|
self.joint_graph
|
||||||
.graph
|
.graph
|
||||||
.edges
|
.edges
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.map(|e| &mut e.weight)
|
.map(|e| (e.weight.handle, &mut e.weight))
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// The set of joints as an array.
|
// /// The set of joints as an array.
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ impl NPhysicsWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for joint in joints.iter() {
|
for joint in joints.iter() {
|
||||||
let b1 = BodyPartHandle(rapier2nphysics[&joint.body1], 0);
|
let b1 = BodyPartHandle(rapier2nphysics[&joint.1.body1], 0);
|
||||||
let b2 = BodyPartHandle(rapier2nphysics[&joint.body2], 0);
|
let b2 = BodyPartHandle(rapier2nphysics[&joint.1.body2], 0);
|
||||||
|
|
||||||
match &joint.params {
|
match &joint.1.params {
|
||||||
JointParams::FixedJoint(params) => {
|
JointParams::FixedJoint(params) => {
|
||||||
let c = FixedConstraint::new(
|
let c = FixedConstraint::new(
|
||||||
b1,
|
b1,
|
||||||
|
|||||||
Reference in New Issue
Block a user