[SDL] Fixed Rate Logic (was: stuck with multiplayer and some segfaults)

David Olofson david at olofson.net
Sat Mar 12 02:03:03 PST 2005


On Friday 11 March 2005 21.11, Marian Schedenig wrote:
> On Friday 11 March 2005 19:59, Olof Bjarnason wrote:
> > Let's say we have 100 Hz game logic, and 60 Hz gfx. Then there are
> > 100/60 ~= 1.67 logic frames per graphic update. Then somethimes 
there
> > will be two logic updates between two graphic frames, and 
sometimes
> > one.
> 
> Ok. I thought since it seems to be an often-used technique,
> interpolation would reduce the effect so much that it isn't
> noticeable  

Fixed logic frame rates are rather popular, but in most games I've 
seen so far, it's implemented by running the logic in a separate 
thread, by "modulating" the number of calls to the game logic per 
rendered frame, or by locking the whole game to a fixed frame rate. 
Combining it with interpolation seems to be rather unusual, for some 
reason.


[...]
> I haven't yet looked at the interpolation details, but isn't the
> whole point of interpolation not having to use too high logic rates?

Yes, and no. As long as the logic frame rate is higher than the 
rendering frame rate, it's "sort of" sufficient - but it doesn't 
result in anything like smooth animation. Without interpolation, 
"higher" is useless; you need "many times higher," to even get close.

With interpolation, OTOH, you get perfectly smooth animation with a 5 
Hz logic frame rate. Right; it won't be accurate, there'll be lots of 
lag, and fast curved motiouns will start to show signs of linear 
segments - but it's still smooth, even at that low rates.

So, if you use interpolation, the selection of logic frame rate is 
mostly about latency and collision detection accuracy. (Of course, 
the latter is mostly a non-issue if you calculate the exact time of 
impact, rater than just test for intersection once per logic frame.)


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---




More information about the SDL mailing list