2017-08-01 12:30:58 +00:00
/*
Bullet Continuous Collision Detection and Physics Library
Copyright ( c ) 2003 - 2006 Erwin Coumans http : //continuousphysics.com/Bullet/
This software is provided ' as - is ' , without any express or implied warranty .
In no event will the authors be held liable for any damages arising from the use of this software .
Permission is granted to anyone to use this software for any purpose ,
including commercial applications , and to alter it and redistribute it freely ,
subject to the following restrictions :
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 .
2. Altered source versions must be plainly marked as such , and must not be misrepresented as being the original software .
3. This notice may not be removed or altered from any source distribution .
*/
# ifndef BT_SOFT_MULTIBODY_DYNAMICS_WORLD_H
# define BT_SOFT_MULTIBODY_DYNAMICS_WORLD_H
# include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
# include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h"
# include "BulletSoftBody/btSoftBody.h"
# ifndef BT_SOFT_RIGID_DYNAMICS_WORLD_H
2019-01-03 13:26:51 +00:00
typedef btAlignedObjectArray < btSoftBody * > btSoftBodyArray ;
2017-08-01 12:30:58 +00:00
# endif
class btSoftBodySolver ;
class btSoftMultiBodyDynamicsWorld : public btMultiBodyDynamicsWorld
{
2019-01-03 13:26:51 +00:00
btSoftBodyArray m_softBodies ;
int m_drawFlags ;
bool m_drawNodeTree ;
bool m_drawFaceTree ;
bool m_drawClusterTree ;
2017-08-01 12:30:58 +00:00
btSoftBodyWorldInfo m_sbi ;
///Solver classes that encapsulate multiple soft bodies for solving
2019-01-03 13:26:51 +00:00
btSoftBodySolver * m_softBodySolver ;
bool m_ownsSolver ;
2017-08-01 12:30:58 +00:00
protected :
2019-01-03 13:26:51 +00:00
virtual void predictUnconstraintMotion ( btScalar timeStep ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
virtual void internalSingleStepSimulation ( btScalar timeStep ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
void solveSoftBodiesConstraints ( btScalar timeStep ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
void serializeSoftBodies ( btSerializer * serializer ) ;
2017-08-01 12:30:58 +00:00
public :
2019-01-03 13:26:51 +00:00
btSoftMultiBodyDynamicsWorld ( btDispatcher * dispatcher , btBroadphaseInterface * pairCache , btMultiBodyConstraintSolver * constraintSolver , btCollisionConfiguration * collisionConfiguration , btSoftBodySolver * softBodySolver = 0 ) ;
2017-08-01 12:30:58 +00:00
virtual ~ btSoftMultiBodyDynamicsWorld ( ) ;
2019-01-03 13:26:51 +00:00
virtual void debugDrawWorld ( ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
void addSoftBody ( btSoftBody * body , int collisionFilterGroup = btBroadphaseProxy : : DefaultFilter , int collisionFilterMask = btBroadphaseProxy : : AllFilter ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
void removeSoftBody ( btSoftBody * body ) ;
2017-08-01 12:30:58 +00:00
///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btDiscreteDynamicsWorld::removeCollisionObject
2019-01-03 13:26:51 +00:00
virtual void removeCollisionObject ( btCollisionObject * collisionObject ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
int getDrawFlags ( ) const { return ( m_drawFlags ) ; }
void setDrawFlags ( int f ) { m_drawFlags = f ; }
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
btSoftBodyWorldInfo & getWorldInfo ( )
2017-08-01 12:30:58 +00:00
{
return m_sbi ;
}
2019-01-03 13:26:51 +00:00
const btSoftBodyWorldInfo & getWorldInfo ( ) const
2017-08-01 12:30:58 +00:00
{
return m_sbi ;
}
2019-01-03 13:26:51 +00:00
virtual btDynamicsWorldType getWorldType ( ) const
2017-08-01 12:30:58 +00:00
{
2019-01-03 13:26:51 +00:00
return BT_SOFT_MULTIBODY_DYNAMICS_WORLD ;
2017-08-01 12:30:58 +00:00
}
btSoftBodyArray & getSoftBodyArray ( )
{
return m_softBodies ;
}
const btSoftBodyArray & getSoftBodyArray ( ) const
{
return m_softBodies ;
}
2019-01-03 13:26:51 +00:00
virtual void rayTest ( const btVector3 & rayFromWorld , const btVector3 & rayToWorld , RayResultCallback & resultCallback ) const ;
2017-08-01 12:30:58 +00:00
/// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest.
/// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape.
/// This allows more customization.
2019-01-03 13:26:51 +00:00
static void rayTestSingle ( const btTransform & rayFromTrans , const btTransform & rayToTrans ,
btCollisionObject * collisionObject ,
const btCollisionShape * collisionShape ,
const btTransform & colObjWorldTransform ,
RayResultCallback & resultCallback ) ;
2017-08-01 12:30:58 +00:00
2019-01-03 13:26:51 +00:00
virtual void serialize ( btSerializer * serializer ) ;
2017-08-01 12:30:58 +00:00
} ;
2019-01-03 13:26:51 +00:00
# endif //BT_SOFT_MULTIBODY_DYNAMICS_WORLD_H