reactphysics3d icon indicating copy to clipboard operation
reactphysics3d copied to clipboard

Multithreading

Open andreasdr opened this issue 7 years ago • 3 comments

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.

    1. Original world, means static and dynamic and collision bodies and physics resolving and such
    1. 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

andreasdr avatar May 30 '18 23:05 andreasdr

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.

DanielChappuis avatar May 31 '18 18:05 DanielChappuis

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:

image

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!

GameDeva avatar Aug 26 '19 10:08 GameDeva

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

DanielChappuis avatar Aug 26 '19 15:08 DanielChappuis