Revert to max 1 substep by default: increased maxSubSteps to 10 make debug version way too slow.
Use btDbvtBroadphase in BasicDemo and CcdPhysicsDemo.
This commit is contained in:
@@ -88,25 +88,19 @@ void BasicDemo::initPhysics()
|
|||||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||||
|
|
||||||
///the maximum size of the collision world. Make sure objects stay within these boundaries
|
m_broadphase = new btDbvtBroadphase();
|
||||||
///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);
|
|
||||||
|
|
||||||
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||||
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
||||||
m_solver = sol;
|
m_solver = sol;
|
||||||
|
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
|
||||||
|
|
||||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||||
|
|
||||||
///create a few basic rigid bodies
|
///create a few basic rigid bodies
|
||||||
// btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||||
btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
||||||
|
|
||||||
m_collisionShapes.push_back(groundShape);
|
m_collisionShapes.push_back(groundShape);
|
||||||
|
|
||||||
@@ -162,11 +156,9 @@ void BasicDemo::initPhysics()
|
|||||||
|
|
||||||
for (int k=0;k<ARRAY_SIZE_Y;k++)
|
for (int k=0;k<ARRAY_SIZE_Y;k++)
|
||||||
{
|
{
|
||||||
int i=0;
|
for (int i=0;i<ARRAY_SIZE_X;i++)
|
||||||
// for (int i=0;i<ARRAY_SIZE_X;i++)
|
|
||||||
{
|
{
|
||||||
int j=0;
|
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
||||||
// for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
|
||||||
{
|
{
|
||||||
startTransform.setOrigin(btVector3(
|
startTransform.setOrigin(btVector3(
|
||||||
2.0*i + start_x,
|
2.0*i + start_x,
|
||||||
@@ -195,7 +187,6 @@ void BasicDemo::initPhysics()
|
|||||||
void BasicDemo::exitPhysics()
|
void BasicDemo::exitPhysics()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//cleanup in the reverse order of creation/initialization
|
//cleanup in the reverse order of creation/initialization
|
||||||
|
|
||||||
//remove the rigidbodies from the dynamics world and delete them
|
//remove the rigidbodies from the dynamics world and delete them
|
||||||
@@ -219,16 +210,12 @@ void BasicDemo::exitPhysics()
|
|||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete dynamics world
|
|
||||||
delete m_dynamicsWorld;
|
delete m_dynamicsWorld;
|
||||||
|
|
||||||
//delete solver
|
|
||||||
delete m_solver;
|
delete m_solver;
|
||||||
|
|
||||||
//delete broadphase
|
delete m_broadphase;
|
||||||
delete m_overlappingPairCache;
|
|
||||||
|
|
||||||
//delete dispatcher
|
|
||||||
delete m_dispatcher;
|
delete m_dispatcher;
|
||||||
|
|
||||||
delete m_collisionConfiguration;
|
delete m_collisionConfiguration;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class BasicDemo : public DemoApplication
|
|||||||
//keep the collision shapes, for deletion/cleanup
|
//keep the collision shapes, for deletion/cleanup
|
||||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||||
|
|
||||||
btBroadphaseInterface* m_overlappingPairCache;
|
btBroadphaseInterface* m_broadphase;
|
||||||
|
|
||||||
btCollisionDispatcher* m_dispatcher;
|
btCollisionDispatcher* m_dispatcher;
|
||||||
|
|
||||||
|
|||||||
@@ -409,16 +409,8 @@ int maxNumOutstandingTasks = 4;
|
|||||||
m_dispatcher->setNearCallback(customNearCallback);
|
m_dispatcher->setNearCallback(customNearCallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
btVector3 worldAabbMin(-1000,-1000,-1000);
|
|
||||||
btVector3 worldAabbMax(1000,1000,1000);
|
|
||||||
|
|
||||||
m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
|
m_broadphase = new btDbvtBroadphase();
|
||||||
/// 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
|
|
||||||
|
|
||||||
#ifdef COMPARE_WITH_QUICKSTEP
|
#ifdef COMPARE_WITH_QUICKSTEP
|
||||||
m_solver = new btOdeQuickstepConstraintSolver();
|
m_solver = new btOdeQuickstepConstraintSolver();
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void ConcaveDemo::initPhysics()
|
|||||||
bool useQuantizedAabbCompression = true;
|
bool useQuantizedAabbCompression = true;
|
||||||
|
|
||||||
//comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
|
//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
|
#ifdef SERIALIZE_TO_DISK
|
||||||
btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000);
|
btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000);
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
///By default, Bullet will subdivide the timestep in constant substeps of each 'fixedTimeStep'.
|
///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'.
|
///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.
|
///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;
|
virtual void debugDrawWorld() = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user