From 536122e08066c762a0f6a1585c458f6c7a54bc2e Mon Sep 17 00:00:00 2001 From: zhguchev Date: Tue, 11 Jan 2022 14:56:26 +0100 Subject: add defaults for the several structs --- src/dynamics/joint/fixed_joint.rs | 6 +++++- src/dynamics/joint/multibody_joint/multibody.rs | 8 ++++++-- src/dynamics/joint/multibody_joint/multibody_joint_set.rs | 1 + src/dynamics/joint/spherical_joint.rs | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/dynamics/joint') diff --git a/src/dynamics/joint/fixed_joint.rs b/src/dynamics/joint/fixed_joint.rs index 10c4d7e..6082938 100644 --- a/src/dynamics/joint/fixed_joint.rs +++ b/src/dynamics/joint/fixed_joint.rs @@ -6,7 +6,11 @@ use crate::math::{Isometry, Point, Real}; pub struct FixedJoint { data: JointData, } - +impl Default for FixedJoint{ + fn default() -> Self { + FixedJoint::new() + } +} impl FixedJoint { pub fn new() -> Self { #[cfg(feature = "dim2")] diff --git a/src/dynamics/joint/multibody_joint/multibody.rs b/src/dynamics/joint/multibody_joint/multibody.rs index e31a333..5779b3e 100644 --- a/src/dynamics/joint/multibody_joint/multibody.rs +++ b/src/dynamics/joint/multibody_joint/multibody.rs @@ -18,7 +18,7 @@ use na::{ }; #[repr(C)] -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug,Default)] struct Force { linear: Vector, angular: AngVector, @@ -91,7 +91,11 @@ pub struct Multibody { coriolis_w: Vec>, i_coriolis_dt: Jacobian, } - +impl Default for Multibody{ + fn default() -> Self { + Multibody::new() + } +} impl Multibody { /// Creates a new multibody with no link. pub fn new() -> Self { diff --git a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs index 24b329f..3e786e2 100644 --- a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs +++ b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs @@ -75,6 +75,7 @@ impl Default for MultibodyJointLink { } } +#[derive(Default)] /// A set of rigid bodies that can be handled by a physics pipeline. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Clone)] diff --git a/src/dynamics/joint/spherical_joint.rs b/src/dynamics/joint/spherical_joint.rs index 581b959..19fbd6f 100644 --- a/src/dynamics/joint/spherical_joint.rs +++ b/src/dynamics/joint/spherical_joint.rs @@ -7,7 +7,11 @@ use crate::math::{Point, Real}; pub struct SphericalJoint { data: JointData, } - +impl Default for SphericalJoint{ + fn default() -> Self { + SphericalJoint::new() + } +} impl SphericalJoint { pub fn new() -> Self { let data = -- cgit