Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 11:45:51 PM (16 years ago)
Author:
rgrieder
Message:

Updated to Bullet 2.73 (first part).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp

    r2192 r2430  
    3939#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
    4040
    41 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
     41#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
    4242#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
    4343
     
    6161
    6262btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    63 : btCollisionAlgorithm(ci),
    64 m_gjkPairDetector(0,0,simplexSolver,pdSolver),
     63: btActivatingCollisionAlgorithm(ci,body0,body1),
     64m_simplexSolver(simplexSolver),
     65m_pdSolver(pdSolver),
    6566m_ownManifold (false),
    6667m_manifoldPtr(mf),
    6768m_lowLevelOfDetail(false)
     69#ifdef USE_SEPDISTANCE_UTIL2
     70,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
     71                          (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc())
     72#endif
    6873{
    6974        (void)body0;
    7075        (void)body1;
    71 
    72 
    7376}
    7477
     
    108111        resultOut->setPersistentManifold(m_manifoldPtr);
    109112
    110 #ifdef USE_BT_GJKEPA
    111         btConvexShape*                          shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
    112         btConvexShape*                          shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
    113         const btScalar                          radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/);
    114         btGjkEpaSolver::sResults        results;
    115         if(btGjkEpaSolver::Collide(     shape0,body0->getWorldTransform(),
    116                                                                 shape1,body1->getWorldTransform(),
    117                                                                 radialmargin,results))
    118                 {
    119                 dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
    120                 resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
    121                 }
    122 #else
     113       
    123114
    124115        btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
    125116        btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
     117
     118#ifdef USE_SEPDISTANCE_UTIL2
     119        m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform());
     120        if (!dispatchInfo.m_useConvexConservativeDistanceUtil || m_sepDistance.getConservativeSeparatingDistance()<=0.f)
     121#endif //USE_SEPDISTANCE_UTIL2
     122
     123        {
     124
    126125       
    127126        btGjkPairDetector::ClosestPointInput input;
    128127
     128        btGjkPairDetector       gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver);
    129129        //TODO: if (dispatchInfo.m_useContinuous)
    130         m_gjkPairDetector.setMinkowskiA(min0);
    131         m_gjkPairDetector.setMinkowskiB(min1);
    132         input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
    133         input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
     130        gjkPairDetector.setMinkowskiA(min0);
     131        gjkPairDetector.setMinkowskiB(min1);
     132
     133#ifdef USE_SEPDISTANCE_UTIL2
     134        if (dispatchInfo.m_useConvexConservativeDistanceUtil)
     135        {
     136                input.m_maximumDistanceSquared = 1e30f;
     137        } else
     138#endif //USE_SEPDISTANCE_UTIL2
     139        {
     140                input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
     141                input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
     142        }
     143
    134144        input.m_stackAlloc = dispatchInfo.m_stackAllocator;
    135 
    136 //      input.m_maximumDistanceSquared = btScalar(1e30);
    137        
    138145        input.m_transformA = body0->getWorldTransform();
    139146        input.m_transformB = body1->getWorldTransform();
    140        
    141         m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
    142 #endif
     147
     148        gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
     149
     150        btScalar sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold;
     151
     152#ifdef USE_SEPDISTANCE_UTIL2
     153        if (dispatchInfo.m_useConvexConservativeDistanceUtil)
     154        {
     155                m_sepDistance.initSeparatingDistance(gjkPairDetector.getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform());
     156        }
     157#endif //USE_SEPDISTANCE_UTIL2
     158
     159
     160        }
    143161
    144162        if (m_ownManifold)
Note: See TracChangeset for help on using the changeset viewer.