Game Development Reference
In-Depth Information
We also add a friend declaration to the contact data structure to allow the resolver
to have direct access to its internals:
Excerpt from include/cyclone/contacts.h
class Contact
{
// ... Other data as before ...
/**
* The contact resolver object needs access into the contacts to
* set and effect the contact.
*/
friend ContactResolver;
};
14.4.2
P REPARING C ONTACT D ATA
Because we may be performing a penetration resolution step as well as a velocity
resolution step for each contact, it is useful to calculate information that both steps
need in one central location. In addition, extra information required to work out the
correct order of resolution must be calculated.
In the first category are two bits of data:
The basis matrix for the contact point, calculated in the calculateContact-
Basis method, is called contactToWorld .
The position of the contact is relative to each object. I called this relative-
ContactPosition in the previous code.
The relative velocity at the contact point falls into the second category. We need this
to resolve velocity, so we can just calculate it in the appropriate method. If we're go-
ing to resolve collisions in order of severity (the fastest first), we'll need this value to
determine which collision to consider first. So it benefits from being calculated once
and reused when needed.
We can store these data in the Contact data structure:
Excerpt from include/cyclone/contacts.h
class Contact
{
// ... Other data as before ...
protected:
/**
* A transform matrix that converts coordinates in the contact's
* frame of reference to world coordinates. The columns of this
* matrix form an orthonormal set of vectors.
Search Nedrilad ::




Custom Search