Game Engine Architecture

(Ben Green) #1

762 14. Runtime Gameplay Foundation Systems


if (isVisible)
{
m_pCollisionComponent->Activate();
m_pRenderingComponent->Show();
}
else
{
m_pCollisionComponent->Deactivate();
m_pRenderingComponent->Hide();
}
// etc.
}
The game loop then ends up looking more like this:
while (true)
{
PollJoypad();
float dt = g_gameClock.CalculateDeltaTime();
for (each gameObject)
{
gameObject.Update(dt);
}

g_animationEngine. Update(dt);
g_physicsEngine. Simulate(dt);

g_collisionEngine. DetectAndResolveCollisions(dt);

g_audioEngine. Update(dt);

g_renderingEngine. RenderFrameAndSwapBuffers();
}
Batched updating provides many performance benefi ts, including but not
limited to:
z Maximal cache coherency. Batched updating allows an engine subsys-
tem to achieve maximum cache coherency because its per-object data
is maintained internally and can be arranged in a single, contiguous
region of RAM.
z Minimal duplication of computations. Global calculations can be done once
and reused for many game objects rather than being redone for each
object.
Free download pdf