Setting restitution to zero makes the bouncing smaller, but it does not prevent it completely. So after the capsule lands on the static floor, it bounces back upwards, making it difficult to get consistent jump height and precise player controls.
I have the same problem for the ragdoll too, so fixing it should help there as well.
This is how i do it in the Update() function of ndModel:
- Code: Select all
ndVector align = frictionAlignment;//playerNotify->playerAcc;// both works
ndFloat32 mag = ndSqrt(align.DotProduct(align).GetScalar());
if (mag > FP_EPSILON)
{
align *= 1.f / mag;
const ndBodyKinematic::ndContactMap& contactMap = playerBody->GetAsBodyDynamic()->GetContactMap();
ndBodyKinematic::ndContactMap::Iterator it(contactMap);
for (it.Begin(); it; it++)
{
ndContact* const contact = *it;
if (contact->IsActive())
{
ndContactPointList& contactPoints = contact->GetContactPoints();
const ndBodyKinematic* const otherBody = contact->GetBody1();
for (ndContactPointList::ndNode* contactNode = contactPoints.GetFirst(); contactNode; contactNode = contactNode->GetNext())
{
ndContactMaterial& contactPoint = contactNode->GetInfo();
ndVector aligned = align - contactPoint.m_normal * contactPoint.m_normal.DotProduct(align);
ndFloat32 mag = ndSqrt(aligned.DotProduct(aligned).GetScalar());
if (mag > FP_EPSILON)
{
contactPoint.m_dir1 = aligned * (1.f / mag);
contactPoint.m_dir0 = contactPoint.m_dir1.CrossProduct(contactPoint.m_normal);
}
contactPoint.m_material.m_restitution = 0.f; // body still bounces after landing from a jump
}
}
}
}
Is there something else i need to do, beside contactPoint.m_material.m_restitution = 0.f ?
Or could it be a bug?