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