From cef07cfa2071830176fad82d4aaf662fd90c4d35 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Fri, 5 Sep 2008 01:41:32 +0000 Subject: [PATCH] Revert to max 1 substep by default: increased maxSubSteps to 10 make debug version way too slow. Use btDbvtBroadphase in BasicDemo and CcdPhysicsDemo. --- Demos/BasicDemo/BasicDemo.cpp | 33 ++++++------------- Demos/BasicDemo/BasicDemo.h | 2 +- Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp | 10 +----- Demos/ConcaveDemo/ConcavePhysicsDemo.cpp | 2 +- src/BulletDynamics/Dynamics/btDynamicsWorld.h | 2 +- 5 files changed, 14 insertions(+), 35 deletions(-) diff --git a/Demos/BasicDemo/BasicDemo.cpp b/Demos/BasicDemo/BasicDemo.cpp index d70441ae0..cb8851338 100644 --- a/Demos/BasicDemo/BasicDemo.cpp +++ b/Demos/BasicDemo/BasicDemo.cpp @@ -88,25 +88,19 @@ void BasicDemo::initPhysics() ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); - ///the maximum size of the collision world. Make sure objects stay within these boundaries - ///Don't make the world AABB size too large, it will harm simulation quality and performance - btVector3 worldAabbMin(-10000,-10000,-10000); - btVector3 worldAabbMax(10000,10000,10000); - //m_overlappingPairCache = new btSimpleBroadphase();//new btAxisSweep3(worldAabbMin,worldAabbMax,MAX_PROXIES); - m_overlappingPairCache = new btAxisSweep3(worldAabbMin,worldAabbMax,MAX_PROXIES); + m_broadphase = new btDbvtBroadphase(); ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver; m_solver = sol; - - m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration); + m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration); m_dynamicsWorld->setGravity(btVector3(0,-10,0)); ///create a few basic rigid bodies -// btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); - btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); + btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); +// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); m_collisionShapes.push_back(groundShape); @@ -162,11 +156,9 @@ void BasicDemo::initPhysics() for (int k=0;k m_collisionShapes; - btBroadphaseInterface* m_overlappingPairCache; + btBroadphaseInterface* m_broadphase; btCollisionDispatcher* m_dispatcher; diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index 687c2a521..99fc13f82 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -409,16 +409,8 @@ int maxNumOutstandingTasks = 4; m_dispatcher->setNearCallback(customNearCallback); #endif - btVector3 worldAabbMin(-1000,-1000,-1000); - btVector3 worldAabbMax(1000,1000,1000); - m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies); -/// For large worlds or over 16384 objects, use the bt32BitAxisSweep3 broadphase -// m_broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax,maxProxies); -/// When trying to debug broadphase issues, try to use the btSimpleBroadphase -// m_broadphase = new btSimpleBroadphase; - - //box-box is in Extras/AlternativeCollisionAlgorithms:it requires inclusion of those files + m_broadphase = new btDbvtBroadphase(); #ifdef COMPARE_WITH_QUICKSTEP m_solver = new btOdeQuickstepConstraintSolver(); diff --git a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp index d03d3f179..8e5d9288c 100644 --- a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp @@ -186,7 +186,7 @@ void ConcaveDemo::initPhysics() bool useQuantizedAabbCompression = true; //comment out the next line to read the BVH from disk (first run the demo once to create the BVH) -//#define SERIALIZE_TO_DISK 1 +#define SERIALIZE_TO_DISK 1 #ifdef SERIALIZE_TO_DISK btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000); diff --git a/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/src/BulletDynamics/Dynamics/btDynamicsWorld.h index 095c61bcc..52e23823c 100644 --- a/src/BulletDynamics/Dynamics/btDynamicsWorld.h +++ b/src/BulletDynamics/Dynamics/btDynamicsWorld.h @@ -60,7 +60,7 @@ public: ///By default, Bullet will subdivide the timestep in constant substeps of each 'fixedTimeStep'. ///in order to keep the simulation real-time, the maximum number of substeps can be clamped to 'maxSubSteps'. ///You can disable subdividing the timestep/substepping by passing maxSubSteps=0 as second argument to stepSimulation, but in that case you have to keep the timeStep constant. - virtual int stepSimulation( btScalar timeStep,int maxSubSteps=10, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0; + virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0; virtual void debugDrawWorld() = 0;