Blokworld
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Fixed vs variable timestep

2 posters

Go down

Fixed vs variable timestep Empty Fixed vs variable timestep

Post by S33m3 Sun Apr 03, 2011 4:56 am

Just curious, are you using a fixed or variable timestep in your "update" routines ?

S33m3

Posts : 54
Join date : 2011-03-23

Back to top Go down

Fixed vs variable timestep Empty Re: Fixed vs variable timestep

Post by Slaihne Wed Apr 13, 2011 2:17 pm

This has been a thorny issue for me, and what the recent work i was doing was all about.

The world updates at a variable rate, basically as fast as possible. If a lot of water is being updated, say when soemone breaches a lake from a cave then updates will happen slower.

I use a priority system to try to manage this.

Player initiated actions (digging, building etc) update with high priority.

New chunks being added over the horizon because the player moves are a low priority but some work time is reserved to process these.

World updates are middle priority but again, some time is reserved to process these also.
Slaihne
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 56

Back to top Go down

Fixed vs variable timestep Empty Re: Fixed vs variable timestep

Post by S33m3 Wed Apr 13, 2011 3:46 pm

I see Smile

I was facing this kind of problem lately with my own voxel renderer.
(Was doing like your are doing, updating linked to the render loop).

While everything was working properly, a faced strange "physic" bug on a slower machine : My collision was not working properly (Fast objects moving through walls). Very difficult to reproduce because it was linked to the execution time of the render loop varying too much between iteration ! What are you doing to prevent this ?

Until I read this paper :

http://gafferongames.com/game-physics/fix-your-timestep/

So now my render loop looks like this :

Code:

//very simplified loop
while()
{
FixedStepUpdate() // Only executed at fixed time step
Update()              // Once per iteration for stuff that needs to be updated as fast as possible
     
Draw(Interpolation value) // Draw with states interpolated between previous and current frame

}

But it asked me to review in depth my core engine !

S33m3

Posts : 54
Join date : 2011-03-23

Back to top Go down

Fixed vs variable timestep Empty Re: Fixed vs variable timestep

Post by Slaihne Sat Apr 16, 2011 3:21 am

I do something similar if i've picked you up right.

I monitor the frame rate and adjust the distance moved each update to compensate. So it always takes you a certain amount of time to run 10 blocks distance regardless of the frame rate.
Slaihne
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 56

Back to top Go down

Fixed vs variable timestep Empty Re: Fixed vs variable timestep

Post by S33m3 Sat Apr 16, 2011 8:02 am

That's variable fixed time your are using, the problem with this methods is mainly "unforseen freeze".

Let's say that the user launch another application while your program is running, it leads to a "freeze" of 1 second because of high CPU usage.

If you use a variable delta time in your equation (Current update - Previous Update time), in this case it could lead to unpredictible results in physic simulation.

Example with collision : The 1 second freeze could lead to have object missing collision with other objects. And this could be very difficult to debug because it is linked to a situation difficult to reproduce. The link added in my previous message describe clearly this situation.

S33m3

Posts : 54
Join date : 2011-03-23

Back to top Go down

Fixed vs variable timestep Empty Re: Fixed vs variable timestep

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum