Game Development Reference
To demonstrate this feature, this chapter's source code sets the spheres to only
move in the X - Y plane (up/down/left/right relative to our camera's starting position),
while being constricted along the Z plane (they cannot move towards/away from the
camera's starting position). Even if another object (such as a box we shoot with a
right-click) collides with one of the spheres along the Z axis, it still cannot move in
that direction. The following call restricts the linear motion of the sphere in such a
The CollisionFilteringDemo application creates 25 boxes and 25 spheres in a
stacked 5 x 5 grid formation. It then configures both types of objects to collide with
the ground plane, but also configures such that the boxes cannot collide with the
spheres, and vice versa.
When we launch this application, we should observe two stacks of boxes and
spheres, each occupying the same space without any collisions between them.
There can be collisions only with the objects of the same shape. The following
screenshot shows the collision filtering in effect: