For linear motion damping the following code works well:
Code: Select all
inline btVector3 get_linear_velocity(double time)
{
btVector3 vel= (m_calculatedLinearDiff-old_pos1)/time;
return vel;
}
for(i = 0; i < 3; i++)
{
if(m_springEnabled[i])
{
// get current position of constraint
btScalar currPos = m_calculatedLinearDiff[i];
// calculate difference
btScalar delta = currPos - m_equilibriumPoint[i];
// spring force is (delta * m_stiffness) according to Hooke's Law
btScalar force = delta * m_springStiffness[i];
m_linearLimits.m_targetVelocity[i]=SIMD_INFINITY;
m_linearLimits.m_maxMotorForce[i]=(force+(m_springDamping[i]*get_linear_velocity(time_step)[i]))/ info->fps;
}
old_pos1=m_calculatedLinearDiff;
It seems as if m_targetVelocity and m_maxMotorForce work differently in the angular case, or that the angular integration works differently .
Does anybody have any ideas about this issue?