From ffcdb0f93d01ddba80829a766b0a96b9c2cbb144 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Sun, 14 Oct 2007 01:51:07 +0000 Subject: [PATCH] BulletMultiThreaded needs to refreshContactPoint for contact manifold (this has been moved to the collision detector, instead of constraint solver) BulletMultiThreaded support function for box shouldn't compensate for the collision margin anymore --- Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp | 14 +++++++++----- Demos/GimpactTestDemo/GimpactTestDemo.cpp | 2 +- Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp | 4 ++-- .../SpuContactResult.cpp | 8 ++++++++ .../SpuNarrowPhaseCollisionTask/SpuLocalSupport.h | 5 ++--- .../BroadphaseCollision/btBroadphaseProxy.h | 4 ++-- .../BroadphaseCollision/btOverlappingPairCache.cpp | 3 ++- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index 945dea748..581eb2cbf 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -366,7 +366,7 @@ void CcdPhysicsDemo::initPhysics() #endif //DO_BENCHMARK_PYRAMIDS btCollisionDispatcher* dispatcher=0; - + btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); #ifdef USE_PARALLEL_DISPATCHER @@ -387,10 +387,10 @@ int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks #endif - dispatcher = new SpuGatheringCollisionDispatcher(threadSupportCollision,maxNumOutstandingTasks); -// dispatcher = new btCollisionDispatcher(); + dispatcher = new SpuGatheringCollisionDispatcher(threadSupportCollision,maxNumOutstandingTasks,collisionConfiguration); +// dispatcher = new btCollisionDispatcher(collisionConfiguration); #else - btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); + dispatcher = new btCollisionDispatcher(collisionConfiguration); #endif //USE_PARALLEL_DISPATCHER @@ -450,7 +450,11 @@ int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver); m_dynamicsWorld = world; -// world->getSolverInfo().m_numIterations = 4; + +#ifdef DO_BENCHMARK_PYRAMIDS + world->getSolverInfo().m_numIterations = 4; +#endif //DO_BENCHMARK_PYRAMIDS + m_dynamicsWorld->getDispatchInfo().m_enableSPU = true; m_dynamicsWorld->setGravity(btVector3(0,-10,0)); diff --git a/Demos/GimpactTestDemo/GimpactTestDemo.cpp b/Demos/GimpactTestDemo/GimpactTestDemo.cpp index 17841ef8c..b73b43696 100644 --- a/Demos/GimpactTestDemo/GimpactTestDemo.cpp +++ b/Demos/GimpactTestDemo/GimpactTestDemo.cpp @@ -252,7 +252,7 @@ void GimpactConcaveDemo::renderme() //bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP); - bool useCCD = (getDebugMode() & btIDebugDraw::DBG_EnableCCD); + bool useCCD = ((getDebugMode() & btIDebugDraw::DBG_EnableCCD) != 0); glRasterPos3f(xOffset,yStart,0); sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD); diff --git a/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp index d94dd9221..9bd303158 100644 --- a/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp @@ -1600,7 +1600,7 @@ void ConcaveDemo::renderme() //bool useBulletLCP = !(getDebugMode() & btIDebugDraw::DBG_DisableBulletLCP); - bool useCCD = (getDebugMode() & btIDebugDraw::DBG_EnableCCD); + bool useCCD = ((getDebugMode() & btIDebugDraw::DBG_EnableCCD) != 0); glRasterPos3f(xOffset,yStart,0); sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD); @@ -1643,7 +1643,7 @@ void ConcaveDemo::initGImpactCollision() void ConcaveDemo::initPhysics() { - + btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); //btConstraintSolver* solver = new btSequentialImpulseConstraintSolver; diff --git a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp index abec29eab..a391d66ef 100644 --- a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp +++ b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp @@ -170,6 +170,14 @@ void SpuContactResult::addContactPoint(const btVector3& normalOnBInWorld,const b void SpuContactResult::flush() { + + if (m_spuManifold && m_spuManifold->getNumContacts()) + { + m_spuManifold->refreshContactPoints(m_rootWorldTransform0,m_rootWorldTransform1); + m_RequiresWriteBack = true; + } + + if (m_RequiresWriteBack) { #ifdef DEBUG_SPU_COLLISION_DETECTION diff --git a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h index f55f275e1..7ad95dd7f 100644 --- a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h +++ b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h @@ -48,9 +48,8 @@ inline btPoint3 localGetSupportingVertexWithoutMargin(int shapeType, void* shape { // spu_printf("SPU: getSupport BOX_SHAPE_PROXYTYPE\n"); btConvexInternalShape* convexShape = (btConvexInternalShape*)shape; - btVector3 halfExtents = convexShape->getImplicitShapeDimensions(); - float margin = convexShape->getMarginNV(); - halfExtents -= btVector3(margin,margin,margin); + const btVector3& halfExtents = convexShape->getImplicitShapeDimensions(); + return btPoint3( localDir.getX() < 0.0f ? -halfExtents.x() : halfExtents.x(), localDir.getY() < 0.0f ? -halfExtents.y() : halfExtents.y(), diff --git a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h index b07ec2924..c07124cb9 100644 --- a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h +++ b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h @@ -64,8 +64,8 @@ CONCAVE_SHAPES_END_HERE, ///btBroadphaseProxy -ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy -//struct btBroadphaseProxy +//ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy +struct btBroadphaseProxy { BT_DECLARE_ALIGNED_ALLOCATOR(); diff --git a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp index 33c40829f..ea01656ca 100644 --- a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp +++ b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp @@ -33,8 +33,9 @@ btOverlappingPairCache::btOverlappingPairCache(): { int initialAllocatedSize= 2; m_overlappingPairArray.reserve(initialAllocatedSize); - +#ifdef USE_HASH_PAIRCACHE growTables(); +#endif //USE_HASH_PAIRCACHE }