Stop resitution for resting contact, after n frames (can be controlled by btContactSolverInfo.m_restingContactRestitutionThreshold
Thanks Jan Bender for bringing this up
This commit is contained in:
@@ -44,6 +44,7 @@ struct btContactSolverInfoData
|
|||||||
btScalar m_warmstartingFactor;
|
btScalar m_warmstartingFactor;
|
||||||
|
|
||||||
int m_solverMode;
|
int m_solverMode;
|
||||||
|
int m_restingContactRestitutionThreshold;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -69,6 +70,7 @@ struct btContactSolverInfo : public btContactSolverInfoData
|
|||||||
m_linearSlop = btScalar(0.0);
|
m_linearSlop = btScalar(0.0);
|
||||||
m_warmstartingFactor=btScalar(0.85);
|
m_warmstartingFactor=btScalar(0.85);
|
||||||
m_solverMode = SOLVER_RANDMIZE_ORDER | SOLVER_CACHE_FRIENDLY | SOLVER_USE_WARMSTARTING;
|
m_solverMode = SOLVER_RANDMIZE_ORDER | SOLVER_CACHE_FRIENDLY | SOLVER_USE_WARMSTARTING;
|
||||||
|
m_restingContactRestitutionThreshold = 2;//resting contact lifetime threshold to disable restitution
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -718,11 +718,19 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
//solverConstraint.m_penetration = cp.getDistance();
|
//solverConstraint.m_penetration = cp.getDistance();
|
||||||
|
|
||||||
solverConstraint.m_friction = cp.m_combinedFriction;
|
solverConstraint.m_friction = cp.m_combinedFriction;
|
||||||
|
|
||||||
|
|
||||||
|
if (cp.m_lifeTime>infoGlobal.m_restingContactRestitutionThreshold)
|
||||||
|
{
|
||||||
|
solverConstraint.m_restitution = 0.f;
|
||||||
|
} else
|
||||||
|
{
|
||||||
solverConstraint.m_restitution = restitutionCurve(rel_vel, cp.m_combinedRestitution);
|
solverConstraint.m_restitution = restitutionCurve(rel_vel, cp.m_combinedRestitution);
|
||||||
if (solverConstraint.m_restitution <= btScalar(0.))
|
if (solverConstraint.m_restitution <= btScalar(0.))
|
||||||
{
|
{
|
||||||
solverConstraint.m_restitution = 0.f;
|
solverConstraint.m_restitution = 0.f;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
btScalar penVel = -solverConstraint.m_penetration/infoGlobal.m_timeStep;
|
btScalar penVel = -solverConstraint.m_penetration/infoGlobal.m_timeStep;
|
||||||
@@ -1220,12 +1228,17 @@ void btSequentialImpulseConstraintSolver::prepareConstraints(btPersistentManifol
|
|||||||
|
|
||||||
cpd->m_penetration = cp.getDistance();///btScalar(info.m_numIterations);
|
cpd->m_penetration = cp.getDistance();///btScalar(info.m_numIterations);
|
||||||
cpd->m_friction = cp.m_combinedFriction;
|
cpd->m_friction = cp.m_combinedFriction;
|
||||||
|
if (cp.m_lifeTime>info.m_restingContactRestitutionThreshold)
|
||||||
|
{
|
||||||
|
cpd->m_restitution = 0.f;
|
||||||
|
} else
|
||||||
|
{
|
||||||
cpd->m_restitution = restitutionCurve(rel_vel, combinedRestitution);
|
cpd->m_restitution = restitutionCurve(rel_vel, combinedRestitution);
|
||||||
if (cpd->m_restitution <= btScalar(0.))
|
if (cpd->m_restitution <= btScalar(0.))
|
||||||
{
|
{
|
||||||
cpd->m_restitution = btScalar(0.0);
|
cpd->m_restitution = btScalar(0.0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//restitution and penetration work in same direction so
|
//restitution and penetration work in same direction so
|
||||||
//rel_vel
|
//rel_vel
|
||||||
|
|||||||
Reference in New Issue
Block a user