Understanding Time Advance [Help!]

al2950

29-09-2009 00:45:08

I have a few, possibly stupid, questions that i cant quite work out.

My understanding of physics engines is that they should be updated at a constant rate, seperate from the rendering, at about 60-100Hz.

With this understanding i was implementing NxOgre with a seperate thread for the TimeController->advance() method. From what i have read this might be completely wrong!!

So my question, ...Does NxOgre/PhysX update its simulation at a constant rate in a seperate (Hidden) thread and so when you call advance it only updates the objects with the data created from the simulation runnning in the background??

The reason i ask is that my app currently runs at about 30-40 fps, not the 60Hz i would like the physics to work at. I have a few kinematic actors which i call movePosition on, however they do not move smoothly and 'jitter' quite alot

Hope that makes sense to someone!!

Cheers

Gus

betajaen

29-09-2009 01:41:47

No, it doesn't use a separate thread, and I believe it wouldn't make a difference if the thread was all the same or seperated out.

The physics time stepping code is based off the "Fix Your Timestep" article. Which is a good way to handle when the frame rate is above the desired 60hz. But it fails when it doesn't, as you can currently see. One of the fixes is to use interpolation.

If you like in the other recent jittering thread, I posted a fix that may (or may not) help. If you want to try and add the fix and see how it helps for you. If it does work, I'll modify BloodyMess for others to make use of it.

al2950

29-09-2009 08:46:16

ah I see now, thanks for pointing me at that 'Fix your timestep' article.

On another note, and I know this has been talked about before, but surely if you are updating the physics in the same thread as the rendering this is going to degrade the performance of your app, or have i got the wrong end of the stick again!! :?

betajaen

29-09-2009 09:12:37

PhysX runs in a different thread. So what happens is tell it to calculate the new frame, and whilst it's doing that you do something else such as maintenance or render the last frames results, etc.

al2950

29-09-2009 09:47:30

Ah ok thanks very much betajaen, I understand now!!

I will try and intergrate your interpolation code and see if that fix's my issues

Thanks for the quick responses

Gus