How to get global pose of actors in different threads and an issue on api checkResults #283
-
Hello dev teams, I want get the global pose of actors in different threads and I care about the performance cost so I think adding the Lock is not the most suitable approach. So I tried the api of scene
I think result0 should be true, and result1 should be false while result2 should be true. My question is 1. is there any better way to get global pose of a actor in different threads? Thanks and best regards. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi SHiziw, PxScene->simulate(); now you read from your PhysX actors etc. and this can happen in parallel on multiple threads. Once you've read all you needed to read, you start another simulate/fetchResults cycle. The checkResults() call you've mentioned, is meaningful between simulate() and fetchResults() but not really between fetchResults() and simulate() |
Beta Was this translation helpful? Give feedback.
If you really want to keep them totally independent, then it seems to me that you can't avoid some sort of mutex or at least lock-free data structure to communicate the actor poses safely.
It would seem simpler if the reading thread called simulate() and fetchResults(). Note that the simulation will run on a separate thread that way, if you implement the PxCpuDispatcher interface with one worker thread (see PxSceneDesc::cpuDispatcher and the PxDefaultCpuDispatcher example). And by using checkResults(), the reader thread will only call fetchResults() once the simulation has finished, it will not get blocked otherwise. But I'm sure there is a good reason why you do not want to work with suc…