[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / BulletDynamics / Featherstone / btMultiBodySphericalJointLimit.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2018 Erwin Coumans  http://bulletphysics.org
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 */
15
16 ///This file was written by Erwin Coumans
17
18 #ifndef BT_MULTIBODY_SPHERICAL_JOINT_LIMIT_H
19 #define BT_MULTIBODY_SPHERICAL_JOINT_LIMIT_H
20
21 #include "btMultiBodyConstraint.h"
22 struct btSolverInfo;
23
24 class btMultiBodySphericalJointLimit : public btMultiBodyConstraint
25 {
26 protected:
27         btVector3 m_desiredVelocity;
28         btQuaternion m_desiredPosition;
29         bool m_use_multi_dof_params;
30         btVector3 m_kd;
31         btVector3 m_kp;
32         btScalar m_erp;
33         btScalar m_rhsClamp;  //maximum error
34         btVector3 m_maxAppliedImpulseMultiDof;
35         btVector3 m_pivotA;
36         btVector3 m_pivotB;
37         btScalar m_swingxRange;
38         btScalar m_swingyRange;
39         btScalar m_twistRange;
40
41 public:
42         btMultiBodySphericalJointLimit(btMultiBody* body, int link, 
43                 btScalar swingxRange,
44                 btScalar swingyRange,
45                 btScalar twistRange,
46                 btScalar maxAppliedImpulse);
47         
48         virtual ~btMultiBodySphericalJointLimit();
49         virtual void finalizeMultiDof();
50
51         virtual int getIslandIdA() const;
52         virtual int getIslandIdB() const;
53
54         virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
55                                                                           btMultiBodyJacobianData& data,
56                                                                           const btContactSolverInfo& infoGlobal);
57
58         virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.0)
59         {
60                 m_desiredVelocity = velTarget;
61                 m_kd = btVector3(kd, kd, kd);
62                 m_use_multi_dof_params = false;
63         }
64
65         virtual void setVelocityTargetMultiDof(const btVector3& velTarget, const btVector3& kd = btVector3(1.0, 1.0, 1.0))
66         {
67                 m_desiredVelocity = velTarget;
68                 m_kd = kd;
69                 m_use_multi_dof_params = true;
70         }
71
72         virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp =1.f)
73         {
74                 m_desiredPosition = posTarget;
75                 m_kp = btVector3(kp, kp, kp);
76                 m_use_multi_dof_params = false;
77         }
78
79         virtual void setPositionTargetMultiDof(const btQuaternion& posTarget, const btVector3& kp = btVector3(1.f, 1.f, 1.f))
80         {
81                 m_desiredPosition = posTarget;
82                 m_kp = kp;
83                 m_use_multi_dof_params = true;
84         }
85
86         virtual void setErp(btScalar erp)
87         {
88                 m_erp = erp;
89         }
90         virtual btScalar getErp() const
91         {
92                 return m_erp;
93         }
94         virtual void setRhsClamp(btScalar rhsClamp)
95         {
96                 m_rhsClamp = rhsClamp;
97         }
98
99         btScalar getMaxAppliedImpulseMultiDof(int i) const
100         {
101                 return m_maxAppliedImpulseMultiDof[i];
102         }
103
104         void setMaxAppliedImpulseMultiDof(const btVector3& maxImp)
105         {
106                 m_maxAppliedImpulseMultiDof = maxImp;
107                 m_use_multi_dof_params = true;
108         }
109
110
111         virtual void debugDraw(class btIDebugDraw* drawer);
112
113 };
114
115 #endif  //BT_MULTIBODY_SPHERICAL_JOINT_LIMIT_H