bullet: Update to current svn, r2636
authorSergej Reich <sergej.reich@googlemail.com>
Thu, 7 Mar 2013 17:53:16 +0000 (17:53 +0000)
committerSergej Reich <sergej.reich@googlemail.com>
Thu, 7 Mar 2013 17:53:16 +0000 (17:53 +0000)
Apply patches in patches directory, remove patches that were applied
upstream.
If you made changes without adding a patch, please check.

Fixes [#32233] exporting bullet format results in corrupt files.

175 files changed:
extern/bullet2/CMakeLists.txt
extern/bullet2/patches/make_id.patch [deleted file]
extern/bullet2/patches/pvs_warning_fixes.patch [deleted file]
extern/bullet2/readme.txt
extern/bullet2/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h
extern/bullet2/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/BroadphaseCollision/btDbvt.h
extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h [new file with mode: 0644]
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btManifoldResult.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/CollisionShapes/btBox2dShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btConvex2dShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPolyhedron.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPolyhedron.h
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btShapeHull.h
extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h
extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleInfoMap.h
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.h
extern/bullet2/src/BulletCollision/Gimpact/btBoxCollision.h
extern/bullet2/src/BulletCollision/Gimpact/btCompoundFromGimpact.h
extern/bullet2/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h
extern/bullet2/src/BulletCollision/Gimpact/gim_array.h
extern/bullet2/src/BulletCollision/Gimpact/gim_box_collision.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h
extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.cpp [new file with mode: 0644]
extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h [new file with mode: 0644]
extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp [changed mode: 0644->0755]
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h [changed mode: 0644->0755]
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
extern/bullet2/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h
extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.cpp
extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp
extern/bullet2/src/BulletSoftBody/btDefaultSoftBodySolver.cpp
extern/bullet2/src/BulletSoftBody/btDefaultSoftBodySolver.h
extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
extern/bullet2/src/BulletSoftBody/btSoftBody.h
extern/bullet2/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp
extern/bullet2/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h
extern/bullet2/src/BulletSoftBody/btSoftBodyData.h
extern/bullet2/src/BulletSoftBody/btSoftBodyInternals.h
extern/bullet2/src/BulletSoftBody/btSoftBodySolvers.h
extern/bullet2/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp
extern/bullet2/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.h
extern/bullet2/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp
extern/bullet2/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp
extern/bullet2/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.h
extern/bullet2/src/BulletSoftBody/btSparseSDF.h
extern/bullet2/src/LinearMath/btAabbUtil2.h
extern/bullet2/src/LinearMath/btAlignedAllocator.cpp
extern/bullet2/src/LinearMath/btAlignedObjectArray.h
extern/bullet2/src/LinearMath/btConvexHull.cpp
extern/bullet2/src/LinearMath/btConvexHullComputer.cpp
extern/bullet2/src/LinearMath/btDefaultMotionState.h
extern/bullet2/src/LinearMath/btGrahamScan2dConvexHull.h
extern/bullet2/src/LinearMath/btIDebugDraw.h
extern/bullet2/src/LinearMath/btMatrix3x3.h
extern/bullet2/src/LinearMath/btPolarDecomposition.cpp [new file with mode: 0644]
extern/bullet2/src/LinearMath/btPolarDecomposition.h [new file with mode: 0644]
extern/bullet2/src/LinearMath/btQuadWord.h
extern/bullet2/src/LinearMath/btQuaternion.h
extern/bullet2/src/LinearMath/btScalar.h
extern/bullet2/src/LinearMath/btSerializer.cpp
extern/bullet2/src/LinearMath/btSerializer.h
extern/bullet2/src/LinearMath/btTransform.h
extern/bullet2/src/LinearMath/btVector3.cpp [new file with mode: 0644]
extern/bullet2/src/LinearMath/btVector3.h
extern/bullet2/src/btBulletCollisionCommon.h
extern/bullet2/src/btBulletDynamicsCommon.h
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index 3d75794798005d5aeda345f0f96a690fa47ae26a..02ca2cd375591c7d4c4825fa8b04d5e453201c37 100644 (file)
@@ -139,6 +139,7 @@ set(SRC
        src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
        src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
        src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp
        src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
        src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
        src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp
+       src/BulletDynamics/ConstraintSolver/btGearConstraint.cpp
        src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
        src/BulletDynamics/Dynamics/btRigidBody.cpp
        src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
        src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
        src/BulletDynamics/Dynamics/btRigidBody.cpp
        src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
@@ -162,6 +163,8 @@ set(SRC
        src/LinearMath/btGeometryUtil.cpp
        src/LinearMath/btQuickprof.cpp
        src/LinearMath/btSerializer.cpp
        src/LinearMath/btGeometryUtil.cpp
        src/LinearMath/btQuickprof.cpp
        src/LinearMath/btSerializer.cpp
+       src/LinearMath/btVector3.cpp
+       src/LinearMath/btPolarDecomposition.cpp
        
        
        src/BulletCollision/BroadphaseCollision/btAxisSweep3.h
        
        
        src/BulletCollision/BroadphaseCollision/btAxisSweep3.h
@@ -183,6 +186,7 @@ set(SRC
        src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
        src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
        src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
        src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
        src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
        src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
+       src/BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h
        src/BulletCollision/CollisionDispatch/btCollisionObject.h
        src/BulletCollision/CollisionDispatch/btCollisionWorld.h
        src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
        src/BulletCollision/CollisionDispatch/btCollisionObject.h
        src/BulletCollision/CollisionDispatch/btCollisionWorld.h
        src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
@@ -303,6 +307,7 @@ set(SRC
        src/BulletDynamics/ConstraintSolver/btSolverConstraint.h
        src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
        src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h
        src/BulletDynamics/ConstraintSolver/btSolverConstraint.h
        src/BulletDynamics/ConstraintSolver/btTypedConstraint.h
        src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h
+       src/BulletDynamics/ConstraintSolver/btGearConstraint.h
        src/BulletDynamics/Dynamics/btActionInterface.h
        src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
        src/BulletDynamics/Dynamics/btDynamicsWorld.h
        src/BulletDynamics/Dynamics/btActionInterface.h
        src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
        src/BulletDynamics/Dynamics/btDynamicsWorld.h
@@ -353,6 +358,7 @@ set(SRC
        src/LinearMath/btTransform.h
        src/LinearMath/btTransformUtil.h
        src/LinearMath/btVector3.h
        src/LinearMath/btTransform.h
        src/LinearMath/btTransformUtil.h
        src/LinearMath/btVector3.h
+       src/LinearMath/btPolarDecomposition.h
        
        
        src/btBulletCollisionCommon.h
        
        
        src/btBulletCollisionCommon.h
diff --git a/extern/bullet2/patches/make_id.patch b/extern/bullet2/patches/make_id.patch
deleted file mode 100644 (file)
index 959e578..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-Index: src/LinearMath/btSerializer.h
-===================================================================
---- src/LinearMath/btSerializer.h      (revision 46625)
-+++ src/LinearMath/btSerializer.h      (working copy)
-@@ -106,23 +106,23 @@
- #define BT_HEADER_LENGTH 12
- #if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
--#     define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
-+#     define BT_MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
- #else
--#     define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
-+#     define BT_MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
- #endif
--#define BT_SOFTBODY_CODE              MAKE_ID('S','B','D','Y')
--#define BT_COLLISIONOBJECT_CODE MAKE_ID('C','O','B','J')
--#define BT_RIGIDBODY_CODE             MAKE_ID('R','B','D','Y')
--#define BT_CONSTRAINT_CODE            MAKE_ID('C','O','N','S')
--#define BT_BOXSHAPE_CODE              MAKE_ID('B','O','X','S')
--#define BT_QUANTIZED_BVH_CODE MAKE_ID('Q','B','V','H')
--#define BT_TRIANLGE_INFO_MAP  MAKE_ID('T','M','A','P')
--#define BT_SHAPE_CODE                 MAKE_ID('S','H','A','P')
--#define BT_ARRAY_CODE                 MAKE_ID('A','R','A','Y')
--#define BT_SBMATERIAL_CODE            MAKE_ID('S','B','M','T')
--#define BT_SBNODE_CODE                        MAKE_ID('S','B','N','D')
--#define BT_DNA_CODE                           MAKE_ID('D','N','A','1')
-+#define BT_SOFTBODY_CODE              BT_MAKE_ID('S','B','D','Y')
-+#define BT_COLLISIONOBJECT_CODE BT_MAKE_ID('C','O','B','J')
-+#define BT_RIGIDBODY_CODE             BT_MAKE_ID('R','B','D','Y')
-+#define BT_CONSTRAINT_CODE            BT_MAKE_ID('C','O','N','S')
-+#define BT_BOXSHAPE_CODE              BT_MAKE_ID('B','O','X','S')
-+#define BT_QUANTIZED_BVH_CODE BT_MAKE_ID('Q','B','V','H')
-+#define BT_TRIANLGE_INFO_MAP  BT_MAKE_ID('T','M','A','P')
-+#define BT_SHAPE_CODE                 BT_MAKE_ID('S','H','A','P')
-+#define BT_ARRAY_CODE                 BT_MAKE_ID('A','R','A','Y')
-+#define BT_SBMATERIAL_CODE            BT_MAKE_ID('S','B','M','T')
-+#define BT_SBNODE_CODE                        BT_MAKE_ID('S','B','N','D')
-+#define BT_DNA_CODE                           BT_MAKE_ID('D','N','A','1')
- struct        btPointerUid
diff --git a/extern/bullet2/patches/pvs_warning_fixes.patch b/extern/bullet2/patches/pvs_warning_fixes.patch
deleted file mode 100644 (file)
index 5a3fe14..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-Index: extern/bullet2/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h
-===================================================================
---- extern/bullet2/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h    (Revision 45907)
-+++ extern/bullet2/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h    (Revision 45908)
-@@ -45,7 +45,9 @@
-       int     getTriangleIndex() const
-       {
-               // Get only the lower bits where the triangle index is stored
--              return (m_PartIdTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
-+              unsigned int x = 0;
-+              unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);
-+              return (m_PartIdTriangleIndex&~(y));
-       }
-       int     getPartId() const
-       {
-Index: extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
-===================================================================
---- extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h    (Revision 45907)
-+++ extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h    (Revision 45908)
-@@ -78,8 +78,10 @@
-       int     getTriangleIndex() const
-       {
-               btAssert(isLeafNode());
-+              unsigned int x=0;
-+              unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);
-               // Get only the lower bits where the triangle index is stored
--              return (m_escapeIndexOrTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
-+              return (m_escapeIndexOrTriangleIndex&~(y));
-       }
-       int     getPartId() const
-       {
index 7f5a7f1e1632552924a1ed96322762042203a823..dd806d40facca042428a0d24eaa6001fa613de87 100644 (file)
@@ -7,13 +7,6 @@ Erwin
 Apply patches/ghost_softbody.patch to prevent softbodies being hit by ghost objects.
 Originally committed in blender svn revision: 43905.
 
 Apply patches/ghost_softbody.patch to prevent softbodies being hit by ghost objects.
 Originally committed in blender svn revision: 43905.
 
-Apply patches/pvs_warning_fixes.patch to fix warnings reported by PVS-Studio.
-Originally committed in blender svn revision: 45908.
-
-Apply patches/make_id.patch to prevent duplicated define of MAKE_ID macro in blender
-side and bullet side.
-Sergey
-
 Apply patches/ghost_character.patch to prevent characters from colliding with ghost objects.
 Mitchell
 
 Apply patches/ghost_character.patch to prevent characters from colliding with ghost objects.
 Mitchell
 
index 4f4d94b3cc7a03b4c24f80ca1e81d91014c6b36e..cd6e1a8929e008ea7564c3f35478e493899adc04 100644 (file)
@@ -615,7 +615,7 @@ void btAxisSweep3Internal<BP_FP_INT_TYPE>::removeHandle(BP_FP_INT_TYPE handle,bt
 }
 
 template <typename BP_FP_INT_TYPE>
 }
 
 template <typename BP_FP_INT_TYPE>
-void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* dispatcher)
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* /*dispatcher*/)
 {
        if (m_numHandles == 0)
        {
 {
        if (m_numHandles == 0)
        {
index 36eec97174f326aca4d6687775e3a5b164708ae5..405656236bd20b1d8f1cb7a923967995b41f516f 100644 (file)
@@ -23,6 +23,7 @@ struct btBroadphaseProxy;
 class btDispatcher;
 class btManifoldResult;
 class btCollisionObject;
 class btDispatcher;
 class btManifoldResult;
 class btCollisionObject;
+struct btCollisionObjectWrapper;
 struct btDispatcherInfo;
 class  btPersistentManifold;
 
 struct btDispatcherInfo;
 class  btPersistentManifold;
 
@@ -69,7 +70,7 @@ public:
 
        virtual ~btCollisionAlgorithm() {};
 
 
        virtual ~btCollisionAlgorithm() {};
 
-       virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
+       virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
 
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
 
index 409da80ae1b2c8a08a5cd93f2f1aebf147b44709..b64936844d52b01936814e09e1a0a9cf9f3c888a 100644 (file)
@@ -57,7 +57,7 @@ subject to the following restrictions:
 // Specific methods implementation
 
 //SSE gives errors on a MSVC 7.1
 // Specific methods implementation
 
 //SSE gives errors on a MSVC 7.1
-#if defined (BT_USE_SSE) && defined (_WIN32)
+#if defined (BT_USE_SSE) //&& defined (_WIN32)
 #define DBVT_SELECT_IMPL               DBVT_IMPL_SSE
 #define DBVT_MERGE_IMPL                        DBVT_IMPL_SSE
 #define DBVT_INT0_IMPL                 DBVT_IMPL_SSE
 #define DBVT_SELECT_IMPL               DBVT_IMPL_SSE
 #define DBVT_MERGE_IMPL                        DBVT_IMPL_SSE
 #define DBVT_INT0_IMPL                 DBVT_IMPL_SSE
@@ -160,6 +160,10 @@ struct     btDbvtAabbMm
                btDbvtAabbMm& r);
        DBVT_INLINE friend bool                 NotEqual(       const btDbvtAabbMm& a,
                const btDbvtAabbMm& b);
                btDbvtAabbMm& r);
        DBVT_INLINE friend bool                 NotEqual(       const btDbvtAabbMm& a,
                const btDbvtAabbMm& b);
+    
+    DBVT_INLINE btVector3&     tMins() { return(mi); }
+       DBVT_INLINE btVector3&  tMaxs() { return(mx); }
+    
 private:
        DBVT_INLINE void                                AddSpan(const btVector3& d,btScalar& smi,btScalar& smx) const;
 private:
 private:
        DBVT_INLINE void                                AddSpan(const btVector3& d,btScalar& smi,btScalar& smx) const;
 private:
@@ -320,7 +324,7 @@ struct      btDbvt
        DBVT_PREFIX
                void            collideTV(      const btDbvtNode* root,
                const btDbvtVolume& volume,
        DBVT_PREFIX
                void            collideTV(      const btDbvtNode* root,
                const btDbvtVolume& volume,
-               DBVT_IPOLICY);
+               DBVT_IPOLICY) const;
        ///rayTest is a re-entrant ray test, and can be called in parallel as long as the btAlignedAlloc is thread-safe (uses locking etc)
        ///rayTest is slower than rayTestInternal, because it builds a local stack, using memory allocations, and it recomputes signs/rayDirectionInverses each time
        DBVT_PREFIX
        ///rayTest is a re-entrant ray test, and can be called in parallel as long as the btAlignedAlloc is thread-safe (uses locking etc)
        ///rayTest is slower than rayTestInternal, because it builds a local stack, using memory allocations, and it recomputes signs/rayDirectionInverses each time
        DBVT_PREFIX
@@ -519,7 +523,11 @@ DBVT_INLINE bool           Intersect(      const btDbvtAabbMm& a,
 #if    DBVT_INT0_IMPL == DBVT_IMPL_SSE
        const __m128    rt(_mm_or_ps(   _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)),
                _mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi))));
 #if    DBVT_INT0_IMPL == DBVT_IMPL_SSE
        const __m128    rt(_mm_or_ps(   _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)),
                _mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi))));
+#if defined (_WIN32)
        const __int32*  pu((const __int32*)&rt);
        const __int32*  pu((const __int32*)&rt);
+#else
+    const int* pu((const int*)&rt);
+#endif
        return((pu[0]|pu[1]|pu[2])==0);
 #else
        return( (a.mi.x()<=b.mx.x())&&
        return((pu[0]|pu[1]|pu[2])==0);
 #else
        return( (a.mi.x()<=b.mx.x())&&
@@ -568,7 +576,12 @@ DBVT_INLINE int                    Select( const btDbvtAabbMm& o,
                                                           const btDbvtAabbMm& b)
 {
 #if    DBVT_SELECT_IMPL == DBVT_IMPL_SSE
                                                           const btDbvtAabbMm& b)
 {
 #if    DBVT_SELECT_IMPL == DBVT_IMPL_SSE
+    
+#if defined (_WIN32)
        static ATTRIBUTE_ALIGNED16(const unsigned __int32)      mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
        static ATTRIBUTE_ALIGNED16(const unsigned __int32)      mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
+#else
+    static ATTRIBUTE_ALIGNED16(const unsigned int)     mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x00000000 /*0x7fffffff*/};
+#endif
        ///@todo: the intrinsic version is 11% slower
 #if DBVT_USE_INTRINSIC_SSE
 
        ///@todo: the intrinsic version is 11% slower
 #if DBVT_USE_INTRINSIC_SSE
 
@@ -908,7 +921,7 @@ inline void         btDbvt::collideTT(      const btDbvtNode* root0,
 DBVT_PREFIX
 inline void            btDbvt::collideTV(      const btDbvtNode* root,
                                                                  const btDbvtVolume& vol,
 DBVT_PREFIX
 inline void            btDbvt::collideTV(      const btDbvtNode* root,
                                                                  const btDbvtVolume& vol,
-                                                                 DBVT_IPOLICY)
+                                                                 DBVT_IPOLICY) const
 {
        DBVT_CHECKTYPE
                if(root)
 {
        DBVT_CHECKTYPE
                if(root)
index a79cf9402b1d5cd3d143ed4410dccedaa20ba338..1ebb37797d97b2f082f9df4d27c3a5efa617e2b6 100644 (file)
@@ -22,7 +22,7 @@ struct btBroadphaseProxy;
 class btRigidBody;
 class  btCollisionObject;
 class btOverlappingPairCache;
 class btRigidBody;
 class  btCollisionObject;
 class btOverlappingPairCache;
-
+struct btCollisionObjectWrapper;
 
 class btPersistentManifold;
 class btStackAlloc;
 
 class btPersistentManifold;
 class btStackAlloc;
@@ -76,17 +76,17 @@ class btDispatcher
 public:
        virtual ~btDispatcher() ;
 
 public:
        virtual ~btDispatcher() ;
 
-       virtual btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold=0) = 0;
+       virtual btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btPersistentManifold* sharedManifold=0) = 0;
 
 
-       virtual btPersistentManifold*   getNewManifold(void* body0,void* body1)=0;
+       virtual btPersistentManifold*   getNewManifold(const btCollisionObject* b0,const btCollisionObject* b1)=0;
 
        virtual void releaseManifold(btPersistentManifold* manifold)=0;
 
        virtual void clearManifold(btPersistentManifold* manifold)=0;
 
 
        virtual void releaseManifold(btPersistentManifold* manifold)=0;
 
        virtual void clearManifold(btPersistentManifold* manifold)=0;
 
-       virtual bool    needsCollision(btCollisionObject* body0,btCollisionObject* body1) = 0;
+       virtual bool    needsCollision(const btCollisionObject* body0,const btCollisionObject* body1) = 0;
 
 
-       virtual bool    needsResponse(btCollisionObject* body0,btCollisionObject* body1)=0;
+       virtual bool    needsResponse(const btCollisionObject* body0,const btCollisionObject* body1)=0;
 
        virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher)  =0;
 
 
        virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher)  =0;
 
index c911435a946350a6e55c1acd906f08c22296fde1..889216df5092a6c5a0db469cec599e5973a84689 100644 (file)
@@ -96,7 +96,25 @@ void btQuantizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btV
        m_bvhAabbMax = bvhAabbMax + clampValue;
        btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
        m_bvhQuantization = btVector3(btScalar(65533.0),btScalar(65533.0),btScalar(65533.0)) / aabbSize;
        m_bvhAabbMax = bvhAabbMax + clampValue;
        btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
        m_bvhQuantization = btVector3(btScalar(65533.0),btScalar(65533.0),btScalar(65533.0)) / aabbSize;
+
        m_useQuantization = true;
        m_useQuantization = true;
+
+       {
+               unsigned short vecIn[3];
+               btVector3 v;
+               {
+                       quantize(vecIn,m_bvhAabbMin,false);
+                       v = unQuantize(vecIn);
+                       m_bvhAabbMin.setMin(v-clampValue);
+               }
+               {
+                       quantize(vecIn,m_bvhAabbMax,true);
+                       v = unQuantize(vecIn);
+                       m_bvhAabbMax.setMax(v+clampValue);
+               }
+               aabbSize = m_bvhAabbMax - m_bvhAabbMin;
+               m_bvhQuantization = btVector3(btScalar(65533.0),btScalar(65533.0),btScalar(65533.0)) / aabbSize;
+       }
 }
 
 
 }
 
 
index 23a5c7526b4dea3239c0a969b9a86ba962f22382..63401780970f75df0efb61cd9923a64e7a4870cd 100644 (file)
@@ -158,7 +158,6 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
                                depth = -(radius-distance);
                        } else
                        {
                                depth = -(radius-distance);
                        } else
                        {
-                               btScalar distance = 0.f;
                                resultNormal = normal;
                                point = contactPoint;
                                depth = -radius;
                                resultNormal = normal;
                                point = contactPoint;
                                depth = -radius;
index 7e5da6c587273ecbb30122fcce892ba995055423..57f146493531e7a1cb4d86a165d249c951871da7 100644 (file)
@@ -24,7 +24,7 @@ btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisio
 //m_colObj1(0)
 {
 }
 //m_colObj1(0)
 {
 }
-btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* colObj0,btCollisionObject* colObj1)
+btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* ,const btCollisionObjectWrapper* )
 :btCollisionAlgorithm(ci)
 //,
 //m_colObj0(0),
 :btCollisionAlgorithm(ci)
 //,
 //m_colObj0(0),
index 25fe088942d79e67d322563c2aa85e6a4beb5561..489812b96631d49db4c0ebce6e58fe71e5045458 100644 (file)
@@ -28,7 +28,7 @@ public:
 
        btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci);
 
 
        btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci);
 
-       btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* colObj0,btCollisionObject* colObj1);
+       btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
 
        virtual ~btActivatingCollisionAlgorithm();
 
 
        virtual ~btActivatingCollisionAlgorithm();
 
index 2182d0d7e49a4e234d990aa138fc93b5debb0551..2c3627782109e5f4cd69cc4fd6adf2c9dd0645f7 100644 (file)
@@ -22,17 +22,18 @@ subject to the following restrictions:
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 #include "BulletCollision/CollisionDispatch/btBoxBoxDetector.h"
 #include "BulletCollision/CollisionShapes/btBox2dShape.h"
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 #include "BulletCollision/CollisionDispatch/btBoxBoxDetector.h"
 #include "BulletCollision/CollisionShapes/btBox2dShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 #define USE_PERSISTENT_CONTACTS 1
 
 
 #define USE_PERSISTENT_CONTACTS 1
 
-btBox2dBox2dCollisionAlgorithm::btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1)
-: btActivatingCollisionAlgorithm(ci,obj0,obj1),
+btBox2dBox2dCollisionAlgorithm::btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* obj0Wrap,const btCollisionObjectWrapper* obj1Wrap)
+: btActivatingCollisionAlgorithm(ci,obj0Wrap,obj1Wrap),
 m_ownManifold(false),
 m_manifoldPtr(mf)
 {
 m_ownManifold(false),
 m_manifoldPtr(mf)
 {
-       if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0,obj1))
+       if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0Wrap->getCollisionObject(),obj1Wrap->getCollisionObject()))
        {
        {
-               m_manifoldPtr = m_dispatcher->getNewManifold(obj0,obj1);
+               m_manifoldPtr = m_dispatcher->getNewManifold(obj0Wrap->getCollisionObject(),obj1Wrap->getCollisionObject());
                m_ownManifold = true;
        }
 }
                m_ownManifold = true;
        }
 }
@@ -52,19 +53,18 @@ btBox2dBox2dCollisionAlgorithm::~btBox2dBox2dCollisionAlgorithm()
 void b2CollidePolygons(btManifoldResult* manifold,  const btBox2dShape* polyA, const btTransform& xfA, const btBox2dShape* polyB, const btTransform& xfB);
 
 //#include <stdio.h>
 void b2CollidePolygons(btManifoldResult* manifold,  const btBox2dShape* polyA, const btTransform& xfA, const btBox2dShape* polyB, const btTransform& xfB);
 
 //#include <stdio.h>
-void btBox2dBox2dCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btBox2dBox2dCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
        if (!m_manifoldPtr)
                return;
 
 {
        if (!m_manifoldPtr)
                return;
 
-       btCollisionObject*      col0 = body0;
-       btCollisionObject*      col1 = body1;
-       btBox2dShape* box0 = (btBox2dShape*)col0->getCollisionShape();
-       btBox2dShape* box1 = (btBox2dShape*)col1->getCollisionShape();
+       
+       const btBox2dShape* box0 = (const btBox2dShape*)body0Wrap->getCollisionShape();
+       const btBox2dShape* box1 = (const btBox2dShape*)body1Wrap->getCollisionShape();
 
        resultOut->setPersistentManifold(m_manifoldPtr);
 
 
        resultOut->setPersistentManifold(m_manifoldPtr);
 
-       b2CollidePolygons(resultOut,box0,col0->getWorldTransform(),box1,col1->getWorldTransform());
+       b2CollidePolygons(resultOut,box0,body0Wrap->getWorldTransform(),box1,body1Wrap->getWorldTransform());
 
        //  refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
        if (m_ownManifold)
 
        //  refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
        if (m_ownManifold)
@@ -151,15 +151,8 @@ static btScalar EdgeSeparation(const btBox2dShape* poly1, const btTransform& xf1
        int index = 0;
        btScalar minDot = BT_LARGE_FLOAT;
 
        int index = 0;
        btScalar minDot = BT_LARGE_FLOAT;
 
-       for (int i = 0; i < count2; ++i)
-       {
-               btScalar dot = b2Dot(vertices2[i], normal1);
-               if (dot < minDot)
-               {
-                       minDot = dot;
-                       index = i;
-               }
-       }
+    if( count2 > 0 )
+        index = (int) normal1.minDot( vertices2, count2, minDot);
 
        btVector3 v1 = b2Mul(xf1, vertices1[edge1]);
        btVector3 v2 = b2Mul(xf2, vertices2[index]);
 
        btVector3 v1 = b2Mul(xf1, vertices1[edge1]);
        btVector3 v2 = b2Mul(xf2, vertices2[index]);
@@ -181,16 +174,9 @@ static btScalar FindMaxSeparation(int* edgeIndex,
 
        // Find edge normal on poly1 that has the largest projection onto d.
        int edge = 0;
 
        // Find edge normal on poly1 that has the largest projection onto d.
        int edge = 0;
-       btScalar maxDot = -BT_LARGE_FLOAT;
-       for (int i = 0; i < count1; ++i)
-       {
-               btScalar dot = b2Dot(normals1[i], dLocal1);
-               if (dot > maxDot)
-               {
-                       maxDot = dot;
-                       edge = i;
-               }
-       }
+    btScalar maxDot;
+    if( count1 > 0 )
+        edge = (int) dLocal1.maxDot( normals1, count1, maxDot);
 
        // Get the separation for the edge normal.
        btScalar s = EdgeSeparation(poly1, xf1, edge, poly2, xf2);
 
        // Get the separation for the edge normal.
        btScalar s = EdgeSeparation(poly1, xf1, edge, poly2, xf2);
@@ -368,7 +354,7 @@ void b2CollidePolygons(btManifoldResult* manifold,
        btVector3 v11 = vertices1[edge1];
        btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1+1] : vertices1[0];
 
        btVector3 v11 = vertices1[edge1];
        btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1+1] : vertices1[0];
 
-       btVector3 dv = v12 - v11;
+       //btVector3 dv = v12 - v11;
        btVector3 sideNormal = b2Mul(xf1.getBasis(), v12 - v11);
        sideNormal.normalize();
        btVector3 frontNormal = btCrossS(sideNormal, 1.0f);
        btVector3 sideNormal = b2Mul(xf1.getBasis(), v12 - v11);
        sideNormal.normalize();
        btVector3 frontNormal = btCrossS(sideNormal, 1.0f);
index 97c5be7700391ab378a9dc6aa4f3a69705745a60..6ea6e89bda6aa2fe326aa48a2a1c18af808d48c8 100644 (file)
@@ -33,11 +33,11 @@ public:
        btBox2dBox2dCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
                : btActivatingCollisionAlgorithm(ci) {}
 
        btBox2dBox2dCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
                : btActivatingCollisionAlgorithm(ci) {}
 
-       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);
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
-       btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+       btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
 
        virtual ~btBox2dBox2dCollisionAlgorithm();
 
 
        virtual ~btBox2dBox2dCollisionAlgorithm();
 
@@ -52,11 +52,11 @@ public:
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
-               virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+               virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
                {
                        int bbsize = sizeof(btBox2dBox2dCollisionAlgorithm);
                        void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
                {
                        int bbsize = sizeof(btBox2dBox2dCollisionAlgorithm);
                        void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
-                       return new(ptr) btBox2dBox2dCollisionAlgorithm(0,ci,body0,body1);
+                       return new(ptr) btBox2dBox2dCollisionAlgorithm(0,ci,body0Wrap,body1Wrap);
                }
        };
 
                }
        };
 
index 49628853493793a5998bc56e53e460f477d9b08f..ac68968f590b8cae0137fe66ec7831a5130a4720 100644 (file)
@@ -18,17 +18,17 @@ subject to the following restrictions:
 #include "BulletCollision/CollisionShapes/btBoxShape.h"
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 #include "btBoxBoxDetector.h"
 #include "BulletCollision/CollisionShapes/btBoxShape.h"
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 #include "btBoxBoxDetector.h"
-
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 #define USE_PERSISTENT_CONTACTS 1
 
 #define USE_PERSISTENT_CONTACTS 1
 
-btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1)
-: btActivatingCollisionAlgorithm(ci,obj0,obj1),
+btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
+: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
 m_ownManifold(false),
 m_manifoldPtr(mf)
 {
 m_ownManifold(false),
 m_manifoldPtr(mf)
 {
-       if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0,obj1))
+       if (!m_manifoldPtr && m_dispatcher->needsCollision(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject()))
        {
        {
-               m_manifoldPtr = m_dispatcher->getNewManifold(obj0,obj1);
+               m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
                m_ownManifold = true;
        }
 }
                m_ownManifold = true;
        }
 }
@@ -42,15 +42,14 @@ btBoxBoxCollisionAlgorithm::~btBoxBoxCollisionAlgorithm()
        }
 }
 
        }
 }
 
-void btBoxBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btBoxBoxCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
        if (!m_manifoldPtr)
                return;
 
 {
        if (!m_manifoldPtr)
                return;
 
-       btCollisionObject*      col0 = body0;
-       btCollisionObject*      col1 = body1;
-       btBoxShape* box0 = (btBoxShape*)col0->getCollisionShape();
-       btBoxShape* box1 = (btBoxShape*)col1->getCollisionShape();
+       
+       const btBoxShape* box0 = (btBoxShape*)body0Wrap->getCollisionShape();
+       const btBoxShape* box1 = (btBoxShape*)body1Wrap->getCollisionShape();
 
 
 
 
 
 
@@ -62,8 +61,8 @@ void btBoxBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btCo
 
        btDiscreteCollisionDetectorInterface::ClosestPointInput input;
        input.m_maximumDistanceSquared = BT_LARGE_FLOAT;
 
        btDiscreteCollisionDetectorInterface::ClosestPointInput input;
        input.m_maximumDistanceSquared = BT_LARGE_FLOAT;
-       input.m_transformA = body0->getWorldTransform();
-       input.m_transformB = body1->getWorldTransform();
+       input.m_transformA = body0Wrap->getWorldTransform();
+       input.m_transformB = body1Wrap->getWorldTransform();
 
        btBoxBoxDetector detector(box0,box1);
        detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
 
        btBoxBoxDetector detector(box0,box1);
        detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
index f0bbae61e3b58509ec2710244b20e4c0acd07fad..59808df5a9d3f85b8b0c3d41d88350dc5e6d3028 100644 (file)
@@ -33,11 +33,11 @@ public:
        btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
                : btActivatingCollisionAlgorithm(ci) {}
 
        btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
                : btActivatingCollisionAlgorithm(ci) {}
 
-       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);
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
-       btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+       btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
 
        virtual ~btBoxBoxCollisionAlgorithm();
 
 
        virtual ~btBoxBoxCollisionAlgorithm();
 
@@ -52,11 +52,11 @@ public:
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
-               virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
+               virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
                {
                        int bbsize = sizeof(btBoxBoxCollisionAlgorithm);
                        void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
                {
                        int bbsize = sizeof(btBoxBoxCollisionAlgorithm);
                        void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
-                       return new(ptr) btBoxBoxCollisionAlgorithm(0,ci,body0,body1);
+                       return new(ptr) btBoxBoxCollisionAlgorithm(0,ci,body0Wrap,body1Wrap);
                }
        };
 
                }
        };
 
index a7c8cf140ce4e97e3b614484c68f59bb62557d96..7043bde34f59f4d0beb837e8fc6f1efd48251731 100644 (file)
@@ -24,7 +24,7 @@ subject to the following restrictions:
 #include <float.h>
 #include <string.h>
 
 #include <float.h>
 #include <string.h>
 
-btBoxBoxDetector::btBoxBoxDetector(btBoxShape* box1,btBoxShape* box2)
+btBoxBoxDetector::btBoxBoxDetector(const btBoxShape* box1,const btBoxShape* box2)
 : m_box1(box1),
 m_box2(box2)
 {
 : m_box1(box1),
 m_box2(box2)
 {
index 3c941f7deb233f76049d38ca903e51bbc3d270f5..39243777051d358ceaab1a4e0e3c20588a7e0bc9 100644 (file)
@@ -28,12 +28,12 @@ class btBoxShape;
 /// re-distributed under the Zlib license with permission from Russell L. Smith
 struct btBoxBoxDetector : public btDiscreteCollisionDetectorInterface
 {
 /// re-distributed under the Zlib license with permission from Russell L. Smith
 struct btBoxBoxDetector : public btDiscreteCollisionDetectorInterface
 {
-       btBoxShape* m_box1;
-       btBoxShape* m_box2;
+       const btBoxShape* m_box1;
+       const btBoxShape* m_box2;
 
 public:
 
 
 public:
 
-       btBoxBoxDetector(btBoxShape* box1,btBoxShape* box2);
+       btBoxBoxDetector(const btBoxShape* box1,const btBoxShape* box2);
 
        virtual ~btBoxBoxDetector() {};
 
 
        virtual ~btBoxBoxDetector() {};
 
index 1d7e74401dd84ced780762c0978f677a90ef2911..62ee66c4e9a3fbca44ba07027bffa900992eaad7 100644 (file)
@@ -19,7 +19,7 @@ subject to the following restrictions:
 #include "LinearMath/btAlignedObjectArray.h"
 class btCollisionAlgorithm;
 class btCollisionObject;
 #include "LinearMath/btAlignedObjectArray.h"
 class btCollisionAlgorithm;
 class btCollisionObject;
-
+struct btCollisionObjectWrapper;
 struct btCollisionAlgorithmConstructionInfo;
 
 ///Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm
 struct btCollisionAlgorithmConstructionInfo;
 
 ///Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm
@@ -33,11 +33,11 @@ struct btCollisionAlgorithmCreateFunc
        }
        virtual ~btCollisionAlgorithmCreateFunc(){};
 
        }
        virtual ~btCollisionAlgorithmCreateFunc(){};
 
-       virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& , btCollisionObject* body0,btCollisionObject* body1)
+       virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& , const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
        {
                
        {
                
-               (void)body0;
-               (void)body1;
+               (void)body0Wrap;
+               (void)body1Wrap;
                return 0;
        }
 };
                return 0;
        }
 };
index 29674f3be46e2cfe0bc5b5f6e3cc00e1cb7254d5..669d0b6b55e4c65316593c1bfaef01376937e1af 100644 (file)
@@ -25,6 +25,7 @@ subject to the following restrictions:
 #include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
 #include "LinearMath/btPoolAllocator.h"
 #include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
 #include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
 #include "LinearMath/btPoolAllocator.h"
 #include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 int gNumManifold = 0;
 
 
 int gNumManifold = 0;
 
@@ -67,15 +68,13 @@ btCollisionDispatcher::~btCollisionDispatcher()
 {
 }
 
 {
 }
 
