Setting up bullet physics multithreading

Post Reply
YessMasster
Posts: 3
Joined: Mon Jan 18, 2021 1:08 pm

Setting up bullet physics multithreading

Post by YessMasster »

Hello,

I have the following problem - im trying to set up multi-threaded calculations in BP, however, not all seems to be going as it should. Here's the init code:

Code: Select all

static CustomTaskScheduler TaskScheduler(TEXT("bullet physics task scheduler"), PhysicsThreadCount);
TaskScheduler.setNumThreads(PhysicsThreadCount);
btSetTaskScheduler(&TaskScheduler);

CollisionConfiguration = new btDefaultCollisionConfiguration();
Dispatcher = new btCollisionDispatcherMt(CollisionConfiguration);
OverlappingPairCache = new btDbvtBroadphase();
SolverPool = new btConstraintSolverPoolMt(PhysicsThreadCount);

DynamicsWorld = new btDiscreteDynamicsWorldMt(Dispatcher, OverlappingPairCache, SolverPool, nullptr, CollisionConfiguration);
CustomTaskScheduler is a custom scheduler i wrote.

When I launch the simulation, however, all the task threads in the scheduler i wrote. Breakpoints in parallelFor() and parallelSum() are not being hit at all. In the thread list i see the threads from the CustomTaskScheduler, but no other additional Bullet-related threads. So all in all, it seems like despite everything, Bullet still operated on a single thread. Is there something im missing in my initialization?

EDIT: Previously i forgot to use Mt version of dispatcher. After the fix, however, it still doesnt seem to use other threads.
paokakis
Posts: 29
Joined: Mon Jan 04, 2021 10:31 am

Re: Setting up bullet physics multithreading

Post by paokakis »

Interested. Did you add

Code: Select all

#define BT_THREADSAFE = 1
?
Post Reply