Back to index

supertuxkart  0.5+dfsg1
btContactConstraint.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef CONTACT_CONSTRAINT_H
00017 #define CONTACT_CONSTRAINT_H
00018 
00019 //todo: make into a proper class working with the iterative constraint solver
00020 
00021 class btRigidBody;
00022 #include "LinearMath/btVector3.h"
00023 #include "LinearMath/btScalar.h"
00024 struct btContactSolverInfo;
00025 class btManifoldPoint;
00026 
00027 enum {
00028        DEFAULT_CONTACT_SOLVER_TYPE=0,
00029        CONTACT_SOLVER_TYPE1,
00030        CONTACT_SOLVER_TYPE2,
00031        USER_CONTACT_SOLVER_TYPE1,
00032        MAX_CONTACT_SOLVER_TYPES
00033 };
00034 
00035 
00036 typedef btScalar (*ContactSolverFunc)(btRigidBody& body1,
00037                                                                 btRigidBody& body2,
00038                                                                 class btManifoldPoint& contactPoint,
00039                                                                 const btContactSolverInfo& info);
00040 
00042 struct btConstraintPersistentData
00043 {
00044        inline btConstraintPersistentData()
00045        :m_appliedImpulse(btScalar(0.)),
00046        m_prevAppliedImpulse(btScalar(0.)),
00047        m_accumulatedTangentImpulse0(btScalar(0.)),
00048        m_accumulatedTangentImpulse1(btScalar(0.)),
00049        m_jacDiagABInv(btScalar(0.)),
00050        m_persistentLifeTime(0),
00051        m_restitution(btScalar(0.)),
00052        m_friction(btScalar(0.)),
00053        m_penetration(btScalar(0.)),
00054        m_contactSolverFunc(0),
00055        m_frictionSolverFunc(0)
00056        {
00057        }
00058        
00059                                    
00061                      btScalar      m_appliedImpulse;
00062                      btScalar      m_prevAppliedImpulse;
00063                      btScalar      m_accumulatedTangentImpulse0;
00064                      btScalar      m_accumulatedTangentImpulse1;
00065                      
00066                      btScalar      m_jacDiagABInv;
00067                      btScalar      m_jacDiagABInvTangent0;
00068                      btScalar      m_jacDiagABInvTangent1;
00069                      int           m_persistentLifeTime;
00070                      btScalar      m_restitution;
00071                      btScalar      m_friction;
00072                      btScalar      m_penetration;
00073                      btVector3     m_frictionWorldTangential0;
00074                      btVector3     m_frictionWorldTangential1;
00075 
00076                      btVector3     m_frictionAngularComponent0A;
00077                      btVector3     m_frictionAngularComponent0B;
00078                      btVector3     m_frictionAngularComponent1A;
00079                      btVector3     m_frictionAngularComponent1B;
00080 
00081                      //some data doesn't need to be persistent over frames: todo: clean/reuse this
00082                      btVector3     m_angularComponentA;
00083                      btVector3     m_angularComponentB;
00084               
00085                      ContactSolverFunc    m_contactSolverFunc;
00086                      ContactSolverFunc    m_frictionSolverFunc;
00087 
00088 };
00089 
00092 void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1,
00093                       btRigidBody& body2, const btVector3& pos2,
00094                       btScalar distance, const btVector3& normal,btScalar& impulse ,btScalar timeStep);
00095 
00096 
00100 btScalar resolveSingleCollision(
00101        btRigidBody& body1,
00102        btRigidBody& body2,
00103               btManifoldPoint& contactPoint,
00104                const btContactSolverInfo& info);
00105 
00106 btScalar resolveSingleFriction(
00107        btRigidBody& body1,
00108        btRigidBody& body2,
00109        btManifoldPoint& contactPoint,
00110        const btContactSolverInfo& solverInfo
00111               );
00112 
00113 
00114 
00115 btScalar resolveSingleCollisionCombined(
00116        btRigidBody& body1,
00117        btRigidBody& body2,
00118        btManifoldPoint& contactPoint,
00119        const btContactSolverInfo& solverInfo
00120               );
00121 
00122 #endif //CONTACT_CONSTRAINT_H