-btPersistentManifold*  btCollisionDispatcher::getNewManifold(void* b0,void* b1) 
+btPersistentManifold*  btCollisionDispatcher::getNewManifold(const btCollisionObject* body0,const btCollisionObject* body1) 
 { 
        gNumManifold++;
        
        //btAssert(gNumManifold < 65535);
        
 
 { 
        gNumManifold++;
        
        //btAssert(gNumManifold < 65535);
        
 
-       btCollisionObject* body0 = (btCollisionObject*)b0;
-       btCollisionObject* body1 = (btCollisionObject*)b1;
 
        //optional relative contact breaking threshold, turned on by default (use setDispatcherFlags to switch off feature for improved performance)
        
 
        //optional relative contact breaking threshold, turned on by default (use setDispatcherFlags to switch off feature for improved performance)
        
@@ -85,7 +84,7 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
 
        btScalar contactProcessingThreshold = btMin(body0->getContactProcessingThreshold(),body1->getContactProcessingThreshold());
                
 
        btScalar contactProcessingThreshold = btMin(body0->getContactProcessingThreshold(),body1->getContactProcessingThreshold());
                
-       void* mem = 0;
+       void* mem = 0;
        
        if (m_persistentManifoldPoolAllocator->getFreeCount())
        {
        
        if (m_persistentManifoldPoolAllocator->getFreeCount())
        {
@@ -143,14 +142,14 @@ void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
 
        
 
 
        
 
-btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
+btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btPersistentManifold* sharedManifold)
 {
        
        btCollisionAlgorithmConstructionInfo ci;
 
        ci.m_dispatcher1 = this;
        ci.m_manifold = sharedManifold;
 {
        
        btCollisionAlgorithmConstructionInfo ci;
 
        ci.m_dispatcher1 = this;
        ci.m_manifold = sharedManifold;
-       btCollisionAlgorithm* algo = m_doubleDispatch[body0->getCollisionShape()->getShapeType()][body1->getCollisionShape()->getShapeType()]->CreateCollisionAlgorithm(ci,body0,body1);
+       btCollisionAlgorithm* algo = m_doubleDispatch[body0Wrap->getCollisionShape()->getShapeType()][body1Wrap->getCollisionShape()->getShapeType()]->CreateCollisionAlgorithm(ci,body0Wrap,body1Wrap);
 
        return algo;
 }
 
        return algo;
 }
@@ -158,7 +157,7 @@ btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* bo
 
 
 
 
 
 
-bool   btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
+bool   btCollisionDispatcher::needsResponse(const btCollisionObject* body0,const btCollisionObject* body1)
 {
        //here you can do filtering
        bool hasResponse = 
 {
        //here you can do filtering
        bool hasResponse = 
@@ -169,7 +168,7 @@ bool        btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionOb
        return hasResponse;
 }
 
        return hasResponse;
 }
 
-bool   btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1)
+bool   btCollisionDispatcher::needsCollision(const btCollisionObject* body0,const btCollisionObject* body1)
 {
        btAssert(body0);
        btAssert(body1);
 {
        btAssert(body0);
        btAssert(body1);
@@ -259,20 +258,25 @@ void btCollisionDispatcher::defaultNearCallback(btBroadphasePair& collisionPair,
 
                if (dispatcher.needsCollision(colObj0,colObj1))
                {
 
                if (dispatcher.needsCollision(colObj0,colObj1))
                {
+                       btCollisionObjectWrapper obj0Wrap(0,colObj0->getCollisionShape(),colObj0,colObj0->getWorldTransform(),-1,-1);
+                       btCollisionObjectWrapper obj1Wrap(0,colObj1->getCollisionShape(),colObj1,colObj1->getWorldTransform(),-1,-1);
+
+
                        //dispatcher will keep algorithms persistent in the collision pair
                        if (!collisionPair.m_algorithm)
                        {
                        //dispatcher will keep algorithms persistent in the collision pair
                        if (!collisionPair.m_algorithm)
                        {
-                               collisionPair.m_algorithm = dispatcher.findAlgorithm(colObj0,colObj1);
+                               collisionPair.m_algorithm = dispatcher.findAlgorithm(&obj0Wrap,&obj1Wrap);
                        }
 
                        if (collisionPair.m_algorithm)
                        {
                        }
 
                        if (collisionPair.m_algorithm)
                        {
-                               btManifoldResult contactPointResult(colObj0,colObj1);
+                               btManifoldResult contactPointResult(&obj0Wrap,&obj1Wrap);
                                
                                if (dispatchInfo.m_dispatchFunc ==              btDispatcherInfo::DISPATCH_DISCRETE)
                                {
                                        //discrete collision detection query
                                
                                if (dispatchInfo.m_dispatchFunc ==              btDispatcherInfo::DISPATCH_DISCRETE)
                                {
                                        //discrete collision detection query
-                                       collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
+                                       
+                                       collisionPair.m_algorithm->processCollision(&obj0Wrap,&obj1Wrap,dispatchInfo,&contactPointResult);
                                } else
                                {
                                        //continuous collision detection query, time of impact (toi)
                                } else
                                {
                                        //continuous collision detection query, time of impact (toi)
index 5accad9a993bcac450c915e0df621c931eed344b..92696ee5429081a1df9a3038e918f9e5063a5acd 100644 (file)
@@ -108,19 +108,18 @@ public:
 
        virtual ~btCollisionDispatcher();
 
 
        virtual ~btCollisionDispatcher();
 
-       virtual btPersistentManifold*   getNewManifold(void* b0,void* b1);
+       virtual btPersistentManifold*   getNewManifold(const btCollisionObject* b0,const btCollisionObject* b1);
        
        virtual void releaseManifold(btPersistentManifold* manifold);
 
 
        virtual void clearManifold(btPersistentManifold* manifold);
 
        
        virtual void releaseManifold(btPersistentManifold* manifold);
 
 
        virtual void clearManifold(btPersistentManifold* manifold);
 
-                       
-       btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
+       btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btPersistentManifold* sharedManifold = 0);
                
                
-       virtual bool    needsCollision(btCollisionObject* body0,btCollisionObject* body1);
+       virtual bool    needsCollision(const btCollisionObject* body0,const btCollisionObject* body1);
        
        
-       virtual bool    needsResponse(btCollisionObject* body0,btCollisionObject* body1);
+       virtual bool    needsResponse(const btCollisionObject* body0,const btCollisionObject* body1);
        
        virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
 
        
        virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
 
index 580ea3458607192ccdadd5e7771811e85d9527d5..cf8ed59a541489d88b0ee06d5610432bdf0e5bea 100644 (file)
@@ -31,6 +31,7 @@ btCollisionObject::btCollisionObject()
                m_activationState1(1),
                m_deactivationTime(btScalar(0.)),
                m_friction(btScalar(0.5)),
                m_activationState1(1),
                m_deactivationTime(btScalar(0.)),
                m_friction(btScalar(0.5)),
+               m_rollingFriction(0.0f),
                m_restitution(btScalar(0.)),
                m_internalType(CO_COLLISION_OBJECT),
                m_userObjectPointer(0),
                m_restitution(btScalar(0.)),
                m_internalType(CO_COLLISION_OBJECT),
                m_userObjectPointer(0),
@@ -46,18 +47,18 @@ btCollisionObject::~btCollisionObject()
 {
 }
 
 {
 }
 
-void btCollisionObject::setActivationState(int newState) 
+void btCollisionObject::setActivationState(int newState) const
 { 
        if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION))
                m_activationState1 = newState;
 }
 
 { 
        if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION))
                m_activationState1 = newState;
 }
 
-void btCollisionObject::forceActivationState(int newState)
+void btCollisionObject::forceActivationState(int newState) const
 {
        m_activationState1 = newState;
 }
 
 {
        m_activationState1 = newState;
 }
 
-void btCollisionObject::activate(bool forceActivation)
+void btCollisionObject::activate(bool forceActivation) const
 {
        if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
        {
 {
        if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
        {
@@ -85,9 +86,9 @@ const char* btCollisionObject::serialize(void* dataBuffer, btSerializer* seriali
        dataOut->m_islandTag1 = m_islandTag1;
        dataOut->m_companionId = m_companionId;
        dataOut->m_activationState1 = m_activationState1;
        dataOut->m_islandTag1 = m_islandTag1;
        dataOut->m_companionId = m_companionId;
        dataOut->m_activationState1 = m_activationState1;
-       dataOut->m_activationState1 = m_activationState1;
        dataOut->m_deactivationTime = m_deactivationTime;
        dataOut->m_friction = m_friction;
        dataOut->m_deactivationTime = m_deactivationTime;
        dataOut->m_friction = m_friction;
+       dataOut->m_rollingFriction = m_rollingFriction;
        dataOut->m_restitution = m_restitution;
        dataOut->m_internalType = m_internalType;
        
        dataOut->m_restitution = m_restitution;
        dataOut->m_internalType = m_internalType;
        
@@ -100,7 +101,6 @@ const char* btCollisionObject::serialize(void* dataBuffer, btSerializer* seriali
        dataOut->m_hitFraction = m_hitFraction;
        dataOut->m_ccdSweptSphereRadius = m_ccdSweptSphereRadius;
        dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold;
        dataOut->m_hitFraction = m_hitFraction;
        dataOut->m_ccdSweptSphereRadius = m_ccdSweptSphereRadius;
        dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold;
-       dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold;
        dataOut->m_checkCollideWith = m_checkCollideWith;
 
        return btCollisionObjectDataName;
        dataOut->m_checkCollideWith = m_checkCollideWith;
 
        return btCollisionObjectDataName;
index 3a11c967ac9c498a498ad1b6e61abbfe24839032..2f17967fe0f06a5e056d2ddfcae5b893e6784495 100644 (file)
@@ -80,11 +80,12 @@ protected:
        int                             m_islandTag1;
        int                             m_companionId;
 
        int                             m_islandTag1;
        int                             m_companionId;
 
-       int                             m_activationState1;
-       btScalar                        m_deactivationTime;
+       mutable int                             m_activationState1;
+       mutable btScalar                        m_deactivationTime;
 
        btScalar                m_friction;
        btScalar                m_restitution;
 
        btScalar                m_friction;
        btScalar                m_restitution;
+       btScalar                m_rollingFriction;
 
        ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody, btGhostObject etc.
        ///do not assign your own m_internalType unless you write a new dynamics object class.
 
        ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody, btGhostObject etc.
        ///do not assign your own m_internalType unless you write a new dynamics object class.
@@ -105,7 +106,7 @@ protected:
        /// If some object should have elaborate collision filtering by sub-classes
        int                     m_checkCollideWith;
 
        /// If some object should have elaborate collision filtering by sub-classes
        int                     m_checkCollideWith;
 
-       virtual bool    checkCollideWithOverride(btCollisionObject* /* co */)
+       virtual bool    checkCollideWithOverride(const btCollisionObject* /* co */) const
        {
                return true;
        }
        {
                return true;
        }
@@ -137,6 +138,13 @@ public:
                CO_USER_TYPE=32
        };
 
                CO_USER_TYPE=32
        };
 
+       enum AnisotropicFrictionFlags
+       {
+               CF_ANISOTROPIC_FRICTION_DISABLED=0,
+               CF_ANISOTROPIC_FRICTION = 1,
+               CF_ANISOTROPIC_ROLLING_FRICTION = 2
+       };
+
        SIMD_FORCE_INLINE bool mergesSimulationIslands() const
        {
                ///static objects, kinematic and object without contact response don't merge islands
        SIMD_FORCE_INLINE bool mergesSimulationIslands() const
        {
                ///static objects, kinematic and object without contact response don't merge islands
@@ -147,14 +155,15 @@ public:
        {
                return m_anisotropicFriction;
        }
        {
                return m_anisotropicFriction;
        }
-       void    setAnisotropicFriction(const btVector3& anisotropicFriction)
+       void    setAnisotropicFriction(const btVector3& anisotropicFriction, int frictionMode = CF_ANISOTROPIC_FRICTION)
        {
                m_anisotropicFriction = anisotropicFriction;
        {
                m_anisotropicFriction = anisotropicFriction;
-               m_hasAnisotropicFriction = (anisotropicFriction[0]!=1.f) || (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f);
+               bool isUnity = (anisotropicFriction[0]!=1.f) || (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f);
+               m_hasAnisotropicFriction = isUnity?frictionMode : 0;
        }
        }
-       bool    hasAnisotropicFriction() const
+       bool    hasAnisotropicFriction(int frictionMode = CF_ANISOTROPIC_FRICTION) const
        {
        {
-               return m_hasAnisotropicFriction!=0;
+               return (m_hasAnisotropicFriction&frictionMode)!=0;
        }
 
        ///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default.
        }
 
        ///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default.
@@ -207,22 +216,9 @@ public:
                return m_collisionShape;
        }
 
                return m_collisionShape;
        }
 
-       SIMD_FORCE_INLINE const btCollisionShape*       getRootCollisionShape() const
-       {
-               return m_rootCollisionShape;
-       }
-
-       SIMD_FORCE_INLINE btCollisionShape*     getRootCollisionShape()
-       {
-               return m_rootCollisionShape;
-       }
+       
 
 
-       ///Avoid using this internal API call
-       ///internalSetTemporaryCollisionShape is used to temporary replace the actual collision shape by a child collision shape.
-       void    internalSetTemporaryCollisionShape(btCollisionShape* collisionShape)
-       {
-               m_collisionShape = collisionShape;
-       }
+       
 
        ///Avoid using this internal API call, the extension pointer is used by some Bullet extensions. 
        ///If you need to store your own user pointer, use 'setUserPointer/getUserPointer' instead.
 
        ///Avoid using this internal API call, the extension pointer is used by some Bullet extensions. 
        ///If you need to store your own user pointer, use 'setUserPointer/getUserPointer' instead.
@@ -239,7 +235,7 @@ public:
 
        SIMD_FORCE_INLINE       int     getActivationState() const { return m_activationState1;}
        
 
        SIMD_FORCE_INLINE       int     getActivationState() const { return m_activationState1;}
        
-       void setActivationState(int newState);
+       void setActivationState(int newState) const;
 
        void    setDeactivationTime(btScalar time)
        {
 
        void    setDeactivationTime(btScalar time)
        {
@@ -250,9 +246,9 @@ public:
                return m_deactivationTime;
        }
 
                return m_deactivationTime;
        }
 
-       void forceActivationState(int newState);
+       void forceActivationState(int newState) const;
 
 
-       void    activate(bool forceActivation = false);
+       void    activate(bool forceActivation = false) const;
 
        SIMD_FORCE_INLINE bool isActive() const
        {
 
        SIMD_FORCE_INLINE bool isActive() const
        {
@@ -276,6 +272,16 @@ public:
                return m_friction;
        }
 
                return m_friction;
        }
 
+       void    setRollingFriction(btScalar frict)
+       {
+               m_rollingFriction = frict;
+       }
+       btScalar        getRollingFriction() const
+       {
+               return m_rollingFriction;
+       }
+
+
        ///reserved for Bullet internal usage
        int     getInternalType() const
        {
        ///reserved for Bullet internal usage
        int     getInternalType() const
        {
@@ -433,7 +439,7 @@ public:
        }
 
 
        }
 
 
-       inline bool checkCollideWith(btCollisionObject* co)
+       inline bool checkCollideWith(const btCollisionObject* co) const
        {
                if (m_checkCollideWith)
                        return checkCollideWithOverride(co);
        {
                if (m_checkCollideWith)
                        return checkCollideWithOverride(co);
@@ -466,6 +472,7 @@ struct      btCollisionObjectDoubleData
        double                                  m_contactProcessingThreshold;   
        double                                  m_deactivationTime;
        double                                  m_friction;
        double                                  m_contactProcessingThreshold;   
        double                                  m_deactivationTime;
        double                                  m_friction;
+       double                                  m_rollingFriction;
        double                                  m_restitution;
        double                                  m_hitFraction; 
        double                                  m_ccdSweptSphereRadius;
        double                                  m_restitution;
        double                                  m_hitFraction; 
        double                                  m_ccdSweptSphereRadius;
@@ -498,6 +505,8 @@ struct      btCollisionObjectFloatData
        float                                   m_contactProcessingThreshold;   
        float                                   m_deactivationTime;
        float                                   m_friction;
        float                                   m_contactProcessingThreshold;   
        float                                   m_deactivationTime;
        float                                   m_friction;
+       float                                   m_rollingFriction;
+
        float                                   m_restitution;
        float                                   m_hitFraction; 
        float                                   m_ccdSweptSphereRadius;
        float                                   m_restitution;
        float                                   m_hitFraction; 
        float                                   m_ccdSweptSphereRadius;
@@ -510,6 +519,7 @@ struct      btCollisionObjectFloatData
        int                                             m_activationState1;
        int                                             m_internalType;
        int                                             m_checkCollideWith;
        int                                             m_activationState1;
        int                                             m_internalType;
        int                                             m_checkCollideWith;
+       char                                    m_padding[4];
 };
 
 
 };
 
 
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h
new file mode 100644 (file)
index 0000000..952440b
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef BT_COLLISION_OBJECT_WRAPPER_H
+#define BT_COLLISION_OBJECT_WRAPPER_H
+
+///btCollisionObjectWrapperis an internal data structure. 
+///Most users can ignore this and use btCollisionObject and btCollisionShape instead
+class btCollisionShape;
+class btCollisionObject;
+class btTransform;
+#include "LinearMath/btScalar.h" // for SIMD_FORCE_INLINE definition
+
+#define BT_DECLARE_STACK_ONLY_OBJECT \
+       private: \
+               void* operator new(size_t size); \
+               void operator delete(void*);
+
+struct btCollisionObjectWrapper;
+struct btCollisionObjectWrapper
+{
+BT_DECLARE_STACK_ONLY_OBJECT
+
+private:
+       btCollisionObjectWrapper(const btCollisionObjectWrapper&); // not implemented. Not allowed.
+       btCollisionObjectWrapper* operator=(const btCollisionObjectWrapper&);
+
+public:
+       const btCollisionObjectWrapper* m_parent;
+       const btCollisionShape* m_shape;
+       const btCollisionObject* m_collisionObject;
+       const btTransform& m_worldTransform;
+       int             m_partId;
+       int             m_index;
+
+       btCollisionObjectWrapper(const btCollisionObjectWrapper* parent, const btCollisionShape* shape, const btCollisionObject* collisionObject, const btTransform& worldTransform, int partId, int index)
+       : m_parent(parent), m_shape(shape), m_collisionObject(collisionObject), m_worldTransform(worldTransform),
+       m_partId(partId), m_index(index)
+       {}
+
+       SIMD_FORCE_INLINE const btTransform& getWorldTransform() const { return m_worldTransform; }
+       SIMD_FORCE_INLINE const btCollisionObject* getCollisionObject() const { return m_collisionObject; }
+       SIMD_FORCE_INLINE const btCollisionShape* getCollisionShape() const { return m_shape; }
+};
+
+#endif //BT_COLLISION_OBJECT_WRAPPER_H
index 66b93b88efa05763fe6b0968ec0f0ade16a4e8fd..4c09291692d19a1d10fb42e360a35ccccc0b296b 100644 (file)
@@ -34,6 +34,7 @@ subject to the following restrictions:
 #include "LinearMath/btStackAlloc.h"
 #include "LinearMath/btSerializer.h"
 #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
 #include "LinearMath/btStackAlloc.h"
 #include "LinearMath/btSerializer.h"
 #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 //#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
 
 
 //#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
 
@@ -207,6 +208,11 @@ void       btCollisionWorld::updateAabbs()
 }
 
 
 }
 
 
+void   btCollisionWorld::computeOverlappingPairs()
+{
+       BT_PROFILE("calculateOverlappingPairs");
+       m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
+}
 
 void   btCollisionWorld::performDiscreteCollisionDetection()
 {
 
 void   btCollisionWorld::performDiscreteCollisionDetection()
 {
@@ -216,11 +222,7 @@ void       btCollisionWorld::performDiscreteCollisionDetection()
 
        updateAabbs();
 
 
        updateAabbs();
 
-       {
-               BT_PROFILE("calculateOverlappingPairs");
-               m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
-       }
-
+       computeOverlappingPairs();
 
        btDispatcher* dispatcher = getDispatcher();
        {
 
        btDispatcher* dispatcher = getDispatcher();
        {
@@ -260,16 +262,25 @@ void      btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject)
 }
 
 
 }
 
 
-
 void   btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
                                                                                btCollisionObject* collisionObject,
                                                                                const btCollisionShape* collisionShape,
                                                                                const btTransform& colObjWorldTransform,
                                                                                RayResultCallback& resultCallback)
 void   btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
                                                                                btCollisionObject* collisionObject,
                                                                                const btCollisionShape* collisionShape,
                                                                                const btTransform& colObjWorldTransform,
                                                                                RayResultCallback& resultCallback)
+{
+       btCollisionObjectWrapper colObWrap(0,collisionShape,collisionObject,colObjWorldTransform,-1,-1);
+       btCollisionWorld::rayTestSingleInternal(rayFromTrans,rayToTrans,&colObWrap,resultCallback);
+}
+
+void   btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,const btTransform& rayToTrans,
+                                                                               const btCollisionObjectWrapper* collisionObjectWrap,
+                                                                               RayResultCallback& resultCallback)
 {
        btSphereShape pointShape(btScalar(0.0));
        pointShape.setMargin(0.f);
        const btConvexShape* castShape = &pointShape;
 {
        btSphereShape pointShape(btScalar(0.0));
        pointShape.setMargin(0.f);
        const btConvexShape* castShape = &pointShape;
+       const btCollisionShape* collisionShape = collisionObjectWrap->getCollisionShape();
+       const btTransform& colObjWorldTransform = collisionObjectWrap->getWorldTransform();
 
        if (collisionShape->isConvex())
        {
 
        if (collisionShape->isConvex())
        {
@@ -302,7 +313,7 @@ void        btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                        castResult.m_normal.normalize();
                                        btCollisionWorld::LocalRayResult localRayResult
                                                (
                                        castResult.m_normal.normalize();
                                        btCollisionWorld::LocalRayResult localRayResult
                                                (
-                                               collisionObject,
+                                               collisionObjectWrap->getCollisionObject(),
                                                0,
                                                castResult.m_normal,
                                                castResult.m_fraction
                                                0,
                                                castResult.m_normal,
                                                castResult.m_fraction
@@ -330,13 +341,13 @@ void      btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
                                {
                                        btCollisionWorld::RayResultCallback* m_resultCallback;
                                struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
                                {
                                        btCollisionWorld::RayResultCallback* m_resultCallback;
-                                       btCollisionObject*      m_collisionObject;
+                                       const btCollisionObject*        m_collisionObject;
                                        btTriangleMeshShape*    m_triangleMesh;
 
                                        btTransform m_colObjWorldTransform;
 
                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
                                        btTriangleMeshShape*    m_triangleMesh;
 
                                        btTransform m_colObjWorldTransform;
 
                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
-                                               btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*    triangleMesh,const btTransform& colObjWorldTransform):
+                                               btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,btTriangleMeshShape*      triangleMesh,const btTransform& colObjWorldTransform):
                                        //@BP Mod
                                        btTriangleRaycastCallback(from,to, resultCallback->m_flags),
                                                m_resultCallback(resultCallback),
                                        //@BP Mod
                                        btTriangleRaycastCallback(from,to, resultCallback->m_flags),
                                                m_resultCallback(resultCallback),
@@ -367,7 +378,7 @@ void        btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
 
                                };
 
 
                                };
 
-                               BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh,colObjWorldTransform);
+                               BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),triangleMesh,colObjWorldTransform);
                                rcb.m_hitFraction = resultCallback.m_closestHitFraction;
                                triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
                        } else
                                rcb.m_hitFraction = resultCallback.m_closestHitFraction;
                                triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
                        } else
@@ -385,13 +396,13 @@ void      btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
                                {
                                        btCollisionWorld::RayResultCallback* m_resultCallback;
                                struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
                                {
                                        btCollisionWorld::RayResultCallback* m_resultCallback;
-                                       btCollisionObject*      m_collisionObject;
+                                       const btCollisionObject*        m_collisionObject;
                                        btConcaveShape* m_triangleMesh;
 
                                        btTransform m_colObjWorldTransform;
 
                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
                                        btConcaveShape* m_triangleMesh;
 
                                        btTransform m_colObjWorldTransform;
 
                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
-                                               btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& colObjWorldTransform):
+                                               btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,btConcaveShape*   triangleMesh, const btTransform& colObjWorldTransform):
                                        //@BP Mod
                                        btTriangleRaycastCallback(from,to, resultCallback->m_flags),
                                                m_resultCallback(resultCallback),
                                        //@BP Mod
                                        btTriangleRaycastCallback(from,to, resultCallback->m_flags),
                                                m_resultCallback(resultCallback),
@@ -423,7 +434,7 @@ void        btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                };
 
 
                                };
 
 
-                               BridgeTriangleRaycastCallback   rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,concaveShape, colObjWorldTransform);
+                               BridgeTriangleRaycastCallback   rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),concaveShape, colObjWorldTransform);
                                rcb.m_hitFraction = resultCallback.m_closestHitFraction;
 
                                btVector3 rayAabbMinLocal = rayFromLocal;
                                rcb.m_hitFraction = resultCallback.m_closestHitFraction;
 
                                btVector3 rayAabbMinLocal = rayFromLocal;
@@ -446,6 +457,7 @@ void        btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                                : m_userCallback(user), m_i(i)
                                        { 
                                                m_closestHitFraction = m_userCallback->m_closestHitFraction;
                                                : m_userCallback(user), m_i(i)
                                        { 
                                                m_closestHitFraction = m_userCallback->m_closestHitFraction;
+                                               m_flags = m_userCallback->m_flags;
                                        }
                                        virtual bool needsCollision(btBroadphaseProxy* p) const
                                        {
                                        }
                                        virtual bool needsCollision(btBroadphaseProxy* p) const
                                        {
@@ -468,14 +480,14 @@ void      btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                
                                struct RayTester : btDbvt::ICollide
                                {
                                
                                struct RayTester : btDbvt::ICollide
                                {
-                                       btCollisionObject* m_collisionObject;
+                                       const btCollisionObject* m_collisionObject;
                                        const btCompoundShape* m_compoundShape;
                                        const btTransform& m_colObjWorldTransform;
                                        const btTransform& m_rayFromTrans;
                                        const btTransform& m_rayToTrans;
                                        RayResultCallback& m_resultCallback;
                                        
                                        const btCompoundShape* m_compoundShape;
                                        const btTransform& m_colObjWorldTransform;
                                        const btTransform& m_rayFromTrans;
                                        const btTransform& m_rayToTrans;
                                        RayResultCallback& m_resultCallback;
                                        
-                                       RayTester(btCollisionObject* collisionObject,
+                                       RayTester(const btCollisionObject* collisionObject,
                                                        const btCompoundShape* compoundShape,
                                                        const btTransform& colObjWorldTransform,
                                                        const btTransform& rayFromTrans,
                                                        const btCompoundShape* compoundShape,
                                                        const btTransform& colObjWorldTransform,
                                                        const btTransform& rayFromTrans,
@@ -491,33 +503,30 @@ void      btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                                
                                        }
                                        
                                                
                                        }
                                        
-                                       void Process(int i)
+                                       void ProcessLeaf(int i)
                                        {
                                                const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i);
                                                const btTransform& childTrans = m_compoundShape->getChildTransform(i);
                                                btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
                                                
                                        {
                                                const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i);
                                                const btTransform& childTrans = m_compoundShape->getChildTransform(i);
                                                btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
                                                
+                                               btCollisionObjectWrapper tmpOb(0,childCollisionShape,m_collisionObject,childWorldTrans,-1,i);
                                                // replace collision shape so that callback can determine the triangle
                                                // replace collision shape so that callback can determine the triangle
-                                               btCollisionShape* saveCollisionShape = m_collisionObject->getCollisionShape();
-                                               m_collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
+
+                                               
 
                                                LocalInfoAdder2 my_cb(i, &m_resultCallback);
 
 
                                                LocalInfoAdder2 my_cb(i, &m_resultCallback);
 
-                                               rayTestSingle(
+                                               rayTestSingleInternal(
                                                        m_rayFromTrans,
                                                        m_rayToTrans,
                                                        m_rayFromTrans,
                                                        m_rayToTrans,
-                                                       m_collisionObject,
-                                                       childCollisionShape,
-                                                       childWorldTrans,
+                                                       &tmpOb,
                                                        my_cb);
                                                
                                                        my_cb);
                                                
-                                               // restore
-                                               m_collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
                                        }
                                        }
-                                       
+                               
                                        void Process(const btDbvtNode* leaf)
                                        {
                                        void Process(const btDbvtNode* leaf)
                                        {
-                                               Process(leaf->dataAsInt);
+                                               ProcessLeaf(leaf->dataAsInt);
                                        }
                                };
                                
                                        }
                                };
                                
@@ -526,7 +535,7 @@ void        btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
 
 
                                RayTester rayCB(
 
 
                                RayTester rayCB(
-                                       collisionObject,
+                                       collisionObjectWrap->getCollisionObject(),
                                        compoundShape,
                                        colObjWorldTransform,
                                        rayFromTrans,
                                        compoundShape,
                                        colObjWorldTransform,
                                        rayFromTrans,
@@ -544,7 +553,7 @@ void        btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
                                {
                                        for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i)
                                        {
                                {
                                        for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i)
                                        {
-                                               rayCB.Process(i);
+                                               rayCB.ProcessLeaf(i);
                                        }       
                                }
                        }
                                        }       
                                }
                        }
@@ -558,6 +567,17 @@ void       btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
                                                                                        const btTransform& colObjWorldTransform,
                                                                                        ConvexResultCallback& resultCallback, btScalar allowedPenetration)
 {
                                                                                        const btTransform& colObjWorldTransform,
                                                                                        ConvexResultCallback& resultCallback, btScalar allowedPenetration)
 {
+       btCollisionObjectWrapper tmpOb(0,collisionShape,collisionObject,colObjWorldTransform,-1,-1);
+       btCollisionWorld::objectQuerySingleInternal(castShape,convexFromTrans,convexToTrans,&tmpOb,resultCallback,allowedPenetration);
+}
+
+void   btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,const btTransform& convexFromTrans,const btTransform& convexToTrans,
+                                                                                       const btCollisionObjectWrapper* colObjWrap,
+                                                                                       ConvexResultCallback& resultCallback, btScalar allowedPenetration)
+{
+       const btCollisionShape* collisionShape = colObjWrap->getCollisionShape();
+       const btTransform& colObjWorldTransform = colObjWrap->getWorldTransform();
+
        if (collisionShape->isConvex())
        {
                //BT_PROFILE("convexSweepConvex");
        if (collisionShape->isConvex())
        {
                //BT_PROFILE("convexSweepConvex");
@@ -587,7 +607,7 @@ void        btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
                                        castResult.m_normal.normalize();
                                        btCollisionWorld::LocalConvexResult localConvexResult
                                                (
                                        castResult.m_normal.normalize();
                                        btCollisionWorld::LocalConvexResult localConvexResult
                                                (
-                                               collisionObject,
+                                               colObjWrap->getCollisionObject(),
                                                0,
                                                castResult.m_normal,
                                                castResult.m_hitPoint,
                                                0,
                                                castResult.m_normal,
                                                castResult.m_hitPoint,
@@ -617,11 +637,11 @@ void      btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
                                struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
                                {
                                        btCollisionWorld::ConvexResultCallback* m_resultCallback;
                                struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
                                {
                                        btCollisionWorld::ConvexResultCallback* m_resultCallback;
-                                       btCollisionObject*      m_collisionObject;
+                                       const btCollisionObject*        m_collisionObject;
                                        btTriangleMeshShape*    m_triangleMesh;
 
                                        BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
                                        btTriangleMeshShape*    m_triangleMesh;
 
                                        BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
-                                               btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh, const btTransform& triangleToWorld):
+                                               btCollisionWorld::ConvexResultCallback* resultCallback, const btCollisionObject* collisionObject,btTriangleMeshShape*   triangleMesh, const btTransform& triangleToWorld):
                                        btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
                                                m_resultCallback(resultCallback),
                                                m_collisionObject(collisionObject),
                                        btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
                                                m_resultCallback(resultCallback),
                                                m_collisionObject(collisionObject),
@@ -655,7 +675,7 @@ void        btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
 
                                };
 
 
                                };
 
-                               BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform);
+                               BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,colObjWrap->getCollisionObject(),triangleMesh, colObjWorldTransform);
                                tccb.m_hitFraction = resultCallback.m_closestHitFraction;
                                tccb.m_allowedPenetration = allowedPenetration;
                                btVector3 boxMinLocal, boxMaxLocal;
                                tccb.m_hitFraction = resultCallback.m_closestHitFraction;
                                tccb.m_allowedPenetration = allowedPenetration;
                                btVector3 boxMinLocal, boxMaxLocal;
@@ -682,7 +702,7 @@ void        btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
                                                                castResult.m_normal.normalize();
                                                                btCollisionWorld::LocalConvexResult localConvexResult
                                                                        (
                                                                castResult.m_normal.normalize();
                                                                btCollisionWorld::LocalConvexResult localConvexResult
                                                                        (
-                                                                       collisionObject,
+                                                                       colObjWrap->getCollisionObject(),
                                                                        0,
                                                                        castResult.m_normal,
                                                                        castResult.m_hitPoint,
                                                                        0,
                                                                        castResult.m_normal,
                                                                        castResult.m_hitPoint,
@@ -709,11 +729,11 @@ void      btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
                                        struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
                                        {
                                                btCollisionWorld::ConvexResultCallback* m_resultCallback;
                                        struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
                                        {
                                                btCollisionWorld::ConvexResultCallback* m_resultCallback;
-                                               btCollisionObject*      m_collisionObject;
+                                               const btCollisionObject*        m_collisionObject;
                                                btConcaveShape* m_triangleMesh;
 
                                                BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
                                                btConcaveShape* m_triangleMesh;
 
                                                BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
-                                                       btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape*      triangleMesh, const btTransform& triangleToWorld):
+                                                       btCollisionWorld::ConvexResultCallback* resultCallback, const btCollisionObject* collisionObject,btConcaveShape*        triangleMesh, const btTransform& triangleToWorld):
                                                btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
                                                        m_resultCallback(resultCallback),
                                                        m_collisionObject(collisionObject),
                                                btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
                                                        m_resultCallback(resultCallback),
                                                        m_collisionObject(collisionObject),
@@ -746,7 +766,7 @@ void        btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
 
                                        };
 
 
                                        };
 
-                                       BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform);
+                                       BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,colObjWrap->getCollisionObject(),concaveShape, colObjWorldTransform);
                                        tccb.m_hitFraction = resultCallback.m_closestHitFraction;
                                        tccb.m_allowedPenetration = allowedPenetration;
                                        btVector3 boxMinLocal, boxMaxLocal;
                                        tccb.m_hitFraction = resultCallback.m_closestHitFraction;
                                        tccb.m_allowedPenetration = allowedPenetration;
                                        btVector3 boxMinLocal, boxMaxLocal;
@@ -773,9 +793,7 @@ void        btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
                                        btTransform childTrans = compoundShape->getChildTransform(i);
                                        const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
                                        btTransform childWorldTrans = colObjWorldTransform * childTrans;
                                        btTransform childTrans = compoundShape->getChildTransform(i);
                                        const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
                                        btTransform childWorldTrans = colObjWorldTransform * childTrans;
-                                       // replace collision shape so that callback can determine the triangle
-                                       btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape();
-                                       collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
+                                       
                     struct     LocalInfoAdder : public ConvexResultCallback {
                             ConvexResultCallback* m_userCallback;
                                                        int m_i;
                     struct     LocalInfoAdder : public ConvexResultCallback {
                             ConvexResultCallback* m_userCallback;
                                                        int m_i;
@@ -805,14 +823,11 @@ void      btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
 
                     LocalInfoAdder my_cb(i, &resultCallback);
                                        
 
                     LocalInfoAdder my_cb(i, &resultCallback);
                                        
+                                       btCollisionObjectWrapper tmpObj(colObjWrap,childCollisionShape,colObjWrap->getCollisionObject(),childWorldTrans,-1,i);
 
 
-                                       objectQuerySingle(castShape, convexFromTrans,convexToTrans,
-                                               collisionObject,
-                                               childCollisionShape,
-                                               childWorldTrans,
-                                               my_cb, allowedPenetration);
-                                       // restore
-                                       collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
+                                       objectQuerySingleInternal(castShape, convexFromTrans,convexToTrans,
+                                               &tmpObj,my_cb, allowedPenetration);
+                                       
                                }
                        }
                }
                                }
                        }
                }
@@ -993,13 +1008,13 @@ void     btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btT
        /* Compute AABB that encompasses angular movement */
        {
                btVector3 linVel, angVel;
        /* Compute AABB that encompasses angular movement */
        {
                btVector3 linVel, angVel;
-               btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel);
+               btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0f, linVel, angVel);
                btVector3 zeroLinVel;
                zeroLinVel.setValue(0,0,0);
                btTransform R;
                R.setIdentity ();
                R.setRotation (convexFromTrans.getRotation());
                btVector3 zeroLinVel;
                zeroLinVel.setValue(0,0,0);
                btTransform R;
                R.setIdentity ();
                R.setRotation (convexFromTrans.getRotation());
-               castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax);
+               castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0f, castShapeAabbMin, castShapeAabbMax);
        }
 
 #ifndef USE_BRUTEFORCE_RAYBROADPHASE
        }
 
 #ifndef USE_BRUTEFORCE_RAYBROADPHASE
@@ -1044,26 +1059,26 @@ struct btBridgedManifoldResult : public btManifoldResult
 
        btCollisionWorld::ContactResultCallback&        m_resultCallback;
 
 
        btCollisionWorld::ContactResultCallback&        m_resultCallback;
 
-       btBridgedManifoldResult( btCollisionObject* obj0,btCollisionObject* obj1,btCollisionWorld::ContactResultCallback& resultCallback )
-               :btManifoldResult(obj0,obj1),
+       btBridgedManifoldResult( const btCollisionObjectWrapper* obj0Wrap,const btCollisionObjectWrapper* obj1Wrap,btCollisionWorld::ContactResultCallback& resultCallback )
+               :btManifoldResult(obj0Wrap,obj1Wrap),
                m_resultCallback(resultCallback)
        {
        }
 
        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
        {
                m_resultCallback(resultCallback)
        {
        }
 
        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
        {
-               bool isSwapped = m_manifoldPtr->getBody0() != m_body0;
+               bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject();
                btVector3 pointA = pointInWorld + normalOnBInWorld * depth;
                btVector3 localA;
                btVector3 localB;
                if (isSwapped)
                {
                btVector3 pointA = pointInWorld + normalOnBInWorld * depth;
                btVector3 localA;
                btVector3 localB;
                if (isSwapped)
                {
-                       localA = m_rootTransB.invXform(pointA );
-                       localB = m_rootTransA.invXform(pointInWorld);
+                       localA = m_body1Wrap->getCollisionObject()->getWorldTransform().invXform(pointA );
+                       localB = m_body0Wrap->getCollisionObject()->getWorldTransform().invXform(pointInWorld);
                } else
                {
                } else
                {
-                       localA = m_rootTransA.invXform(pointA );
-                       localB = m_rootTransB.invXform(pointInWorld);
+                       localA = m_body0Wrap->getCollisionObject()->getWorldTransform().invXform(pointA );
+                       localB = m_body1Wrap->getCollisionObject()->getWorldTransform().invXform(pointInWorld);
                }
                
                btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth);
                }
                
                btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth);
@@ -1086,9 +1101,9 @@ struct btBridgedManifoldResult : public btManifoldResult
                }
 
                //experimental feature info, for per-triangle material etc.
                }
 
                //experimental feature info, for per-triangle material etc.
