Game Development Reference
In-Depth Information
List of Collision Geometries
One last option to increase the accuracy of collision checks is to have an actual list
of collision geometries to test against. So in the case of a human, we could have a
sphere for the head, an AABB for the torso, and maybe some convex polygons for
the hands/legs, and so on. By using several different types of collision geometries,
we can almost completely eliminate false positives.
Although testing against a list of collision geometries is going to be faster than
testing against the actual triangles of a model, it's slow enough that you may not
want to do it as a primary collision check. In the case of a humanoid, you should
do a first-pass collision check against an AABB or capsule. Then only if that colli-
sion check passes should you bother checking against the list of collision objects.
This, of course, assumes you even need that level of accuracy—you might need
such accuracy to test for bullets colliding with the player, but you don't need it to
see whether or not the player is trying to walk into the wall.
Collision Detection
Now that we've covered some of the most common types of collision geometries
used in games, we can take a look at actually testing for intersections between
said objects. Any game that needs to respond to two objects colliding with each
other must use some type of collision detection algorithm. Although some might
find the amount of math in this section a bit off-putting, know that it is absolutely
something that is used in a large number of games. Therefore, it's very important
to understand this math—it's not covered just for the sake of being covered. This
sectionwon'tcovereverypermutationofeverygeometrycollidingwitheveryoth-
er geometry, but it does go over the most common ones you might use.
Sphere versus Sphere Intersection
Two spheres intersect if the distance between their center points is less than the
sum of their radii, as shown in Figure 7.5 . However, computing a distance requires
the use of a square root, so to avoid the square root, it is common instead to check
the distance squared against the sum of the radii squared .
Search WWH ::




Custom Search