Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2009, 8:05:51 PM (15 years ago)
Author:
rgrieder
Message:

Update from Bullet 2.73 to 2.74.

Location:
code/trunk/src/bullet/BulletCollision/CollisionDispatch
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp

    r2662 r2882  
    5353                {
    5454                        m_doubleDispatch[i][j] = m_collisionConfiguration->getCollisionAlgorithmCreateFunc(i,j);
    55                         assert(m_doubleDispatch[i][j]);
     55                        btAssert(m_doubleDispatch[i][j]);
    5656                }
    5757        }
     
    8080        btCollisionObject* body1 = (btCollisionObject*)b1;
    8181
    82         btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
    83        
     82        //test for Bullet 2.74: use a relative contact breaking threshold without clamping against 'gContactBreakingThreshold'
     83        //btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
     84        btScalar contactBreakingThreshold = btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold());
     85
     86        btScalar contactProcessingThreshold = btMin(body0->getContactProcessingThreshold(),body1->getContactProcessingThreshold());
     87               
    8488        void* mem = 0;
    8589       
     
    9296
    9397        }
    94         btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold);
     98        btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold);
    9599        manifold->m_index1a = m_manifoldsPtr.size();
    96100        m_manifoldsPtr.push_back(manifold);
     
    143147        return algo;
    144148}
    145 
    146149
    147150
     
    161164bool    btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1)
    162165{
    163         assert(body0);
    164         assert(body1);
     166        btAssert(body0);
     167        btAssert(body1);
    165168
    166169        bool needsCollision = true;
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp

    r2662 r2882  
    1818
    1919btCollisionObject::btCollisionObject()
    20         :       m_broadphaseHandle(0),
     20        :       m_anisotropicFriction(1.f,1.f,1.f),
     21        m_hasAnisotropicFriction(false),
     22        m_contactProcessingThreshold(1e30f),
     23                m_broadphaseHandle(0),
    2124                m_collisionShape(0),
    2225                m_rootCollisionShape(0),
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h

    r2662 r2882  
    5353        btVector3       m_interpolationLinearVelocity;
    5454        btVector3       m_interpolationAngularVelocity;
     55       
     56        btVector3               m_anisotropicFriction;
     57        bool                            m_hasAnisotropicFriction;
     58        btScalar                m_contactProcessingThreshold;   
     59
    5560        btBroadphaseProxy*              m_broadphaseHandle;
    5661        btCollisionShape*               m_collisionShape;
     
    115120                CO_COLLISION_OBJECT =1,
    116121                CO_RIGID_BODY,
    117                 CO_SOFT_BODY,
    118122                ///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter
    119123                ///It is useful for collision sensors, explosion objects, character controller etc.
    120                 CO_GHOST_OBJECT
     124                CO_GHOST_OBJECT,
     125                CO_SOFT_BODY,
     126                CO_HF_FLUID
    121127        };
    122128
     
    127133        }
    128134
     135        const btVector3& getAnisotropicFriction() const
     136        {
     137                return m_anisotropicFriction;
     138        }
     139        void    setAnisotropicFriction(const btVector3& anisotropicFriction)
     140        {
     141                m_anisotropicFriction = anisotropicFriction;
     142                m_hasAnisotropicFriction = (anisotropicFriction[0]!=1.f) || (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f);
     143        }
     144        bool    hasAnisotropicFriction() const
     145        {
     146                return m_hasAnisotropicFriction;
     147        }
     148
     149        ///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default.
     150        ///Note that using contacts with positive distance can improve stability. It increases, however, the chance of colliding with degerate contacts, such as 'interior' triangle edges
     151        void    setContactProcessingThreshold( btScalar contactProcessingThreshold)
     152        {
     153                m_contactProcessingThreshold = contactProcessingThreshold;
     154        }
     155        btScalar        getContactProcessingThreshold() const
     156        {
     157                return m_contactProcessingThreshold;
     158        }
    129159
    130160        SIMD_FORCE_INLINE bool          isStaticObject() const {
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

    r2662 r2882  
    7070                        getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
    7171                        getBroadphase()->destroyProxy(bp,m_dispatcher1);
     72                        collisionObject->setBroadphaseHandle(0);
    7273                }
    7374        }
     
    119120
    120121
     122void    btCollisionWorld::updateSingleAabb(btCollisionObject* colObj)
     123{
     124        btVector3 minAabb,maxAabb;
     125        colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
     126        //need to increase the aabb for contact thresholds
     127        btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
     128        minAabb -= contactThreshold;
     129        maxAabb += contactThreshold;
     130
     131        btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
     132
     133        //moving objects should be moderately sized, probably something wrong if not
     134        if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
     135        {
     136                bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
     137        } else
     138        {
     139                //something went wrong, investigate
     140                //this assert is unwanted in 3D modelers (danger of loosing work)
     141                colObj->setActivationState(DISABLE_SIMULATION);
     142
     143                static bool reportMe = true;
     144                if (reportMe && m_debugDrawer)
     145                {
     146                        reportMe = false;
     147                        m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
     148                        m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
     149                        m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
     150                        m_debugDrawer->reportErrorWarning("Thanks.\n");
     151                }
     152        }
     153}
     154
    121155void    btCollisionWorld::updateAabbs()
    122156{
     
    131165                if (colObj->isActive())
    132166                {
    133                         btVector3 minAabb,maxAabb;
    134                         colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
    135                         //need to increase the aabb for contact thresholds
    136                         btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
    137                         minAabb -= contactThreshold;
    138                         maxAabb += contactThreshold;
    139 
    140                         btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
    141 
    142                         //moving objects should be moderately sized, probably something wrong if not
    143                         if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
    144                         {
    145                                 bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
    146                         } else
    147                         {
    148                                 //something went wrong, investigate
    149                                 //this assert is unwanted in 3D modelers (danger of loosing work)
    150                                 colObj->setActivationState(DISABLE_SIMULATION);
    151 
    152                                 static bool reportMe = true;
    153                                 if (reportMe && m_debugDrawer)
    154                                 {
    155                                         reportMe = false;
    156                                         m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
    157                                         m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
    158                                         m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
    159                                         m_debugDrawer->reportErrorWarning("Thanks.\n");
    160                                 }
    161                         }
    162                 }
    163         }
    164 
     167                        updateSingleAabb(colObj);
     168                }
     169        }
    165170}
    166171
     
    294299                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
    295300                                                btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*    triangleMesh):
    296                                                 btTriangleRaycastCallback(from,to),
     301                  //@BP Mod
     302                                                btTriangleRaycastCallback(from,to, resultCallback->m_flags),
    297303                                                        m_resultCallback(resultCallback),
    298304                                                        m_collisionObject(collisionObject),
     
    343349                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
    344350                                                btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh):
    345                                                 btTriangleRaycastCallback(from,to),
     351                  //@BP Mod
     352                  btTriangleRaycastCallback(from,to, resultCallback->m_flags),
    346353                                                        m_resultCallback(resultCallback),
    347354                                                        m_collisionObject(collisionObject),
     
    664671                        //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
    665672                        //btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
    666                        
     673#if 0
    667674#ifdef RECALCULATE_AABB
    668675                        btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
     
    672679                        const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin;
    673680                        const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax;
     681#endif
    674682#endif
    675683                        //btScalar hitLambda = m_resultCallback.m_closestHitFraction;
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h

    r2877 r2882  
    139139        }
    140140
     141        void    updateSingleAabb(btCollisionObject* colObj);
     142
    141143        virtual void    updateAabbs();
    142 
    143144
    144145       
     
    193194                short int       m_collisionFilterGroup;
    194195                short int       m_collisionFilterMask;
     196      //@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback
     197      unsigned int m_flags;
    195198
    196199                virtual ~RayResultCallback()
     
    206209                        m_collisionObject(0),
    207210                        m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
    208                         m_collisionFilterMask(btBroadphaseProxy::AllFilter)
     211                        m_collisionFilterMask(btBroadphaseProxy::AllFilter),
     212         //@BP Mod
     213         m_flags(0)
    209214                {
    210215                }
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp

    r2662 r2882  
    2020#include "LinearMath/btIDebugDraw.h"
    2121#include "LinearMath/btAabbUtil2.h"
     22#include "btManifoldResult.h"
    2223
    2324btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
     
    2930
    3031        btCollisionObject* colObj = m_isSwapped? body1 : body0;
     32        btAssert (colObj->getCollisionShape()->isCompound());
     33       
     34        btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
     35        m_compoundShapeRevision = compoundShape->getUpdateRevision();
     36       
     37        preallocateChildAlgorithms(body0,body1);
     38}
     39
     40void    btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1)
     41{
     42        btCollisionObject* colObj = m_isSwapped? body1 : body0;
    3143        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
    32         assert (colObj->getCollisionShape()->isCompound());
     44        btAssert (colObj->getCollisionShape()->isCompound());
    3345       
    3446        btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
     47
    3548        int numChildren = compoundShape->getNumChildShapes();
    3649        int i;
     
    4760                        btCollisionShape* childShape = compoundShape->getChildShape(i);
    4861                        colObj->internalSetTemporaryCollisionShape( childShape );
    49                         m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj,m_sharedManifold);
     62                        m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(colObj,otherObj,m_sharedManifold);
    5063                        colObj->internalSetTemporaryCollisionShape( tmpShape );
    5164                }
     
    5366}
    5467
    55 
    56 btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
     68void    btCompoundCollisionAlgorithm::removeChildAlgorithms()
    5769{
    5870        int numChildren = m_childCollisionAlgorithms.size();
     
    6678                }
    6779        }
     80}
     81
     82btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
     83{
     84        removeChildAlgorithms();
    6885}
    6986
     
    168185        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
    169186
    170         assert (colObj->getCollisionShape()->isCompound());
     187       
     188
     189        btAssert (colObj->getCollisionShape()->isCompound());
    171190        btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
     191
     192        ///btCompoundShape might have changed:
     193        ////make sure the internal child collision algorithm caches are still valid
     194        if (compoundShape->getUpdateRevision() != m_compoundShapeRevision)
     195        {
     196                ///clear and update all
     197                removeChildAlgorithms();
     198               
     199                preallocateChildAlgorithms(body0,body1);
     200        }
     201
    172202
    173203        btDbvt* tree = compoundShape->getDynamicAabbTree();
     
    175205        btCompoundLeafCallback  callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
    176206
     207        ///we need to refresh all contact manifolds
     208        ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep
     209        ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm
     210        {
     211                int i;
     212                btManifoldArray manifoldArray;
     213                for (i=0;i<m_childCollisionAlgorithms.size();i++)
     214                {
     215                        if (m_childCollisionAlgorithms[i])
     216                        {
     217                                m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
     218                                for (int m=0;m<manifoldArray.size();m++)
     219                                {
     220                                        if (manifoldArray[m]->getNumContacts())
     221                                        {
     222                                                resultOut->setPersistentManifold(manifoldArray[m]);
     223                                                resultOut->refreshContactPoints();
     224                                                resultOut->setPersistentManifold(0);//??necessary?
     225                                        }
     226                                }
     227                                manifoldArray.clear();
     228                        }
     229                }
     230        }
    177231
    178232        if (tree)
     
    243297        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
    244298
    245         assert (colObj->getCollisionShape()->isCompound());
     299        btAssert (colObj->getCollisionShape()->isCompound());
    246300       
    247301        btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
     
    286340
    287341
     342
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h

    r2662 r2882  
    2727#include "LinearMath/btAlignedObjectArray.h"
    2828class btDispatcher;
     29class btCollisionObject;
    2930
    3031/// btCompoundCollisionAlgorithm  supports collision between CompoundCollisionShapes and other collision shapes
     
    3637        class btPersistentManifold*     m_sharedManifold;
    3738        bool                                    m_ownsManifold;
     39
     40        int     m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated
    3841       
     42        void    removeChildAlgorithms();
     43       
     44        void    preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1);
     45
    3946public:
    4047
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp

    r2662 r2882  
    5252btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*                       simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    5353{
     54        m_numPerturbationIterations = 0;
     55        m_minimumPointsPerturbationThreshold = 3;
    5456        m_simplexSolver = simplexSolver;
    5557        m_pdSolver = pdSolver;
     
    6062}
    6163
    62 btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
     64btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
    6365: btActivatingCollisionAlgorithm(ci,body0,body1),
    6466m_simplexSolver(simplexSolver),
     
    6668m_ownManifold (false),
    6769m_manifoldPtr(mf),
    68 m_lowLevelOfDetail(false)
     70m_lowLevelOfDetail(false),
    6971#ifdef USE_SEPDISTANCE_UTIL2
    7072,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
    71                           (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc())
     73                          (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
    7274#endif
     75m_numPerturbationIterations(numPerturbationIterations),
     76m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
    7377{
    7478        (void)body0;
     
    9498
    9599
    96 
    97 
     100struct btPerturbedContactResult : public btManifoldResult
     101{
     102        btManifoldResult* m_originalManifoldResult;
     103        btTransform m_transformA;
     104        btTransform m_transformB;
     105        btTransform     m_unPerturbedTransform;
     106        bool    m_perturbA;
     107        btIDebugDraw*   m_debugDrawer;
     108
     109
     110        btPerturbedContactResult(btManifoldResult* originalResult,const btTransform& transformA,const btTransform& transformB,const btTransform& unPerturbedTransform,bool perturbA,btIDebugDraw* debugDrawer)
     111                :m_originalManifoldResult(originalResult),
     112                m_transformA(transformA),
     113                m_transformB(transformB),
     114                m_perturbA(perturbA),
     115                m_unPerturbedTransform(unPerturbedTransform),
     116                m_debugDrawer(debugDrawer)
     117        {
     118        }
     119        virtual ~ btPerturbedContactResult()
     120        {
     121        }
     122
     123        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar orgDepth)
     124        {
     125                btVector3 endPt,startPt;
     126                btScalar newDepth;
     127                btVector3 newNormal;
     128
     129                if (m_perturbA)
     130                {
     131                        btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth;
     132                        endPt = (m_unPerturbedTransform*m_transformA.inverse())(endPtOrg);
     133                        newDepth = (endPt -  pointInWorld).dot(normalOnBInWorld);
     134                        startPt = endPt+normalOnBInWorld*newDepth;
     135                } else
     136                {
     137                        endPt = pointInWorld + normalOnBInWorld*orgDepth;
     138                        startPt = (m_unPerturbedTransform*m_transformB.inverse())(pointInWorld);
     139                        newDepth = (endPt -  startPt).dot(normalOnBInWorld);
     140                       
     141                }
     142
     143//#define DEBUG_CONTACTS 1
     144#ifdef DEBUG_CONTACTS
     145                m_debugDrawer->drawLine(startPt,endPt,btVector3(1,0,0));
     146                m_debugDrawer->drawSphere(startPt,0.05,btVector3(0,1,0));
     147                m_debugDrawer->drawSphere(endPt,0.05,btVector3(0,0,1));
     148#endif //DEBUG_CONTACTS
     149
     150               
     151                m_originalManifoldResult->addContactPoint(normalOnBInWorld,startPt,newDepth);
     152        }
     153
     154};
     155
     156extern btScalar gContactBreakingThreshold;
    98157
    99158//
     
    111170        resultOut->setPersistentManifold(m_manifoldPtr);
    112171
     172        //comment-out next line to test multi-contact generation
     173        //resultOut->getPersistentManifold()->clearManifold();
    113174       
    114175
     
    147208
    148209        gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
    149 
    150210        btScalar sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold;
     211
     212        //now perturbe directions to get multiple contact points
     213        btVector3 v0,v1;
     214        btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
     215        btPlaneSpace1(sepNormalWorldSpace,v0,v1);
     216        //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
     217       
     218        //perform perturbation when more then 'm_minimumPointsPerturbationThreshold' points
     219        if (resultOut->getPersistentManifold()->getNumContacts() < m_minimumPointsPerturbationThreshold)
     220        {
     221               
     222                int i;
     223
     224                bool perturbeA = true;
     225                const btScalar angleLimit = 0.125f * SIMD_PI;
     226                btScalar perturbeAngle;
     227                btScalar radiusA = min0->getAngularMotionDisc();
     228                btScalar radiusB = min1->getAngularMotionDisc();
     229                if (radiusA < radiusB)
     230                {
     231                        perturbeAngle = gContactBreakingThreshold /radiusA;
     232                        perturbeA = true;
     233                } else
     234                {
     235                        perturbeAngle = gContactBreakingThreshold / radiusB;
     236                        perturbeA = false;
     237                }
     238                if ( perturbeAngle > angleLimit )
     239                                perturbeAngle = angleLimit;
     240
     241                btTransform unPerturbedTransform;
     242                if (perturbeA)
     243                {
     244                        unPerturbedTransform = input.m_transformA;
     245                } else
     246                {
     247                        unPerturbedTransform = input.m_transformB;
     248                }
     249               
     250                for ( i=0;i<m_numPerturbationIterations;i++)
     251                {
     252                        btQuaternion perturbeRot(v0,perturbeAngle);
     253                        btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
     254                        btQuaternion rotq(sepNormalWorldSpace,iterationAngle);
     255                       
     256                       
     257                        if (perturbeA)
     258                        {
     259                                input.m_transformA.setBasis(  btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body0->getWorldTransform().getBasis());
     260                                input.m_transformB = body1->getWorldTransform();
     261#ifdef DEBUG_CONTACTS
     262                                dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0);
     263#endif //DEBUG_CONTACTS
     264                        } else
     265                        {
     266                                input.m_transformA = body0->getWorldTransform();
     267                                input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1->getWorldTransform().getBasis());
     268#ifdef DEBUG_CONTACTS
     269                                dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0);
     270#endif
     271                        }
     272                       
     273                        btPerturbedContactResult perturbedResultOut(resultOut,input.m_transformA,input.m_transformB,unPerturbedTransform,perturbeA,dispatchInfo.m_debugDraw);
     274                        gjkPairDetector.getClosestPoints(input,perturbedResultOut,dispatchInfo.m_debugDraw);
     275                       
     276                       
     277                }
     278        }
     279
     280       
    151281
    152282#ifdef USE_SEPDISTANCE_UTIL2
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h

    r2662 r2882  
    3434///#define USE_SEPDISTANCE_UTIL2 1
    3535
    36 ///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
     36///The convexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations between two convex objects.
     37///Multiple contact points are calculated by perturbing the orientation of the smallest object orthogonal to the separating normal.
     38///This idea was described by Gino van den Bergen in this forum topic http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=4&t=288&p=888#p888
    3739class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm
    3840{
     
    4850        bool                    m_lowLevelOfDetail;
    4951       
     52        int m_numPerturbationIterations;
     53        int m_minimumPointsPerturbationThreshold;
     54
     55
    5056        ///cache separating vector to speedup collision detection
    5157       
     
    5359public:
    5460
    55         btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
     61        btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
     62
    5663
    5764        virtual ~btConvexConvexAlgorithm();
     
    7986        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
    8087        {
     88
    8189                btConvexPenetrationDepthSolver*         m_pdSolver;
    8290                btSimplexSolverInterface*                       m_simplexSolver;
    83                
     91                int m_numPerturbationIterations;
     92                int m_minimumPointsPerturbationThreshold;
     93
    8494                CreateFunc(btSimplexSolverInterface*                    simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
    8595               
     
    8999                {
    90100                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm));
    91                         return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver);
     101                        return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
    92102                }
    93103        };
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp

    r2662 r2882  
    55This software is provided 'as-is', without any express or implied warranty.
    66In no event will the authors be held liable for any damages arising from the use of this software.
    7 Permission is granted to anyone to use this software for any purpose, 
    8 including commercial applications, and to alter it and redistribute it freely, 
     7Permission is granted to anyone to use this software for any purpose,
     8including commercial applications, and to alter it and redistribute it freely,
    99subject to the following restrictions:
    1010
     
    2323//#include <stdio.h>
    2424
    25 btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
     25btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold)
    2626: btCollisionAlgorithm(ci),
    2727m_ownManifold(false),
    2828m_manifoldPtr(mf),
    29 m_isSwapped(isSwapped)
     29m_isSwapped(isSwapped),
     30m_numPerturbationIterations(numPerturbationIterations),
     31m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
    3032{
    3133        btCollisionObject* convexObj = m_isSwapped? col1 : col0;
    3234        btCollisionObject* planeObj = m_isSwapped? col0 : col1;
    33        
     35
    3436        if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
    3537        {
     
    4951}
    5052
    51 
    52 
    53 void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
     53void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
    5454{
    55         (void)dispatchInfo;
    56         (void)resultOut;
    57         if (!m_manifoldPtr)
    58                 return;
    59 
    60         btCollisionObject* convexObj = m_isSwapped? body1 : body0;
     55    btCollisionObject* convexObj = m_isSwapped? body1 : body0;
    6156        btCollisionObject* planeObj = m_isSwapped? body0: body1;
    6257
     
    6459        btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
    6560
    66         bool hasCollision = false;
     61    bool hasCollision = false;
    6762        const btVector3& planeNormal = planeShape->getPlaneNormal();
    6863        const btScalar& planeConstant = planeShape->getPlaneConstant();
     64       
     65        btTransform convexWorldTransform = convexObj->getWorldTransform();
     66        btTransform convexInPlaneTrans;
     67        convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform;
     68        //now perturbe the convex-world transform
     69        convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
    6970        btTransform planeInConvex;
    70         planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
    71         btTransform convexInPlaneTrans;
    72         convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
     71        planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform();
     72       
     73        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
    7374
    74         btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
    7575        btVector3 vtxInPlane = convexInPlaneTrans(vtx);
    7676        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
     
    8888                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
    8989        }
     90}
     91
     92
     93void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
     94{
     95        (void)dispatchInfo;
     96        if (!m_manifoldPtr)
     97                return;
     98
     99    btCollisionObject* convexObj = m_isSwapped? body1 : body0;
     100        btCollisionObject* planeObj = m_isSwapped? body0: body1;
     101
     102        btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
     103        btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
     104
     105    bool hasCollision = false;
     106        const btVector3& planeNormal = planeShape->getPlaneNormal();
     107        const btScalar& planeConstant = planeShape->getPlaneConstant();
     108
     109        //first perform a collision query with the non-perturbated collision objects
     110        {
     111                btQuaternion rotq(0,0,0,1);
     112                collideSingleContact(rotq,body0,body1,dispatchInfo,resultOut);
     113        }
     114
     115        if (resultOut->getPersistentManifold()->getNumContacts()<m_minimumPointsPerturbationThreshold)
     116        {
     117                btVector3 v0,v1;
     118                btPlaneSpace1(planeNormal,v0,v1);
     119                //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
     120
     121                const btScalar angleLimit = 0.125f * SIMD_PI;
     122                btScalar perturbeAngle;
     123                btScalar radius = convexShape->getAngularMotionDisc();
     124                perturbeAngle = gContactBreakingThreshold / radius;
     125                if ( perturbeAngle > angleLimit )
     126                                perturbeAngle = angleLimit;
     127
     128                btQuaternion perturbeRot(v0,perturbeAngle);
     129                for (int i=0;i<m_numPerturbationIterations;i++)
     130                {
     131                        btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
     132                        btQuaternion rotq(planeNormal,iterationAngle);
     133                        collideSingleContact(rotq.inverse()*perturbeRot*rotq,body0,body1,dispatchInfo,resultOut);
     134                }
     135        }
     136
    90137        if (m_ownManifold)
    91138        {
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h

    r2662 r2882  
    55This software is provided 'as-is', without any express or implied warranty.
    66In no event will the authors be held liable for any damages arising from the use of this software.
    7 Permission is granted to anyone to use this software for any purpose, 
    8 including commercial applications, and to alter it and redistribute it freely, 
     7Permission is granted to anyone to use this software for any purpose,
     8including commercial applications, and to alter it and redistribute it freely,
    99subject to the following restrictions:
    1010
     
    2929class btConvexPlaneCollisionAlgorithm : public btCollisionAlgorithm
    3030{
    31         bool    m_ownManifold;
     31        bool            m_ownManifold;
    3232        btPersistentManifold*   m_manifoldPtr;
    33         bool    m_isSwapped;
    34        
     33        bool            m_isSwapped;
     34        int                     m_numPerturbationIterations;
     35        int                     m_minimumPointsPerturbationThreshold;
     36
    3537public:
    3638
    37         btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
     39        btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold);
    3840
    3941        virtual ~btConvexPlaneCollisionAlgorithm();
    4042
    4143        virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
     44
     45        void collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
    4246
    4347        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
     
    5357        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
    5458        {
     59                int     m_numPerturbationIterations;
     60                int m_minimumPointsPerturbationThreshold;
     61                       
     62                CreateFunc()
     63                        : m_numPerturbationIterations(3),
     64                        m_minimumPointsPerturbationThreshold(3)
     65                {
     66                }
     67               
    5568                virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
    5669                {
     
    5871                        if (!m_swapped)
    5972                        {
    60                                 return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false);
     73                                return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
    6174                        } else
    6275                        {
    63                                 return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true);
     76                                return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
    6477                        }
    6578                }
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp

    r2662 r2882  
    289289        return m_emptyCreateFunc;
    290290}
     291
     292void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
     293{
     294        btConvexConvexAlgorithm::CreateFunc* convexConvex = (btConvexConvexAlgorithm::CreateFunc*) m_convexConvexCreateFunc;
     295        convexConvex->m_numPerturbationIterations = numPerturbationIterations;
     296        convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
     297}
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h

    r2662 r2882  
    112112        virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
    113113
     114        ///Use this method to allow to generate multiple contact points between at once, between two objects using the generic convex-convex algorithm.
     115        ///By default, this feature is disabled for best performance.
     116        ///@param numPerturbationIterations controls the number of collision queries. Set it to zero to disable the feature.
     117        ///@param minimumPointsPerturbationThreshold is the minimum number of points in the contact cache, above which the feature is disabled
     118        ///3 is a good value for both params, if you want to enable the feature. This is because the default contact cache contains a maximum of 4 points, and one collision query at the unperturbed orientation is performed first.
     119        ///See Bullet/Demos/CollisionDemo for an example how this feature gathers multiple points.
     120        ///@todo we could add a per-object setting of those parameters, for level-of-detail collision detection.
     121        void    setConvexConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold = 3);
    114122
    115123};
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btGhostObject.cpp

    r2662 r2882  
    6464btPairCachingGhostObject::~btPairCachingGhostObject()
    6565{
     66        m_hashPairCache->~btHashedOverlappingPairCache();
    6667        btAlignedFree( m_hashPairCache );
    6768}
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp

    r2662 r2882  
    5656void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
    5757{
    58         assert(m_manifoldPtr);
     58        btAssert(m_manifoldPtr);
    5959        //order in manifold needs to match
    6060       
     
    9393   newPt.m_index0  = m_index0;
    9494   newPt.m_index1  = m_index1;
    95        
     95        //printf("depth=%f\n",depth);
    9696        ///@todo, check this for any side effects
    9797        if (insertIndex >= 0)
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h

    r2662 r2882  
    4646        int m_index0;
    4747        int m_index1;
     48       
     49
    4850public:
    4951
     
    7880        }
    7981
     82
    8083        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
    8184
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp

    r2662 r2882  
    2525#include "LinearMath/btQuickprof.h"
    2626
    27 btSimulationIslandManager::btSimulationIslandManager()
     27btSimulationIslandManager::btSimulationIslandManager():
     28m_splitIslands(true)
    2829{
    2930}
     
    4445       
    4546        {
    46                 btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
    47 
     47               
    4848                for (int i=0;i<colWorld->getPairCache()->getNumOverlappingPairs();i++)
    4949                {
     50                        btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
    5051                        const btBroadphasePair& collisionPair = pairPtr[i];
    5152                        btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
     
    186187                        }
    187188
    188                         assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
     189                        btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
    189190                        if (colObj0->getIslandTag() == islandId)
    190191                        {
     
    213214                                }
    214215
    215                                 assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
     216                                btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
    216217
    217218                                if (colObj0->getIslandTag() == islandId)
     
    234235                                }
    235236
    236                                 assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
     237                                btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
    237238
    238239                                if (colObj0->getIslandTag() == islandId)
     
    252253        int maxNumManifolds = dispatcher->getNumManifolds();
    253254
    254 #define SPLIT_ISLANDS 1
    255 #ifdef SPLIT_ISLANDS
    256 
    257        
    258 #endif //SPLIT_ISLANDS
     255//#define SPLIT_ISLANDS 1
     256//#ifdef SPLIT_ISLANDS
     257
     258       
     259//#endif //SPLIT_ISLANDS
    259260
    260261       
     
    280281                                colObj0->activate();
    281282                        }
    282 #ifdef SPLIT_ISLANDS
    283         //              //filtering for response
    284                         if (dispatcher->needsResponse(colObj0,colObj1))
    285                                 m_islandmanifold.push_back(manifold);
    286 #endif //SPLIT_ISLANDS
     283                        if(m_splitIslands)
     284                        {
     285                                //filtering for response
     286                                if (dispatcher->needsResponse(colObj0,colObj1))
     287                                        m_islandmanifold.push_back(manifold);
     288                        }
    287289                }
    288290        }
     
    304306        BT_PROFILE("processIslands");
    305307
    306 #ifndef SPLIT_ISLANDS
    307         btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
    308        
    309         callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
    310 #else
    311         // Sort manifolds, based on islands
    312         // Sort the vector using predicate and std::sort
    313         //std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
    314 
    315         int numManifolds = int (m_islandmanifold.size());
    316 
    317         //we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
    318         m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
    319 
    320         //now process all active islands (sets of manifolds for now)
    321 
    322         int startManifoldIndex = 0;
    323         int endManifoldIndex = 1;
    324 
    325         //int islandId;
    326 
    327        
    328 
    329 //      printf("Start Islands\n");
    330 
    331         //traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
    332         for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
    333         {
    334                 int islandId = getUnionFind().getElement(startIslandIndex).m_id;
    335 
    336 
    337                bool islandSleeping = false;
    338                
    339                 for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
    340                 {
    341                         int i = getUnionFind().getElement(endIslandIndex).m_sz;
    342                         btCollisionObject* colObj0 = collisionObjects[i];
    343                                                 m_islandBodies.push_back(colObj0);
    344                         if (!colObj0->isActive())
    345                                 islandSleeping = true;
    346                 }
    347                
    348 
    349                 //find the accompanying contact manifold for this islandId
    350                 int numIslandManifolds = 0;
    351                 btPersistentManifold** startManifold = 0;
    352 
    353                 if (startManifoldIndex<numManifolds)
    354                 {
    355                         int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
    356                         if (curIslandId == islandId)
    357                         {
    358                                 startManifold = &m_islandmanifold[startManifoldIndex];
     308        if(!m_splitIslands)
     309        {
     310                btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
     311                int maxNumManifolds = dispatcher->getNumManifolds();
     312                callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
     313        }
     314        else
     315        {
     316                // Sort manifolds, based on islands
     317                // Sort the vector using predicate and std::sort
     318                //std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
     319
     320                int numManifolds = int (m_islandmanifold.size());
     321
     322                //we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
     323                m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
     324
     325                //now process all active islands (sets of manifolds for now)
     326
     327                int startManifoldIndex = 0;
     328                int endManifoldIndex = 1;
     329
     330                //int islandId;
     331
     332               
     333
     334        //      printf("Start Islands\n");
     335
     336                //traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
     337                for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
     338                {
     339                        int islandId = getUnionFind().getElement(startIslandIndex).m_id;
     340
     341
     342                           bool islandSleeping = false;
     343                       
     344                                        for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
     345                                        {
     346                                                        int i = getUnionFind().getElement(endIslandIndex).m_sz;
     347                                                        btCollisionObject* colObj0 = collisionObjects[i];
     348                                                        m_islandBodies.push_back(colObj0);
     349                                                        if (!colObj0->isActive())
     350                                                                        islandSleeping = true;
     351                                        }
     352                       
     353
     354                        //find the accompanying contact manifold for this islandId
     355                        int numIslandManifolds = 0;
     356                        btPersistentManifold** startManifold = 0;
     357
     358                        if (startManifoldIndex<numManifolds)
     359                        {
     360                                int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
     361                                if (curIslandId == islandId)
     362                                {
     363                                        startManifold = &m_islandmanifold[startManifoldIndex];
     364                               
     365                                        for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
     366                                        {
     367
     368                                        }
     369                                        /// Process the actual simulation, only if not sleeping/deactivated
     370                                        numIslandManifolds = endManifoldIndex-startManifoldIndex;
     371                                }
     372
     373                        }
     374
     375                        if (!islandSleeping)
     376                        {
     377                                callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
     378        //                      printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
     379                        }
    359380                       
    360                                 for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
    361                                 {
    362 
    363                                 }
    364                                 /// Process the actual simulation, only if not sleeping/deactivated
    365                                 numIslandManifolds = endManifoldIndex-startManifoldIndex;
    366                         }
    367 
    368                 }
    369 
    370                 if (!islandSleeping)
    371                 {
    372                         callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
    373 //                      printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
    374                 }
    375                
    376                 if (numIslandManifolds)
    377                 {
    378                         startManifoldIndex = endManifoldIndex;
    379                 }
    380 
    381                 m_islandBodies.resize(0);
    382         }
    383 #endif //SPLIT_ISLANDS
    384 
    385 
    386 }
     381                        if (numIslandManifolds)
     382                        {
     383                                startManifoldIndex = endManifoldIndex;
     384                        }
     385
     386                        m_islandBodies.resize(0);
     387                }
     388        } // else if(!splitIslands)
     389
     390}
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h

    r2662 r2882  
    3636        btAlignedObjectArray<btCollisionObject* >  m_islandBodies;
    3737       
     38        bool m_splitIslands;
    3839       
    3940public:
     
    6667        void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld);
    6768
     69        bool getSplitIslands()
     70        {
     71                return m_splitIslands;
     72        }
     73        void setSplitIslands(bool doSplitIslands)
     74        {
     75                m_splitIslands = doSplitIslands;
     76        }
     77
    6878};
    6979
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp

    r2662 r2882  
    7979
    8080        ///point on A (worldspace)
    81         btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
     81        ///btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
    8282        ///point on B (worldspace)
    8383        btVector3 pos1 = col1->getWorldTransform().getOrigin() + radius1* normalOnSurfaceB;
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp

    r2662 r2882  
    1515
    1616#include "btUnionFind.h"
    17 #include <assert.h>
    18 
    1917
    2018
  • code/trunk/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h

    r2662 r2882  
    9999                int find(int x)
    100100                {
    101                         //assert(x < m_N);
    102                         //assert(x >= 0);
     101                        //btAssert(x < m_N);
     102                        //btAssert(x >= 0);
    103103
    104104                        while (x != m_elements[x].m_id)
     
    111111                #endif //
    112112                                x = m_elements[x].m_id;
    113                                 //assert(x < m_N);
    114                                 //assert(x >= 0);
     113                                //btAssert(x < m_N);
     114                                //btAssert(x >= 0);
    115115
    116116                        }
Note: See TracChangeset for help on using the changeset viewer.