Bullet Collision Detection & Physics Library: btDeformableMultiBodyDynamicsWorld.cpp Source File

Bullet Collision Detection & Physics Library

btDeformableMultiBodyDynamicsWorld.cpp
Go to the documentation of this file.
1 /*
2 Written by Xuchen Han <xuchenhan2015@u.northwestern.edu>
3
4 Bullet Continuous Collision Detection and Physics Library
5 Copyright (c) 2019 Google Inc. http://bulletphysics.org
6 This software is provided 'as-is', without any express or implied warranty.
7 In no event will the authors be held liable for any damages arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it freely,
10 subject to the following restrictions:
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 /* ====== Overview of the Deformable Algorithm ====== */
17
18 /*
19 A single step of the deformable body simulation contains the following main components:
20 Call internalStepSimulation multiple times, to achieve 240Hz (4 steps of 60Hz).
21 1. Deformable maintaintenance of rest lengths and volume preservation. Forces only depend on position: Update velocity to a temporary state v_{n+1}^* = v_n + explicit_force * dt / mass, where explicit forces include gravity and elastic forces.
22 2. Detect discrete collisions between rigid and deformable bodies at position x_{n+1}^* = x_n + dt * v_{n+1}^*.
23
24 3a. Solve all constraints, including LCP. Contact, position correction due to numerical drift, friction, and anchors for deformable.
25 TODO: add option for positional drift correction (using vel_target += erp * pos_error/dt
26
27 3b. 5 Newton steps (multiple step). Conjugent Gradient solves linear system. Deformable Damping: Then velocities of deformable bodies v_{n+1} are solved in
28 M(v_{n+1} - v_{n+1}^*) = damping_force * dt / mass,
29 by a conjugate gradient solver, where the damping force is implicit and depends on v_{n+1}.
30 Make sure contact constraints are not violated in step b by performing velocity projections as in the paper by Baraff and Witkin https://www.cs.cmu.edu/~baraff/papers/sig98.pdf. Dynamic frictions are treated as a force and added to the rhs of the CG solve, whereas static frictions are treated as constraints similar to contact.
31 4. Position is updated via x_{n+1} = x_n + dt * v_{n+1}.
32
33
34 The algorithm also closely resembles the one in http://physbam.stanford.edu/~fedkiw/papers/stanford2008-03.pdf
35 */
36
37 #include <stdio.h>
38 #include "btDeformableMultiBodyDynamicsWorld.h"
39 #include "DeformableBodyInplaceSolverIslandCallback.h"
40 #include "btDeformableBodySolver.h"
41 #include "LinearMath/btQuickprof.h"
42 #include "btSoftBodyInternals.h"
43 btDeformableMultiBodyDynamicsWorld::btDeformableMultiBodyDynamicsWorld(btDispatcher* dispatcher, btBroadphaseInterface* pairCache, btDeformableMultiBodyConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration, btDeformableBodySolver* deformableBodySolver)
44 : btMultiBodyDynamicsWorld(dispatcher, pairCache, (btMultiBodyConstraintSolver*)constraintSolver, collisionConfiguration),
45 m_deformableBodySolver(deformableBodySolver), m_solverCallback(0)
46 {
47 m_drawFlags = fDrawFlags::Std;
48 m_drawNodeTree = true;
49 m_drawFaceTree = false;
50 m_drawClusterTree = false;
51 m_sbi.m_broadphase = pairCache;
52 m_sbi.m_dispatcher = dispatcher;
53 m_sbi.m_sparsesdf.Initialize();
54 m_sbi.m_sparsesdf.setDefaultVoxelsz(0.005);
55 m_sbi.m_sparsesdf.Reset();
56
57 m_sbi.air_density = (btScalar)1.2;
58 m_sbi.water_density = 0;
59 m_sbi.water_offset = 0;
60 m_sbi.water_normal = btVector3(0, 0, 0);
61 m_sbi.m_gravity.setValue(0, -10, 0);
62 m_internalTime = 0.0;
63 m_implicit = false;
64 m_lineSearch = false;
65 m_selfCollision = true;
66 m_solverDeformableBodyIslandCallback = new DeformableBodyInplaceSolverIslandCallback(constraintSolver, dispatcher);
67 }
68
69 void btDeformableMultiBodyDynamicsWorld::internalSingleStepSimulation(btScalar timeStep)
70 {
71 BT_PROFILE("internalSingleStepSimulation");
72 if (0 != m_internalPreTickCallback)
73 {
74 (*m_internalPreTickCallback)(this, timeStep);
75 }
76 reinitialize(timeStep);
77 // add gravity to velocity of rigid and multi bodys
78 applyRigidBodyGravity(timeStep);
79
81 predictUnconstraintMotion(timeStep);
82
84 btMultiBodyDynamicsWorld::performDiscreteCollisionDetection();
85
86 if (m_selfCollision)
87 {
88 softBodySelfCollision();
89 }
90
91 btMultiBodyDynamicsWorld::calculateSimulationIslands();
92
93 beforeSolverCallbacks(timeStep);
94
96 solveConstraints(timeStep);
97
98 afterSolverCallbacks(timeStep);
99
100 integrateTransforms(timeStep);
101
103 btMultiBodyDynamicsWorld::updateActions(timeStep);
104
105 updateActivationState(timeStep);
106 // End solver-wise simulation step
107 // ///////////////////////////////
108 }
109
110 void btDeformableMultiBodyDynamicsWorld::updateActivationState(btScalar timeStep)
111 {
112 for (int i = 0; i < m_softBodies.size(); i++)
113 {
114 btSoftBody* psb = m_softBodies[i];
115 psb->updateDeactivation(timeStep);
116 if (psb->wantsSleeping())
117 {
118 if (psb->getActivationState() == ACTIVE_TAG)
119 psb->setActivationState(WANTS_DEACTIVATION);
120 if (psb->getActivationState() == ISLAND_SLEEPING)
121 {
122 psb->setZeroVelocity();
123 }
124 }
125 else
126 {
127 if (psb->getActivationState() != DISABLE_DEACTIVATION)
128 psb->setActivationState(ACTIVE_TAG);
129 }
130 }
131 btMultiBodyDynamicsWorld::updateActivationState(timeStep);
132 }
133
134
135 void btDeformableMultiBodyDynamicsWorld::softBodySelfCollision()
136 {
137 m_deformableBodySolver->updateSoftBodies();
138 for (int i = 0; i < m_softBodies.size(); i++)
139 {
140 btSoftBody* psb = m_softBodies[i];
141 if (psb->isActive())
142 {
143 psb->defaultCollisionHandler(psb);
144 }
145 }
146 }
147
148 void btDeformableMultiBodyDynamicsWorld::positionCorrection(btScalar timeStep)
149 {
150 // correct the position of rigid bodies with temporary velocity generated from split impulse
151 btContactSolverInfo infoGlobal;
152 btVector3 zero(0,0,0);
153 for (int i = 0; i < m_nonStaticRigidBodies.size(); ++i)
154 {
155 btRigidBody* rb = m_nonStaticRigidBodies[i];
156 //correct the position/orientation based on push/turn recovery
157 btTransform newTransform;
158 btVector3 pushVelocity = rb->getPushVelocity();
159 btVector3 turnVelocity = rb->getTurnVelocity();
160 if (pushVelocity[0] != 0.f || pushVelocity[1] != 0 || pushVelocity[2] != 0 || turnVelocity[0] != 0.f || turnVelocity[1] != 0 || turnVelocity[2] != 0)
161 {
162 btTransformUtil::integrateTransform(rb->getWorldTransform(), pushVelocity, turnVelocity * infoGlobal.m_splitImpulseTurnErp, timeStep, newTransform);
163 rb->setWorldTransform(newTransform);
164 rb->setPushVelocity(zero);
165 rb->setTurnVelocity(zero);
166 }
167 }
168 }
169
170 void btDeformableMultiBodyDynamicsWorld::integrateTransforms(btScalar timeStep)
171 {
172 BT_PROFILE("integrateTransforms");
173 positionCorrection(timeStep);
174 btMultiBodyDynamicsWorld::integrateTransforms(timeStep);
175 for (int i = 0; i < m_softBodies.size(); ++i)
176 {
177 btSoftBody* psb = m_softBodies[i];
178 for (int j = 0; j < psb->m_nodes.size(); ++j)
179 {
180 btSoftBody::Node& node = psb->m_nodes[j];
181 btScalar maxDisplacement = psb->getWorldInfo()->m_maxDisplacement;
182 btScalar clampDeltaV = maxDisplacement / timeStep;
183 for (int c = 0; c < 3; c++)
184 {
185 if (node.m_v[c] > clampDeltaV)
186 {
187 node.m_v[c] = clampDeltaV;
188 }
189 if (node.m_v[c] < -clampDeltaV)
190 {
191 node.m_v[c] = -clampDeltaV;
192 }
193 }
194 node.m_x = node.m_x + timeStep * node.m_v;
195 node.m_v -= node.m_vsplit;
196 node.m_vsplit.setZero();
197 node.m_q = node.m_x;
198 node.m_vn = node.m_v;
199 }
200 // enforce anchor constraints
201 for (int j = 0; j < psb->m_deformableAnchors.size();++j)
202 {
203 btSoftBody::DeformableNodeRigidAnchor& a = psb->m_deformableAnchors[j];
204 btSoftBody::Node* n = a.m_node;
205 n->m_x = a.m_cti.m_colObj->getWorldTransform() * a.m_local;
206
207 // update multibody anchor info
208 if (a.m_cti.m_colObj->getInternalType() == btCollisionObject::CO_FEATHERSTONE_LINK)
209 {
210 btMultiBodyLinkCollider* multibodyLinkCol = (btMultiBodyLinkCollider*)btMultiBodyLinkCollider::upcast(a.m_cti.m_colObj);
211 if (multibodyLinkCol)
212 {
213 btVector3 nrm;
214 const btCollisionShape* shp = multibodyLinkCol->getCollisionShape();
215 const btTransform& wtr = multibodyLinkCol->getWorldTransform();
216 psb->m_worldInfo->m_sparsesdf.Evaluate(
217 wtr.invXform(n->m_x),
218 shp,
219 nrm,
220 0);
221 a.m_cti.m_normal = wtr.getBasis() * nrm;
222 btVector3 normal = a.m_cti.m_normal;
223 btVector3 t1 = generateUnitOrthogonalVector(normal);
224 btVector3 t2 = btCross(normal, t1);
225 btMultiBodyJacobianData jacobianData_normal, jacobianData_t1, jacobianData_t2;
226 findJacobian(multibodyLinkCol, jacobianData_normal, a.m_node->m_x, normal);
227 findJacobian(multibodyLinkCol, jacobianData_t1, a.m_node->m_x, t1);
228 findJacobian(multibodyLinkCol, jacobianData_t2, a.m_node->m_x, t2);
229
230 btScalar* J_n = &jacobianData_normal.m_jacobians[0];
231 btScalar* J_t1 = &jacobianData_t1.m_jacobians[0];
232 btScalar* J_t2 = &jacobianData_t2.m_jacobians[0];
233
234 btScalar* u_n = &jacobianData_normal.m_deltaVelocitiesUnitImpulse[0];
235 btScalar* u_t1 = &jacobianData_t1.m_deltaVelocitiesUnitImpulse[0];
236 btScalar* u_t2 = &jacobianData_t2.m_deltaVelocitiesUnitImpulse[0];
237
238 btMatrix3x3 rot(normal.getX(), normal.getY(), normal.getZ(),
239 t1.getX(), t1.getY(), t1.getZ(),
240 t2.getX(), t2.getY(), t2.getZ()); // world frame to local frame
241 const int ndof = multibodyLinkCol->m_multiBody->getNumDofs() + 6;
242 btMatrix3x3 local_impulse_matrix = (Diagonal(n->m_im) + OuterProduct(J_n, J_t1, J_t2, u_n, u_t1, u_t2, ndof)).inverse();
243 a.m_c0 = rot.transpose() * local_impulse_matrix * rot;
244 a.jacobianData_normal = jacobianData_normal;
245 a.jacobianData_t1 = jacobianData_t1;
246 a.jacobianData_t2 = jacobianData_t2;
247 a.t1 = t1;
248 a.t2 = t2;
249 }
250 }
251 }
252 psb->interpolateRenderMesh();
253 }
254 }
255
256 void btDeformableMultiBodyDynamicsWorld::solveConstraints(btScalar timeStep)
257 {
258 // save v_{n+1}^* velocity after explicit forces
259 m_deformableBodySolver->backupVelocity();
260
261 // set up constraints among multibodies and between multibodies and deformable bodies
262 setupConstraints();
263
264 // solve contact constraints
265 solveContactConstraints();
266
267 // set up the directions in which the velocity does not change in the momentum solve
268 m_deformableBodySolver->m_objective->m_projection.setProjection();
269
270 // for explicit scheme, m_backupVelocity = v_{n+1}^*
271 // for implicit scheme, m_backupVelocity = v_n
272 // Here, set dv = v_{n+1} - v_n for nodes in contact
273 m_deformableBodySolver->setupDeformableSolve(m_implicit);
274
275 // At this point, dv should be golden for nodes in contact
276 // proceed to solve deformable momentum equation
277 m_deformableBodySolver->solveDeformableConstraints(timeStep);
278 }
279
280 void btDeformableMultiBodyDynamicsWorld::setupConstraints()
281 {
282 // set up constraints between multibody and deformable bodies
283 m_deformableBodySolver->setConstraints();
284
285 // set up constraints among multibodies
286 {
287 sortConstraints();
288 // setup the solver callback
289 btMultiBodyConstraint** sortedMultiBodyConstraints = m_sortedMultiBodyConstraints.size() ? &m_sortedMultiBodyConstraints[0] : 0;
290 btTypedConstraint** constraintsPtr = getNumConstraints() ? &m_sortedConstraints[0] : 0;
291 m_solverDeformableBodyIslandCallback->setup(&m_solverInfo, constraintsPtr, m_sortedConstraints.size(), sortedMultiBodyConstraints, m_sortedMultiBodyConstraints.size(), getDebugDrawer());
292
293 // build islands
294 m_islandManager->buildIslands(getCollisionWorld()->getDispatcher(), getCollisionWorld());
295 }
296 }
297
298 void btDeformableMultiBodyDynamicsWorld::sortConstraints()
299 {
300 m_sortedConstraints.resize(m_constraints.size());
301 int i;
302 for (i = 0; i < getNumConstraints(); i++)
303 {
304 m_sortedConstraints[i] = m_constraints[i];
305 }
306 m_sortedConstraints.quickSort(btSortConstraintOnIslandPredicate2());
307
308 m_sortedMultiBodyConstraints.resize(m_multiBodyConstraints.size());
309 for (i = 0; i < m_multiBodyConstraints.size(); i++)
310 {
311 m_sortedMultiBodyConstraints[i] = m_multiBodyConstraints[i];
312 }
313 m_sortedMultiBodyConstraints.quickSort(btSortMultiBodyConstraintOnIslandPredicate());
314 }
315
316
317 void btDeformableMultiBodyDynamicsWorld::solveContactConstraints()
318 {
319 // process constraints on each island
320 m_islandManager->processIslands(getCollisionWorld()->getDispatcher(), getCollisionWorld(), m_solverDeformableBodyIslandCallback);
321
322 // process deferred
323 m_solverDeformableBodyIslandCallback->processConstraints();
324 m_constraintSolver->allSolved(m_solverInfo, m_debugDrawer);
325
326 // write joint feedback
327 {
328 for (int i = 0; i < this->m_multiBodies.size(); i++)
329 {
330 btMultiBody* bod = m_multiBodies[i];
331
332 bool isSleeping = false;
333
334 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
335 {
336 isSleeping = true;
337 }
338 for (int b = 0; b < bod->getNumLinks(); b++)
339 {
340 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
341 isSleeping = true;
342 }
343
344 if (!isSleeping)
345 {
346 //useless? they get resized in stepVelocities once again (AND DIFFERENTLY)
347 m_scratch_r.resize(bod->getNumLinks() + 1); //multidof? ("Y"s use it and it is used to store qdd)
348 m_scratch_v.resize(bod->getNumLinks() + 1);
349 m_scratch_m.resize(bod->getNumLinks() + 1);
350
351 if (bod->internalNeedsJointFeedback())
352 {
353 if (!bod->isUsingRK4Integration())
354 {
355 if (bod->internalNeedsJointFeedback())
356 {
357 bool isConstraintPass = true;
358 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(m_solverInfo.m_timeStep, m_scratch_r, m_scratch_v, m_scratch_m, isConstraintPass,
359 getSolverInfo().m_jointFeedbackInWorldSpace,
360 getSolverInfo().m_jointFeedbackInJointFrame);
361 }
362 }
363 }
364 }
365 }
366 }
367
368 for (int i = 0; i < this->m_multiBodies.size(); i++)
369 {
370 btMultiBody* bod = m_multiBodies[i];
371 bod->processDeltaVeeMultiDof2();
372 }
373 }
374
375 void btDeformableMultiBodyDynamicsWorld::addSoftBody(btSoftBody* body, int collisionFilterGroup, int collisionFilterMask)
376 {
377 m_softBodies.push_back(body);
378
379 // Set the soft body solver that will deal with this body
380 // to be the world's solver
381 body->setSoftBodySolver(m_deformableBodySolver);
382
383 btCollisionWorld::addCollisionObject(body,
384 collisionFilterGroup,
385 collisionFilterMask);
386 }
387
388 void btDeformableMultiBodyDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
389 {
390 BT_PROFILE("predictUnconstraintMotion");
391 btMultiBodyDynamicsWorld::predictUnconstraintMotion(timeStep);
392 m_deformableBodySolver->predictMotion(timeStep);
393 }
394
395 void btDeformableMultiBodyDynamicsWorld::reinitialize(btScalar timeStep)
396 {
397 m_internalTime += timeStep;
398 m_deformableBodySolver->setImplicit(m_implicit);
399 m_deformableBodySolver->setLineSearch(m_lineSearch);
400 m_deformableBodySolver->reinitialize(m_softBodies, timeStep);
401 btDispatcherInfo& dispatchInfo = btMultiBodyDynamicsWorld::getDispatchInfo();
402 dispatchInfo.m_timeStep = timeStep;
403 dispatchInfo.m_stepCount = 0;
404 dispatchInfo.m_debugDraw = btMultiBodyDynamicsWorld::getDebugDrawer();
405 btMultiBodyDynamicsWorld::getSolverInfo().m_timeStep = timeStep;
406 }
407
408
409 void btDeformableMultiBodyDynamicsWorld::debugDrawWorld()
410 {
411
412 btMultiBodyDynamicsWorld::debugDrawWorld();
413
414 for (int i = 0; i < getSoftBodyArray().size(); i++)
415 {
416 btSoftBody* psb = (btSoftBody*)getSoftBodyArray()[i];
417 {
418 btSoftBodyHelpers::DrawFrame(psb, getDebugDrawer());
419 btSoftBodyHelpers::Draw(psb, getDebugDrawer(), getDrawFlags());
420 }
421 }
422
423
424 }
425
426 void btDeformableMultiBodyDynamicsWorld::applyRigidBodyGravity(btScalar timeStep)
427 {
428 // Gravity is applied in stepSimulation and then cleared here and then applied here and then cleared here again
429 // so that 1) gravity is applied to velocity before constraint solve and 2) gravity is applied in each substep
430 // when there are multiple substeps
431 btMultiBodyDynamicsWorld::applyGravity();
432 // integrate rigid body gravity
433 for (int i = 0; i < m_nonStaticRigidBodies.size(); ++i)
434 {
435 btRigidBody* rb = m_nonStaticRigidBodies[i];
436 rb->integrateVelocities(timeStep);
437 }
438
439 // integrate multibody gravity
440 {
441 forwardKinematics();
442 clearMultiBodyConstraintForces();
443 {
444 for (int i = 0; i < this->m_multiBodies.size(); i++)
445 {
446 btMultiBody* bod = m_multiBodies[i];
447
448 bool isSleeping = false;
449
450 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
451 {
452 isSleeping = true;
453 }
454 for (int b = 0; b < bod->getNumLinks(); b++)
455 {
456 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
457 isSleeping = true;
458 }
459
460 if (!isSleeping)
461 {
462 m_scratch_r.resize(bod->getNumLinks() + 1);
463 m_scratch_v.resize(bod->getNumLinks() + 1);
464 m_scratch_m.resize(bod->getNumLinks() + 1);
465 bool isConstraintPass = false;
466 {
467 if (!bod->isUsingRK4Integration())
468 {
469 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(m_solverInfo.m_timeStep,
470 m_scratch_r, m_scratch_v, m_scratch_m,isConstraintPass,
471 getSolverInfo().m_jointFeedbackInWorldSpace,
472 getSolverInfo().m_jointFeedbackInJointFrame);
473 }
474 else
475 {
476 btAssert(" RK4Integration is not supported" );
477 }
478 }
479 }
480 }
481 }
482 }
483 clearGravity();
484 }
485
486 void btDeformableMultiBodyDynamicsWorld::clearGravity()
487 {
488 BT_PROFILE("btMultiBody clearGravity");
489 // clear rigid body gravity
490 for (int i = 0; i < m_nonStaticRigidBodies.size(); i++)
491 {
492 btRigidBody* body = m_nonStaticRigidBodies[i];
493 if (body->isActive())
494 {
495 body->clearGravity();
496 }
497 }
498 // clear multibody gravity
499 for (int i = 0; i < this->m_multiBodies.size(); i++)
500 {
501 btMultiBody* bod = m_multiBodies[i];
502
503 bool isSleeping = false;
504
505 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
506 {
507 isSleeping = true;
508 }
509 for (int b = 0; b < bod->getNumLinks(); b++)
510 {
511 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
512 isSleeping = true;
513 }
514
515 if (!isSleeping)
516 {
517 bod->addBaseForce(-m_gravity * bod->getBaseMass());
518
519 for (int j = 0; j < bod->getNumLinks(); ++j)
520 {
521 bod->addLinkForce(j, -m_gravity * bod->getLinkMass(j));
522 }
523 }
524 }
525 }
526
527 void btDeformableMultiBodyDynamicsWorld::beforeSolverCallbacks(btScalar timeStep)
528 {
529 if (0 != m_internalTickCallback)
530 {
531 (*m_internalTickCallback)(this, timeStep);
532 }
533
534 if (0 != m_solverCallback)
535 {
536 (*m_solverCallback)(m_internalTime, this);
537 }
538 }
539
540 void btDeformableMultiBodyDynamicsWorld::afterSolverCallbacks(btScalar timeStep)
541 {
542 if (0 != m_solverCallback)
543 {
544 (*m_solverCallback)(m_internalTime, this);
545 }
546 }
547
548 void btDeformableMultiBodyDynamicsWorld::addForce(btSoftBody* psb, btDeformableLagrangianForce* force)
549 {
550 btAlignedObjectArray<btDeformableLagrangianForce*>& forces = m_deformableBodySolver->m_objective->m_lf;
551 bool added = false;
552 for (int i = 0; i < forces.size(); ++i)
553 {
554 if (forces[i]->getForceType() == force->getForceType())
555 {
556 forces[i]->addSoftBody(psb);
557 added = true;
558 break;
559 }
560 }
561 if (!added)
562 {
563 force->addSoftBody(psb);
564 force->setIndices(m_deformableBodySolver->m_objective->getIndices());
565 forces.push_back(force);
566 }
567 }
568
569 void btDeformableMultiBodyDynamicsWorld::removeSoftBody(btSoftBody* body)
570 {
571 m_softBodies.remove(body);
572 btCollisionWorld::removeCollisionObject(body);
573 // force a reinitialize so that node indices get updated.
574 m_deformableBodySolver->reinitialize(m_softBodies, btScalar(-1));
575 }
576
577 void btDeformableMultiBodyDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject)
578 {
579 btSoftBody* body = btSoftBody::upcast(collisionObject);
580 if (body)
581 removeSoftBody(body);
582 else
583 btDiscreteDynamicsWorld::removeCollisionObject(collisionObject);
584 }
585
586
587 int btDeformableMultiBodyDynamicsWorld::stepSimulation(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep)
588 {
589 startProfiling(timeStep);
590
591 int numSimulationSubSteps = 0;
592
593 if (maxSubSteps)
594 {
595 //fixed timestep with interpolation
596 m_fixedTimeStep = fixedTimeStep;
597 m_localTime += timeStep;
598 if (m_localTime >= fixedTimeStep)
599 {
600 numSimulationSubSteps = int(m_localTime / fixedTimeStep);
601 m_localTime -= numSimulationSubSteps * fixedTimeStep;
602 }
603 }
604 else
605 {
606 //variable timestep
607 fixedTimeStep = timeStep;
608 m_localTime = m_latencyMotionStateInterpolation ? 0 : timeStep;
609 m_fixedTimeStep = 0;
610 if (btFuzzyZero(timeStep))
611 {
612 numSimulationSubSteps = 0;
613 maxSubSteps = 0;
614 }
615 else
616 {
617 numSimulationSubSteps = 1;
618 maxSubSteps = 1;
619 }
620 }
621
622 //process some debugging flags
623 if (getDebugDrawer())
624 {
625 btIDebugDraw* debugDrawer = getDebugDrawer();
626 gDisableDeactivation = (debugDrawer->getDebugMode() & btIDebugDraw::DBG_NoDeactivation) != 0;
627 }
628 if (numSimulationSubSteps)
629 {
630 //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
631 int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps) ? maxSubSteps : numSimulationSubSteps;
632
633 saveKinematicState(fixedTimeStep * clampedSimulationSteps);
634
635 for (int i = 0; i < clampedSimulationSteps; i++)
636 {
637 internalSingleStepSimulation(fixedTimeStep);
638 synchronizeMotionStates();
639 }
640 }
641 else
642 {
643 synchronizeMotionStates();
644 }
645
646 clearForces();
647
648 #ifndef BT_NO_PROFILE
649 CProfileManager::Increment_Frame_Counter();
650 #endif //BT_NO_PROFILE
651
652 return numSimulationSubSteps;
653 }
btCollisionWorld::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btCollisionWorld.h:96
btSoftBody::DeformableRigidContact::jacobianData_t2
btMultiBodyJacobianData jacobianData_t2
Definition: btSoftBody.h:349
btSoftBody::updateDeactivation
void updateDeactivation(btScalar timeStep)
Definition: btSoftBody.cpp:4237
btDiscreteDynamicsWorld::m_constraints
btAlignedObjectArray< btTypedConstraint * > m_constraints
Definition: btDiscreteDynamicsWorld.h:47
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:76
btDiscreteDynamicsWorld::m_localTime
btScalar m_localTime
Definition: btDiscreteDynamicsWorld.h:54
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:50
btDeformableBackwardEulerObjective::m_lf
btAlignedObjectArray< btDeformableLagrangianForce * > m_lf
Definition: btDeformableBackwardEulerObjective.h:35
btDeformableBodySolver::setupDeformableSolve
void setupDeformableSolve(bool implicit)
Definition: btDeformableBodySolver.cpp:314
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:60
btDeformableLagrangianForce::setIndices
virtual void setIndices(const btAlignedObjectArray< btSoftBody::Node * > *nodes)
Definition: btDeformableLagrangianForce.h:88
DISABLE_DEACTIVATION
#define DISABLE_DEACTIVATION
Definition: btCollisionObject.h:25
btDiscreteDynamicsWorld::m_nonStaticRigidBodies
btAlignedObjectArray< btRigidBody * > m_nonStaticRigidBodies
Definition: btDiscreteDynamicsWorld.h:49
btSoftBody::wantsSleeping
bool wantsSleeping()
Definition: btSoftBody.cpp:4262
btDynamicsWorld::m_internalTickCallback
btInternalTickCallback m_internalTickCallback
Definition: btDynamicsWorld.h:45
btDeformableBackwardEulerObjective::getIndices
const btAlignedObjectArray< btSoftBody::Node * > * getIndices() const
Definition: btDeformableBackwardEulerObjective.h:120
btMultiBodyDynamicsWorld::calculateSimulationIslands
virtual void calculateSimulationIslands()
Definition: btMultiBodyDynamicsWorld.cpp:42
btMultiBodyLinkCollider::upcast
static btMultiBodyLinkCollider * upcast(btCollisionObject *colObj)
Definition: btMultiBodyLinkCollider.h:61
btDeformableBodySolver::updateSoftBodies
virtual void updateSoftBodies()
Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes.
Definition: btDeformableBodySolver.cpp:463
btIDebugDraw::DBG_NoDeactivation
@ DBG_NoDeactivation
Definition: btIDebugDraw.h:59
btDeformableMultiBodyDynamicsWorld::m_selfCollision
bool m_selfCollision
Definition: btDeformableMultiBodyDynamicsWorld.h:52
btCollisionWorld::getDebugDrawer
virtual btIDebugDraw * getDebugDrawer()
Definition: btCollisionWorld.h:155
btDeformableMultiBodyDynamicsWorld::solveConstraints
void solveConstraints(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:256
btDeformableMultiBodyDynamicsWorld::getDrawFlags
int getDrawFlags() const
Definition: btDeformableMultiBodyDynamicsWorld.h:140
btMultiBody::processDeltaVeeMultiDof2
void processDeltaVeeMultiDof2()
Definition: btMultiBody.h:407
btContactSolverInfo
Definition: btContactSolverInfo.h:73
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btDynamicsWorld::m_internalPreTickCallback
btInternalTickCallback m_internalPreTickCallback
Definition: btDynamicsWorld.h:46
btDiscreteDynamicsWorld::m_sortedConstraints
btAlignedObjectArray< btTypedConstraint * > m_sortedConstraints
Definition: btDiscreteDynamicsWorld.h:40
btDeformableLagrangianForce::getForceType
virtual btDeformableLagrangianForceType getForceType()=0
btMultiBody::getNumLinks
int getNumLinks() const
Definition: btMultiBody.h:166
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btSoftBody::defaultCollisionHandler
void defaultCollisionHandler(const btCollisionObjectWrapper *pcoWrap)
Definition: btSoftBody.cpp:3613
gDisableDeactivation
bool gDisableDeactivation
Definition: btRigidBody.cpp:26
ACTIVE_TAG
#define ACTIVE_TAG
Definition: btCollisionObject.h:22
btMultiBody::internalNeedsJointFeedback
bool internalNeedsJointFeedback() const
Definition: btMultiBody.h:598
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
btDiscreteDynamicsWorld::m_islandManager
btSimulationIslandManager * m_islandManager
Definition: btDiscreteDynamicsWorld.h:45
btMultiBodyJacobianData::m_jacobians
btAlignedObjectArray< btScalar > m_jacobians
Definition: btMultiBodyConstraint.h:30
btDeformableMultiBodyDynamicsWorld::m_implicit
bool m_implicit
Definition: btDeformableMultiBodyDynamicsWorld.h:50
btMultiBodyDynamicsWorld::clearMultiBodyConstraintForces
virtual void clearMultiBodyConstraintForces()
Definition: btMultiBodyDynamicsWorld.cpp:780
btAlignedObjectArray::quickSort
void quickSort(const L &CompareFunc)
Definition: btAlignedObjectArray.h:341
btSimulationIslandManager::buildIslands
void buildIslands(btDispatcher *dispatcher, btCollisionWorld *colWorld)
Definition: btSimulationIslandManager.cpp:196
btSparseSdf::Evaluate
btScalar Evaluate(const btVector3 &x, const btCollisionShape *shape, btVector3 &normal, btScalar margin)
Definition: btSparseSDF.h:196
btMultiBodyConstraint
Definition: btMultiBodyConstraint.h:42
btSoftBodyWorldInfo::m_dispatcher
btDispatcher * m_dispatcher
Definition: btSoftBody.h:53
OuterProduct
static btMatrix3x3 OuterProduct(const btScalar *v1, const btScalar *v2, const btScalar *v3, const btScalar *u1, const btScalar *u2, const btScalar *u3, int ndof)
Definition: btSoftBodyInternals.h:355
btSoftBodyWorldInfo::water_normal
btVector3 water_normal
Definition: btSoftBody.h:51
btContactSolverInfoData::m_splitImpulseTurnErp
btScalar m_splitImpulseTurnErp
Definition: btContactSolverInfo.h:56
btDeformableBackwardEulerObjective::m_projection
btDeformableContactProjection m_projection
Definition: btDeformableBackwardEulerObjective.h:38
btSoftBody::upcast
static const btSoftBody * upcast(const btCollisionObject *colObj)
Definition: btSoftBody.h:1092
btDeformableMultiBodyDynamicsWorld::positionCorrection
void positionCorrection(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:148
btIDebugDraw::getDebugMode
virtual int getDebugMode() const =0
btRigidBody::integrateVelocities
void integrateVelocities(btScalar step)
Definition: btRigidBody.cpp:368
btDynamicsWorld::getSolverInfo
btContactSolverInfo & getSolverInfo()
Definition: btDynamicsWorld.h:140
btDiscreteDynamicsWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise ca...
Definition: btDiscreteDynamicsWorld.cpp:522
btDeformableMultiBodyDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btDeformableMultiBodyDynamicsWorld.cpp:409
btCollisionObject::getActivationState
int getActivationState() const
Definition: btCollisionObject.h:277
btDispatcherInfo::m_debugDraw
class btIDebugDraw * m_debugDraw
Definition: btDispatcher.h:58
btCross
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
Definition: btVector3.h:918
btSimulationIslandManager::processIslands
void processIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, IslandCallback *callback)
Definition: btSimulationIslandManager.cpp:349
btVector3::setZero
void setZero()
Definition: btVector3.h:671
inverse
btQuaternion inverse(const btQuaternion &q)
Return the inverse of a quaternion.
Definition: btQuaternion.h:909
btDeformableMultiBodyDynamicsWorld::softBodySelfCollision
void softBodySelfCollision()
Definition: btDeformableMultiBodyDynamicsWorld.cpp:135
btDeformableBodySolver::reinitialize
void reinitialize(const btAlignedObjectArray< btSoftBody * > &softBodies, btScalar dt)
Definition: btDeformableBodySolver.cpp:206
btSoftBody::Node::m_vsplit
btVector3 m_vsplit
Definition: btSoftBody.h:260
btSoftBodyHelpers::DrawFrame
static void DrawFrame(btSoftBody *psb, btIDebugDraw *idraw)
Definition: btSoftBodyHelpers.cpp:666
Diagonal
static btMatrix3x3 Diagonal(btScalar x)
Definition: btSoftBodyInternals.h:329
btDeformableMultiBodyDynamicsWorld::m_drawClusterTree
bool m_drawClusterTree
Definition: btDeformableMultiBodyDynamicsWorld.h:46
btMultiBody::isUsingRK4Integration
bool isUsingRK4Integration() const
Definition: btMultiBody.h:584
btSortConstraintOnIslandPredicate2
Definition: btMultiBodyInplaceSolverIslandCallback.h:32
DeformableBodyInplaceSolverIslandCallback::processConstraints
virtual void processConstraints(int islandId=-1)
Definition: DeformableBodyInplaceSolverIslandCallback.h:22
btDeformableBodySolver::setLineSearch
void setLineSearch(bool lineSearch)
Definition: btDeformableBodySolver.cpp:482
btSoftBody::Node
Definition: btSoftBody.h:256
btCollisionWorld::performDiscreteCollisionDetection
virtual void performDiscreteCollisionDetection()
Definition: btCollisionWorld.cpp:221
btDeformableMultiBodyDynamicsWorld::setupConstraints
void setupConstraints()
Definition: btDeformableMultiBodyDynamicsWorld.cpp:280
btDeformableMultiBodyDynamicsWorld::reinitialize
void reinitialize(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:395
btMultiBodyJacobianData
Definition: btMultiBodyConstraint.h:29
btMultiBodyDynamicsWorld::clearForces
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
Definition: btMultiBodyDynamicsWorld.cpp:816
btDeformableContactProjection::setProjection
virtual void setProjection()
Definition: btDeformableContactProjection.cpp:244
btDeformableMultiBodyDynamicsWorld::m_softBodies
btSoftBodyArray m_softBodies
Definition: btDeformableMultiBodyDynamicsWorld.h:42
btVector3::getX
const btScalar & getX() const
Return the x value.
Definition: btVector3.h:561
btRigidBody::clearGravity
void clearGravity()
Definition: btRigidBody.cpp:209
btMultiBodyDynamicsWorld::m_scratch_r
btAlignedObjectArray< btScalar > m_scratch_r
Definition: btMultiBodyDynamicsWorld.h:45
MultiBodyInplaceSolverIslandCallback::setup
virtual void setup(btContactSolverInfo *solverInfo, btTypedConstraint **sortedConstraints, int numConstraints, btMultiBodyConstraint **sortedMultiBodyConstraints, int numMultiBodyConstraints, btIDebugDraw *debugDrawer)
Definition: btMultiBodyInplaceSolverIslandCallback.h:104
btDeformableMultiBodyDynamicsWorld::addSoftBody
virtual void addSoftBody(btSoftBody *body, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:375
btCollisionObject::getWorldTransform
btTransform & getWorldTransform()
Definition: btCollisionObject.h:367
btSoftBody::DeformableNodeRigidAnchor
Definition: btSoftBody.h:361
btSoftBody::Node::m_q
btVector3 m_q
Definition: btSoftBody.h:258
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:28
ISLAND_SLEEPING
#define ISLAND_SLEEPING
Definition: btCollisionObject.h:23
btAssert
#define btAssert(x)
Definition: btScalar.h:153
btSoftBody::sCti::m_colObj
const btCollisionObject * m_colObj
Definition: btSoftBody.h:220
btDeformableMultiBodyDynamicsWorld::beforeSolverCallbacks
void beforeSolverCallbacks(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:527
btSoftBody::m_worldInfo
btSoftBodyWorldInfo * m_worldInfo
Definition: btSoftBody.h:775
btMultiBody::addLinkForce
void addLinkForce(int i, const btVector3 &f)
Definition: btMultiBody.cpp:664
btSoftBody::Node::m_x
btVector3 m_x
Definition: btSoftBody.h:257
btDiscreteDynamicsWorld::getCollisionWorld
btCollisionWorld * getCollisionWorld()
Definition: btDiscreteDynamicsWorld.h:135
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
btSoftBody::DeformableRigidContact::jacobianData_normal
btMultiBodyJacobianData jacobianData_normal
Definition: btSoftBody.h:347
btMultiBodyDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btMultiBodyDynamicsWorld.cpp:670
btSoftBody::setZeroVelocity
void setZeroVelocity()
Definition: btSoftBody.cpp:4254
btSoftBodyWorldInfo::m_gravity
btVector3 m_gravity
Definition: btSoftBody.h:54
btDeformableBodySolver::setConstraints
void setConstraints()
Definition: btDeformableBodySolver.cpp:231
btMultiBodyDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:568
btDeformableLagrangianForce::addSoftBody
virtual void addSoftBody(btSoftBody *psb)
Definition: btDeformableLagrangianForce.h:83
DeformableBodyInplaceSolverIslandCallback.h
btMultiBodyDynamicsWorld::m_multiBodies
btAlignedObjectArray< btMultiBody * > m_multiBodies
Definition: btMultiBodyDynamicsWorld.h:34
btSoftBody::getWorldInfo
btSoftBodyWorldInfo * getWorldInfo()
Definition: btSoftBody.h:837
btMultiBody::getNumDofs
int getNumDofs() const
Definition: btMultiBody.h:167
btAlignedObjectArray::resize
void resize(int newsize, const T &fillData=T())
Definition: btAlignedObjectArray.h:203
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:108
btDeformableMultiBodyDynamicsWorld::stepSimulation
virtual int stepSimulation(btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))
if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
Definition: btDeformableMultiBodyDynamicsWorld.cpp:587
btContactSolverInfoData::m_timeStep
btScalar m_timeStep
Definition: btContactSolverInfo.h:42
btSortMultiBodyConstraintOnIslandPredicate
Definition: btMultiBodyInplaceSolverIslandCallback.h:54
btDispatcherInfo::m_stepCount
int m_stepCount
Definition: btDispatcher.h:54
btMultiBodyConstraintSolver
Definition: btMultiBodyConstraintSolver.h:30
btDiscreteDynamicsWorld::m_gravity
btVector3 m_gravity
Definition: btDiscreteDynamicsWorld.h:51
btDeformableMultiBodyDynamicsWorld::internalSingleStepSimulation
virtual void internalSingleStepSimulation(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:69
btDeformableBodySolver::backupVelocity
void backupVelocity()
Definition: btDeformableBodySolver.cpp:301
btDeformableLagrangianForce
Definition: btDeformableLagrangianForce.h:38
btDeformableMultiBodyDynamicsWorld.h
btSoftBody::DeformableNodeRigidContact::m_node
Node * m_node
Definition: btSoftBody.h:357
btSoftBody::setSoftBodySolver
void setSoftBodySolver(btSoftBodySolver *softBodySolver)
Definition: btSoftBody.h:1067
btDiscreteDynamicsWorld::saveKinematicState
virtual void saveKinematicState(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:249
btMultiBody::addBaseForce
void addBaseForce(const btVector3 &f)
Definition: btMultiBody.h:327
btCollisionObject::setWorldTransform
void setWorldTransform(const btTransform &worldTrans)
Definition: btCollisionObject.h:377
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:48
btMultiBody::getBaseMass
btScalar getBaseMass() const
Definition: btMultiBody.h:169
btConstraintSolver::allSolved
virtual void allSolved(const btContactSolverInfo &, class btIDebugDraw *)
Definition: btConstraintSolver.h:51
btMatrix3x3::transpose
btMatrix3x3 transpose() const
Return the transpose of the matrix.
Definition: btMatrix3x3.h:1033
findJacobian
static void findJacobian(const btMultiBodyLinkCollider *multibodyLinkCol, btMultiBodyJacobianData &jacobianData, const btVector3 &contact_point, const btVector3 &dir)
btSoftBody implementation by Nathanael Presson
Definition: btSoftBodyInternals.h:34
btDeformableMultiBodyDynamicsWorld::sortConstraints
void sortConstraints()
Definition: btDeformableMultiBodyDynamicsWorld.cpp:298
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btMultiBodyLinkCollider
Definition: btMultiBodyLinkCollider.h:33
btSparseSdf::Initialize
void Initialize(int hashsize=2383, int clampCells=256 *1024)
Definition: btSparseSDF.h:100
btDiscreteDynamicsWorld::m_fixedTimeStep
btScalar m_fixedTimeStep
Definition: btDiscreteDynamicsWorld.h:55
btMultiBodyDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:36
btSoftBodyWorldInfo::m_maxDisplacement
btScalar m_maxDisplacement
Definition: btSoftBody.h:50
btSparseSdf::Reset
void Reset()
Definition: btSparseSDF.h:116
btDeformableMultiBodyDynamicsWorld::addForce
void addForce(btSoftBody *psb, btDeformableLagrangianForce *force)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:548
generateUnitOrthogonalVector
static btVector3 generateUnitOrthogonalVector(const btVector3 &u)
Definition: btSoftBodyInternals.h:47
btMultiBody::getLink
const btMultibodyLink & getLink(int index) const
Definition: btMultiBody.h:114
btDeformableMultiBodyDynamicsWorld::m_deformableBodySolver
btDeformableBodySolver * m_deformableBodySolver
Solver classes that encapsulate multiple deformable bodies for solving.
Definition: btDeformableMultiBodyDynamicsWorld.h:41
btRigidBody::getTurnVelocity
btVector3 getTurnVelocity()
Definition: btRigidBody.h:355
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btDeformableMultiBodyDynamicsWorld::m_lineSearch
bool m_lineSearch
Definition: btDeformableMultiBodyDynamicsWorld.h:51
btMultiBodyDynamicsWorld::m_sortedMultiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_sortedMultiBodyConstraints
Definition: btMultiBodyDynamicsWorld.h:36
btSoftBody::sCti::m_normal
btVector3 m_normal
Definition: btSoftBody.h:221
btDeformableMultiBodyDynamicsWorld::afterSolverCallbacks
void afterSolverCallbacks(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:540
btMultiBody
Definition: btMultiBody.h:51
btSoftBody::DeformableRigidContact::m_c0
btMatrix3x3 m_c0
Definition: btSoftBody.h:340
btSoftBodyWorldInfo::water_offset
btScalar water_offset
Definition: btSoftBody.h:49
btMultiBodyDynamicsWorld::forwardKinematics
void forwardKinematics()
Definition: btMultiBodyDynamicsWorld.cpp:208
btSoftBody::Node::m_vn
btVector3 m_vn
Definition: btSoftBody.h:261
btDeformableMultiBodyDynamicsWorld::m_solverCallback
btSolverCallback m_solverCallback
Definition: btDeformableMultiBodyDynamicsWorld.h:56
btDeformableMultiBodyDynamicsWorld::m_sbi
btSoftBodyWorldInfo m_sbi
Definition: btDeformableMultiBodyDynamicsWorld.h:47
btTransform::invXform
btVector3 invXform(const btVector3 &inVec) const
Definition: btTransform.h:215
btMultiBodyDynamicsWorld::m_scratch_v
btAlignedObjectArray< btVector3 > m_scratch_v
Definition: btMultiBodyDynamicsWorld.h:46
btDiscreteDynamicsWorld::updateActions
void updateActions(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:584
btFuzzyZero
bool btFuzzyZero(btScalar x)
Definition: btScalar.h:572
btMultibodyLink::m_collider
class btMultiBodyLinkCollider * m_collider
Definition: btMultiBodyLink.h:132
btVector3::getZ
const btScalar & getZ() const
Return the z value.
Definition: btVector3.h:565
btDeformableMultiBodyDynamicsWorld::clearGravity
void clearGravity()
Definition: btDeformableMultiBodyDynamicsWorld.cpp:486
btCollisionObject::CO_FEATHERSTONE_LINK
@ CO_FEATHERSTONE_LINK
Definition: btCollisionObject.h:153
btDynamicsWorld::m_solverInfo
btContactSolverInfo m_solverInfo
Definition: btDynamicsWorld.h:49
btDeformableMultiBodyDynamicsWorld::m_drawFlags
int m_drawFlags
Definition: btDeformableMultiBodyDynamicsWorld.h:43
btMultiBodyDynamicsWorld::applyGravity
virtual void applyGravity()
apply gravity, call this once per timestep
Definition: btMultiBodyDynamicsWorld.cpp:746
btDispatcherInfo
Definition: btDispatcher.h:31
btAlignedObjectArray< btDeformableLagrangianForce * >
btVector3::getY
const btScalar & getY() const
Return the y value.
Definition: btVector3.h:563
btMultiBody::getLinkMass
btScalar getLinkMass(int i) const
Definition: btMultiBody.cpp:362
btDeformableMultiBodyDynamicsWorld::solveContactConstraints
void solveContactConstraints()
Definition: btDeformableMultiBodyDynamicsWorld.cpp:317
btMultiBody::computeAccelerationsArticulatedBodyAlgorithmMultiDof
void computeAccelerationsArticulatedBodyAlgorithmMultiDof(btScalar dt, btAlignedObjectArray< btScalar > &scratch_r, btAlignedObjectArray< btVector3 > &scratch_v, btAlignedObjectArray< btMatrix3x3 > &scratch_m, bool isConstraintPass, bool jointFeedbackInWorldSpace, bool jointFeedbackInJointFrame)
Definition: btMultiBody.cpp:744
btDiscreteDynamicsWorld::m_latencyMotionStateInterpolation
bool m_latencyMotionStateInterpolation
Definition: btDiscreteDynamicsWorld.h:67
btMultiBodyDynamicsWorld::m_scratch_m
btAlignedObjectArray< btMatrix3x3 > m_scratch_m
Definition: btMultiBodyDynamicsWorld.h:47
btCollisionWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
Definition: btCollisionWorld.cpp:239
btSoftBody::DeformableNodeRigidAnchor::m_local
btVector3 m_local
Definition: btSoftBody.h:363
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:73
btDeformableBodySolver::predictMotion
virtual void predictMotion(btScalar solverdt)
Predict motion of soft bodies into next timestep.
Definition: btDeformableBodySolver.cpp:370
btDeformableBodySolver.h
btSparseSdf::setDefaultVoxelsz
void setDefaultVoxelsz(btScalar sz)
Definition: btSparseSDF.h:111
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
Definition: btBroadphaseInterface.h:50
btDeformableMultiBodyConstraintSolver
Definition: btDeformableMultiBodyConstraintSolver.h:34
btDeformableMultiBodyDynamicsWorld::removeSoftBody
void removeSoftBody(btSoftBody *body)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:569
btDiscreteDynamicsWorld::synchronizeMotionStates
virtual void synchronizeMotionStates()
Definition: btDiscreteDynamicsWorld.cpp:356
btDeformableMultiBodyDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:170
btQuickprof.h
btRigidBody::setPushVelocity
void setPushVelocity(const btVector3 &v)
Definition: btRigidBody.h:360
btCollisionObject::getInternalType
int getInternalType() const
reserved for Bullet internal usage
Definition: btCollisionObject.h:362
btRigidBody::getPushVelocity
btVector3 getPushVelocity()
Definition: btRigidBody.h:350
btDiscreteDynamicsWorld::m_constraintSolver
btConstraintSolver * m_constraintSolver
Definition: btDiscreteDynamicsWorld.h:43
btMultiBodyDynamicsWorld::m_multiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_multiBodyConstraints
Definition: btMultiBodyDynamicsWorld.h:35
btCollisionObject::isActive
bool isActive() const
Definition: btCollisionObject.h:294
btSoftBody::DeformableRigidContact::m_cti
sCti m_cti
Definition: btSoftBody.h:339
btDeformableMultiBodyDynamicsWorld::removeCollisionObject
void removeCollisionObject(btCollisionObject *collisionObject)
removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise ca...
Definition: btDeformableMultiBodyDynamicsWorld.cpp:577
btDiscreteDynamicsWorld::getNumConstraints
virtual int getNumConstraints() const
Definition: btDiscreteDynamicsWorld.cpp:1358
btDeformableMultiBodyDynamicsWorld::applyRigidBodyGravity
void applyRigidBodyGravity(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:426
WANTS_DEACTIVATION
#define WANTS_DEACTIVATION
Definition: btCollisionObject.h:24
btMultiBodyLinkCollider::m_multiBody
btMultiBody * m_multiBody
Definition: btMultiBodyLinkCollider.h:36
btSoftBodyHelpers::Draw
static void Draw(btSoftBody *psb, btIDebugDraw *idraw, int drawflags=fDrawFlags::Std)
Definition: btSoftBodyHelpers.cpp:171
btSoftBodyInternals.h
btDeformableMultiBodyDynamicsWorld::m_drawNodeTree
bool m_drawNodeTree
Definition: btDeformableMultiBodyDynamicsWorld.h:44
btSoftBody::m_deformableAnchors
btAlignedObjectArray< DeformableNodeRigidAnchor > m_deformableAnchors
Definition: btSoftBody.h:786
btCollisionWorld::getDispatcher
btDispatcher * getDispatcher()
Definition: btCollisionWorld.h:132
btSoftBody::DeformableRigidContact::jacobianData_t1
btMultiBodyJacobianData jacobianData_t1
Definition: btSoftBody.h:348
btSoftBodyWorldInfo::air_density
btScalar air_density
Definition: btSoftBody.h:47
btDeformableBodySolver
Definition: btDeformableBodySolver.h:31
fDrawFlags::Std
@ Std
Definition: btSoftBodyHelpers.h:45
btDeformableMultiBodyDynamicsWorld::getSoftBodyArray
btSoftBodyArray & getSoftBodyArray()
Definition: btDeformableMultiBodyDynamicsWorld.h:106
btDeformableMultiBodyDynamicsWorld::m_solverDeformableBodyIslandCallback
DeformableBodyInplaceSolverIslandCallback * m_solverDeformableBodyIslandCallback
Definition: btDeformableMultiBodyDynamicsWorld.h:53
btMultiBodyDynamicsWorld
The btMultiBodyDynamicsWorld adds Featherstone multi body dynamics to Bullet This implementation is s...
Definition: btMultiBodyDynamicsWorld.h:32
btSoftBody::DeformableRigidContact::t2
btVector3 t2
Definition: btSoftBody.h:351
btRigidBody::setTurnVelocity
void setTurnVelocity(const btVector3 &v)
Definition: btRigidBody.h:365
btCollisionWorld::addCollisionObject
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btCollisionWorld.cpp:124
btMultiBodyDynamicsWorld::updateActivationState
virtual void updateActivationState(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:125
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:257
btSoftBodyWorldInfo::m_broadphase
btBroadphaseInterface * m_broadphase
Definition: btSoftBody.h:52
DeformableBodyInplaceSolverIslandCallback
Definition: DeformableBodyInplaceSolverIslandCallback.h:12
btSoftBody::interpolateRenderMesh
void interpolateRenderMesh()
Definition: btSoftBody.cpp:3373
btSoftBodyWorldInfo::m_sparsesdf
btSparseSdf< 3 > m_sparsesdf
Definition: btSoftBody.h:55
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size,...
Definition: btCollisionConfiguration.h:27
btDeformableBodySolver::m_objective
btDeformableBackwardEulerObjective * m_objective
Definition: btDeformableBodySolver.h:50
btAlignedObjectArray::remove
void remove(const T &key)
Definition: btAlignedObjectArray.h:480
btSoftBody::Node::m_im
btScalar m_im
Definition: btSoftBody.h:264
btSoftBody::Node::m_v
btVector3 m_v
Definition: btSoftBody.h:259
btDeformableBodySolver::solveDeformableConstraints
virtual void solveDeformableConstraints(btScalar solverdt)
Definition: btDeformableBodySolver.cpp:37
btDeformableMultiBodyDynamicsWorld::btDeformableMultiBodyDynamicsWorld
btDeformableMultiBodyDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btDeformableMultiBodyConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration, btDeformableBodySolver *deformableBodySolver=0)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:43
btDeformableBodySolver::setImplicit
void setImplicit(bool implicit)
Definition: btDeformableBodySolver.cpp:476
btDeformableMultiBodyDynamicsWorld::m_internalTime
btScalar m_internalTime
Definition: btDeformableMultiBodyDynamicsWorld.h:48
btDispatcherInfo::m_timeStep
btScalar m_timeStep
Definition: btDispatcher.h:53
BT_PROFILE
#define BT_PROFILE(name)
Definition: btQuickprof.h:198
btMultiBody::getBaseCollider
const btMultiBodyLinkCollider * getBaseCollider() const
Definition: btMultiBody.h:128
btSoftBodyWorldInfo::water_density
btScalar water_density
Definition: btSoftBody.h:48
btCollisionWorld::getDispatchInfo
btDispatcherInfo & getDispatchInfo()
Definition: btCollisionWorld.h:490
btMultiBodyJacobianData::m_deltaVelocitiesUnitImpulse
btAlignedObjectArray< btScalar > m_deltaVelocitiesUnitImpulse
Definition: btMultiBodyConstraint.h:31
btSoftBody::DeformableRigidContact::t1
btVector3 t1
Definition: btSoftBody.h:350
btDeformableMultiBodyDynamicsWorld::updateActivationState
void updateActivationState(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:110
btDeformableMultiBodyDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btDeformableMultiBodyDynamicsWorld.cpp:388
btCollisionObject::setActivationState
void setActivationState(int newState) const
Definition: btCollisionObject.cpp:61
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:142
btTransformUtil::integrateTransform
static void integrateTransform(const btTransform &curTrans, const btVector3 &linvel, const btVector3 &angvel, btScalar timeStep, btTransform &predictedTransform)
Definition: btTransformUtil.h:32
btSoftBody::m_nodes
tNodeArray m_nodes
Definition: btSoftBody.h:777
btDiscreteDynamicsWorld::startProfiling
void startProfiling(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1100
btCollisionObject::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btCollisionObject.h:226
btDeformableMultiBodyDynamicsWorld::m_drawFaceTree
bool m_drawFaceTree
Definition: btDeformableMultiBodyDynamicsWorld.h:45