| Bullet Collision Detection & Physics Library
    | 
 
 
 
Go to the documentation of this file.
   17 #ifndef _BT_SOFT_BODY_INTERNALS_H 
   18 #define _BT_SOFT_BODY_INTERNALS_H 
   37         void resize(
int n, 
const T& init = T())
 
   40                 store.resize((n * (n + 1)) / 2, init);
 
   46                 return ((r * (r + 1)) / 2 + c);
 
   92                 aabbMin = aabbMax = crns[0];
 
   93                 for (
int i = 1; i < 8; ++i)
 
  166         virtual const char* 
getName()
 const { 
return "SOFTCLUSTER"; }
 
  183 template <
typename T>
 
  186         memset(&value, 0, 
sizeof(T));
 
  189 template <
typename T>
 
  190 static inline bool CompLess(
const T& a, 
const T& b)
 
  195 template <
typename T>
 
  201 template <
typename T>
 
  204         return (a + (b - a) * t);
 
  207 template <
typename T>
 
  210         return ((b + a * t - b * t) / (a * b));
 
  218         r[0] = 
Lerp(a[0], b[0], t);
 
  219         r[1] = 
Lerp(a[1], b[1], t);
 
  220         r[2] = 
Lerp(a[2], b[2], t);
 
  227         if (sql > (maxlength * maxlength))
 
  228                 return ((v * maxlength) / 
btSqrt(sql));
 
  233 template <
typename T>
 
  234 static inline T 
Clamp(
const T& x, 
const T& l, 
const T& h)
 
  236         return (x < l ? l : x > h ? h : x);
 
  239 template <
typename T>
 
  240 static inline T 
Sq(
const T& x)
 
  245 template <
typename T>
 
  246 static inline T 
Cube(
const T& x)
 
  251 template <
typename T>
 
  252 static inline T 
Sign(
const T& x)
 
  254         return ((T)(x < 0 ? -1 : +1));
 
  257 template <
typename T>
 
  258 static inline bool SameSign(
const T& x, 
const T& y)
 
  260         return ((x * y) > 0);
 
  278         m[0] = 
btVector3(1 - xx + xx * s, xy * s - xy, zx * s - zx);
 
  279         m[1] = 
btVector3(xy * s - xy, 1 - yy + yy * s, yz * s - yz);
 
  280         m[2] = 
btVector3(zx * s - zx, yz * s - yz, 1 - zz + zz * s);
 
  306         for (
int i = 0; i < 3; ++i) r[i] = a[i] + b[i];
 
  314         for (
int i = 0; i < 3; ++i) r[i] = a[i] - b[i];
 
  322         for (
int i = 0; i < 3; ++i) r[i] = a[i] * b;
 
  367         return (a * 
btDot(v, a));
 
  431 template <
typename T>
 
  437         return (a * coord.
x() + b * coord.
y() + c * coord.
z());
 
  448         const btScalar isum = 1 / (w[0] + w[1] + w[2]);
 
  449         return (
btVector3(w[1] * isum, w[2] * isum, w[0] * isum));
 
  457                                                                          const int maxiterations = 256)
 
  461         if (values[0] > values[1])
 
  464                 btSwap(values[0], values[1]);
 
  466         if (values[0] > -accuracy) 
return (-1);
 
  467         if (values[1] < +accuracy) 
return (-1);
 
  468         for (
int i = 0; i < maxiterations; ++i)
 
  470                 const btScalar t = 
Lerp(span[0], span[1], values[0] / (values[0] - values[1]));
 
  472                 if ((t <= 0) || (t >= 1)) 
break;
 
  473                 if (
btFabs(v) < accuracy) 
return (t);
 
  582         if ((a == ma) && (b == mb)) 
return (0);
 
  583         if ((a == mb) && (b == ma)) 
return (1);
 
  596                 static const int maxiterations = 16;
 
  614                         if (
btFabs(a[p][q]) > accuracy)
 
  616                                 const btScalar w = (a[q][q] - a[p][p]) / (2 * a[p][q]);
 
  623                                         mulPQ(a, c, s, p, q);
 
  625                                         mulPQ(v, c, s, p, q);
 
  632                 } 
while ((++iterations) < maxiterations);
 
  635                         *values = 
