Game Development Reference
In-Depth Information
F IGURE 16.4
Iterative resolution makes microscopic changes.
on-a-plane situation. If we run this simulation and look at the resolutions being per-
formed, we see that the two contacts (four in a 3D simulation) are repeatedly consid-
ered. Taking just penetration, if we look at the penetration depths at each iteration, we
see (as shown in the figure) that the first penetration resolutions get us almost there
and then subsequent resolutions make such tiny adjustments that they can never be
seen by a player. This kind of sub-visual adjustment is a pure waste of time.
To avoid this situation we can add a tolerance limit to both velocity and penetra-
tion collisions. Only collisions that are more severe than this limit will be considered.
That way the first time a contact is resolved, it should be brought within the limit and
then never reconsidered unless the resolution of another contact disturbs it greatly.
This limit can be simply implemented when we search for the most severe contact
to consider. Rather than starting with a worstPenetration value of zero
Contact* lastContact = contacts + numContacts;
for (unsigned i = 0; i < positionIterations; i++)
Contact* worstContact = NULL;
real worstPenetration = 0;
for(Contact* contact = contacts; contact < lastContact; contact++)
if (contact->penetration > worstPenetration)
Search Nedrilad ::

Custom Search