Posts Tagged ‘revolute joint’


pivot constraints == awesome chain physics!

November 17, 2008

In the past, I have had two different kinds of inelastic distance constraints: single distance constraints (rat_constraint_bar) and min/max distance constraints (rat_constraint_slider).  I add a new one called the pivot (rat_constraint_pivot).  Why, you ask?

Well, you might think a distance constraint with a length of zero is sufficient, but it isn’t.  Here’s why: a distance constraint uses the normal of the distance “bar” to decide how to pull or push the anchor points.  If you are a point, this value cannot exist unless the objects are separated, which means the constraint will never keep the anchors at zero distance from each other.  Furthermore, this means the pivot will never react like a revolute joint, because this behavior relies on a shared point.  So, the key is to compromise.  We use our old friend bias velocity (pseudo velocity) to keep the points together, regular distance constraint style.  But in order to get the correct pivot behavior out of it we have to calculate the impulse as if, like I said before, the anchors share a point even if they don’t.  This means instead of normals, we must create a mass matrix to get the correct torque, then apply the equal offset impulse to the anchors.  Think of it as unbreakable sticky friction.

The really cool looking result can be seen in the following video.  I can now have real segmented chains; solid segments, not distance constraints between particles!  🙂