Refactoring to enable multi SAP broadphase.

This was already planned, and Pierre Terdiman recent thread motivated me to decouple the paircache from the sweep and prune.
http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
This commit is contained in:
ejcoumans
2007-08-02 23:48:46 +00:00
parent 5279f9e129
commit 1f7646f72a
29 changed files with 212 additions and 85 deletions

View File

@@ -152,7 +152,7 @@ void BasicDemo::initPhysics()
m_dispatcher = new btCollisionDispatcher(true);
#endif //USE_PARALLEL_DISPATCHER
//#define USE_SWEEP_AND_PRUNE 1
#define USE_SWEEP_AND_PRUNE 1
#ifdef USE_SWEEP_AND_PRUNE
#define maxProxies 8192
btVector3 worldAabbMin(-10000,-10000,-10000);

View File

@@ -31,7 +31,7 @@ class BasicDemo : public DemoApplication
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btOverlappingPairCache* m_overlappingPairCache;
btBroadphaseInterface* m_overlappingPairCache;
btCollisionDispatcher* m_dispatcher;

View File

@@ -138,7 +138,7 @@ void BspDemo::initPhysics(char* bspfilename)
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
//ConstraintSolver* solver = new OdeConstraintSolver;

View File

@@ -361,7 +361,7 @@ void CcdPhysicsDemo::initPhysics()
btVector3 worldAabbMin(-1000,-1000,-1000);
btVector3 worldAabbMax(1000,1000,1000);
btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
btBroadphaseInterface* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
// btOverlappingPairCache* broadphase = new btSimpleBroadphase;
#ifdef REGISTER_CUSTOM_COLLISION_ALGORITHM

View File

@@ -173,7 +173,7 @@ void ColladaDemo::initPhysics(const char* filename)
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);

View File

@@ -223,7 +223,7 @@ void ConcaveDemo::initPhysics()
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
#ifdef USE_PARALLEL_DISPATCHER
@@ -276,7 +276,7 @@ void ConcaveDemo::clientMoveAndDisplay()
trimeshShape->refitTree();
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->cleanProxyFromPairs(staticBody->getBroadphaseHandle());
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle());
}
m_dynamicsWorld->stepSimulation(dt);

View File

@@ -79,8 +79,8 @@ void ConstraintDemo::initPhysics()
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
//btBroadphaseInterface* broadphase = new btSimpleBroadphase();
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
//ConstraintSolver* solver = new OdeConstraintSolver;
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);

View File

@@ -122,8 +122,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btVector3 worldAabbMin(-10000,-10000,-10000);
btVector3 worldAabbMax(10000,10000,10000);
btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
//OverlappingPairCache* broadphase = new btSimpleBroadphase();
btBroadphaseInterface* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
//btBroadphaseInterface* broadphase = new btSimpleBroadphase();
btConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver);

View File

@@ -1648,7 +1648,7 @@ void ConcaveDemo::initPhysics()
//btConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
btOverlappingPairCache* broadphase = new btSimpleBroadphase();
btBroadphaseInterface* broadphase = new btSimpleBroadphase();
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver);

View File

@@ -450,12 +450,12 @@ void DemoApplication::shootBox(const btVector3& destination)
startTransform.setIdentity();
btVector3 camPos = getCameraPosition();
startTransform.setOrigin(camPos);
#define TEST_UNIFORM_SCALING_SHAPE 1
//#define TEST_UNIFORM_SCALING_SHAPE 1
#ifdef TEST_UNIFORM_SCALING_SHAPE
btConvexShape* childShape = new btBoxShape(btVector3(1.f,1.f,1.f));
btUniformScalingShape* boxShape = new btUniformScalingShape(childShape,0.5f);
#else
btCollisionShape* boxShape = new btSphereShape(1);
btCollisionShape* boxShape = new btBoxShape(btVector3(0.5f,0.5f,0.5f));
#endif//
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,boxShape);
@@ -932,7 +932,7 @@ void DemoApplication::clientResetScene()
colObj->activate();
}
//removed cached contact points
m_dynamicsWorld->getBroadphase()->cleanProxyFromPairs(colObj->getBroadphaseHandle());
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(colObj->getBroadphaseHandle());
btRigidBody* body = btRigidBody::upcast(colObj);
if (body && !body->isStaticObject())

View File

@@ -311,7 +311,7 @@ void RagdollDemo::initPhysics()
btPoint3 worldAabbMin(-10000,-10000,-10000);
btPoint3 worldAabbMax(10000,10000,10000);
btOverlappingPairCache* overlappingPairCache = new btAxisSweep3 (worldAabbMin, worldAabbMax);
btBroadphaseInterface* overlappingPairCache = new btAxisSweep3 (worldAabbMin, worldAabbMax);
btConstraintSolver* solver = new btSequentialImpulseConstraintSolver;

View File

@@ -109,7 +109,7 @@ void UserCollisionAlgorithm::initPhysics()
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 maxAabb(10000,10000,10000);
btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
btBroadphaseInterface* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();

View File

@@ -121,7 +121,7 @@ void VehicleDemo::setupPhysics()
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
#ifdef FORCE_ZAXIS_UP
@@ -490,7 +490,7 @@ void VehicleDemo::clientResetScene()
m_carChassis->setCenterOfMassTransform(btTransform::getIdentity());
m_carChassis->setLinearVelocity(btVector3(0,0,0));
m_carChassis->setAngularVelocity(btVector3(0,0,0));
m_dynamicsWorld->getBroadphase()->cleanProxyFromPairs(m_carChassis->getBroadphaseHandle());
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_carChassis->getBroadphaseHandle());
if (m_vehicle)
{
m_vehicle->resetSuspension();