Make cloning rigid-bodies and colliders more idiomatic.

Fix #53
This commit is contained in:
Crozet Sébastien
2020-11-03 14:29:47 +01:00
parent 0cc850dc50
commit 036a246141
6 changed files with 29 additions and 38 deletions

View File

@@ -188,6 +188,7 @@ impl<'de> serde::Deserialize<'de> for ColliderShape {
}
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[derive(Clone)]
/// A geometric entity that can be attached to a body so it can be affected by contacts and proximity queries.
///
/// To build a new collider, use the `ColliderBuilder` structure.
@@ -212,20 +213,14 @@ pub struct Collider {
pub user_data: u128,
}
impl Clone for Collider {
fn clone(&self) -> Self {
Self {
shape: self.shape.clone(),
parent: RigidBodySet::invalid_handle(),
contact_graph_index: ColliderGraphIndex::new(crate::INVALID_U32),
proximity_graph_index: ColliderGraphIndex::new(crate::INVALID_U32),
proxy_index: crate::INVALID_USIZE,
..*self
}
}
}
impl Collider {
pub(crate) fn reset_internal_links(&mut self) {
self.parent = RigidBodySet::invalid_handle();
self.contact_graph_index = ColliderGraphIndex::new(crate::INVALID_U32);
self.proximity_graph_index = ColliderGraphIndex::new(crate::INVALID_U32);
self.proxy_index = crate::INVALID_USIZE;
}
/// The rigid body this collider is attached to.
pub fn parent(&self) -> RigidBodyHandle {
self.parent