[ODE] interpolating between physics frames to get the actual positions in the render time

John DeWeese deweese at ict.usc.edu
Wed Apr 16 21:12:02 2003


I think is one of those features that should be left outside of ODE. It
shouldn't be too hard to keep a data structure corresponding to each
body that buffers the positions and orientations at each physics time step.

Arright, so animation jitter occurs when the physics update rate is not
an integer multiple of the framerate. If you want smooth animation in
full screen mode, you want to keep the framerate as an integer multiple
or divisor of the display frequency. If you're running in windowed mode,
the window system double buffers so it doesn't matter.  So the easiest
thing to do is to lock the physics at a rate that's an integer multiple
of the frame rate, changing the step size if necessary, and if your
physics is less frequent than the display, then interpolate using stored
state.

If physics is less frequent than (but not a multiple of) the visual
frame rate, then you get motion gaps, and when it's more frequent than
(but not an integer multiple of) the visual frame rate, then you get
motion jitter because the display is tracking varyingly older versions
of the physics. One option is to adapt the step size of the physics to
meet the expected render time, and try to keep this within a small
variance. Another option (which you suggested) would be to interpolate
between the current frame and the most recent frame. Alternatively, you
could project slightly forward in time using old copies of the state -
that's extrapolation. In both these cases, your visual frame lags a bit
behind reality here, so you have to keep that lag low. If the user wants
to affect the sim, you either have to roll back (ick) or just accept the
resulting user feedback latency.

Interpolation and extrapolation may take some tooling with. With
unconnected bodies, it is easy to interpolate and extrapolate, but with
articulated bodies the results might look funky due to the joint
constraints. You might get away with it for articulated structures that
don't twist their joints around much, but otherwise it would look rather
carpy. Yes, carpy. If you have only point-rotation joints (like most of
'em), you could do forward kinematic interpolation/extrapolation using
quaternion slerp or a quadratic function. For the other types of joints
like sliders, it's just one more annoying thing to deal with.

Unreal does infrequent master physics updates (because it's
client-server) and some kind of extrapolation with collision detection
to fill in the blanks. I think a well-chosen cubic spline and would work
well for the extrapolation, so that you can ensure continuity of the
velocity, thus reducing pops and changes in direction. Pretty advanced
stuff if you ask me.

Finally, I'd like a nice chocolate cake, thanks.

juhani honkala wrote:

> Using the fixed time step physics results in slight time difference 
> between the actual
> render time and physic time which can cause choppiness to the 
> movements of objects...the effect would be more noticeable with kind 
> of large timesteps tho.
>  
> Instead of using just the last physics step position/orientation one 
> could interpolate
> between the last two physics steps and get the position/orientation 
> exactly at the
> rendering time..
>  
>  
> Therefore my question is..
>  
> Is there any way to do that with ODE?
>  
> It's certainly possible to do that outside ODE but it's kinda 
> hassle..and what do you think about lerping between the frames in 
> general..
>  
>  
>  
> cheers,
>  
>  
>  
> juhnu
>  
>  
>  
>  
>  
> ps. oh my first posting to this list ever.. have to buy a cake or 
> something
>  
>  
>  
>