I have a problem with stuttering animations at frame rates lower than around 100 fps, and I am uncertain how to debug this.
In my engine the physics simulation is updated at 60Hz. Every time the physics is updated, my dynamic objects get a new position and orientation. This new transform data is added to an interpolator with a ring buffer, along with the current physics time which increases in steps of 1/60.
The renderer works at a variable frame rate but it can easily be capped at some frame rate. Every time a frame is rendered, the engine asks for the interpolated transform of the dynamic objects and renders those on the screen. The render time is updated every frame and increases with the dt of the last frame. I then apply a visual lag of 50 ms to the render time (ie. I just subtract 0.05 seconds from the time) to make sure I am interpolating and not extrapolating.
All of this works beautifully at high frame rates, but if I cap the frame rate at for example 70 fps, there is a very noticeable stuttering in the movements of all dynamic objects. This stuttering seems to come and go: It might be gone for 5 seconds and then stutter again for 5 seconds and so on.
Does this simply mean that the interpolator does not work as it should? I have checked and double checked the math inside it, and it seems correct. I have also checked that the data that goes into it has the correct transform and time. Everything seems to check out, at least on paper. I attached fraps to the application to see that the capped frame rate stays constant, and it seems to work fine.
What should I test for next?
Edited by GuyWithBeard, 23 October 2012 - 10:13 PM.