2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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:
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.
16 #ifndef BT_SOFT_MULTIBODY_DYNAMICS_WORLD_H
17 #define BT_SOFT_MULTIBODY_DYNAMICS_WORLD_H
19 #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
20 #include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h"
21 #include "BulletSoftBody/btSoftBody.h"
23 typedef btAlignedObjectArray
<btSoftBody
*> btSoftBodyArray
;
25 class btSoftBodySolver
;
27 class btSoftMultiBodyDynamicsWorld
: public btMultiBodyDynamicsWorld
30 btSoftBodyArray m_softBodies
;
34 bool m_drawClusterTree
;
35 btSoftBodyWorldInfo m_sbi
;
36 ///Solver classes that encapsulate multiple soft bodies for solving
37 btSoftBodySolver
*m_softBodySolver
;
42 virtual void predictUnconstraintMotion(btScalar timeStep
);
44 virtual void internalSingleStepSimulation( btScalar timeStep
);
46 void solveSoftBodiesConstraints( btScalar timeStep
);
48 void serializeSoftBodies(btSerializer
* serializer
);
52 btSoftMultiBodyDynamicsWorld(btDispatcher
* dispatcher
,btBroadphaseInterface
* pairCache
,btMultiBodyConstraintSolver
* constraintSolver
, btCollisionConfiguration
* collisionConfiguration
, btSoftBodySolver
*softBodySolver
= 0 );
54 virtual ~btSoftMultiBodyDynamicsWorld();
56 virtual void debugDrawWorld();
58 void addSoftBody(btSoftBody
* body
,short int collisionFilterGroup
=btBroadphaseProxy::DefaultFilter
,short int collisionFilterMask
=btBroadphaseProxy::AllFilter
);
60 void removeSoftBody(btSoftBody
* body
);
62 ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btDiscreteDynamicsWorld::removeCollisionObject
63 virtual void removeCollisionObject(btCollisionObject
* collisionObject
);
65 int getDrawFlags() const { return(m_drawFlags
); }
66 void setDrawFlags(int f
) { m_drawFlags
=f
; }
68 btSoftBodyWorldInfo
& getWorldInfo()
72 const btSoftBodyWorldInfo
& getWorldInfo() const
77 virtual btDynamicsWorldType
getWorldType() const
79 return BT_SOFT_MULTIBODY_DYNAMICS_WORLD
;
82 btSoftBodyArray
& getSoftBodyArray()
87 const btSoftBodyArray
& getSoftBodyArray() const
93 virtual void rayTest(const btVector3
& rayFromWorld
, const btVector3
& rayToWorld
, RayResultCallback
& resultCallback
) const;
95 /// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest.
96 /// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape.
97 /// This allows more customization.
98 static void rayTestSingle(const btTransform
& rayFromTrans
,const btTransform
& rayToTrans
,
99 btCollisionObject
* collisionObject
,
100 const btCollisionShape
* collisionShape
,
101 const btTransform
& colObjWorldTransform
,
102 RayResultCallback
& resultCallback
);
104 virtual void serialize(btSerializer
* serializer
);
108 #endif //BT_SOFT_MULTIBODY_DYNAMICS_WORLD_H