POV-Ray : Newsgroups : povray.off-topic : The Unintended consequence of "fixing" a physics timestep : Re: The Unintended consequence of "fixing" a physics timestep Server Time
2 Nov 2024 16:09:40 EDT (-0400)
  Re: The Unintended consequence of "fixing" a physics timestep  
From: Slime
Date: 15 Apr 2008 03:28:29
Message: <4804591d$1@news.povray.org>
> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.