[PhysX] Pose updating lag?

Started by
7 comments, last by uhfath 13 years, 3 months ago
Hi!
I can't seem to get it.
Here is the situation.
My game loop looks like this:
UpdateLocalTransforms();UpdateGlobalTransforms();UpdatePhysX();RenderStuff();

Inside of UpdatePhysX() right now i'm just moving PhysX actors based on global positions of my graphic objects. Looks like this:
  for(PhysicalBody *body = static_cast<PhysicalBody*>(bodyList.First()); body; body = body->Next())  {    NxMat34 matrix(false);    matrix.setColumnMajor44(body->bodyNode->GetWorldTransform().Get());    body->bodyActor->moveGlobalPose(matrix);  }  currentScene->simulate(TheTimeMgr->GetFloatDeltaTime() * PHYSX_TIMESTEP_SCALE);  currentScene->flushStream();  currentScene->fetchResults(NX_RIGID_BODY_FINISHED, true);

To simplify things, all actors (actually there is just one actor) are kinematic.
Inside RenderStuff() i render all objects based on their global transforms and also render debug info from PhysX.
But when launched, i clearly see my actor lagin behind by one (subjective of course) frame. Like it's taking previous transforms or render in previous transforms. After using different loggings i found that transforms i pass to my actors are exactly same as those that are calculated previously. In other words, all graphic objects are syncronized with physical objects.
Example.
I create a graphic object as a capsule and an actor with a capsule shape. Now i just move my graphic object and then pass resulted transforms to an actor (physical object). After that i render graphic object separately and actor (debug render) separately (not combining them now). Clearly seeing the lag. But all debug stuff (logging to a file, using Visual Studio debugger, etc.) show same transforms (in this case just a simple X coordinate, because i change only it).
What can be the problem?

P.S.
PhysX scene is created with 0 flags set (i.e. no multithreading) and using fixed timestep method.
Changed to using fixed time step like in docs (replaced my GetFloatDeltaTime() with a fixed number), but it didn't help.
Tried to move my actors updating after fetchResults() and before - no difference.
Advertisement
Anyone?
Please?
Someone?
hey, what about the time gone since the last tick ? depending on how long ur deltatime is and the speed of ur object this might cause ur problems.
If i dont correct this in my engine, i get problems aswell.

Dont know physX but get sure about that.
I tried different methods (for calculating deltatime and speeds of objects) for this, but no success. Even a slowly moved object causes this lag.
The strangest thing is that transforms are always exactly same. Those that are used to render graphical objects and those that are used to calculate physical objects.
I'm really lost on this. Also there seems to be different methods used in samples for updating transforms. Which are correct is not clear to me.
Maybe any other ideas?
i tracked this problem, with moving my objects in time ;).
Means i let objects travel on an axis with speed1 and then compared the time with the pos of the object.
before u begin drawing compare the time with what ur objectpos should be like.
for me really sounds it like this problem, but i dont know physx rly.

http://www.gamedev.net/community/forums/ViewReply.asp?id=3726058
Quote:
Another idea of ur problem is if ur paint randomly between ticks ?!
Means if u calc the position just depending on the tick and not depending on the time. Us then draw always the position from the begining of the tick and not
the position between current/nextstate.

Means u draw
(Tick X)(<-u draw here)---------------------------(Tick X+1)
(Time Y)(<-u draw here)---------------------------(Tick Y + DeltaTime)

but times passed since calcing position and u should draw like this:
(Tick X)-------------(<-u draw here)--------------(Tick X+1)
(Time Y)-------------(<-u draw here)--------------(Tick Y + DeltaTime)

This problem is rising, when the movement is high.
U also should check this with Debugoutput and a HighResolutionTimer
(Just print difference between ticktime and real! drawingtime)

Thanks a bunch. I will sure try that.

This topic is closed to new replies.

Advertisement