4.7. Hardware-Accelerated SIMD Math 185
One convenient representation of a frustum is as an array of six planes,
each of which is represented in point-normal form (i.e., one point and one
normal vector per plane).
Testing whether a point lies inside a frustum is a bit involved, but the basic
idea is to use dot products to determine whether the point lies on the front or
back side of each plane. If it lies inside all six planes, it is inside the frustum.
A helpful trick is to transform the world-space point being tested, by
applying the camera’s perspective projection to it. This takes the point from
world space into a space known as homogeneous clip space. In this space, the
frustum is just an axis-aligned cuboid (AABB). This permits much simpler in/
out tests to be performed.
4.6.7. Convex Polyhedral Regions
A convex polyhedral region is defi ned by an arbitrary set of planes, all with nor-
mals pointing inward (or outward). The test for whether a point lies inside
or outside the volume defi ned by the planes is relatively straightforward; it
is similar to a frustum test, but with possibly more planes. Convex regions
are very useful for implementing arbitrarily-shaped trigger regions in games.
Many engines employ this technique; for example, the Quake engine’s ubiqui-
tous brushes are just volumes bounded by planes in exactly this way.
4.7 Hardware-Accelerated SIMD Math
SIMD stands for “single instruction multiple data .” This refers to the ability of
most modern microprocessors to perform a single mathematical operation on
multiple data items in parallel, using a single machine instruction. For exam-
ple, the CPU might multiply four pairs of fl oating-point numbers in parallel
with a single instruction. SIMD is widely used in game engine math libraries,
because it permits common vector operations such as dot products and matrix
multiplication to be performed extremely rapidly.
Intel fi rst introduced MMX instructions with their Pentium line of CPUs
in 1994. These instructions permitt ed SIMD calculations to be performed on
8-, 16-, and 32-bit integers packed into special 64-bit MMX registers. Intel fol-
lowed this up with various revisions of an extended instruction set called
Streaming SIMD Extensions, or SSE, the fi rst version of which appeared in the
Pentium III processor. The SSE instruction set utilizes 128-bit registers that can
contain integer or IEEE fl oating-point data.
The SSE mode most commonly used by game engines is called packed 32-
bit fl oating-point mode. In this mode, four 32-bit float values are packed into