Game Development Reference
Joints are at the most fundamental level simpler than contacts. It is an equality
constraint, keeping the relative velocity between two bodies to zero. No inequal-
ities, no interdependent friction, etc. However, the way we combine constraints,
and add limits, breakable constraints, joint friction, and damping typically make
them fairly complex.
The most common artifact with joints is drifting, i.e., an unintended separation
between the two jointed objects. It is the joint counterpart to stacked objects
sinking into each other. The solver simply fails to find a valid solution within the
limited number of iterations. However, as described in the introduction to this
chapter, even with an unlimited number of iterations, joints can still drift due to
the linearization of velocities. Most engines cope with drifting in the same way
they cope with penetration or friction drift: simply add a geometric term, acting
as a spring to compensate for the drift.
2.7.2 Solving Direct
A good way to reduce joint drift is to solve as many constraints as possible at
the same time. Since joints are made up of equality constraints, they can be
solved as a system of linear equations, sometimes referred to as a direct solver.
Solving a system of linear equations is more complicated than applying sequential
impulses, but it does pay off in stability. On the upside, these two methods can
be easily combined. Some engines solve systems of three orthogonal constraints
(this particular assembly is found in many joint types) as a special case with a
three-by-three matrix inversion and then interweave the rest of the constraints
using sequential impulses.
The way the constraints are placed also matters when it comes to stability.
Consider a ball joint. It might be tempting to use a single constraint in the direc-
tion of maximum separation or in the direction of relative velocity. But remember
that whatever constraints go into the solver are the only constraints avoiding mo-
tion, so a single constraint will naturally transfer motion from the constraint axis
to the other two. A proper ball joint needs three constraints to be stable, and even
the way the three constraints are aligned matters. Keeping the constraints aligned
roughly the same way every frame helps stability. World axes are a good start-
ing point, but using the axes of one of the objects can be even better, since they
will then be stationary to at least one of the objects, keeping the configuration as
similar as possible.