bullet: Update to current svn, r2636
[blender.git] / extern / bullet2 / src / BulletCollision / Gimpact / btGImpactCollisionAlgorithm.h
index 8998cd06cf0356915d4d44d8a20db1d53ae61860..f85a94cb4c7d9a99d13d753fefdbd1ff2a71a6d5 100644 (file)
@@ -1,5 +1,5 @@
 /*! \file btGImpactShape.h
-\author Francisco León Nájera
+\author Francisco Leon Najera
 */
 /*
 This source file is part of GIMPACT Library.
@@ -21,10 +21,10 @@ subject to the following restrictions:
 3. This notice may not be removed or altered from any source distribution.
 */
 
-#ifndef BVH_CONCAVE_COLLISION_ALGORITHM_H
-#define BVH_CONCAVE_COLLISION_ALGORITHM_H
+#ifndef BT_GIMPACT_BVH_CONCAVE_COLLISION_ALGORITHM_H
+#define BT_GIMPACT_BVH_CONCAVE_COLLISION_ALGORITHM_H
 
-#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
+#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
 #include "BulletCollision/BroadphaseCollision/btDispatcher.h"
 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
@@ -40,7 +40,7 @@ class btDispatcher;
 #include "BulletCollision/CollisionShapes/btCompoundShape.h"
 #include "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h"
 #include "LinearMath/btIDebugDraw.h"
-
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 
 //! Collision Algorithm for GImpact Shapes
@@ -51,7 +51,7 @@ btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(m_dyna
 btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
  \endcode
 */
-class btGImpactCollisionAlgorithm : public btCollisionAlgorithm
+class btGImpactCollisionAlgorithm : public btActivatingCollisionAlgorithm
 {
 protected:
        btCollisionAlgorithm * m_convex_algorithm;
@@ -65,9 +65,9 @@ protected:
 
 
        //! Creates a new contact point
-       SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(btCollisionObject* body0,btCollisionObject* body1)
+       SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(const btCollisionObject* body0,const btCollisionObject* body1)
        {
-               m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);              
+               m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
                return m_manifoldPtr;
        }
 
@@ -106,38 +106,38 @@ protected:
 
 
        // Call before process collision
-       SIMD_FORCE_INLINE void checkManifold(btCollisionObject* body0,btCollisionObject* body1)
+       SIMD_FORCE_INLINE void checkManifold(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
        {
                if(getLastManifold() == 0)
                {
-                       newContactManifold(body0,body1);
+                       newContactManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
                }
 
                m_resultOut->setPersistentManifold(getLastManifold());
        }
 
        // Call before process collision
-       SIMD_FORCE_INLINE btCollisionAlgorithm * newAlgorithm(btCollisionObject* body0,btCollisionObject* body1)
+       SIMD_FORCE_INLINE btCollisionAlgorithm * newAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
        {
-               checkManifold(body0,body1);
+               checkManifold(body0Wrap,body1Wrap);
 
                btCollisionAlgorithm * convex_algorithm = m_dispatcher->findAlgorithm(
-                               body0,body1,getLastManifold());
+                               body0Wrap,body1Wrap,getLastManifold());
                return convex_algorithm ;
        }
 
        // Call before process collision
-       SIMD_FORCE_INLINE void checkConvexAlgorithm(btCollisionObject* body0,btCollisionObject* body1)
+       SIMD_FORCE_INLINE void checkConvexAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
        {
                if(m_convex_algorithm) return;
-               m_convex_algorithm = newAlgorithm(body0,body1);
+               m_convex_algorithm = newAlgorithm(body0Wrap,body1Wrap);
        }
 
 
 
 
-       void addContactPoint(btCollisionObject * body0,
-                                       btCollisionObject * body1,
+       void addContactPoint(const btCollisionObjectWrapper * body0Wrap,
+                                       const btCollisionObjectWrapper * body1Wrap,
                                        const btVector3 & point,
                                        const btVector3 & normal,
                                        btScalar distance);
@@ -145,62 +145,62 @@ protected:
 //! Collision routines
 //!@{
 
-       void collide_gjk_triangles(btCollisionObject * body0,
-                                 btCollisionObject * body1,
-                                 btGImpactMeshShapePart * shape0,
-                                 btGImpactMeshShapePart * shape1,
+       void collide_gjk_triangles(const btCollisionObjectWrapper* body0Wrap,
+                                 const btCollisionObjectWrapper* body1Wrap,
+                                 const btGImpactMeshShapePart * shape0,
+                                 const btGImpactMeshShapePart * shape1,
                                  const int * pairs, int pair_count);
 
-       void collide_sat_triangles(btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btGImpactMeshShapePart * shape0,
-                                         btGImpactMeshShapePart * shape1,
+       void collide_sat_triangles(const btCollisionObjectWrapper* body0Wrap,
+                                         const btCollisionObjectWrapper* body1Wrap,
+                                         const btGImpactMeshShapePart * shape0,
+                                         const btGImpactMeshShapePart * shape1,
                                          const int * pairs, int pair_count);
 
 
 
 
        void shape_vs_shape_collision(
-                                         btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btCollisionShape * shape0,
-                                         btCollisionShape * shape1);
+                                         const btCollisionObjectWrapper* body0,
+                                         const btCollisionObjectWrapper* body1,
+                                         const btCollisionShape * shape0,
+                                         const btCollisionShape * shape1);
 
-       void convex_vs_convex_collision(btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btCollisionShape * shape0,
-                                         btCollisionShape * shape1);
+       void convex_vs_convex_collision(const btCollisionObjectWrapper* body0Wrap,
+                                         const btCollisionObjectWrapper* body1Wrap,
+                                         const btCollisionShape* shape0,
+                                         const btCollisionShape* shape1);
 
 
 
        void gimpact_vs_gimpact_find_pairs(
                                          const btTransform & trans0,
                                          const btTransform & trans1,
-                                         btGImpactShapeInterface * shape0,
-                                         btGImpactShapeInterface * shape1,btPairSet & pairset);
+                                         const btGImpactShapeInterface * shape0,
+                                         const btGImpactShapeInterface * shape1,btPairSet & pairset);
 
        void gimpact_vs_shape_find_pairs(
                                          const btTransform & trans0,
                                          const btTransform & trans1,
-                                         btGImpactShapeInterface * shape0,
-                                         btCollisionShape * shape1,
+                                         const btGImpactShapeInterface * shape0,
+                                         const btCollisionShape * shape1,
                                          btAlignedObjectArray<int> & collided_primitives);
 
 
        void gimpacttrimeshpart_vs_plane_collision(
-                                         btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btGImpactMeshShapePart * shape0,
-                                         btStaticPlaneShape * shape1,bool swapped);
+                                         const btCollisionObjectWrapper * body0Wrap,
+                                         const btCollisionObjectWrapper * body1Wrap,
+                                         const btGImpactMeshShapePart * shape0,
+                                         const btStaticPlaneShape * shape1,bool swapped);
 
 
 public:
 
-       btGImpactCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+       btGImpactCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
 
        virtual ~btGImpactCollisionAlgorithm();
 
-       virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+       virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
        btScalar        calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
@@ -210,25 +210,29 @@ public:
                        manifoldArray.push_back(m_manifoldPtr);
        }
 
