Back to index

supertuxkart  0.5+dfsg1
btManifoldResult.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 
00017 #ifndef MANIFOLD_RESULT_H
00018 #define MANIFOLD_RESULT_H
00019 
00020 class btCollisionObject;
00021 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
00022 class btManifoldPoint;
00023 
00024 #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
00025 
00026 #include "LinearMath/btTransform.h"
00027 
00028 typedef bool (*ContactAddedCallback)(btManifoldPoint& cp,      const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1);
00029 extern ContactAddedCallback        gContactAddedCallback;
00030 
00031 
00032 
00034 class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result
00035 {
00036        btPersistentManifold* m_manifoldPtr;
00037 
00038        //we need this for compounds
00039        btTransform   m_rootTransA;
00040        btTransform   m_rootTransB;
00041 
00042        btCollisionObject* m_body0;
00043        btCollisionObject* m_body1;
00044        int    m_partId0;
00045        int m_partId1;
00046        int m_index0;
00047        int m_index1;
00048 public:
00049 
00050        btManifoldResult()
00051        {
00052        }
00053 
00054        btManifoldResult(btCollisionObject* body0,btCollisionObject* body1);
00055 
00056        virtual ~btManifoldResult() {};
00057 
00058        void   setPersistentManifold(btPersistentManifold* manifoldPtr)
00059        {
00060               m_manifoldPtr = manifoldPtr;
00061        }
00062 
00063        const btPersistentManifold* getPersistentManifold() const
00064        {
00065               return m_manifoldPtr;
00066        }
00067        btPersistentManifold*       getPersistentManifold()
00068        {
00069               return m_manifoldPtr;
00070        }
00071 
00072        virtual void setShapeIdentifiers(int partId0,int index0,       int partId1,int index1)
00073        {
00074                      m_partId0=partId0;
00075                      m_partId1=partId1;
00076                      m_index0=index0;
00077                      m_index1=index1;            
00078        }
00079 
00080        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
00081 
00082        SIMD_FORCE_INLINE    void refreshContactPoints()
00083        {
00084               btAssert(m_manifoldPtr);
00085               if (!m_manifoldPtr->getNumContacts())
00086                      return;
00087 
00088               bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
00089 
00090               if (isSwapped)
00091               {
00092                      m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA);
00093               } else
00094               {
00095                      m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB);
00096               }
00097        }
00098 
00099 
00100 };
00101 
00102 #endif //MANIFOLD_RESULT_H