SpuContactManifoldCollisionAlgorithm.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com
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 SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H
00017 #define SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H
00018 
00019 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00021 #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
00022 #include "BulletCollision/BroadphaseCollision/btDispatcher.h"
00023 #include "LinearMath/btTransformUtil.h"
00024 
00025 class btPersistentManifold;
00026 
00027 //#define USE_SEPDISTANCE_UTIL 1
00028 
00030 class SpuContactManifoldCollisionAlgorithm : public btCollisionAlgorithm
00031 {
00032         btVector3       m_shapeDimensions0;
00033         btVector3       m_shapeDimensions1;
00034         btPersistentManifold*   m_manifoldPtr;
00035         int             m_shapeType0;
00036         int             m_shapeType1;
00037         float   m_collisionMargin0;
00038         float   m_collisionMargin1;
00039 
00040         btCollisionObject*      m_collisionObject0;
00041         btCollisionObject*      m_collisionObject1;
00042         
00043         
00044 
00045         
00046 public:
00047         
00048         virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
00049 
00050         virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
00051 
00052         
00053         SpuContactManifoldCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
00054 #ifdef USE_SEPDISTANCE_UTIL
00055         btConvexSeparatingDistanceUtil  m_sepDistance;
00056 #endif //USE_SEPDISTANCE_UTIL
00057 
00058         virtual ~SpuContactManifoldCollisionAlgorithm();
00059 
00060         virtual void    getAllContactManifolds(btManifoldArray& manifoldArray)
00061         {
00062                 if (m_manifoldPtr)
00063                         manifoldArray.push_back(m_manifoldPtr);
00064         }
00065 
00066         btPersistentManifold*   getContactManifoldPtr()
00067         {
00068                 return m_manifoldPtr;
00069         }
00070 
00071         btCollisionObject*      getCollisionObject0()
00072         {
00073                 return m_collisionObject0;
00074         }
00075         
00076         btCollisionObject*      getCollisionObject1()
00077         {
00078                 return m_collisionObject1;
00079         }
00080 
00081         int             getShapeType0() const
00082         {
00083                 return m_shapeType0;
00084         }
00085 
00086         int             getShapeType1() const
00087         {
00088                 return m_shapeType1;
00089         }
00090         float   getCollisionMargin0() const
00091         {
00092                 return m_collisionMargin0;
00093         }
00094         float   getCollisionMargin1() const
00095         {
00096                 return m_collisionMargin1;
00097         }
00098 
00099         const btVector3&        getShapeDimensions0() const
00100         {
00101                 return m_shapeDimensions0;
00102         }
00103 
00104         const btVector3&        getShapeDimensions1() const
00105         {
00106                 return m_shapeDimensions1;
00107         }
00108 
00109         struct CreateFunc :public       btCollisionAlgorithmCreateFunc
00110         {
00111                 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
00112                 {
00113                         void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(SpuContactManifoldCollisionAlgorithm));
00114                         return new(mem) SpuContactManifoldCollisionAlgorithm(ci,body0,body1);
00115                 }
00116         };
00117 
00118 };
00119 
00120 #endif //SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H

Generated on Mon Feb 15 22:17:08 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1