Hi everyone,
I am trying to port some older physx 2.8 code to the newer physx 3.2 and i am having a hard time getting the graphics and physics to sync properly.
With the old physx 2.8 it had the scene->setTiming method which has been removed in physx 3.
The engine has a preTickSingal and a postTickSignal, with physx 2.8 i would do this and it worked perfectly (that is using the default vales in setTiming function).
void preTickSignal()
{
mScene->fetchResults(NX_RIGID_BODY_FINISHED,true);
mSimulating=false;
}
void postTickSignal(elapsed)
{
mScene->simulate(elapsed);
mSimulating=true;
}
I am trying to emulate the behavior of the old physx fixed time step but i just can't get it to work. What exactly is the old physx 2.8 doing under the hood when setTiming is set with NX_TIMESTEP_FIXED? Is it internally doing something like this (i have tried this in the postTickSignal and the simulation is very unstable and i am using the exact same default values the physx 2.8 used by default but it's not using the maxTimeStep, i wasn't sure about this variable):
if(mAccumulator > FixedSubStepSize)
mAccumulator = 0.0f;
mAccumulator += elapsed;
if(mAccumulator < FixedSubStepSize)
{
mNbSubSteps = 0;
return;
}
mNbSubSteps= physx::PxMin(physx::PxU32(mAccumulator/FixedSubStepSize), MaxSubSteps);
mAccumulator -= F32(mNbSubSteps)*FixedSubStepSize;
if(mNbSubSteps ==0)
return;
for(int i=0;i<mNbSubSteps;i++)
{
mScene->fetchResults( true );
mScene->simulate(FixedSubStepSize);
}
Forgive my noobness on this, it's something i never investigated before because the old physx 2.8 way just worked.