|
|
> if (dt > ts*5)
> step(dt)
> else
> while (dt > ts)
> step(ts)
> dt -= ts
Won't this have the effect of the framerate dropping steadily until frames
get too long, at which point we drop all the extra work we've accumulated
and the framerate snaps back to decent and starts dropping again? This might
be annoying.
A different possibility would be to cap the number of physics timesteps we
take in any frame:
if ( dt > ts * 5 )
for ( i = 1 to 5 )
step( dt / 5 )
else
while (dt > ts)
step(ts)
dt -= ts
With this solution, if the framerate drops it will eventually settle
somewhere (depending on the number you use instead of '5') and remain
constant, because we'll be doing the same amount of work every frame.
Of course, if you see the framerate dropping for this reason, the *best*
solution is to admit that you're doing more work than you can handle in the
time you have, and either increase the timestep, reduce the number of
objects being simulated, or optimize physics engine. =) (It doesn't hurt to
have a fallback, of course.)
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|