Game Development Reference
In-Depth Information
be the total change in velocity, not the total velocity:
m
n
1
p = ˙
˙
p
+
g i
where g 1 ...g n is the set of all impulses acting on the object. In practice we won't
accumulate impulses in the way we did forces. We will apply impulses as they arise
during the collision resolution process. Each will be applied one at a time using the
equation
1
m g
The result of our collision resolution will be an impulse to apply to each object.
The impulse will be immediately applied and will instantly change the velocity of the
object.
p = ˙
˙
p
+
7.2
C OLLISION P ROCESSING
To handle collisions we will create a new piece of code—the ContactResolver .Ithas
the job of taking a whole set of collisions and applying the relevant impulses to the
objects involved. Each collision is provided in a Contact data structure, which looks
like this:
Excerpt from include/cyclone/pcontacts.h
/**
* A contact represents two objects in contact (in this case
* ParticleContact representing two particles). Resolving a
* contact removes their interpenetration, and applies sufficient
* impulse to keep them apart. Colliding bodies may also rebound.
*
* The contact has no callable functions, it just holds the
* contact details. To resolve a set of contacts, use the particle
* contact resolver class.
*/
class ParticleContact
{
public:
/**
* Holds the particles that are involved in the contact. The
* second of these can be NULL, for contacts with the scenery.
*/
Particle* particle[2];
/**
Search Nedrilad ::




Custom Search