17 #ifndef _BT_SOFT_BODY_H
18 #define _BT_SOFT_BODY_H
36 #define btSoftBodyData btSoftBodyFloatData
37 #define btSoftBodyDataName "btSoftBodyFloatData"
39 static unsigned long seed = 243703;
523 static const btMatrix3x3 iwi(0, 0, 0, 0, 0, 0, 0, 0, 0);
880 const Node* node1)
const;
911 bool bcheckexist =
false);
915 bool bcheckexist =
false);
934 btRigidBody* body,
bool disableCollisionBetweenLinkedBodies =
false,
btScalar influence = 1);
974 bool fromfaces =
false);
1033 static void clusterAImpulse(Cluster* cluster,
const Impulse& impulse);
1194 #define SAFE_EPSILON SIMD_EPSILON * 100.0
1222 Merge(
node->childs[0]->volume,
node->childs[1]->volume, vol);
1233 template <
class DBVTNODE>
1266 Merge(
node->childs[0]->volume,
node->childs[1]->volume, vol);
1278 template <
typename T>
1284 return (
a * coord.x() +
b * coord.y() +
c * coord.z());
1295 #define NEXTRAND (seed = (1664525L * seed + 1013904223L) & 0xffffffff)
1298 for (i = 0, ni =
indices.size(); i < ni; ++i)
1324 if (applySpringForce)
1327 I += 0.5 * mass *
vn;
1328 int face_penetration = 0, node_penetration =
node->m_constrained;
1329 for (
int i = 0; i < 3; ++i)
1331 btScalar I_tilde = 2.0 *
I / (1.0 +
w.length2());
1334 if (face_penetration > 0 || node_penetration > 0)
1338 if (face_penetration <= 0)
1340 for (
int j = 0; j < 3; ++j)
1341 face->
m_n[j]->
m_v +=
w[j] * n * I_tilde *
node->m_im;
1343 if (node_penetration <= 0)
1345 node->m_v -= I_tilde *
node->m_im * n;
1355 I = 0.5 * mass * (vt_norm - vt_new);
1357 I_tilde = 2.0 *
I / (1.0 +
w.length2());
1359 if (face_penetration > 0 || node_penetration > 0)
1361 if (face_penetration <= 0)
1363 for (
int j = 0; j < 3; ++j)
1364 face->
m_n[j]->
m_v +=
w[j] * vt * I_tilde * (face->
m_n[j])->m_im;
1366 if (node_penetration <= 0)
1368 node->m_v -= I_tilde *
node->m_im * vt;
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint vn
int pad[32 - sizeof(int)]
ATTR_WARN_UNUSED_RESULT const BMLoop * l
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
DBVT_INLINE void Merge(const btDbvtAabbMm &a, const btDbvtAabbMm &b, btDbvtAabbMm &r)
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
static const btMatrix3x3 & getIdentity()
SIMD_FORCE_INLINE const T & btMin(const T &a, const T &b)
SIMD_FORCE_INLINE const T & btMax(const T &a, const T &b)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
SIMD_FORCE_INLINE void btSwap(T &a, T &b)
static unsigned long seed
static const btScalar OVERLAP_REDUCTION_FACTOR
SIMD_FORCE_INLINE btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
SIMD_FORCE_INLINE btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
SIMD_FORCE_INLINE int size() const
return the number of elements in the array
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
void applyTorqueImpulse(const btVector3 &torque)
const btVector3 & getAngularVelocity() const
btScalar getInvMass() const
static const btRigidBody * upcast(const btCollisionObject *colObj)
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
void applyCentralImpulse(const btVector3 &impulse)
const btVector3 & getLinearVelocity() const
const btMatrix3x3 & getInvInertiaTensorWorld() const
btMultiBodyJacobianData jacobianData_t1
btMultiBodyJacobianData jacobianData_normal
btMultiBodyJacobianData jacobianData_t2
static void PSolve_Links(btSoftBody *psb, btScalar kst, btScalar ti)
static void PSolve_SContacts(btSoftBody *psb, btScalar, btScalar ti)
bool checkLink(int node0, int node1) const
btScalar m_sleepingThreshold
void transformTo(const btTransform &trs)
btVector3 getLinearVelocity()
bool checkFace(int node0, int node1, int node2) const
void advanceDeformation()
btAlignedObjectArray< eVSolver::_ > tVSolverArray
void setGravityFactor(btScalar gravFactor)
void setPose(bool bvolume, bool bframe)
bool cutLink(int node0, int node1, btScalar position)
btSoftBodySolver * getSoftBodySolver()
void appendFace(int model=-1, Material *mat=0)
void setMass(int node, btScalar mass)
void interpolateRenderMesh()
btScalar m_dampingCoefficient
void updateNode(btDbvtNode *node, bool use_velocity, bool margin)
btAlignedObjectArray< TetraScratch > m_tetraScratchesTn
btAlignedObjectArray< Tetra > tTetraArray
bool rayFaceTest(const btVector3 &rayFrom, const btVector3 &rayTo, sRayCast &results)
void appendLinearJoint(const LJoint::Specs &specs, Cluster *body0, Body body1)
btAlignedObjectArray< SContact > tSContactArray
void scale(const btVector3 &scl)
btAlignedObjectArray< bool > m_clusterConnectivity
void updateFaceTree(bool use_velocity, bool margin)
void defaultCollisionHandler(const btCollisionObjectWrapper *pcoWrap)
btSoftBodyWorldInfo * getWorldInfo()
btScalar getVolume() const
bool rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, sRayCast &results)
Ray casting using rayFrom and rayTo in worldspace, (not direction!)
void addVelocity(const btVector3 &velocity)
btAlignedObjectArray< RContact > tRContactArray
void setDampingCoefficient(btScalar damping_coeff)
void predictMotion(btScalar dt)
void setSelfCollision(bool useSelfCollision)
void setLinearVelocity(const btVector3 &linVel)
btAlignedObjectArray< int > m_userIndexMapping
btAlignedObjectArray< Face > tFaceArray
void appendTetra(int model, Material *mat)
void setRestLengthScale(btScalar restLength)
void updateNodeTree(bool use_velocity, bool margin)
void rotate(const btQuaternion &rot)
void updateFace(DBVTNODE *node, bool use_velocity, bool margin)
void applyClusters(bool drift)
static void PSolve_Anchors(btSoftBody *psb, btScalar kst, btScalar ti)
btSoftBodyWorldInfo * m_worldInfo
void setSoftBodySolver(btSoftBodySolver *softBodySolver)
void updateArea(bool averageArea=true)
void addForce(const btVector3 &force)
void prepareClusters(int iterations)
void setCollisionQuadrature(int N)
static void clusterVImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
btAlignedObjectArray< DeformableFaceNodeContact > m_faceNodeContacts
static void VSolve_Links(btSoftBody *psb, btScalar kst)
btVector3 evaluateCom() const
void setTotalDensity(btScalar density)
btAlignedObjectArray< const class btCollisionObject * > m_collisionDisabledObjects
btAlignedObjectArray< Link > tLinkArray
static void clusterDAImpulse(Cluster *cluster, const btVector3 &impulse)
void appendNode(const btVector3 &x, btScalar m)
void staticSolve(int iterations)
void setVolumeMass(btScalar mass)
btScalar m_restLengthScale
bool checkDeformableContact(const btCollisionObjectWrapper *colObjWrap, const btVector3 &x, btScalar margin, btSoftBody::sCti &cti, bool predict=false) const
void updateDeactivation(btScalar timeStep)
btAlignedObjectArray< TetraScratch > m_tetraScratches
const btVector3 & getWindVelocity()
void addAeroForceToFace(const btVector3 &windVelocity, int faceIndex)
btAlignedObjectArray< btVector4 > m_renderNodesInterpolationWeights
void appendAngularJoint(const AJoint::Specs &specs, Cluster *body0, Body body1)
void setAngularVelocity(const btVector3 &angVel)
void setVolumeDensity(btScalar density)
static void clusterDCImpulse(Cluster *cluster, const btVector3 &impulse)
void transform(const btTransform &trs)
static void clusterVAImpulse(Cluster *cluster, const btVector3 &impulse)
btScalar getMass(int node) const
tMaterialArray m_materials
void setMaxStress(btScalar maxStress)
btSoftBody(btSoftBodyWorldInfo *worldInfo, int node_count, const btVector3 *x, const btScalar *m)
BT_DECLARE_ALIGNED_ALLOCATOR()
btAlignedObjectArray< btScalar > m_z
void addAeroForceToNode(const btVector3 &windVelocity, int nodeIndex)
void applyRepulsionForce(btScalar timeStep, bool applySpringForce)
btAlignedObjectArray< btVector3 > tVector3Array
static btVector3 clusterCom(const Cluster *cluster)
tRContactArray m_rcontacts
void appendAnchor(int node, btRigidBody *body, bool disableCollisionBetweenLinkedBodies=false, btScalar influence=1)
btAlignedObjectArray< Node > tNodeArray
btScalar m_maxSpeedSquared
void releaseCluster(int index)
btScalar m_repulsionStiffness
void setVelocity(const btVector3 &velocity)
btAlignedObjectArray< Joint * > tJointArray
btAlignedObjectArray< DeformableFaceRigidContact > m_faceRigidContacts
int generateClusters(int k, int maxiterations=8192)
void geometricCollisionHandler(btSoftBody *psb)
void refine(ImplicitFn *ifn, btScalar accurary, bool cut)
void setSolver(eSolverPresets::_ preset)
btSoftBodySolver * getSoftBodySolver() const
static T BaryEval(const T &a, const T &b, const T &c, const btVector3 &coord)
Material * appendMaterial()
void removeAnchor(int node)
btAlignedObjectArray< DeformableNodeRigidAnchor > m_deformableAnchors
btAlignedObjectArray< Material * > tMaterialArray
btAlignedObjectArray< Anchor > tAnchorArray
static void solveClusters(const btAlignedObjectArray< btSoftBody * > &bodies)
void appendNote(const char *text, const btVector3 &o, const btVector4 &c=btVector4(1, 0, 0, 0), Node *n0=0, Node *n1=0, Node *n2=0, Node *n3=0)
bool checkDeformableFaceContact(const btCollisionObjectWrapper *colObjWrap, Face &f, btVector3 &contact_point, btVector3 &bary, btScalar margin, btSoftBody::sCti &cti, bool predict=false) const
virtual int calculateSerializeBufferSize() const
btAlignedObjectArray< DeformableNodeRigidContact > m_nodeRigidContacts
btAlignedObjectArray< btSoftBody * > tSoftBodyArray
static void PSolve_RContacts(btSoftBody *psb, btScalar kst, btScalar ti)
static void clusterImpulse(Cluster *cluster, const btVector3 &rpos, const Impulse &impulse)
btAlignedObjectArray< btAlignedObjectArray< const btSoftBody::Node * > > m_renderNodesParents
static void clusterDImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
static btSoftBody * upcast(btCollisionObject *colObj)
static btVector3 clusterVelocity(const Cluster *cluster, const btVector3 &rpos)
btTransform getRigidTransform()
tSContactArray m_scontacts
btAlignedObjectArray< btDbvtNode * > tLeafArray
void(* psolver_t)(btSoftBody *, btScalar, btScalar)
static const btSoftBody * upcast(const btCollisionObject *colObj)
void initializeClusters()
btScalar getRestLengthScale()
btAlignedObjectArray< Note > tNoteArray
void randomizeConstraints()
virtual void setCollisionShape(btCollisionShape *collisionShape)
btScalar getTotalMass() const
btAlignedObjectArray< ePSolver::_ > tPSolverArray
void appendLink(int model=-1, Material *mat=0)
void setSpringStiffness(btScalar k)
void initializeDmInverse()
void setTotalMass(btScalar mass, bool fromfaces=false)
void appendDeformableAnchor(int node, btRigidBody *body)
void updateLinkConstants()
virtual void getAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
void(* vsolver_t)(btSoftBody *, btScalar)
btAlignedObjectArray< btVector3 > m_quads
static psolver_t getSolver(ePSolver::_ solver)
bool checkContact(const btCollisionObjectWrapper *colObjWrap, const btVector3 &x, btScalar margin, btSoftBody::sCti &cti) const
void indicesToPointers(const int *map=0)
static void solveCommonConstraints(btSoftBody **bodies, int count, int iterations)
btAlignedObjectArray< Cluster * > tClusterArray
void setWindVelocity(const btVector3 &velocity)
int generateBendingConstraints(int distance, Material *mat=0)
btAlignedObjectArray< btVector3 > m_X
void translate(const btVector3 &trs)
btVector3 getCenterOfMass() const
void initializeFaceTree()
btSoftBodySolver * m_softBodySolver
void resetLinkRestLengths()
btAlignedObjectArray< btScalar > tScalarArray
static void clusterAImpulse(Cluster *cluster, const Impulse &impulse)
SyclQueue void void size_t num_bytes void
ccl_gpu_kernel_postfix int ccl_global int * indices
T distance(const T &a, const T &b)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken density("density", pxr::TfToken::Immortal)
SocketIndexByIdentifierMap * map
static btDbvtAabbMm FromCR(const btVector3 &c, btScalar r)
static btDbvtAabbMm FromPoints(const btVector3 *pts, int n)
btDispatcher * m_dispatcher
btSparseSdf< 3 > m_sparsesdf
btScalar m_maxDisplacement
btBroadphaseInterface * m_broadphase
virtual btScalar Speed(AJoint *, btScalar current)
virtual void Prepare(AJoint *)
static IControl * Default()
void Prepare(btScalar dt, int iterations)
void Solve(btScalar dt, btScalar sor)
void Terminate(btScalar dt)
void applyVImpulse(const btVector3 &impulse, const btVector3 &rpos) const
btVector3 angularVelocity() const
const btTransform & xform() const
btVector3 linearVelocity() const
btVector3 angularVelocity(const btVector3 &rpos) const
void applyDImpulse(const btVector3 &impulse, const btVector3 &rpos) const
Body(const btCollisionObject *colObj)
btVector3 velocity(const btVector3 &rpos) const
void applyDCImpulse(const btVector3 &impulse) const
void applyDAImpulse(const btVector3 &impulse) const
const btMatrix3x3 & invWorldInertia() const
void applyVAImpulse(const btVector3 &impulse) const
void applyAImpulse(const Impulse &impulse) const
void applyImpulse(const Impulse &impulse, const btVector3 &rpos) const
const btCollisionObject * m_collisionObject
void Terminate(btScalar dt)
void Prepare(btScalar dt, int iterations)
void Solve(btScalar dt, btScalar sor)
tVector3Array m_framerefs
btScalar m_maxSelfCollisionImpulse
btAlignedObjectArray< Node * > m_nodes
btScalar m_selfCollisionImpulseFactor
tPSolverArray m_psequence
tPSolverArray m_dsequence
tVSolverArray m_vsequence
virtual btScalar Eval(const btVector3 &x)=0
Impulse operator*(btScalar x) const
Impulse operator-() const
virtual void Solve(btScalar dt, btScalar sor)=0
virtual void Terminate(btScalar dt)=0
virtual void Prepare(btScalar dt, int iterations)
virtual eType::_ Type() const =0
void Solve(btScalar dt, btScalar sor)
void Prepare(btScalar dt, int iterations)
void Terminate(btScalar dt)
btMatrix3x3 m_effectiveMass_inv
btMatrix3x3 m_effectiveMass
btMultiBodyJacobianData jacobianData_t2
btMultiBodyJacobianData jacobianData_t1
btMultiBodyJacobianData jacobianData_normal
RayFromToCaster takes a ray from, ray to (instead of direction!)
RayFromToCaster(const btVector3 &rayFrom, const btVector3 &rayTo, btScalar mxt)
void Process(const btDbvtNode *leaf)
static btScalar rayFromToTriangle(const btVector3 &rayFrom, const btVector3 &rayTo, const btVector3 &rayNormalizedDirection, const btVector3 &a, const btVector3 &b, const btVector3 &c, btScalar maxt=SIMD_INFINITY)
btVector3 m_rayNormalizedDirection
btScalar m_element_measure
@ V_TwoSided
Vertex normals are oriented toward velocity.
@ V_OneSided
Vertex normals are flipped to match velocity and lift and drag forces are applied.
@ END
Face normals are taken as it is.
@ V_TwoSidedLiftDrag
Vertex normals are flipped to match velocity.
@ F_OneSided
Face normals are flipped to match velocity and lift and drag forces are applied.
@ F_TwoSided
Vertex normals are taken as it is.
@ F_TwoSidedLiftDrag
Face normals are flipped to match velocity.
ePSolver : positions solvers
@ RContacts
Anchor solver.
@ SContacts
Rigid contacts solver.
@ END
Soft contacts solver.
eVSolver : velocities solvers
@ SDF_RDN
GJK based Multibody vs. deformable face.
@ VF_SS
Rigid versus soft mask.
@ Default
SDF based Rigid vs. deformable node.
@ RVDFmask
Vertex vs face soft vs soft handling.
@ VF_DD
Cluster soft body self collision.
@ CL_SS
Vertex vs face soft vs soft handling.
@ CL_SELF
Cluster vs cluster soft vs soft handling.
@ SVSmask
rigid vs deformable
@ SDF_RS
Rigid versus soft mask.
@ SDF_RD
Cluster vs convex rigid vs soft.
@ SDF_RDF
Rigid versus deformable face mask.
@ SDF_MDF
GJK based Rigid vs. deformable face.
@ CL_RS
SDF based rigid vs soft.
@ Default
Enable debug draw.
const btCollisionObject * m_colObj
eFeature::_ feature
soft body
btScalar fraction
feature index