Game Development Reference
In-Depth Information
F IGURE 14.5
Velocity-based resolution introduces apparent friction.
To move the objects back we need to keep track of the velocity and rotation of
each object before any collision resolution began. We can then use these values to
work out an equation for the path each contact point takes, and work out when they
first crossed over (i.e., when interpenetration began).
While this is a sensible strategy and can give good results, it has the effect of intro-
ducing additional friction into the simulation. Figure 14.5 shows an example of this.
The object penetrates the ground while moving sideways at high speed. The velocity-
based resolution method would move it back along its path as shown. To the user it
would appear that the object hits the ground and sticks, even if no friction was set for
the collision.
Nonlinear Projection
A third option, and the one I will employ in this chapter, is based on the linear projec-
tion method. Rather than just moving the objects back linearly, we use a combination
of linear and angular movement to resolve the penetration.
The theory is the same: we move both objects in the direction of the contact nor-
mal until they are no longer interpenetrating. The movement, rather than being ex-
clusively linear, can also have an angular component.
For each object in the collision we need to calculate the amount of linear motion
and the amount of angular motion so the total effect is exactly enough to resolve
the interpenetration. Just as for linear projection, the amount of motion each object
makes will depend on the inverse mass of each object. Unlike linear projection, the
balance between linear and angular velocity will depend on the inverse inertia tensor
of each object.
An object with a high moment of inertia tensor at the contact point will be less
likely to rotate, so will take more of its motion as linear motion. If the object rotates
easily, however, then angular motion will take more of the burden.
Figure 14.6 shows nonlinear projection applied to the same situation we saw in
figures 14.4 and 14.5. The result is still not exactly as it would be in reality, but the
result is more believable and usually doesn't look odd. Figure 14.7 shows the shallow
Search Nedrilad ::




Custom Search