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 | */ |
---|
15 | |
---|
16 | #ifndef POINT2POINTCONSTRAINT_H |
---|
17 | #define POINT2POINTCONSTRAINT_H |
---|
18 | |
---|
19 | #include "LinearMath/btVector3.h" |
---|
20 | #include "btJacobianEntry.h" |
---|
21 | #include "btTypedConstraint.h" |
---|
22 | |
---|
23 | class btRigidBody; |
---|
24 | |
---|
25 | struct btConstraintSetting |
---|
26 | { |
---|
27 | btConstraintSetting() : |
---|
28 | m_tau(btScalar(0.3)), |
---|
29 | m_damping(btScalar(1.)), |
---|
30 | m_impulseClamp(btScalar(0.)) |
---|
31 | { |
---|
32 | } |
---|
33 | btScalar m_tau; |
---|
34 | btScalar m_damping; |
---|
35 | btScalar m_impulseClamp; |
---|
36 | }; |
---|
37 | |
---|
38 | /// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space |
---|
39 | class btPoint2PointConstraint : public btTypedConstraint |
---|
40 | { |
---|
41 | #ifdef IN_PARALLELL_SOLVER |
---|
42 | public: |
---|
43 | #endif |
---|
44 | btJacobianEntry m_jac[3]; //3 orthogonal linear constraints |
---|
45 | |
---|
46 | btVector3 m_pivotInA; |
---|
47 | btVector3 m_pivotInB; |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | public: |
---|
52 | |
---|
53 | ///for backwards compatibility during the transition to 'getInfo/getInfo2' |
---|
54 | bool m_useSolveConstraintObsolete; |
---|
55 | |
---|
56 | btConstraintSetting m_setting; |
---|
57 | |
---|
58 | btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB); |
---|
59 | |
---|
60 | btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA); |
---|
61 | |
---|
62 | btPoint2PointConstraint(); |
---|
63 | |
---|
64 | virtual void buildJacobian(); |
---|
65 | |
---|
66 | virtual void getInfo1 (btConstraintInfo1* info); |
---|
67 | |
---|
68 | virtual void getInfo2 (btConstraintInfo2* info); |
---|
69 | |
---|
70 | |
---|
71 | virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); |
---|
72 | |
---|
73 | void updateRHS(btScalar timeStep); |
---|
74 | |
---|
75 | void setPivotA(const btVector3& pivotA) |
---|
76 | { |
---|
77 | m_pivotInA = pivotA; |
---|
78 | } |
---|
79 | |
---|
80 | void setPivotB(const btVector3& pivotB) |
---|
81 | { |
---|
82 | m_pivotInB = pivotB; |
---|
83 | } |
---|
84 | |
---|
85 | const btVector3& getPivotInA() const |
---|
86 | { |
---|
87 | return m_pivotInA; |
---|
88 | } |
---|
89 | |
---|
90 | const btVector3& getPivotInB() const |
---|
91 | { |
---|
92 | return m_pivotInB; |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | }; |
---|
97 | |
---|
98 | #endif //POINT2POINTCONSTRAINT_H |
---|