Fixed Timestep Overrun

posted in VoxycDev
Published June 20, 2019
Advertisement

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++;
	}

 

 

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement