From b631fe9193a2e769e5ca1c5c8c4ac9843da870ac Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 9 Jan 2022 22:15:36 +0100 Subject: Allow locking individual translational axes --- src/dynamics/solver/velocity_ground_constraint_element.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/dynamics/solver/velocity_ground_constraint_element.rs') diff --git a/src/dynamics/solver/velocity_ground_constraint_element.rs b/src/dynamics/solver/velocity_ground_constraint_element.rs index adfcfda..4d4d3c3 100644 --- a/src/dynamics/solver/velocity_ground_constraint_element.rs +++ b/src/dynamics/solver/velocity_ground_constraint_element.rs @@ -29,7 +29,7 @@ impl VelocityGroundConstraintTangentPart { pub fn solve( &mut self, tangents1: [&Vector; DIM - 1], - im2: N, + im2: &Vector, limit: N, mj_lambda2: &mut DeltaVel, ) where @@ -45,7 +45,7 @@ impl VelocityGroundConstraintTangentPart { let dlambda = new_impulse - self.impulse[0]; self.impulse[0] = new_impulse; - mj_lambda2.linear += tangents1[0] * (-im2 * dlambda); + mj_lambda2.linear += tangents1[0].component_mul(im2) * -dlambda; mj_lambda2.angular += self.gcross2[0] * dlambda; } @@ -72,8 +72,8 @@ impl VelocityGroundConstraintTangentPart { self.impulse = new_impulse; - mj_lambda2.linear += - tangents1[0] * (-im2 * dlambda[0]) + tangents1[1] * (-im2 * dlambda[1]); + mj_lambda2.linear += tangents1[0].component_mul(im2) * -dlambda[0] + + tangents1[1].component_mul(im2) * -dlambda[1]; mj_lambda2.angular += self.gcross2[0] * dlambda[0] + self.gcross2[1] * dlambda[1]; } } @@ -101,7 +101,7 @@ impl VelocityGroundConstraintNormalPart { } #[inline] - pub fn solve(&mut self, dir1: &Vector, im2: N, mj_lambda2: &mut DeltaVel) + pub fn solve(&mut self, dir1: &Vector, im2: &Vector, mj_lambda2: &mut DeltaVel) where AngVector: WDot, Result = N>, { @@ -111,7 +111,7 @@ impl VelocityGroundConstraintNormalPart { let dlambda = new_impulse - self.impulse; self.impulse = new_impulse; - mj_lambda2.linear += dir1 * (-im2 * dlambda); + mj_lambda2.linear += dir1.component_mul(im2) * -dlambda; mj_lambda2.angular += self.gcross2 * dlambda; } } @@ -136,7 +136,7 @@ impl VelocityGroundConstraintElement { elements: &mut [Self], dir1: &Vector, #[cfg(feature = "dim3")] tangent1: &Vector, - im2: N, + im2: &Vector, limit: N, mj_lambda2: &mut DeltaVel, solve_normal: bool, -- cgit