626 12. Collision and Rigid Body Dynamics
are used by weapon systems (e.g., to determine bullet hits), player mechanics
(e.g., to determine whether or not there is solid ground beneath the character’s
feet), AI systems (e.g., line of sight checks, targeting , movement queries, etc.),
vehicle systems (e.g., to locate and snap the vehicle’s tires to the terrain), and
so on.
12.3.7.2. Shape Casting
Another common query involves asking the collision system how far an imag-
inary convex shape would be able to travel along a directed line segment be-
fore it hits something solid. This is known as a sphere cast when the volume
being cast is a sphere, or a shape cast in general. (Havok calls them linear casts.)
As with ray casts, a shape cast is usually described by specifying the start
point p 0 , the distance to travel d, and of course the type, dimensions, and ori-
entation of the shape we wish to cast.
There are two cases to consider when casting a convex shape.
- The cast shape is already interpenetrating or contacting at least one other
collidable, preventing it from moving away from its starting location. - The cast shape is not intersecting with anything else at its starting loca-
tion, so it is free to move a non-zero distance along its path.
In the fi rst scenario, the collision system typically reports the contact (s)
between the cast shape and all of the collidables with which it is initially in-
terpenetrating. These contacts might be inside the cast shape or on its surface,
as shown in Figure 12.19.
In the second case, the shape can move a non-zero distance along the line
segment before striking something. Presuming that it hits something, it will
usually be a single collidable. However, it is possible for a cast shape to strike
more than one collidable simultaneously if its trajectory is just right. And of
course, if the impacted collidable is a non-convex poly soup, the cast shape
Contacts
d
Figure 12.19. A cast
sphere that starts in
penetration will be un-
able to move, and the
possibly many contact
points will lie inside the
cast shape in general.
Contact Contacts
d
d
Figure 12.20. If the starting location of a cast shape is not interpenetrating anything, then
the shape will move a non-zero distance along its line segment, and its contacts (if any) will
always be on its surface.