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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btManifoldPoint.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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"
24typedef sce::PhysicsEffects::PfxConstraintRow btConstraintRow;
25#else
26// Don't change following order of parameters
27 ATTRIBUTE_ALIGNED16(struct)
28 btConstraintRow
29{
30 btScalar m_normal[3];
31 btScalar m_rhs;
32 btScalar m_jacDiagInv;
33 btScalar m_lowerLimit;
34 btScalar m_upperLimit;
35 btScalar m_accumImpulse;
36};
37 typedef btConstraintRow PfxConstraintRow;
38#endif //PFX_USE_FREE_VECTORMATH
39
40 enum btContactPointFlags
41{
42 BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED = 1,
43 BT_CONTACT_FLAG_HAS_CONTACT_CFM = 2,
44 BT_CONTACT_FLAG_HAS_CONTACT_ERP = 4,
45 BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING = 8,
46 BT_CONTACT_FLAG_FRICTION_ANCHOR = 16,
47};
48
51 class btManifoldPoint
52{
53public:
54 btManifoldPoint()
55 : m_userPersistentData(0),
56 m_contactPointFlags(0),
57 m_appliedImpulse(0.f),
58 m_prevRHS(0.f),
59 m_appliedImpulseLateral1(0.f),
60 m_appliedImpulseLateral2(0.f),
61 m_contactMotion1(0.f),
62 m_contactMotion2(0.f),
63 m_contactCFM(0.f),
64 m_contactERP(0.f),
65 m_frictionCFM(0.f),
66 m_lifeTime(0)
67 {
68 }
69
70 btManifoldPoint(const btVector3& pointA, const btVector3& pointB,
71 const btVector3& normal,
72 btScalar distance) : m_localPointA(pointA),
73 m_localPointB(pointB),
74 m_positionWorldOnB(0,0,0),
75 m_positionWorldOnA(0,0,0),
76 m_normalWorldOnB(normal),
77 m_distance1(distance),
78 m_combinedFriction(btScalar(0.)),
79 m_combinedRollingFriction(btScalar(0.)),
80 m_combinedSpinningFriction(btScalar(0.)),
81 m_combinedRestitution(btScalar(0.)),
82 m_partId0(-1),
83 m_partId1(-1),
84 m_index0(-1),
85 m_index1(-1),
86 m_userPersistentData(0),
87 m_contactPointFlags(0),
88 m_appliedImpulse(0.f),
89 m_prevRHS(0.f),
90 m_appliedImpulseLateral1(0.f),
91 m_appliedImpulseLateral2(0.f),
92 m_contactMotion1(0.f),
93 m_contactMotion2(0.f),
94 m_contactCFM(0.f),
95 m_contactERP(0.f),
96 m_frictionCFM(0.f),
97 m_lifeTime(0),
98 m_lateralFrictionDir1(0,0,0),
99 m_lateralFrictionDir2(0,0,0)
100 {
101 }
102
103 btVector3 m_localPointA;
104 btVector3 m_localPointB;
105 btVector3 m_positionWorldOnB;
107 btVector3 m_positionWorldOnA;
108 btVector3 m_normalWorldOnB;
109
110 btScalar m_distance1;
111 btScalar m_combinedFriction;
112 btScalar m_combinedRollingFriction; //torsional friction orthogonal to contact normal, useful to make spheres stop rolling forever
113 btScalar m_combinedSpinningFriction; //torsional friction around contact normal, useful for grasping objects
114 btScalar m_combinedRestitution;
115
116 //BP mod, store contact triangles.
117 int m_partId0;
118 int m_partId1;
119 int m_index0;
120 int m_index1;
121
122 mutable void* m_userPersistentData;
123 //bool m_lateralFrictionInitialized;
124 int m_contactPointFlags;
125
126 btScalar m_appliedImpulse;
127 btScalar m_prevRHS;
128 btScalar m_appliedImpulseLateral1;
129 btScalar m_appliedImpulseLateral2;
130 btScalar m_contactMotion1;
131 btScalar m_contactMotion2;
132
133 union {
134 btScalar m_contactCFM;
135 btScalar m_combinedContactStiffness1;
136 };
137
138 union {
139 btScalar m_contactERP;
140 btScalar m_combinedContactDamping1;
141 };
142
143 btScalar m_frictionCFM;
144
145 int m_lifeTime; //lifetime of the contactpoint in frames
146
147 btVector3 m_lateralFrictionDir1;
148 btVector3 m_lateralFrictionDir2;
149
150 btScalar getDistance() const
151 {
152 return m_distance1;
153 }
154 int getLifeTime() const
155 {
156 return m_lifeTime;
157 }
158
159 const btVector3& getPositionWorldOnA() const
160 {
161 return m_positionWorldOnA;
162 // return m_positionWorldOnB + m_normalWorldOnB * m_distance1;
163 }
164
165 const btVector3& getPositionWorldOnB() const
166 {
167 return m_positionWorldOnB;
168 }
169
170 void setDistance(btScalar dist)
171 {
172 m_distance1 = dist;
173 }
174
176 btScalar getAppliedImpulse() const
177 {
178 return m_appliedImpulse;
179 }
180};
181
182#endif //BT_MANIFOLD_CONTACT_POINT_H
btContactPointFlags
btContactPointFlags
Definition: btManifoldPoint.h:41
BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED
@ BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED
Definition: btManifoldPoint.h:42
BT_CONTACT_FLAG_HAS_CONTACT_ERP
@ BT_CONTACT_FLAG_HAS_CONTACT_ERP
Definition: btManifoldPoint.h:44
BT_CONTACT_FLAG_HAS_CONTACT_CFM
@ BT_CONTACT_FLAG_HAS_CONTACT_CFM
Definition: btManifoldPoint.h:43
BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING
@ BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING
Definition: btManifoldPoint.h:45
BT_CONTACT_FLAG_FRICTION_ANCHOR
@ BT_CONTACT_FLAG_FRICTION_ANCHOR
Definition: btManifoldPoint.h:46
PfxConstraintRow
btConstraintRow PfxConstraintRow
Definition: btManifoldPoint.h:37
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:99
btTransformUtil.h
btVector3.h
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition: btManifoldPoint.h:52
btManifoldPoint::m_partId0
int m_partId0
Definition: btManifoldPoint.h:117
btManifoldPoint::m_index1
int m_index1
Definition: btManifoldPoint.h:120
btManifoldPoint::btManifoldPoint
btManifoldPoint()
Definition: btManifoldPoint.h:54
btManifoldPoint::m_frictionCFM
btScalar m_frictionCFM
Definition: btManifoldPoint.h:143
btManifoldPoint::m_combinedSpinningFriction
btScalar m_combinedSpinningFriction
Definition: btManifoldPoint.h:113
btManifoldPoint::m_combinedRollingFriction
btScalar m_combinedRollingFriction
Definition: btManifoldPoint.h:112
btManifoldPoint::getDistance
btScalar getDistance() const
Definition: btManifoldPoint.h:150
btManifoldPoint::m_contactPointFlags
int m_contactPointFlags
Definition: btManifoldPoint.h:124
btManifoldPoint::m_combinedContactStiffness1
btScalar m_combinedContactStiffness1
Definition: btManifoldPoint.h:135
btManifoldPoint::getLifeTime
int getLifeTime() const
Definition: btManifoldPoint.h:154
btManifoldPoint::m_combinedRestitution
btScalar m_combinedRestitution
Definition: btManifoldPoint.h:114
btManifoldPoint::m_localPointA
btVector3 m_localPointA
Definition: btManifoldPoint.h:103
btManifoldPoint::m_lateralFrictionDir2
btVector3 m_lateralFrictionDir2
Definition: btManifoldPoint.h:148
btManifoldPoint::m_positionWorldOnA
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity
Definition: btManifoldPoint.h:107
btManifoldPoint::m_index0
int m_index0
Definition: btManifoldPoint.h:119
btManifoldPoint::m_localPointB
btVector3 m_localPointB
Definition: btManifoldPoint.h:104
btManifoldPoint::m_combinedContactDamping1
btScalar m_combinedContactDamping1
Definition: btManifoldPoint.h:140
btManifoldPoint::getPositionWorldOnB
const btVector3 & getPositionWorldOnB() const
Definition: btManifoldPoint.h:165
btManifoldPoint::m_appliedImpulseLateral2
btScalar m_appliedImpulseLateral2
Definition: btManifoldPoint.h:129
btManifoldPoint::getPositionWorldOnA
const btVector3 & getPositionWorldOnA() const
Definition: btManifoldPoint.h:159
btManifoldPoint::m_appliedImpulse
btScalar m_appliedImpulse
Definition: btManifoldPoint.h:126
btManifoldPoint::m_distance1
btScalar m_distance1
Definition: btManifoldPoint.h:110
btManifoldPoint::setDistance
void setDistance(btScalar dist)
Definition: btManifoldPoint.h:170
btManifoldPoint::m_partId1
int m_partId1
Definition: btManifoldPoint.h:118
btManifoldPoint::m_userPersistentData
void * m_userPersistentData
Definition: btManifoldPoint.h:122
btManifoldPoint::m_appliedImpulseLateral1
btScalar m_appliedImpulseLateral1
Definition: btManifoldPoint.h:128
btManifoldPoint::m_prevRHS
btScalar m_prevRHS
Definition: btManifoldPoint.h:127
btManifoldPoint::m_contactCFM
btScalar m_contactCFM
Definition: btManifoldPoint.h:134
btManifoldPoint::m_lifeTime
int m_lifeTime
Definition: btManifoldPoint.h:145
btManifoldPoint::m_normalWorldOnB
btVector3 m_normalWorldOnB
Definition: btManifoldPoint.h:108
btManifoldPoint::m_combinedFriction
btScalar m_combinedFriction
Definition: btManifoldPoint.h:111
btManifoldPoint::m_contactERP
btScalar m_contactERP
Definition: btManifoldPoint.h:139
btManifoldPoint::m_positionWorldOnB
btVector3 m_positionWorldOnB
Definition: btManifoldPoint.h:105
btManifoldPoint::m_contactMotion2
btScalar m_contactMotion2
Definition: btManifoldPoint.h:131
btManifoldPoint::getAppliedImpulse
btScalar getAppliedImpulse() const
this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver
Definition: btManifoldPoint.h:176
btManifoldPoint::m_lateralFrictionDir1
btVector3 m_lateralFrictionDir1
Definition: btManifoldPoint.h:147
btManifoldPoint::m_contactMotion1
btScalar m_contactMotion1
Definition: btManifoldPoint.h:130
btManifoldPoint::btManifoldPoint
btManifoldPoint(const btVector3 &pointA, const btVector3 &pointB, const btVector3 &normal, btScalar distance)
Definition: btManifoldPoint.h:70
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btConstraintRow
Definition: btManifoldPoint.h:29
btConstraintRow::m_jacDiagInv
btScalar m_jacDiagInv
Definition: btManifoldPoint.h:32
btConstraintRow::m_upperLimit
btScalar m_upperLimit
Definition: btManifoldPoint.h:34
btConstraintRow::m_lowerLimit
btScalar m_lowerLimit
Definition: btManifoldPoint.h:33
btConstraintRow::m_accumImpulse
btScalar m_accumImpulse
Definition: btManifoldPoint.h:35
btConstraintRow::m_rhs
btScalar m_rhs
Definition: btManifoldPoint.h:31