17 #ifndef _BT_SOFT_BODY_H 18 #define _BT_SOFT_BODY_H 34 #define btSoftBodyData btSoftBodyFloatData 35 #define btSoftBodyDataName "btSoftBodyFloatData" 59 m_maxDisplacement(1000.f),
60 water_normal(0, 0, 0),
376 Cluster() : m_leaf(0), m_ndamping(0), m_ldamping(0), m_adamping(0), m_matching(0), m_maxSelfCollisionImpulse(100.f), m_selfCollisionImpulseFactor(0.01f), m_containsAnchor(false)
387 Impulse() : m_velocity(0, 0, 0), m_drift(0, 0, 0), m_asVelocity(0), m_asDrift(0) {}
410 Body() : m_soft(0), m_rigid(0), m_collisionObject(0) {}
421 if (m_collisionObject)
426 static const btMatrix3x3 iwi(0, 0, 0, 0, 0, 0, 0, 0, 0);
428 if (m_soft)
return (m_soft->
m_invwi);
434 if (m_soft)
return (m_soft->
m_imass);
447 if (m_soft)
return (m_soft->
m_lv);
459 if (m_soft)
return (m_soft->
m_av);
464 return (linearVelocity() + angularVelocity(rpos));
486 applyDImpulse(impulse.
m_drift, rpos);
540 virtual void Prepare(
btScalar dt,
int iterations);
542 virtual void Terminate(
btScalar dt) = 0;
553 void Prepare(
btScalar dt,
int iterations);
556 eType::_
Type()
const {
return (eType::Linear); }
580 void Prepare(
btScalar dt,
int iterations);
583 eType::_
Type()
const {
return (eType::Angular); }
593 void Prepare(
btScalar dt,
int iterations);
596 eType::_
Type()
const {
return (eType::Contact); }
729 virtual ~btSoftBody();
744 bool checkLink(
int node0,
746 bool checkLink(
const Node* node0,
747 const Node* node1)
const;
749 bool checkFace(
int node0,
755 void appendNote(
const char* text,
762 void appendNote(
const char* text,
765 void appendNote(
const char* text,
768 void appendNote(
const char* text,
772 void appendNode(
const btVector3& x, btScalar m);
774 void appendLink(
int model = -1,
Material* mat = 0);
775 void appendLink(
int node0,
778 bool bcheckexist =
false);
779 void appendLink(
Node* node0,
782 bool bcheckexist =
false);
784 void appendFace(
int model = -1,
Material* mat = 0);
785 void appendFace(
int node0,
789 void appendTetra(
int model,
Material* mat);
791 void appendTetra(
int node0,
798 void appendAnchor(
int node,
799 btRigidBody* body,
bool disableCollisionBetweenLinkedBodies =
false, btScalar influence = 1);
800 void appendAnchor(
int node,
btRigidBody* body,
const btVector3& localPivot,
bool disableCollisionBetweenLinkedBodies =
false, btScalar influence = 1);
804 void appendLinearJoint(
const LJoint::Specs& specs, btSoftBody* body);
808 void appendAngularJoint(
const AJoint::Specs& specs, btSoftBody* body);
815 void addAeroForceToNode(
const btVector3& windVelocity,
int nodeIndex);
818 void addAeroForceToFace(
const btVector3& windVelocity,
int faceIndex);
821 void addVelocity(
const btVector3& velocity);
824 void setVelocity(
const btVector3& velocity);
827 void addVelocity(
const btVector3& velocity,
830 void setMass(
int node,
833 btScalar getMass(
int node)
const;
835 btScalar getTotalMass()
const;
837 void setTotalMass(btScalar mass,
838 bool fromfaces =
false);
840 void setTotalDensity(btScalar density);
842 void setVolumeMass(btScalar mass);
844 void setVolumeDensity(btScalar density);
854 btScalar getRestLengthScale();
856 void setRestLengthScale(btScalar restLength);
858 void setPose(
bool bvolume,
861 void resetLinkRestLengths();
863 btScalar getVolume()
const;
865 int clusterCount()
const;
877 static void clusterAImpulse(
Cluster* cluster,
const Impulse& impulse);
880 int generateBendingConstraints(
int distance,
883 void randomizeConstraints();
885 void releaseCluster(
int index);
886 void releaseClusters();
890 int generateClusters(
int k,
int maxiterations = 8192);
892 void refine(
ImplicitFn* ifn, btScalar accurary,
bool cut);
894 bool cutLink(
int node0,
int node1, btScalar position);
895 bool cutLink(
const Node* node0,
const Node* node1, btScalar position);
904 void predictMotion(btScalar dt);
906 void solveConstraints();
908 void staticSolve(
int iterations);
910 static void solveCommonConstraints(btSoftBody** bodies,
int count,
int iterations);
914 void integrateMotion();
917 void defaultCollisionHandler(btSoftBody* psb);
926 void setWindVelocity(
const btVector3& velocity);
939 m_softBodySolver = softBodySolver;
947 return m_softBodySolver;
955 return m_softBodySolver;
965 return (
const btSoftBody*)colObj;
971 return (btSoftBody*)colObj;
981 aabbMin = m_bounds[0];
982 aabbMax = m_bounds[1];
987 void pointersToIndices();
988 void indicesToPointers(
const int* map = 0);
991 btScalar& mint,
eFeature::_& feature,
int& index,
bool bcountonly)
const;
992 void initializeFaceTree();
995 void updateNormals();
998 void updateConstants();
999 void updateLinkConstants();
1000 void updateArea(
bool averageArea =
true);
1001 void initializeClusters();
1002 void updateClusters();
1003 void cleanupClusters();
1004 void prepareClusters(
int iterations);
1005 void solveClusters(btScalar sor);
1006 void applyClusters(
bool drift);
1007 void dampClusters();
1009 static void PSolve_Anchors(btSoftBody* psb, btScalar kst, btScalar ti);
1010 static void PSolve_RContacts(btSoftBody* psb, btScalar kst, btScalar ti);
1011 static void PSolve_SContacts(btSoftBody* psb, btScalar, btScalar ti);
1012 static void PSolve_Links(btSoftBody* psb, btScalar kst, btScalar ti);
1013 static void VSolve_Links(btSoftBody* psb, btScalar kst);
1017 virtual int calculateSerializeBufferSize()
const;
1020 virtual const char* serialize(
void* dataBuffer,
class btSerializer* serializer)
const;
1025 #endif //_BT_SOFT_BODY_H
btVector3 linearVelocity() const
const btCollisionObject * m_colObj
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don't store a rigidbody pointer but a rigidbody ...
eFeature::_ feature
soft body
btAlignedObjectArray< Link > tLinkArray
Vertex normals are oriented toward velocity.
btScalar m_maxDisplacement
const btVector3 & getAngularVelocity() const
void applyVImpulse(const btVector3 &impulse, const btVector3 &rpos) const
void applyAImpulse(const Impulse &impulse) const
void applyTorqueImpulse(const btVector3 &torque)
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
btAlignedObjectArray< ePSolver::_ > tPSolverArray
void applyVAImpulse(const btVector3 &impulse) const
Impulse operator-() const
Vertex normals are flipped to match velocity.
btScalar m_restLengthScale
tVector3Array m_framerefs
btAlignedObjectArray< btVector3 > tVector3Array
Body(const btCollisionObject *colObj)
btAlignedObjectArray< bool > m_clusterConnectivity
static int split(btDbvtNode **leaves, int count, const btVector3 &org, const btVector3 &axis)
btVector3 angularVelocity(const btVector3 &rpos) const
btAlignedObjectArray< Cluster * > tClusterArray
btAlignedObjectArray< Node * > m_nodes
btAlignedObjectArray< btScalar > tScalarArray
static void clusterVImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
btDispatcher * m_dispatcher
The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes ...
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
btScalar fraction
feature index
virtual btScalar Speed(AJoint *, btScalar current)
tSContactArray m_scontacts
btAlignedObjectArray< Face > tFaceArray
btAlignedObjectArray< RContact > tRContactArray
btVector3 angularVelocity() const
btAlignedObjectArray< int > m_userIndexMapping
static IControl * Default()
btAlignedObjectArray< Tetra > tTetraArray
Vertex normals are taken as it is.
btTransform m_initialWorldTransform
static btSoftBody * upcast(btCollisionObject *colObj)
btAlignedObjectArray< btDbvtNode * > tLeafArray
virtual void getAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
void applyDImpulse(const btVector3 &impulse, const btVector3 &rpos) const
btSoftBodyWorldInfo * m_worldInfo
btSparseSdf< 3 > m_sparsesdf
void applyDAImpulse(const btVector3 &impulse) const
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
void activate(bool forceActivation=false) const
virtual void setCollisionShape(btCollisionShape *collisionShape)
btTransform & getWorldTransform()
btSoftBodyWorldInfo * getWorldInfo()
const btVector3 & getLinearVelocity() const
Vertex normals are flipped to match velocity and lift and drag forces are applied.
btAlignedObjectArray< Material * > tMaterialArray
tMaterialArray m_materials
static void clusterDImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
static const btSoftBody * upcast(const btCollisionObject *colObj)
btScalar getInvMass() const
const btCollisionObject * m_collisionObject
RayFromToCaster takes a ray from, ray to (instead of direction!)
eVSolver : velocities solvers
btSoftBodySolver * getSoftBodySolver()
btCollisionObject can be used to manage collision detection objects.
static void clusterVAImpulse(Cluster *cluster, const btVector3 &impulse)
void applyImpulse(const Impulse &impulse, const btVector3 &rpos) const
The btRigidBody is the main class for rigid body objects.
tPSolverArray m_dsequence
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
const btMatrix3x3 & invWorldInertia() const
btScalar m_maxSelfCollisionImpulse
btVector3 can be used to represent 3D points and vectors.
#define ATTRIBUTE_ALIGNED16(a)
btAlignedObjectArray< Note > tNoteArray
btAlignedObjectArray< btSoftBody * > tSoftBodyArray
btAlignedObjectArray< SContact > tSContactArray
ePSolver : positions solvers
btVector3 velocity(const btVector3 &rpos) const
btAlignedObjectArray< Joint * > tJointArray
virtual void Prepare(AJoint *)
Impulse operator*(btScalar x) const
Face normals are flipped to match velocity.
int getInternalType() const
reserved for Bullet internal usage
Face normals are flipped to match velocity and lift and drag forces are applied.
#define BT_DECLARE_ALIGNED_ALLOCATOR()
void setSoftBodySolver(btSoftBodySolver *softBodySolver)
const btTransform & xform() const
void applyCentralImpulse(const btVector3 &impulse)
tVSolverArray m_vsequence
void applyDCImpulse(const btVector3 &impulse) const
tPSolverArray m_psequence
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btBroadphaseInterface * m_broadphase
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
btSoftBodySolver * m_softBodySolver
const btMatrix3x3 & getInvInertiaTensorWorld() const
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btAlignedObjectArray< const class btCollisionObject * > m_collisionDisabledObjects
btScalar m_selfCollisionImpulseFactor
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
btAlignedObjectArray< Node > tNodeArray
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
static void clusterDCImpulse(Cluster *cluster, const btVector3 &impulse)
tRContactArray m_rcontacts
btAlignedObjectArray< Anchor > tAnchorArray
btVector3 m_rayNormalizedDirection
btAlignedObjectArray< eVSolver::_ > tVSolverArray
static void clusterDAImpulse(Cluster *cluster, const btVector3 &impulse)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btSoftBodySolver * getSoftBodySolver() const