Game Development Reference
In-Depth Information
position vector). Therefore larger objects can have more angular movement. This is
the approach I have used in the code on the CD.
real limit = angularLimitConstant *
relativeContactPosition.magnitude();
// Check the angular move is within limits.
if (real_abs(angularMove) > limit)
{
real totalMove = linearMove + angularMove;
// Set the new angular move, with the same sign as before.
if (angularMove >= 0) {
angularMove = limit;
} else {
angularMove = -limit;
}
// Make the linear move take the extra slack.
linearMove = totalMove - angularMove;
}
The value for angularLimitConstant needs to be determined by playing with your
particular simulation. I have found that values around 0.2 give good results, although
lower values are better when very bouncy collisions are needed.
14.4
T HE C OLLISION R ESOLUTION P ROCESS
So far we have looked at resolving particular collisions for both velocity and interpen-
etration. Handling one collision on its own isn't very useful.
The collision detector generates any number of contacts, and all these need to
be processed. We need to build a framework in which any number of collisions can
be processed at once. This final section of the chapter ties the previous algorithms
together to that end. We will end up with a complete collision resolution system that
can be used for simulations that don't need friction. In the next two chapters we will
extend the engine to handle friction, to improve speed, and to increase stability for
objects resting on one another.
I mentioned in the introduction to the topic that the choice of how to resolve a
series of collisions is at the heart of how a physics system is engineered. Most of the
commercial physics middleware packages process all the collisions at the same time
(or at least batch them into groups to be processed simultaneously). This allows them
to make sure that the adjustments made to one contact don't disturb others.
Search Nedrilad ::




Custom Search