-               btCollisionObject* obj0 = isSwapped? m_body1 : m_body0;
-               btCollisionObject* obj1 = isSwapped? m_body0 : m_body1;
-               m_resultCallback.addSingleResult(newPt,obj0,newPt.m_partId0,newPt.m_index0,obj1,newPt.m_partId1,newPt.m_index1);
+               const btCollisionObjectWrapper* obj0Wrap = isSwapped? m_body1Wrap : m_body0Wrap;
+               const btCollisionObjectWrapper* obj1Wrap = isSwapped? m_body0Wrap : m_body1Wrap;
+               m_resultCallback.addSingleResult(newPt,obj0Wrap,newPt.m_partId0,newPt.m_index0,obj1Wrap,newPt.m_partId1,newPt.m_index1);
 
        }
        
 
        }
        
@@ -1120,12 +1135,16 @@ struct btSingleContactCallback : public btBroadphaseAabbCallback
                //only perform raycast if filterMask matches
                if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) 
                {
                //only perform raycast if filterMask matches
                if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) 
                {
-                       btCollisionAlgorithm* algorithm = m_world->getDispatcher()->findAlgorithm(m_collisionObject,collisionObject);
+                       btCollisionObjectWrapper ob0(0,m_collisionObject->getCollisionShape(),m_collisionObject,m_collisionObject->getWorldTransform(),-1,-1);
+                       btCollisionObjectWrapper ob1(0,collisionObject->getCollisionShape(),collisionObject,collisionObject->getWorldTransform(),-1,-1);
+
+                       btCollisionAlgorithm* algorithm = m_world->getDispatcher()->findAlgorithm(&ob0,&ob1);
                        if (algorithm)
                        {
                        if (algorithm)
                        {
-                               btBridgedManifoldResult contactPointResult(m_collisionObject,collisionObject, m_resultCallback);
+                               btBridgedManifoldResult contactPointResult(&ob0,&ob1, m_resultCallback);
                                //discrete collision detection query
                                //discrete collision detection query
-                               algorithm->processCollision(m_collisionObject,collisionObject, m_world->getDispatchInfo(),&contactPointResult);
+                               
+                               algorithm->processCollision(&ob0,&ob1, m_world->getDispatchInfo(),&contactPointResult);
 
                                algorithm->~btCollisionAlgorithm();
                                m_world->getDispatcher()->freeCollisionAlgorithm(algorithm);
 
                                algorithm->~btCollisionAlgorithm();
                                m_world->getDispatcher()->freeCollisionAlgorithm(algorithm);
@@ -1152,12 +1171,15 @@ void    btCollisionWorld::contactTest( btCollisionObject* colObj, ContactResultCall
 ///it reports one or more contact points (including the one with deepest penetration)
 void   btCollisionWorld::contactPairTest(btCollisionObject* colObjA, btCollisionObject* colObjB, ContactResultCallback& resultCallback)
 {
 ///it reports one or more contact points (including the one with deepest penetration)
 void   btCollisionWorld::contactPairTest(btCollisionObject* colObjA, btCollisionObject* colObjB, ContactResultCallback& resultCallback)
 {
-       btCollisionAlgorithm* algorithm = getDispatcher()->findAlgorithm(colObjA,colObjB);
+       btCollisionObjectWrapper obA(0,colObjA->getCollisionShape(),colObjA,colObjA->getWorldTransform(),-1,-1);
+       btCollisionObjectWrapper obB(0,colObjB->getCollisionShape(),colObjB,colObjB->getWorldTransform(),-1,-1);
+
+       btCollisionAlgorithm* algorithm = getDispatcher()->findAlgorithm(&obA,&obB);
        if (algorithm)
        {
        if (algorithm)
        {
-               btBridgedManifoldResult contactPointResult(colObjA,colObjB, resultCallback);
+               btBridgedManifoldResult contactPointResult(&obA,&obB, resultCallback);
                //discrete collision detection query
                //discrete collision detection query
-               algorithm->processCollision(colObjA,colObjB, getDispatchInfo(),&contactPointResult);
+               algorithm->processCollision(&obA,&obB, getDispatchInfo(),&contactPointResult);
 
                algorithm->~btCollisionAlgorithm();
                getDispatcher()->freeCollisionAlgorithm(algorithm);
 
                algorithm->~btCollisionAlgorithm();
                getDispatcher()->freeCollisionAlgorithm(algorithm);
@@ -1231,163 +1253,162 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
        } else
        {
 
        } else
        {
 
-               /// for polyhedral shapes
-               if (shape->isPolyhedral())
-               {
-                       btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
-
-                       int i;
-                       if (polyshape->getConvexPolyhedron())
-                       {
-                               const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron();
-                               for (i=0;i<poly->m_faces.size();i++)
-                               {
-                                       btVector3 centroid(0,0,0);
-                                       int numVerts = poly->m_faces[i].m_indices.size();
-                                       if (numVerts)
-                                       {
-                                               int lastV = poly->m_faces[i].m_indices[numVerts-1];
-                                               for (int v=0;v<poly->m_faces[i].m_indices.size();v++)
-                                               {
-                                                       int curVert = poly->m_faces[i].m_indices[v];
-                                                       centroid+=poly->m_vertices[curVert];
-                                                       getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color);
-                                                       lastV = curVert;
-                                               }
-                                       }
-                                       centroid*= btScalar(1.f)/btScalar(numVerts);
-                    if (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawNormals)
+        switch (shape->getShapeType())
+        {
+
+        case BOX_SHAPE_PROXYTYPE:
+            {
+                const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
+                btVector3 halfExtents = boxShape->getHalfExtentsWithMargin();
+                getDebugDrawer()->drawBox(-halfExtents,halfExtents,worldTransform,color);
+                break;
+            }
+
+        case SPHERE_SHAPE_PROXYTYPE:
+            {
+                const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
+                btScalar radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
+
+                getDebugDrawer()->drawSphere(radius, worldTransform, color);
+                break;
+            }
+        case MULTI_SPHERE_SHAPE_PROXYTYPE:
+            {
+                const btMultiSphereShape* multiSphereShape = static_cast<const btMultiSphereShape*>(shape);
+
+                btTransform childTransform;
+                childTransform.setIdentity();
+
+                for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--)
+                {
+                    childTransform.setOrigin(multiSphereShape->getSpherePosition(i));
+                    getDebugDrawer()->drawSphere(multiSphereShape->getSphereRadius(i), worldTransform*childTransform, color);
+                }
+
+                break;
+            }
+        case CAPSULE_SHAPE_PROXYTYPE:
+            {
+                const btCapsuleShape* capsuleShape = static_cast<const btCapsuleShape*>(shape);
+
+                btScalar radius = capsuleShape->getRadius();
+                btScalar halfHeight = capsuleShape->getHalfHeight();
+
+                int upAxis = capsuleShape->getUpAxis();
+                getDebugDrawer()->drawCapsule(radius, halfHeight, upAxis, worldTransform, color);
+                break;
+            }
+        case CONE_SHAPE_PROXYTYPE:
+            {
+                const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
+                btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
+                btScalar height = coneShape->getHeight();//+coneShape->getMargin();
+
+                int upAxis= coneShape->getConeUpIndex();
+                getDebugDrawer()->drawCone(radius, height, upAxis, worldTransform, color);
+                break;
+
+            }
+        case CYLINDER_SHAPE_PROXYTYPE:
+            {
+                const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
+                int upAxis = cylinder->getUpAxis();
+                btScalar radius = cylinder->getRadius();
+                btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
+                getDebugDrawer()->drawCylinder(radius, halfHeight, upAxis, worldTransform, color);
+                break;
+            }
+
+        case STATIC_PLANE_PROXYTYPE:
+            {
+                const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape);
+                btScalar planeConst = staticPlaneShape->getPlaneConstant();
+                const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
+                getDebugDrawer()->drawPlane(planeNormal, planeConst,worldTransform, color);
+                break;
+
+            }
+        default:
+            {
+
+                /// for polyhedral shapes
+                if (shape->isPolyhedral())
+                {
+                    btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
+                    
+                    int i;
+                    if (polyshape->getConvexPolyhedron())
+                    {
+                        const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron();
+                        for (i=0;i<poly->m_faces.size();i++)
+                        {
+                            btVector3 centroid(0,0,0);
+                            int numVerts = poly->m_faces[i].m_indices.size();
+                            if (numVerts)
+                            {
+                                int lastV = poly->m_faces[i].m_indices[numVerts-1];
+                                for (int v=0;v<poly->m_faces[i].m_indices.size();v++)
+                                {
+                                    int curVert = poly->m_faces[i].m_indices[v];
+                                    centroid+=poly->m_vertices[curVert];
+                                    getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color);
+                                    lastV = curVert;
+                                }
+                            }
+                            centroid*= btScalar(1.f)/btScalar(numVerts);
+                            if (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawNormals)
+                            {
+                                btVector3 normalColor(1,1,0);
+                                btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
+                                getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
+                            }
+                            
+                        }
+                        
+                        
+                    } else
                     {
                     {
-                                         btVector3 normalColor(1,1,0);
-                                         btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
-                                         getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
+                        for (i=0;i<polyshape->getNumEdges();i++)
+                        {
+                            btVector3 a,b;
+                            polyshape->getEdge(i,a,b);
+                            btVector3 wa = worldTransform * a;
+                            btVector3 wb = worldTransform * b;
+                            getDebugDrawer()->drawLine(wa,wb,color);
+                        }
                     }
                     }
-                                       
-                               }
-
-                               
-                       } else
-                       {
-                               for (i=0;i<polyshape->getNumEdges();i++)
-                               {
-                                       btVector3 a,b;
-                                       polyshape->getEdge(i,a,b);
-                                       btVector3 wa = worldTransform * a;
-                                       btVector3 wb = worldTransform * b;
-                                       getDebugDrawer()->drawLine(wa,wb,color);
-                               }
-                       }
-
-
-               }
-               else
-               {
-                       switch (shape->getShapeType())
-                       {
-
-                       case BOX_SHAPE_PROXYTYPE:
-                               {
-                                       const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
-                                       btVector3 halfExtents = boxShape->getHalfExtentsWithMargin();
-                                       getDebugDrawer()->drawBox(-halfExtents,halfExtents,worldTransform,color);
-                                       break;
-                               }
-
-                       case SPHERE_SHAPE_PROXYTYPE:
-                               {
-                                       const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
-                                       btScalar radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
-
-                                       getDebugDrawer()->drawSphere(radius, worldTransform, color);
-                                       break;
-                               }
-                       case MULTI_SPHERE_SHAPE_PROXYTYPE:
-                               {
-                                       const btMultiSphereShape* multiSphereShape = static_cast<const btMultiSphereShape*>(shape);
-
-                                       btTransform childTransform;
-                                       childTransform.setIdentity();
-
-                                       for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--)
-                                       {
-                                               childTransform.setOrigin(multiSphereShape->getSpherePosition(i));
-                                               getDebugDrawer()->drawSphere(multiSphereShape->getSphereRadius(i), worldTransform*childTransform, color);
-                                       }
-
-                                       break;
-                               }
-                       case CAPSULE_SHAPE_PROXYTYPE:
-                               {
-                                       const btCapsuleShape* capsuleShape = static_cast<const btCapsuleShape*>(shape);
-
-                                       btScalar radius = capsuleShape->getRadius();
-                                       btScalar halfHeight = capsuleShape->getHalfHeight();
-
-                                       int upAxis = capsuleShape->getUpAxis();
-                                       getDebugDrawer()->drawCapsule(radius, halfHeight, upAxis, worldTransform, color);
-                                       break;
-                               }
-                       case CONE_SHAPE_PROXYTYPE:
-                               {
-                                       const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
-                                       btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
-                                       btScalar height = coneShape->getHeight();//+coneShape->getMargin();
-
-                                       int upAxis= coneShape->getConeUpIndex();
-                                       getDebugDrawer()->drawCone(radius, height, upAxis, worldTransform, color);
-                                       break;
-
-                               }
-                       case CYLINDER_SHAPE_PROXYTYPE:
-                               {
-                                       const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
-                                       int upAxis = cylinder->getUpAxis();
-                                       btScalar radius = cylinder->getRadius();
-                                       btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
-                                       getDebugDrawer()->drawCylinder(radius, halfHeight, upAxis, worldTransform, color);
-                                       break;
-                               }
-
-                       case STATIC_PLANE_PROXYTYPE:
-                               {
-                                       const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape);
-                                       btScalar planeConst = staticPlaneShape->getPlaneConstant();
-                                       const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
-                                       getDebugDrawer()->drawPlane(planeNormal, planeConst,worldTransform, color);
-                                       break;
-
-                               }
-                       default:
-                               {
-
-                                       if (shape->isConcave())
-                                       {
-                                               btConcaveShape* concaveMesh = (btConcaveShape*) shape;
-
-                                               ///@todo pass camera, for some culling? no -> we are not a graphics lib
-                                               btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
-                                               btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
-
-                                               DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
-                                               concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
-
-                                       }
-
-                                       if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
-                                       {
-                                               btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
-                                               //todo: pass camera for some culling                    
-                                               btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
-                                               btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
-                                               //DebugDrawcallback drawCallback;
-                                               DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
-                                               convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
-                                       }
-
-
-                                       
-                               }
-                       }
+                    
+                    
+                }
+                    
+                if (shape->isConcave())
+                {
+                    btConcaveShape* concaveMesh = (btConcaveShape*) shape;
+
+                    ///@todo pass camera, for some culling? no -> we are not a graphics lib
+                    btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
+                    btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
+
+                    DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
+                    concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
+
+                }
+
+                if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
+                {
+                    btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
+                    //todo: pass camera for some culling                       
+                    btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
+                    btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
+                    //DebugDrawcallback drawCallback;
+                    DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
+                    convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
+                }
+
+
+                
+            }
+       
                }
        }
 }
                }
        }
 }
