Hi, im my application, physics and sounds are perfectly synchronized, but graphics are a bit late (about 0.25 sec, more than one frame). I checked my physics simulation loop : I always call fetchResult() after simulate(), each time before using actor->GetPose(). I’m stuck for a week on this, and could’nt find anything solving it …
What could cause this please ?
maybe you passed a wrong value for DeltaTime in your physic loop or graphic loop.
Delta time is the same for graphics and for physics, what’s more delta time in graphics is only used for texture and skinning animations.
For a single frame (game engine loop) :
-Get delta time
-Call the physics loop with delta time as argument. (simulate() and fetchResult() for each time step)
-Render the scene with the same delta time as argument, using actor->GetPose() to position dynamic entities.
I don’t know why, but with this scenario, I have a time shift between physics and graphics.
So how do you now graphic and physic are not synced?
Because sounds are perfectly synced with physics. When there’s a collision, I hear the sound before the entities collide graphically. It’s even more noticable when I use huge velocities (racing game).
I think you should use visual debugger and see if the collision shape of your vehicle is matched with its graphical mesh or not.maybe the pivot point of them are not the same.
Thanks. I’ve already checked with PVD, the collision shapes match with the graphics mesh. And this latency is for any rigid body and for vehicles. For instance if I drop a box on a plane, I will ear the collision sound before the box touches the plane (graphically).
It’s like actor->getPose() is giving a previous pose from a constant time shift (around 0.25 sec), but obviously it must be something else …
It may sounds weird but you may accidentally run the physic for more than once in a frame.It happened to me before.You may want to add a counter to physic and your graphic and check if the number of calls are the same.
I tried to add Sleep(x) x=10, x=20 in the main loop and the decay is still the same, so it doesn’t depend on the frame rate (FPS).
Config of my computer :
CPU : Intel G2030 3 Ghz
GPU : Intel HD graphics
On another computer :
CPU : i5 2.9 Ghz
GPU : Nvidia GT 530
… and with this computer there’s no latency at all.