aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/rigid_body_set.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2020-11-03 15:33:11 +0100
committerGitHub <noreply@github.com>2020-11-03 15:33:11 +0100
commitf70a840f79943aa6da49db2590e13dcd3f3a89ed (patch)
tree1c743ed924b10ebd0eb0982e5c7d798235c12cee /src/dynamics/rigid_body_set.rs
parent0cc850dc505a4034103d229fdce22f9ec7bc410a (diff)
parent71611d3e30ce2fddee20832db3c3e0c8b6ba0d07 (diff)
downloadrapier-f70a840f79943aa6da49db2590e13dcd3f3a89ed.tar.gz
rapier-f70a840f79943aa6da49db2590e13dcd3f3a89ed.tar.bz2
rapier-f70a840f79943aa6da49db2590e13dcd3f3a89ed.zip
Merge pull request #54 from dimforge/idiomatic_clone
Allow cloning all the physics components worth cloning
Diffstat (limited to 'src/dynamics/rigid_body_set.rs')
-rw-r--r--src/dynamics/rigid_body_set.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dynamics/rigid_body_set.rs b/src/dynamics/rigid_body_set.rs
index 83f1c51..b857173 100644
--- a/src/dynamics/rigid_body_set.rs
+++ b/src/dynamics/rigid_body_set.rs
@@ -75,6 +75,7 @@ impl BodyPair {
}
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
+#[derive(Clone)]
/// A set of rigid bodies that can be handled by a physics pipeline.
pub struct RigidBodySet {
// NOTE: the pub(crate) are needed by the broad phase
@@ -154,7 +155,11 @@ impl RigidBodySet {
}
/// Insert a rigid body into this set and retrieve its handle.
- pub fn insert(&mut self, rb: RigidBody) -> RigidBodyHandle {
+ pub fn insert(&mut self, mut rb: RigidBody) -> RigidBodyHandle {
+ // Make sure the internal links are reset, they may not be
+ // if this rigid-body was obtained by cloning another one.
+ rb.reset_internal_references();
+
let handle = self.bodies.insert(rb);
let rb = &mut self.bodies[handle];