@@ -1398,7 +1419,7 @@ void      btCollisionWorld::debugDrawWorld()
        if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
        {
                int numManifolds = getDispatcher()->getNumManifolds();
        if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
        {
                int numManifolds = getDispatcher()->getNumManifolds();
-               btVector3 color(1,0.65,0);
+               btVector3 color(1,1,0);
                for (int i=0;i<numManifolds;i++)
                {
                        btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
                for (int i=0;i<numManifolds;i++)
                {
                        btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
index 0a92d2d6e158d2bcba926ec734553fb37923e44c..9412242e8a37742aa0ea1ccf69e4ba02466edfc3 100644 (file)
@@ -144,6 +144,11 @@ public:
        void    updateSingleAabb(btCollisionObject* colObj);
 
        virtual void    updateAabbs();
        void    updateSingleAabb(btCollisionObject* colObj);
 
        virtual void    updateAabbs();
+
+       ///the computeOverlappingPairs is usually already called by performDiscreteCollisionDetection (or stepSimulation)
+       ///it can be useful to use if you perform ray tests without collision detection/simulation
+       virtual void    computeOverlappingPairs();
+
        
        virtual void    setDebugDrawer(btIDebugDraw*    debugDrawer)
        {
        
        virtual void    setDebugDrawer(btIDebugDraw*    debugDrawer)
        {
@@ -173,7 +178,7 @@ public:
 
        struct  LocalRayResult
        {
 
        struct  LocalRayResult
        {
-               LocalRayResult(btCollisionObject*       collisionObject, 
+               LocalRayResult(const btCollisionObject* collisionObject, 
                        LocalShapeInfo* localShapeInfo,
                        const btVector3&                hitNormalLocal,
                        btScalar hitFraction)
                        LocalShapeInfo* localShapeInfo,
                        const btVector3&                hitNormalLocal,
                        btScalar hitFraction)
@@ -184,7 +189,7 @@ public:
                {
                }
 
                {
                }
 
-               btCollisionObject*              m_collisionObject;
+               const btCollisionObject*                m_collisionObject;
                LocalShapeInfo*                 m_localShapeInfo;
                btVector3                               m_hitNormalLocal;
                btScalar                                m_hitFraction;
                LocalShapeInfo*                 m_localShapeInfo;
                btVector3                               m_hitNormalLocal;
                btScalar                                m_hitFraction;
@@ -195,11 +200,11 @@ public:
        struct  RayResultCallback
        {
                btScalar        m_closestHitFraction;
        struct  RayResultCallback
        {
                btScalar        m_closestHitFraction;
-               btCollisionObject*              m_collisionObject;
+               const btCollisionObject*                m_collisionObject;
                short int       m_collisionFilterGroup;
                short int       m_collisionFilterMask;
                short int       m_collisionFilterGroup;
                short int       m_collisionFilterMask;
-      //@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback
-      unsigned int m_flags;
+               //@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback.h. Apply any of the EFlags defined there on m_flags here to invoke.
+               unsigned int m_flags;
 
                virtual ~RayResultCallback()
                {
 
                virtual ~RayResultCallback()
                {
@@ -214,8 +219,8 @@ public:
                        m_collisionObject(0),
                        m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
                        m_collisionFilterMask(btBroadphaseProxy::AllFilter),
                        m_collisionObject(0),
                        m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
                        m_collisionFilterMask(btBroadphaseProxy::AllFilter),
-         //@BP Mod
-         m_flags(0)
+                       //@BP Mod
+                       m_flags(0)
                {
                }
 
                {
                }
 
@@ -272,7 +277,7 @@ public:
                {
                }
 
                {
                }
 
-               btAlignedObjectArray<btCollisionObject*>                m_collisionObjects;
+               btAlignedObjectArray<const btCollisionObject*>          m_collisionObjects;
 
                btVector3       m_rayFromWorld;//used to calculate hitPointWorld from hitFraction
                btVector3       m_rayToWorld;
 
                btVector3       m_rayFromWorld;//used to calculate hitPointWorld from hitFraction
                btVector3       m_rayToWorld;
@@ -306,7 +311,7 @@ public:
 
        struct LocalConvexResult
        {
 
        struct LocalConvexResult
        {
-               LocalConvexResult(btCollisionObject*    hitCollisionObject, 
+               LocalConvexResult(const btCollisionObject*      hitCollisionObject, 
                        LocalShapeInfo* localShapeInfo,
                        const btVector3&                hitNormalLocal,
                        const btVector3&                hitPointLocal,
                        LocalShapeInfo* localShapeInfo,
                        const btVector3&                hitNormalLocal,
                        const btVector3&                hitPointLocal,
@@ -320,7 +325,7 @@ public:
                {
                }
 
                {
                }
 
-               btCollisionObject*              m_hitCollisionObject;
+               const btCollisionObject*                m_hitCollisionObject;
                LocalShapeInfo*                 m_localShapeInfo;
                btVector3                               m_hitNormalLocal;
                btVector3                               m_hitPointLocal;
                LocalShapeInfo*                 m_localShapeInfo;
                btVector3                               m_hitNormalLocal;
                btVector3                               m_hitPointLocal;
@@ -376,7 +381,7 @@ public:
 
                btVector3       m_hitNormalWorld;
                btVector3       m_hitPointWorld;
 
                btVector3       m_hitNormalWorld;
                btVector3       m_hitPointWorld;
-               btCollisionObject*      m_hitCollisionObject;
+               const btCollisionObject*        m_hitCollisionObject;
                
                virtual btScalar        addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace)
                {
                
                virtual btScalar        addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace)
                {
@@ -421,7 +426,7 @@ public:
                        return collides;
                }
 
                        return collides;
                }
 
-               virtual btScalar        addSingleResult(btManifoldPoint& cp,    const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1) = 0;
+               virtual btScalar        addSingleResult(btManifoldPoint& cp,    const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1) = 0;
        };
 
 
        };
 
 
@@ -457,6 +462,10 @@ public:
                                          const btTransform& colObjWorldTransform,
                                          RayResultCallback& resultCallback);
 
                                          const btTransform& colObjWorldTransform,
                                          RayResultCallback& resultCallback);
 
+       static void     rayTestSingleInternal(const btTransform& rayFromTrans,const btTransform& rayToTrans,
+                                         const btCollisionObjectWrapper* collisionObjectWrap,
+                                         RayResultCallback& resultCallback);
+
        /// objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest.
        static void     objectQuerySingle(const btConvexShape* castShape, const btTransform& rayFromTrans,const btTransform& rayToTrans,
                                          btCollisionObject* collisionObject,
        /// objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest.
        static void     objectQuerySingle(const btConvexShape* castShape, const btTransform& rayFromTrans,const btTransform& rayToTrans,
                                          btCollisionObject* collisionObject,
@@ -464,6 +473,10 @@ public:
                                          const btTransform& colObjWorldTransform,
                                          ConvexResultCallback& resultCallback, btScalar        allowedPenetration);
 
                                          const btTransform& colObjWorldTransform,
                                          ConvexResultCallback& resultCallback, btScalar        allowedPenetration);
 
+       static void     objectQuerySingleInternal(const btConvexShape* castShape,const btTransform& convexFromTrans,const btTransform& convexToTrans,
+                                                                                       const btCollisionObjectWrapper* colObjWrap,
+                                                                                       ConvexResultCallback& resultCallback, btScalar allowedPenetration);
+
        virtual void    addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
 
        btCollisionObjectArray& getCollisionObjectArray()
        virtual void    addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
 
        btCollisionObjectArray& getCollisionObjectArray()
index 54889a6375d1540aea34d56425ebd2b168e3ccd2..39b86a289183c52563abe3bbaa2e1b94b28e6bc6 100644 (file)
@@ -20,30 +20,32 @@ subject to the following restrictions:
 #include "LinearMath/btIDebugDraw.h"
 #include "LinearMath/btAabbUtil2.h"
 #include "btManifoldResult.h"
 #include "LinearMath/btIDebugDraw.h"
 #include "LinearMath/btAabbUtil2.h"
 #include "btManifoldResult.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 
-btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
-:btActivatingCollisionAlgorithm(ci,body0,body1),
+btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped)
+:btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
 m_isSwapped(isSwapped),
 m_sharedManifold(ci.m_manifold)
 {
        m_ownsManifold = false;
 
 m_isSwapped(isSwapped),
 m_sharedManifold(ci.m_manifold)
 {
        m_ownsManifold = false;
 
-       btCollisionObject* colObj = m_isSwapped? body1 : body0;
-       btAssert (colObj->getCollisionShape()->isCompound());
+       const btCollisionObjectWrapper* colObjWrap = m_isSwapped? body1Wrap : body0Wrap;
+       btAssert (colObjWrap->getCollisionShape()->isCompound());
        
        
-       btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
+       const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(colObjWrap->getCollisionShape());
        m_compoundShapeRevision = compoundShape->getUpdateRevision();
        
        m_compoundShapeRevision = compoundShape->getUpdateRevision();
        
-       preallocateChildAlgorithms(body0,body1);
+       
+       preallocateChildAlgorithms(body0Wrap,body1Wrap);
 }
 
 }
 
-void   btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1)
+void   btCompoundCollisionAlgorithm::preallocateChildAlgorithms(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
 {
 {
-       btCollisionObject* colObj = m_isSwapped? body1 : body0;
-       btCollisionObject* otherObj = m_isSwapped? body0 : body1;
-       btAssert (colObj->getCollisionShape()->isCompound());
+       const btCollisionObjectWrapper* colObjWrap = m_isSwapped? body1Wrap : body0Wrap;
+       const btCollisionObjectWrapper* otherObjWrap = m_isSwapped? body0Wrap : body1Wrap;
+       btAssert (colObjWrap->getCollisionShape()->isCompound());
        
        
-       btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
+       const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(colObjWrap->getCollisionShape());
 
        int numChildren = compoundShape->getNumChildShapes();
        int i;
 
        int numChildren = compoundShape->getNumChildShapes();
        int i;
@@ -56,11 +58,11 @@ void        btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject*
                        m_childCollisionAlgorithms[i] = 0;
                } else
                {
                        m_childCollisionAlgorithms[i] = 0;
                } else
                {
-                       btCollisionShape* tmpShape = colObj->getCollisionShape();
-                       btCollisionShape* childShape = compoundShape->getChildShape(i);
-                       colObj->internalSetTemporaryCollisionShape( childShape );
-                       m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(colObj,otherObj,m_sharedManifold);
-                       colObj->internalSetTemporaryCollisionShape( tmpShape );
+                       
+                       const btCollisionShape* childShape = compoundShape->getChildShape(i);
+
+                       btCollisionObjectWrapper childWrap(colObjWrap,childShape,colObjWrap->getCollisionObject(),colObjWrap->getWorldTransform(),-1,i);//wrong child trans, but unused (hopefully)
+                       m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(&childWrap,otherObjWrap,m_sharedManifold);
                }
        }
 }
                }
        }
 }
@@ -92,19 +94,16 @@ struct      btCompoundLeafCallback : btDbvt::ICollide
 
 public:
 
 
 public:
 
-       btCollisionObject* m_compoundColObj;
-       btCollisionObject* m_otherObj;
+       const btCollisionObjectWrapper* m_compoundColObjWrap;
+       const btCollisionObjectWrapper* m_otherObjWrap;
        btDispatcher* m_dispatcher;
        const btDispatcherInfo& m_dispatchInfo;
        btManifoldResult*       m_resultOut;
        btCollisionAlgorithm**  m_childCollisionAlgorithms;
        btPersistentManifold*   m_sharedManifold;
        btDispatcher* m_dispatcher;
        const btDispatcherInfo& m_dispatchInfo;
        btManifoldResult*       m_resultOut;
        btCollisionAlgorithm**  m_childCollisionAlgorithms;
        btPersistentManifold*   m_sharedManifold;
-
-
-
-
-       btCompoundLeafCallback (btCollisionObject* compoundObj,btCollisionObject* otherObj,btDispatcher* dispatcher,const btDispatcherInfo& dispatchInfo,btManifoldResult*      resultOut,btCollisionAlgorithm**        childCollisionAlgorithms,btPersistentManifold*  sharedManifold)
-               :m_compoundColObj(compoundObj),m_otherObj(otherObj),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut),
+       
+       btCompoundLeafCallback (const btCollisionObjectWrapper* compoundObjWrap,const btCollisionObjectWrapper* otherObjWrap,btDispatcher* dispatcher,const btDispatcherInfo& dispatchInfo,btManifoldResult*    resultOut,btCollisionAlgorithm**        childCollisionAlgorithms,btPersistentManifold*  sharedManifold)
+               :m_compoundColObjWrap(compoundObjWrap),m_otherObjWrap(otherObjWrap),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut),
                m_childCollisionAlgorithms(childCollisionAlgorithms),
                m_sharedManifold(sharedManifold)
        {
                m_childCollisionAlgorithms(childCollisionAlgorithms),
                m_sharedManifold(sharedManifold)
        {
@@ -112,73 +111,89 @@ public:
        }
 
 
        }
 
 
-       void    ProcessChildShape(btCollisionShape* childShape,int index)
+       void    ProcessChildShape(const btCollisionShape* childShape,int index)
        {
                btAssert(index>=0);
        {
                btAssert(index>=0);
-               btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
+               const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(m_compoundColObjWrap->getCollisionShape());
                btAssert(index<compoundShape->getNumChildShapes());
 
 
                //backup
                btAssert(index<compoundShape->getNumChildShapes());
 
 
                //backup
-               btTransform     orgTrans = m_compoundColObj->getWorldTransform();
-               btTransform     orgInterpolationTrans = m_compoundColObj->getInterpolationWorldTransform();
+               btTransform     orgTrans = m_compoundColObjWrap->getWorldTransform();
+               btTransform     orgInterpolationTrans = m_compoundColObjWrap->getWorldTransform();
                const btTransform& childTrans = compoundShape->getChildTransform(index);
                btTransform     newChildWorldTrans = orgTrans*childTrans ;
 
                //perform an AABB check first
                btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
                childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
                const btTransform& childTrans = compoundShape->getChildTransform(index);
                btTransform     newChildWorldTrans = orgTrans*childTrans ;
 
                //perform an AABB check first
                btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
                childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
-               m_otherObj->getCollisionShape()->getAabb(m_otherObj->getWorldTransform(),aabbMin1,aabbMax1);
+               m_otherObjWrap->getCollisionShape()->getAabb(m_otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1);
 
                if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
                {
 
 
                if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
                {
 
-                       m_compoundColObj->setWorldTransform( newChildWorldTrans);
-                       m_compoundColObj->setInterpolationWorldTransform(newChildWorldTrans);
+                       btCollisionObjectWrapper compoundWrap(this->m_compoundColObjWrap,childShape,m_compoundColObjWrap->getCollisionObject(),newChildWorldTrans,-1,index);
 
 
-                       //the contactpoint is still projected back using the original inverted worldtrans
-                       btCollisionShape* tmpShape = m_compoundColObj->getCollisionShape();
-                       m_compoundColObj->internalSetTemporaryCollisionShape( childShape );
 
 
+                       //the contactpoint is still projected back using the original inverted worldtrans
                        if (!m_childCollisionAlgorithms[index])
                        if (!m_childCollisionAlgorithms[index])
-                               m_childCollisionAlgorithms[index] = m_dispatcher->findAlgorithm(m_compoundColObj,m_otherObj,m_sharedManifold);
+                               m_childCollisionAlgorithms[index] = m_dispatcher->findAlgorithm(&compoundWrap,m_otherObjWrap,m_sharedManifold);
+
+                       
+                       const btCollisionObjectWrapper* tmpWrap = 0;
 
                        ///detect swapping case
 
                        ///detect swapping case
-                       if (m_resultOut->getBody0Internal() == m_compoundColObj)
+                       if (m_resultOut->getBody0Internal() == m_compoundColObjWrap->getCollisionObject())
                        {
                        {
+                               tmpWrap = m_resultOut->getBody0Wrap();
+                               m_resultOut->setBody0Wrap(&compoundWrap);
                                m_resultOut->setShapeIdentifiersA(-1,index);
                        } else
                        {
                                m_resultOut->setShapeIdentifiersA(-1,index);
                        } else
                        {
+                               tmpWrap = m_resultOut->getBody1Wrap();
+                               m_resultOut->setBody1Wrap(&compoundWrap);
                                m_resultOut->setShapeIdentifiersB(-1,index);
                        }
 
                                m_resultOut->setShapeIdentifiersB(-1,index);
                        }
 
-                       m_childCollisionAlgorithms[index]->processCollision(m_compoundColObj,m_otherObj,m_dispatchInfo,m_resultOut);
+
+                       m_childCollisionAlgorithms[index]->processCollision(&compoundWrap,m_otherObjWrap,m_dispatchInfo,m_resultOut);
+
+#if 0
                        if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
                        {
                                btVector3 worldAabbMin,worldAabbMax;
                                m_dispatchInfo.m_debugDraw->drawAabb(aabbMin0,aabbMax0,btVector3(1,1,1));
                                m_dispatchInfo.m_debugDraw->drawAabb(aabbMin1,aabbMax1,btVector3(1,1,1));
                        }
                        if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
                        {
                                btVector3 worldAabbMin,worldAabbMax;
                                m_dispatchInfo.m_debugDraw->drawAabb(aabbMin0,aabbMax0,btVector3(1,1,1));
                                m_dispatchInfo.m_debugDraw->drawAabb(aabbMin1,aabbMax1,btVector3(1,1,1));
                        }
+#endif
+
+                       if (m_resultOut->getBody0Internal() == m_compoundColObjWrap->getCollisionObject())
+                       {
+                               m_resultOut->setBody0Wrap(tmpWrap);
+                       } else
+                       {
+                               m_resultOut->setBody1Wrap(tmpWrap);
+                       }
                        
                        
-                       //revert back transform
-                       m_compoundColObj->internalSetTemporaryCollisionShape( tmpShape);
-                       m_compoundColObj->setWorldTransform(  orgTrans );
-                       m_compoundColObj->setInterpolationWorldTransform(orgInterpolationTrans);
                }
        }
        void            Process(const btDbvtNode* leaf)
        {
                int index = leaf->dataAsInt;
 
                }
        }
        void            Process(const btDbvtNode* leaf)
        {
                int index = leaf->dataAsInt;
 
-               btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
-               btCollisionShape* childShape = compoundShape->getChildShape(index);
+               const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(m_compoundColObjWrap->getCollisionShape());
+               const btCollisionShape* childShape = compoundShape->getChildShape(index);
+
+#if 0
                if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
                {
                        btVector3 worldAabbMin,worldAabbMax;
                if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
                {
                        btVector3 worldAabbMin,worldAabbMax;
-                       btTransform     orgTrans = m_compoundColObj->getWorldTransform();
+                       btTransform     orgTrans = m_compoundColObjWrap->getWorldTransform();
                        btTransformAabb(leaf->volume.Mins(),leaf->volume.Maxs(),0.,orgTrans,worldAabbMin,worldAabbMax);
                        m_dispatchInfo.m_debugDraw->drawAabb(worldAabbMin,worldAabbMax,btVector3(1,0,0));
                }
                        btTransformAabb(leaf->volume.Mins(),leaf->volume.Maxs(),0.,orgTrans,worldAabbMin,worldAabbMax);
                        m_dispatchInfo.m_debugDraw->drawAabb(worldAabbMin,worldAabbMax,btVector3(1,0,0));
                }
+#endif
+
                ProcessChildShape(childShape,index);
 
        }
                ProcessChildShape(childShape,index);
 
        }
@@ -189,15 +204,13 @@ public:
 
 
 
 
 
 
-void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btCompoundCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
 {
-       btCollisionObject* colObj = m_isSwapped? body1 : body0;
-       btCollisionObject* otherObj = m_isSwapped? body0 : body1;
-
-       
+       const btCollisionObjectWrapper* colObjWrap = m_isSwapped? body1Wrap : body0Wrap;
+       const btCollisionObjectWrapper* otherObjWrap = m_isSwapped? body0Wrap : body1Wrap;
 
 
-       btAssert (colObj->getCollisionShape()->isCompound());
-       btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
+       btAssert (colObjWrap->getCollisionShape()->isCompound());
+       const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(colObjWrap->getCollisionShape());
 
        ///btCompoundShape might have changed:
        ////make sure the internal child collision algorithm caches are still valid
 
        ///btCompoundShape might have changed:
        ////make sure the internal child collision algorithm caches are still valid
@@ -206,13 +219,13 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
                ///clear and update all
                removeChildAlgorithms();
                
                ///clear and update all
                removeChildAlgorithms();
                
-               preallocateChildAlgorithms(body0,body1);
+               preallocateChildAlgorithms(body0Wrap,body1Wrap);
        }
 
 
        }
 
 
-       btDbvt* tree = compoundShape->getDynamicAabbTree();
+       const btDbvt* tree = compoundShape->getDynamicAabbTree();
        //use a dynamic aabb tree to cull potential child-overlaps
        //use a dynamic aabb tree to cull potential child-overlaps
-       btCompoundLeafCallback  callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
+       btCompoundLeafCallback  callback(colObjWrap,otherObjWrap,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
 
        ///we need to refresh all contact manifolds
        ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep
 
        ///we need to refresh all contact manifolds
        ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep
@@ -244,8 +257,8 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
 
                btVector3 localAabbMin,localAabbMax;
                btTransform otherInCompoundSpace;
 
                btVector3 localAabbMin,localAabbMax;
                btTransform otherInCompoundSpace;
-               otherInCompoundSpace = colObj->getWorldTransform().inverse() * otherObj->getWorldTransform();
-               otherObj->getCollisionShape()->getAabb(otherInCompoundSpace,localAabbMin,localAabbMax);
+               otherInCompoundSpace = colObjWrap->getWorldTransform().inverse() * otherObjWrap->getWorldTransform();
+               otherObjWrap->getCollisionShape()->getAabb(otherInCompoundSpace,localAabbMin,localAabbMax);
 
                const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
                //process all children, that overlap with  the given AABB bounds
 
                const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
                //process all children, that overlap with  the given AABB bounds
@@ -267,7 +280,7 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
                int numChildren = m_childCollisionAlgorithms.size();
                int i;
                btManifoldArray manifoldArray;
                int numChildren = m_childCollisionAlgorithms.size();
                int i;
                btManifoldArray manifoldArray;
-        btCollisionShape* childShape = 0;
+        const btCollisionShape* childShape = 0;
         btTransform    orgTrans;
         btTransform    orgInterpolationTrans;
         btTransform    newChildWorldTrans;
         btTransform    orgTrans;
         btTransform    orgInterpolationTrans;
         btTransform    newChildWorldTrans;
@@ -279,14 +292,14 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
                        {
                                childShape = compoundShape->getChildShape(i);
                        //if not longer overlapping, remove the algorithm
                        {
                                childShape = compoundShape->getChildShape(i);
                        //if not longer overlapping, remove the algorithm
-                orgTrans = colObj->getWorldTransform();
-                orgInterpolationTrans = colObj->getInterpolationWorldTransform();
+                orgTrans = colObjWrap->getWorldTransform();
+                orgInterpolationTrans = colObjWrap->getWorldTransform();
                                const btTransform& childTrans = compoundShape->getChildTransform(i);
                 newChildWorldTrans = orgTrans*childTrans ;
 
                                //perform an AABB check first
                                childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
                                const btTransform& childTrans = compoundShape->getChildTransform(i);
                 newChildWorldTrans = orgTrans*childTrans ;
 
                                //perform an AABB check first
                                childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
-                               otherObj->getCollisionShape()->getAabb(otherObj->getWorldTransform(),aabbMin1,aabbMax1);
+                               otherObjWrap->getCollisionShape()->getAabb(otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1);
 
                                if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
                                {
 
                                if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
                                {
@@ -301,7 +314,8 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
 
 btScalar       btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
 
 btScalar       btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
-
+       btAssert(0);
+       //needs to be fixed, using btCollisionObjectWrapper and NOT modifying internal data structures
        btCollisionObject* colObj = m_isSwapped? body1 : body0;
        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
 
        btCollisionObject* colObj = m_isSwapped? body1 : body0;
        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
 
@@ -324,8 +338,7 @@ btScalar    btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject*
     btScalar frac;
        for (i=0;i<numChildren;i++)
        {
     btScalar frac;
        for (i=0;i<numChildren;i++)
        {
-               //temporarily exchange parent btCollisionShape with childShape, and recurse
-               btCollisionShape* childShape = compoundShape->getChildShape(i);
+               //btCollisionShape* childShape = compoundShape->getChildShape(i);
 
                //backup
         orgTrans = colObj->getWorldTransform();
 
                //backup
         orgTrans = colObj->getWorldTransform();
@@ -334,15 +347,15 @@ btScalar  btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject*
                //btTransform   newChildWorldTrans = orgTrans*childTrans ;
                colObj->setWorldTransform( orgTrans*childTrans );
 
                //btTransform   newChildWorldTrans = orgTrans*childTrans ;
                colObj->setWorldTransform( orgTrans*childTrans );
 
-               btCollisionShape* tmpShape = colObj->getCollisionShape();
-               colObj->internalSetTemporaryCollisionShape( childShape );
+               //btCollisionShape* tmpShape = colObj->getCollisionShape();
+               //colObj->internalSetTemporaryCollisionShape( childShape );
         frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
                if (frac<hitFraction)
                {
                        hitFraction = frac;
                }
                //revert back
         frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
                if (frac<hitFraction)
                {
                        hitFraction = frac;
                }
                //revert back
-               colObj->internalSetTemporaryCollisionShape( tmpShape);
+               //colObj->internalSetTemporaryCollisionShape( tmpShape);
                colObj->setWorldTransform( orgTrans);
        }
        return hitFraction;
                colObj->setWorldTransform( orgTrans);
        }
        return hitFraction;
index 404574989ab0061c0ba8e2e868989c15df524a2e..b16fc524672c9299473c173409a331d266830354 100644 (file)
@@ -41,15 +41,15 @@ class btCompoundCollisionAlgorithm  : public btActivatingCollisionAlgorithm
        
        void    removeChildAlgorithms();
        
        
        void    removeChildAlgorithms();
        
-       void    preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1);
+       void    preallocateChildAlgorithms(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
 
 public:
 
 
 public:
 
-       btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+       btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped);
 
        virtual ~btCompoundCollisionAlgorithm();
 
 
        virtual ~btCompoundCollisionAlgorithm();
 
-       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);
 
 
        btScalar        calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
@@ -65,19 +65,19 @@ public:
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
 
        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(btCompoundCollisionAlgorithm));
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm));
-                       return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,false);
+                       return new(mem) btCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,false);
                }
        };
 
        struct SwappedCreateFunc :public        btCollisionAlgorithmCreateFunc
        {
                }
        };
 
        struct SwappedCreateFunc :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(btCompoundCollisionAlgorithm));
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm));
-                       return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,true);
+                       return new(mem) btCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,true);
                }
        };
 
                }
        };
 
