From 5ab6a0ad434447d99b3080ec9a86a1f733a5b2cb Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Thu, 14 Dec 2017 10:51:43 -0800 Subject: [PATCH] Fix issue with cone friction, we had to accumulate squared residual, not just residual. This fixes issue 1473, thanks to Avik De for reporting the issue. --- .../Featherstone/btMultiBodyConstraintSolver.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp b/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp index 7ed088c9f..5bab043d6 100644 --- a/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp +++ b/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp @@ -114,7 +114,14 @@ btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btColl frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse; frictionConstraintB.m_lowerLimit = -(frictionConstraintB.m_friction*totalImpulse); frictionConstraintB.m_upperLimit = frictionConstraintB.m_friction*totalImpulse; - leastSquaredResidual += resolveConeFrictionConstraintRows(frictionConstraint, frictionConstraintB); + btScalar residual = resolveConeFrictionConstraintRows(frictionConstraint, frictionConstraintB); + leastSquaredResidual += residual*residual; + + if (frictionConstraintB.m_multiBodyA) + frictionConstraintB.m_multiBodyA->setPosUpdated(false); + if (frictionConstraintB.m_multiBodyB) + frictionConstraintB.m_multiBodyB->setPosUpdated(false); + if (frictionConstraint.m_multiBodyA) frictionConstraint.m_multiBodyA->setPosUpdated(false); if (frictionConstraint.m_multiBodyB)