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