Bullet Collision Detection & Physics Library: btManifoldPoint.h Source File

Bullet Collision Detection & Physics Library

btManifoldPoint.h
Go to the documentation of this file.
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 enum btContactPointFlags
39 {
40 BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED=1,
41 BT_CONTACT_FLAG_HAS_CONTACT_CFM=2,
42 BT_CONTACT_FLAG_HAS_CONTACT_ERP=4,
43 BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING = 8,
44 };
45
48 class btManifoldPoint
49 {
50 public:
51 btManifoldPoint()
52 :m_userPersistentData(0),
53 m_contactPointFlags(0),
54 m_appliedImpulse(0.f),
55 m_appliedImpulseLateral1(0.f),
56 m_appliedImpulseLateral2(0.f),
57 m_contactMotion1(0.f),
58 m_contactMotion2(0.f),
59 m_contactCFM(0.f),
60 m_contactERP(0.f),
61 m_frictionCFM(0.f),
62 m_lifeTime(0)
63 {
64 }
65
66 btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB,
67 const btVector3 &normal,
68 btScalar distance ) :
69 m_localPointA( pointA ),
70 m_localPointB( pointB ),
71 m_normalWorldOnB( normal ),
72 m_distance1( distance ),
73 m_combinedFriction(btScalar(0.)),
74 m_combinedRollingFriction(btScalar(0.)),
75 m_combinedSpinningFriction(btScalar(0.)),
76 m_combinedRestitution(btScalar(0.)),
77 m_userPersistentData(0),
78 m_contactPointFlags(0),
79 m_appliedImpulse(0.f),
80 m_appliedImpulseLateral1(0.f),
81 m_appliedImpulseLateral2(0.f),
82 m_contactMotion1(0.f),
83 m_contactMotion2(0.f),
84 m_contactCFM(0.f),
85 m_contactERP(0.f),
86 m_frictionCFM(0.f),
87 m_lifeTime(0)
88 {
89
90 }
91
92
93
94 btVector3 m_localPointA;
95 btVector3 m_localPointB;
96 btVector3 m_positionWorldOnB;
98 btVector3 m_positionWorldOnA;
99 btVector3 m_normalWorldOnB;
100
101 btScalar m_distance1;
102 btScalar m_combinedFriction;
103 btScalar m_combinedRollingFriction;//torsional friction orthogonal to contact normal, useful to make spheres stop rolling forever
104 btScalar m_combinedSpinningFriction;//torsional friction around contact normal, useful for grasping objects
105 btScalar m_combinedRestitution;
106
107 //BP mod, store contact triangles.
108 int m_partId0;
109 int m_partId1;
110 int m_index0;
111 int m_index1;
112
113 mutable void* m_userPersistentData;
114 //bool m_lateralFrictionInitialized;
115 int m_contactPointFlags;
116
117 btScalar m_appliedImpulse;
118 btScalar m_appliedImpulseLateral1;
119 btScalar m_appliedImpulseLateral2;
120 btScalar m_contactMotion1;
121 btScalar m_contactMotion2;
122
123 union
124 {
125 btScalar m_contactCFM;
126 btScalar m_combinedContactStiffness1;
127 };
128
129 union
130 {
131 btScalar m_contactERP;
132 btScalar m_combinedContactDamping1;
133 };
134
135 btScalar m_frictionCFM;
136
137 int m_lifeTime;//lifetime of the contactpoint in frames
138
139 btVector3 m_lateralFrictionDir1;
140 btVector3 m_lateralFrictionDir2;
141
142
143
144
145 btScalar getDistance() const
146 {
147 return m_distance1;
148 }
149 int getLifeTime() const
150 {
151 return m_lifeTime;
152 }
153
154 const btVector3& getPositionWorldOnA() const {
155 return m_positionWorldOnA;
156 // return m_positionWorldOnB + m_normalWorldOnB * m_distance1;
157 }
158
159 const btVector3& getPositionWorldOnB() const
160 {
161 return m_positionWorldOnB;
162 }
163
164 void setDistance(btScalar dist)
165 {
166 m_distance1 = dist;
167 }
168
170 btScalar getAppliedImpulse() const
171 {
172 return m_appliedImpulse;
173 }
174
175
176
177 };
178
179 #endif //BT_MANIFOLD_CONTACT_POINT_H
btManifoldPoint::m_contactPointFlags
int m_contactPointFlags
Definition: btManifoldPoint.h:115
btTransformUtil.h
btManifoldPoint::getPositionWorldOnA
const btVector3 & getPositionWorldOnA() const
Definition: btManifoldPoint.h:154
btManifoldPoint::m_combinedContactStiffness1
btScalar m_combinedContactStiffness1
Definition: btManifoldPoint.h:126
btManifoldPoint::m_partId1
int m_partId1
Definition: btManifoldPoint.h:109
btManifoldPoint::m_lateralFrictionDir1
btVector3 m_lateralFrictionDir1
Definition: btManifoldPoint.h:139
btVector3.h
btConstraintRow
Definition: btManifoldPoint.h:27
btManifoldPoint::m_appliedImpulseLateral1
btScalar m_appliedImpulseLateral1
Definition: btManifoldPoint.h:118
BT_CONTACT_FLAG_HAS_CONTACT_ERP
Definition: btManifoldPoint.h:42
btManifoldPoint::m_combinedRestitution
btScalar m_combinedRestitution
Definition: btManifoldPoint.h:105
btManifoldPoint::m_contactERP
btScalar m_contactERP
Definition: btManifoldPoint.h:131
BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING
Definition: btManifoldPoint.h:43
btManifoldPoint::m_appliedImpulse
btScalar m_appliedImpulse
Definition: btManifoldPoint.h:117
PfxConstraintRow
btConstraintRow PfxConstraintRow
Definition: btManifoldPoint.h:35
btManifoldPoint::m_frictionCFM
btScalar m_frictionCFM
Definition: btManifoldPoint.h:135
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition: btManifoldPoint.h:48
btManifoldPoint::m_contactMotion1
btScalar m_contactMotion1
Definition: btManifoldPoint.h:120
btManifoldPoint::btManifoldPoint
btManifoldPoint(const btVector3 &pointA, const btVector3 &pointB, const btVector3 &normal, btScalar distance)
Definition: btManifoldPoint.h:66
btManifoldPoint::m_combinedRollingFriction
btScalar m_combinedRollingFriction
Definition: btManifoldPoint.h:103
btManifoldPoint::m_normalWorldOnB
btVector3 m_normalWorldOnB
Definition: btManifoldPoint.h:99
btManifoldPoint::m_userPersistentData
void * m_userPersistentData
Definition: btManifoldPoint.h:113
btManifoldPoint::m_positionWorldOnB
btVector3 m_positionWorldOnB
Definition: btManifoldPoint.h:96
btManifoldPoint::m_localPointA
btVector3 m_localPointA
Definition: btManifoldPoint.h:94
btManifoldPoint::getPositionWorldOnB
const btVector3 & getPositionWorldOnB() const
Definition: btManifoldPoint.h:159
btManifoldPoint::m_appliedImpulseLateral2
btScalar m_appliedImpulseLateral2
Definition: btManifoldPoint.h:119
btContactPointFlags
btContactPointFlags
Definition: btManifoldPoint.h:38
btManifoldPoint::getAppliedImpulse
btScalar getAppliedImpulse() const
this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver...
Definition: btManifoldPoint.h:170
btManifoldPoint::m_lifeTime
int m_lifeTime
Definition: btManifoldPoint.h:137
btConstraintRow::m_accumImpulse
btScalar m_accumImpulse
Definition: btManifoldPoint.h:33
btManifoldPoint::m_positionWorldOnA
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity ...
Definition: btManifoldPoint.h:98
BT_CONTACT_FLAG_HAS_CONTACT_CFM
Definition: btManifoldPoint.h:41
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:65
BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED
Definition: btManifoldPoint.h:40
btConstraintRow::m_lowerLimit
btScalar m_lowerLimit
Definition: btManifoldPoint.h:31
btManifoldPoint::m_contactCFM
btScalar m_contactCFM
Definition: btManifoldPoint.h:125
btManifoldPoint::m_index1
int m_index1
Definition: btManifoldPoint.h:111
btManifoldPoint::m_distance1
btScalar m_distance1
Definition: btManifoldPoint.h:101
btManifoldPoint::m_combinedContactDamping1
btScalar m_combinedContactDamping1
Definition: btManifoldPoint.h:132
btManifoldPoint::m_localPointB
btVector3 m_localPointB
Definition: btManifoldPoint.h:95
btManifoldPoint::setDistance
void setDistance(btScalar dist)
Definition: btManifoldPoint.h:164
btManifoldPoint::m_contactMotion2
btScalar m_contactMotion2
Definition: btManifoldPoint.h:121
btConstraintRow::m_upperLimit
btScalar m_upperLimit
Definition: btManifoldPoint.h:32
btManifoldPoint::m_combinedFriction
btScalar m_combinedFriction
Definition: btManifoldPoint.h:102
btManifoldPoint::btManifoldPoint
btManifoldPoint()
Definition: btManifoldPoint.h:51
btConstraintRow::m_rhs
btScalar m_rhs
Definition: btManifoldPoint.h:29
btConstraintRow::m_jacDiagInv
btScalar m_jacDiagInv
Definition: btManifoldPoint.h:30
btManifoldPoint::m_lateralFrictionDir2
btVector3 m_lateralFrictionDir2
Definition: btManifoldPoint.h:140
btManifoldPoint::getLifeTime
int getLifeTime() const
Definition: btManifoldPoint.h:149
btManifoldPoint::getDistance
btScalar getDistance() const
Definition: btManifoldPoint.h:145
btManifoldPoint::m_partId0
int m_partId0
Definition: btManifoldPoint.h:108
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:279
btManifoldPoint::m_combinedSpinningFriction
btScalar m_combinedSpinningFriction
Definition: btManifoldPoint.h:104
btManifoldPoint::m_index0
int m_index0
Definition: btManifoldPoint.h:110