Game Development Reference
In-Depth Information
The collision detection system's role is very specific: determine which objects are col‐
liding, what points on each object are involved in the collision, and the velocities of
those points. It sounds straightforward, but actual implementation can get quite com‐
plex. There are situations where fast-moving objects may go right though other objects,
especially thin ones, over a single time step, making the collision detection system miss
the collision if it relies solely on checking the separation distance between objects and
their relative velocity (i.e., it detects a collision if the objects are within some collision
tolerance and are also moving toward each other). A robust collision detection system
will capture this situation and respond accordingly. In Chapter 8 we simply check if
particles moved past the ground over the course of a single time step, for example, and
then reset their position to that of the ground plane level. We can handle many situations
using such simple techniques, especially when dealing with objects passing through
floors or walls; however, other situations may require more complex algorithms to pre‐
dict if a collision will occur sometime in the near future depending on how fast objects
are moving relative to each other. This latter case is called continuous collision detection,
and it is covered in many Internet, book, and technical paper sources. Many commercial
and open source physics engines advertise their capability to handle continuous colli‐
sion detection.
Another challenge associated with collision detection is the fact that it can be very time-
consuming if you have a large or even moderate number of objects in your simulation.
There are various techniques to deal with this. First, the game space is partitioned in
some coarse grid-like manner, and this grid is used to organize objects depending on
which cell they occupy. Then, in the second phase of collision detection, only those
objects occupying adjacent cells are checked against each other to see if they are col‐
liding. Without this grid partitioning, pairwise checks of every object against every other
object would be very computationally expensive. The second phase of collision detec‐
tion is often a broad approach using bounding spheres or bounding boxes, which may
be axis- or body-aligned. If the bounding spheres or boxes of each object are found to
collide, then the objects likewise may be colliding and further checks will be required;
otherwise, we can infer that the objects are not colliding. In the case of a potential
collision, these further checks become more complex depending on the geometry of the
objects. This phase generally involves polygon- and vertex-level checks; there are well-
established techniques for performing such checks that we won't get into here. Again,
there's a wealth of literature on collision detection available online.
Collision Response
Once the collision detection system does its job, it's time for the collision response system
to deal with the colliding objects. Earlier in this topic, we showed you how to implement
an impulse-moment collision response method. Recall that this method assumes that
at the instant of collision, the most significant forces acting on the objects are the col‐
lision forces, so all other forces can be ignored for that instant. The method then com‐
Search Nedrilad ::




Custom Search