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