btSoftBodyData.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 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.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef BT_SOFTBODY_FLOAT_DATA
  14. #define BT_SOFTBODY_FLOAT_DATA
  15. #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
  16. #include "BulletDynamics/Dynamics/btRigidBody.h"
  17. struct SoftBodyMaterialData
  18. {
  19. float m_linearStiffness;
  20. float m_angularStiffness;
  21. float m_volumeStiffness;
  22. int m_flags;
  23. };
  24. struct SoftBodyNodeData
  25. {
  26. SoftBodyMaterialData *m_material;
  27. btVector3FloatData m_position;
  28. btVector3FloatData m_previousPosition;
  29. btVector3FloatData m_velocity;
  30. btVector3FloatData m_accumulatedForce;
  31. btVector3FloatData m_normal;
  32. float m_inverseMass;
  33. float m_area;
  34. int m_attach;
  35. int m_pad;
  36. };
  37. struct SoftBodyLinkData
  38. {
  39. SoftBodyMaterialData *m_material;
  40. int m_nodeIndices[2]; // Node pointers
  41. float m_restLength; // Rest length
  42. int m_bbending; // Bending link
  43. };
  44. struct SoftBodyFaceData
  45. {
  46. btVector3FloatData m_normal; // Normal
  47. SoftBodyMaterialData *m_material;
  48. int m_nodeIndices[3]; // Node pointers
  49. float m_restArea; // Rest area
  50. };
  51. struct SoftBodyTetraData
  52. {
  53. btVector3FloatData m_c0[4]; // gradients
  54. SoftBodyMaterialData *m_material;
  55. int m_nodeIndices[4]; // Node pointers
  56. float m_restVolume; // Rest volume
  57. float m_c1; // (4*kVST)/(im0+im1+im2+im3)
  58. float m_c2; // m_c1/sum(|g0..3|^2)
  59. int m_pad;
  60. };
  61. struct SoftRigidAnchorData
  62. {
  63. btMatrix3x3FloatData m_c0; // Impulse matrix
  64. btVector3FloatData m_c1; // Relative anchor
  65. btVector3FloatData m_localFrame; // Anchor position in body space
  66. btRigidBodyData *m_rigidBody;
  67. int m_nodeIndex; // Node pointer
  68. float m_c2; // ima*dt
  69. };
  70. struct SoftBodyConfigData
  71. {
  72. int m_aeroModel; // Aerodynamic model (default: V_Point)
  73. float m_baumgarte; // Velocities correction factor (Baumgarte)
  74. float m_damping; // Damping coefficient [0,1]
  75. float m_drag; // Drag coefficient [0,+inf]
  76. float m_lift; // Lift coefficient [0,+inf]
  77. float m_pressure; // Pressure coefficient [-inf,+inf]
  78. float m_volume; // Volume conversation coefficient [0,+inf]
  79. float m_dynamicFriction; // Dynamic friction coefficient [0,1]
  80. float m_poseMatch; // Pose matching coefficient [0,1]
  81. float m_rigidContactHardness; // Rigid contacts hardness [0,1]
  82. float m_kineticContactHardness; // Kinetic contacts hardness [0,1]
  83. float m_softContactHardness; // Soft contacts hardness [0,1]
  84. float m_anchorHardness; // Anchors hardness [0,1]
  85. float m_softRigidClusterHardness; // Soft vs rigid hardness [0,1] (cluster only)
  86. float m_softKineticClusterHardness; // Soft vs kinetic hardness [0,1] (cluster only)
  87. float m_softSoftClusterHardness; // Soft vs soft hardness [0,1] (cluster only)
  88. float m_softRigidClusterImpulseSplit; // Soft vs rigid impulse split [0,1] (cluster only)
  89. float m_softKineticClusterImpulseSplit; // Soft vs rigid impulse split [0,1] (cluster only)
  90. float m_softSoftClusterImpulseSplit; // Soft vs rigid impulse split [0,1] (cluster only)
  91. float m_maxVolume; // Maximum volume ratio for pose
  92. float m_timeScale; // Time scale
  93. int m_velocityIterations; // Velocities solver iterations
  94. int m_positionIterations; // Positions solver iterations
  95. int m_driftIterations; // Drift solver iterations
  96. int m_clusterIterations; // Cluster solver iterations
  97. int m_collisionFlags; // Collisions flags
  98. };
  99. struct SoftBodyPoseData
  100. {
  101. btMatrix3x3FloatData m_rot; // Rotation
  102. btMatrix3x3FloatData m_scale; // Scale
  103. btMatrix3x3FloatData m_aqq; // Base scaling
  104. btVector3FloatData m_com; // COM
  105. btVector3FloatData *m_positions; // Reference positions
  106. float *m_weights; // Weights
  107. int m_numPositions;
  108. int m_numWeigts;
  109. int m_bvolume; // Is valid
  110. int m_bframe; // Is frame
  111. float m_restVolume; // Rest volume
  112. int m_pad;
  113. };
  114. struct SoftBodyClusterData
  115. {
  116. btTransformFloatData m_framexform;
  117. btMatrix3x3FloatData m_locii;
  118. btMatrix3x3FloatData m_invwi;
  119. btVector3FloatData m_com;
  120. btVector3FloatData m_vimpulses[2];
  121. btVector3FloatData m_dimpulses[2];
  122. btVector3FloatData m_lv;
  123. btVector3FloatData m_av;
  124. btVector3FloatData *m_framerefs;
  125. int *m_nodeIndices;
  126. float *m_masses;
  127. int m_numFrameRefs;
  128. int m_numNodes;
  129. int m_numMasses;
  130. float m_idmass;
  131. float m_imass;
  132. int m_nvimpulses;
  133. int m_ndimpulses;
  134. float m_ndamping;
  135. float m_ldamping;
  136. float m_adamping;
  137. float m_matching;
  138. float m_maxSelfCollisionImpulse;
  139. float m_selfCollisionImpulseFactor;
  140. int m_containsAnchor;
  141. int m_collide;
  142. int m_clusterIndex;
  143. };
  144. enum btSoftJointBodyType
  145. {
  146. BT_JOINT_SOFT_BODY_CLUSTER = 1,
  147. BT_JOINT_RIGID_BODY,
  148. BT_JOINT_COLLISION_OBJECT
  149. };
  150. struct btSoftBodyJointData
  151. {
  152. void *m_bodyA;
  153. void *m_bodyB;
  154. btVector3FloatData m_refs[2];
  155. float m_cfm;
  156. float m_erp;
  157. float m_split;
  158. int m_delete;
  159. btVector3FloatData m_relPosition[2]; //linear
  160. int m_bodyAtype;
  161. int m_bodyBtype;
  162. int m_jointType;
  163. int m_pad;
  164. };
  165. ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
  166. struct btSoftBodyFloatData
  167. {
  168. btCollisionObjectFloatData m_collisionObjectData;
  169. SoftBodyPoseData *m_pose;
  170. SoftBodyMaterialData **m_materials;
  171. SoftBodyNodeData *m_nodes;
  172. SoftBodyLinkData *m_links;
  173. SoftBodyFaceData *m_faces;
  174. SoftBodyTetraData *m_tetrahedra;
  175. SoftRigidAnchorData *m_anchors;
  176. SoftBodyClusterData *m_clusters;
  177. btSoftBodyJointData *m_joints;
  178. int m_numMaterials;
  179. int m_numNodes;
  180. int m_numLinks;
  181. int m_numFaces;
  182. int m_numTetrahedra;
  183. int m_numAnchors;
  184. int m_numClusters;
  185. int m_numJoints;
  186. SoftBodyConfigData m_config;
  187. };
  188. #endif //BT_SOFTBODY_FLOAT_DATA