Bullet Collision Detection & Physics Library
btSoftBody.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
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:
10 
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.
14 */
16 
17 #ifndef _BT_SOFT_BODY_H
18 #define _BT_SOFT_BODY_H
19 
21 #include "LinearMath/btTransform.h"
24 
27 #include "btSparseSDF.h"
29 
30 //#ifdef BT_USE_DOUBLE_PRECISION
31 //#define btRigidBodyData btRigidBodyDoubleData
32 //#define btRigidBodyDataName "btRigidBodyDoubleData"
33 //#else
34 #define btSoftBodyData btSoftBodyFloatData
35 #define btSoftBodyDataName "btSoftBodyFloatData"
36 //#endif //BT_USE_DOUBLE_PRECISION
37 
39 class btDispatcher;
40 class btSoftBodySolver;
41 
42 /* btSoftBodyWorldInfo */
44 {
54 
56  : air_density((btScalar)1.2),
57  water_density(0),
58  water_offset(0),
59  m_maxDisplacement(1000.f), //avoid soft body from 'exploding' so use some upper threshold of maximum motion that a node can travel per frame
60  water_normal(0, 0, 0),
61  m_broadphase(0),
62  m_dispatcher(0),
63  m_gravity(0, -10, 0)
64  {
65  }
66 };
67 
71 {
72 public:
74 
75  // The solver object that handles this soft body
77 
78  //
79  // Enumerations
80  //
81 
83  struct eAeroModel
84  {
85  enum _
86  {
95  };
96  };
97 
99  struct eVSolver
100  {
101  enum _
102  {
105  };
106  };
107 
109  struct ePSolver
110  {
111  enum _
112  {
118  };
119  };
120 
123  {
124  enum _
125  {
130  };
131  };
132 
134  struct eFeature
135  {
136  enum _
137  {
144  };
145  };
146 
149 
150  //
151  // Flags
152  //
153 
155  struct fCollision
156  {
157  enum _
158  {
159  RVSmask = 0x000f,
160  SDF_RS = 0x0001,
161  CL_RS = 0x0002,
162 
163  SVSmask = 0x0030,
164  VF_SS = 0x0010,
165  CL_SS = 0x0020,
166  CL_SELF = 0x0040,
167  /* presets */
170  };
171  };
172 
174  struct fMaterial
175  {
176  enum _
177  {
178  DebugDraw = 0x0001,
179  /* presets */
182  };
183  };
184 
185  //
186  // API Types
187  //
188 
189  /* sRayCast */
190  struct sRayCast
191  {
194  int index;
196  };
197 
198  /* ImplicitFn */
199  struct ImplicitFn
200  {
201  virtual ~ImplicitFn() {}
202  virtual btScalar Eval(const btVector3& x) = 0;
203  };
204 
205  //
206  // Internal types
207  //
208 
211 
212  /* sCti is Softbody contact info */
213  struct sCti
214  {
215  const btCollisionObject* m_colObj; /* Rigid body */
216  btVector3 m_normal; /* Outward normal */
217  btScalar m_offset; /* Offset from origin */
218  };
219 
220  /* sMedium */
221  struct sMedium
222  {
223  btVector3 m_velocity; /* Velocity */
224  btScalar m_pressure; /* Pressure */
225  btScalar m_density; /* Density */
226  };
227 
228  /* Base type */
229  struct Element
230  {
231  void* m_tag; // User data
232  Element() : m_tag(0) {}
233  };
234  /* Material */
235  struct Material : Element
236  {
237  btScalar m_kLST; // Linear stiffness coefficient [0,1]
238  btScalar m_kAST; // Area/Angular stiffness coefficient [0,1]
239  btScalar m_kVST; // Volume stiffness coefficient [0,1]
240  int m_flags; // Flags
241  };
242 
243  /* Feature */
244  struct Feature : Element
245  {
246  Material* m_material; // Material
247  };
248  /* Node */
249  struct Node : Feature
250  {
251  btVector3 m_x; // Position
252  btVector3 m_q; // Previous step position
253  btVector3 m_v; // Velocity
254  btVector3 m_f; // Force accumulator
255  btVector3 m_n; // Normal
256  btScalar m_im; // 1/mass
257  btScalar m_area; // Area
258  btDbvtNode* m_leaf; // Leaf data
259  int m_battach : 1; // Attached
260  };
261  /* Link */
263  Link : Feature
264  {
265  btVector3 m_c3; // gradient
266  Node* m_n[2]; // Node pointers
267  btScalar m_rl; // Rest length
268  int m_bbending : 1; // Bending link
269  btScalar m_c0; // (ima+imb)*kLST
270  btScalar m_c1; // rl^2
271  btScalar m_c2; // |gradient|^2/c0
272 
274  };
275  /* Face */
276  struct Face : Feature
277  {
278  Node* m_n[3]; // Node pointers
279  btVector3 m_normal; // Normal
280  btScalar m_ra; // Rest area
281  btDbvtNode* m_leaf; // Leaf data
282  };
283  /* Tetra */
284  struct Tetra : Feature
285  {
286  Node* m_n[4]; // Node pointers
287  btScalar m_rv; // Rest volume
288  btDbvtNode* m_leaf; // Leaf data
289  btVector3 m_c0[4]; // gradients
290  btScalar m_c1; // (4*kVST)/(im0+im1+im2+im3)
291  btScalar m_c2; // m_c1/sum(|g0..3|^2)
292  };
293  /* RContact */
294  struct RContact
295  {
296  sCti m_cti; // Contact infos
297  Node* m_node; // Owner node
298  btMatrix3x3 m_c0; // Impulse matrix
299  btVector3 m_c1; // Relative anchor
300  btScalar m_c2; // ima*dt
301  btScalar m_c3; // Friction
302  btScalar m_c4; // Hardness
303  };
304  /* SContact */
305  struct SContact
306  {
307  Node* m_node; // Node
308  Face* m_face; // Face
309  btVector3 m_weights; // Weigths
310  btVector3 m_normal; // Normal
311  btScalar m_margin; // Margin
312  btScalar m_friction; // Friction
313  btScalar m_cfm[2]; // Constraint force mixing
314  };
315  /* Anchor */
316  struct Anchor
317  {
318  Node* m_node; // Node pointer
319  btVector3 m_local; // Anchor position in body space
320  btRigidBody* m_body; // Body
322  btMatrix3x3 m_c0; // Impulse matrix
323  btVector3 m_c1; // Relative anchor
324  btScalar m_c2; // ima*dt
325  };
326  /* Note */
327  struct Note : Element
328  {
329  const char* m_text; // Text
330  btVector3 m_offset; // Offset
331  int m_rank; // Rank
332  Node* m_nodes[4]; // Nodes
333  btScalar m_coords[4]; // Coordinates
334  };
335  /* Pose */
336  struct Pose
337  {
338  bool m_bvolume; // Is valid
339  bool m_bframe; // Is frame
340  btScalar m_volume; // Rest volume
341  tVector3Array m_pos; // Reference positions
342  tScalarArray m_wgh; // Weights
343  btVector3 m_com; // COM
344  btMatrix3x3 m_rot; // Rotation
345  btMatrix3x3 m_scl; // Scale
346  btMatrix3x3 m_aqq; // Base scaling
347  };
348  /* Cluster */
349  struct Cluster
350  {
367  btScalar m_ndamping; /* Node damping */
368  btScalar m_ldamping; /* Linear damping */
369  btScalar m_adamping; /* Angular damping */
374  bool m_collide;
377  {
378  }
379  };
380  /* Impulse */
381  struct Impulse
382  {
385  int m_asVelocity : 1;
386  int m_asDrift : 1;
387  Impulse() : m_velocity(0, 0, 0), m_drift(0, 0, 0), m_asVelocity(0), m_asDrift(0) {}
389  {
390  Impulse i = *this;
391  i.m_velocity = -i.m_velocity;
392  i.m_drift = -i.m_drift;
393  return (i);
394  }
396  {
397  Impulse i = *this;
398  i.m_velocity *= x;
399  i.m_drift *= x;
400  return (i);
401  }
402  };
403  /* Body */
404  struct Body
405  {
409 
412  Body(const btCollisionObject* colObj) : m_soft(0), m_collisionObject(colObj)
413  {
415  }
416 
417  void activate() const
418  {
419  if (m_rigid)
420  m_rigid->activate();
421  if (m_collisionObject)
423  }
425  {
426  static const btMatrix3x3 iwi(0, 0, 0, 0, 0, 0, 0, 0, 0);
427  if (m_rigid) return (m_rigid->getInvInertiaTensorWorld());
428  if (m_soft) return (m_soft->m_invwi);
429  return (iwi);
430  }
432  {
433  if (m_rigid) return (m_rigid->getInvMass());
434  if (m_soft) return (m_soft->m_imass);
435  return (0);
436  }
437  const btTransform& xform() const
438  {
439  static const btTransform identity = btTransform::getIdentity();
441  if (m_soft) return (m_soft->m_framexform);
442  return (identity);
443  }
445  {
446  if (m_rigid) return (m_rigid->getLinearVelocity());
447  if (m_soft) return (m_soft->m_lv);
448  return (btVector3(0, 0, 0));
449  }
451  {
452  if (m_rigid) return (btCross(m_rigid->getAngularVelocity(), rpos));
453  if (m_soft) return (btCross(m_soft->m_av, rpos));
454  return (btVector3(0, 0, 0));
455  }
457  {
458  if (m_rigid) return (m_rigid->getAngularVelocity());
459  if (m_soft) return (m_soft->m_av);
460  return (btVector3(0, 0, 0));
461  }
462  btVector3 velocity(const btVector3& rpos) const
463  {
464  return (linearVelocity() + angularVelocity(rpos));
465  }
466  void applyVImpulse(const btVector3& impulse, const btVector3& rpos) const
467  {
468  if (m_rigid) m_rigid->applyImpulse(impulse, rpos);
469  if (m_soft) btSoftBody::clusterVImpulse(m_soft, rpos, impulse);
470  }
471  void applyDImpulse(const btVector3& impulse, const btVector3& rpos) const
472  {
473  if (m_rigid) m_rigid->applyImpulse(impulse, rpos);
474  if (m_soft) btSoftBody::clusterDImpulse(m_soft, rpos, impulse);
475  }
476  void applyImpulse(const Impulse& impulse, const btVector3& rpos) const
477  {
478  if (impulse.m_asVelocity)
479  {
480  // printf("impulse.m_velocity = %f,%f,%f\n",impulse.m_velocity.getX(),impulse.m_velocity.getY(),impulse.m_velocity.getZ());
481  applyVImpulse(impulse.m_velocity, rpos);
482  }
483  if (impulse.m_asDrift)
484  {
485  // printf("impulse.m_drift = %f,%f,%f\n",impulse.m_drift.getX(),impulse.m_drift.getY(),impulse.m_drift.getZ());
486  applyDImpulse(impulse.m_drift, rpos);
487  }
488  }
489  void applyVAImpulse(const btVector3& impulse) const
490  {
491  if (m_rigid) m_rigid->applyTorqueImpulse(impulse);
493  }
494  void applyDAImpulse(const btVector3& impulse) const
495  {
496  if (m_rigid) m_rigid->applyTorqueImpulse(impulse);
498  }
499  void applyAImpulse(const Impulse& impulse) const
500  {
501  if (impulse.m_asVelocity) applyVAImpulse(impulse.m_velocity);
502  if (impulse.m_asDrift) applyDAImpulse(impulse.m_drift);
503  }
504  void applyDCImpulse(const btVector3& impulse) const
505  {
506  if (m_rigid) m_rigid->applyCentralImpulse(impulse);
508  }
509  };
510  /* Joint */
511  struct Joint
512  {
513  struct eType
514  {
515  enum _
516  {
517  Linear = 0,
520  };
521  };
522  struct Specs
523  {
524  Specs() : erp(1), cfm(1), split(1) {}
528  };
537  bool m_delete;
538  virtual ~Joint() {}
539  Joint() : m_delete(false) {}
540  virtual void Prepare(btScalar dt, int iterations);
541  virtual void Solve(btScalar dt, btScalar sor) = 0;
542  virtual void Terminate(btScalar dt) = 0;
543  virtual eType::_ Type() const = 0;
544  };
545  /* LJoint */
546  struct LJoint : Joint
547  {
549  {
551  };
553  void Prepare(btScalar dt, int iterations);
554  void Solve(btScalar dt, btScalar sor);
555  void Terminate(btScalar dt);
556  eType::_ Type() const { return (eType::Linear); }
557  };
558  /* AJoint */
559  struct AJoint : Joint
560  {
561  struct IControl
562  {
563  virtual ~IControl() {}
564  virtual void Prepare(AJoint*) {}
565  virtual btScalar Speed(AJoint*, btScalar current) { return (current); }
566  static IControl* Default()
567  {
568  static IControl def;
569  return (&def);
570  }
571  };
573  {
574  Specs() : icontrol(IControl::Default()) {}
577  };
580  void Prepare(btScalar dt, int iterations);
581  void Solve(btScalar dt, btScalar sor);
582  void Terminate(btScalar dt);
583  eType::_ Type() const { return (eType::Angular); }
584  };
585  /* CJoint */
586  struct CJoint : Joint
587  {
588  int m_life;
593  void Prepare(btScalar dt, int iterations);
594  void Solve(btScalar dt, btScalar sor);
595  void Terminate(btScalar dt);
596  eType::_ Type() const { return (eType::Contact); }
597  };
598  /* Config */
599  struct Config
600  {
601  eAeroModel::_ aeromodel; // Aerodynamic model (default: V_Point)
602  btScalar kVCF; // Velocities correction factor (Baumgarte)
603  btScalar kDP; // Damping coefficient [0,1]
604  btScalar kDG; // Drag coefficient [0,+inf]
605  btScalar kLF; // Lift coefficient [0,+inf]
606  btScalar kPR; // Pressure coefficient [-inf,+inf]
607  btScalar kVC; // Volume conversation coefficient [0,+inf]
608  btScalar kDF; // Dynamic friction coefficient [0,1]
609  btScalar kMT; // Pose matching coefficient [0,1]
610  btScalar kCHR; // Rigid contacts hardness [0,1]
611  btScalar kKHR; // Kinetic contacts hardness [0,1]
612  btScalar kSHR; // Soft contacts hardness [0,1]
613  btScalar kAHR; // Anchors hardness [0,1]
614  btScalar kSRHR_CL; // Soft vs rigid hardness [0,1] (cluster only)
615  btScalar kSKHR_CL; // Soft vs kinetic hardness [0,1] (cluster only)
616  btScalar kSSHR_CL; // Soft vs soft hardness [0,1] (cluster only)
617  btScalar kSR_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only)
618  btScalar kSK_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only)
619  btScalar kSS_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only)
620  btScalar maxvolume; // Maximum volume ratio for pose
621  btScalar timescale; // Time scale
622  int viterations; // Velocities solver iterations
623  int piterations; // Positions solver iterations
624  int diterations; // Drift solver iterations
625  int citerations; // Cluster solver iterations
626  int collisions; // Collisions flags
627  tVSolverArray m_vsequence; // Velocity solvers sequence
628  tPSolverArray m_psequence; // Position solvers sequence
629  tPSolverArray m_dsequence; // Drift solvers sequence
630  };
631  /* SolverState */
632  struct SolverState
633  {
634  btScalar sdt; // dt*timescale
635  btScalar isdt; // 1/sdt
636  btScalar velmrg; // velocity margin
637  btScalar radmrg; // radial margin
638  btScalar updmrg; // Update margin
639  };
642  {
648  int m_tests;
649  RayFromToCaster(const btVector3& rayFrom, const btVector3& rayTo, btScalar mxt);
650  void Process(const btDbvtNode* leaf);
651 
652  static /*inline*/ btScalar rayFromToTriangle(const btVector3& rayFrom,
653  const btVector3& rayTo,
654  const btVector3& rayNormalizedDirection,
655  const btVector3& a,
656  const btVector3& b,
657  const btVector3& c,
658  btScalar maxt = SIMD_INFINITY);
659  };
660 
661  //
662  // Typedefs
663  //
664 
665  typedef void (*psolver_t)(btSoftBody*, btScalar, btScalar);
666  typedef void (*vsolver_t)(btSoftBody*, btScalar);
680 
681  //
682  // Fields
683  //
684 
685  Config m_cfg; // Configuration
686  SolverState m_sst; // Solver state
687  Pose m_pose; // Pose
688  void* m_tag; // User data
690  tNoteArray m_notes; // Notes
691  tNodeArray m_nodes; // Nodes
692  tLinkArray m_links; // Links
693  tFaceArray m_faces; // Faces
696  tRContactArray m_rcontacts; // Rigid contacts
697  tSContactArray m_scontacts; // Soft contacts
700  btScalar m_timeacc; // Time accumulator
701  btVector3 m_bounds[2]; // Spatial bounds
702  bool m_bUpdateRtCst; // Update runtime constants
703  btDbvt m_ndbvt; // Nodes tree
704  btDbvt m_fdbvt; // Faces tree
705  btDbvt m_cdbvt; // Clusters tree
707 
708  btAlignedObjectArray<bool> m_clusterConnectivity; //cluster connectivity, for self-collision
709 
711 
713 
715 
716  //
717  // Api
718  //
719 
720  /* ctor */
721  btSoftBody(btSoftBodyWorldInfo* worldInfo, int node_count, const btVector3* x, const btScalar* m);
722 
723  /* ctor */
724  btSoftBody(btSoftBodyWorldInfo* worldInfo);
725 
726  void initDefaults();
727 
728  /* dtor */
729  virtual ~btSoftBody();
730  /* Check for existing link */
731 
733 
735  {
736  return m_worldInfo;
737  }
738 
740  virtual void setCollisionShape(btCollisionShape* collisionShape)
741  {
742  }
743 
744  bool checkLink(int node0,
745  int node1) const;
746  bool checkLink(const Node* node0,
747  const Node* node1) const;
748  /* Check for existring face */
749  bool checkFace(int node0,
750  int node1,
751  int node2) const;
752  /* Append material */
753  Material* appendMaterial();
754  /* Append note */
755  void appendNote(const char* text,
756  const btVector3& o,
757  const btVector4& c = btVector4(1, 0, 0, 0),
758  Node* n0 = 0,
759  Node* n1 = 0,
760  Node* n2 = 0,
761  Node* n3 = 0);
762  void appendNote(const char* text,
763  const btVector3& o,
764  Node* feature);
765  void appendNote(const char* text,
766  const btVector3& o,
767  Link* feature);
768  void appendNote(const char* text,
769  const btVector3& o,
770  Face* feature);
771  /* Append node */
772  void appendNode(const btVector3& x, btScalar m);
773  /* Append link */
774  void appendLink(int model = -1, Material* mat = 0);
775  void appendLink(int node0,
776  int node1,
777  Material* mat = 0,
778  bool bcheckexist = false);
779  void appendLink(Node* node0,
780  Node* node1,
781  Material* mat = 0,
782  bool bcheckexist = false);
783  /* Append face */
784  void appendFace(int model = -1, Material* mat = 0);
785  void appendFace(int node0,
786  int node1,
787  int node2,
788  Material* mat = 0);
789  void appendTetra(int model, Material* mat);
790  //
791  void appendTetra(int node0,
792  int node1,
793  int node2,
794  int node3,
795  Material* mat = 0);
796 
797  /* Append anchor */
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);
801  /* Append linear joint */
802  void appendLinearJoint(const LJoint::Specs& specs, Cluster* body0, Body body1);
803  void appendLinearJoint(const LJoint::Specs& specs, Body body = Body());
804  void appendLinearJoint(const LJoint::Specs& specs, btSoftBody* body);
805  /* Append linear joint */
806  void appendAngularJoint(const AJoint::Specs& specs, Cluster* body0, Body body1);
807  void appendAngularJoint(const AJoint::Specs& specs, Body body = Body());
808  void appendAngularJoint(const AJoint::Specs& specs, btSoftBody* body);
809  /* Add force (or gravity) to the entire body */
810  void addForce(const btVector3& force);
811  /* Add force (or gravity) to a node of the body */
812  void addForce(const btVector3& force,
813  int node);
814  /* Add aero force to a node of the body */
815  void addAeroForceToNode(const btVector3& windVelocity, int nodeIndex);
816 
817  /* Add aero force to a face of the body */
818  void addAeroForceToFace(const btVector3& windVelocity, int faceIndex);
819 
820  /* Add velocity to the entire body */
821  void addVelocity(const btVector3& velocity);
822 
823  /* Set velocity for the entire body */
824  void setVelocity(const btVector3& velocity);
825 
826  /* Add velocity to a node of the body */
827  void addVelocity(const btVector3& velocity,
828  int node);
829  /* Set mass */
830  void setMass(int node,
831  btScalar mass);
832  /* Get mass */
833  btScalar getMass(int node) const;
834  /* Get total mass */
835  btScalar getTotalMass() const;
836  /* Set total mass (weighted by previous masses) */
837  void setTotalMass(btScalar mass,
838  bool fromfaces = false);
839  /* Set total density */
840  void setTotalDensity(btScalar density);
841  /* Set volume mass (using tetrahedrons) */
842  void setVolumeMass(btScalar mass);
843  /* Set volume density (using tetrahedrons) */
844  void setVolumeDensity(btScalar density);
845  /* Transform */
846  void transform(const btTransform& trs);
847  /* Translate */
848  void translate(const btVector3& trs);
849  /* Rotate */
850  void rotate(const btQuaternion& rot);
851  /* Scale */
852  void scale(const btVector3& scl);
853  /* Get link resting lengths scale */
855  /* Scale resting length of all springs */
856  void setRestLengthScale(btScalar restLength);
857  /* Set current state as pose */
858  void setPose(bool bvolume,
859  bool bframe);
860  /* Set current link lengths as resting lengths */
861  void resetLinkRestLengths();
862  /* Return the volume */
863  btScalar getVolume() const;
864  /* Cluster count */
865  int clusterCount() const;
866  /* Cluster center of mass */
867  static btVector3 clusterCom(const Cluster* cluster);
868  btVector3 clusterCom(int cluster) const;
869  /* Cluster velocity at rpos */
870  static btVector3 clusterVelocity(const Cluster* cluster, const btVector3& rpos);
871  /* Cluster impulse */
872  static void clusterVImpulse(Cluster* cluster, const btVector3& rpos, const btVector3& impulse);
873  static void clusterDImpulse(Cluster* cluster, const btVector3& rpos, const btVector3& impulse);
874  static void clusterImpulse(Cluster* cluster, const btVector3& rpos, const Impulse& impulse);
875  static void clusterVAImpulse(Cluster* cluster, const btVector3& impulse);
876  static void clusterDAImpulse(Cluster* cluster, const btVector3& impulse);
877  static void clusterAImpulse(Cluster* cluster, const Impulse& impulse);
878  static void clusterDCImpulse(Cluster* cluster, const btVector3& impulse);
879  /* Generate bending constraints based on distance in the adjency graph */
880  int generateBendingConstraints(int distance,
881  Material* mat = 0);
882  /* Randomize constraints to reduce solver bias */
883  void randomizeConstraints();
884  /* Release clusters */
885  void releaseCluster(int index);
886  void releaseClusters();
887  /* Generate clusters (K-mean) */
890  int generateClusters(int k, int maxiterations = 8192);
891  /* Refine */
892  void refine(ImplicitFn* ifn, btScalar accurary, bool cut);
893  /* CutLink */
894  bool cutLink(int node0, int node1, btScalar position);
895  bool cutLink(const Node* node0, const Node* node1, btScalar position);
896 
898  bool rayTest(const btVector3& rayFrom,
899  const btVector3& rayTo,
900  sRayCast& results);
901  /* Solver presets */
902  void setSolver(eSolverPresets::_ preset);
903  /* predictMotion */
904  void predictMotion(btScalar dt);
905  /* solveConstraints */
906  void solveConstraints();
907  /* staticSolve */
908  void staticSolve(int iterations);
909  /* solveCommonConstraints */
910  static void solveCommonConstraints(btSoftBody** bodies, int count, int iterations);
911  /* solveClusters */
912  static void solveClusters(const btAlignedObjectArray<btSoftBody*>& bodies);
913  /* integrateMotion */
914  void integrateMotion();
915  /* defaultCollisionHandlers */
918 
919  //
920  // Functionality to deal with new accelerated solvers.
921  //
922 
926  void setWindVelocity(const btVector3& velocity);
927 
931  const btVector3& getWindVelocity();
932 
933  //
934  // Set the solver that handles this soft body
935  // Should not be allowed to get out of sync with reality
936  // Currently called internally on addition to the world
937  void setSoftBodySolver(btSoftBodySolver* softBodySolver)
938  {
939  m_softBodySolver = softBodySolver;
940  }
941 
942  //
943  // Return the solver that handles this soft body
944  //
946  {
947  return m_softBodySolver;
948  }
949 
950  //
951  // Return the solver that handles this soft body
952  //
954  {
955  return m_softBodySolver;
956  }
957 
958  //
959  // Cast
960  //
961 
962  static const btSoftBody* upcast(const btCollisionObject* colObj)
963  {
964  if (colObj->getInternalType() == CO_SOFT_BODY)
965  return (const btSoftBody*)colObj;
966  return 0;
967  }
969  {
970  if (colObj->getInternalType() == CO_SOFT_BODY)
971  return (btSoftBody*)colObj;
972  return 0;
973  }
974 
975  //
976  // ::btCollisionObject
977  //
978 
979  virtual void getAabb(btVector3& aabbMin, btVector3& aabbMax) const
980  {
981  aabbMin = m_bounds[0];
982  aabbMax = m_bounds[1];
983  }
984  //
985  // Private
986  //
987  void pointersToIndices();
988  void indicesToPointers(const int* map = 0);
989 
990  int rayTest(const btVector3& rayFrom, const btVector3& rayTo,
991  btScalar& mint, eFeature::_& feature, int& index, bool bcountonly) const;
992  void initializeFaceTree();
993  btVector3 evaluateCom() const;
994  bool checkContact(const btCollisionObjectWrapper* colObjWrap, const btVector3& x, btScalar margin, btSoftBody::sCti& cti) const;
995  void updateNormals();
996  void updateBounds();
997  void updatePose();
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();
1008  void applyForces();
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);
1014  static psolver_t getSolver(ePSolver::_ solver);
1015  static vsolver_t getSolver(eVSolver::_ solver);
1016 
1017  virtual int calculateSerializeBufferSize() const;
1018 
1020  virtual const char* serialize(void* dataBuffer, class btSerializer* serializer) const;
1021 
1022  //virtual void serializeSingleObject(class btSerializer* serializer) const;
1023 };
1024 
1025 #endif //_BT_SOFT_BODY_H
static void PSolve_RContacts(btSoftBody *psb, btScalar kst, btScalar ti)
RayFromToCaster(const btVector3 &rayFrom, const btVector3 &rayTo, btScalar mxt)
btVector3 linearVelocity() const
Definition: btSoftBody.h:444
btVector3 m_rpos[2]
Definition: btSoftBody.h:552
const btCollisionObject * m_colObj
Definition: btSoftBody.h:215
btVector3 m_velocity
Definition: btSoftBody.h:383
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don&#39;t store a rigidbody pointer but a rigidbody ...
Definition: btRigidBody.h:189
int generateBendingConstraints(int distance, Material *mat=0)
btMatrix3x3 m_scl
Definition: btSoftBody.h:345
void(* vsolver_t)(btSoftBody *, btScalar)
Definition: btSoftBody.h:666
eFeature::_ feature
soft body
Definition: btSoftBody.h:193
Rigid contacts solver.
Definition: btSoftBody.h:116
btScalar kSS_SPLT_CL
Definition: btSoftBody.h:619
btAlignedObjectArray< Link > tLinkArray
Definition: btSoftBody.h:671
void Process(const btDbvtNode *leaf)
int index
feature type
Definition: btSoftBody.h:194
Vertex normals are oriented toward velocity.
Definition: btSoftBody.h:88
bool checkFace(int node0, int node1, int node2) const
Definition: btSoftBody.cpp:152
void updateConstants()
btScalar m_maxDisplacement
Definition: btSoftBody.h:48
void Prepare(btScalar dt, int iterations)
const btVector3 & getAngularVelocity() const
Definition: btRigidBody.h:357
Config m_cfg
Definition: btSoftBody.h:685
btMatrix3x3 m_c0
Definition: btSoftBody.h:298
void applyVImpulse(const btVector3 &impulse, const btVector3 &rpos) const
Definition: btSoftBody.h:466
void applyAImpulse(const Impulse &impulse) const
Definition: btSoftBody.h:499
btScalar getTotalMass() const
Definition: btSoftBody.cpp:700
btVector3 m_normal
Definition: btSoftBody.h:216
Body(Cluster *p)
Definition: btSoftBody.h:411
btScalar water_offset
Definition: btSoftBody.h:47
void defaultCollisionHandler(const btCollisionObjectWrapper *pcoWrap)
void applyTorqueImpulse(const btVector3 &torque)
Definition: btRigidBody.h:318
btVector3 m_rpos[2]
Definition: btSoftBody.h:590
bool cutLink(int node0, int node1, btScalar position)
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
btMatrix3x3 m_locii
Definition: btSoftBody.h:357
virtual int calculateSerializeBufferSize() const
btAlignedObjectArray< ePSolver::_ > tPSolverArray
Definition: btSoftBody.h:148
void applyVAImpulse(const btVector3 &impulse) const
Definition: btSoftBody.h:489
Impulse operator-() const
Definition: btSoftBody.h:388
void integrateMotion()
Vertex normals are flipped to match velocity.
Definition: btSoftBody.h:89
btScalar m_restLengthScale
Definition: btSoftBody.h:714
Cluster * m_soft
Definition: btSoftBody.h:406
void releaseClusters()
tVector3Array m_framerefs
Definition: btSoftBody.h:353
void setSolver(eSolverPresets::_ preset)
btAlignedObjectArray< btVector3 > tVector3Array
Definition: btSoftBody.h:210
static btVector3 clusterVelocity(const Cluster *cluster, const btVector3 &rpos)
Definition: btSoftBody.cpp:981
Body(const btCollisionObject *colObj)
Definition: btSoftBody.h:412
btScalar kSK_SPLT_CL
Definition: btSoftBody.h:618
void activate() const
Definition: btSoftBody.h:417
btMatrix3x3 m_c0
Definition: btSoftBody.h:322
tJointArray m_joints
Definition: btSoftBody.h:698
btAlignedObjectArray< bool > m_clusterConnectivity
Definition: btSoftBody.h:708
Material * appendMaterial()
Definition: btSoftBody.cpp:176
btVector3 angularVelocity(const btVector3 &rpos) const
Definition: btSoftBody.h:450
btScalar m_split
Definition: btSoftBody.h:533
virtual void Prepare(btScalar dt, int iterations)
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)
void Prepare(btScalar dt, int iterations)
btAlignedObjectArray< Cluster * > tClusterArray
Definition: btSoftBody.h:667
Cluster vs convex rigid vs soft.
Definition: btSoftBody.h:163
btAlignedObjectArray< Node * > m_nodes
Definition: btSoftBody.h:352
btAlignedObjectArray< btScalar > tScalarArray
Definition: btSoftBody.h:209
static void clusterVImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
Definition: btSoftBody.cpp:987
btDispatcher * m_dispatcher
Definition: btSoftBody.h:51
The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes ...
Definition: btDbvt.h:198
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
void * m_tag
Definition: btSoftBody.h:688
btScalar fraction
feature index
Definition: btSoftBody.h:195
void setVelocity(const btVector3 &velocity)
Definition: btSoftBody.cpp:664
btVector3 m_windVelocity
Definition: btSoftBody.h:712
void Solve(btScalar dt, btScalar sor)
virtual btScalar Speed(AJoint *, btScalar current)
Definition: btSoftBody.h:565
tSContactArray m_scontacts
Definition: btSoftBody.h:697
Soft contacts solver.
Definition: btSoftBody.h:117
btAlignedObjectArray< Face > tFaceArray
Definition: btSoftBody.h:672
btAlignedObjectArray< RContact > tRContactArray
Definition: btSoftBody.h:675
SDF based rigid vs soft.
Definition: btSoftBody.h:161
btDbvt m_fdbvt
Definition: btSoftBody.h:704
btVector3 angularVelocity() const
Definition: btSoftBody.h:456
btAlignedObjectArray< int > m_userIndexMapping
Definition: btSoftBody.h:732
static IControl * Default()
Definition: btSoftBody.h:566
void appendAnchor(int node, btRigidBody *body, bool disableCollisionBetweenLinkedBodies=false, btScalar influence=1)
Definition: btSoftBody.cpp:378
btAlignedObjectArray< Tetra > tTetraArray
Definition: btSoftBody.h:673
static void clusterImpulse(Cluster *cluster, const btVector3 &rpos, const Impulse &impulse)
btVector3 water_normal
Definition: btSoftBody.h:49
btScalar getMass(int node) const
Definition: btSoftBody.cpp:694
static btVector3 clusterCom(const Cluster *cluster)
Definition: btSoftBody.cpp:964
btMatrix3x3 m_aqq
Definition: btSoftBody.h:346
Vertex normals are taken as it is.
Definition: btSoftBody.h:91
void addForce(const btVector3 &force)
Definition: btSoftBody.cpp:458
void setWindVelocity(const btVector3 &velocity)
Set a wind velocity for interaction with the air.
Cluster vs cluster soft vs soft handling.
Definition: btSoftBody.h:166
btTransform m_initialWorldTransform
Definition: btSoftBody.h:710
btSoftBody(btSoftBodyWorldInfo *worldInfo, int node_count, const btVector3 *x, const btScalar *m)
btSoftBody implementation by Nathanael Presson
Definition: btSoftBody.cpp:25
btDbvtNode * m_leaf
Definition: btSoftBody.h:281
static btSoftBody * upcast(btCollisionObject *colObj)
Definition: btSoftBody.h:968
void appendLink(int model=-1, Material *mat=0)
Definition: btSoftBody.cpp:266
void Terminate(btScalar dt)
bool rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, sRayCast &results)
Ray casting using rayFrom and rayTo in worldspace, (not direction!)
void applyForces()
tNodeArray m_nodes
Definition: btSoftBody.h:691
tLinkArray m_links
Definition: btSoftBody.h:692
void appendAngularJoint(const AJoint::Specs &specs, Cluster *body0, Body body1)
Definition: btSoftBody.cpp:431
Node * m_n[3]
Definition: btSoftBody.h:278
virtual void Solve(btScalar dt, btScalar sor)=0
btVector3 m_normal
Definition: btSoftBody.h:279
btAlignedObjectArray< btDbvtNode * > tLeafArray
Definition: btSoftBody.h:670
virtual void getAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
Definition: btSoftBody.h:979
void applyDImpulse(const btVector3 &impulse, const btVector3 &rpos) const
Definition: btSoftBody.h:471
void appendFace(int model=-1, Material *mat=0)
Definition: btSoftBody.cpp:306
btSoftBodyWorldInfo * m_worldInfo
Definition: btSoftBody.h:689
tTetraArray m_tetras
Definition: btSoftBody.h:694
virtual ~btSoftBody()
Definition: btSoftBody.cpp:116
Cluster soft body self collision.
Definition: btSoftBody.h:168
btSparseSdf< 3 > m_sparsesdf
Definition: btSoftBody.h:53
void applyDAImpulse(const btVector3 &impulse) const
Definition: btSoftBody.h:494
int generateClusters(int k, int maxiterations=8192)
generateClusters with k=0 will create a convex cluster for each tetrahedron or triangle otherwise an ...
void addVelocity(const btVector3 &velocity)
Definition: btSoftBody.cpp:658
const char * m_text
Definition: btSoftBody.h:329
void addAeroForceToNode(const btVector3 &windVelocity, int nodeIndex)
Definition: btSoftBody.cpp:473
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
Definition: btVector3.h:918
Enable debug draw.
Definition: btSoftBody.h:180
static void solveClusters(const btAlignedObjectArray< btSoftBody *> &bodies)
void appendLinearJoint(const LJoint::Specs &specs, Cluster *body0, Body body1)
Definition: btSoftBody.cpp:405
void activate(bool forceActivation=false) const
void initDefaults()
Definition: btSoftBody.cpp:61
virtual void setCollisionShape(btCollisionShape *collisionShape)
Definition: btSoftBody.h:740
btScalar getRestLengthScale()
Definition: btSoftBody.cpp:859
#define SIMD_INFINITY
Definition: btScalar.h:524
btTransform & getWorldTransform()
Material * m_material
Definition: btSoftBody.h:246
btVector3 m_offset
Definition: btSoftBody.h:330
btScalar kSR_SPLT_CL
Definition: btSoftBody.h:617
btSoftBodyWorldInfo * getWorldInfo()
Definition: btSoftBody.h:734
virtual ~Joint()
Definition: btSoftBody.h:538
void indicesToPointers(const int *map=0)
btVector3 m_sdrift
Definition: btSoftBody.h:535
void setVolumeMass(btScalar mass)
Definition: btSoftBody.cpp:753
btVector3 m_normal
Definition: btSoftBody.h:591
const btVector3 & getLinearVelocity() const
Definition: btRigidBody.h:353
void updatePose()
btVector3 m_velocity
Definition: btSoftBody.h:223
virtual eType::_ Type() const =0
void randomizeConstraints()
Vertex normals are flipped to match velocity and lift and drag forces are applied.
Definition: btSoftBody.h:90
void Prepare(btScalar dt, int iterations)
btAlignedObjectArray< Material * > tMaterialArray
Definition: btSoftBody.h:677
void updateLinkConstants()
const btVector3 & getWindVelocity()
Return the wind velocity for interaction with the air.
tMaterialArray m_materials
Definition: btSoftBody.h:699
static void clusterDImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
Definition: btSoftBody.cpp:999
int clusterCount() const
Definition: btSoftBody.cpp:958
static const btSoftBody * upcast(const btCollisionObject *colObj)
Definition: btSoftBody.h:962
btScalar getInvMass() const
Definition: btRigidBody.h:261
void refine(ImplicitFn *ifn, btScalar accurary, bool cut)
static void PSolve_SContacts(btSoftBody *psb, btScalar, btScalar ti)
const btCollisionObject * m_collisionObject
Definition: btSoftBody.h:408
btMatrix3x3 m_invwi
Definition: btSoftBody.h:358
void staticSolve(int iterations)
RayFromToCaster takes a ray from, ray to (instead of direction!)
Definition: btSoftBody.h:641
eVSolver : velocities solvers
Definition: btSoftBody.h:99
static psolver_t getSolver(ePSolver::_ solver)
btSoftBodySolver * getSoftBodySolver()
Definition: btSoftBody.h:945
void releaseCluster(int index)
void updateNormals()
void updateBounds()
void appendTetra(int model, Material *mat)
Definition: btSoftBody.cpp:346
btCollisionObject can be used to manage collision detection objects.
void solveConstraints()
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
void predictMotion(btScalar dt)
static void clusterVAImpulse(Cluster *cluster, const btVector3 &impulse)
void appendNode(const btVector3 &x, btScalar m)
Definition: btSoftBody.cpp:246
tAnchorArray m_anchors
Definition: btSoftBody.h:695
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)
Definition: btSoftBody.cpp:188
btDbvtNode * m_leaf
Definition: btSoftBody.h:288
void applyImpulse(const Impulse &impulse, const btVector3 &rpos) const
Definition: btSoftBody.h:476
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:59
static void VSolve_Links(btSoftBody *psb, btScalar kst)
btScalar m_influence
Definition: btSoftBody.h:321
void setTotalMass(btScalar mass, bool fromfaces=false)
Definition: btSoftBody.cpp:711
btVector3 m_vimpulses[2]
Definition: btSoftBody.h:360
Pose m_pose
Definition: btSoftBody.h:687
void initializeClusters()
tPSolverArray m_dsequence
Definition: btSoftBody.h:629
eType::_ Type() const
Definition: btSoftBody.h:583
void initializeFaceTree()
btScalar m_cfm[2]
Definition: btSoftBody.h:313
void rotate(const btQuaternion &rot)
Definition: btSoftBody.cpp:830
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
const btMatrix3x3 & invWorldInertia() const
Definition: btSoftBody.h:424
btVector3 m_axis[2]
Definition: btSoftBody.h:578
virtual void Terminate(btScalar dt)=0
void setTotalDensity(btScalar density)
Definition: btSoftBody.cpp:747
btScalar m_maxSelfCollisionImpulse
Definition: btSoftBody.h:371
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:84
btAlignedObjectArray< Note > tNoteArray
Definition: btSoftBody.h:668
Rigid versus soft mask.
Definition: btSoftBody.h:164
btScalar m_coords[4]
Definition: btSoftBody.h:333
btScalar m_offset
Definition: btSoftBody.h:217
virtual btScalar Eval(const btVector3 &x)=0
btScalar getVolume() const
Definition: btSoftBody.cpp:939
btVector3 m_com
Definition: btSoftBody.h:343
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
btAlignedObjectArray< btSoftBody * > tSoftBodyArray
Definition: btSoftBody.h:679
btVector3 m_refs[2]
Definition: btSoftBody.h:530
btAlignedObjectArray< SContact > tSContactArray
Definition: btSoftBody.h:676
ePSolver : positions solvers
Definition: btSoftBody.h:109
btVector3 velocity(const btVector3 &rpos) const
Definition: btSoftBody.h:462
Node * m_nodes[4]
Definition: btSoftBody.h:332
void Solve(btScalar dt, btScalar sor)
btDbvt m_cdbvt
Definition: btSoftBody.h:705
btAlignedObjectArray< Joint * > tJointArray
Definition: btSoftBody.h:678
void Solve(btScalar dt, btScalar sor)
tNoteArray m_notes
Definition: btSoftBody.h:690
eType::_ Type() const
Definition: btSoftBody.h:556
virtual void Prepare(AJoint *)
Definition: btSoftBody.h:564
Impulse operator*(btScalar x) const
Definition: btSoftBody.h:395
static const btTransform & getIdentity()
Return an identity transform.
Definition: btTransform.h:197
void applyClusters(bool drift)
Face normals are flipped to match velocity.
Definition: btSoftBody.h:92
void transform(const btTransform &trs)
Definition: btSoftBody.cpp:798
Face normals are taken as it is.
Definition: btSoftBody.h:94
btDbvt m_ndbvt
Definition: btSoftBody.h:703
btVector3 m_n
Definition: btSoftBody.h:255
btVector3 m_local
Definition: btSoftBody.h:319
int getInternalType() const
reserved for Bullet internal usage
btDbvtNode * m_leaf
Definition: btSoftBody.h:366
btScalar timescale
Definition: btSoftBody.h:621
SolverState m_sst
Definition: btSoftBody.h:686
void Terminate(btScalar dt)
Face normals are flipped to match velocity and lift and drag forces are applied.
Definition: btSoftBody.h:93
Rigid versus soft mask.
Definition: btSoftBody.h:160
tClusterArray m_clusters
Definition: btSoftBody.h:706
btSoftBody * body
Definition: btSoftBody.h:192
btVector3 m_dimpulses[2]
Definition: btSoftBody.h:361
void(* psolver_t)(btSoftBody *, btScalar, btScalar)
Definition: btSoftBody.h:665
btMatrix3x3 m_rot
Definition: btSoftBody.h:344
void setSoftBodySolver(btSoftBodySolver *softBodySolver)
Definition: btSoftBody.h:937
bool checkContact(const btCollisionObjectWrapper *colObjWrap, const btVector3 &x, btScalar margin, btSoftBody::sCti &cti) const
const btTransform & xform() const
Definition: btSoftBody.h:437
static void clusterAImpulse(Cluster *cluster, const Impulse &impulse)
void scale(const btVector3 &scl)
Definition: btSoftBody.cpp:839
void cleanupClusters()
void applyCentralImpulse(const btVector3 &impulse)
Definition: btRigidBody.h:313
bool checkLink(int node0, int node1) const
Definition: btSoftBody.cpp:130
btMatrix3x3 m_massmatrix
Definition: btSoftBody.h:536
btScalar water_density
Definition: btSoftBody.h:46
btVector3 m_bounds[2]
Definition: btSoftBody.h:701
btScalar m_volume
Definition: btSoftBody.h:340
btVector3 m_v
Definition: btSoftBody.h:253
tVSolverArray m_vsequence
Definition: btSoftBody.h:627
void applyDCImpulse(const btVector3 &impulse) const
Definition: btSoftBody.h:504
btScalar m_timeacc
Definition: btSoftBody.h:700
void dampClusters()
tPSolverArray m_psequence
Definition: btSoftBody.h:628
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:46
tScalarArray m_wgh
Definition: btSoftBody.h:342
IControl * m_icontrol
Definition: btSoftBody.h:579
btBroadphaseInterface * m_broadphase
Definition: btSoftBody.h:50
void translate(const btVector3 &trs)
Definition: btSoftBody.cpp:821
eAeroModel::_ aeromodel
Definition: btSoftBody.h:601
btScalar air_density
Definition: btSoftBody.h:45
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
Definition: btRigidBody.h:323
eType::_ Type() const
Definition: btSoftBody.h:596
btSoftBodySolver * m_softBodySolver
Definition: btSoftBody.h:76
const btMatrix3x3 & getInvInertiaTensorWorld() const
Definition: btRigidBody.h:262
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:49
void setRestLengthScale(btScalar restLength)
Definition: btSoftBody.cpp:865
btVector3 m_q
Definition: btSoftBody.h:252
btAlignedObjectArray< const class btCollisionObject * > m_collisionDisabledObjects
Definition: btSoftBody.h:73
btScalar m_selfCollisionImpulseFactor
Definition: btSoftBody.h:372
btVector3 m_f
Definition: btSoftBody.h:254
void prepareClusters(int iterations)
btVector3 m_gravity
Definition: btSoftBody.h:52
btScalar invMass() const
Definition: btSoftBody.h:431
static void solveCommonConstraints(btSoftBody **bodies, int count, int iterations)
bool m_bUpdateRtCst
Definition: btSoftBody.h:702
tScalarArray m_masses
Definition: btSoftBody.h:351
void pointersToIndices()
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:70
btAlignedObjectArray< Node > tNodeArray
Definition: btSoftBody.h:669
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:76
static void clusterDCImpulse(Cluster *cluster, const btVector3 &impulse)
btRigidBody * m_body
Definition: btSoftBody.h:320
void setPose(bool bvolume, bool bframe)
Definition: btSoftBody.cpp:880
static void PSolve_Anchors(btSoftBody *psb, btScalar kst, btScalar ti)
btVector3 m_drift
Definition: btSoftBody.h:534
btRigidBody * m_rigid
Definition: btSoftBody.h:407
void setMass(int node, btScalar mass)
Definition: btSoftBody.cpp:687
void setVolumeDensity(btScalar density)
Definition: btSoftBody.cpp:783
btVector3 m_x
Definition: btSoftBody.h:251
tRContactArray m_rcontacts
Definition: btSoftBody.h:696
btAlignedObjectArray< Anchor > tAnchorArray
Definition: btSoftBody.h:674
btScalar maxvolume
Definition: btSoftBody.h:620
void updateClusters()
static void PSolve_Links(btSoftBody *psb, btScalar kst, btScalar ti)
btScalar m_area
Definition: btSoftBody.h:257
btVector3 evaluateCom() const
btVector3 m_rayNormalizedDirection
Definition: btSoftBody.h:645
btAlignedObjectArray< eVSolver::_ > tVSolverArray
Definition: btSoftBody.h:147
void addAeroForceToFace(const btVector3 &windVelocity, int faceIndex)
Definition: btSoftBody.cpp:562
static void clusterDAImpulse(Cluster *cluster, const btVector3 &impulse)
btVector3 m_c0[4]
Definition: btSoftBody.h:289
Vertex vs face soft vs soft handling.
Definition: btSoftBody.h:165
btDbvtNode * m_leaf
Definition: btSoftBody.h:258
btTransform m_framexform
Definition: btSoftBody.h:354
void updateArea(bool averageArea=true)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
btScalar m_friction
Definition: btSoftBody.h:592
tVector3Array m_pos
Definition: btSoftBody.h:341
void Terminate(btScalar dt)
btSoftBodySolver * getSoftBodySolver() const
Definition: btSoftBody.h:953
void resetLinkRestLengths()
Definition: btSoftBody.cpp:928
tFaceArray m_faces
Definition: btSoftBody.h:693