index db7f884ac82feee26754e72c22f315980c9520aa..3e1afede1bf6bf313fcb42af657fae222a714a2a 100644 (file)
@@ -43,7 +43,7 @@ subject to the following restrictions:
 
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
 
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
-
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 btConvex2dConvex2dAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*                  simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
 {
 
 btConvex2dConvex2dAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*                  simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
 {
@@ -57,8 +57,8 @@ btConvex2dConvex2dAlgorithm::CreateFunc::~CreateFunc()
 { 
 }
 
 { 
 }
 
-btConvex2dConvex2dAlgorithm::btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
-: btActivatingCollisionAlgorithm(ci,body0,body1),
+btConvex2dConvex2dAlgorithm::btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
+: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
 m_simplexSolver(simplexSolver),
 m_pdSolver(pdSolver),
 m_ownManifold (false),
 m_simplexSolver(simplexSolver),
 m_pdSolver(pdSolver),
 m_ownManifold (false),
@@ -67,8 +67,8 @@ m_lowLevelOfDetail(false),
  m_numPerturbationIterations(numPerturbationIterations),
 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
  m_numPerturbationIterations(numPerturbationIterations),
 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
-       (void)body0;
-       (void)body1;
+       (void)body0Wrap;
+       (void)body1Wrap;
 }
 
 
 }
 
 
@@ -96,13 +96,13 @@ extern btScalar gContactBreakingThreshold;
 //
 // Convex-Convex collision algorithm
 //
 //
 // Convex-Convex collision algorithm
 //
-void btConvex2dConvex2dAlgorithm ::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btConvex2dConvex2dAlgorithm ::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
 
        if (!m_manifoldPtr)
        {
                //swapped?
 {
 
        if (!m_manifoldPtr)
        {
                //swapped?
-               m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
+               m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
                m_ownManifold = true;
        }
        resultOut->setPersistentManifold(m_manifoldPtr);
                m_ownManifold = true;
        }
        resultOut->setPersistentManifold(m_manifoldPtr);
@@ -111,8 +111,8 @@ void btConvex2dConvex2dAlgorithm ::processCollision (btCollisionObject* body0,bt
        //resultOut->getPersistentManifold()->clearManifold();
 
 
        //resultOut->getPersistentManifold()->clearManifold();
 
 
-       btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
-       btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
+       const btConvexShape* min0 = static_cast<const btConvexShape*>(body0Wrap->getCollisionShape());
+       const btConvexShape* min1 = static_cast<const btConvexShape*>(body1Wrap->getCollisionShape());
 
        btVector3  normalOnB;
        btVector3  pointOnBWorld;
 
        btVector3  normalOnB;
        btVector3  pointOnBWorld;
@@ -133,8 +133,8 @@ void btConvex2dConvex2dAlgorithm ::processCollision (btCollisionObject* body0,bt
                }
 
                input.m_stackAlloc = dispatchInfo.m_stackAllocator;
                }
 
                input.m_stackAlloc = dispatchInfo.m_stackAllocator;
-               input.m_transformA = body0->getWorldTransform();
-               input.m_transformB = body1->getWorldTransform();
+               input.m_transformA = body0Wrap->getWorldTransform();
+               input.m_transformB = body1Wrap->getWorldTransform();
 
                gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
 
 
                gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
 
index 53d13b87151faacbb93255f3d6507b1e4809d843..18d9385a1804f6169abe4d4f45558d49a05710f2 100644 (file)
@@ -45,12 +45,12 @@ class btConvex2dConvex2dAlgorithm : public btActivatingCollisionAlgorithm
 
 public:
 
 
 public:
 
-       btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
+       btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
 
 
        virtual ~btConvex2dConvex2dAlgorithm();
 
 
 
        virtual ~btConvex2dConvex2dAlgorithm();
 
-       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);
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
@@ -82,10 +82,10 @@ public:
                
                virtual ~CreateFunc();
 
                
                virtual ~CreateFunc();
 
-               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(btConvex2dConvex2dAlgorithm));
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvex2dConvex2dAlgorithm));
-                       return new(mem) btConvex2dConvex2dAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
+                       return new(mem) btConvex2dConvex2dAlgorithm(ci.m_manifold,ci,body0Wrap,body1Wrap,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
                }
        };
 
                }
        };
 
index d2b2c221426943561a02a9175d3c3f16ed68ad98..18fde771b14773e6c7fa5cc10a79729dc43f0e6a 100644 (file)
@@ -25,11 +25,12 @@ subject to the following restrictions:
 #include "BulletCollision/CollisionShapes/btSphereShape.h"
 #include "LinearMath/btIDebugDraw.h"
 #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
 #include "BulletCollision/CollisionShapes/btSphereShape.h"
 #include "LinearMath/btIDebugDraw.h"
 #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 
-btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
-: btActivatingCollisionAlgorithm(ci,body0,body1),
+btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped)
+: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
 m_isSwapped(isSwapped),
 m_isSwapped(isSwapped),
-m_btConvexTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped)
+m_btConvexTriangleCallback(ci.m_dispatcher1,body0Wrap,body1Wrap,isSwapped)
 {
 }
 
 {
 }
 
@@ -46,17 +47,17 @@ void        btConvexConcaveCollisionAlgorithm::getAllContactManifolds(btManifoldArray&
 }
 
 
 }
 
 
-btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher*  dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped):
+btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher*  dispatcher,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped):
          m_dispatcher(dispatcher),
        m_dispatchInfoPtr(0)
 {
          m_dispatcher(dispatcher),
        m_dispatchInfoPtr(0)
 {
-       m_convexBody = isSwapped? body1:body0;
-       m_triBody = isSwapped? body0:body1;
+       m_convexBodyWrap = isSwapped? body1Wrap:body0Wrap;
+       m_triBodyWrap = isSwapped? body0Wrap:body1Wrap;
        
          //
          // create the manifold from the dispatcher 'manifold pool'
          //
        
          //
          // create the manifold from the dispatcher 'manifold pool'
          //
-         m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
+         m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBodyWrap->getCollisionObject(),m_triBodyWrap->getCollisionObject());
 
          clearCache();
 }
 
          clearCache();
 }
@@ -88,7 +89,7 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
        btCollisionAlgorithmConstructionInfo ci;
        ci.m_dispatcher1 = m_dispatcher;
 
        btCollisionAlgorithmConstructionInfo ci;
        ci.m_dispatcher1 = m_dispatcher;
 
-       btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
+       //const btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBodyWrap->getCollisionObject());
 
 
 #if 0  
 
 
 #if 0  
@@ -103,46 +104,63 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
        }
 #endif
        
        }
 #endif
        
-       if (m_convexBody->getCollisionShape()->isConvex())
+       if (m_convexBodyWrap->getCollisionShape()->isConvex())
        {
                btTriangleShape tm(triangle[0],triangle[1],triangle[2]);        
                tm.setMargin(m_collisionMarginTriangle);
                
        {
                btTriangleShape tm(triangle[0],triangle[1],triangle[2]);        
                tm.setMargin(m_collisionMarginTriangle);
                
-               btCollisionShape* tmpShape = ob->getCollisionShape();
-               ob->internalSetTemporaryCollisionShape( &tm );
+               
+               btCollisionObjectWrapper triObWrap(m_triBodyWrap,&tm,m_triBodyWrap->getCollisionObject(),m_triBodyWrap->getWorldTransform(),partId,triangleIndex);//correct transform?
+               btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBodyWrap,&triObWrap,m_manifoldPtr);
 
 
-               btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr);
+               const btCollisionObjectWrapper* tmpWrap = 0;
 
 
-               if (m_resultOut->getBody0Internal() == m_triBody)
+               if (m_resultOut->getBody0Internal() == m_triBodyWrap->getCollisionObject())
                {
                {
+                       tmpWrap = m_resultOut->getBody0Wrap();
+                       m_resultOut->setBody0Wrap(&triObWrap);
                        m_resultOut->setShapeIdentifiersA(partId,triangleIndex);
                }
                else
                {
                        m_resultOut->setShapeIdentifiersA(partId,triangleIndex);
                }
                else
                {
+                       tmpWrap = m_resultOut->getBody1Wrap();
+                       m_resultOut->setBody1Wrap(&triObWrap);
                        m_resultOut->setShapeIdentifiersB(partId,triangleIndex);
                }
        
                        m_resultOut->setShapeIdentifiersB(partId,triangleIndex);
                }
        
-               colAlgo->processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
+               colAlgo->processCollision(m_convexBodyWrap,&triObWrap,*m_dispatchInfoPtr,m_resultOut);
+
+               if (m_resultOut->getBody0Internal() == m_triBodyWrap->getCollisionObject())
+               {
+                       m_resultOut->setBody0Wrap(tmpWrap);
+               } else
+               {
+                       m_resultOut->setBody1Wrap(tmpWrap);
+               }
+               
+
+
                colAlgo->~btCollisionAlgorithm();
                ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
                colAlgo->~btCollisionAlgorithm();
                ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
-               ob->internalSetTemporaryCollisionShape( tmpShape);
        }
 
        }
 
-
 }
 
 
 
 }
 
 
 
-void   btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void   btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,const btCollisionObjectWrapper* convexBodyWrap, const btCollisionObjectWrapper* triBodyWrap, btManifoldResult* resultOut)
 {
 {
+       m_convexBodyWrap = convexBodyWrap;
+       m_triBodyWrap = triBodyWrap;
+
        m_dispatchInfoPtr = &dispatchInfo;
        m_collisionMarginTriangle = collisionMarginTriangle;
        m_resultOut = resultOut;
 
        //recalc aabbs
        btTransform convexInTriangleSpace;
        m_dispatchInfoPtr = &dispatchInfo;
        m_collisionMarginTriangle = collisionMarginTriangle;
        m_resultOut = resultOut;
 
        //recalc aabbs
        btTransform convexInTriangleSpace;
-       convexInTriangleSpace = m_triBody->getWorldTransform().inverse() * m_convexBody->getWorldTransform();
-       btCollisionShape* convexShape = static_cast<btCollisionShape*>(m_convexBody->getCollisionShape());
+       convexInTriangleSpace = m_triBodyWrap->getWorldTransform().inverse() * m_convexBodyWrap->getWorldTransform();
+       const btCollisionShape* convexShape = static_cast<const btCollisionShape*>(m_convexBodyWrap->getCollisionShape());
        //CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
        convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
        btScalar extraMargin = collisionMarginTriangle;
        //CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
        convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
        btScalar extraMargin = collisionMarginTriangle;
@@ -159,35 +177,34 @@ void btConvexConcaveCollisionAlgorithm::clearCache()
 
 }
 
 
 }
 
-void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btConvexConcaveCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
        
        
 {
        
        
-       btCollisionObject* convexBody = m_isSwapped ? body1 : body0;
-       btCollisionObject* triBody = m_isSwapped ? body0 : body1;
+       const btCollisionObjectWrapper* convexBodyWrap = m_isSwapped ? body1Wrap : body0Wrap;
+       const btCollisionObjectWrapper* triBodyWrap = m_isSwapped ? body0Wrap : body1Wrap;
 
 
-       if (triBody->getCollisionShape()->isConcave())
+       if (triBodyWrap->getCollisionShape()->isConcave())
        {
 
 
        {
 
 
-               btCollisionObject*      triOb = triBody;
-               btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
                
                
-               if (convexBody->getCollisionShape()->isConvex())
+               const btConcaveShape* concaveShape = static_cast<const btConcaveShape*>( triBodyWrap->getCollisionShape());
+               
+               if (convexBodyWrap->getCollisionShape()->isConvex())
                {
                        btScalar collisionMarginTriangle = concaveShape->getMargin();
                                        
                        resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr);
                {
                        btScalar collisionMarginTriangle = concaveShape->getMargin();
                                        
                        resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr);
-                       m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
-
-                       //Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
-                       //m_dispatcher->clearManifold(m_btConvexTriangleCallback.m_manifoldPtr);
+                       m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,convexBodyWrap,triBodyWrap,resultOut);
 
 
-                       m_btConvexTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
+                       m_btConvexTriangleCallback.m_manifoldPtr->setBodies(convexBodyWrap->getCollisionObject(),triBodyWrap->getCollisionObject());
 
                        concaveShape->processAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.getAabbMin(),m_btConvexTriangleCallback.getAabbMax());
                        
                        resultOut->refreshContactPoints();
 
                        concaveShape->processAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.getAabbMin(),m_btConvexTriangleCallback.getAabbMax());
                        
                        resultOut->refreshContactPoints();
+
+                       m_btConvexTriangleCallback.clearWrapperData();
        
                }
        
        
                }
        
index f718d1dec259f80a74c4de84f183ef9644f13428..e90d06eb191b73e400d4a8daaec9bbc0e478b912 100644 (file)
@@ -28,8 +28,8 @@ class btDispatcher;
 ///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called.
 class btConvexTriangleCallback : public btTriangleCallback
 {
 ///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called.
 class btConvexTriangleCallback : public btTriangleCallback
 {
-       btCollisionObject* m_convexBody;
-       btCollisionObject* m_triBody;
+       const btCollisionObjectWrapper* m_convexBodyWrap;
+       const btCollisionObjectWrapper* m_triBodyWrap;
 
        btVector3       m_aabbMin;
        btVector3       m_aabbMax ;
 
        btVector3       m_aabbMin;
        btVector3       m_aabbMax ;
@@ -45,10 +45,15 @@ int m_triangleCount;
        
        btPersistentManifold*   m_manifoldPtr;
 
        
        btPersistentManifold*   m_manifoldPtr;
 
-       btConvexTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+       btConvexTriangleCallback(btDispatcher* dispatcher,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped);
 
 
-       void    setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+       void    setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,const btCollisionObjectWrapper* convexBodyWrap, const btCollisionObjectWrapper* triBodyWrap, btManifoldResult* resultOut);
 
 
+       void    clearWrapperData()
+       {
+               m_convexBodyWrap = 0;
+               m_triBodyWrap = 0;
+       }
        virtual ~btConvexTriangleCallback();
 
        virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
        virtual ~btConvexTriangleCallback();
 
        virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
@@ -81,11 +86,11 @@ class btConvexConcaveCollisionAlgorithm  : public btActivatingCollisionAlgorithm
 
 public:
 
 
 public:
 
-       btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
+       btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped);
 
        virtual ~btConvexConcaveCollisionAlgorithm();
 
 
        virtual ~btConvexConcaveCollisionAlgorithm();
 
-       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);
 
 
        btScalar        calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
@@ -95,19 +100,19 @@ public:
 
        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
        {
 
        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(btConvexConcaveCollisionAlgorithm));
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
-                       return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0,body1,false);
+                       return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0Wrap,body1Wrap,false);
                }
        };
 
        struct SwappedCreateFunc :public        btCollisionAlgorithmCreateFunc
        {
                }
        };
 
        struct SwappedCreateFunc :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(btConvexConcaveCollisionAlgorithm));
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
-                       return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0,body1,true);
+                       return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0Wrap,body1Wrap,true);
                }
        };
 
                }
        };
 
index dd1f3e2490f2746c2d21f6d85f2d895558a04a5a..62f98a846f4503e73768e89e69f4e032006aefb2 100644 (file)
@@ -52,7 +52,7 @@ subject to the following restrictions:
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
 #include "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h"
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
 #include "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h"
-
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 ///////////
 
 
 ///////////
 
@@ -191,8 +191,8 @@ btConvexConvexAlgorithm::CreateFunc::~CreateFunc()
 { 
 }
 
 { 
 }
 
-btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
-: btActivatingCollisionAlgorithm(ci,body0,body1),
+btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
+: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
 m_simplexSolver(simplexSolver),
 m_pdSolver(pdSolver),
 m_ownManifold (false),
 m_simplexSolver(simplexSolver),
 m_pdSolver(pdSolver),
 m_ownManifold (false),
@@ -205,8 +205,8 @@ m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngu
 m_numPerturbationIterations(numPerturbationIterations),
 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
 m_numPerturbationIterations(numPerturbationIterations),
 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
-       (void)body0;
-       (void)body1;
+       (void)body0Wrap;
+       (void)body1Wrap;
 }
 
 
 }
 
 
@@ -289,13 +289,13 @@ extern btScalar gContactBreakingThreshold;
 //
 // Convex-Convex collision algorithm
 //
 //
 // Convex-Convex collision algorithm
 //
