For each wheel:
- Ray is shot from the start of the spring downwards (vehicle space) for a distance of the resting length of the spring + the radius of the wheel.
- This gives the compression of the spring (wheel radius is subtracted to get this), and the normal of the ground at the contact point
- Then two forces are calculated, a spring force proportional to compression and a damping force proportional to velocity.
Code: Select all
force = wheel_info.m_suspensionStiffness
* length_diff * wheel_info.m_clippedInvContactDotSuspension;
Code: Select all
btScalar denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS );
if ( denominator >= btScalar(-0.1))
{
wheel.m_clippedInvContactDotSuspension = 10;
}
else
{
wheel.m_clippedInvContactDotSuspension = -1 / denominator;
}
So the two vectors are:
wheel.m_raycastInfo.m_contactNormalWS (the normal of the ground, in world space, typically "up")
wheel.m_raycastInfo.m_wheelDirectionWS (the direction of the "action" of the spring, in world space, typically "down")
so denominator will typically be -1
So as far as I can tell, m_clippedInvContactDotSuspension is usually 1 which makes no difference to the force.
As the car tips away from the vertical (e.g. going round corners) this factor is increased to 10.
What's the purpose of this denominator mechanism? Is it to provide more springiness for when the car is balancing on two wheels?
I have a separate question about damping. There are really two damping coefficients, one for when the wheel is moving up and one when it is moving down. Is this important for stability? I seem to get pretty good results when I use the same value for both.
Usually I would choose damping coefficients so that the system is critically damped. With one damping factor this is easy but I'm not sure how to do it with more than one.