Jump to content
  • Advertisement
  • entries
    23
  • comments
    67
  • views
    2575

Project: Fateless

Fixed Timestep Overrun

VoxycDev

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

 

 



0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!