• entries
23
67
• views
2617

# Fixed Timestep Overrun

734 views

Fixed timestep works when there is nothing loading or not much going on, but as soon as I start switching scenes, the counters go out of control and curTime can never catch up with updatedTime. The editor with the grid launches with this algorithm just fine, and as I add random cubes it works as it should and things get choppy, but moving around is still fast, as it should be. When I delete the cubes, things get smooth again. But once I hit a few hundred cubes to display, the runaway scenario happens. How to prevent curTime from outrunning updatedTime? Tried making them equal, etc, to no avail. This is the code inside the tick function:

	long msecInterval = 1000 / targetFps;

if (updatedTime == 0)
updatedTime = PLAT_GetTime() - msecInterval;

unsigned long curTime = PLAT_GetTime();

while (curTime - updatedTime > msecInterval)
{
fixedTick();
updatedTime += msecInterval;

numLoops++;
}

There are no comments to display.

## Create an account

Register a new account