Game Development Reference
In-Depth Information
Because we only check for collisions at the end of each frame, objects may have
already passed into one another. So, second, we need to resolve any interpenetration
that has occurred. The interpenetration can be handled in a very similar way to inter-
penetration for particles. But the impulse calculations we need to do anyway allow us
to derive a more physically realistic interpenetration resolution. We'll return to this
process in section 14.3
To resolve the relative motion of the two objects we need to calculate four impulses:
linear and angular impulses for each object. If there is only one object involved in
the collision (if an object is colliding with an immovable object, such as the ground),
then we need only two values: the impulse and impulsive torque for the single object.
To calculate the impulse and impulsive force on each object we go through a series
of steps:
1. We work in a set of coordinates that are relative to the contact. This makes much
of the mathematics a lot simpler. We create a transform matrix to convert into
and out of this new set of coordinates.
2. We work out the change in velocity of the contact point on each object per unit
impulse. Because the impulse will cause linear and angular motion, this value
needs to take account of both components.
3. We will know the velocity change we want to see (in the next step), so we invert
the result of the last stage to find the impulse needed to generate any given velocity
4. We work out what the separating velocity at the contact point should be, what
the closing velocity currently is, and the difference between the two. This is the
desired change in velocity.
5. From the desired change in velocity we can calculate the impulse that must be
6. We split the impulse into its linear and angular components and apply them to
each object.
Let's look at each of these stages in turn.
Our goal is to work out what impulse we need to apply as a result of the collision.
The impulse will generate a change in velocity, and we need to find the impulse that
generates the change in velocity we are looking for.
We are not interested in the linear and angular velocity of the whole object at this
stage. For the purpose of the collision we are only interested in the separating velocity
Search Nedrilad ::

Custom Search