generic6DofSpringConstraint damping values

User avatar
majestik666
Posts: 66
Joined: Tue Mar 02, 2010 6:13 am

generic6DofSpringConstraint damping values

Post by majestik666 »

hi,

I was playing around with this constraint today and realized I had
to use very low values of damping to actually get any effect
anything above 0.01 , it wouldn't have any effect and a good damping
would appear with a value of 0.0025

I looked at the code and don't really understand what's happening
with the damping there, I replaced the code with a version that follows
Hooke's Law and I can now use values comparable to the Stiffness values
to get the damping I want :

OLD :
// spring force is (delta * m_stiffness) according to Hooke's Law
btScalar force = delta * m_springStiffness;
btScalar velFactor = info->fps * m_springDamping / btScalar(info->m_numIterations);
m_linearLimits.m_targetVelocity = velFactor * force;
m_linearLimits.m_maxMotorForce = btFabs(force) / info->fps;

NEW :
// spring force is (delta * m_stiffness) according to Hooke's Law
btScalar force = delta * m_springStiffness;
force += m_springDamping*relVel;
m_linearLimits.m_targetVelocity = force;
m_linearLimits.m_maxMotorForce = btFabs(force) / info->fps;

Any reason why not to use the relVel in the calculation of the damping ?

Cheers
Francois