MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / initPhysics

Method initPhysics

examples/ReducedDeformableDemo/ConservationTest.cpp:194–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192};
193
194void ConservationTest::initPhysics()
195{
196 m_guiHelper->setUpAxis(1);
197
198 ///collision configuration contains default setup for memory, collision setup
199 m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
200
201 ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
202 m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
203
204 m_broadphase = new btDbvtBroadphase();
205 btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver();
206 btVector3 gravity = btVector3(0, 0, 0);
207 reducedSoftBodySolver->setGravity(gravity);
208
209 btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver();
210 sol->setDeformableSolver(reducedSoftBodySolver);
211 m_solver = sol;
212
213 m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, reducedSoftBodySolver);
214 m_dynamicsWorld->setGravity(gravity);
215 m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
216
217 // create volumetric reduced deformable body
218 {
219 std::string file_path("../../../data/reduced_beam/");
220 std::string vtk_file("beam_mesh_origin.vtk");
221 btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedDeformableObject(
222 getDeformableDynamicsWorld()->getWorldInfo(),
223 file_path,
224 vtk_file,
225 num_modes,
226 false);
227
228 getDeformableDynamicsWorld()->addSoftBody(rsb);
229 rsb->getCollisionShape()->setMargin(0.1);
230
231 btTransform init_transform;
232 init_transform.setIdentity();
233 init_transform.setOrigin(btVector3(0, 4, 0));
234 // init_transform.setRotation(btQuaternion(btVector3(0, 1, 0), SIMD_PI / 2.0));
235 rsb->transformTo(init_transform);
236
237 rsb->setStiffnessScale(100);
238 rsb->setDamping(damping_alpha, damping_beta);
239
240 rsb->m_cfg.kKHR = 1; // collision hardness with kinematic objects
241 rsb->m_cfg.kCHR = 1; // collision hardness with rigid body
242 rsb->m_cfg.kDF = 0;
243 rsb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
244 rsb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN;
245 rsb->m_sleepingThreshold = 0;
246 btSoftBodyHelpers::generateBoundaryFaces(rsb);
247
248 // rsb->setVelocity(btVector3(0, -COLLIDING_VELOCITY, 0));
249 // rsb->setRigidVelocity(btVector3(0, 1, 0));
250 // rsb->setRigidAngularVelocity(btVector3(1, 0, 0));
251 }

Callers

nothing calls this directly

Calls 15

setStiffnessScaleMethod · 0.80
setUseProjectionMethod · 0.80
btVector3Class · 0.50
setUpAxisMethod · 0.45
setGravityMethod · 0.45
addSoftBodyMethod · 0.45
setMarginMethod · 0.45
getCollisionShapeMethod · 0.45
setIdentityMethod · 0.45
transformToMethod · 0.45
setDampingMethod · 0.45

Tested by

no test coverage detected