aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/solver/velocity_ground_constraint_element.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-01-23 16:50:02 +0100
committerSébastien Crozet <developer@crozet.re>2022-01-23 16:50:26 +0100
commit78c8bc6cdef26d14c57d0eeb23188cba592961bf (patch)
treeb26951b1b08c66171e172237dfce6024792b36e9 /src/dynamics/solver/velocity_ground_constraint_element.rs
parentb7bf80550d8cc61637a251aa2ba0e6cdb8d26b74 (diff)
downloadrapier-78c8bc6cdef26d14c57d0eeb23188cba592961bf.tar.gz
rapier-78c8bc6cdef26d14c57d0eeb23188cba592961bf.tar.bz2
rapier-78c8bc6cdef26d14c57d0eeb23188cba592961bf.zip
Improve cfm configuration using the critical damping factor
Diffstat (limited to 'src/dynamics/solver/velocity_ground_constraint_element.rs')
-rw-r--r--src/dynamics/solver/velocity_ground_constraint_element.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/dynamics/solver/velocity_ground_constraint_element.rs b/src/dynamics/solver/velocity_ground_constraint_element.rs
index a843905..8057030 100644
--- a/src/dynamics/solver/velocity_ground_constraint_element.rs
+++ b/src/dynamics/solver/velocity_ground_constraint_element.rs
@@ -109,12 +109,17 @@ impl<N: SimdRealField + Copy> VelocityGroundConstraintNormalPart<N> {
}
#[inline]
- pub fn solve(&mut self, dir1: &Vector<N>, im2: &Vector<N>, mj_lambda2: &mut DeltaVel<N>)
- where
+ pub fn solve(
+ &mut self,
+ cfm_factor: N,
+ dir1: &Vector<N>,
+ im2: &Vector<N>,
+ mj_lambda2: &mut DeltaVel<N>,
+ ) where
AngVector<N>: WDot<AngVector<N>, Result = N>,
{
let dvel = -dir1.dot(&mj_lambda2.linear) + self.gcross2.gdot(mj_lambda2.angular) + self.rhs;
- let new_impulse = (self.impulse - self.r * dvel).simd_max(N::zero());
+ let new_impulse = cfm_factor * (self.impulse - self.r * dvel).simd_max(N::zero());
let dlambda = new_impulse - self.impulse;
self.impulse = new_impulse;
@@ -139,6 +144,7 @@ impl<N: SimdRealField + Copy> VelocityGroundConstraintElement<N> {
#[inline]
pub fn solve_group(
+ cfm_factor: N,
elements: &mut [Self],
dir1: &Vector<N>,
#[cfg(feature = "dim3")] tangent1: &Vector<N>,
@@ -155,7 +161,9 @@ impl<N: SimdRealField + Copy> VelocityGroundConstraintElement<N> {
// Solve penetration.
if solve_normal {
for element in elements.iter_mut() {
- element.normal_part.solve(&dir1, im2, mj_lambda2);
+ element
+ .normal_part
+ .solve(cfm_factor, &dir1, im2, mj_lambda2);
}
}