2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
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)
32 btScalar m_jacDiagInv;
33 btScalar m_lowerLimit;
34 btScalar m_upperLimit;
35 btScalar m_accumImpulse;
37 typedef btConstraintRow PfxConstraintRow;
38 #endif //PFX_USE_FREE_VECTORMATH
40 enum btContactPointFlags
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,
49 /// ManifoldContactPoint collects and maintains persistent contactpoints.
50 /// used to improve stability and performance of rigidbody dynamics response.
55 : m_userPersistentData(0),
56 m_contactPointFlags(0),
57 m_appliedImpulse(0.f),
59 m_appliedImpulseLateral1(0.f),
60 m_appliedImpulseLateral2(0.f),
61 m_contactMotion1(0.f),
62 m_contactMotion2(0.f),
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.)),
86 m_userPersistentData(0),
87 m_contactPointFlags(0),
88 m_appliedImpulse(0.f),
90 m_appliedImpulseLateral1(0.f),
91 m_appliedImpulseLateral2(0.f),
92 m_contactMotion1(0.f),
93 m_contactMotion2(0.f),
98 m_lateralFrictionDir1(0,0,0),
99 m_lateralFrictionDir2(0,0,0)
103 btVector3 m_localPointA;
104 btVector3 m_localPointB;
105 btVector3 m_positionWorldOnB;
106 ///m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity
107 btVector3 m_positionWorldOnA;
108 btVector3 m_normalWorldOnB;
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;
116 //BP mod, store contact triangles.
122 mutable void* m_userPersistentData;
123 //bool m_lateralFrictionInitialized;
124 int m_contactPointFlags;
126 btScalar m_appliedImpulse;
128 btScalar m_appliedImpulseLateral1;
129 btScalar m_appliedImpulseLateral2;
130 btScalar m_contactMotion1;
131 btScalar m_contactMotion2;
134 btScalar m_contactCFM;
135 btScalar m_combinedContactStiffness1;
139 btScalar m_contactERP;
140 btScalar m_combinedContactDamping1;
143 btScalar m_frictionCFM;
145 int m_lifeTime; //lifetime of the contactpoint in frames
147 btVector3 m_lateralFrictionDir1;
148 btVector3 m_lateralFrictionDir2;
150 btScalar getDistance() const
154 int getLifeTime() const
159 const btVector3& getPositionWorldOnA() const
161 return m_positionWorldOnA;
162 // return m_positionWorldOnB + m_normalWorldOnB * m_distance1;
165 const btVector3& getPositionWorldOnB() const
167 return m_positionWorldOnB;
170 void setDistance(btScalar dist)
175 ///this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver
176 btScalar getAppliedImpulse() const
178 return m_appliedImpulse;
182 #endif //BT_MANIFOLD_CONTACT_POINT_H