aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics
diff options
context:
space:
mode:
authorRobert Hrusecky <robert.hrusecky@utexas.edu>2020-11-02 15:00:12 -0600
committerRobert Hrusecky <robert.hrusecky@utexas.edu>2020-11-02 15:00:12 -0600
commit8b81a3fd2727dcb911f19c3d7a98c4ec94c6f2fa (patch)
treeb59ce89ff5d1e0505cdf2b7b91740a48763efa76 /src/dynamics
parentbcec54ef31d987cf20b493628a20777183a95f65 (diff)
parenta38fdc101dc74473c45a8b4f5d770f2bc43f30c2 (diff)
downloadrapier-8b81a3fd2727dcb911f19c3d7a98c4ec94c6f2fa.tar.gz
rapier-8b81a3fd2727dcb911f19c3d7a98c4ec94c6f2fa.tar.bz2
rapier-8b81a3fd2727dcb911f19c3d7a98c4ec94c6f2fa.zip
Merge branch 'master' into infinite_fall_memory
Diffstat (limited to 'src/dynamics')
-rw-r--r--src/dynamics/joint/joint_set.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/dynamics/joint/joint_set.rs b/src/dynamics/joint/joint_set.rs
index 2b1895f..5144d97 100644
--- a/src/dynamics/joint/joint_set.rs
+++ b/src/dynamics/joint/joint_set.rs
@@ -181,6 +181,38 @@ impl JointSet {
}
}
+ /// Removes a joint from this set.
+ ///
+ /// If `wake_up` is set to `true`, then the bodies attached to this joint will be
+ /// automatically woken up.
+ pub fn remove(
+ &mut self,
+ handle: JointHandle,
+ bodies: &mut RigidBodySet,
+ wake_up: bool,
+ ) -> Option<Joint> {
+ let id = self.joint_ids.remove(handle)?;
+ let endpoints = self.joint_graph.graph.edge_endpoints(id)?;
+
+ if wake_up {
+ // Wake-up the bodies attached to this joint.
+ if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.0) {
+ bodies.wake_up(*rb_handle, true);
+ }
+ if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.1) {
+ bodies.wake_up(*rb_handle, true);
+ }
+ }
+
+ let removed_joint = self.joint_graph.graph.remove_edge(id);
+
+ if let Some(edge) = self.joint_graph.graph.edge_weight(id) {
+ self.joint_ids[edge.handle] = id;
+ }
+
+ removed_joint
+ }
+
pub(crate) fn remove_rigid_body(
&mut self,
deleted_id: RigidBodyGraphIndex,