| 98 | }; |
| 99 | |
| 100 | void Planar2D::initPhysics() |
| 101 | { |
| 102 | m_guiHelper->setUpAxis(1); |
| 103 | |
| 104 | ///collision configuration contains default setup for memory, collision setup |
| 105 | m_collisionConfiguration = new btDefaultCollisionConfiguration(); |
| 106 | //m_collisionConfiguration->setConvexConvexMultipointIterations(); |
| 107 | |
| 108 | ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) |
| 109 | m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); |
| 110 | |
| 111 | m_simplexSolver = new btVoronoiSimplexSolver(); |
| 112 | m_pdSolver = new btMinkowskiPenetrationDepthSolver(); |
| 113 | |
| 114 | m_convexAlgo2d = new btConvex2dConvex2dAlgorithm::CreateFunc(m_simplexSolver, m_pdSolver); |
| 115 | m_box2dbox2dAlgo = new btBox2dBox2dCollisionAlgorithm::CreateFunc(); |
| 116 | |
| 117 | m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE, CONVEX_2D_SHAPE_PROXYTYPE, m_convexAlgo2d); |
| 118 | m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE, CONVEX_2D_SHAPE_PROXYTYPE, m_convexAlgo2d); |
| 119 | m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE, BOX_2D_SHAPE_PROXYTYPE, m_convexAlgo2d); |
| 120 | m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE, BOX_2D_SHAPE_PROXYTYPE, m_box2dbox2dAlgo); |
| 121 | |
| 122 | m_broadphase = new btDbvtBroadphase(); |
| 123 | //m_broadphase = new btSimpleBroadphase(); |
| 124 | |
| 125 | ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) |
| 126 | btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver; |
| 127 | m_solver = sol; |
| 128 | |
| 129 | m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration); |
| 130 | //m_dynamicsWorld->getSolverInfo().m_erp = 1.f; |
| 131 | //m_dynamicsWorld->getSolverInfo().m_numIterations = 4; |
| 132 | m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld); |
| 133 | |
| 134 | m_dynamicsWorld->setGravity(btVector3(0, -10, 0)); |
| 135 | |
| 136 | ///create a few basic rigid bodies |
| 137 | btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.), btScalar(50.), btScalar(150.))); |
| 138 | // btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); |
| 139 | |
| 140 | m_collisionShapes.push_back(groundShape); |
| 141 | |
| 142 | btTransform groundTransform; |
| 143 | groundTransform.setIdentity(); |
| 144 | groundTransform.setOrigin(btVector3(0, -43, 0)); |
| 145 | |
| 146 | //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here: |
| 147 | { |
| 148 | btScalar mass(0.); |
| 149 | |
| 150 | //rigidbody is dynamic if and only if mass is non zero, otherwise static |
| 151 | bool isDynamic = (mass != 0.f); |
| 152 | |
| 153 | btVector3 localInertia(0, 0, 0); |
| 154 | if (isDynamic) |
| 155 | groundShape->calculateLocalInertia(mass, localInertia); |
| 156 | |
| 157 | //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects |
nothing calls this directly
no test coverage detected