[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 POINT2POINTCONSTRAINT_H |
---|
| 17 | #define POINT2POINTCONSTRAINT_H |
---|
| 18 | |
---|
| 19 | #include "LinearMath/btVector3.h" |
---|
| 20 | #include "btJacobianEntry.h" |
---|
| 21 | #include "btTypedConstraint.h" |
---|
| 22 | |
---|
| 23 | class btRigidBody; |
---|
| 24 | |
---|
| 25 | struct btConstraintSetting |
---|
| 26 | { |
---|
| 27 | btConstraintSetting() : |
---|
| 28 | m_tau(btScalar(0.3)), |
---|
| 29 | m_damping(btScalar(1.)), |
---|
| 30 | m_impulseClamp(btScalar(0.)) |
---|
| 31 | { |
---|
| 32 | } |
---|
| 33 | btScalar m_tau; |
---|
| 34 | btScalar m_damping; |
---|
| 35 | btScalar m_impulseClamp; |
---|
| 36 | }; |
---|
| 37 | |
---|
| 38 | /// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space |
---|
| 39 | class btPoint2PointConstraint : public btTypedConstraint |
---|
| 40 | { |
---|
| 41 | #ifdef IN_PARALLELL_SOLVER |
---|
| 42 | public: |
---|
| 43 | #endif |
---|
| 44 | btJacobianEntry m_jac[3]; //3 orthogonal linear constraints |
---|
| 45 | |
---|
| 46 | btVector3 m_pivotInA; |
---|
| 47 | btVector3 m_pivotInB; |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | public: |
---|
| 52 | |
---|
| 53 | btConstraintSetting m_setting; |
---|
| 54 | |
---|
| 55 | btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB); |
---|
| 56 | |
---|
| 57 | btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA); |
---|
| 58 | |
---|
| 59 | btPoint2PointConstraint(); |
---|
| 60 | |
---|
| 61 | virtual void buildJacobian(); |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | virtual void solveConstraint(btScalar timeStep); |
---|
| 65 | |
---|
| 66 | void updateRHS(btScalar timeStep); |
---|
| 67 | |
---|
| 68 | void setPivotA(const btVector3& pivotA) |
---|
| 69 | { |
---|
| 70 | m_pivotInA = pivotA; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | void setPivotB(const btVector3& pivotB) |
---|
| 74 | { |
---|
| 75 | m_pivotInB = pivotB; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | const btVector3& getPivotInA() const |
---|
| 79 | { |
---|
| 80 | return m_pivotInA; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | const btVector3& getPivotInB() const |
---|
| 84 | { |
---|
| 85 | return m_pivotInB; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | }; |
---|
| 90 | |
---|
| 91 | #endif //POINT2POINTCONSTRAINT_H |
---|