Jump to content
  • Advertisement
Sign in to follow this  

[PhysX] Pose updating lag?

This topic is 2908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can't seem to get it.
Here is the situation.
My game loop looks like this:

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);

currentScene->simulate(TheTimeMgr->GetFloatDeltaTime() * PHYSX_TIMESTEP_SCALE);
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.
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?

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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.


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)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!