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 TYPED_CONSTRAINT_H |
---|
17 | #define TYPED_CONSTRAINT_H |
---|
18 | |
---|
19 | class btRigidBody; |
---|
20 | #include "LinearMath/btScalar.h" |
---|
21 | |
---|
22 | enum btTypedConstraintType |
---|
23 | { |
---|
24 | POINT2POINT_CONSTRAINT_TYPE, |
---|
25 | HINGE_CONSTRAINT_TYPE, |
---|
26 | CONETWIST_CONSTRAINT_TYPE, |
---|
27 | D6_CONSTRAINT_TYPE, |
---|
28 | VEHICLE_CONSTRAINT_TYPE, |
---|
29 | SLIDER_CONSTRAINT_TYPE |
---|
30 | }; |
---|
31 | |
---|
32 | ///TypedConstraint is the baseclass for Bullet constraints and vehicles |
---|
33 | class btTypedConstraint |
---|
34 | { |
---|
35 | int m_userConstraintType; |
---|
36 | int m_userConstraintId; |
---|
37 | |
---|
38 | btTypedConstraintType m_constraintType; |
---|
39 | |
---|
40 | btTypedConstraint& operator=(btTypedConstraint& other) |
---|
41 | { |
---|
42 | btAssert(0); |
---|
43 | (void) other; |
---|
44 | return *this; |
---|
45 | } |
---|
46 | |
---|
47 | protected: |
---|
48 | btRigidBody& m_rbA; |
---|
49 | btRigidBody& m_rbB; |
---|
50 | btScalar m_appliedImpulse; |
---|
51 | |
---|
52 | |
---|
53 | public: |
---|
54 | |
---|
55 | btTypedConstraint(btTypedConstraintType type); |
---|
56 | virtual ~btTypedConstraint() {}; |
---|
57 | btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA); |
---|
58 | |
---|
59 | btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB); |
---|
60 | |
---|
61 | virtual void buildJacobian() = 0; |
---|
62 | |
---|
63 | virtual void solveConstraint(btScalar timeStep) = 0; |
---|
64 | |
---|
65 | const btRigidBody& getRigidBodyA() const |
---|
66 | { |
---|
67 | return m_rbA; |
---|
68 | } |
---|
69 | const btRigidBody& getRigidBodyB() const |
---|
70 | { |
---|
71 | return m_rbB; |
---|
72 | } |
---|
73 | |
---|
74 | btRigidBody& getRigidBodyA() |
---|
75 | { |
---|
76 | return m_rbA; |
---|
77 | } |
---|
78 | btRigidBody& getRigidBodyB() |
---|
79 | { |
---|
80 | return m_rbB; |
---|
81 | } |
---|
82 | |
---|
83 | int getUserConstraintType() const |
---|
84 | { |
---|
85 | return m_userConstraintType ; |
---|
86 | } |
---|
87 | |
---|
88 | void setUserConstraintType(int userConstraintType) |
---|
89 | { |
---|
90 | m_userConstraintType = userConstraintType; |
---|
91 | }; |
---|
92 | |
---|
93 | void setUserConstraintId(int uid) |
---|
94 | { |
---|
95 | m_userConstraintId = uid; |
---|
96 | } |
---|
97 | |
---|
98 | int getUserConstraintId() const |
---|
99 | { |
---|
100 | return m_userConstraintId; |
---|
101 | } |
---|
102 | |
---|
103 | int getUid() const |
---|
104 | { |
---|
105 | return m_userConstraintId; |
---|
106 | } |
---|
107 | |
---|
108 | btScalar getAppliedImpulse() const |
---|
109 | { |
---|
110 | return m_appliedImpulse; |
---|
111 | } |
---|
112 | |
---|
113 | btTypedConstraintType getConstraintType () const |
---|
114 | { |
---|
115 | return m_constraintType; |
---|
116 | } |
---|
117 | |
---|
118 | }; |
---|
119 | |
---|
120 | #endif //TYPED_CONSTRAINT_H |
---|