btVector3(a[0][0], a[1][1], a[2][2]);
 
  643                 const btScalar m[2][3] = {{a[p][0], a[p][1], a[p][2]},
 
  644                                                                   {a[q][0], a[q][1], a[q][2]}};
 
  647                 for (i = 0; i < 3; ++i) a[p][i] = c * m[0][i] - s * m[1][i];
 
  648                 for (i = 0; i < 3; ++i) a[q][i] = c * m[1][i] + s * m[0][i];
 
  652                 const btScalar m[2][3] = {{a[0][p], a[1][p], a[2][p]},
 
  653                                                                   {a[0][q], a[1][q], a[2][q]}};
 
  656                 for (i = 0; i < 3; ++i) a[i][p] = c * m[0][i] - s * m[1][i];
 
  657                 for (i = 0; i < 3; ++i) a[i][q] = c * m[1][i] + s * m[0][i];
 
  813                         bool connected = 
false;
 
  826                                                                                                         cla->
m_com - clb->m_com, res))
 
  841                                 static int count = 0;
 
  881                                         static const btMatrix3x3 iwiStatic(0, 0, 0, 0, 0, 0, 0, 0, 0);
 
  894                                         c.
m_c3 = fv.
length2() < (dn * fc * dn * fc) ? 0 : 1 - fc;
 
  922                                                   face->m_n[1]->m_x - o,
 
  923                                                   face->m_n[2]->m_x - o,
 
  932                                 if ((n[0]->m_im <= 0) ||
 
  959 #endif  //_BT_SOFT_BODY_INTERNALS_H 
  
virtual int getShapeType() const
btAlignedObjectArray< T > store
btRigidBody * m_rigidBody
const btTransform & xform() const
T & operator()(int c, int r)
static btVector3 CenterOf(const btSoftBody::Face &f)
The btRigidBody is the main class for rigid body objects.
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
DBVT_PREFIX void collideTT(const btDbvtNode *root0, const btDbvtNode *root1, DBVT_IPOLICY)
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
static btMatrix3x3 ImpulseMatrix(btScalar dt, btScalar ima, btScalar imb, const btMatrix3x3 &iwi, const btVector3 &r)
DBVT_INLINE void Expand(const btVector3 &e)
btAlignedObjectArray< bool > m_clusterConnectivity
static T Sign(const T &x)
static void mulPQ(btMatrix3x3 &a, btScalar c, btScalar s, int p, int q)
btSymMatrix(int n, const T &init=T())
btScalar length() const
Return the length of the vector.
virtual btScalar getMargin() const
The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
static void ZeroInitialize(T &value)
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
const btSoftBody::Cluster * m_cluster
static btDbvtVolume VolumeOf(const btSoftBody::Face &f, btScalar margin)
static btVector3 ProjectOnPlane(const btVector3 &v, const btVector3 &a)
static bool SameSign(const T &x, const T &y)
static int PolarDecompose(const btMatrix3x3 &m, btMatrix3x3 &q, btMatrix3x3 &s)
virtual const char * getName() const
static void EvaluateMedium(const btSoftBodyWorldInfo *wfi, const btVector3 &x, btSoftBody::sMedium &medium)
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
#define btAlignedAlloc(size, alignment)
virtual void calculateLocalInertia(btScalar, btVector3 &) const
const btTransform & getWorldTransform() const
btQuaternion inverse(const btQuaternion &q)
Return the inverse of a quaternion.
btVector3 velocity(const btVector3 &rpos) const
static void ApplyClampedForce(btSoftBody::Node &n, const btVector3 &f, btScalar dt)
static btMatrix3x3 Diagonal(btScalar x)
static btVector3 BaryCoord(const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &p)
void DoNode(btSoftBody::Node &n) const
static btScalar AreaOf(const btVector3 &x0, const btVector3 &x1, const btVector3 &x2)
static btScalar SignedDistance(const btVector3 &position, btScalar margin, const btConvexShape *shape, const btTransform &wtrs, sResults &results)
virtual void setLocalScaling(const btVector3 &)
static int system(btMatrix3x3 &a, btMatrix3x3 *vectors, btVector3 *values=0)
const T & btMin(const T &a, const T &b)
const btMatrix3x3 & invWorldInertia() const
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
static btScalar ClusterMetric(const btVector3 &x, const btVector3 &y)
const T & btMax(const T &a, const T &b)
const btScalar & y() const
Return the y value.
bool isStaticOrKinematicObject() const
btTransform & getWorldTransform()
tSContactArray m_scontacts
btAlignedObjectArray< Node * > m_nodes
static btMatrix3x3 Mul(const btMatrix3x3 &a, btScalar b)
virtual btScalar getMargin() const =0
btScalar btFabs(btScalar x)
static bool CompGreater(const T &a, const T &b)
static void ProjectOrigin(const btVector3 &a, const btVector3 &b, btVector3 &prj, btScalar &sqd)
static T InvLerp(const T &a, const T &b, btScalar t)
void activate(bool forceActivation=false) const
void ProcessColObj(btSoftBody *ps, const btCollisionObjectWrapper *colObWrap)
const btCollisionShape * getCollisionShape() const
static btMatrix3x3 AngularImpulseMatrix(const btMatrix3x3 &iia, const btMatrix3x3 &iib)
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
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.
DBVT_PREFIX void collideTV(const btDbvtNode *root, const btDbvtVolume &volume, DBVT_IPOLICY) const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
void ProcessSoftSoft(btSoftBody *psa, btSoftBody *psb)
const T & operator()(int c, int r) const
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
btScalar getInvMass() const
const btCollisionObject * getCollisionObject() const
static T Lerp(const T &a, const T &b, btScalar t)
btVector3 can be used to represent 3D points and vectors.
btVector3 getVelocityInLocalPoint(const btVector3 &rel_pos) const
static btDbvtAabbMm FromMM(const btVector3 &mi, const btVector3 &mx)
static int MatchEdge(const btSoftBody::Node *a, const btSoftBody::Node *b, const btSoftBody::Node *ma, const btSoftBody::Node *mb)
void processAllTriangles(btTriangleCallback *, const btVector3 &, const btVector3 &) const
static T BaryEval(const T &a, const T &b, const T &c, const btVector3 &coord)
bool SolveContact(const btGjkEpaSolver2::sResults &res, btSoftBody::Body ba, const btSoftBody::Body bb, btSoftBody::CJoint &joint)
#define ATTRIBUTE_ALIGNED16(a)
This class is used to compute the polar decomposition of a matrix.
virtual btScalar getMargin() const
virtual void setMargin(btScalar margin)
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
int index(int c, int r) const
virtual btScalar Eval(const btVector3 &x)=0
tRContactArray m_rcontacts
static btMatrix3x3 Add(const btMatrix3x3 &a, const btMatrix3x3 &b)
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
static btVector3 Clamp(const btVector3 &v, btScalar maxlength)
static btDbvtAabbMm FromPoints(const btVector3 *pts, int n)
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const
void Process(const btDbvtNode *leaf)
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
static btMatrix3x3 Cross(const btVector3 &v)
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
const btScalar & x() const
Return the x value.
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
virtual const btVector3 & getLocalScaling() const
virtual const char * getName() const
bool checkContact(const btCollisionObjectWrapper *colObjWrap, const btVector3 &x, btScalar margin, btSoftBody::sCti &cti) const
void resize(int n, const T &init=T())
static bool CompLess(const T &a, const T &b)
static btMatrix3x3 ScaleAlongAxis(const btVector3 &a, btScalar s)
static btVector3 NormalizeAny(const btVector3 &v)
void setIdentity()
Set the matrix to the identity.
static btVector3 ProjectOnAxis(const btVector3 &v, const btVector3 &a)
const btMatrix3x3 & getInvInertiaTensorWorld() const
void Process(const btDbvtNode *leaf)
static T Cube(const T &x)
virtual void setMargin(btScalar margin)
btSoftClusterCollisionShape(const btSoftBody::Cluster *cluster)
const btCollisionObjectWrapper * m_colObjWrap
static btMatrix3x3 MassMatrix(btScalar im, const btMatrix3x3 &iwi, const btVector3 &r)
static btScalar ImplicitSolve(btSoftBody::ImplicitFn *fn, const btVector3 &a, const btVector3 &b, const btScalar accuracy, const int maxiterations=256)
const btCollisionObjectWrapper * m_colObj1Wrap
static btMatrix3x3 Sub(const btMatrix3x3 &a, const btMatrix3x3 &b)
virtual ~btSoftBodyCollisionShape()
btSoftBody implementation by Nathanael Presson
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const
static void Orthogonalize(btMatrix3x3 &m)
void push_back(const T &_Val)
void Process(const btDbvtNode *lnode, const btDbvtNode *lface)
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
btScalar btSqrt(btScalar y)
btScalar getFriction() const
btSoftBodyCollisionShape(btSoftBody *backptr)
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btVector3 normalized() const
Return a normalized version of this vector.
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
unsigned int decompose(const btMatrix3x3 &a, btMatrix3x3 &u, btMatrix3x3 &h) const
Decomposes a matrix into orthogonal and symmetric, positive-definite parts.
const btScalar & z() const
Return the z value.
void Process(const btDbvtNode *la, const btDbvtNode *lb)
int size() const
return the number of elements in the array
static void mulTPQ(btMatrix3x3 &a, btScalar c, btScalar s, int p, int q)
btScalar length2() const
Return the length of the vector squared.
const btCollisionShape * getCollisionShape() const