Game Development Reference
In-Depth Information
F IGURE 14.13
Resolving penetration can cause unexpected contact changes.
contact to disappear altogether, or bring new contacts that weren't expected before.
Figure 14.3 shows this in action.
Unfortunately collision detection is far too complex to be run for each iteration
of the resolution algorithm. We need a faster way.
Updating Penetration Depths
Fortunately there is an approximation we can use that gives good results. When the
penetration for a collision is resolved, only one or two objects can be moved: the one
or two objects involved in the collision. At the point where we move these objects
(in the applyPositionChange method), we know how much they are moving both
linearly and angularly.
After resolving the penetration, we keep track of the linear and angular motion
we applied to each object. Then we check through all contacts and find those that also
apply to either object. Only these contacts are updated based on the stored linear and
angular movements.
The update for one contact involves the assumption we've used several times in
this chapter: that the only point involved in the contact is the point designated as
the contact point. To calculate the new penetration value we calculate the new po-
sition of the relative contact point for each object, based on the linear and angular
movements we applied. The penetration value is adjusted based on the new position
of these two points: if they have moved apart (along the line of the contact normal),
then the penetration will be less; if they have overlapped, then the penetration will be
increased.
If the first object in a contact has changed, then the update of the position will be
cp = rotationChange[0].vectorProduct(
c[i].relativeContactPosition[0])
;
cp += velocityChange[0];
Search Nedrilad ::




Custom Search