diff options
Diffstat (limited to 'src/dynamics/joint')
| -rw-r--r-- | src/dynamics/joint/fixed_joint.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/joint/generic_joint.rs | 8 | ||||
| -rw-r--r-- | src/dynamics/joint/impulse_joint/impulse_joint_set.rs | 6 | ||||
| -rw-r--r-- | src/dynamics/joint/motor_model.rs | 9 | ||||
| -rw-r--r-- | src/dynamics/joint/multibody_joint/multibody.rs | 21 | ||||
| -rw-r--r-- | src/dynamics/joint/multibody_joint/multibody_joint_set.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/joint/prismatic_joint.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/joint/revolute_joint.rs | 14 | ||||
| -rw-r--r-- | src/dynamics/joint/rope_joint.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/joint/spherical_joint.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/joint/spring_joint.rs | 12 |
11 files changed, 65 insertions, 65 deletions
diff --git a/src/dynamics/joint/fixed_joint.rs b/src/dynamics/joint/fixed_joint.rs index 75c8228..2bb2f64 100644 --- a/src/dynamics/joint/fixed_joint.rs +++ b/src/dynamics/joint/fixed_joint.rs @@ -84,9 +84,9 @@ impl FixedJoint { } } -impl Into<GenericJoint> for FixedJoint { - fn into(self) -> GenericJoint { - self.data +impl From<FixedJoint> for GenericJoint { + fn from(val: FixedJoint) -> GenericJoint { + val.data } } @@ -143,8 +143,8 @@ impl FixedJointBuilder { } } -impl Into<GenericJoint> for FixedJointBuilder { - fn into(self) -> GenericJoint { - self.0.into() +impl From<FixedJointBuilder> for GenericJoint { + fn from(val: FixedJointBuilder) -> GenericJoint { + val.0.into() } } diff --git a/src/dynamics/joint/generic_joint.rs b/src/dynamics/joint/generic_joint.rs index 83e27be..76a7fe1 100644 --- a/src/dynamics/joint/generic_joint.rs +++ b/src/dynamics/joint/generic_joint.rs @@ -1,3 +1,5 @@ +#![allow(clippy::bad_bit_mask)] // Clippy will complain about the bitmasks due to JointAxesMask::FREE_FIXED_AXES being 0. + use crate::dynamics::solver::MotorParameters; use crate::dynamics::{FixedJoint, MotorModel, PrismaticJoint, RevoluteJoint, RopeJoint}; use crate::math::{Isometry, Point, Real, Rotation, UnitVector, Vector, SPATIAL_DIM}; @@ -704,8 +706,8 @@ impl GenericJointBuilder { } } -impl Into<GenericJoint> for GenericJointBuilder { - fn into(self) -> GenericJoint { - self.0 +impl From<GenericJointBuilder> for GenericJoint { + fn from(val: GenericJointBuilder) -> GenericJoint { + val.0 } } diff --git a/src/dynamics/joint/impulse_joint/impulse_joint_set.rs b/src/dynamics/joint/impulse_joint/impulse_joint_set.rs index 67f8949..3f9835e 100644 --- a/src/dynamics/joint/impulse_joint/impulse_joint_set.rs +++ b/src/dynamics/joint/impulse_joint/impulse_joint_set.rs @@ -105,8 +105,8 @@ impl ImpulseJointSet { } /// Iterates through all the impulse joints attached to the given rigid-body. - pub fn map_attached_joints_mut<'a>( - &'a mut self, + pub fn map_attached_joints_mut( + &mut self, body: RigidBodyHandle, mut f: impl FnMut(RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &mut ImpulseJoint), ) { @@ -282,7 +282,7 @@ impl ImpulseJointSet { &self, islands: &IslandManager, bodies: &RigidBodySet, - out: &mut Vec<Vec<JointIndex>>, + out: &mut [Vec<JointIndex>], ) { for out_island in &mut out[..islands.num_islands()] { out_island.clear(); diff --git a/src/dynamics/joint/motor_model.rs b/src/dynamics/joint/motor_model.rs index e8ffffa..74b8dd3 100644 --- a/src/dynamics/joint/motor_model.rs +++ b/src/dynamics/joint/motor_model.rs @@ -1,23 +1,18 @@ use crate::math::Real; /// The spring-like model used for constraints resolution. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub enum MotorModel { /// The solved spring-like equation is: /// `acceleration = stiffness * (pos - target_pos) + damping * (vel - target_vel)` + #[default] AccelerationBased, /// The solved spring-like equation is: /// `force = stiffness * (pos - target_pos) + damping * (vel - target_vel)` ForceBased, } -impl Default for MotorModel { - fn default() -> Self { - MotorModel::AccelerationBased - } -} - impl MotorModel { /// Combines the coefficients used for solving the spring equation. /// diff --git a/src/dynamics/joint/multibody_joint/multibody.rs b/src/dynamics/joint/multibody_joint/multibody.rs index c65a6ff..617d447 100644 --- a/src/dynamics/joint/multibody_joint/multibody.rs +++ b/src/dynamics/joint/multibody_joint/multibody.rs @@ -127,8 +127,9 @@ impl Multibody { let mut link_id2new_id = vec![usize::MAX; self.links.len()]; for (i, mut link) in self.links.0.into_iter().enumerate() { - let is_new_root = (!joint_only && (i == 0 || link.parent_internal_id == to_remove)) - || (joint_only && (i == 0 || i == to_remove)); + let is_new_root = i == 0 + || !joint_only && link.parent_internal_id == to_remove + || joint_only && i == to_remove; if !joint_only && i == to_remove { continue; @@ -492,7 +493,7 @@ impl Multibody { parent_to_world = parent_link.local_to_world; let (link_j, parent_j) = self.body_jacobians.index_mut_const(i, parent_id); - link_j.copy_from(&parent_j); + link_j.copy_from(parent_j); { let mut link_j_v = link_j.fixed_rows_mut::<DIM>(0); @@ -602,12 +603,12 @@ impl Multibody { let (coriolis_v, parent_coriolis_v) = self.coriolis_v.index_mut2(i, parent_id); let (coriolis_w, parent_coriolis_w) = self.coriolis_w.index_mut2(i, parent_id); - coriolis_v.copy_from(&parent_coriolis_v); - coriolis_w.copy_from(&parent_coriolis_w); + coriolis_v.copy_from(parent_coriolis_v); + coriolis_w.copy_from(parent_coriolis_w); // [c1 - c0].gcross() * (JDot + JDot/u * qdot)" let shift_cross_tr = link.shift02.gcross_matrix_tr(); - coriolis_v.gemm(1.0, &shift_cross_tr, &parent_coriolis_w, 1.0); + coriolis_v.gemm(1.0, &shift_cross_tr, parent_coriolis_w, 1.0); // JDot (but the 2.0 originates from the sum of two identical terms in JDot and JDot/u * gdot) let dvel_cross = (rb.vels.angvel.gcross(link.shift02) @@ -663,7 +664,7 @@ impl Multibody { { // [c3 - c2].gcross() * (JDot + JDot/u * qdot) let shift_cross_tr = link.shift23.gcross_matrix_tr(); - coriolis_v.gemm(1.0, &shift_cross_tr, &coriolis_w, 1.0); + coriolis_v.gemm(1.0, &shift_cross_tr, coriolis_w, 1.0); // JDot let dvel_cross = rb.vels.angvel.gcross(link.shift23).gcross_matrix_tr(); @@ -696,16 +697,16 @@ impl Multibody { { let mut i_coriolis_dt_w = self.i_coriolis_dt.fixed_rows_mut::<ANG_DIM>(DIM); // NOTE: this is just an axpy, but on row columns. - i_coriolis_dt_w.zip_apply(&coriolis_w, |o, x| *o = x * dt * rb_inertia); + i_coriolis_dt_w.zip_apply(coriolis_w, |o, x| *o = x * dt * rb_inertia); } #[cfg(feature = "dim3")] { let mut i_coriolis_dt_w = self.i_coriolis_dt.fixed_rows_mut::<ANG_DIM>(DIM); - i_coriolis_dt_w.gemm(dt, &rb_inertia, &coriolis_w, 0.0); + i_coriolis_dt_w.gemm(dt, &rb_inertia, coriolis_w, 0.0); } self.acc_augmented_mass - .gemm_tr(1.0, &rb_j, &self.i_coriolis_dt, 1.0); + .gemm_tr(1.0, rb_j, &self.i_coriolis_dt, 1.0); } /* diff --git a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs index 748de3b..fa0ffdb 100644 --- a/src/dynamics/joint/multibody_joint/multibody_joint_set.rs +++ b/src/dynamics/joint/multibody_joint/multibody_joint_set.rs @@ -393,10 +393,10 @@ impl MultibodyJointSet { /// Iterate through the handles of all the rigid-bodies attached to this rigid-body /// by a multibody_joint. - pub fn attached_bodies<'a>( - &'a self, + pub fn attached_bodies( + &self, body: RigidBodyHandle, - ) -> impl Iterator<Item = RigidBodyHandle> + 'a { + ) -> impl Iterator<Item = RigidBodyHandle> + '_ { self.rb2mb .get(body.0) .into_iter() @@ -406,10 +406,10 @@ impl MultibodyJointSet { /// Iterate through the handles of all the rigid-bodies attached to this rigid-body /// by an enabled multibody_joint. - pub fn bodies_attached_with_enabled_joint<'a>( - &'a self, + pub fn bodies_attached_with_enabled_joint( + &self, body: RigidBodyHandle, - ) -> impl Iterator<Item = RigidBodyHandle> + 'a { + ) -> impl Iterator<Item = RigidBodyHandle> + '_ { self.attached_bodies(body).filter(move |other| { if let Some((_, _, link)) = self.joint_between(body, *other) { link.joint.data.is_enabled() diff --git a/src/dynamics/joint/prismatic_joint.rs b/src/dynamics/joint/prismatic_joint.rs index 1e7a016..d0f3a7d 100644 --- a/src/dynamics/joint/prismatic_joint.rs +++ b/src/dynamics/joint/prismatic_joint.rs @@ -152,9 +152,9 @@ impl PrismaticJoint { } } -impl Into<GenericJoint> for PrismaticJoint { - fn into(self) -> GenericJoint { - self.data +impl From<PrismaticJoint> for GenericJoint { + fn from(val: PrismaticJoint) -> GenericJoint { + val.data } } @@ -263,8 +263,8 @@ impl PrismaticJointBuilder { } } -impl Into<GenericJoint> for PrismaticJointBuilder { - fn into(self) -> GenericJoint { - self.0.into() +impl From<PrismaticJointBuilder> for GenericJoint { + fn from(val: PrismaticJointBuilder) -> GenericJoint { + val.0.into() } } diff --git a/src/dynamics/joint/revolute_joint.rs b/src/dynamics/joint/revolute_joint.rs index 9400ba8..ba27351 100644 --- a/src/dynamics/joint/revolute_joint.rs +++ b/src/dynamics/joint/revolute_joint.rs @@ -17,6 +17,7 @@ pub struct RevoluteJoint { impl RevoluteJoint { /// Creates a new revolute joint allowing only relative rotations. #[cfg(feature = "dim2")] + #[allow(clippy::new_without_default)] // For symmetry with 3D which can’t have a Default impl. pub fn new() -> Self { let data = GenericJointBuilder::new(JointAxesMask::LOCKED_REVOLUTE_AXES); Self { data: data.build() } @@ -137,9 +138,9 @@ impl RevoluteJoint { } } -impl Into<GenericJoint> for RevoluteJoint { - fn into(self) -> GenericJoint { - self.data +impl From<RevoluteJoint> for GenericJoint { + fn from(val: RevoluteJoint) -> GenericJoint { + val.data } } @@ -153,6 +154,7 @@ pub struct RevoluteJointBuilder(pub RevoluteJoint); impl RevoluteJointBuilder { /// Creates a new revolute joint builder. #[cfg(feature = "dim2")] + #[allow(clippy::new_without_default)] // For symmetry with 3D which can’t have a Default impl. pub fn new() -> Self { Self(RevoluteJoint::new()) } @@ -241,8 +243,8 @@ impl RevoluteJointBuilder { } } -impl Into<GenericJoint> for RevoluteJointBuilder { - fn into(self) -> GenericJoint { - self.0.into() +impl From<RevoluteJointBuilder> for GenericJoint { + fn from(val: RevoluteJointBuilder) -> GenericJoint { + val.0.into() } } diff --git a/src/dynamics/joint/rope_joint.rs b/src/dynamics/joint/rope_joint.rs index 08c90e5..64a66ea 100644 --- a/src/dynamics/joint/rope_joint.rs +++ b/src/dynamics/joint/rope_joint.rs @@ -134,9 +134,9 @@ impl RopeJoint { } } -impl Into<GenericJoint> for RopeJoint { - fn into(self) -> GenericJoint { - self.data +impl From<RopeJoint> for GenericJoint { + fn from(val: RopeJoint) -> GenericJoint { + val.data } } @@ -231,8 +231,8 @@ impl RopeJointBuilder { } } -impl Into<GenericJoint> for RopeJointBuilder { - fn into(self) -> GenericJoint { - self.0.into() +impl From<RopeJointBuilder> for GenericJoint { + fn from(val: RopeJointBuilder) -> GenericJoint { + val.0.into() } } diff --git a/src/dynamics/joint/spherical_joint.rs b/src/dynamics/joint/spherical_joint.rs index 6f2dc39..dcbf5fb 100644 --- a/src/dynamics/joint/spherical_joint.rs +++ b/src/dynamics/joint/spherical_joint.rs @@ -164,9 +164,9 @@ impl SphericalJoint { } } -impl Into<GenericJoint> for SphericalJoint { - fn into(self) -> GenericJoint { - self.data +impl From<SphericalJoint> for GenericJoint { + fn from(val: SphericalJoint) -> GenericJoint { + val.data } } @@ -288,8 +288,8 @@ impl SphericalJointBuilder { } } -impl Into<GenericJoint> for SphericalJointBuilder { - fn into(self) -> GenericJoint { - self.0.into() +impl From<SphericalJointBuilder> for GenericJoint { + fn from(val: SphericalJointBuilder) -> GenericJoint { + val.0.into() } } diff --git a/src/dynamics/joint/spring_joint.rs b/src/dynamics/joint/spring_joint.rs index d9a849a..f5cb5bd 100644 --- a/src/dynamics/joint/spring_joint.rs +++ b/src/dynamics/joint/spring_joint.rs @@ -94,9 +94,9 @@ impl SpringJoint { // } } -impl Into<GenericJoint> for SpringJoint { - fn into(self) -> GenericJoint { - self.data +impl From<SpringJoint> for GenericJoint { + fn from(val: SpringJoint) -> GenericJoint { + val.data } } @@ -165,8 +165,8 @@ impl SpringJointBuilder { } } -impl Into<GenericJoint> for SpringJointBuilder { - fn into(self) -> GenericJoint { - self.0.into() +impl From<SpringJointBuilder> for GenericJoint { + fn from(val: SpringJointBuilder) -> GenericJoint { + val.0.into() } } |
