Game Development Reference
In-Depth Information
F IGURE 12.1
A spherical bounding volume.
It is also very easy to check whether two spheres overlap (see chapter 13 for the code).
They overlap if the distance between their centers is less than the sum of their radii.
Spheres are a good shape for bounding volumes for most objects.
Cubic boxes are also often used. They can be represented as a central point and
a set of dimensions, one for each direction. These dimensions are often called “half-
sizes” or “half-widths” because they represent the distance from the central point to
the edge of the box, which is half the overall size of the box in the corresponding
direction.
struct BoundingBox
{
Vector3 center;
Vector3 halfSize;
};
There are two common ways to use boxes as bounding volumes: either aligned to
the world coordinates (called “axis-aligned bounding boxes,” or AABBs) or aligned
to the object's coordinates (called “object bounding boxes,” or OBBs). 2 Spheres have
no such distinction because they don't change under rotation. For tall and thin ob-
2. OBBs commonly can be oriented in a different way to the object they are enclosing. They still rotate
with the object and are expressed in object space, but they have a constant offset orientation. This allows
an even tighter fit in some cases, but adds an extra orientation to their representation and some overhead
when working with them. The BoundingBox data structure would work for either axis-aligned bounding
boxes or object bounding boxes with the same orientation as the rigid body they contained. For a general
object bounding box we'd need to have a separate orientation quaternion in the bounding box structure.
Search Nedrilad ::




Custom Search