Fixed vs variable timestep
2 posters
Blokworld :: Development :: Information
Page 1 of 1
Fixed vs variable timestep
Just curious, are you using a fixed or variable timestep in your "update" routines ?
S33m3- Posts : 54
Join date : 2011-03-23
Re: Fixed vs variable timestep
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.
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- Posts : 264
Join date : 2011-03-17
Age : 56
Re: Fixed vs variable timestep
I see
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 :
But it asked me to review in depth my core engine !
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
Re: Fixed vs variable timestep
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.
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- Posts : 264
Join date : 2011-03-17
Age : 56
Re: Fixed vs variable timestep
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.
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
Blokworld :: Development :: Information
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Fri Jul 01, 2016 7:25 am by croxxx
» Source?
Thu Jul 12, 2012 9:55 am by raistlinthewiz
» Version Available (Take 2)
Sat Jun 09, 2012 3:23 am by kamild1996
» Terrain Rendering Bug
Thu May 17, 2012 8:07 am by sackboy789
» Mystery Block!
Thu Mar 29, 2012 4:42 am by Corvin73
» Your procedural tree/plant seeding technique?
Sat Mar 24, 2012 3:10 am by Slaihne
» Voxeliq project
Wed Mar 07, 2012 4:25 am by raistlinthewiz
» What is a Tech-Test?
Wed Jan 18, 2012 12:32 pm by joeydmars
» Images
Fri Jan 06, 2012 6:02 am by croxxx