| 334 | } |
| 335 | |
| 336 | void BenchmarkDemo::initPhysics() |
| 337 | { |
| 338 | m_guiHelper->setUpAxis(1); |
| 339 | |
| 340 | setCameraDistance(btScalar(100.)); |
| 341 | |
| 342 | createEmptyDynamicsWorld(); |
| 343 | /////collision configuration contains default setup for memory, collision setup |
| 344 | //btDefaultCollisionConstructionInfo cci; |
| 345 | //cci.m_defaultMaxPersistentManifoldPoolSize = 32768; |
| 346 | //m_collisionConfiguration = new btDefaultCollisionConfiguration(cci); |
| 347 | |
| 348 | /////use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) |
| 349 | //m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); |
| 350 | // |
| 351 | //m_dispatcher->setDispatcherFlags(btCollisionDispatcher::CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION); |
| 352 | |
| 353 | /////the maximum size of the collision world. Make sure objects stay within these boundaries |
| 354 | /////Don't make the world AABB size too large, it will harm simulation quality and performance |
| 355 | //btVector3 worldAabbMin(-1000,-1000,-1000); |
| 356 | //btVector3 worldAabbMax(1000,1000,1000); |
| 357 | // |
| 358 | //btHashedOverlappingPairCache* pairCache = new btHashedOverlappingPairCache(); |
| 359 | //m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,3500,pairCache); |
| 360 | // m_broadphase = new btSimpleBroadphase(); |
| 361 | // m_broadphase = new btDbvtBroadphase(); |
| 362 | |
| 363 | ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) |
| 364 | //btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver; |
| 365 | |
| 366 | //m_solver = sol; |
| 367 | |
| 368 | //btDiscreteDynamicsWorld* dynamicsWorld; |
| 369 | //m_dynamicsWorld = dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration); |
| 370 | |
| 371 | ///the following 3 lines increase the performance dramatically, with a little bit of loss of quality |
| 372 | m_dynamicsWorld->getSolverInfo().m_solverMode |= SOLVER_ENABLE_FRICTION_DIRECTION_CACHING; //don't recalculate friction values each frame |
| 373 | m_dynamicsWorld->getSolverInfo().m_numIterations = 5; //few solver iterations |
| 374 | //m_defaultContactProcessingThreshold = 0.f;//used when creating bodies: body->setContactProcessingThreshold(...); |
| 375 | m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld); |
| 376 | |
| 377 | m_dynamicsWorld->setGravity(btVector3(0, -10, 0)); |
| 378 | |
| 379 | if (m_benchmark < 5) |
| 380 | { |
| 381 | ///create a few basic rigid bodies |
| 382 | btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(250.), btScalar(50.), btScalar(250.))); |
| 383 | // btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),0); |
| 384 | |
| 385 | m_collisionShapes.push_back(groundShape); |
| 386 | |
| 387 | btTransform groundTransform; |
| 388 | groundTransform.setIdentity(); |
| 389 | groundTransform.setOrigin(btVector3(0, -50, 0)); |
| 390 | |
| 391 | //We can also use DemoApplication::createRigidBody, but for clarity it is provided here: |
| 392 | { |
| 393 | btScalar mass(0.); |
nothing calls this directly
no test coverage detected