| 86 | }; |
| 87 | |
| 88 | void SplitImpulse::initPhysics() |
| 89 | { |
| 90 | m_guiHelper->setUpAxis(1); |
| 91 | |
| 92 | ///collision configuration contains default setup for memory, collision setup |
| 93 | m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); |
| 94 | |
| 95 | ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) |
| 96 | m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); |
| 97 | |
| 98 | m_broadphase = new btDbvtBroadphase(); |
| 99 | btDeformableBodySolver* deformableBodySolver = new btDeformableBodySolver(); |
| 100 | |
| 101 | ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) |
| 102 | btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver(); |
| 103 | sol->setDeformableSolver(deformableBodySolver); |
| 104 | m_solver = sol; |
| 105 | |
| 106 | m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, deformableBodySolver); |
| 107 | // deformableBodySolver->setWorld(getDeformableDynamicsWorld()); |
| 108 | // m_dynamicsWorld->getSolverInfo().m_singleAxisDeformableThreshold = 0.f;//faster but lower quality |
| 109 | btVector3 gravity = btVector3(0, -50, 0); |
| 110 | m_dynamicsWorld->setGravity(gravity); |
| 111 | getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity; |
| 112 | getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25); |
| 113 | getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.Reset(); |
| 114 | |
| 115 | // getDeformableDynamicsWorld()->before_solver_callbacks.push_back(dynamics); |
| 116 | m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld); |
| 117 | |
| 118 | { |
| 119 | ///create a ground |
| 120 | btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.), btScalar(25.), btScalar(150.))); |
| 121 | |
| 122 | m_collisionShapes.push_back(groundShape); |
| 123 | |
| 124 | btTransform groundTransform; |
| 125 | groundTransform.setIdentity(); |
| 126 | groundTransform.setOrigin(btVector3(0, -32, 0)); |
| 127 | groundTransform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI * 0.)); |
| 128 | //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here: |
| 129 | btScalar mass(0.); |
| 130 | |
| 131 | //rigidbody is dynamic if and only if mass is non zero, otherwise static |
| 132 | bool isDynamic = (mass != 0.f); |
| 133 | |
| 134 | btVector3 localInertia(0, 0, 0); |
| 135 | if (isDynamic) |
| 136 | groundShape->calculateLocalInertia(mass, localInertia); |
| 137 | |
| 138 | //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects |
| 139 | btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform); |
| 140 | btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, groundShape, localInertia); |
| 141 | btRigidBody* body = new btRigidBody(rbInfo); |
| 142 | body->setFriction(1); |
| 143 | |
| 144 | //add the ground to the dynamics world |
| 145 | m_dynamicsWorld->addRigidBody(body); |
nothing calls this directly
no test coverage detected