Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (16 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp

    r2907 r2908  
    5252btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*                       simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    5353{
    54         m_numPerturbationIterations = 0;
    55         m_minimumPointsPerturbationThreshold = 3;
    5654        m_simplexSolver = simplexSolver;
    5755        m_pdSolver = pdSolver;
     
    6260}
    6361
    64 btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
     62btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    6563: btActivatingCollisionAlgorithm(ci,body0,body1),
    6664m_simplexSolver(simplexSolver),
     
    6866m_ownManifold (false),
    6967m_manifoldPtr(mf),
    70 m_lowLevelOfDetail(false),
     68m_lowLevelOfDetail(false)
    7169#ifdef USE_SEPDISTANCE_UTIL2
    7270,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
    73                           (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
     71                          (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc())
    7472#endif
    75 m_numPerturbationIterations(numPerturbationIterations),
    76 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
    7773{
    7874        (void)body0;
     
    9894
    9995
    100 struct 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 
    156 extern btScalar gContactBreakingThreshold;
     96
     97
    15798
    15899//
     
    170111        resultOut->setPersistentManifold(m_manifoldPtr);
    171112
    172         //comment-out next line to test multi-contact generation
    173         //resultOut->getPersistentManifold()->clearManifold();
    174113       
    175114
     
    208147
    209148        gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
     149
    210150        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        
    281151
    282152#ifdef USE_SEPDISTANCE_UTIL2
Note: See TracChangeset for help on using the changeset viewer.