Fix for bug #19817: cloth simulation with collision slow on Mac.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 5 Nov 2009 19:06:29 +0000 (19:06 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 5 Nov 2009 19:06:29 +0000 (19:06 +0000)
The cause of this is in the bullet library, seems like some kind
of poor handling of many repeated allocations by Mac OS X, but the
allocation is unnecessary, so removed it.

Patch submitted to bullet:
http://code.google.com/p/bullet/issues/detail?id=303

extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp

index 274c5f5bdc6b03bec294ca6ceb87544c458c2d79..496fd996f8c78e381e80c17811ba4d33db5171e0 100644 (file)
@@ -202,7 +202,6 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
                input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
        }
 
-       input.m_stackAlloc = dispatchInfo.m_stackAllocator;
        input.m_transformA = body0->getWorldTransform();
        input.m_transformB = body1->getWorldTransform();
 
index 412aace21146e85a388c332ce886e963ecb86589..2989daeb44edfdf42afc3949163fa607709c2dc9 100644 (file)
@@ -33,7 +33,7 @@ public:
                const btConvexShape* convexA,const btConvexShape* convexB,
                                        const btTransform& transA,const btTransform& transB,
                                btVector3& v, btVector3& pa, btVector3& pb,
-                               class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+                               class btIDebugDraw* debugDraw
                                ) = 0;
 
 
index db797d5141ffd9f0049c88100f6c99e1cd998bd0..b011bb9ae588899011fa818828d28a157f000dd1 100644 (file)
@@ -41,15 +41,13 @@ struct btDiscreteCollisionDetectorInterface
        struct ClosestPointInput
        {
                ClosestPointInput()
-                       :m_maximumDistanceSquared(btScalar(1e30)),
-                       m_stackAlloc(0)
+                       :m_maximumDistanceSquared(btScalar(1e30))
                {
                }
 
                btTransform m_transformA;
                btTransform m_transformB;
                btScalar        m_maximumDistanceSquared;
-               btStackAlloc* m_stackAlloc;
        };
 
        virtual ~btDiscreteCollisionDetectorInterface() {};
index 05573c7cfceed4c0eb220a098681b3c2869b3bb4..55c23ee854965bebf143c1795db9b31dce886c2c 100644 (file)
@@ -25,7 +25,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
                                                                                          const btConvexShape* pConvexA, const btConvexShape* pConvexB,
                                                                                          const btTransform& transformA, const btTransform& transformB,
                                                                                          btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
-                                                                                         class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
+                                                                                         class btIDebugDraw* debugDraw )
 {
 
        (void)debugDraw;
index 68dbc56651817365f996c86f3fee99d4809dc702..4db18628021bbd9fade3aa75136eb02716cdf977 100644 (file)
@@ -29,7 +29,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
                                                                          const btConvexShape* pConvexA, const btConvexShape* pConvexB,
                                                                          const btTransform& transformA, const btTransform& transformB,
                                                                          btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
-                                                                         class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
+                                                                         class btIDebugDraw* debugDraw );
 
        private :
 
index 0856332d1ca2f2416a7aa2bba91b850edf889dda..331d25623df1e11359d367e864ee8b943efd2369 100644 (file)
@@ -293,7 +293,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
                                        m_minkowskiA,m_minkowskiB,
                                        localTransA,localTransB,
                                        m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
-                                       debugDraw,input.m_stackAlloc
+                                       debugDraw
                                        );
 
                                if (isValid2)
index 581b4258f03aaef70b15e2858e51d473b6e85091..1fdbb2457d17973e324eea726f5192d84f57c4c4 100644 (file)
@@ -71,11 +71,10 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
                                                                                                   const btConvexShape* convexA,const btConvexShape* convexB,
                                                                                                   const btTransform& transA,const btTransform& transB,
                                                                                                   btVector3& v, btVector3& pa, btVector3& pb,
-                                                                                                  class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+                                                                                                  class btIDebugDraw* debugDraw
                                                                                                   )
 {
 
-       (void)stackAlloc;
        (void)v;
        
 
index 23cbd57ac7ef95dec5aa01888e38cdc065a6800f..e93e4e4bb4efb493051b32526949134424cce131 100644 (file)
@@ -28,7 +28,7 @@ public:
        const btConvexShape* convexA,const btConvexShape* convexB,
                                const btTransform& transA,const btTransform& transB,
                        btVector3& v, btVector3& pa, btVector3& pb,
-                       class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
+                       class btIDebugDraw* debugDraw
                        );
 };
 
index 47addbac45b8e5cf9d3c740fe6b360fdf2c02128..20d6975832b838d1cba910b630ae2058071522d4 100644 (file)
@@ -365,10 +365,6 @@ double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float
        btPointCollector gjkOutput;
        btGjkPairDetector::ClosestPointInput input;
        
-       btStackAlloc gStackAlloc(1024*1024*2);
-       input.m_stackAlloc = &gStackAlloc;
-       
        btTransform tr;
        tr.setIdentity();