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