reactphysics3d
reactphysics3d copied to clipboard
Multithreading
Hi,
TDME2 has the ability to clone worlds and keep them in synch. These operations are synchronized by mutexes in my code.
Usually this also means a world has its own thread and got only accessed by its own thread.
In my special case with ASW I have two worlds.
-
- Original world, means static and dynamic and collision bodies and physics resolving and such
-
- Cloned world, basically only with static bodies, I even do not call update() on it and only do raycasting for path finding.
Do you see any issues using RP3D this way?
Best regards Andreas
Hello,
I do not see any problem with this but I do not know all the details of your code. However, keep in mind that for the moment ReactPhysics3D is not really thread safe. You have to make sure to lock the objects on your side. I am currently working on multi-threading in order to run the collision detection on multiple threads. Hopefully the code will become more and more thread-safe in the future.
Hi,
Is there any update on the ability to run collision detection on multiple threads. For example if I am calling testoverlap on a large group of objects each with their own callback method that stores its own list of bodies that have been overlapped, like the one providing in the sample:

And eachcall of this testoverlap for each of the 100 enemies, is sent as a job in my job system. And is to be dealt with on different threads similar to a parallelfor, would that be of any issue? Since many testoverlaps may be called at the same time.
Thank you!
Currently, it is not safe to call multiple times testoverlap() in different threads. It is plan to support multithreading for the collision detection for the v0.8.0 release of the library (at the end of the year hopefully).