Changeset 2430 for code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
- Timestamp:
- Dec 13, 2008, 11:45:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
r2192 r2430 39 39 #include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" 40 40 41 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa .h"41 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" 42 42 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" 43 43 … … 61 61 62 62 btConvexConvexAlgorithm::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), 64 m_simplexSolver(simplexSolver), 65 m_pdSolver(pdSolver), 65 66 m_ownManifold (false), 66 67 m_manifoldPtr(mf), 67 68 m_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 68 73 { 69 74 (void)body0; 70 75 (void)body1; 71 72 73 76 } 74 77 … … 108 111 resultOut->setPersistentManifold(m_manifoldPtr); 109 112 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 123 114 124 115 btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape()); 125 116 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 126 125 127 126 btGjkPairDetector::ClosestPointInput input; 128 127 128 btGjkPairDetector gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver); 129 129 //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 134 144 input.m_stackAlloc = dispatchInfo.m_stackAllocator; 135 136 // input.m_maximumDistanceSquared = btScalar(1e30);137 138 145 input.m_transformA = body0->getWorldTransform(); 139 146 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 } 143 161 144 162 if (m_ownManifold)
Note: See TracChangeset
for help on using the changeset viewer.