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 | |
---|
23 | |
---|
24 | |
---|
25 | |
---|
26 | /// ManifoldContactPoint collects and maintains persistent contactpoints. |
---|
27 | /// used to improve stability and performance of rigidbody dynamics response. |
---|
28 | class btManifoldPoint |
---|
29 | { |
---|
30 | public: |
---|
31 | btManifoldPoint() |
---|
32 | :m_userPersistentData(0), |
---|
33 | m_appliedImpulse(0.f), |
---|
34 | m_lateralFrictionInitialized(false), |
---|
35 | m_appliedImpulseLateral1(0.f), |
---|
36 | m_appliedImpulseLateral2(0.f), |
---|
37 | m_lifeTime(0) |
---|
38 | { |
---|
39 | } |
---|
40 | |
---|
41 | btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB, |
---|
42 | const btVector3 &normal, |
---|
43 | btScalar distance ) : |
---|
44 | m_localPointA( pointA ), |
---|
45 | m_localPointB( pointB ), |
---|
46 | m_normalWorldOnB( normal ), |
---|
47 | m_distance1( distance ), |
---|
48 | m_combinedFriction(btScalar(0.)), |
---|
49 | m_combinedRestitution(btScalar(0.)), |
---|
50 | m_userPersistentData(0), |
---|
51 | m_appliedImpulse(0.f), |
---|
52 | m_lateralFrictionInitialized(false), |
---|
53 | m_appliedImpulseLateral1(0.f), |
---|
54 | m_appliedImpulseLateral2(0.f), |
---|
55 | m_lifeTime(0) |
---|
56 | { |
---|
57 | |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | btVector3 m_localPointA; |
---|
64 | btVector3 m_localPointB; |
---|
65 | btVector3 m_positionWorldOnB; |
---|
66 | ///m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity |
---|
67 | btVector3 m_positionWorldOnA; |
---|
68 | btVector3 m_normalWorldOnB; |
---|
69 | |
---|
70 | btScalar m_distance1; |
---|
71 | btScalar m_combinedFriction; |
---|
72 | btScalar m_combinedRestitution; |
---|
73 | |
---|
74 | //BP mod, store contact triangles. |
---|
75 | int m_partId0; |
---|
76 | int m_partId1; |
---|
77 | int m_index0; |
---|
78 | int m_index1; |
---|
79 | |
---|
80 | mutable void* m_userPersistentData; |
---|
81 | btScalar m_appliedImpulse; |
---|
82 | |
---|
83 | bool m_lateralFrictionInitialized; |
---|
84 | btScalar m_appliedImpulseLateral1; |
---|
85 | btScalar m_appliedImpulseLateral2; |
---|
86 | int m_lifeTime;//lifetime of the contactpoint in frames |
---|
87 | |
---|
88 | btVector3 m_lateralFrictionDir1; |
---|
89 | btVector3 m_lateralFrictionDir2; |
---|
90 | |
---|
91 | btScalar getDistance() const |
---|
92 | { |
---|
93 | return m_distance1; |
---|
94 | } |
---|
95 | int getLifeTime() const |
---|
96 | { |
---|
97 | return m_lifeTime; |
---|
98 | } |
---|
99 | |
---|
100 | const btVector3& getPositionWorldOnA() const { |
---|
101 | return m_positionWorldOnA; |
---|
102 | // return m_positionWorldOnB + m_normalWorldOnB * m_distance1; |
---|
103 | } |
---|
104 | |
---|
105 | const btVector3& getPositionWorldOnB() const |
---|
106 | { |
---|
107 | return m_positionWorldOnB; |
---|
108 | } |
---|
109 | |
---|
110 | void setDistance(btScalar dist) |
---|
111 | { |
---|
112 | m_distance1 = dist; |
---|
113 | } |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | }; |
---|
118 | |
---|
119 | #endif //MANIFOLD_CONTACT_POINT_H |
---|