767
phases. Then we repeat the entire process for each bucket until there are no
more buckets.
In theory, the depths of the trees in our dependency forest are unbounded.
However, in practice, they are usually quite shallow. For example, we might
have characters holding weapons, and those characters might or might not be
riding on a moving platform or a vehicle. To implement this, we only need
three tiers in our dependency forest, and hence only three buckets: one for
platforms/vehicles, one for characters, and one for the weapons in the charac-
ters’ hands. Many game engines explicitly limit the depth of their dependency
forest so that they can use a fi xed number of buckets (presuming they use a
bucketed approach at all—there are of course many other ways to architect a
game loop).
Here’s what a bucketed, phased, batched update loop might look like:
voidUpdateBucket(Bucketbucket)
{
// ...
for (each gameObject in bucket)
{
gameObject.PreAnimUpdate(dt);
}
g_animationEngine.CalculateIntermediatePoses
( bucket, dt);
for (each gameObject in bucket)
{
gameObject.PostAnimUpdate(dt);
}
g_ragdollSystem.ApplySkeletonsToRagDolls( bucket);
g_physicsEngine.Simulate( bucket, dt); // runs
// ragdolls too
g_collisionEngine.DetectAndResolveCollisions
( bucket, dt);
g_ragdollSystem.ApplyRagDollsToSkeletons( bucket);
g_animationEngine.FinalizePoseAndMatrixPalette
( bucket);
for (each gameObject in bucket)
{
gameObject.FinalUpdate(dt);
}
14.6. Updating Game Objects in Real Time