btConvexConvexAlgorithm.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. ///Specialized capsule-capsule collision algorithm has been added for Bullet 2.75 release to increase ragdoll performance
  14. ///If you experience problems with capsule-capsule collision, try to define BT_DISABLE_CAPSULE_CAPSULE_COLLIDER and report it in the Bullet forums
  15. ///with reproduction case
  16. //define BT_DISABLE_CAPSULE_CAPSULE_COLLIDER 1
  17. #include "btConvexConvexAlgorithm.h"
  18. //#include <stdio.h>
  19. #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
  20. #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
  21. #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
  22. #include "BulletCollision/CollisionShapes/btConvexShape.h"
  23. #include "BulletCollision/CollisionShapes/btCapsuleShape.h"
  24. #include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
  25. #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
  26. #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
  27. #include "BulletCollision/CollisionShapes/btBoxShape.h"
  28. #include "BulletCollision/CollisionDispatch/btManifoldResult.h"
  29. #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
  30. #include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
  31. #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
  32. #include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
  33. #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
  34. #include "BulletCollision/CollisionShapes/btSphereShape.h"
  35. #include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
  36. #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
  37. #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
  38. ///////////
  39. static SIMD_FORCE_INLINE void segmentsClosestPoints(
  40. btVector3& ptsVector,
  41. btVector3& offsetA,
  42. btVector3& offsetB,
  43. btScalar& tA, btScalar& tB,
  44. const btVector3& translation,
  45. const btVector3& dirA, btScalar hlenA,
  46. const btVector3& dirB, btScalar hlenB )
  47. {
  48. // compute the parameters of the closest points on each line segment
  49. btScalar dirA_dot_dirB = btDot(dirA,dirB);
  50. btScalar dirA_dot_trans = btDot(dirA,translation);
  51. btScalar dirB_dot_trans = btDot(dirB,translation);
  52. btScalar denom = 1.0f - dirA_dot_dirB * dirA_dot_dirB;
  53. if ( denom == 0.0f ) {
  54. tA = 0.0f;
  55. } else {
  56. tA = ( dirA_dot_trans - dirB_dot_trans * dirA_dot_dirB ) / denom;
  57. if ( tA < -hlenA )
  58. tA = -hlenA;
  59. else if ( tA > hlenA )
  60. tA = hlenA;
  61. }
  62. tB = tA * dirA_dot_dirB - dirB_dot_trans;
  63. if ( tB < -hlenB ) {
  64. tB = -hlenB;
  65. tA = tB * dirA_dot_dirB + dirA_dot_trans;
  66. if ( tA < -hlenA )
  67. tA = -hlenA;
  68. else if ( tA > hlenA )
  69. tA = hlenA;
  70. } else if ( tB > hlenB ) {
  71. tB = hlenB;
  72. tA = tB * dirA_dot_dirB + dirA_dot_trans;
  73. if ( tA < -hlenA )
  74. tA = -hlenA;
  75. else if ( tA > hlenA )
  76. tA = hlenA;
  77. }
  78. // compute the closest points relative to segment centers.
  79. offsetA = dirA * tA;
  80. offsetB = dirB * tB;
  81. ptsVector = translation - offsetA + offsetB;
  82. }
  83. static SIMD_FORCE_INLINE btScalar capsuleCapsuleDistance(
  84. btVector3& normalOnB,
  85. btVector3& pointOnB,
  86. btScalar capsuleLengthA,
  87. btScalar capsuleRadiusA,
  88. btScalar capsuleLengthB,
  89. btScalar capsuleRadiusB,
  90. int capsuleAxisA,
  91. int capsuleAxisB,
  92. const btTransform& transformA,
  93. const btTransform& transformB,
  94. btScalar distanceThreshold )
  95. {
  96. btVector3 directionA = transformA.getBasis().getColumn(capsuleAxisA);
  97. btVector3 translationA = transformA.getOrigin();
  98. btVector3 directionB = transformB.getBasis().getColumn(capsuleAxisB);
  99. btVector3 translationB = transformB.getOrigin();
  100. // translation between centers
  101. btVector3 translation = translationB - translationA;
  102. // compute the closest points of the capsule line segments
  103. btVector3 ptsVector; // the vector between the closest points
  104. btVector3 offsetA, offsetB; // offsets from segment centers to their closest points
  105. btScalar tA, tB; // parameters on line segment
  106. segmentsClosestPoints( ptsVector, offsetA, offsetB, tA, tB, translation,
  107. directionA, capsuleLengthA, directionB, capsuleLengthB );
  108. btScalar distance = ptsVector.length() - capsuleRadiusA - capsuleRadiusB;
  109. if ( distance > distanceThreshold )
  110. return distance;
  111. btScalar lenSqr = ptsVector.length2();
  112. if (lenSqr<= (SIMD_EPSILON*SIMD_EPSILON))
  113. {
  114. //degenerate case where 2 capsules are likely at the same location: take a vector tangential to 'directionA'
  115. btVector3 q;
  116. btPlaneSpace1(directionA,normalOnB,q);
  117. } else
  118. {
  119. // compute the contact normal
  120. normalOnB = ptsVector*-btRecipSqrt(lenSqr);
  121. }
  122. pointOnB = transformB.getOrigin()+offsetB + normalOnB * capsuleRadiusB;
  123. return distance;
  124. }
  125. //////////
  126. btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
  127. {
  128. m_numPerturbationIterations = 0;
  129. m_minimumPointsPerturbationThreshold = 3;
  130. m_simplexSolver = simplexSolver;
  131. m_pdSolver = pdSolver;
  132. }
  133. btConvexConvexAlgorithm::CreateFunc::~CreateFunc()
  134. {
  135. }
  136. btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
  137. : btActivatingCollisionAlgorithm(ci,body0,body1),
  138. m_simplexSolver(simplexSolver),
  139. m_pdSolver(pdSolver),
  140. m_ownManifold (false),
  141. m_manifoldPtr(mf),
  142. m_lowLevelOfDetail(false),
  143. #ifdef USE_SEPDISTANCE_UTIL2
  144. m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
  145. (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
  146. #endif
  147. m_numPerturbationIterations(numPerturbationIterations),
  148. m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
  149. {
  150. (void)body0;
  151. (void)body1;
  152. }
  153. btConvexConvexAlgorithm::~btConvexConvexAlgorithm()
  154. {
  155. if (m_ownManifold)
  156. {
  157. if (m_manifoldPtr)
  158. m_dispatcher->releaseManifold(m_manifoldPtr);
  159. }
  160. }
  161. void btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel)
  162. {
  163. m_lowLevelOfDetail = useLowLevel;
  164. }
  165. struct btPerturbedContactResult : public btManifoldResult
  166. {
  167. btManifoldResult* m_originalManifoldResult;
  168. btTransform m_transformA;
  169. btTransform m_transformB;
  170. btTransform m_unPerturbedTransform;
  171. bool m_perturbA;
  172. btIDebugDraw* m_debugDrawer;
  173. btPerturbedContactResult(btManifoldResult* originalResult,const btTransform& transformA,const btTransform& transformB,const btTransform& unPerturbedTransform,bool perturbA,btIDebugDraw* debugDrawer)
  174. :m_originalManifoldResult(originalResult),
  175. m_transformA(transformA),
  176. m_transformB(transformB),
  177. m_perturbA(perturbA),
  178. m_unPerturbedTransform(unPerturbedTransform),
  179. m_debugDrawer(debugDrawer)
  180. {
  181. }
  182. virtual ~ btPerturbedContactResult()
  183. {
  184. }
  185. virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar orgDepth)
  186. {
  187. btVector3 endPt,startPt;
  188. btScalar newDepth;
  189. btVector3 newNormal;
  190. if (m_perturbA)
  191. {
  192. btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth;
  193. endPt = (m_unPerturbedTransform*m_transformA.inverse())(endPtOrg);
  194. newDepth = (endPt - pointInWorld).dot(normalOnBInWorld);
  195. startPt = endPt+normalOnBInWorld*newDepth;
  196. } else
  197. {
  198. endPt = pointInWorld + normalOnBInWorld*orgDepth;
  199. startPt = (m_unPerturbedTransform*m_transformB.inverse())(pointInWorld);
  200. newDepth = (endPt - startPt).dot(normalOnBInWorld);
  201. }
  202. //#define DEBUG_CONTACTS 1
  203. #ifdef DEBUG_CONTACTS
  204. m_debugDrawer->drawLine(startPt,endPt,btVector3(1,0,0));
  205. m_debugDrawer->drawSphere(startPt,0.05,btVector3(0,1,0));
  206. m_debugDrawer->drawSphere(endPt,0.05,btVector3(0,0,1));
  207. #endif //DEBUG_CONTACTS
  208. m_originalManifoldResult->addContactPoint(normalOnBInWorld,startPt,newDepth);
  209. }
  210. };
  211. extern btScalar gContactBreakingThreshold;
  212. //
  213. // Convex-Convex collision algorithm
  214. //
  215. void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
  216. {
  217. if (!m_manifoldPtr)
  218. {
  219. //swapped?
  220. m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
  221. m_ownManifold = true;
  222. }
  223. resultOut->setPersistentManifold(m_manifoldPtr);
  224. //comment-out next line to test multi-contact generation
  225. //resultOut->getPersistentManifold()->clearManifold();
  226. btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
  227. btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
  228. btVector3 normalOnB;
  229. btVector3 pointOnBWorld;
  230. #ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
  231. if ((min0->getShapeType() == CAPSULE_SHAPE_PROXYTYPE) && (min1->getShapeType() == CAPSULE_SHAPE_PROXYTYPE))
  232. {
  233. btCapsuleShape* capsuleA = (btCapsuleShape*) min0;
  234. btCapsuleShape* capsuleB = (btCapsuleShape*) min1;
  235. btVector3 localScalingA = capsuleA->getLocalScaling();
  236. btVector3 localScalingB = capsuleB->getLocalScaling();
  237. btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
  238. btScalar dist = capsuleCapsuleDistance(normalOnB, pointOnBWorld,capsuleA->getHalfHeight(),capsuleA->getRadius(),
  239. capsuleB->getHalfHeight(),capsuleB->getRadius(),capsuleA->getUpAxis(),capsuleB->getUpAxis(),
  240. body0->getWorldTransform(),body1->getWorldTransform(),threshold);
  241. if (dist<threshold)
  242. {
  243. btAssert(normalOnB.length2()>=(SIMD_EPSILON*SIMD_EPSILON));
  244. resultOut->addContactPoint(normalOnB,pointOnBWorld,dist);
  245. }
  246. resultOut->refreshContactPoints();
  247. return;
  248. }
  249. #endif //BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
  250. #ifdef USE_SEPDISTANCE_UTIL2
  251. m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform());
  252. if (!dispatchInfo.m_useConvexConservativeDistanceUtil || m_sepDistance.getConservativeSeparatingDistance()<=0.f)
  253. #endif //USE_SEPDISTANCE_UTIL2
  254. {
  255. btGjkPairDetector::ClosestPointInput input;
  256. btGjkPairDetector gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver);
  257. //TODO: if (dispatchInfo.m_useContinuous)
  258. gjkPairDetector.setMinkowskiA(min0);
  259. gjkPairDetector.setMinkowskiB(min1);
  260. #ifdef USE_SEPDISTANCE_UTIL2
  261. if (dispatchInfo.m_useConvexConservativeDistanceUtil)
  262. {
  263. input.m_maximumDistanceSquared = BT_LARGE_FLOAT;
  264. } else
  265. #endif //USE_SEPDISTANCE_UTIL2
  266. {
  267. input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
  268. input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
  269. }
  270. input.m_stackAlloc = dispatchInfo.m_stackAllocator;
  271. input.m_transformA = body0->getWorldTransform();
  272. input.m_transformB = body1->getWorldTransform();
  273. gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
  274. btVector3 v0,v1;
  275. btVector3 sepNormalWorldSpace;
  276. #ifdef USE_SEPDISTANCE_UTIL2
  277. btScalar sepDist = 0.f;
  278. if (dispatchInfo.m_useConvexConservativeDistanceUtil)
  279. {
  280. sepDist = gjkPairDetector.getCachedSeparatingDistance();
  281. if (sepDist>SIMD_EPSILON)
  282. {
  283. sepDist += dispatchInfo.m_convexConservativeDistanceThreshold;
  284. //now perturbe directions to get multiple contact points
  285. sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
  286. btPlaneSpace1(sepNormalWorldSpace,v0,v1);
  287. }
  288. }
  289. #endif //USE_SEPDISTANCE_UTIL2
  290. //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
  291. //perform perturbation when more then 'm_minimumPointsPerturbationThreshold' points
  292. if (resultOut->getPersistentManifold()->getNumContacts() < m_minimumPointsPerturbationThreshold)
  293. {
  294. int i;
  295. bool perturbeA = true;
  296. const btScalar angleLimit = 0.125f * SIMD_PI;
  297. btScalar perturbeAngle;
  298. btScalar radiusA = min0->getAngularMotionDisc();
  299. btScalar radiusB = min1->getAngularMotionDisc();
  300. if (radiusA < radiusB)
  301. {
  302. perturbeAngle = gContactBreakingThreshold /radiusA;
  303. perturbeA = true;
  304. } else
  305. {
  306. perturbeAngle = gContactBreakingThreshold / radiusB;
  307. perturbeA = false;
  308. }
  309. if ( perturbeAngle > angleLimit )
  310. perturbeAngle = angleLimit;
  311. btTransform unPerturbedTransform;
  312. if (perturbeA)
  313. {
  314. unPerturbedTransform = input.m_transformA;
  315. } else
  316. {
  317. unPerturbedTransform = input.m_transformB;
  318. }
  319. for ( i=0;i<m_numPerturbationIterations;i++)
  320. {
  321. btQuaternion perturbeRot(v0,perturbeAngle);
  322. btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
  323. btQuaternion rotq(sepNormalWorldSpace,iterationAngle);
  324. if (perturbeA)
  325. {
  326. input.m_transformA.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body0->getWorldTransform().getBasis());
  327. input.m_transformB = body1->getWorldTransform();
  328. #ifdef DEBUG_CONTACTS
  329. dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0);
  330. #endif //DEBUG_CONTACTS
  331. } else
  332. {
  333. input.m_transformA = body0->getWorldTransform();
  334. input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1->getWorldTransform().getBasis());
  335. #ifdef DEBUG_CONTACTS
  336. dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0);
  337. #endif
  338. }
  339. btPerturbedContactResult perturbedResultOut(resultOut,input.m_transformA,input.m_transformB,unPerturbedTransform,perturbeA,dispatchInfo.m_debugDraw);
  340. gjkPairDetector.getClosestPoints(input,perturbedResultOut,dispatchInfo.m_debugDraw);
  341. }
  342. }
  343. #ifdef USE_SEPDISTANCE_UTIL2
  344. if (dispatchInfo.m_useConvexConservativeDistanceUtil && (sepDist>SIMD_EPSILON))
  345. {
  346. m_sepDistance.initSeparatingDistance(gjkPairDetector.getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform());
  347. }
  348. #endif //USE_SEPDISTANCE_UTIL2
  349. }
  350. if (m_ownManifold)
  351. {
  352. resultOut->refreshContactPoints();
  353. }
  354. }
  355. bool disableCcd = false;
  356. btScalar btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
  357. {
  358. (void)resultOut;
  359. (void)dispatchInfo;
  360. ///Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold
  361. ///Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold
  362. ///col0->m_worldTransform,
  363. btScalar resultFraction = btScalar(1.);
  364. btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2();
  365. btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2();
  366. if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
  367. squareMot1 < col1->getCcdSquareMotionThreshold())
  368. return resultFraction;
  369. if (disableCcd)
  370. return btScalar(1.);
  371. //An adhoc way of testing the Continuous Collision Detection algorithms
  372. //One object is approximated as a sphere, to simplify things
  373. //Starting in penetration should report no time of impact
  374. //For proper CCD, better accuracy and handling of 'allowed' penetration should be added
  375. //also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies)
  376. /// Convex0 against sphere for Convex1
  377. {
  378. btConvexShape* convex0 = static_cast<btConvexShape*>(col0->getCollisionShape());
  379. btSphereShape sphere1(col1->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation
  380. btConvexCast::CastResult result;
  381. btVoronoiSimplexSolver voronoiSimplex;
  382. //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
  383. ///Simplification, one object is simplified as a sphere
  384. btGjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex);
  385. //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
  386. if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(),
  387. col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result))
  388. {
  389. //store result.m_fraction in both bodies
  390. if (col0->getHitFraction()> result.m_fraction)
  391. col0->setHitFraction( result.m_fraction );
  392. if (col1->getHitFraction() > result.m_fraction)
  393. col1->setHitFraction( result.m_fraction);
  394. if (resultFraction > result.m_fraction)
  395. resultFraction = result.m_fraction;
  396. }
  397. }
  398. /// Sphere (for convex0) against Convex1
  399. {
  400. btConvexShape* convex1 = static_cast<btConvexShape*>(col1->getCollisionShape());
  401. btSphereShape sphere0(col0->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation
  402. btConvexCast::CastResult result;
  403. btVoronoiSimplexSolver voronoiSimplex;
  404. //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
  405. ///Simplification, one object is simplified as a sphere
  406. btGjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex);
  407. //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
  408. if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(),
  409. col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result))
  410. {
  411. //store result.m_fraction in both bodies
  412. if (col0->getHitFraction() > result.m_fraction)
  413. col0->setHitFraction( result.m_fraction);
  414. if (col1->getHitFraction() > result.m_fraction)
  415. col1->setHitFraction( result.m_fraction);
  416. if (resultFraction > result.m_fraction)
  417. resultFraction = result.m_fraction;
  418. }
  419. }
  420. return resultFraction;
  421. }