-void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btConvexConvexAlgorithm ::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
 
        if (!m_manifoldPtr)
        {
                //swapped?
 {
 
        if (!m_manifoldPtr)
        {
                //swapped?
-               m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
+               m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
                m_ownManifold = true;
        }
        resultOut->setPersistentManifold(m_manifoldPtr);
                m_ownManifold = true;
        }
        resultOut->setPersistentManifold(m_manifoldPtr);
@@ -304,8 +304,8 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
        //resultOut->getPersistentManifold()->clearManifold();
        
 
        //resultOut->getPersistentManifold()->clearManifold();
        
 
-       btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
-       btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
+       const btConvexShape* min0 = static_cast<const btConvexShape*>(body0Wrap->getCollisionShape());
+       const btConvexShape* min1 = static_cast<const btConvexShape*>(body1Wrap->getCollisionShape());
 
        btVector3  normalOnB;
                btVector3  pointOnBWorld;
 
        btVector3  normalOnB;
                btVector3  pointOnBWorld;
@@ -314,14 +314,14 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
        {
                btCapsuleShape* capsuleA = (btCapsuleShape*) min0;
                btCapsuleShape* capsuleB = (btCapsuleShape*) min1;
        {
                btCapsuleShape* capsuleA = (btCapsuleShape*) min0;
                btCapsuleShape* capsuleB = (btCapsuleShape*) min1;
-               btVector3 localScalingA = capsuleA->getLocalScaling();
-               btVector3 localScalingB = capsuleB->getLocalScaling();
+       //      btVector3 localScalingA = capsuleA->getLocalScaling();
+       //      btVector3 localScalingB = capsuleB->getLocalScaling();
                
                btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
 
                btScalar dist = capsuleCapsuleDistance(normalOnB,       pointOnBWorld,capsuleA->getHalfHeight(),capsuleA->getRadius(),
                        capsuleB->getHalfHeight(),capsuleB->getRadius(),capsuleA->getUpAxis(),capsuleB->getUpAxis(),
                
                btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
 
                btScalar dist = capsuleCapsuleDistance(normalOnB,       pointOnBWorld,capsuleA->getHalfHeight(),capsuleA->getRadius(),
                        capsuleB->getHalfHeight(),capsuleB->getRadius(),capsuleA->getUpAxis(),capsuleB->getUpAxis(),
-                       body0->getWorldTransform(),body1->getWorldTransform(),threshold);
+                       body0Wrap->getWorldTransform(),body1Wrap->getWorldTransform(),threshold);
 
                if (dist<threshold)
                {
 
                if (dist<threshold)
                {
@@ -374,8 +374,8 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
        }
 
        input.m_stackAlloc = dispatchInfo.m_stackAllocator;
        }
 
        input.m_stackAlloc = dispatchInfo.m_stackAllocator;
-       input.m_transformA = body0->getWorldTransform();
-       input.m_transformB = body1->getWorldTransform();
+       input.m_transformA = body0Wrap->getWorldTransform();
+       input.m_transformB = body1Wrap->getWorldTransform();
 
 
 
 
 
 
@@ -407,9 +407,51 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
                        {
                        }
                };
                        {
                        }
                };
+
+               
+               struct btWithoutMarginResult : public btDiscreteCollisionDetectorInterface::Result
+               {
+                       btDiscreteCollisionDetectorInterface::Result* m_originalResult;
+                       btVector3       m_reportedNormalOnWorld;
+                       btScalar m_marginOnA;
+                       btScalar m_marginOnB;
+                       btScalar        m_reportedDistance;
+                       
+                       bool            m_foundResult;
+                       btWithoutMarginResult(btDiscreteCollisionDetectorInterface::Result* result, btScalar marginOnA, btScalar marginOnB)
+                       :m_originalResult(result),
+                       m_marginOnA(marginOnA),
+                       m_marginOnB(marginOnB),
+                       m_foundResult(false)
+                       {
+                       }
+                       
+                       virtual void setShapeIdentifiersA(int partId0,int index0){}
+                       virtual void setShapeIdentifiersB(int partId1,int index1){}
+                       virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorldOrg,btScalar depthOrg) 
+                       {
+                               m_reportedDistance = depthOrg;
+                               m_reportedNormalOnWorld = normalOnBInWorld;
+                               
+                               btVector3 adjustedPointB = pointInWorldOrg - normalOnBInWorld*m_marginOnB;
+                               m_reportedDistance = depthOrg+(m_marginOnA+m_marginOnB);
+                               if (m_reportedDistance<0.f)
+                               {
+                                       m_foundResult = true;                                   
+                               }
+                               m_originalResult->addContactPoint(normalOnBInWorld,adjustedPointB,m_reportedDistance);
+                       }
+               };
+
                
                btDummyResult dummy;
 
                
                btDummyResult dummy;
 
+///btBoxShape is an exception: its vertices are created WITH margin so don't subtract it
+
+               btScalar min0Margin = min0->getShapeType()==BOX_SHAPE_PROXYTYPE? 0.f : min0->getMargin();
+               btScalar min1Margin = min1->getShapeType()==BOX_SHAPE_PROXYTYPE? 0.f : min1->getMargin();
+
+               btWithoutMarginResult   withoutMargin(resultOut, min0Margin,min1Margin);
 
                btPolyhedralConvexShape* polyhedronA = (btPolyhedralConvexShape*) min0;
                btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*) min1;
 
                btPolyhedralConvexShape* polyhedronA = (btPolyhedralConvexShape*) min0;
                btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*) min1;
@@ -429,39 +471,42 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
                        {
                                foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis(
                                        *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
                        {
                                foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis(
                                        *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
-                                       body0->getWorldTransform(), 
-                                       body1->getWorldTransform(),
-                                       sepNormalWorldSpace);
+                                       body0Wrap->getWorldTransform(), 
+                                       body1Wrap->getWorldTransform(),
+                                       sepNormalWorldSpace,*resultOut);
                        } else
                        {
 #ifdef ZERO_MARGIN
                                gjkPairDetector.setIgnoreMargin(true);
                                gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
 #else
                        } else
                        {
 #ifdef ZERO_MARGIN
                                gjkPairDetector.setIgnoreMargin(true);
                                gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
 #else
-                               //gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
-                               gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw);
+
+
+                               gjkPairDetector.getClosestPoints(input,withoutMargin,dispatchInfo.m_debugDraw);
+                               //gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw);
 #endif //ZERO_MARGIN
 #endif //ZERO_MARGIN
-                               btScalar l2 = gjkPairDetector.getCachedSeparatingAxis().length2();
-                               if (l2>SIMD_EPSILON)
+                               //btScalar l2 = gjkPairDetector.getCachedSeparatingAxis().length2();
+                               //if (l2>SIMD_EPSILON)
                                {
                                {
-                                       sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis()*(1.f/l2);
+                                       sepNormalWorldSpace = withoutMargin.m_reportedNormalOnWorld;//gjkPairDetector.getCachedSeparatingAxis()*(1.f/l2);
                                        //minDist = -1e30f;//gjkPairDetector.getCachedSeparatingDistance();
                                        //minDist = -1e30f;//gjkPairDetector.getCachedSeparatingDistance();
-                                       minDist = gjkPairDetector.getCachedSeparatingDistance()-min0->getMargin()-min1->getMargin();
+                                       minDist = withoutMargin.m_reportedDistance;//gjkPairDetector.getCachedSeparatingDistance()+min0->getMargin()+min1->getMargin();
        
 #ifdef ZERO_MARGIN
                                        foundSepAxis = true;//gjkPairDetector.getCachedSeparatingDistance()<0.f;
 #else
        
 #ifdef ZERO_MARGIN
                                        foundSepAxis = true;//gjkPairDetector.getCachedSeparatingDistance()<0.f;
 #else
-                                       foundSepAxis = gjkPairDetector.getCachedSeparatingDistance()<(min0->getMargin()+min1->getMargin());
+                                       foundSepAxis = withoutMargin.m_foundResult && minDist<0;//-(min0->getMargin()+min1->getMargin());
 #endif
                                }
                        }
                        if (foundSepAxis)
                        {
 #endif
                                }
                        }
                        if (foundSepAxis)
                        {
+                               
 //                             printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ());
 
                                btPolyhedralContactClipping::clipHullAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
 //                             printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ());
 
                                btPolyhedralContactClipping::clipHullAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
-                                       body0->getWorldTransform(), 
-                                       body1->getWorldTransform(), minDist-threshold, threshold, *resultOut);
+                                       body0Wrap->getWorldTransform(), 
+                                       body1Wrap->getWorldTransform(), minDist-threshold, threshold, *resultOut);
                                
                        }
                        if (m_ownManifold)
                                
                        }
                        if (m_ownManifold)
@@ -478,9 +523,9 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
 
                                btVertexArray vertices;
                                btTriangleShape* tri = (btTriangleShape*)polyhedronB;
 
                                btVertexArray vertices;
                                btTriangleShape* tri = (btTriangleShape*)polyhedronB;
-                               vertices.push_back(     body1->getWorldTransform()*tri->m_vertices1[0]);
-                               vertices.push_back(     body1->getWorldTransform()*tri->m_vertices1[1]);
-                               vertices.push_back(     body1->getWorldTransform()*tri->m_vertices1[2]);
+                               vertices.push_back(     body1Wrap->getWorldTransform()*tri->m_vertices1[0]);
+                               vertices.push_back(     body1Wrap->getWorldTransform()*tri->m_vertices1[1]);
+                               vertices.push_back(     body1Wrap->getWorldTransform()*tri->m_vertices1[2]);
                                
                                //tri->initializePolyhedralFeatures();
 
                                
                                //tri->initializePolyhedralFeatures();
 
@@ -496,9 +541,9 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
                                        polyhedronB->initializePolyhedralFeatures();
                                         foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis(
                                        *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
                                        polyhedronB->initializePolyhedralFeatures();
                                         foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis(
                                        *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
-                                       body0->getWorldTransform(), 
-                                       body1->getWorldTransform(),
-                                       sepNormalWorldSpace);
+                                       body0Wrap->getWorldTransform(), 
+                                       body1Wrap->getWorldTransform(),
+                                       sepNormalWorldSpace,*resultOut);
                                //       printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ());
 
                                } else
                                //       printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ());
 
                                } else
@@ -525,7 +570,7 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
                        if (foundSepAxis)
                        {
                                btPolyhedralContactClipping::clipFaceAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), 
                        if (foundSepAxis)
                        {
                                btPolyhedralContactClipping::clipFaceAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), 
-                                       body0->getWorldTransform(), vertices, minDist-threshold, maxDist, *resultOut);
+                                       body0Wrap->getWorldTransform(), vertices, minDist-threshold, maxDist, *resultOut);
                        }
                                
                                
                        }
                                
                                
@@ -599,15 +644,15 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
                                
                                if (perturbeA)
                                {
                                
                                if (perturbeA)
                                {
-                                       input.m_transformA.setBasis(  btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body0->getWorldTransform().getBasis());
-                                       input.m_transformB = body1->getWorldTransform();
+                                       input.m_transformA.setBasis(  btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body0Wrap->getWorldTransform().getBasis());
+                                       input.m_transformB = body1Wrap->getWorldTransform();
        #ifdef DEBUG_CONTACTS
                                        dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0);
        #endif //DEBUG_CONTACTS
                                } else
                                {
        #ifdef DEBUG_CONTACTS
                                        dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0);
        #endif //DEBUG_CONTACTS
                                } else
                                {
-                                       input.m_transformA = body0->getWorldTransform();
-                                       input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1->getWorldTransform().getBasis());
+                                       input.m_transformA = body0Wrap->getWorldTransform();
+                                       input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1Wrap->getWorldTransform().getBasis());
        #ifdef DEBUG_CONTACTS
                                        dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0);
        #endif
        #ifdef DEBUG_CONTACTS
                                        dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0);
        #endif
index 4380b80eb4d92f29aa51b83a4997cf0ef30f1da0..51db0c6548dc6dda53ef101e57ed7a7f145682bd 100644 (file)
@@ -59,12 +59,11 @@ class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm
 
 public:
 
 
 public:
 
-       btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
-
+       btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
 
        virtual ~btConvexConvexAlgorithm();
 
 
        virtual ~btConvexConvexAlgorithm();
 
-       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);
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
@@ -96,10 +95,10 @@ public:
                
                virtual ~CreateFunc();
 
                
                virtual ~CreateFunc();
 
-               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(btConvexConvexAlgorithm));
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm));
-                       return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
+                       return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0Wrap,body1Wrap,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
                }
        };
 
                }
        };
 
index b2e9bfaf593dbb33794f1e9f2c28a9cbeaf69d3c..cce2d95bcf9fa5e970b8d01f3de4757647731e25 100644 (file)
@@ -19,10 +19,11 @@ subject to the following restrictions:
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 #include "BulletCollision/CollisionShapes/btConvexShape.h"
 #include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 #include "BulletCollision/CollisionShapes/btConvexShape.h"
 #include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
+#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
 
 //#include <stdio.h>
 
 
 //#include <stdio.h>
 
-btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold)
+btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold)
 : btCollisionAlgorithm(ci),
 m_ownManifold(false),
 m_manifoldPtr(mf),
 : btCollisionAlgorithm(ci),
 m_ownManifold(false),
 m_manifoldPtr(mf),
@@ -30,12 +31,12 @@ m_isSwapped(isSwapped),
 m_numPerturbationIterations(numPerturbationIterations),
 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
 m_numPerturbationIterations(numPerturbationIterations),
 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
-       btCollisionObject* convexObj = m_isSwapped? col1 : col0;
-       btCollisionObject* planeObj = m_isSwapped? col0 : col1;
+       const btCollisionObjectWrapper* convexObjWrap = m_isSwapped? col1Wrap : col0Wrap;
+       const btCollisionObjectWrapper* planeObjWrap = m_isSwapped? col0Wrap : col1Wrap;
 
 
-       if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
+       if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObjWrap->getCollisionObject(),planeObjWrap->getCollisionObject()))
        {
        {
-               m_manifoldPtr = m_dispatcher->getNewManifold(convexObj,planeObj);
+               m_manifoldPtr = m_dispatcher->getNewManifold(convexObjWrap->getCollisionObject(),planeObjWrap->getCollisionObject());
                m_ownManifold = true;
        }
 }
                m_ownManifold = true;
        }
 }
@@ -50,25 +51,25 @@ btConvexPlaneCollisionAlgorithm::~btConvexPlaneCollisionAlgorithm()
        }
 }
 
        }
 }
 
-void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
 {
-    btCollisionObject* convexObj = m_isSwapped? body1 : body0;
-       btCollisionObject* planeObj = m_isSwapped? body0: body1;
+    const btCollisionObjectWrapper* convexObjWrap = m_isSwapped? body1Wrap : body0Wrap;
+       const btCollisionObjectWrapper* planeObjWrap = m_isSwapped? body0Wrap: body1Wrap;
 
 
-       btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
-       btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
+       btConvexShape* convexShape = (btConvexShape*) convexObjWrap->getCollisionShape();
+       btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObjWrap->getCollisionShape();
 
     bool hasCollision = false;
        const btVector3& planeNormal = planeShape->getPlaneNormal();
        const btScalar& planeConstant = planeShape->getPlaneConstant();
        
 
     bool hasCollision = false;
        const btVector3& planeNormal = planeShape->getPlaneNormal();
        const btScalar& planeConstant = planeShape->getPlaneConstant();
        
-       btTransform convexWorldTransform = convexObj->getWorldTransform();
+       btTransform convexWorldTransform = convexObjWrap->getWorldTransform();
        btTransform convexInPlaneTrans;
        btTransform convexInPlaneTrans;
-       convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform;
+       convexInPlaneTrans= planeObjWrap->getWorldTransform().inverse() * convexWorldTransform;
        //now perturbe the convex-world transform
        convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
        btTransform planeInConvex;
        //now perturbe the convex-world transform
        convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
        btTransform planeInConvex;
-       planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform();
+       planeInConvex= convexWorldTransform.inverse() * planeObjWrap->getWorldTransform();
        
        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
 
        
        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
 
@@ -76,53 +77,53 @@ void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion&
        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
 
        btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
 
        btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
-       btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected;
+       btVector3 vtxInPlaneWorld = planeObjWrap->getWorldTransform() * vtxInPlaneProjected;
 
        hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
        resultOut->setPersistentManifold(m_manifoldPtr);
        if (hasCollision)
        {
                /// report a contact. internally this will be kept persistent, and contact reduction is done
 
        hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
        resultOut->setPersistentManifold(m_manifoldPtr);
        if (hasCollision)
        {
                /// report a contact. internally this will be kept persistent, and contact reduction is done
-               btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal;
+               btVector3 normalOnSurfaceB = planeObjWrap->getWorldTransform().getBasis() * planeNormal;
                btVector3 pOnB = vtxInPlaneWorld;
                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
        }
 }
 
 
                btVector3 pOnB = vtxInPlaneWorld;
                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
        }
 }
 
 
-void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btConvexPlaneCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
        (void)dispatchInfo;
        if (!m_manifoldPtr)
                return;
 
 {
        (void)dispatchInfo;
        if (!m_manifoldPtr)
                return;
 
-       btCollisionObject* convexObj = m_isSwapped? body1 : body0;
-       btCollisionObject* planeObj = m_isSwapped? body0: body1;
+       const btCollisionObjectWrapper* convexObjWrap = m_isSwapped? body1Wrap : body0Wrap;
+       const btCollisionObjectWrapper* planeObjWrap = m_isSwapped? body0Wrap: body1Wrap;
 
 
-       btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
-       btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
+       btConvexShape* convexShape = (btConvexShape*) convexObjWrap->getCollisionShape();
+       btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObjWrap->getCollisionShape();
 
        bool hasCollision = false;
        const btVector3& planeNormal = planeShape->getPlaneNormal();
        const btScalar& planeConstant = planeShape->getPlaneConstant();
        btTransform planeInConvex;
 
        bool hasCollision = false;
        const btVector3& planeNormal = planeShape->getPlaneNormal();
        const btScalar& planeConstant = planeShape->getPlaneConstant();
        btTransform planeInConvex;
-       planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
+       planeInConvex= convexObjWrap->getWorldTransform().inverse() * planeObjWrap->getWorldTransform();
        btTransform convexInPlaneTrans;
        btTransform convexInPlaneTrans;
-       convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
+       convexInPlaneTrans= planeObjWrap->getWorldTransform().inverse() * convexObjWrap->getWorldTransform();
 
        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
        btVector3 vtxInPlane = convexInPlaneTrans(vtx);
        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
 
        btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
 
        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
        btVector3 vtxInPlane = convexInPlaneTrans(vtx);
        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
 
        btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
-       btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected;
+       btVector3 vtxInPlaneWorld = planeObjWrap->getWorldTransform() * vtxInPlaneProjected;
 
        hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
        resultOut->setPersistentManifold(m_manifoldPtr);
        if (hasCollision)
        {
                /// report a contact. internally this will be kept persistent, and contact reduction is done
 
        hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
        resultOut->setPersistentManifold(m_manifoldPtr);
        if (hasCollision)
        {
                /// report a contact. internally this will be kept persistent, and contact reduction is done
-               btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal;
+               btVector3 normalOnSurfaceB = planeObjWrap->getWorldTransform().getBasis() * planeNormal;
                btVector3 pOnB = vtxInPlaneWorld;
                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
        }
                btVector3 pOnB = vtxInPlaneWorld;
                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
        }
@@ -148,7 +149,7 @@ void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0
                {
                        btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
                        btQuaternion rotq(planeNormal,iterationAngle);
                {
                        btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
                        btQuaternion rotq(planeNormal,iterationAngle);
-                       collideSingleContact(rotq.inverse()*perturbeRot*rotq,body0,body1,dispatchInfo,resultOut);
+                       collideSingleContact(rotq.inverse()*perturbeRot*rotq,body0Wrap,body1Wrap,dispatchInfo,resultOut);
                }
        }
 
                }
        }
 
index b9494f5ad3bff89e04098df446c82327dd575dae..d28c430c4c14b313a60ed695f01ef8838e6a23a4 100644 (file)
@@ -36,13 +36,13 @@ class btConvexPlaneCollisionAlgorithm : public btCollisionAlgorithm
 
 public:
 
 
 public:
 
-       btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold);
+       btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold);
 
        virtual ~btConvexPlaneCollisionAlgorithm();
 
 
        virtual ~btConvexPlaneCollisionAlgorithm();
 
-       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);
 
 
-       void collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
+       void collideSingleContact (const btQuaternion& perturbeRot, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
 
        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
@@ -65,15 +65,15 @@ public:
                {
                }
                
                {
                }
                
-               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(btConvexPlaneCollisionAlgorithm));
                        if (!m_swapped)
                        {
                {
                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexPlaneCollisionAlgorithm));
                        if (!m_swapped)
                        {
-                               return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
+                               return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0Wrap,body1Wrap,false,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);