Back to index

supertuxkart  0.5+dfsg1
btSolverBody.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 BT_SOLVER_BODY_H
00017 #define BT_SOLVER_BODY_H
00018 
00019 class  btRigidBody;
00020 #include "LinearMath/btVector3.h"
00021 #include "LinearMath/btMatrix3x3.h"
00022 #include "BulletDynamics/Dynamics/btRigidBody.h"
00023 #include "LinearMath/btAlignedAllocator.h"
00024 
00025 
00027 ATTRIBUTE_ALIGNED16 (struct)       btSolverBody
00028 {
00029        BT_DECLARE_ALIGNED_ALLOCATOR();
00030        
00031        btVector3            m_angularVelocity;
00032        float                m_angularFactor;
00033        float                m_invMass;
00034        float                m_friction;
00035        btRigidBody*  m_originalBody;
00036        btVector3            m_linearVelocity;
00037        btVector3            m_centerOfMassPosition;
00038        
00039        SIMD_FORCE_INLINE void      getVelocityInLocalPoint(const btVector3& rel_pos, btVector3& velocity ) const
00040        {
00041               velocity = m_linearVelocity + m_angularVelocity.cross(rel_pos);
00042        }
00043 
00044        //Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
00045        SIMD_FORCE_INLINE void internalApplyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
00046        {
00047               m_linearVelocity += linearComponent*impulseMagnitude;
00048               m_angularVelocity += angularComponent*(impulseMagnitude*m_angularFactor);
00049        }
00050 
00051        void   writebackVelocity()
00052        {
00053               if (m_invMass)
00054               {
00055                      m_originalBody->setLinearVelocity(m_linearVelocity);
00056                      m_originalBody->setAngularVelocity(m_angularVelocity);
00057                      //m_originalBody->setCompanionId(-1);
00058               }
00059        }
00060 
00061        void   readVelocity()
00062        {
00063               if (m_invMass)
00064               {
00065                      m_linearVelocity = m_originalBody->getLinearVelocity();
00066                      m_angularVelocity = m_originalBody->getAngularVelocity();
00067               }
00068        }
00069 
00070        
00071 
00072 
00073 };
00074 
00075 #endif //BT_SOLVER_BODY_H
00076