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

Bullet Collision Detection & Physics Library

btSoftRigidDynamicsWorld.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
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 #include "btSoftRigidDynamicsWorld.h"
17 #include "LinearMath/btQuickprof.h"
18
19 //softbody & helpers
20 #include "btSoftBody.h"
21 #include "btSoftBodyHelpers.h"
22 #include "btSoftBodySolvers.h"
23 #include "btDefaultSoftBodySolver.h"
24 #include "LinearMath/btSerializer.h"
25
26 btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(
27 btDispatcher* dispatcher,
28 btBroadphaseInterface* pairCache,
29 btConstraintSolver* constraintSolver,
30 btCollisionConfiguration* collisionConfiguration,
31 btSoftBodySolver* softBodySolver) : btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration),
32 m_softBodySolver(softBodySolver),
33 m_ownsSolver(false)
34 {
35 if (!m_softBodySolver)
36 {
37 void* ptr = btAlignedAlloc(sizeof(btDefaultSoftBodySolver), 16);
38 m_softBodySolver = new (ptr) btDefaultSoftBodySolver();
39 m_ownsSolver = true;
40 }
41
42 m_drawFlags = fDrawFlags::Std;
43 m_drawNodeTree = true;
44 m_drawFaceTree = false;
45 m_drawClusterTree = false;
46 m_sbi.m_broadphase = pairCache;
47 m_sbi.m_dispatcher = dispatcher;
48 m_sbi.m_sparsesdf.Initialize();
49 m_sbi.m_sparsesdf.Reset();
50
51 m_sbi.air_density = (btScalar)1.2;
52 m_sbi.water_density = 0;
53 m_sbi.water_offset = 0;
54 m_sbi.water_normal = btVector3(0, 0, 0);
55 m_sbi.m_gravity.setValue(0, -10, 0);
56
57 m_sbi.m_sparsesdf.Initialize();
58 }
59
60 btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld()
61 {
62 if (m_ownsSolver)
63 {
64 m_softBodySolver->~btSoftBodySolver();
65 btAlignedFree(m_softBodySolver);
66 }
67 }
68
69 void btSoftRigidDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
70 {
71 btDiscreteDynamicsWorld::predictUnconstraintMotion(timeStep);
72 {
73 BT_PROFILE("predictUnconstraintMotionSoftBody");
74 m_softBodySolver->predictMotion(float(timeStep));
75 }
76 }
77
78 void btSoftRigidDynamicsWorld::internalSingleStepSimulation(btScalar timeStep)
79 {
80 // Let the solver grab the soft bodies and if necessary optimize for it
81 m_softBodySolver->optimize(getSoftBodyArray());
82
83 if (!m_softBodySolver->checkInitialized())
84 {
85 btAssert("Solver initialization failed\n");
86 }
87
88 btDiscreteDynamicsWorld::internalSingleStepSimulation(timeStep);
89
91 solveSoftBodiesConstraints(timeStep);
92
93 //self collisions
94 for (int i = 0; i < m_softBodies.size(); i++)
95 {
96 btSoftBody* psb = (btSoftBody*)m_softBodies[i];
97 psb->defaultCollisionHandler(psb);
98 }
99
101 m_softBodySolver->updateSoftBodies();
102
103 // End solver-wise simulation step
104 // ///////////////////////////////
105 }
106
107 void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints(btScalar timeStep)
108 {
109 BT_PROFILE("solveSoftConstraints");
110
111 if (m_softBodies.size())
112 {
113 btSoftBody::solveClusters(m_softBodies);
114 }
115
116 // Solve constraints solver-wise
117 m_softBodySolver->solveConstraints(timeStep * m_softBodySolver->getTimeScale());
118 }
119
120 void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body, int collisionFilterGroup, int collisionFilterMask)
121 {
122 m_softBodies.push_back(body);
123
124 // Set the soft body solver that will deal with this body
125 // to be the world's solver
126 body->setSoftBodySolver(m_softBodySolver);
127
128 btCollisionWorld::addCollisionObject(body,
129 collisionFilterGroup,
130 collisionFilterMask);
131 }
132
133 void btSoftRigidDynamicsWorld::removeSoftBody(btSoftBody* body)
134 {
135 m_softBodies.remove(body);
136
137 btCollisionWorld::removeCollisionObject(body);
138 }
139
140 void btSoftRigidDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject)
141 {
142 btSoftBody* body = btSoftBody::upcast(collisionObject);
143 if (body)
144 removeSoftBody(body);
145 else
146 btDiscreteDynamicsWorld::removeCollisionObject(collisionObject);
147 }
148
149 void btSoftRigidDynamicsWorld::debugDrawWorld()
150 {
151 btDiscreteDynamicsWorld::debugDrawWorld();
152
153 if (getDebugDrawer())
154 {
155 int i;
156 for (i = 0; i < this->m_softBodies.size(); i++)
157 {
158 btSoftBody* psb = (btSoftBody*)this->m_softBodies[i];
159 if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
160 {
161 btSoftBodyHelpers::DrawFrame(psb, m_debugDrawer);
162 btSoftBodyHelpers::Draw(psb, m_debugDrawer, m_drawFlags);
163 }
164
165 if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
166 {
167 if (m_drawNodeTree) btSoftBodyHelpers::DrawNodeTree(psb, m_debugDrawer);
168 if (m_drawFaceTree) btSoftBodyHelpers::DrawFaceTree(psb, m_debugDrawer);
169 if (m_drawClusterTree) btSoftBodyHelpers::DrawClusterTree(psb, m_debugDrawer);
170 }
171 }
172 }
173 }
174
175 struct btSoftSingleRayCallback : public btBroadphaseRayCallback
176 {
177 btVector3 m_rayFromWorld;
178 btVector3 m_rayToWorld;
179 btTransform m_rayFromTrans;
180 btTransform m_rayToTrans;
181 btVector3 m_hitNormal;
182
183 const btSoftRigidDynamicsWorld* m_world;
184 btCollisionWorld::RayResultCallback& m_resultCallback;
185
186 btSoftSingleRayCallback(const btVector3& rayFromWorld, const btVector3& rayToWorld, const btSoftRigidDynamicsWorld* world, btCollisionWorld::RayResultCallback& resultCallback)
187 : m_rayFromWorld(rayFromWorld),
188 m_rayToWorld(rayToWorld),
189 m_world(world),
190 m_resultCallback(resultCallback)
191 {
192 m_rayFromTrans.setIdentity();
193 m_rayFromTrans.setOrigin(m_rayFromWorld);
194 m_rayToTrans.setIdentity();
195 m_rayToTrans.setOrigin(m_rayToWorld);
196
197 btVector3 rayDir = (rayToWorld - rayFromWorld);
198
199 rayDir.normalize();
201 m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[0];
202 m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[1];
203 m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[2];
204 m_signs[0] = m_rayDirectionInverse[0] < 0.0;
205 m_signs[1] = m_rayDirectionInverse[1] < 0.0;
206 m_signs[2] = m_rayDirectionInverse[2] < 0.0;
207
208 m_lambda_max = rayDir.dot(m_rayToWorld - m_rayFromWorld);
209 }
210
211 virtual bool process(const btBroadphaseProxy* proxy)
212 {
214 if (m_resultCallback.m_closestHitFraction == btScalar(0.f))
215 return false;
216
217 btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject;
218
219 //only perform raycast if filterMask matches
220 if (m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
221 {
222 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
223 //btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
224 #if 0
225 #ifdef RECALCULATE_AABB
226 btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
227 collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
228 #else
229 //getBroadphase()->getAabb(collisionObject->getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax);
230 const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin;
231 const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax;
232 #endif
233 #endif
234 //btScalar hitLambda = m_resultCallback.m_closestHitFraction;
235 //culling already done by broadphase
236 //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal))
237 {
238 m_world->rayTestSingle(m_rayFromTrans, m_rayToTrans,
239 collisionObject,
240 collisionObject->getCollisionShape(),
241 collisionObject->getWorldTransform(),
242 m_resultCallback);
243 }
244 }
245 return true;
246 }
247 };
248
249 void btSoftRigidDynamicsWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const
250 {
251 BT_PROFILE("rayTest");
254 btSoftSingleRayCallback rayCB(rayFromWorld, rayToWorld, this, resultCallback);
255
256 #ifndef USE_BRUTEFORCE_RAYBROADPHASE
257 m_broadphasePairCache->rayTest(rayFromWorld, rayToWorld, rayCB);
258 #else
259 for (int i = 0; i < this->getNumCollisionObjects(); i++)
260 {
261 rayCB.process(m_collisionObjects[i]->getBroadphaseHandle());
262 }
263 #endif //USE_BRUTEFORCE_RAYBROADPHASE
264 }
265
266 void btSoftRigidDynamicsWorld::rayTestSingle(const btTransform& rayFromTrans, const btTransform& rayToTrans,
267 btCollisionObject* collisionObject,
268 const btCollisionShape* collisionShape,
269 const btTransform& colObjWorldTransform,
270 RayResultCallback& resultCallback)
271 {
272 if (collisionShape->isSoftBody())
273 {
274 btSoftBody* softBody = btSoftBody::upcast(collisionObject);
275 if (softBody)
276 {
277 btSoftBody::sRayCast softResult;
278 if (softBody->rayTest(rayFromTrans.getOrigin(), rayToTrans.getOrigin(), softResult))
279 {
280 if (softResult.fraction <= resultCallback.m_closestHitFraction)
281 {
282 btCollisionWorld::LocalShapeInfo shapeInfo;
283 shapeInfo.m_shapePart = 0;
284 shapeInfo.m_triangleIndex = softResult.index;
285 // get the normal
286 btVector3 rayDir = rayToTrans.getOrigin() - rayFromTrans.getOrigin();
287 btVector3 normal = -rayDir;
288 normal.normalize();
289
290 if (softResult.feature == btSoftBody::eFeature::Face)
291 {
292 normal = softBody->m_faces[softResult.index].m_normal;
293 if (normal.dot(rayDir) > 0)
294 {
295 // normal always point toward origin of the ray
296 normal = -normal;
297 }
298 }
299
300 btCollisionWorld::LocalRayResult rayResult(collisionObject,
301 &shapeInfo,
302 normal,
303 softResult.fraction);
304 bool normalInWorldSpace = true;
305 resultCallback.addSingleResult(rayResult, normalInWorldSpace);
306 }
307 }
308 }
309 }
310 else
311 {
312 btCollisionWorld::rayTestSingle(rayFromTrans, rayToTrans, collisionObject, collisionShape, colObjWorldTransform, resultCallback);
313 }
314 }
315
316 void btSoftRigidDynamicsWorld::serializeSoftBodies(btSerializer* serializer)
317 {
318 int i;
319 //serialize all collision objects
320 for (i = 0; i < m_collisionObjects.size(); i++)
321 {
322 btCollisionObject* colObj = m_collisionObjects[i];
323 if (colObj->getInternalType() & btCollisionObject::CO_SOFT_BODY)
324 {
325 int len = colObj->calculateSerializeBufferSize();
326 btChunk* chunk = serializer->allocate(len, 1);
327 const char* structType = colObj->serialize(chunk->m_oldPtr, serializer);
328 serializer->finalizeChunk(chunk, structType, BT_SOFTBODY_CODE, colObj);
329 }
330 }
331 }
332
333 void btSoftRigidDynamicsWorld::serialize(btSerializer* serializer)
334 {
335 serializer->startSerialization();
336
337 serializeDynamicsWorldInfo(serializer);
338
339 serializeSoftBodies(serializer);
340
341 serializeRigidBodies(serializer);
342
343 serializeCollisionObjects(serializer);
344
345 serializer->finishSerialization();
346 }
btTransform::setOrigin
void setOrigin(const btVector3 &origin)
Set the translational element.
Definition: btTransform.h:146
btCollisionObject::CO_SOFT_BODY
Definition: btCollisionObject.h:148
btDiscreteDynamicsWorld::internalSingleStepSimulation
virtual void internalSingleStepSimulation(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:452
btSerializer::finishSerialization
virtual void finishSerialization()=0
btDiscreteDynamicsWorld::serializeDynamicsWorldInfo
void serializeDynamicsWorldInfo(btSerializer *serializer)
Definition: btDiscreteDynamicsWorld.cpp:1397
btSoftRigidDynamicsWorld::getSoftBodyArray
btSoftBodyArray & getSoftBodyArray()
Definition: btSoftRigidDynamicsWorld.h:78
btBroadphaseRayCallback::m_lambda_max
btScalar m_lambda_max
Definition: btBroadphaseInterface.h:36
btSoftSingleRayCallback::m_rayToWorld
btVector3 m_rayToWorld
Definition: btSoftMultiBodyDynamicsWorld.cpp:178
btCollisionWorld::serializeCollisionObjects
void serializeCollisionObjects(btSerializer *serializer)
Definition: btCollisionWorld.cpp:1553
btIDebugDraw::DBG_DrawAabb
Definition: btIDebugDraw.h:56
btSoftBody::sRayCast::feature
eFeature::_ feature
soft body
Definition: btSoftBody.h:193
btSoftSingleRayCallback::m_rayFromWorld
btVector3 m_rayFromWorld
Definition: btSoftMultiBodyDynamicsWorld.cpp:177
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:264
btSoftBody::sRayCast::index
int index
feature type
Definition: btSoftBody.h:194
btChunk
Definition: btSerializer.h:47
btSoftBodySolver::checkInitialized
virtual bool checkInitialized()=0
Ensure that this solver is initialized.
btSoftBodySolvers.h
btCollisionObject::serialize
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btCollisionObject.cpp:80
btSoftSingleRayCallback::m_world
const btSoftRigidDynamicsWorld * m_world
Definition: btSoftRigidDynamicsWorld.cpp:183
btSoftRigidDynamicsWorld::serialize
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see B...
Definition: btSoftRigidDynamicsWorld.cpp:333
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btSoftRigidDynamicsWorld.h
btSoftBodyWorldInfo::water_offset
btScalar water_offset
Definition: btSoftBody.h:47
btSoftBody::defaultCollisionHandler
void defaultCollisionHandler(const btCollisionObjectWrapper *pcoWrap)
Definition: btSoftBody.cpp:3218
btSoftRigidDynamicsWorld::serializeSoftBodies
void serializeSoftBodies(btSerializer *serializer)
Definition: btSoftRigidDynamicsWorld.cpp:316
btCollisionWorld::addCollisionObject
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btCollisionWorld.cpp:123
btSoftRigidDynamicsWorld::removeSoftBody
void removeSoftBody(btSoftBody *body)
Definition: btSoftRigidDynamicsWorld.cpp:133
btBroadphaseProxy::m_aabbMax
btVector3 m_aabbMax
Definition: btBroadphaseProxy.h:109
btSerializer::startSerialization
virtual void startSerialization()=0
btDiscreteDynamicsWorld
btDiscreteDynamicsWorld provides discrete rigid body simulation those classes replace the obsolete Cc...
Definition: btDiscreteDynamicsWorld.h:36
btCollisionWorld::LocalShapeInfo::m_triangleIndex
int m_triangleIndex
Definition: btCollisionWorld.h:169
btTransform::setIdentity
void setIdentity()
Set this transformation to the identity.
Definition: btTransform.h:166
btAssert
#define btAssert(x)
Definition: btScalar.h:133
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Definition: btCollisionConfiguration.h:26
btSoftBodyWorldInfo::m_dispatcher
btDispatcher * m_dispatcher
Definition: btSoftBody.h:51
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:26
btSoftMultiBodyDynamicsWorld::rayTestSingle
static void rayTestSingle(const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, RayResultCallback &resultCallback)
rayTestSingle performs a raycast call and calls the resultCallback.
Definition: btSoftMultiBodyDynamicsWorld.cpp:266
btSoftBody::sRayCast::fraction
btScalar fraction
feature index
Definition: btSoftBody.h:195
BT_SOFTBODY_CODE
#define BT_SOFTBODY_CODE
Definition: btSerializer.h:110
btCollisionWorld::RayResultCallback
RayResultCallback is used to report new raycast results.
Definition: btCollisionWorld.h:195
btDefaultSoftBodySolver.h
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
btSoftBodyWorldInfo::water_normal
btVector3 water_normal
Definition: btSoftBody.h:49
btSoftRigidDynamicsWorld::m_drawFlags
int m_drawFlags
Definition: btSoftRigidDynamicsWorld.h:29
btSoftBodyHelpers::DrawFaceTree
static void DrawFaceTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:469
btCollisionWorld::RayResultCallback::m_closestHitFraction
btScalar m_closestHitFraction
Definition: btCollisionWorld.h:197
btSoftBody::rayTest
bool rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, sRayCast &results)
Ray casting using rayFrom and rayTo in worldspace, (not direction!)
Definition: btSoftBody.cpp:1719
btCollisionShape::getAabb
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t...
btSerializer
Definition: btSerializer.h:65
btVector3::normalize
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition: btVector3.h:303
btSoftSingleRayCallback::m_resultCallback
btCollisionWorld::RayResultCallback & m_resultCallback
Definition: btSoftMultiBodyDynamicsWorld.cpp:184
btCollisionWorld::getNumCollisionObjects
int getNumCollisionObjects() const
Definition: btCollisionWorld.h:427
btSoftBodyHelpers::Draw
static void Draw(btSoftBody *psb, btIDebugDraw *idraw, int drawflags=fDrawFlags::Std)
Definition: btSoftBodyHelpers.cpp:166
btSoftRigidDynamicsWorld
Definition: btSoftRigidDynamicsWorld.h:26
btSoftBodyWorldInfo::m_sparsesdf
btSparseSdf< 3 > m_sparsesdf
Definition: btSoftBody.h:53
btSoftBody::solveClusters
static void solveClusters(const btAlignedObjectArray< btSoftBody *> &bodies)
Definition: btSoftBody.cpp:1981
btSoftBody::sRayCast
Definition: btSoftBody.h:190
btCollisionWorld::RayResultCallback::addSingleResult
virtual btScalar addSingleResult(LocalRayResult &rayResult, bool normalInWorldSpace)=0
btCollisionObject::getWorldTransform
btTransform & getWorldTransform()
Definition: btCollisionObject.h:365
btSoftBody.h
btIDebugDraw::DBG_DrawWireframe
Definition: btIDebugDraw.h:55
btDefaultSoftBodySolver
Definition: btDefaultSoftBodySolver.h:23
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:113
btCollisionObject::getBroadphaseHandle
btBroadphaseProxy * getBroadphaseHandle()
Definition: btCollisionObject.h:381
btSoftBodySolver::predictMotion
virtual void predictMotion(float solverdt)=0
Predict motion of soft bodies into next timestep.
btSoftBodySolver::solveConstraints
virtual void solveConstraints(float solverdt)=0
Solve constraints for a set of soft bodies.
btSoftRigidDynamicsWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise ca...
Definition: btSoftRigidDynamicsWorld.cpp:140
btCollisionWorld::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btCollisionWorld.h:96
btSoftRigidDynamicsWorld::m_drawFaceTree
bool m_drawFaceTree
Definition: btSoftRigidDynamicsWorld.h:31
btCollisionWorld::getDebugDrawer
virtual btIDebugDraw * getDebugDrawer()
Definition: btCollisionWorld.h:155
btSoftSingleRayCallback::m_world
const btSoftMultiBodyDynamicsWorld * m_world
Definition: btSoftMultiBodyDynamicsWorld.cpp:183
btDiscreteDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btDiscreteDynamicsWorld.cpp:269
btSoftBody::upcast
static const btSoftBody * upcast(const btCollisionObject *colObj)
Definition: btSoftBody.h:962
btSoftBodySolver::~btSoftBodySolver
virtual ~btSoftBodySolver()
Definition: btSoftBodySolvers.h:55
btCollisionWorld::RayResultCallback::needsCollision
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Definition: btCollisionWorld.h:222
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:229
btSoftRigidDynamicsWorld::m_ownsSolver
bool m_ownsSolver
Definition: btSoftRigidDynamicsWorld.h:36
btSoftSingleRayCallback::m_rayFromTrans
btTransform m_rayFromTrans
Definition: btSoftMultiBodyDynamicsWorld.cpp:179
btSoftBodySolver::optimize
virtual void optimize(btAlignedObjectArray< btSoftBody *> &softBodies, bool forceUpdate=false)=0
Optimize soft bodies in this solver.
btDiscreteDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1083
btSoftRigidDynamicsWorld::m_drawClusterTree
bool m_drawClusterTree
Definition: btSoftRigidDynamicsWorld.h:32
btSoftRigidDynamicsWorld::internalSingleStepSimulation
virtual void internalSingleStepSimulation(btScalar timeStep)
Definition: btSoftRigidDynamicsWorld.cpp:78
btBroadphaseRayCallback
Definition: btBroadphaseInterface.h:31
btAlignedFree
#define btAlignedFree(ptr)
Definition: btAlignedAllocator.h:47
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:48
btBroadphaseProxy::m_clientObject
void * m_clientObject
Definition: btBroadphaseProxy.h:102
btSoftRigidDynamicsWorld::m_drawNodeTree
bool m_drawNodeTree
Definition: btSoftRigidDynamicsWorld.h:30
btCollisionWorld::rayTestSingle
static void rayTestSingle(const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, RayResultCallback &resultCallback)
rayTestSingle performs a raycast call and calls the resultCallback.
Definition: btCollisionWorld.cpp:276
btSoftSingleRayCallback::m_hitNormal
btVector3 m_hitNormal
Definition: btSoftMultiBodyDynamicsWorld.cpp:181
btCollisionWorld::LocalShapeInfo
LocalShapeInfo gives extra information for complex shapes Currently, only btTriangleMeshShape is avai...
Definition: btCollisionWorld.h:166
btCollisionWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
Definition: btCollisionWorld.cpp:238
btSoftSingleRayCallback
Definition: btSoftMultiBodyDynamicsWorld.cpp:175
btCollisionObject::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btCollisionObject.h:661
btCollisionWorld::LocalShapeInfo::m_shapePart
int m_shapePart
Definition: btCollisionWorld.h:168
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
Definition: btBroadphaseInterface.h:49
btSoftSingleRayCallback::btSoftSingleRayCallback
btSoftSingleRayCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const btSoftRigidDynamicsWorld *world, btCollisionWorld::RayResultCallback &resultCallback)
Definition: btSoftRigidDynamicsWorld.cpp:186
btBroadphaseProxy
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
Definition: btBroadphaseProxy.h:84
btSoftRigidDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btSoftRigidDynamicsWorld.cpp:69
btSoftBodyHelpers::DrawNodeTree
static void DrawNodeTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:460
btSoftBodySolver
Definition: btSoftBodySolvers.h:28
fDrawFlags::Std
Definition: btSoftBodyHelpers.h:44
btSoftRigidDynamicsWorld::m_softBodySolver
btSoftBodySolver * m_softBodySolver
Solver classes that encapsulate multiple soft bodies for solving.
Definition: btSoftRigidDynamicsWorld.h:35
btSoftBodyHelpers::DrawClusterTree
static void DrawClusterTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:478
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
btSoftBodySolver::updateSoftBodies
virtual void updateSoftBodies()=0
Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes...
btSoftRigidDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btSoftRigidDynamicsWorld.cpp:149
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:149
BT_PROFILE
#define BT_PROFILE(name)
Definition: btQuickprof.h:198
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
btSoftRigidDynamicsWorld::solveSoftBodiesConstraints
void solveSoftBodiesConstraints(btScalar timeStep)
Definition: btSoftRigidDynamicsWorld.cpp:107
btSerializer::finalizeChunk
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
btBroadphaseProxy::m_aabbMin
btVector3 m_aabbMin
Definition: btBroadphaseProxy.h:108
btSoftSingleRayCallback::process
virtual bool process(const btBroadphaseProxy *proxy)
Definition: btSoftRigidDynamicsWorld.cpp:211
btSoftRigidDynamicsWorld::addSoftBody
void addSoftBody(btSoftBody *body, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btSoftRigidDynamicsWorld.cpp:120
btAlignedObjectArray::remove
void remove(const T &key)
Definition: btAlignedObjectArray.h:487
btBroadphaseRayCallback::m_signs
unsigned int m_signs[3]
Definition: btBroadphaseInterface.h:35
btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld
virtual ~btSoftRigidDynamicsWorld()
Definition: btSoftRigidDynamicsWorld.cpp:60
btQuickprof.h
btCollisionShape::isSoftBody
bool isSoftBody() const
Definition: btCollisionShape.h:86
btCollisionObject::getInternalType
int getInternalType() const
reserved for Bullet internal usage
Definition: btCollisionObject.h:360
btIDebugDraw::getDebugMode
virtual int getDebugMode() const =0
btCollisionWorld::m_collisionObjects
btAlignedObjectArray< btCollisionObject * > m_collisionObjects
Definition: btCollisionWorld.h:88
btSoftBody::setSoftBodySolver
void setSoftBodySolver(btSoftBodySolver *softBodySolver)
Definition: btSoftBody.h:937
btBroadphaseRayCallback::m_rayDirectionInverse
btVector3 m_rayDirectionInverse
added some cached data to accelerate ray-AABB tests
Definition: btBroadphaseInterface.h:34
btSoftBodySolver::getTimeScale
float getTimeScale()
Return the timescale that the simulation is using.
Definition: btSoftBodySolvers.h:113
btSoftBodyWorldInfo::water_density
btScalar water_density
Definition: btSoftBody.h:46
btCollisionWorld::m_broadphasePairCache
btBroadphaseInterface * m_broadphasePairCache
Definition: btCollisionWorld.h:94
btAlignedAlloc
#define btAlignedAlloc(size, alignment)
Definition: btAlignedAllocator.h:46
btSoftRigidDynamicsWorld::rayTest
virtual void rayTest(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, RayResultCallback &resultCallback) const
rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback This ...
Definition: btSoftRigidDynamicsWorld.cpp:249
btSoftBodyHelpers.h
btSoftBodyWorldInfo::m_broadphase
btBroadphaseInterface * m_broadphase
Definition: btSoftBody.h:50
btSoftBodyWorldInfo::air_density
btScalar air_density
Definition: btSoftBody.h:45
btDiscreteDynamicsWorld::serializeRigidBodies
void serializeRigidBodies(btSerializer *serializer)
Definition: btDiscreteDynamicsWorld.cpp:1371
btSoftBodyWorldInfo::m_gravity
btVector3 m_gravity
Definition: btSoftBody.h:52
btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld
btSoftRigidDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration, btSoftBodySolver *softBodySolver=0)
Definition: btSoftRigidDynamicsWorld.cpp:26
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:70
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:76
btSoftRigidDynamicsWorld::m_softBodies
btSoftBodyArray m_softBodies
Definition: btSoftRigidDynamicsWorld.h:28
btSoftBody::eFeature::Face
Definition: btSoftBody.h:141
btChunk::m_oldPtr
void * m_oldPtr
Definition: btSerializer.h:52
btSoftSingleRayCallback::m_rayToTrans
btTransform m_rayToTrans
Definition: btSoftMultiBodyDynamicsWorld.cpp:180
btSerializer::allocate
virtual btChunk * allocate(size_t size, int numElements)=0
btBroadphaseInterface::rayTest
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btBroadphaseRayCallback &rayCallback, const btVector3 &aabbMin=btVector3(0, 0, 0), const btVector3 &aabbMax=btVector3(0, 0, 0))=0
btCollisionWorld::LocalRayResult
Definition: btCollisionWorld.h:175
btSoftRigidDynamicsWorld::rayTestSingle
static void rayTestSingle(const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, RayResultCallback &resultCallback)
rayTestSingle performs a raycast call and calls the resultCallback.
Definition: btSoftRigidDynamicsWorld.cpp:266
btSoftBodyHelpers::DrawFrame
static void DrawFrame(btSoftBody *psb, btIDebugDraw *idraw)
Definition: btSoftBodyHelpers.cpp:661
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
btCollisionObject::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btCollisionObject.h:224
btSoftRigidDynamicsWorld::m_sbi
btSoftBodyWorldInfo m_sbi
Definition: btSoftRigidDynamicsWorld.h:33
btSparseSdf::Reset
void Reset()
Definition: btSparseSDF.h:93
btSparseSdf::Initialize
void Initialize(int hashsize=2383, int clampCells=256 *1024)
Definition: btSparseSDF.h:84
btSerializer.h
btSoftBody::m_faces
tFaceArray m_faces
Definition: btSoftBody.h:693
btConstraintSolver
Definition: btConstraintSolver.h:40