2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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:
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.
16 #ifndef BT_MANIFOLD_CONTACT_POINT_H
17 #define BT_MANIFOLD_CONTACT_POINT_H
19 #include "LinearMath/btVector3.h"
20 #include "LinearMath/btTransformUtil.h"
22 #ifdef PFX_USE_FREE_VECTORMATH
23 #include "physics_effects/base_level/solver/pfx_constraint_row.h"
24 typedef sce::PhysicsEffects::PfxConstraintRow btConstraintRow
;
26 // Don't change following order of parameters
27 ATTRIBUTE_ALIGNED16(struct) btConstraintRow
{
30 btScalar m_jacDiagInv
;
31 btScalar m_lowerLimit
;
32 btScalar m_upperLimit
;
33 btScalar m_accumImpulse
;
35 typedef btConstraintRow PfxConstraintRow
;
36 #endif //PFX_USE_FREE_VECTORMATH
38 enum btContactPointFlags
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,
46 /// ManifoldContactPoint collects and maintains persistent contactpoints.
47 /// used to improve stability and performance of rigidbody dynamics response.
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
),
66 btManifoldPoint( const btVector3
&pointA
, const btVector3
&pointB
,
67 const btVector3
&normal
,
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
),
94 btVector3 m_localPointA
;
95 btVector3 m_localPointB
;
96 btVector3 m_positionWorldOnB
;
97 ///m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity
98 btVector3 m_positionWorldOnA
;
99 btVector3 m_normalWorldOnB
;
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
;
107 //BP mod, store contact triangles.
113 mutable void* m_userPersistentData
;
114 //bool m_lateralFrictionInitialized;
115 int m_contactPointFlags
;
117 btScalar m_appliedImpulse
;
118 btScalar m_appliedImpulseLateral1
;
119 btScalar m_appliedImpulseLateral2
;
120 btScalar m_contactMotion1
;
121 btScalar m_contactMotion2
;
125 btScalar m_contactCFM
;
126 btScalar m_combinedContactStiffness1
;
131 btScalar m_contactERP
;
132 btScalar m_combinedContactDamping1
;
135 btScalar m_frictionCFM
;
137 int m_lifeTime
;//lifetime of the contactpoint in frames
139 btVector3 m_lateralFrictionDir1
;
140 btVector3 m_lateralFrictionDir2
;
145 btScalar
getDistance() const
149 int getLifeTime() const
154 const btVector3
& getPositionWorldOnA() const {
155 return m_positionWorldOnA
;
156 // return m_positionWorldOnB + m_normalWorldOnB * m_distance1;
159 const btVector3
& getPositionWorldOnB() const
161 return m_positionWorldOnB
;
164 void setDistance(btScalar dist
)
169 ///this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver
170 btScalar
getAppliedImpulse() const
172 return m_appliedImpulse
;
179 #endif //BT_MANIFOLD_CONTACT_POINT_H