+       btManifoldResult*       internalGetResultOut()
+       {
+               return m_resultOut;
+       }
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
-               virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+               virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btGImpactCollisionAlgorithm));
-                       return new(mem) btGImpactCollisionAlgorithm(ci,body0,body1);
+                       return new(mem) btGImpactCollisionAlgorithm(ci,body0Wrap,body1Wrap);
                }
        };
 
        //! Use this function for register the algorithm externally
        static void registerAlgorithm(btCollisionDispatcher * dispatcher);
-
+#ifdef TRI_COLLISION_PROFILING
        //! Gets the average time in miliseconds of tree collisions
        static float getAverageTreeCollisionTime();
 
        //! Gets the average time in miliseconds of triangle collisions
        static float getAverageTriangleCollisionTime();
-
+#endif //TRI_COLLISION_PROFILING
 
        //! Collides two gimpact shapes
        /*!
@@ -236,26 +240,26 @@ public:
        */
 
 
-       void gimpact_vs_gimpact(btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btGImpactShapeInterface * shape0,
-                                         btGImpactShapeInterface * shape1);
+       void gimpact_vs_gimpact(const btCollisionObjectWrapper* body0Wrap,
+                                         const btCollisionObjectWrapper * body1Wrap,
+                                         const btGImpactShapeInterface * shape0,
+                                         const btGImpactShapeInterface * shape1);
 
-       void gimpact_vs_shape(btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btGImpactShapeInterface * shape0,
-                                         btCollisionShape * shape1,bool swapped);
+       void gimpact_vs_shape(const btCollisionObjectWrapper* body0Wrap,
+                                         const btCollisionObjectWrapper* body1Wrap,
+                                         const btGImpactShapeInterface * shape0,
+                                         const btCollisionShape * shape1,bool swapped);
 
-       void gimpact_vs_compoundshape(btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btGImpactShapeInterface * shape0,
-                                         btCompoundShape * shape1,bool swapped);
+       void gimpact_vs_compoundshape(const btCollisionObjectWrapper * body0Wrap,
+                                         const btCollisionObjectWrapper * body1Wrap,
+                                         const btGImpactShapeInterface * shape0,
+                                         const btCompoundShape * shape1,bool swapped);
 
        void gimpact_vs_concave(
-                                         btCollisionObject * body0,
-                                         btCollisionObject * body1,
-                                         btGImpactShapeInterface * shape0,
-                                         btConcaveShape * shape1,bool swapped);
+                                         const btCollisionObjectWrapper * body0Wrap,
+                                         const btCollisionObjectWrapper * body1Wrap,
+                                         const btGImpactShapeInterface * shape0,
+                                         const btConcaveShape * shape1,bool swapped);
 
 
 
@@ -303,4 +307,4 @@ public:
 
 
 
-#endif //BVH_CONCAVE_COLLISION_ALGORITHM_H
+#endif //BT_GIMPACT_BVH_CONCAVE_COLLISION_ALGORITHM_H