I'm making a small racing game for Android and decided to use Bullet as the Physics engine, so I'm using a btRaycastVehicle and some TriMesh, and so far the simulation is fine, and the speed is great.
But I've encountered an issue concerning determinism, after looking into it a bit more, it seems that the way I call stepSimulation() is the root of the problem.
I'm using a standard "Canonical Game Loop" as it's called on the wiki, in which I adjust the parameters of the RaycastVehicle and then step the physics simulation to finally draw the world.
The stepping is done using this call :
// getDeltaTime() returns a float containing the delta in seconds since last call
mDynamicWorld->stepSimulation(gSettings->getDeltaTime(), 12, 0.01f);
Unfortunately, when doing it that way, the simulation is not deterministic at all
, the app runs at a locked 30fps on this Android device (inherent to the device's GL driver), as you can see i'm also using a fixedTimestep of 100Hz because I had some collision issues with the default 60Hz.
However i found out that I can get a deterministic behavior by manually inputting the timestep :
mDynamicWorld->stepSimulation(1/30.f, 12, 0.01f);
Of course, this is not a great solution since it kills the framerate independence.
So i was wondering what could be wrong with my implementation, Isn't it supposed to work just fine ? am I doing it wrong ? Shouldn't Bullet handle it just fine and interpolate the world ?