Game Development Reference
In-Depth Information
Introducing activation states
It may be apparent that the wireframe color of our boxes changes from white to green
a few moments after an object comes to rest. This is yet another optimization that
Bullet handles internally, which is only visualized through the debug mode, but has
a profound effect on CPU usage. Objects whose velocity is below a given threshold
for a given amount of time have their activation state set to deactivated. Meanwhile,
there are actually two dynamic bounding volume trees created when you use a btDb-
vtBroadphase object (as we did). One stores the active objects (the active tree),
and the other stores any static or deactivated objects (the deactive tree). So, when an
object is deactivated, it pushes them into the other tree.
This causes Bullet to skip over them when its time for the world to move objects
around, and since the broad phase object only compares the active tree against itself,
and the active tree against the deactive tree (more importantly, it doesn't compare the
deactive tree against the deactive tree) its impact on processing time is reduced even
further. Later, when an active object collides with the deactivated one, it is activated
once more, pushed back into the active tree, and Bullet performs the necessary calcu-
lations until it decides to deactivate it once more. These activation/deactivation states
are typically referred to as putting the object to sleep, or waking it up.
Tip
Note that the ground plane is always drawn with a green wireframe (asleep) be-
cause Bullet knows that this object has an infinite mass, is static, is never a part
of the active tree, and thus will never need to be moved.
This optimization has its drawbacks; sometimes an object may be moving slow inten-
tionally, but if it is moving too slowly, Bullet deactivates it. For example, we might have
an object that is very slowly teetering on an edge, which means it has a very low an-
gular velocity for a long time, at which point Bullet may assume that it needs to put the
object to sleep. This can cause some bizarre situations, where an object looks like it
should be falling over, but is in fact it is frozen in place at an angle that would not be
possible in the real world.
Search WWH ::




Custom Search