From 5dfcbe9a331df3c0393ee68d88d0e6983ad0a260 Mon Sep 17 00:00:00 2001 From: stolk Date: Tue, 20 Nov 2018 10:46:27 -0800 Subject: [PATCH] Fix issue #2000 of oscillating constraints. --- .../ConstraintSolver/btGeneric6DofSpring2Constraint.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp b/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp index 7d972ca2b..4593a47c7 100644 --- a/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp +++ b/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp @@ -860,7 +860,12 @@ int btGeneric6DofSpring2Constraint::get_limit_motor_info2( // will we not request a velocity with the wrong direction ? // and the answare is not, because in practice during the solving the current velocity is subtracted from the m_constraintError // so the sign of the force that is really matters +#if 0 info->m_constraintError[srow] = (rotational ? -1 : 1) * (f < 0 ? -SIMD_INFINITY : SIMD_INFINITY); +#else + // Using infinite constraints makes the damping not work, and oscillate for ever. + info->m_constraintError[srow] = vel + f / m * (rotational ? -1 : 1); +#endif btScalar minf = f < fd ? f : fd; btScalar maxf = f < fd ? fd : f;