use the maximum square residual instead of sum
This commit is contained in:
@@ -1694,7 +1694,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
if (iteration < constraint.m_overrideNumSolverIterations)
|
if (iteration < constraint.m_overrideNumSolverIterations)
|
||||||
{
|
{
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[constraint.m_solverBodyIdA],m_tmpSolverBodyPool[constraint.m_solverBodyIdB],constraint);
|
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[constraint.m_solverBodyIdA],m_tmpSolverBodyPool[constraint.m_solverBodyIdB],constraint);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1725,7 +1725,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
{
|
{
|
||||||
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[c]];
|
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[c]];
|
||||||
btScalar residual = resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
btScalar residual = resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
|
|
||||||
totalImpulse = solveManifold.m_appliedImpulse;
|
totalImpulse = solveManifold.m_appliedImpulse;
|
||||||
}
|
}
|
||||||
@@ -1742,7 +1742,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
|
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
|
||||||
|
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1757,7 +1757,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
|
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
|
||||||
|
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1774,7 +1774,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
{
|
{
|
||||||
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]];
|
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]];
|
||||||
btScalar residual = resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
btScalar residual = resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1793,7 +1793,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
|
solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse;
|
||||||
|
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1815,7 +1815,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration
|
|||||||
rollingFrictionConstraint.m_upperLimit = rollingFrictionMagnitude;
|
rollingFrictionConstraint.m_upperLimit = rollingFrictionMagnitude;
|
||||||
|
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[rollingFrictionConstraint.m_solverBodyIdA],m_tmpSolverBodyPool[rollingFrictionConstraint.m_solverBodyIdB],rollingFrictionConstraint);
|
btScalar residual = resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[rollingFrictionConstraint.m_solverBodyIdA],m_tmpSolverBodyPool[rollingFrictionConstraint.m_solverBodyIdB],rollingFrictionConstraint);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1843,7 +1843,7 @@ void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIte
|
|||||||
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]];
|
const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]];
|
||||||
|
|
||||||
btScalar residual = resolveSplitPenetrationImpulse(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
btScalar residual = resolveSplitPenetrationImpulse(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold);
|
||||||
leastSquaresResidual += residual*residual;
|
leastSquaresResidual = btMax(leastSquaresResidual, residual*residual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (leastSquaresResidual <= infoGlobal.m_leastSquaresResidualThreshold || iteration>=(infoGlobal.m_numIterations-1))
|
if (leastSquaresResidual <= infoGlobal.m_leastSquaresResidualThreshold || iteration>=(infoGlobal.m_numIterations-1))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btColl
|
|||||||
btMultiBodySolverConstraint& constraint = m_multiBodyNonContactConstraints[index];
|
btMultiBodySolverConstraint& constraint = m_multiBodyNonContactConstraints[index];
|
||||||
|
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(constraint);
|
btScalar residual = resolveSingleConstraintRowGeneric(constraint);
|
||||||
leastSquaredResidual += residual*residual;
|
leastSquaredResidual = btMax(leastSquaredResidual,residual*residual);
|
||||||
|
|
||||||
if(constraint.m_multiBodyA)
|
if(constraint.m_multiBodyA)
|
||||||
constraint.m_multiBodyA->setPosUpdated(false);
|
constraint.m_multiBodyA->setPosUpdated(false);
|
||||||
@@ -60,7 +60,7 @@ btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btColl
|
|||||||
residual = resolveSingleConstraintRowGeneric(constraint);
|
residual = resolveSingleConstraintRowGeneric(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
leastSquaredResidual += residual*residual;
|
leastSquaredResidual = btMax(leastSquaredResidual,residual*residual);
|
||||||
|
|
||||||
if(constraint.m_multiBodyA)
|
if(constraint.m_multiBodyA)
|
||||||
constraint.m_multiBodyA->setPosUpdated(false);
|
constraint.m_multiBodyA->setPosUpdated(false);
|
||||||
@@ -85,7 +85,7 @@ btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btColl
|
|||||||
frictionConstraint.m_lowerLimit = -(frictionConstraint.m_friction*totalImpulse);
|
frictionConstraint.m_lowerLimit = -(frictionConstraint.m_friction*totalImpulse);
|
||||||
frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse;
|
frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse;
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(frictionConstraint);
|
btScalar residual = resolveSingleConstraintRowGeneric(frictionConstraint);
|
||||||
leastSquaredResidual += residual*residual;
|
leastSquaredResidual = btMax(leastSquaredResidual , residual*residual);
|
||||||
|
|
||||||
if (frictionConstraint.m_multiBodyA)
|
if (frictionConstraint.m_multiBodyA)
|
||||||
frictionConstraint.m_multiBodyA->setPosUpdated(false);
|
frictionConstraint.m_multiBodyA->setPosUpdated(false);
|
||||||
@@ -115,7 +115,7 @@ btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btColl
|
|||||||
frictionConstraintB.m_lowerLimit = -(frictionConstraintB.m_friction*totalImpulse);
|
frictionConstraintB.m_lowerLimit = -(frictionConstraintB.m_friction*totalImpulse);
|
||||||
frictionConstraintB.m_upperLimit = frictionConstraintB.m_friction*totalImpulse;
|
frictionConstraintB.m_upperLimit = frictionConstraintB.m_friction*totalImpulse;
|
||||||
btScalar residual = resolveConeFrictionConstraintRows(frictionConstraint, frictionConstraintB);
|
btScalar residual = resolveConeFrictionConstraintRows(frictionConstraint, frictionConstraintB);
|
||||||
leastSquaredResidual += residual*residual;
|
leastSquaredResidual = btMax(leastSquaredResidual, residual*residual);
|
||||||
|
|
||||||
if (frictionConstraintB.m_multiBodyA)
|
if (frictionConstraintB.m_multiBodyA)
|
||||||
frictionConstraintB.m_multiBodyA->setPosUpdated(false);
|
frictionConstraintB.m_multiBodyA->setPosUpdated(false);
|
||||||
@@ -148,7 +148,7 @@ btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btColl
|
|||||||
frictionConstraint.m_lowerLimit = -(frictionConstraint.m_friction*totalImpulse);
|
frictionConstraint.m_lowerLimit = -(frictionConstraint.m_friction*totalImpulse);
|
||||||
frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse;
|
frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse;
|
||||||
btScalar residual = resolveSingleConstraintRowGeneric(frictionConstraint);
|
btScalar residual = resolveSingleConstraintRowGeneric(frictionConstraint);
|
||||||
leastSquaredResidual += residual*residual;
|
leastSquaredResidual = btMax(leastSquaredResidual, residual*residual);
|
||||||
|
|
||||||
if (frictionConstraint.m_multiBodyA)
|
if (frictionConstraint.m_multiBodyA)
|
||||||
frictionConstraint.m_multiBodyA->setPosUpdated(false);
|
frictionConstraint.m_multiBodyA->setPosUpdated(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user