Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple lateral friction constraint magnitudes. #4539

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix possible invalid reference.
Friction contact constraint array is potentially reallocated at each
call if it exceeds capacity, which would invalidate references to
previous constraints. Thus we now get the first friction constraint
based on index rather than its past (possibly invalid) reference.
adamheins committed Nov 15, 2023
commit 36ab535c73084886bfcb0e67aeab9f03aa27e54b
Original file line number Diff line number Diff line change
@@ -1380,14 +1380,15 @@ void btMultiBodyConstraintSolver::convertMultiBodyContact(btPersistentManifold*
{
applyAnisotropicFriction(colObj0, cp.m_lateralFrictionDir1, btCollisionObject::CF_ANISOTROPIC_FRICTION);
applyAnisotropicFriction(colObj1, cp.m_lateralFrictionDir1, btCollisionObject::CF_ANISOTROPIC_FRICTION);
btMultiBodySolverConstraint& frictionConstraint = addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1, cp.m_appliedImpulseLateral1, manifold, frictionIndex, cp, colObj0, colObj1, relaxation, infoGlobal);
addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1, cp.m_appliedImpulseLateral1, manifold, frictionIndex, cp, colObj0, colObj1, relaxation, infoGlobal);

if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
{
applyAnisotropicFriction(colObj0, cp.m_lateralFrictionDir2, btCollisionObject::CF_ANISOTROPIC_FRICTION);
applyAnisotropicFriction(colObj1, cp.m_lateralFrictionDir2, btCollisionObject::CF_ANISOTROPIC_FRICTION);
btMultiBodySolverConstraint& frictionConstraintB = addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2, cp.m_appliedImpulseLateral2, manifold, frictionIndex, cp, colObj0, colObj1, relaxation, infoGlobal);

btMultiBodySolverConstraint& frictionConstraintB = addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2, cp.m_appliedImpulseLateral2, manifold, frictionIndex, cp, colObj0, colObj1, relaxation, infoGlobal);
// frictionConstraintB is at index [m_multiBodyFrictionContactConstraints.size() - 1]
btMultiBodySolverConstraint& frictionConstraint = m_multiBodyFrictionContactConstraints[m_multiBodyFrictionContactConstraints.size() - 2];

btScalar m1 = frictionConstraint.m_jacDiagABInv;
btScalar m2 = frictionConstraintB.m_jacDiagABInv;