Skip to content

Commit c30de41

Browse files
committed
use hashset from parry (#716 follow up)
1 parent b0e72bb commit c30de41

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/dynamics/joint/impulse_joint/impulse_joint_set.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use parry::utils::hashmap::HashMap;
1+
use parry::utils::hashset::HashSet;
22

33
use super::ImpulseJoint;
44
use crate::geometry::{InteractionGraph, RigidBodyGraphIndex, TemporaryInteractionIndex};
@@ -46,7 +46,7 @@ pub struct ImpulseJointSet {
4646
joint_ids: Arena<TemporaryInteractionIndex>,
4747
joint_graph: InteractionGraph<RigidBodyHandle, ImpulseJoint>,
4848
/// A set of rigid-body handles to wake-up during the next timestep.
49-
pub(crate) to_wake_up: HashMap<RigidBodyHandle, ()>,
49+
pub(crate) to_wake_up: HashSet<RigidBodyHandle>,
5050
}
5151

5252
impl ImpulseJointSet {
@@ -56,7 +56,7 @@ impl ImpulseJointSet {
5656
rb_graph_ids: Coarena::new(),
5757
joint_ids: Arena::new(),
5858
joint_graph: InteractionGraph::new(),
59-
to_wake_up: HashMap::default(),
59+
to_wake_up: HashSet::default(),
6060
}
6161
}
6262

@@ -158,8 +158,8 @@ impl ImpulseJointSet {
158158
let joint = self.joint_graph.graph.edge_weight_mut(*id);
159159
if wake_up_connected_bodies {
160160
if let Some(joint) = &joint {
161-
self.to_wake_up.insert(joint.body1, ());
162-
self.to_wake_up.insert(joint.body2, ());
161+
self.to_wake_up.insert(joint.body1);
162+
self.to_wake_up.insert(joint.body2);
163163
}
164164
}
165165
joint
@@ -285,8 +285,8 @@ impl ImpulseJointSet {
285285
self.joint_ids[handle] = self.joint_graph.add_edge(graph_index1, graph_index2, joint);
286286

287287
if wake_up {
288-
self.to_wake_up.insert(body1, ());
289-
self.to_wake_up.insert(body2, ());
288+
self.to_wake_up.insert(body1);
289+
self.to_wake_up.insert(body2);
290290
}
291291

292292
ImpulseJointHandle(handle)
@@ -337,10 +337,10 @@ impl ImpulseJointSet {
337337

338338
if wake_up {
339339
if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.0) {
340-
self.to_wake_up.insert(*rb_handle, ());
340+
self.to_wake_up.insert(*rb_handle);
341341
}
342342
if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.1) {
343-
self.to_wake_up.insert(*rb_handle, ());
343+
self.to_wake_up.insert(*rb_handle);
344344
}
345345
}
346346

@@ -390,8 +390,8 @@ impl ImpulseJointSet {
390390
}
391391

392392
// Wake up the attached bodies.
393-
self.to_wake_up.insert(h1, ());
394-
self.to_wake_up.insert(h2, ());
393+
self.to_wake_up.insert(h1);
394+
self.to_wake_up.insert(h2);
395395
}
396396

397397
if let Some(other) = self.joint_graph.remove_node(deleted_id) {

src/dynamics/joint/multibody_joint/multibody_joint_set.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use parry::utils::hashmap::HashMap;
1+
use parry::utils::hashset::HashSet;
22

33
use crate::data::{Arena, Coarena, Index};
44
use crate::dynamics::joint::MultibodyLink;
@@ -96,7 +96,7 @@ pub struct MultibodyJointSet {
9696
// NOTE: this is mostly for the island extraction. So perhaps we won’t need
9797
// that any more in the future when we improve our island builder.
9898
pub(crate) connectivity_graph: InteractionGraph<RigidBodyHandle, ()>,
99-
pub(crate) to_wake_up: HashMap<RigidBodyHandle, ()>,
99+
pub(crate) to_wake_up: HashSet<RigidBodyHandle>,
100100
}
101101

102102
impl MultibodyJointSet {
@@ -106,7 +106,7 @@ impl MultibodyJointSet {
106106
multibodies: Arena::new(),
107107
rb2mb: Coarena::new(),
108108
connectivity_graph: InteractionGraph::new(),
109-
to_wake_up: HashMap::default(),
109+
to_wake_up: HashSet::default(),
110110
}
111111
}
112112

@@ -203,8 +203,8 @@ impl MultibodyJointSet {
203203
multibody1.append(mb2, link1.id, MultibodyJoint::new(data.into(), kinematic));
204204

205205
if wake_up {
206-
self.to_wake_up.insert(body1, ());
207-
self.to_wake_up.insert(body2, ());
206+
self.to_wake_up.insert(body1);
207+
self.to_wake_up.insert(body2);
208208
}
209209

210210
// Because each rigid-body can only have one parent link,
@@ -227,8 +227,8 @@ impl MultibodyJointSet {
227227
.remove_edge(parent_graph_id, removed.graph_id);
228228

229229
if wake_up {
230-
self.to_wake_up.insert(RigidBodyHandle(handle.0), ());
231-
self.to_wake_up.insert(parent_rb, ());
230+
self.to_wake_up.insert(RigidBodyHandle(handle.0));
231+
self.to_wake_up.insert(parent_rb);
232232
}
233233

234234
// TODO: remove the node if it no longer has any attached edges?
@@ -270,7 +270,7 @@ impl MultibodyJointSet {
270270
let rb_handle = link.rigid_body;
271271

272272
if wake_up {
273-
self.to_wake_up.insert(rb_handle, ());
273+
self.to_wake_up.insert(rb_handle);
274274
}
275275

276276
// Remove the rigid-body <-> multibody mapping for this link.
@@ -296,8 +296,8 @@ impl MultibodyJointSet {
296296
// There is a multibody_joint handle is equal to the second rigid-body’s handle.
297297
articulations_to_remove.push(MultibodyJointHandle(rb2.0));
298298

299-
self.to_wake_up.insert(rb1, ());
300-
self.to_wake_up.insert(rb2, ());
299+
self.to_wake_up.insert(rb1);
300+
self.to_wake_up.insert(rb2);
301301
}
302302

303303
for articulation_handle in articulations_to_remove {

src/pipeline/physics_pipeline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl PhysicsPipeline {
437437
.drain()
438438
.chain(multibody_joints.to_wake_up.drain());
439439
for handle in impulse_joints_iterator {
440-
islands.wake_up(bodies, handle.0, true);
440+
islands.wake_up(bodies, handle, true);
441441
}
442442

443443
// Apply modifications.

0 commit comments

Comments
 (0)