Game Development Reference
In-Depth Information
The domino effect
While on the subject of activation states, it is worth mentioning the domino effect . It is
possible for entire groups of touching objects (often called islands ) to be put to sleep
in the same fashion, greatly reducing their impact on the CPU. Once Bullet detects
that none of the objects has moved in a while, they will all be put to sleep eventually.
This might seem convenient and allow us to throw more objects into the simulation,
but be warned. When these islands get too large, consisting of too many objects, all
it takes is for one of them to be nudged and the entire stack could become active
simultaneously as they collide with one another, wake one another up, and the entire
simulation slows to a crawl until Bullet puts some or all of them back to sleep again.
Too much activity such as this occurring in too short span of time can lead to adverse
physics simulation behavior sometimes known as the Spiral of Death . This occurs
when the simulation takes more time processing the current step, than the step sim-
ulates; for example, if we take 20 ms to simulate a 16 ms timestep we're behind by 4
ms, so the simulation needs to compensate in the next step, requiring even more time
to process.
This can create a situation of progressively lower and lower frame rates until the sim-
ulation finds enough breathing room (simulation steps where very little is going on,
such as when the awoken island has finally been dealt with) to catch up to the current
moment in time. This would obviously create a very jarring and disappointing game-
play experience.
However, as mentioned towards the end of Chapter 3 , Physics Initialization , Bullet lets
you deal with this situation by tweaking the second and third parameters of stepSim-
ulation() . But, this information is worth keeping in mind if you use an alternative
physics engine, or find yourself building a custom solution in the future.
Note
An old, but still relevant, blog post covers this concept in more detail and suggests
good methods to avoid it:
Search WWH ::




Custom Search