Hi,
I am trying to get frame rate independent movement (FRIM) on my Box2D project, however, surprisingly I get slower speeds on a machine with more horsepower than one with less, I am very familiar with ODE, and in it to get FRIM what we usually do is set a static step size, then use the time delta between frames to iterate the step function until the sum of the steps is greater or equal to the delta time.
I tried this same approach with B2D, what I described above is what I get, if I just iterate 60 times as in the example and documentation, then the movement is not frame independent (faster on faster computers).
Anyway, is there a way to get FRIM I am not aware of?
This is my code (msdelta is the delta time since last frame in milliseconds, from SDL_GetTicks(), everything else is self explanatory I think, but let me know if there is any questions):
Code:
void Map::Step(Uint32 msdelta)
{
const Uint32 millistep = 16;
const float timeStep = 0.016f; // 16 milliseconds ~= 60Hz
const int iterations = 10;
Uint32 acumulator = 0;
while(acumulator<msdelta)
{
world->Step(timeStep,10);
acumulator+=millistep;
}
}
Am I right in assuming b2World::Step takes the time step in seconds?
Thanks in advance
