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"
23 #include "LinearMath/btVector3.h"
25 
28 #include "btSparseSDF.h"
32 //#ifdef BT_USE_DOUBLE_PRECISION
33 //#define btRigidBodyData btRigidBodyDoubleData
34 //#define btRigidBodyDataName "btRigidBodyDoubleData"
35 //#else
36 #define btSoftBodyData btSoftBodyFloatData
37 #define btSoftBodyDataName "btSoftBodyFloatData"
38 //#endif //BT_USE_DOUBLE_PRECISION
39 
41 class btDispatcher;
42 class btSoftBodySolver;
43 
44 /* btSoftBodyWorldInfo */
46 {
56 
58  : air_density((btScalar)1.2),
59  water_density(0),
60  water_offset(0),
61  m_maxDisplacement(1000.f), //avoid soft body from 'exploding' so use some upper threshold of maximum motion that a node can travel per frame
62  water_normal(0, 0, 0),
63  m_broadphase(0),
64  m_dispatcher(0),
65  m_gravity(0, -10, 0)
66  {
67  }
68 };
69 
73 {
74 public:
76 
77  // The solver object that handles this soft body
79 
80  //
81  // Enumerations
82  //
83 
85  struct eAeroModel
86  {
87  enum _
88  {
96  END
97  };
98  };
99 
101  struct eVSolver
102  {
103  enum _
104  {
106  END
107  };
108  };
109 
111  struct ePSolver
112  {
113  enum _
114  {
119  END
120  };
121  };
122 
125  {
126  enum _
127  {
131  END
132  };
133  };
134 
136  struct eFeature
137  {
138  enum _
139  {
145  END
146  };
147  };
148 
151 
152  //
153  // Flags
154  //
155 
157  struct fCollision
158  {
159  enum _
160  {
161  RVSmask = 0x000f,
162  SDF_RS = 0x0001,
163  CL_RS = 0x0002,
164  SDF_RD = 0x0003,
165  SDF_RDF = 0x0004,
166 
167  SVSmask = 0x00F0,
168  VF_SS = 0x0010,
169  CL_SS = 0x0020,
170  CL_SELF = 0x0040,
171  VF_DD = 0x0050,
172  /* presets */
174  END
175  };
176  };
177 
179  struct fMaterial
180  {
181  enum _
182  {
183  DebugDraw = 0x0001,
184  /* presets */
186  END
187  };
188  };
189 
190  //
191  // API Types
192  //
193 
194  /* sRayCast */
195  struct sRayCast
196  {
199  int index;
201  };
202 
203  /* ImplicitFn */
204  struct ImplicitFn
205  {
206  virtual ~ImplicitFn() {}
207  virtual btScalar Eval(const btVector3& x) = 0;
208  };
209 
210  //
211  // Internal types
212  //
213 
216 
217  /* sCti is Softbody contact info */
218  struct sCti
219  {
220  const btCollisionObject* m_colObj; /* Rigid body */
221  btVector3 m_normal; /* Outward normal */
222  btScalar m_offset; /* Offset from origin */
223  btVector3 m_bary; /* Barycentric weights for faces */
224  };
225 
226  /* sMedium */
227  struct sMedium
228  {
229  btVector3 m_velocity; /* Velocity */
230  btScalar m_pressure; /* Pressure */
231  btScalar m_density; /* Density */
232  };
233 
234  /* Base type */
235  struct Element
236  {
237  void* m_tag; // User data
238  Element() : m_tag(0) {}
239  };
240  /* Material */
241  struct Material : Element
242  {
243  btScalar m_kLST; // Linear stiffness coefficient [0,1]
244  btScalar m_kAST; // Area/Angular stiffness coefficient [0,1]
245  btScalar m_kVST; // Volume stiffness coefficient [0,1]
246  int m_flags; // Flags
247  };
248 
249  /* Feature */
250  struct Feature : Element
251  {
252  Material* m_material; // Material
253  };
254  /* Node */
255  struct Node : Feature
256  {
257  btVector3 m_x; // Position
258  btVector3 m_q; // Previous step position/Test position
259  btVector3 m_v; // Velocity
260  btVector3 m_vsplit; // Temporary Velocity in addintion to velocity used in split impulse
261  btVector3 m_vn; // Previous step velocity
262  btVector3 m_f; // Force accumulator
263  btVector3 m_n; // Normal
264  btScalar m_im; // 1/mass
265  btScalar m_area; // Area
266  btDbvtNode* m_leaf; // Leaf data
267  int m_battach : 1; // Attached
268  int index;
269  };
270  /* Link */
272  Link : Feature
273  {
274  btVector3 m_c3; // gradient
275  Node* m_n[2]; // Node pointers
276  btScalar m_rl; // Rest length
277  int m_bbending : 1; // Bending link
278  btScalar m_c0; // (ima+imb)*kLST
279  btScalar m_c1; // rl^2
280  btScalar m_c2; // |gradient|^2/c0
281 
283  };
284  /* Face */
285  struct Face : Feature
286  {
287  Node* m_n[3]; // Node pointers
288  btVector3 m_normal; // Normal
289  btScalar m_ra; // Rest area
290  btDbvtNode* m_leaf; // Leaf data
291  btVector4 m_pcontact; // barycentric weights of the persistent contact
292  int m_index;
293  };
294  /* Tetra */
295  struct Tetra : Feature
296  {
297  Node* m_n[4]; // Node pointers
298  btScalar m_rv; // Rest volume
299  btDbvtNode* m_leaf; // Leaf data
300  btVector3 m_c0[4]; // gradients
301  btScalar m_c1; // (4*kVST)/(im0+im1+im2+im3)
302  btScalar m_c2; // m_c1/sum(|g0..3|^2)
303  btMatrix3x3 m_Dm_inverse; // rest Dm^-1
306  };
307 
308  /* TetraScratch */
310  {
311  btMatrix3x3 m_F; // deformation gradient F
312  btScalar m_trace; // trace of F^T * F
313  btScalar m_J; // det(F)
314  btMatrix3x3 m_cofF; // cofactor of F
315  };
316 
317  /* RContact */
318  struct RContact
319  {
320  sCti m_cti; // Contact infos
321  Node* m_node; // Owner node
322  btMatrix3x3 m_c0; // Impulse matrix
323  btVector3 m_c1; // Relative anchor
324  btScalar m_c2; // ima*dt
325  btScalar m_c3; // Friction
326  btScalar m_c4; // Hardness
327 
328  // jacobians and unit impulse responses for multibody
334  };
335 
337  {
338  public:
339  sCti m_cti; // Contact infos
340  btMatrix3x3 m_c0; // Impulse matrix
341  btVector3 m_c1; // Relative anchor
342  btScalar m_c2; // inverse mass of node/face
343  btScalar m_c3; // Friction
344  btScalar m_c4; // Hardness
345 
346  // jacobians and unit impulse responses for multibody
352  };
353 
355  {
356  public:
357  Node* m_node; // Owner node
358  };
359 
361  {
362  public:
363  btVector3 m_local; // Anchor position in body space
364  };
365 
367  {
368  public:
369  Face* m_face; // Owner face
370  btVector3 m_contactPoint; // Contact point
371  btVector3 m_bary; // Barycentric weights
372  btVector3 m_weights; // v_contactPoint * m_weights[i] = m_face->m_node[i]->m_v;
373  };
374 
376  {
377  Node* m_node; // Node
378  Face* m_face; // Face
379  btVector3 m_bary; // Barycentric weights
380  btVector3 m_weights; // v_contactPoint * m_weights[i] = m_face->m_node[i]->m_v;
381  btVector3 m_normal; // Normal
382  btScalar m_margin; // Margin
383  btScalar m_friction; // Friction
384  btScalar m_imf; // inverse mass of the face at contact point
385  btScalar m_c0; // scale of the impulse matrix;
386  };
387 
388  /* SContact */
389  struct SContact
390  {
391  Node* m_node; // Node
392  Face* m_face; // Face
393  btVector3 m_weights; // Weigths
394  btVector3 m_normal; // Normal
395  btScalar m_margin; // Margin
396  btScalar m_friction; // Friction
397  btScalar m_cfm[2]; // Constraint force mixing
398  };
399  /* Anchor */
400  struct Anchor
401  {
402  Node* m_node; // Node pointer
403  btVector3 m_local; // Anchor position in body space
404  btRigidBody* m_body; // Body
406  btMatrix3x3 m_c0; // Impulse matrix
407  btVector3 m_c1; // Relative anchor
408  btScalar m_c2; // ima*dt
409  };
410  /* Note */
411  struct Note : Element
412  {
413  const char* m_text; // Text
414  btVector3 m_offset; // Offset
415  int m_rank; // Rank
416  Node* m_nodes[4]; // Nodes
417  btScalar m_coords[4]; // Coordinates
418  };
419  /* Pose */
420  struct Pose
421  {
422  bool m_bvolume; // Is valid
423  bool m_bframe; // Is frame
424  btScalar m_volume; // Rest volume
425  tVector3Array m_pos; // Reference positions
426  tScalarArray m_wgh; // Weights
427  btVector3 m_com; // COM
428  btMatrix3x3 m_rot; // Rotation
429  btMatrix3x3 m_scl; // Scale
430  btMatrix3x3 m_aqq; // Base scaling
431  };
432  /* Cluster */
433  struct Cluster
434  {
451  btScalar m_ndamping; /* Node damping */
452  btScalar m_ldamping; /* Linear damping */
453  btScalar m_adamping; /* Angular damping */
458  bool m_collide;
461  {
462  }
463  };
464  /* Impulse */
465  struct Impulse
466  {
469  int m_asVelocity : 1;
470  int m_asDrift : 1;
471  Impulse() : m_velocity(0, 0, 0), m_drift(0, 0, 0), m_asVelocity(0), m_asDrift(0) {}
473  {
474  Impulse i = *this;
475  i.m_velocity = -i.m_velocity;
476  i.m_drift = -i.m_drift;
477  return (i);
478  }
480  {
481  Impulse i = *this;
482  i.m_velocity *= x;
483  i.m_drift *= x;
484  return (i);
485  }
486  };
487  /* Body */
488  struct Body
489  {
493 
496  Body(const btCollisionObject* colObj) : m_soft(0), m_collisionObject(colObj)
497  {
499  }
500 
501  void activate() const
502  {
503  if (m_rigid)
504  m_rigid->activate();
505  if (m_collisionObject)
507  }
509  {
510  static const btMatrix3x3 iwi(0, 0, 0, 0, 0, 0, 0, 0, 0);
511  if (m_rigid) return (m_rigid->getInvInertiaTensorWorld());
512  if (m_soft) return (m_soft->m_invwi);
513  return (iwi);
514  }
516  {
517  if (m_rigid) return (m_rigid->getInvMass());
518  if (m_soft) return (m_soft->m_imass);
519  return (0);
520  }
521  const btTransform& xform() const
522  {
523  static const btTransform identity = btTransform::getIdentity();
525  if (m_soft) return (m_soft->m_framexform);
526  return (identity);
527  }
529  {
530  if (m_rigid) return (m_rigid->getLinearVelocity());
531  if (m_soft) return (m_soft->m_lv);
532  return (btVector3(0, 0, 0));
533  }
535  {
536  if (m_rigid) return (btCross(m_rigid->getAngularVelocity(), rpos));
537  if (m_soft) return (btCross(m_soft->m_av, rpos));
538  return (btVector3(0, 0, 0));
539  }
541  {
542  if (m_rigid) return (m_rigid->getAngularVelocity());
543  if (m_soft) return (m_soft->m_av);
544  return (btVector3(0, 0, 0));
545  }
546  btVector3 velocity(const btVector3& rpos) const
547  {
548  return (linearVelocity() + angularVelocity(rpos));
549  }
550  void applyVImpulse(const btVector3& impulse, const btVector3& rpos) const
551  {
552  if (m_rigid) m_rigid->applyImpulse(impulse, rpos);
553  if (m_soft) btSoftBody::clusterVImpulse(m_soft, rpos, impulse);
554  }
555  void applyDImpulse(const btVector3& impulse, const btVector3& rpos) const
556  {
557  if (m_rigid) m_rigid->applyImpulse(impulse, rpos);
558  if (m_soft) btSoftBody::clusterDImpulse(m_soft, rpos, impulse);
559  }
560  void applyImpulse(const Impulse& impulse, const btVector3& rpos) const
561  {
562  if (impulse.m_asVelocity)
563  {
564  // printf("impulse.m_velocity = %f,%f,%f\n",impulse.m_velocity.getX(),impulse.m_velocity.getY(),impulse.m_velocity.getZ());
565  applyVImpulse(impulse.m_velocity, rpos);
566  }
567  if (impulse.m_asDrift)
568  {
569  // printf("impulse.m_drift = %f,%f,%f\n",impulse.m_drift.getX(),impulse.m_drift.getY(),impulse.m_drift.getZ());
570  applyDImpulse(impulse.m_drift, rpos);
571  }
572  }
573  void applyVAImpulse(const btVector3& impulse) const
574  {
575  if (m_rigid) m_rigid->applyTorqueImpulse(impulse);
577  }
578  void applyDAImpulse(const btVector3& impulse) const
579  {
580  if (m_rigid) m_rigid->applyTorqueImpulse(impulse);
582  }
583  void applyAImpulse(const Impulse& impulse) const
584  {
585  if (impulse.m_asVelocity) applyVAImpulse(impulse.m_velocity);
586  if (impulse.m_asDrift) applyDAImpulse(impulse.m_drift);
587  }
588  void applyDCImpulse(const btVector3& impulse) const
589  {
590  if (m_rigid) m_rigid->applyCentralImpulse(impulse);
592  }
593  };
594  /* Joint */
595  struct Joint
596  {
597  struct eType
598  {
599  enum _
600  {
601  Linear = 0,
603  Contact
604  };
605  };
606  struct Specs
607  {
608  Specs() : erp(1), cfm(1), split(1) {}
612  };
621  bool m_delete;
622  virtual ~Joint() {}
623  Joint() : m_delete(false) {}
624  virtual void Prepare(btScalar dt, int iterations);
625  virtual void Solve(btScalar dt, btScalar sor) = 0;
626  virtual void Terminate(btScalar dt) = 0;
627  virtual eType::_ Type() const = 0;
628  };
629  /* LJoint */
630  struct LJoint : Joint
631  {
633  {
635  };
637  void Prepare(btScalar dt, int iterations);
638  void Solve(btScalar dt, btScalar sor);
639  void Terminate(btScalar dt);
640  eType::_ Type() const { return (eType::Linear); }
641  };
642  /* AJoint */
643  struct AJoint : Joint
644  {
645  struct IControl
646  {
647  virtual ~IControl() {}
648  virtual void Prepare(AJoint*) {}
649  virtual btScalar Speed(AJoint*, btScalar current) { return (current); }
650  static IControl* Default()
651  {
652  static IControl def;
653  return (&def);
654  }
655  };
657  {
658  Specs() : icontrol(IControl::Default()) {}
661  };
664  void Prepare(btScalar dt, int iterations);
665  void Solve(btScalar dt, btScalar sor);
666  void Terminate(btScalar dt);
667  eType::_ Type() const { return (eType::Angular); }
668  };
669  /* CJoint */
670  struct CJoint : Joint
671  {
672  int m_life;
677  void Prepare(btScalar dt, int iterations);
678  void Solve(btScalar dt, btScalar sor);
679  void Terminate(btScalar dt);
680  eType::_ Type() const { return (eType::Contact); }
681  };
682  /* Config */
683  struct Config
684  {
685  eAeroModel::_ aeromodel; // Aerodynamic model (default: V_Point)
686  btScalar kVCF; // Velocities correction factor (Baumgarte)
687  btScalar kDP; // Damping coefficient [0,1]
688  btScalar kDG; // Drag coefficient [0,+inf]
689  btScalar kLF; // Lift coefficient [0,+inf]
690  btScalar kPR; // Pressure coefficient [-inf,+inf]
691  btScalar kVC; // Volume conversation coefficient [0,+inf]
692  btScalar kDF; // Dynamic friction coefficient [0,1]
693  btScalar kMT; // Pose matching coefficient [0,1]
694  btScalar kCHR; // Rigid contacts hardness [0,1]
695  btScalar kKHR; // Kinetic contacts hardness [0,1]
696  btScalar kSHR; // Soft contacts hardness [0,1]
697  btScalar kAHR; // Anchors hardness [0,1]
698  btScalar kSRHR_CL; // Soft vs rigid hardness [0,1] (cluster only)
699  btScalar kSKHR_CL; // Soft vs kinetic hardness [0,1] (cluster only)
700  btScalar kSSHR_CL; // Soft vs soft hardness [0,1] (cluster only)
701  btScalar kSR_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only)
702  btScalar kSK_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only)
703  btScalar kSS_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only)
704  btScalar maxvolume; // Maximum volume ratio for pose
705  btScalar timescale; // Time scale
706  int viterations; // Velocities solver iterations
707  int piterations; // Positions solver iterations
708  int diterations; // Drift solver iterations
709  int citerations; // Cluster solver iterations
710  int collisions; // Collisions flags
711  tVSolverArray m_vsequence; // Velocity solvers sequence
712  tPSolverArray m_psequence; // Position solvers sequence
713  tPSolverArray m_dsequence; // Drift solvers sequence
714  btScalar drag; // deformable air drag
715  btScalar m_maxStress; // Maximum principle first Piola stress
716  };
717  /* SolverState */
718  struct SolverState
719  {
720  btScalar sdt; // dt*timescale
721  btScalar isdt; // 1/sdt
722  btScalar velmrg; // velocity margin
723  btScalar radmrg; // radial margin
724  btScalar updmrg; // Update margin
725  };
728  {
734  int m_tests;
735  RayFromToCaster(const btVector3& rayFrom, const btVector3& rayTo, btScalar mxt);
736  void Process(const btDbvtNode* leaf);
737 
738  static /*inline*/ btScalar rayFromToTriangle(const btVector3& rayFrom,
739  const btVector3& rayTo,
740  const btVector3& rayNormalizedDirection,
741  const btVector3& a,
742  const btVector3& b,
743  const btVector3& c,
744  btScalar maxt = SIMD_INFINITY);
745  };
746 
747  //
748  // Typedefs
749  //
750 
751  typedef void (*psolver_t)(btSoftBody*, btScalar, btScalar);
752  typedef void (*vsolver_t)(btSoftBody*, btScalar);
766 
767  //
768  // Fields
769  //
770 
771  Config m_cfg; // Configuration
772  SolverState m_sst; // Solver state
773  Pose m_pose; // Pose
774  void* m_tag; // User data
776  tNoteArray m_notes; // Notes
777  tNodeArray m_nodes; // Nodes
779  tLinkArray m_links; // Links
780  tFaceArray m_faces; // Faces
787  tRContactArray m_rcontacts; // Rigid contacts
791  tSContactArray m_scontacts; // Soft contacts
794  btScalar m_timeacc; // Time accumulator
795  btVector3 m_bounds[2]; // Spatial bounds
796  bool m_bUpdateRtCst; // Update runtime constants
797  btDbvt m_ndbvt; // Nodes tree
798  btDbvt m_fdbvt; // Faces tree
799  btDbvt m_cdbvt; // Clusters tree
801  btScalar m_dampingCoefficient; // Damping Coefficient
805  btAlignedObjectArray<btVector3> m_quads; // quadrature points for collision detection
806 
810 
811  btAlignedObjectArray<bool> m_clusterConnectivity; //cluster connectivity, for self-collision
812 
814 
816 
818 
819  //
820  // Api
821  //
822 
823  /* ctor */
824  btSoftBody(btSoftBodyWorldInfo* worldInfo, int node_count, const btVector3* x, const btScalar* m);
825 
826  /* ctor */
827  btSoftBody(btSoftBodyWorldInfo* worldInfo);
828 
829  void initDefaults();
830 
831  /* dtor */
832  virtual ~btSoftBody();
833  /* Check for existing link */
834 
836 
838  {
839  return m_worldInfo;
840  }
841 
842  void setDampingCoefficient(btScalar damping_coeff)
843  {
844  m_dampingCoefficient = damping_coeff;
845  }
846 
847  void setUseFaceContact(bool useFaceContact)
848  {
849  m_useFaceContact = false;
850  }
851 
853  virtual void setCollisionShape(btCollisionShape* collisionShape)
854  {
855  }
856 
857  bool checkLink(int node0,
858  int node1) const;
859  bool checkLink(const Node* node0,
860  const Node* node1) const;
861  /* Check for existring face */
862  bool checkFace(int node0,
863  int node1,
864  int node2) const;
865  /* Append material */
866  Material* appendMaterial();
867  /* Append note */
868  void appendNote(const char* text,
869  const btVector3& o,
870  const btVector4& c = btVector4(1, 0, 0, 0),
871  Node* n0 = 0,
872  Node* n1 = 0,
873  Node* n2 = 0,
874  Node* n3 = 0);
875  void appendNote(const char* text,
876  const btVector3& o,
877  Node* feature);
878  void appendNote(const char* text,
879  const btVector3& o,
880  Link* feature);
881  void appendNote(const char* text,
882  const btVector3& o,
883  Face* feature);
884  /* Append node */
885  void appendNode(const btVector3& x, btScalar m);
886  /* Append link */
887  void appendLink(int model = -1, Material* mat = 0);
888  void appendLink(int node0,
889  int node1,
890  Material* mat = 0,
891  bool bcheckexist = false);
892  void appendLink(Node* node0,
893  Node* node1,
894  Material* mat = 0,
895  bool bcheckexist = false);
896  /* Append face */
897  void appendFace(int model = -1, Material* mat = 0);
898  void appendFace(int node0,
899  int node1,
900  int node2,
901  Material* mat = 0);
902  void appendTetra(int model, Material* mat);
903  //
904  void appendTetra(int node0,
905  int node1,
906  int node2,
907  int node3,
908  Material* mat = 0);
909 
910  /* Append anchor */
911  void appendDeformableAnchor(int node, btRigidBody* body);
912  void appendDeformableAnchor(int node, btMultiBodyLinkCollider* link);
913  void appendAnchor(int node,
914  btRigidBody* body, bool disableCollisionBetweenLinkedBodies = false, btScalar influence = 1);
915  void appendAnchor(int node, btRigidBody* body, const btVector3& localPivot, bool disableCollisionBetweenLinkedBodies = false, btScalar influence = 1);
916  /* Append linear joint */
917  void appendLinearJoint(const LJoint::Specs& specs, Cluster* body0, Body body1);
918  void appendLinearJoint(const LJoint::Specs& specs, Body body = Body());
919  void appendLinearJoint(const LJoint::Specs& specs, btSoftBody* body);
920  /* Append linear joint */
921  void appendAngularJoint(const AJoint::Specs& specs, Cluster* body0, Body body1);
922  void appendAngularJoint(const AJoint::Specs& specs, Body body = Body());
923  void appendAngularJoint(const AJoint::Specs& specs, btSoftBody* body);
924  /* Add force (or gravity) to the entire body */
925  void addForce(const btVector3& force);
926  /* Add force (or gravity) to a node of the body */
927  void addForce(const btVector3& force,
928  int node);
929  /* Add aero force to a node of the body */
930  void addAeroForceToNode(const btVector3& windVelocity, int nodeIndex);
931 
932  /* Add aero force to a face of the body */
933  void addAeroForceToFace(const btVector3& windVelocity, int faceIndex);
934 
935  /* Add velocity to the entire body */
936  void addVelocity(const btVector3& velocity);
937 
938  /* Set velocity for the entire body */
939  void setVelocity(const btVector3& velocity);
940 
941  /* Add velocity to a node of the body */
942  void addVelocity(const btVector3& velocity,
943  int node);
944  /* Set mass */
945  void setMass(int node,
946  btScalar mass);
947  /* Get mass */
948  btScalar getMass(int node) const;
949  /* Get total mass */
950  btScalar getTotalMass() const;
951  /* Set total mass (weighted by previous masses) */
952  void setTotalMass(btScalar mass,
953  bool fromfaces = false);
954  /* Set total density */
955  void setTotalDensity(btScalar density);
956  /* Set volume mass (using tetrahedrons) */
957  void setVolumeMass(btScalar mass);
958  /* Set volume density (using tetrahedrons) */
959  void setVolumeDensity(btScalar density);
960  /* Transform */
961  void transform(const btTransform& trs);
962  /* Translate */
963  void translate(const btVector3& trs);
964  /* Rotate */
965  void rotate(const btQuaternion& rot);
966  /* Scale */
967  void scale(const btVector3& scl);
968  /* Get link resting lengths scale */
970  /* Scale resting length of all springs */
971  void setRestLengthScale(btScalar restLength);
972  /* Set current state as pose */
973  void setPose(bool bvolume,
974  bool bframe);
975  /* Set current link lengths as resting lengths */
976  void resetLinkRestLengths();
977  /* Return the volume */
978  btScalar getVolume() const;
979  /* Cluster count */
981  {
982  btVector3 com(0, 0, 0);
983  for (int i = 0; i < m_nodes.size(); i++)
984  {
985  com += (m_nodes[i].m_x * this->getMass(i));
986  }
987  com /= this->getTotalMass();
988  return com;
989  }
990  int clusterCount() const;
991  /* Cluster center of mass */
992  static btVector3 clusterCom(const Cluster* cluster);
993  btVector3 clusterCom(int cluster) const;
994  /* Cluster velocity at rpos */
995  static btVector3 clusterVelocity(const Cluster* cluster, const btVector3& rpos);
996  /* Cluster impulse */
997  static void clusterVImpulse(Cluster* cluster, const btVector3& rpos, const btVector3& impulse);
998  static void clusterDImpulse(Cluster* cluster, const btVector3& rpos, const btVector3& impulse);
999  static void clusterImpulse(Cluster* cluster, const btVector3& rpos, const Impulse& impulse);
1000  static void clusterVAImpulse(Cluster* cluster, const btVector3& impulse);
1001  static void clusterDAImpulse(Cluster* cluster, const btVector3& impulse);
1002  static void clusterAImpulse(Cluster* cluster, const Impulse& impulse);
1003  static void clusterDCImpulse(Cluster* cluster, const btVector3& impulse);
1004  /* Generate bending constraints based on distance in the adjency graph */
1005  int generateBendingConstraints(int distance,
1006  Material* mat = 0);
1007  /* Randomize constraints to reduce solver bias */
1008  void randomizeConstraints();
1009  /* Release clusters */
1010  void releaseCluster(int index);
1011  void releaseClusters();
1012  /* Generate clusters (K-mean) */
1015  int generateClusters(int k, int maxiterations = 8192);
1016  /* Refine */
1017  void refine(ImplicitFn* ifn, btScalar accurary, bool cut);
1018  /* CutLink */
1019  bool cutLink(int node0, int node1, btScalar position);
1020  bool cutLink(const Node* node0, const Node* node1, btScalar position);
1021 
1023  bool rayTest(const btVector3& rayFrom,
1024  const btVector3& rayTo,
1025  sRayCast& results);
1026  /* Solver presets */
1027  void setSolver(eSolverPresets::_ preset);
1028  /* predictMotion */
1029  void predictMotion(btScalar dt);
1030  /* solveConstraints */
1031  void solveConstraints();
1032  /* staticSolve */
1033  void staticSolve(int iterations);
1034  /* solveCommonConstraints */
1035  static void solveCommonConstraints(btSoftBody** bodies, int count, int iterations);
1036  /* solveClusters */
1037  static void solveClusters(const btAlignedObjectArray<btSoftBody*>& bodies);
1038  /* integrateMotion */
1039  void integrateMotion();
1040  /* defaultCollisionHandlers */
1044  bool useSelfCollision();
1045  void updateDeactivation(btScalar timeStep);
1046  void setZeroVelocity();
1047  bool wantsSleeping();
1048 
1049  //
1050  // Functionality to deal with new accelerated solvers.
1051  //
1052 
1056  void setWindVelocity(const btVector3& velocity);
1057 
1061  const btVector3& getWindVelocity();
1062 
1063  //
1064  // Set the solver that handles this soft body
1065  // Should not be allowed to get out of sync with reality
1066  // Currently called internally on addition to the world
1067  void setSoftBodySolver(btSoftBodySolver* softBodySolver)
1068  {
1069  m_softBodySolver = softBodySolver;
1070  }
1071 
1072  //
1073  // Return the solver that handles this soft body
1074  //
1076  {
1077  return m_softBodySolver;
1078  }
1079 
1080  //
1081  // Return the solver that handles this soft body
1082  //
1084  {
1085  return m_softBodySolver;
1086  }
1087 
1088  //
1089  // Cast
1090  //
1091 
1092  static const btSoftBody* upcast(const btCollisionObject* colObj)
1093  {
1094  if (colObj->getInternalType() == CO_SOFT_BODY)
1095  return (const btSoftBody*)colObj;
1096  return 0;
1097  }
1099  {
1100  if (colObj->getInternalType() == CO_SOFT_BODY)
1101  return (btSoftBody*)colObj;
1102  return 0;
1103  }
1104 
1105  //
1106  // ::btCollisionObject
1107  //
1108 
1109  virtual void getAabb(btVector3& aabbMin, btVector3& aabbMax) const
1110  {
1111  aabbMin = m_bounds[0];
1112  aabbMax = m_bounds[1];
1113  }
1114  //
1115  // Private
1116  //
1117  void pointersToIndices();
1118  void indicesToPointers(const int* map = 0);
1119 
1120  int rayTest(const btVector3& rayFrom, const btVector3& rayTo,
1121  btScalar& mint, eFeature::_& feature, int& index, bool bcountonly) const;
1122  void initializeFaceTree();
1123  btVector3 evaluateCom() const;
1124  bool checkDeformableContact(const btCollisionObjectWrapper* colObjWrap, const btVector3& x, btScalar margin, btSoftBody::sCti& cti, bool predict = false) const;
1125  bool checkDeformableFaceContact(const btCollisionObjectWrapper* colObjWrap, Face& f, btVector3& contact_point, btVector3& bary, btScalar margin, btSoftBody::sCti& cti, bool predict = false) const;
1126  bool checkContact(const btCollisionObjectWrapper* colObjWrap, const btVector3& x, btScalar margin, btSoftBody::sCti& cti) const;
1127  void updateNormals();
1128  void updateBounds();
1129  void updatePose();
1130  void updateConstants();
1131  void updateLinkConstants();
1132  void updateArea(bool averageArea = true);
1133  void initializeClusters();
1134  void updateClusters();
1135  void cleanupClusters();
1136  void prepareClusters(int iterations);
1137  void solveClusters(btScalar sor);
1138  void applyClusters(bool drift);
1139  void dampClusters();
1140  void setSpringStiffness(btScalar k);
1141  void initializeDmInverse();
1142  void updateDeformation();
1143  void advanceDeformation();
1144  void applyForces();
1145  void setMaxStress(btScalar maxStress);
1146  void interpolateRenderMesh();
1147  void setCollisionQuadrature(int N);
1148  static void PSolve_Anchors(btSoftBody* psb, btScalar kst, btScalar ti);
1149  static void PSolve_RContacts(btSoftBody* psb, btScalar kst, btScalar ti);
1150  static void PSolve_SContacts(btSoftBody* psb, btScalar, btScalar ti);
1151  static void PSolve_Links(btSoftBody* psb, btScalar kst, btScalar ti);
1152  static void VSolve_Links(btSoftBody* psb, btScalar kst);
1153  static psolver_t getSolver(ePSolver::_ solver);
1154  static vsolver_t getSolver(eVSolver::_ solver);
1155 
1156  virtual int calculateSerializeBufferSize() const;
1157 
1159  virtual const char* serialize(void* dataBuffer, class btSerializer* serializer) const;
1160 };
1161 
1162 #endif //_BT_SOFT_BODY_H
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:99
#define SIMD_INFINITY
Definition: btScalar.h:544
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
Definition: btVector3.h:918
int size() const
return the number of elements in the array
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
btCollisionObject can be used to manage collision detection objects.
btTransform & getWorldTransform()
int getInternalType() const
reserved for Bullet internal usage
void activate(bool forceActivation=false) const
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:48
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:50
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:60
void applyTorqueImpulse(const btVector3 &torque)
Definition: btRigidBody.h:321
const btVector3 & getAngularVelocity() const
Definition: btRigidBody.h:402
btScalar getInvMass() const
Definition: btRigidBody.h:263
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don't store a rigidbody pointer but a rigidbody ...
Definition: btRigidBody.h:189
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
Definition: btRigidBody.h:326
void applyCentralImpulse(const btVector3 &impulse)
Definition: btRigidBody.h:316
const btVector3 & getLinearVelocity() const
Definition: btRigidBody.h:398
const btMatrix3x3 & getInvInertiaTensorWorld() const
Definition: btRigidBody.h:265
btMultiBodyJacobianData jacobianData_t1
Definition: btSoftBody.h:348
btMultiBodyJacobianData jacobianData_normal
Definition: btSoftBody.h:347
btMultiBodyJacobianData jacobianData_t2
Definition: btSoftBody.h:349
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:73
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
Definition: btSoftBody.cpp:140
bool m_bUpdateRtCst
Definition: btSoftBody.h:796
btScalar m_sleepingThreshold
Definition: btSoftBody.h:802
bool checkFace(int node0, int node1, int node2) const
Definition: btSoftBody.cpp:162
void advanceDeformation()
btAlignedObjectArray< eVSolver::_ > tVSolverArray
Definition: btSoftBody.h:149
void updateClusters()
btDbvt m_cdbvt
Definition: btSoftBody.h:799
void setPose(bool bvolume, bool bframe)
Definition: btSoftBody.cpp:983
bool cutLink(int node0, int node1, btScalar position)
btSoftBodySolver * getSoftBodySolver()
Definition: btSoftBody.h:1075
void appendFace(int model=-1, Material *mat=0)
Definition: btSoftBody.cpp:316
void setMass(int node, btScalar mass)
Definition: btSoftBody.cpp:789
void interpolateRenderMesh()
tJointArray m_joints
Definition: btSoftBody.h:792
btScalar m_dampingCoefficient
Definition: btSoftBody.h:801
btAlignedObjectArray< TetraScratch > m_tetraScratchesTn
Definition: btSoftBody.h:784
void integrateMotion()
btAlignedObjectArray< Tetra > tTetraArray
Definition: btSoftBody.h:759
void appendLinearJoint(const LJoint::Specs &specs, Cluster *body0, Body body1)
Definition: btSoftBody.cpp:507
void setUseFaceContact(bool useFaceContact)
Definition: btSoftBody.h:847
btAlignedObjectArray< SContact > tSContactArray
Definition: btSoftBody.h:762
void scale(const btVector3 &scl)
Definition: btSoftBody.cpp:941
btAlignedObjectArray< bool > m_clusterConnectivity
Definition: btSoftBody.h:811
void defaultCollisionHandler(const btCollisionObjectWrapper *pcoWrap)
btSoftBodyWorldInfo * getWorldInfo()
Definition: btSoftBody.h:837
btScalar getVolume() const
bool rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, sRayCast &results)
Ray casting using rayFrom and rayTo in worldspace, (not direction!)
SolverState m_sst
Definition: btSoftBody.h:772
void addVelocity(const btVector3 &velocity)
Definition: btSoftBody.cpp:760
btAlignedObjectArray< RContact > tRContactArray
Definition: btSoftBody.h:761
void setDampingCoefficient(btScalar damping_coeff)
Definition: btSoftBody.h:842
void predictMotion(btScalar dt)
void setSelfCollision(bool useSelfCollision)
btScalar m_timeacc
Definition: btSoftBody.h:794
Pose m_pose
Definition: btSoftBody.h:773
btAlignedObjectArray< int > m_userIndexMapping
Definition: btSoftBody.h:835
btAlignedObjectArray< Face > tFaceArray
Definition: btSoftBody.h:758
void appendTetra(int model, Material *mat)
Definition: btSoftBody.cpp:356
void setRestLengthScale(btScalar restLength)
Definition: btSoftBody.cpp:968
void rotate(const btQuaternion &rot)
Definition: btSoftBody.cpp:932
void applyClusters(bool drift)
void setZeroVelocity()
static void PSolve_Anchors(btSoftBody *psb, btScalar kst, btScalar ti)
btSoftBodyWorldInfo * m_worldInfo
Definition: btSoftBody.h:775
void setSoftBodySolver(btSoftBodySolver *softBodySolver)
Definition: btSoftBody.h:1067
void updateArea(bool averageArea=true)
void addForce(const btVector3 &force)
Definition: btSoftBody.cpp:560
bool wantsSleeping()
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
Definition: btSoftBody.h:789
static void VSolve_Links(btSoftBody *psb, btScalar kst)
tTetraArray m_tetras
Definition: btSoftBody.h:782
bool useSelfCollision()
btVector3 evaluateCom() const
void setTotalDensity(btScalar density)
Definition: btSoftBody.cpp:849
btAlignedObjectArray< const class btCollisionObject * > m_collisionDisabledObjects
Definition: btSoftBody.h:75
btAlignedObjectArray< Link > tLinkArray
Definition: btSoftBody.h:757
static void clusterDAImpulse(Cluster *cluster, const btVector3 &impulse)
void appendNode(const btVector3 &x, btScalar m)
Definition: btSoftBody.cpp:256
btTransform m_initialWorldTransform
Definition: btSoftBody.h:813
void staticSolve(int iterations)
void setVolumeMass(btScalar mass)
Definition: btSoftBody.cpp:855
btScalar m_restLengthScale
Definition: btSoftBody.h:817
bool checkDeformableContact(const btCollisionObjectWrapper *colObjWrap, const btVector3 &x, btScalar margin, btSoftBody::sCti &cti, bool predict=false) const
void cleanupClusters()
Config m_cfg
Definition: btSoftBody.h:771
void updateDeactivation(btScalar timeStep)
btAlignedObjectArray< TetraScratch > m_tetraScratches
Definition: btSoftBody.h:783
const btVector3 & getWindVelocity()
Return the wind velocity for interaction with the air.
void addAeroForceToFace(const btVector3 &windVelocity, int faceIndex)
Definition: btSoftBody.cpp:664
btAlignedObjectArray< btVector4 > m_renderNodesInterpolationWeights
Definition: btSoftBody.h:807
void appendAngularJoint(const AJoint::Specs &specs, Cluster *body0, Body body1)
Definition: btSoftBody.cpp:533
tFaceArray m_faces
Definition: btSoftBody.h:780
void setVolumeDensity(btScalar density)
Definition: btSoftBody.cpp:885
static void clusterDCImpulse(Cluster *cluster, const btVector3 &impulse)
void transform(const btTransform &trs)
Definition: btSoftBody.cpp:900
static void clusterVAImpulse(Cluster *cluster, const btVector3 &impulse)
btScalar getMass(int node) const
Definition: btSoftBody.cpp:796
tMaterialArray m_materials
Definition: btSoftBody.h:793
void setMaxStress(btScalar maxStress)
void dampClusters()
btSoftBody(btSoftBodyWorldInfo *worldInfo, int node_count, const btVector3 *x, const btScalar *m)
btSoftBody implementation by Nathanael Presson
Definition: btSoftBody.cpp:28
void updateDeformation()
tFaceArray m_renderFaces
Definition: btSoftBody.h:781
void addAeroForceToNode(const btVector3 &windVelocity, int nodeIndex)
Definition: btSoftBody.cpp:575
btAlignedObjectArray< btVector3 > tVector3Array
Definition: btSoftBody.h:215
static btVector3 clusterCom(const Cluster *cluster)
tRContactArray m_rcontacts
Definition: btSoftBody.h:787
void appendAnchor(int node, btRigidBody *body, bool disableCollisionBetweenLinkedBodies=false, btScalar influence=1)
Definition: btSoftBody.cpp:388
btAlignedObjectArray< Node > tNodeArray
Definition: btSoftBody.h:755
btVector3 m_bounds[2]
Definition: btSoftBody.h:795
btScalar m_maxSpeedSquared
Definition: btSoftBody.h:803
void releaseCluster(int index)
void setVelocity(const btVector3 &velocity)
Definition: btSoftBody.cpp:766
tClusterArray m_clusters
Definition: btSoftBody.h:800
btAlignedObjectArray< Joint * > tJointArray
Definition: btSoftBody.h:764
void solveConstraints()
btAlignedObjectArray< DeformableFaceRigidContact > m_faceRigidContacts
Definition: btSoftBody.h:790
int generateClusters(int k, int maxiterations=8192)
generateClusters with k=0 will create a convex cluster for each tetrahedron or triangle otherwise an ...
void releaseClusters()
void refine(ImplicitFn *ifn, btScalar accurary, bool cut)
void setSolver(eSolverPresets::_ preset)
btSoftBodySolver * getSoftBodySolver() const
Definition: btSoftBody.h:1083
Material * appendMaterial()
Definition: btSoftBody.cpp:186
btAlignedObjectArray< DeformableNodeRigidAnchor > m_deformableAnchors
Definition: btSoftBody.h:786
btAlignedObjectArray< Material * > tMaterialArray
Definition: btSoftBody.h:763
btAlignedObjectArray< Anchor > tAnchorArray
Definition: btSoftBody.h:760
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)
Definition: btSoftBody.cpp:198
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
Definition: btSoftBody.h:788
btAlignedObjectArray< btSoftBody * > tSoftBodyArray
Definition: btSoftBody.h:765
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
Definition: btSoftBody.h:808
void pointersToIndices()
tNoteArray m_notes
Definition: btSoftBody.h:776
void updateNormals()
static void clusterDImpulse(Cluster *cluster, const btVector3 &rpos, const btVector3 &impulse)
static btSoftBody * upcast(btCollisionObject *colObj)
Definition: btSoftBody.h:1098
btDbvt m_fdbvt
Definition: btSoftBody.h:798
tLinkArray m_links
Definition: btSoftBody.h:779
void applyForces()
static btVector3 clusterVelocity(const Cluster *cluster, const btVector3 &rpos)
tSContactArray m_scontacts
Definition: btSoftBody.h:791
bool m_useSelfCollision
Definition: btSoftBody.h:809
void * m_tag
Definition: btSoftBody.h:774
void updatePose()
btAlignedObjectArray< btDbvtNode * > tLeafArray
Definition: btSoftBody.h:756
void(* psolver_t)(btSoftBody *, btScalar, btScalar)
Definition: btSoftBody.h:751
static const btSoftBody * upcast(const btCollisionObject *colObj)
Definition: btSoftBody.h:1092
void initializeClusters()
tAnchorArray m_anchors
Definition: btSoftBody.h:785
btScalar getRestLengthScale()
Definition: btSoftBody.cpp:962
btAlignedObjectArray< Note > tNoteArray
Definition: btSoftBody.h:754
void randomizeConstraints()
virtual void setCollisionShape(btCollisionShape *collisionShape)
Definition: btSoftBody.h:853
btVector3 m_windVelocity
Definition: btSoftBody.h:815
btScalar getTotalMass() const
Definition: btSoftBody.cpp:802
bool m_useFaceContact
Definition: btSoftBody.h:804
tNodeArray m_nodes
Definition: btSoftBody.h:777
btAlignedObjectArray< ePSolver::_ > tPSolverArray
Definition: btSoftBody.h:150
void appendLink(int model=-1, Material *mat=0)
Definition: btSoftBody.cpp:276
void setSpringStiffness(btScalar k)
void initializeDmInverse()
void updateConstants()
void setTotalMass(btScalar mass, bool fromfaces=false)
Definition: btSoftBody.cpp:813
virtual ~btSoftBody()
Definition: btSoftBody.cpp:126
void appendDeformableAnchor(int node, btRigidBody *body)
Definition: btSoftBody.cpp:415
void updateLinkConstants()
virtual void getAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
Definition: btSoftBody.h:1109
void(* vsolver_t)(btSoftBody *, btScalar)
Definition: btSoftBody.h:752
tNodeArray m_renderNodes
Definition: btSoftBody.h:778
void initDefaults()
Definition: btSoftBody.cpp:64
btAlignedObjectArray< btVector3 > m_quads
Definition: btSoftBody.h:805
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
Definition: btSoftBody.h:753
void updateBounds()
void setWindVelocity(const btVector3 &velocity)
Set a wind velocity for interaction with the air.
int generateBendingConstraints(int distance, Material *mat=0)
void translate(const btVector3 &trs)
Definition: btSoftBody.cpp:923
btVector3 getCenterOfMass() const
Definition: btSoftBody.h:980
void initializeFaceTree()
btSoftBodySolver * m_softBodySolver
Definition: btSoftBody.h:78
void resetLinkRestLengths()
int clusterCount() const
btAlignedObjectArray< btScalar > tScalarArray
Definition: btSoftBody.h:214
btDbvt m_ndbvt
Definition: btSoftBody.h:797
static void clusterAImpulse(Cluster *cluster, const Impulse &impulse)
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
static const btTransform & getIdentity()
Return an identity transform.
Definition: btTransform.h:197
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes ...
Definition: btDbvt.h:229
btScalar air_density
Definition: btSoftBody.h:47
btDispatcher * m_dispatcher
Definition: btSoftBody.h:53
btScalar water_density
Definition: btSoftBody.h:48
btSparseSdf< 3 > m_sparsesdf
Definition: btSoftBody.h:55
btVector3 m_gravity
Definition: btSoftBody.h:54
btVector3 water_normal
Definition: btSoftBody.h:51
btScalar m_maxDisplacement
Definition: btSoftBody.h:50
btScalar water_offset
Definition: btSoftBody.h:49
btBroadphaseInterface * m_broadphase
Definition: btSoftBody.h:52
virtual btScalar Speed(AJoint *, btScalar current)
Definition: btSoftBody.h:649
virtual void Prepare(AJoint *)
Definition: btSoftBody.h:648
static IControl * Default()
Definition: btSoftBody.h:650
btVector3 m_axis[2]
Definition: btSoftBody.h:662
void Prepare(btScalar dt, int iterations)
void Solve(btScalar dt, btScalar sor)
IControl * m_icontrol
Definition: btSoftBody.h:663
void Terminate(btScalar dt)
eType::_ Type() const
Definition: btSoftBody.h:667
btScalar m_influence
Definition: btSoftBody.h:405
btVector3 m_local
Definition: btSoftBody.h:403
btRigidBody * m_body
Definition: btSoftBody.h:404
btMatrix3x3 m_c0
Definition: btSoftBody.h:406
btScalar invMass() const
Definition: btSoftBody.h:515
Body(Cluster *p)
Definition: btSoftBody.h:495
void applyVImpulse(const btVector3 &impulse, const btVector3 &rpos) const
Definition: btSoftBody.h:550
btVector3 angularVelocity() const
Definition: btSoftBody.h:540
const btTransform & xform() const
Definition: btSoftBody.h:521
btRigidBody * m_rigid
Definition: btSoftBody.h:491
btVector3 linearVelocity() const
Definition: btSoftBody.h:528
btVector3 angularVelocity(const btVector3 &rpos) const
Definition: btSoftBody.h:534
void applyDImpulse(const btVector3 &impulse, const btVector3 &rpos) const
Definition: btSoftBody.h:555
Body(const btCollisionObject *colObj)
Definition: btSoftBody.h:496
btVector3 velocity(const btVector3 &rpos) const
Definition: btSoftBody.h:546
void applyDCImpulse(const btVector3 &impulse) const
Definition: btSoftBody.h:588
void applyDAImpulse(const btVector3 &impulse) const
Definition: btSoftBody.h:578
const btMatrix3x3 & invWorldInertia() const
Definition: btSoftBody.h:508
void activate() const
Definition: btSoftBody.h:501
void applyVAImpulse(const btVector3 &impulse) const
Definition: btSoftBody.h:573
Cluster * m_soft
Definition: btSoftBody.h:490
void applyAImpulse(const Impulse &impulse) const
Definition: btSoftBody.h:583
void applyImpulse(const Impulse &impulse, const btVector3 &rpos) const
Definition: btSoftBody.h:560
const btCollisionObject * m_collisionObject
Definition: btSoftBody.h:492
void Terminate(btScalar dt)
eType::_ Type() const
Definition: btSoftBody.h:680
btVector3 m_rpos[2]
Definition: btSoftBody.h:674
void Prepare(btScalar dt, int iterations)
btVector3 m_normal
Definition: btSoftBody.h:675
btScalar m_friction
Definition: btSoftBody.h:676
void Solve(btScalar dt, btScalar sor)
btVector3 m_dimpulses[2]
Definition: btSoftBody.h:445
tVector3Array m_framerefs
Definition: btSoftBody.h:437
btMatrix3x3 m_invwi
Definition: btSoftBody.h:442
btScalar m_maxSelfCollisionImpulse
Definition: btSoftBody.h:455
btMatrix3x3 m_locii
Definition: btSoftBody.h:441
btAlignedObjectArray< Node * > m_nodes
Definition: btSoftBody.h:436
btDbvtNode * m_leaf
Definition: btSoftBody.h:450
btVector3 m_vimpulses[2]
Definition: btSoftBody.h:444
tScalarArray m_masses
Definition: btSoftBody.h:435
btScalar m_selfCollisionImpulseFactor
Definition: btSoftBody.h:456
btTransform m_framexform
Definition: btSoftBody.h:438
btScalar maxvolume
Definition: btSoftBody.h:704
tPSolverArray m_psequence
Definition: btSoftBody.h:712
tPSolverArray m_dsequence
Definition: btSoftBody.h:713
btScalar kSK_SPLT_CL
Definition: btSoftBody.h:702
btScalar kSS_SPLT_CL
Definition: btSoftBody.h:703
btScalar m_maxStress
Definition: btSoftBody.h:715
eAeroModel::_ aeromodel
Definition: btSoftBody.h:685
btScalar kSR_SPLT_CL
Definition: btSoftBody.h:701
tVSolverArray m_vsequence
Definition: btSoftBody.h:711
btScalar timescale
Definition: btSoftBody.h:705
btVector4 m_pcontact
Definition: btSoftBody.h:291
btVector3 m_normal
Definition: btSoftBody.h:288
Node * m_n[3]
Definition: btSoftBody.h:287
btDbvtNode * m_leaf
Definition: btSoftBody.h:290
Material * m_material
Definition: btSoftBody.h:252
virtual btScalar Eval(const btVector3 &x)=0
Impulse operator*(btScalar x) const
Definition: btSoftBody.h:479
Impulse operator-() const
Definition: btSoftBody.h:472
btVector3 m_velocity
Definition: btSoftBody.h:467
btVector3 m_drift
Definition: btSoftBody.h:618
btVector3 m_sdrift
Definition: btSoftBody.h:619
btScalar m_split
Definition: btSoftBody.h:617
virtual void Solve(btScalar dt, btScalar sor)=0
virtual void Terminate(btScalar dt)=0
btMatrix3x3 m_massmatrix
Definition: btSoftBody.h:620
virtual ~Joint()
Definition: btSoftBody.h:622
btVector3 m_refs[2]
Definition: btSoftBody.h:614
virtual void Prepare(btScalar dt, int iterations)
virtual eType::_ Type() const =0
void Solve(btScalar dt, btScalar sor)
btVector3 m_rpos[2]
Definition: btSoftBody.h:636
eType::_ Type() const
Definition: btSoftBody.h:640
void Prepare(btScalar dt, int iterations)
void Terminate(btScalar dt)
btScalar m_area
Definition: btSoftBody.h:265
btVector3 m_x
Definition: btSoftBody.h:257
btVector3 m_vsplit
Definition: btSoftBody.h:260
btVector3 m_vn
Definition: btSoftBody.h:261
btVector3 m_v
Definition: btSoftBody.h:259
btVector3 m_q
Definition: btSoftBody.h:258
btDbvtNode * m_leaf
Definition: btSoftBody.h:266
btVector3 m_n
Definition: btSoftBody.h:263
btVector3 m_f
Definition: btSoftBody.h:262
btScalar m_coords[4]
Definition: btSoftBody.h:417
btVector3 m_offset
Definition: btSoftBody.h:414
Node * m_nodes[4]
Definition: btSoftBody.h:416
const char * m_text
Definition: btSoftBody.h:413
btMatrix3x3 m_scl
Definition: btSoftBody.h:429
btScalar m_volume
Definition: btSoftBody.h:424
btVector3 m_com
Definition: btSoftBody.h:427
tVector3Array m_pos
Definition: btSoftBody.h:425
btMatrix3x3 m_aqq
Definition: btSoftBody.h:430
btMatrix3x3 m_rot
Definition: btSoftBody.h:428
tScalarArray m_wgh
Definition: btSoftBody.h:426
btMultiBodyJacobianData jacobianData_t2
Definition: btSoftBody.h:331
btMultiBodyJacobianData jacobianData_t1
Definition: btSoftBody.h:330
btMatrix3x3 m_c0
Definition: btSoftBody.h:322
btMultiBodyJacobianData jacobianData_normal
Definition: btSoftBody.h:329
RayFromToCaster takes a ray from, ray to (instead of direction!)
Definition: btSoftBody.h:728
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
Definition: btSoftBody.h:731
btScalar m_cfm[2]
Definition: btSoftBody.h:397
btScalar m_element_measure
Definition: btSoftBody.h:305
btMatrix3x3 m_Dm_inverse
Definition: btSoftBody.h:303
btMatrix3x3 m_F
Definition: btSoftBody.h:304
btVector3 m_c0[4]
Definition: btSoftBody.h:300
btDbvtNode * m_leaf
Definition: btSoftBody.h:299
@ V_TwoSided
Vertex normals are oriented toward velocity.
Definition: btSoftBody.h:90
@ V_OneSided
Vertex normals are flipped to match velocity and lift and drag forces are applied.
Definition: btSoftBody.h:92
@ END
Face normals are taken as it is.
Definition: btSoftBody.h:96
@ V_TwoSidedLiftDrag
Vertex normals are flipped to match velocity.
Definition: btSoftBody.h:91
@ F_OneSided
Face normals are flipped to match velocity and lift and drag forces are applied.
Definition: btSoftBody.h:95
@ F_TwoSided
Vertex normals are taken as it is.
Definition: btSoftBody.h:93
@ F_TwoSidedLiftDrag
Face normals are flipped to match velocity.
Definition: btSoftBody.h:94
ePSolver : positions solvers
Definition: btSoftBody.h:112
@ RContacts
Anchor solver.
Definition: btSoftBody.h:117
@ SContacts
Rigid contacts solver.
Definition: btSoftBody.h:118
@ Anchors
Linear solver.
Definition: btSoftBody.h:116
@ END
Soft contacts solver.
Definition: btSoftBody.h:119
eVSolver : velocities solvers
Definition: btSoftBody.h:102
@ END
Linear solver.
Definition: btSoftBody.h:106
@ VF_SS
Rigid versus soft mask.
Definition: btSoftBody.h:168
@ Default
Vertex vs face soft vs soft handling.
Definition: btSoftBody.h:173
@ VF_DD
Cluster soft body self collision.
Definition: btSoftBody.h:171
@ CL_SS
Vertex vs face soft vs soft handling.
Definition: btSoftBody.h:169
@ CL_SELF
Cluster vs cluster soft vs soft handling.
Definition: btSoftBody.h:170
@ SVSmask
DF based rigid vs deformable faces.
Definition: btSoftBody.h:167
@ SDF_RS
Rigid versus soft mask.
Definition: btSoftBody.h:162
@ SDF_RD
Cluster vs convex rigid vs soft.
Definition: btSoftBody.h:164
@ SDF_RDF
DF based rigid vs deformable.
Definition: btSoftBody.h:165
@ CL_RS
SDF based rigid vs soft.
Definition: btSoftBody.h:163
@ Default
Enable debug draw.
Definition: btSoftBody.h:185
const btCollisionObject * m_colObj
Definition: btSoftBody.h:220
btVector3 m_bary
Definition: btSoftBody.h:223
btScalar m_offset
Definition: btSoftBody.h:222
btVector3 m_normal
Definition: btSoftBody.h:221
btVector3 m_velocity
Definition: btSoftBody.h:229
eFeature::_ feature
soft body
Definition: btSoftBody.h:198
btScalar fraction
feature index
Definition: btSoftBody.h:200
int index
feature type
Definition: btSoftBody.h:199
btSoftBody * body
Definition: btSoftBody.h:197