Bullet Collision Detection & Physics Library
btDeformableMultiBodyDynamicsWorld.h
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 #ifndef BT_DEFORMABLE_MULTIBODY_DYNAMICS_WORLD_H
17 #define BT_DEFORMABLE_MULTIBODY_DYNAMICS_WORLD_H
18 
22 #include "btDeformableBodySolver.h"
24 #include "btSoftBodyHelpers.h"
26 #include <functional>
28 
34 
36 
38 {
50  bool m_implicit;
54 
57 
58 protected:
59  virtual void internalSingleStepSimulation(btScalar timeStep);
60 
61  virtual void integrateTransforms(btScalar timeStep);
62 
63  void positionCorrection(btScalar timeStep);
64 
65  void solveConstraints(btScalar timeStep);
66 
67  void updateActivationState(btScalar timeStep);
68 
69  void clearGravity();
70 
71 public:
72  btDeformableMultiBodyDynamicsWorld(btDispatcher* dispatcher, btBroadphaseInterface* pairCache, btDeformableMultiBodyConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration, btDeformableBodySolver* deformableBodySolver = 0);
73 
74  virtual int stepSimulation(btScalar timeStep, int maxSubSteps = 1, btScalar fixedTimeStep = btScalar(1.) / btScalar(60.));
75 
76  virtual void debugDrawWorld();
77 
79  {
80  m_solverCallback = cb;
81  }
82 
84  {
85  }
86 
88  {
89  return (btMultiBodyDynamicsWorld*)(this);
90  }
91 
93  {
94  return (const btMultiBodyDynamicsWorld*)(this);
95  }
96 
98  {
100  }
101 
102  virtual void predictUnconstraintMotion(btScalar timeStep);
103 
104  virtual void addSoftBody(btSoftBody* body, int collisionFilterGroup = btBroadphaseProxy::DefaultFilter, int collisionFilterMask = btBroadphaseProxy::AllFilter);
105 
107  {
108  return m_softBodies;
109  }
110 
112  {
113  return m_softBodies;
114  }
115 
117  {
118  return m_sbi;
119  }
120 
122  {
123  return m_sbi;
124  }
125 
126  void reinitialize(btScalar timeStep);
127 
128  void applyRigidBodyGravity(btScalar timeStep);
129 
130  void beforeSolverCallbacks(btScalar timeStep);
131 
132  void afterSolverCallbacks(btScalar timeStep);
133 
135 
136  void removeSoftBody(btSoftBody* body);
137 
138  void removeCollisionObject(btCollisionObject* collisionObject);
139 
140  int getDrawFlags() const { return (m_drawFlags); }
141  void setDrawFlags(int f) { m_drawFlags = f; }
142 
143  void setupConstraints();
144 
146 
148 
149  void sortConstraints();
150 
151  void softBodySelfCollision();
152 
153  void setImplicit(bool implicit)
154  {
155  m_implicit = implicit;
156  }
157 
158  void setLineSearch(bool lineSearch)
159  {
160  m_lineSearch = lineSearch;
161  }
162 
163 };
164 
165 #endif //BT_DEFORMABLE_MULTIBODY_DYNAMICS_WORLD_H
btAlignedObjectArray< btSoftBody * > btSoftBodyArray
btDynamicsWorldType
@ BT_DEFORMABLE_MULTIBODY_DYNAMICS_WORLD
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size,...
btCollisionObject can be used to manage collision detection objects.
void(* btSolverCallback)(btScalar time, btDeformableMultiBodyDynamicsWorld *world)
btDeformableMultiBodyDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btDeformableMultiBodyConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration, btDeformableBodySolver *deformableBodySolver=0)
void removeCollisionObject(btCollisionObject *collisionObject)
removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise ca...
virtual void addSoftBody(btSoftBody *body, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
virtual void predictUnconstraintMotion(btScalar timeStep)
virtual const btMultiBodyDynamicsWorld * getMultiBodyDynamicsWorld() const
void addForce(btSoftBody *psb, btDeformableLagrangianForce *force)
virtual btMultiBodyDynamicsWorld * getMultiBodyDynamicsWorld()
virtual btDynamicsWorldType getWorldType() const
virtual void internalSingleStepSimulation(btScalar timeStep)
const btSoftBodyWorldInfo & getWorldInfo() const
virtual int stepSimulation(btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))
if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
DeformableBodyInplaceSolverIslandCallback * m_solverDeformableBodyIslandCallback
btDeformableBodySolver * m_deformableBodySolver
Solver classes that encapsulate multiple deformable bodies for solving.
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
The btMultiBodyDynamicsWorld adds Featherstone multi body dynamics to Bullet This implementation is s...
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:73