diff --git a/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp b/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp index 8255e8e44..d9c90c1ca 100644 --- a/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp +++ b/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp @@ -178,14 +178,21 @@ void SpuGatheringCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPai //send one big batch int numTotalPairs = pairCache->getNumOverlappingPairs(); + btBroadphasePair* pairPtr = pairCache->getOverlappingPairArrayPtr(); int i; { + int pairRange = SPU_BATCHSIZE_BROADPHASE_PAIRS; + if (numTotalPairs < (m_spuCollisionTaskProcess->getNumTasks()*SPU_BATCHSIZE_BROADPHASE_PAIRS)) + { + pairRange = (numTotalPairs/m_spuCollisionTaskProcess->getNumTasks())+1; + } + BT_PROFILE("addWorkToTask"); for (i=0;iaddWorkToTask(pairPtr,i,endIndex); i = endIndex; diff --git a/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h b/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h index 53b4d7956..7d5be88d7 100644 --- a/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h +++ b/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h @@ -23,8 +23,8 @@ subject to the following restrictions: ///Too big value might render some SPUs are idle, while a few other SPUs are doing all work. //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 8 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 16 -#define SPU_BATCHSIZE_BROADPHASE_PAIRS 64 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 128 +//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 64 +#define SPU_BATCHSIZE_BROADPHASE_PAIRS 128 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 256 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 512 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 1024