Changeset 8393 for code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
- Timestamp:
- May 3, 2011, 5:07:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
r8351 r8393 27 27 #include "BulletCollision/CollisionShapes/btConvexShape.h" 28 28 #include "BulletCollision/CollisionShapes/btCapsuleShape.h" 29 #include "BulletCollision/CollisionShapes/btTriangleShape.h" 30 29 31 30 32 … … 49 51 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" 50 52 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" 51 53 #include "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h" 52 54 53 55 … … 332 334 333 335 336 337 334 338 #ifdef USE_SEPDISTANCE_UTIL2 335 339 if (dispatchInfo.m_useConvexConservativeDistanceUtil) … … 358 362 #endif //USE_SEPDISTANCE_UTIL2 359 363 { 360 if (dispatchInfo.m_convexMaxDistanceUseCPT) 361 { 362 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold(); 363 } else 364 { 365 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); 366 } 364 //if (dispatchInfo.m_convexMaxDistanceUseCPT) 365 //{ 366 // input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold(); 367 //} else 368 //{ 369 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); 370 // } 371 367 372 input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; 368 373 } … … 372 377 input.m_transformB = body1->getWorldTransform(); 373 378 374 gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); 379 375 380 376 381 … … 389 394 } 390 395 #endif //USE_SEPDISTANCE_UTIL2 396 397 if (min0->isPolyhedral() && min1->isPolyhedral()) 398 { 399 400 401 struct btDummyResult : public btDiscreteCollisionDetectorInterface::Result 402 { 403 virtual void setShapeIdentifiersA(int partId0,int index0){} 404 virtual void setShapeIdentifiersB(int partId1,int index1){} 405 virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) 406 { 407 } 408 }; 409 410 btDummyResult dummy; 411 412 413 btPolyhedralConvexShape* polyhedronA = (btPolyhedralConvexShape*) min0; 414 btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*) min1; 415 if (polyhedronA->getConvexPolyhedron() && polyhedronB->getConvexPolyhedron()) 416 { 417 418 419 gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw); 420 421 422 btScalar threshold = m_manifoldPtr->getContactBreakingThreshold(); 423 424 btScalar minDist = 0.f; 425 btVector3 sepNormalWorldSpace; 426 bool foundSepAxis = true; 427 428 if (dispatchInfo.m_enableSatConvex) 429 { 430 foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis( 431 *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(), 432 body0->getWorldTransform(), 433 body1->getWorldTransform(), 434 sepNormalWorldSpace); 435 } else 436 { 437 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized(); 438 minDist = gjkPairDetector.getCachedSeparatingDistance(); 439 } 440 if (foundSepAxis) 441 { 442 // printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ()); 443 444 btPolyhedralContactClipping::clipHullAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(), 445 body0->getWorldTransform(), 446 body1->getWorldTransform(), minDist-threshold, threshold, *resultOut); 447 448 } 449 if (m_ownManifold) 450 { 451 resultOut->refreshContactPoints(); 452 } 453 return; 454 455 } else 456 { 457 //we can also deal with convex versus triangle (without connectivity data) 458 if (polyhedronA->getConvexPolyhedron() && polyhedronB->getShapeType()==TRIANGLE_SHAPE_PROXYTYPE) 459 { 460 gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw); 461 462 btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized(); 463 464 btVertexArray vertices; 465 btTriangleShape* tri = (btTriangleShape*)polyhedronB; 466 vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[0]); 467 vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[1]); 468 vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[2]); 469 470 btScalar threshold = m_manifoldPtr->getContactBreakingThreshold(); 471 btScalar minDist = gjkPairDetector.getCachedSeparatingDistance(); 472 btPolyhedralContactClipping::clipFaceAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), 473 body0->getWorldTransform(), vertices, minDist-threshold, threshold, *resultOut); 474 475 476 if (m_ownManifold) 477 { 478 resultOut->refreshContactPoints(); 479 } 480 481 return; 482 } 483 484 } 485 486 487 } 488 489 gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); 391 490 392 491 //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
Note: See TracChangeset
for help on using the changeset viewer.