Tutorial 11: Spaces
Spaces are useful for optimizing collision detection in application-specific ways.† They allow you to setup a customized space-partitioning scheme by encapsulating groups of Shapes.† Here are a few important concepts to keep in mind:
Spaces are mainly useful when you have lots of Shapes that are naturally grouped together.† For a simple example, say your application contains ten simulated robots, each using ten Solids (each Solid using a single Shape).† You have two options: leave all the Solids in the Simulatorís root Space, or create a new Space for each robot.† In the first case there would be 100 * 100 collision checks every time step because every Shape needs to be checked against every other Shape.† In the second case, as long as the robots werenít near each other, there would only be 10 * 10 collision checks per time step because every Space would be checked against the other Spaces.† Obviously, this can save a lot of time.
The following examples show a few different ways to setup Spaces.† Each example contains sample code and a diagram showing the Space hierarchy.† Note that Solids are shown in the diagrams, but it is the Shapes that are actually contained within the Spaces.
OPAL is Copyright © 2004-2005 Alan Fischer, Andres Reinot, and Tyler Streeter