[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / RigidBody / b3GpuGenericConstraint.h
1 /*
2 Copyright (c) 2013 Advanced Micro Devices, Inc.  
3
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
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 //Originally written by Erwin Coumans
15
16 #ifndef B3_GPU_GENERIC_CONSTRAINT_H
17 #define B3_GPU_GENERIC_CONSTRAINT_H
18
19 #include "Bullet3Common/b3Quaternion.h"
20 struct b3RigidBodyData;
21 enum B3_CONSTRAINT_FLAGS
22 {
23         B3_CONSTRAINT_FLAG_ENABLED = 1,
24 };
25
26 enum b3GpuGenericConstraintType
27 {
28         B3_GPU_POINT2POINT_CONSTRAINT_TYPE = 3,
29         B3_GPU_FIXED_CONSTRAINT_TYPE = 4,
30         //      B3_HINGE_CONSTRAINT_TYPE,
31         //      B3_CONETWIST_CONSTRAINT_TYPE,
32         //      B3_D6_CONSTRAINT_TYPE,
33         //      B3_SLIDER_CONSTRAINT_TYPE,
34         //      B3_CONTACT_CONSTRAINT_TYPE,
35         //      B3_D6_SPRING_CONSTRAINT_TYPE,
36         //      B3_GEAR_CONSTRAINT_TYPE,
37
38         B3_GPU_MAX_CONSTRAINT_TYPE
39 };
40
41 struct b3GpuConstraintInfo2
42 {
43         // integrator parameters: frames per second (1/stepsize), default error
44         // reduction parameter (0..1).
45         b3Scalar fps, erp;
46
47         // for the first and second body, pointers to two (linear and angular)
48         // n*3 jacobian sub matrices, stored by rows. these matrices will have
49         // been initialized to 0 on entry. if the second body is zero then the
50         // J2xx pointers may be 0.
51         b3Scalar *m_J1linearAxis, *m_J1angularAxis, *m_J2linearAxis, *m_J2angularAxis;
52
53         // elements to jump from one row to the next in J's
54         int rowskip;
55
56         // right hand sides of the equation J*v = c + cfm * lambda. cfm is the
57         // "constraint force mixing" vector. c is set to zero on entry, cfm is
58         // set to a constant value (typically very small or zero) value on entry.
59         b3Scalar *m_constraintError, *cfm;
60
61         // lo and hi limits for variables (set to -/+ infinity on entry).
62         b3Scalar *m_lowerLimit, *m_upperLimit;
63
64         // findex vector for variables. see the LCP solver interface for a
65         // description of what this does. this is set to -1 on entry.
66         // note that the returned indexes are relative to the first index of
67         // the constraint.
68         int* findex;
69         // number of solver iterations
70         int m_numIterations;
71
72         //damping of the velocity
73         b3Scalar m_damping;
74 };
75
76 B3_ATTRIBUTE_ALIGNED16(struct)
77 b3GpuGenericConstraint
78 {
79         int m_constraintType;
80         int m_rbA;
81         int m_rbB;
82         float m_breakingImpulseThreshold;
83
84         b3Vector3 m_pivotInA;
85         b3Vector3 m_pivotInB;
86         b3Quaternion m_relTargetAB;
87
88         int m_flags;
89         int m_uid;
90         int m_padding[2];
91
92         int getRigidBodyA() const
93         {
94                 return m_rbA;
95         }
96         int getRigidBodyB() const
97         {
98                 return m_rbB;
99         }
100
101         const b3Vector3& getPivotInA() const
102         {
103                 return m_pivotInA;
104         }
105
106         const b3Vector3& getPivotInB() const
107         {
108                 return m_pivotInB;
109         }
110
111         int isEnabled() const
112         {
113                 return m_flags & B3_CONSTRAINT_FLAG_ENABLED;
114         }
115
116         float getBreakingImpulseThreshold() const
117         {
118                 return m_breakingImpulseThreshold;
119         }
120
121         ///internal method used by the constraint solver, don't use them directly
122         void getInfo1(unsigned int* info, const b3RigidBodyData* bodies);
123
124         ///internal method used by the constraint solver, don't use them directly
125         void getInfo2(b3GpuConstraintInfo2 * info, const b3RigidBodyData* bodies);
126 };
127
128 #endif  //B3_GPU_GENERIC_CONSTRAINT_H