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 MANIFOLD_CONTACT_POINT_H |
---|
17 | #define MANIFOLD_CONTACT_POINT_H |
---|
18 | |
---|
19 | #include "LinearMath/btVector3.h" |
---|
20 | #include "LinearMath/btTransformUtil.h" |
---|
21 | |
---|
22 | // Don't change following order of parameters |
---|
23 | ATTRIBUTE_ALIGNED16(struct) PfxConstraintRow { |
---|
24 | btScalar mNormal[3]; |
---|
25 | btScalar mRhs; |
---|
26 | btScalar mJacDiagInv; |
---|
27 | btScalar mLowerLimit; |
---|
28 | btScalar mUpperLimit; |
---|
29 | btScalar mAccumImpulse; |
---|
30 | }; |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | |
---|
35 | /// ManifoldContactPoint collects and maintains persistent contactpoints. |
---|
36 | /// used to improve stability and performance of rigidbody dynamics response. |
---|
37 | class btManifoldPoint |
---|
38 | { |
---|
39 | public: |
---|
40 | btManifoldPoint() |
---|
41 | :m_userPersistentData(0), |
---|
42 | m_appliedImpulse(0.f), |
---|
43 | m_lateralFrictionInitialized(false), |
---|
44 | m_appliedImpulseLateral1(0.f), |
---|
45 | m_appliedImpulseLateral2(0.f), |
---|
46 | m_contactMotion1(0.f), |
---|
47 | m_contactMotion2(0.f), |
---|
48 | m_contactCFM1(0.f), |
---|
49 | m_contactCFM2(0.f), |
---|
50 | m_lifeTime(0) |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB, |
---|
55 | const btVector3 &normal, |
---|
56 | btScalar distance ) : |
---|
57 | m_localPointA( pointA ), |
---|
58 | m_localPointB( pointB ), |
---|
59 | m_normalWorldOnB( normal ), |
---|
60 | m_distance1( distance ), |
---|
61 | m_combinedFriction(btScalar(0.)), |
---|
62 | m_combinedRestitution(btScalar(0.)), |
---|
63 | m_userPersistentData(0), |
---|
64 | m_appliedImpulse(0.f), |
---|
65 | m_lateralFrictionInitialized(false), |
---|
66 | m_appliedImpulseLateral1(0.f), |
---|
67 | m_appliedImpulseLateral2(0.f), |
---|
68 | m_contactMotion1(0.f), |
---|
69 | m_contactMotion2(0.f), |
---|
70 | m_contactCFM1(0.f), |
---|
71 | m_contactCFM2(0.f), |
---|
72 | m_lifeTime(0) |
---|
73 | { |
---|
74 | mConstraintRow[0].mAccumImpulse = 0.f; |
---|
75 | mConstraintRow[1].mAccumImpulse = 0.f; |
---|
76 | mConstraintRow[2].mAccumImpulse = 0.f; |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | btVector3 m_localPointA; |
---|
82 | btVector3 m_localPointB; |
---|
83 | btVector3 m_positionWorldOnB; |
---|
84 | ///m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity |
---|
85 | btVector3 m_positionWorldOnA; |
---|
86 | btVector3 m_normalWorldOnB; |
---|
87 | |
---|
88 | btScalar m_distance1; |
---|
89 | btScalar m_combinedFriction; |
---|
90 | btScalar m_combinedRestitution; |
---|
91 | |
---|
92 | //BP mod, store contact triangles. |
---|
93 | int m_partId0; |
---|
94 | int m_partId1; |
---|
95 | int m_index0; |
---|
96 | int m_index1; |
---|
97 | |
---|
98 | mutable void* m_userPersistentData; |
---|
99 | btScalar m_appliedImpulse; |
---|
100 | |
---|
101 | bool m_lateralFrictionInitialized; |
---|
102 | btScalar m_appliedImpulseLateral1; |
---|
103 | btScalar m_appliedImpulseLateral2; |
---|
104 | btScalar m_contactMotion1; |
---|
105 | btScalar m_contactMotion2; |
---|
106 | btScalar m_contactCFM1; |
---|
107 | btScalar m_contactCFM2; |
---|
108 | |
---|
109 | int m_lifeTime;//lifetime of the contactpoint in frames |
---|
110 | |
---|
111 | btVector3 m_lateralFrictionDir1; |
---|
112 | btVector3 m_lateralFrictionDir2; |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | PfxConstraintRow mConstraintRow[3]; |
---|
117 | |
---|
118 | |
---|
119 | btScalar getDistance() const |
---|
120 | { |
---|
121 | return m_distance1; |
---|
122 | } |
---|
123 | int getLifeTime() const |
---|
124 | { |
---|
125 | return m_lifeTime; |
---|
126 | } |
---|
127 | |
---|
128 | const btVector3& getPositionWorldOnA() const { |
---|
129 | return m_positionWorldOnA; |
---|
130 | // return m_positionWorldOnB + m_normalWorldOnB * m_distance1; |
---|
131 | } |
---|
132 | |
---|
133 | const btVector3& getPositionWorldOnB() const |
---|
134 | { |
---|
135 | return m_positionWorldOnB; |
---|
136 | } |
---|
137 | |
---|
138 | void setDistance(btScalar dist) |
---|
139 | { |
---|
140 | m_distance1 = dist; |
---|
141 | } |
---|
142 | |
---|
143 | ///this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver |
---|
144 | btScalar getAppliedImpulse() const |
---|
145 | { |
---|
146 | return m_appliedImpulse; |
---|
147 | } |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | }; |
---|
152 | |
---|
153 | #endif //MANIFOLD_CONTACT_POINT_H |
---|