aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/joint/multibody_joint
diff options
context:
space:
mode:
authorThierry Berger <contact@thierryberger.com>2024-09-13 10:48:56 +0200
committerGitHub <noreply@github.com>2024-09-13 10:48:56 +0200
commitc714ff81f2be61f433d0521bc56ba44ce0e71298 (patch)
treeb331203cee1c4291bcb74222c5b6ee792eb97536 /src/dynamics/joint/multibody_joint
parent04058a111dcb99393e52158823c0f7d6a87407fb (diff)
downloadrapier-c714ff81f2be61f433d0521bc56ba44ce0e71298.tar.gz
rapier-c714ff81f2be61f433d0521bc56ba44ce0e71298.tar.bz2
rapier-c714ff81f2be61f433d0521bc56ba44ce0e71298.zip
ImpulseJointSet::get_mut option to wake up connected bodies (#716)
Diffstat (limited to 'src/dynamics/joint/multibody_joint')
-rw-r--r--src/dynamics/joint/multibody_joint/multibody_joint_set.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs
index a9bf521..de1748c 100644
--- a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs
+++ b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs
@@ -1,3 +1,5 @@
+use parry::utils::hashmap::HashMap;
+
use crate::data::{Arena, Coarena, Index};
use crate::dynamics::joint::MultibodyLink;
use crate::dynamics::{GenericJoint, Multibody, MultibodyJoint, RigidBodyHandle};
@@ -94,7 +96,7 @@ pub struct MultibodyJointSet {
// NOTE: this is mostly for the island extraction. So perhaps we won’t need
// that any more in the future when we improve our island builder.
pub(crate) connectivity_graph: InteractionGraph<RigidBodyHandle, ()>,
- pub(crate) to_wake_up: Vec<RigidBodyHandle>,
+ pub(crate) to_wake_up: HashMap<RigidBodyHandle, ()>,
}
impl MultibodyJointSet {
@@ -104,7 +106,7 @@ impl MultibodyJointSet {
multibodies: Arena::new(),
rb2mb: Coarena::new(),
connectivity_graph: InteractionGraph::new(),
- to_wake_up: vec![],
+ to_wake_up: HashMap::default(),
}
}
@@ -200,8 +202,8 @@ impl MultibodyJointSet {
multibody1.append(mb2, link1.id, MultibodyJoint::new(data.into(), kinematic));
if wake_up {
- self.to_wake_up.push(body1);
- self.to_wake_up.push(body2);
+ self.to_wake_up.insert(body1, ());
+ self.to_wake_up.insert(body2, ());
}
// Because each rigid-body can only have one parent link,
@@ -223,8 +225,8 @@ impl MultibodyJointSet {
.remove_edge(parent_graph_id, removed.graph_id);
if wake_up {
- self.to_wake_up.push(RigidBodyHandle(handle.0));
- self.to_wake_up.push(parent_rb);
+ self.to_wake_up.insert(RigidBodyHandle(handle.0), ());
+ self.to_wake_up.insert(parent_rb, ());
}
// TODO: remove the node if it no longer has any attached edges?
@@ -265,7 +267,7 @@ impl MultibodyJointSet {
let rb_handle = link.rigid_body;
if wake_up {
- self.to_wake_up.push(rb_handle);
+ self.to_wake_up.insert(rb_handle, ());
}
// Remove the rigid-body <-> multibody mapping for this link.
@@ -290,8 +292,8 @@ impl MultibodyJointSet {
// There is a multibody_joint handle is equal to the second rigid-body’s handle.
articulations_to_remove.push(MultibodyJointHandle(rb2.0));
- self.to_wake_up.push(rb1);
- self.to_wake_up.push(rb2);
+ self.to_wake_up.insert(rb1, ());
+ self.to_wake_up.insert(rb2, ());
}
for articulation_handle in articulations_to_remove {