Page 1 of 1

Setting up bullet physics multithreading

Posted: Mon Jan 18, 2021 1:21 pm
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.