aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/rigid_body.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/dynamics/rigid_body.rs')
-rw-r--r--src/dynamics/rigid_body.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index 6b897a6..d3bd8d7 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -27,7 +27,7 @@ pub enum BodyStatus {
/// A rigid body.
///
/// To create a new rigid-body, use the `RigidBodyBuilder` structure.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct RigidBody {
/// The world-space position of the rigid-body.
pub position: Isometry<f32>,
@@ -58,20 +58,6 @@ pub struct RigidBody {
pub user_data: u128,
}
-impl Clone for RigidBody {
- fn clone(&self) -> Self {
- Self {
- colliders: Vec::new(),
- joint_graph_index: RigidBodyGraphIndex::new(crate::INVALID_U32),
- active_island_id: crate::INVALID_USIZE,
- active_set_id: crate::INVALID_USIZE,
- active_set_offset: crate::INVALID_USIZE,
- active_set_timestamp: crate::INVALID_U32,
- ..*self
- }
- }
-}
-
impl RigidBody {
fn new() -> Self {
Self {
@@ -96,6 +82,15 @@ impl RigidBody {
}
}
+ pub(crate) fn reset_internal_references(&mut self) {
+ self.colliders = Vec::new();
+ self.joint_graph_index = InteractionGraph::<()>::invalid_graph_index();
+ self.active_island_id = 0;
+ self.active_set_id = 0;
+ self.active_set_offset = 0;
+ self.active_set_timestamp = 0;
+ }
+
pub(crate) fn integrate_accelerations(&mut self, dt: f32, gravity: Vector<f32>) {
if self.mass_properties.inv_mass != 0.0 {
self.linvel += (gravity + self.linacc) * dt;