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