Blender V2.61 - r43446

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 //#define DEBUG_PART_INDEX 1
00032 
00033 
00035 class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result
00036 {
00037 protected:
00038 
00039     btPersistentManifold* m_manifoldPtr;
00040 
00041     //we need this for compounds
00042     btTransform m_rootTransA;
00043     btTransform m_rootTransB;
00044 
00045     btCollisionObject* m_body0;
00046     btCollisionObject* m_body1;
00047     int m_partId0;
00048     int m_partId1;
00049     int m_index0;
00050     int m_index1;
00051     
00052 
00053 public:
00054 
00055     btManifoldResult()
00056 #ifdef DEBUG_PART_INDEX
00057         :
00058     m_partId0(-1),
00059     m_partId1(-1),
00060     m_index0(-1),
00061     m_index1(-1)
00062 #endif //DEBUG_PART_INDEX
00063     {
00064     }
00065 
00066     btManifoldResult(btCollisionObject* body0,btCollisionObject* body1);
00067 
00068     virtual ~btManifoldResult() {};
00069 
00070     void    setPersistentManifold(btPersistentManifold* manifoldPtr)
00071     {
00072         m_manifoldPtr = manifoldPtr;
00073     }
00074 
00075     const btPersistentManifold* getPersistentManifold() const
00076     {
00077         return m_manifoldPtr;
00078     }
00079     btPersistentManifold*   getPersistentManifold()
00080     {
00081         return m_manifoldPtr;
00082     }
00083 
00084     virtual void setShapeIdentifiersA(int partId0,int index0)
00085     {
00086         m_partId0=partId0;
00087         m_index0=index0;
00088     }
00089 
00090     virtual void setShapeIdentifiersB(  int partId1,int index1)
00091     {
00092         m_partId1=partId1;
00093         m_index1=index1;
00094     }
00095 
00096 
00097     virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
00098 
00099     SIMD_FORCE_INLINE   void refreshContactPoints()
00100     {
00101         btAssert(m_manifoldPtr);
00102         if (!m_manifoldPtr->getNumContacts())
00103             return;
00104 
00105         bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
00106 
00107         if (isSwapped)
00108         {
00109             m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA);
00110         } else
00111         {
00112             m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB);
00113         }
00114     }
00115 
00116     const btCollisionObject* getBody0Internal() const
00117     {
00118         return m_body0;
00119     }
00120 
00121     const btCollisionObject* getBody1Internal() const
00122     {
00123         return m_body1;
00124     }
00125     
00126 };
00127 
00128 #endif //MANIFOLD_RESULT_H