- Timestamp:
- May 3, 2011, 5:07:42 AM (14 years ago)
- Location:
- code/trunk/src/external/bullet/BulletCollision/CollisionDispatch
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp
r8351 r8393 58 58 } 59 59 60 #define MAX_OVERLAP btScalar(0.)61 62 60 63 61 … … 94 92 } 95 93 96 ///combined discrete/continuous sphere-triangle97 94 bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold) 98 95 { 99 96 100 97 const btVector3* vertices = &m_triangle->getVertexPtr(0); 101 const btVector3& c = sphereCenter; 102 btScalar r = m_sphere->getRadius(); 103 104 btVector3 delta (0,0,0); 98 99 btScalar radius = m_sphere->getRadius(); 100 btScalar radiusWithThreshold = radius + contactBreakingThreshold; 105 101 106 102 btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]); 107 103 normal.normalize(); 108 btVector3 p1ToCentre = c- vertices[0];104 btVector3 p1ToCentre = sphereCenter - vertices[0]; 109 105 btScalar distanceFromPlane = p1ToCentre.dot(normal); 110 106 … … 112 108 { 113 109 //triangle facing the other way 114 115 110 distanceFromPlane *= btScalar(-1.); 116 111 normal *= btScalar(-1.); 117 112 } 118 113 119 btScalar contactMargin = contactBreakingThreshold; 120 bool isInsideContactPlane = distanceFromPlane < r + contactMargin; 121 bool isInsideShellPlane = distanceFromPlane < r; 122 123 btScalar deltaDotNormal = delta.dot(normal); 124 if (!isInsideShellPlane && deltaDotNormal >= btScalar(0.0)) 125 return false; 126 114 bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold; 115 127 116 // Check for contact / intersection 128 117 bool hasContact = false; 129 118 btVector3 contactPoint; 130 119 if (isInsideContactPlane) { 131 if (facecontains( c,vertices,normal)) {120 if (facecontains(sphereCenter,vertices,normal)) { 132 121 // Inside the contact wedge - touches a point on the shell plane 133 122 hasContact = true; 134 contactPoint = c- normal*distanceFromPlane;123 contactPoint = sphereCenter - normal*distanceFromPlane; 135 124 } else { 136 125 // Could be inside one of the contact capsules 137 btScalar contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin);126 btScalar contactCapsuleRadiusSqr = radiusWithThreshold*radiusWithThreshold; 138 127 btVector3 nearestOnEdge; 139 128 for (int i = 0; i < m_triangle->getNumEdges(); i++) { … … 144 133 m_triangle->getEdge(i,pa,pb); 145 134 146 btScalar distanceSqr = SegmentSqrDistance(pa,pb, c, nearestOnEdge);135 btScalar distanceSqr = SegmentSqrDistance(pa,pb,sphereCenter, nearestOnEdge); 147 136 if (distanceSqr < contactCapsuleRadiusSqr) { 148 137 // Yep, we're inside a capsule … … 156 145 157 146 if (hasContact) { 158 btVector3 contactToCentre = c- contactPoint;147 btVector3 contactToCentre = sphereCenter - contactPoint; 159 148 btScalar distanceSqr = contactToCentre.length2(); 160 if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) { 161 btScalar distance = btSqrt(distanceSqr); 162 resultNormal = contactToCentre; 163 resultNormal.normalize(); 164 point = contactPoint; 165 depth = -(r-distance); 149 150 if (distanceSqr < radiusWithThreshold*radiusWithThreshold) 151 { 152 if (distanceSqr>SIMD_EPSILON) 153 { 154 btScalar distance = btSqrt(distanceSqr); 155 resultNormal = contactToCentre; 156 resultNormal.normalize(); 157 point = contactPoint; 158 depth = -(radius-distance); 159 } else 160 { 161 btScalar distance = 0.f; 162 resultNormal = normal; 163 point = contactPoint; 164 depth = -radius; 165 } 166 166 return true; 167 167 } 168 169 if (delta.dot(contactToCentre) >= btScalar(0.0))170 return false;171 172 // Moving towards the contact point -> collision173 point = contactPoint;174 timeOfImpact = btScalar(0.0);175 return true;176 168 } 177 169 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h
r8351 r8393 14 14 */ 15 15 16 #ifndef SPHERE_TRIANGLE_DETECTOR_H17 #define SPHERE_TRIANGLE_DETECTOR_H16 #ifndef BT_SPHERE_TRIANGLE_DETECTOR_H 17 #define BT_SPHERE_TRIANGLE_DETECTOR_H 18 18 19 19 #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" … … 48 48 49 49 }; 50 #endif // SPHERE_TRIANGLE_DETECTOR_H50 #endif //BT_SPHERE_TRIANGLE_DETECTOR_H 51 51 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B OX_2D_BOX_2D__COLLISION_ALGORITHM_H17 #define B OX_2D_BOX_2D__COLLISION_ALGORITHM_H16 #ifndef BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H 17 #define BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H 18 18 19 19 #include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" … … 63 63 }; 64 64 65 #endif //B OX_2D_BOX_2D__COLLISION_ALGORITHM_H65 #endif //BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H 66 66 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef B OX_BOX__COLLISION_ALGORITHM_H17 #define B OX_BOX__COLLISION_ALGORITHM_H16 #ifndef BT_BOX_BOX__COLLISION_ALGORITHM_H 17 #define BT_BOX_BOX__COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 63 63 }; 64 64 65 #endif //B OX_BOX__COLLISION_ALGORITHM_H65 #endif //BT_BOX_BOX__COLLISION_ALGORITHM_H 66 66 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.h
r5781 r8393 17 17 3. This notice may not be removed or altered from any source distribution. 18 18 */ 19 #ifndef B OX_BOX_DETECTOR_H20 #define B OX_BOX_DETECTOR_H19 #ifndef BT_BOX_BOX_DETECTOR_H 20 #define BT_BOX_BOX_DETECTOR_H 21 21 22 22 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
r5781 r8393 16 16 #ifndef BT_COLLISION_CONFIGURATION 17 17 #define BT_COLLISION_CONFIGURATION 18 18 19 struct btCollisionAlgorithmCreateFunc; 19 20 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
r5781 r8393 14 14 */ 15 15 16 #ifndef COLLISION_CREATE_FUNC17 #define COLLISION_CREATE_FUNC16 #ifndef BT_COLLISION_CREATE_FUNC 17 #define BT_COLLISION_CREATE_FUNC 18 18 19 19 #include "LinearMath/btAlignedObjectArray.h" … … 42 42 } 43 43 }; 44 #endif // COLLISION_CREATE_FUNC44 #endif //BT_COLLISION_CREATE_FUNC 45 45 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
r8351 r8393 93 93 } else 94 94 { 95 mem = btAlignedAlloc(sizeof(btPersistentManifold),16); 96 95 //we got a pool memory overflow, by default we fallback to dynamically allocate memory. If we require a contiguous contact pool then assert. 96 if ((m_dispatcherFlags&CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION)==0) 97 { 98 mem = btAlignedAlloc(sizeof(btPersistentManifold),16); 99 } else 100 { 101 btAssert(0); 102 //make sure to increase the m_defaultMaxPersistentManifoldPoolSize in the btDefaultCollisionConstructionInfo/btDefaultCollisionConfiguration 103 return 0; 104 } 97 105 } 98 106 btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold); … … 173 181 { 174 182 //broadphase filtering already deals with this 175 if ((body0->isStaticObject() || body0->isKinematicObject()) && 176 (body1->isStaticObject() || body1->isKinematicObject())) 183 if (body0->isStaticOrKinematicObject() && body1->isStaticOrKinematicObject()) 177 184 { 178 185 m_dispatcherFlags |= btCollisionDispatcher::CD_STATIC_STATIC_REPORTED; -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION__DISPATCHER_H17 #define COLLISION__DISPATCHER_H16 #ifndef BT_COLLISION__DISPATCHER_H 17 #define BT_COLLISION__DISPATCHER_H 18 18 19 19 #include "BulletCollision/BroadphaseCollision/btDispatcher.h" … … 43 43 class btCollisionDispatcher : public btDispatcher 44 44 { 45 46 protected: 47 45 48 int m_dispatcherFlags; 46 49 47 50 btAlignedObjectArray<btPersistentManifold*> m_manifoldsPtr; 48 51 … … 65 68 { 66 69 CD_STATIC_STATIC_REPORTED = 1, 67 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2 70 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2, 71 CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4 68 72 }; 69 73 … … 75 79 void setDispatcherFlags(int flags) 76 80 { 77 (void) flags; 78 m_dispatcherFlags = 0; 81 m_dispatcherFlags = flags; 79 82 } 80 83 … … 154 157 } 155 158 159 virtual btPoolAllocator* getInternalManifoldPool() 160 { 161 return m_persistentManifoldPoolAllocator; 162 } 163 164 virtual const btPoolAllocator* getInternalManifoldPool() const 165 { 166 return m_persistentManifoldPoolAllocator; 167 } 168 156 169 }; 157 170 158 #endif // COLLISION__DISPATCHER_H171 #endif //BT_COLLISION__DISPATCHER_H 159 172 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION_OBJECT_H17 #define COLLISION_OBJECT_H16 #ifndef BT_COLLISION_OBJECT_H 17 #define BT_COLLISION_OBJECT_H 18 18 19 19 #include "LinearMath/btTransform.h" … … 522 522 523 523 524 #endif // COLLISION_OBJECT_H524 #endif //BT_COLLISION_OBJECT_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
r8351 r8393 29 29 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" 30 30 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" 31 #include "BulletCollision/BroadphaseCollision/btDbvt.h" 31 32 #include "LinearMath/btAabbUtil2.h" 32 33 #include "LinearMath/btQuickprof.h" 33 34 #include "LinearMath/btStackAlloc.h" 34 35 #include "LinearMath/btSerializer.h" 36 #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h" 37 38 //#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION 39 35 40 36 41 //#define USE_BRUTEFORCE_RAYBROADPHASE 1 … … 151 156 maxAabb += contactThreshold; 152 157 158 if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY) 159 { 160 btVector3 minAabb2,maxAabb2; 161 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2); 162 minAabb2 -= contactThreshold; 163 maxAabb2 += contactThreshold; 164 minAabb.setMin(minAabb2); 165 maxAabb.setMax(maxAabb2); 166 } 167 153 168 btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache; 154 169 … … 421 436 } else { 422 437 // BT_PROFILE("rayTestCompound"); 423 ///@todo: use AABB tree or other BVH acceleration structure, see btDbvt424 438 if (collisionShape->isCompound()) 425 439 { 440 struct LocalInfoAdder2 : public RayResultCallback 441 { 442 RayResultCallback* m_userCallback; 443 int m_i; 444 445 LocalInfoAdder2 (int i, RayResultCallback *user) 446 : m_userCallback(user), m_i(i) 447 { 448 m_closestHitFraction = m_userCallback->m_closestHitFraction; 449 } 450 virtual bool needsCollision(btBroadphaseProxy* p) const 451 { 452 return m_userCallback->needsCollision(p); 453 } 454 455 virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b) 456 { 457 btCollisionWorld::LocalShapeInfo shapeInfo; 458 shapeInfo.m_shapePart = -1; 459 shapeInfo.m_triangleIndex = m_i; 460 if (r.m_localShapeInfo == NULL) 461 r.m_localShapeInfo = &shapeInfo; 462 463 const btScalar result = m_userCallback->addSingleResult(r, b); 464 m_closestHitFraction = m_userCallback->m_closestHitFraction; 465 return result; 466 } 467 }; 468 469 struct RayTester : btDbvt::ICollide 470 { 471 btCollisionObject* m_collisionObject; 472 const btCompoundShape* m_compoundShape; 473 const btTransform& m_colObjWorldTransform; 474 const btTransform& m_rayFromTrans; 475 const btTransform& m_rayToTrans; 476 RayResultCallback& m_resultCallback; 477 478 RayTester(btCollisionObject* collisionObject, 479 const btCompoundShape* compoundShape, 480 const btTransform& colObjWorldTransform, 481 const btTransform& rayFromTrans, 482 const btTransform& rayToTrans, 483 RayResultCallback& resultCallback): 484 m_collisionObject(collisionObject), 485 m_compoundShape(compoundShape), 486 m_colObjWorldTransform(colObjWorldTransform), 487 m_rayFromTrans(rayFromTrans), 488 m_rayToTrans(rayToTrans), 489 m_resultCallback(resultCallback) 490 { 491 492 } 493 494 void Process(int i) 495 { 496 const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i); 497 const btTransform& childTrans = m_compoundShape->getChildTransform(i); 498 btTransform childWorldTrans = m_colObjWorldTransform * childTrans; 499 500 // replace collision shape so that callback can determine the triangle 501 btCollisionShape* saveCollisionShape = m_collisionObject->getCollisionShape(); 502 m_collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape); 503 504 LocalInfoAdder2 my_cb(i, &m_resultCallback); 505 506 rayTestSingle( 507 m_rayFromTrans, 508 m_rayToTrans, 509 m_collisionObject, 510 childCollisionShape, 511 childWorldTrans, 512 my_cb); 513 514 // restore 515 m_collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape); 516 } 517 518 void Process(const btDbvtNode* leaf) 519 { 520 Process(leaf->dataAsInt); 521 } 522 }; 523 426 524 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape); 427 int i=0; 428 for (i=0;i<compoundShape->getNumChildShapes();i++) 429 { 430 btTransform childTrans = compoundShape->getChildTransform(i); 431 const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); 432 btTransform childWorldTrans = colObjWorldTransform * childTrans; 433 // replace collision shape so that callback can determine the triangle 434 btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); 435 collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape); 436 struct LocalInfoAdder2 : public RayResultCallback { 437 RayResultCallback* m_userCallback; 438 int m_i; 439 LocalInfoAdder2 (int i, RayResultCallback *user) 440 : m_userCallback(user), 441 m_i(i) 442 { 443 m_closestHitFraction = m_userCallback->m_closestHitFraction; 444 } 445 virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b) 446 { 447 btCollisionWorld::LocalShapeInfo shapeInfo; 448 shapeInfo.m_shapePart = -1; 449 shapeInfo.m_triangleIndex = m_i; 450 if (r.m_localShapeInfo == NULL) 451 r.m_localShapeInfo = &shapeInfo; 452 453 const btScalar result = m_userCallback->addSingleResult(r, b); 454 m_closestHitFraction = m_userCallback->m_closestHitFraction; 455 return result; 456 } 457 }; 458 459 LocalInfoAdder2 my_cb(i, &resultCallback); 460 461 rayTestSingle(rayFromTrans,rayToTrans, 462 collisionObject, 463 childCollisionShape, 464 childWorldTrans, 465 my_cb); 466 // restore 467 collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape); 525 const btDbvt* dbvt = compoundShape->getDynamicAabbTree(); 526 527 528 RayTester rayCB( 529 collisionObject, 530 compoundShape, 531 colObjWorldTransform, 532 rayFromTrans, 533 rayToTrans, 534 resultCallback); 535 #ifndef DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION 536 if (dbvt) 537 { 538 btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).getOrigin(); 539 btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).getOrigin(); 540 btDbvt::rayTest(dbvt->m_root, localRayFrom , localRayTo, rayCB); 541 } 542 else 543 #endif //DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION 544 { 545 for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i) 546 { 547 rayCB.Process(i); 548 } 468 549 } 469 550 } … … 577 658 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform); 578 659 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 660 tccb.m_allowedPenetration = allowedPenetration; 579 661 btVector3 boxMinLocal, boxMaxLocal; 580 662 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); … … 582 664 } else 583 665 { 584 //BT_PROFILE("convexSweepConcave"); 585 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; 586 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); 587 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); 588 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin(); 589 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation 590 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis()); 591 592 //ConvexCast::CastResult 593 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback 594 { 595 btCollisionWorld::ConvexResultCallback* m_resultCallback; 596 btCollisionObject* m_collisionObject; 597 btConcaveShape* m_triangleMesh; 598 599 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, 600 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld): 601 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), 602 m_resultCallback(resultCallback), 603 m_collisionObject(collisionObject), 604 m_triangleMesh(triangleMesh) 605 { 666 if (collisionShape->getShapeType()==STATIC_PLANE_PROXYTYPE) 667 { 668 btConvexCast::CastResult castResult; 669 castResult.m_allowedPenetration = allowedPenetration; 670 castResult.m_fraction = resultCallback.m_closestHitFraction; 671 btStaticPlaneShape* planeShape = (btStaticPlaneShape*) collisionShape; 672 btContinuousConvexCollision convexCaster1(castShape,planeShape); 673 btConvexCast* castPtr = &convexCaster1; 674 675 if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult)) 676 { 677 //add hit 678 if (castResult.m_normal.length2() > btScalar(0.0001)) 679 { 680 if (castResult.m_fraction < resultCallback.m_closestHitFraction) 681 { 682 castResult.m_normal.normalize(); 683 btCollisionWorld::LocalConvexResult localConvexResult 684 ( 685 collisionObject, 686 0, 687 castResult.m_normal, 688 castResult.m_hitPoint, 689 castResult.m_fraction 690 ); 691 692 bool normalInWorldSpace = true; 693 resultCallback.addSingleResult(localConvexResult, normalInWorldSpace); 694 } 695 } 606 696 } 607 697 608 609 virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex ) 610 { 611 btCollisionWorld::LocalShapeInfo shapeInfo; 612 shapeInfo.m_shapePart = partId; 613 shapeInfo.m_triangleIndex = triangleIndex; 614 if (hitFraction <= m_resultCallback->m_closestHitFraction) 698 } else 699 { 700 //BT_PROFILE("convexSweepConcave"); 701 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; 702 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); 703 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); 704 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin(); 705 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation 706 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis()); 707 708 //ConvexCast::CastResult 709 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback 710 { 711 btCollisionWorld::ConvexResultCallback* m_resultCallback; 712 btCollisionObject* m_collisionObject; 713 btConcaveShape* m_triangleMesh; 714 715 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, 716 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld): 717 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), 718 m_resultCallback(resultCallback), 719 m_collisionObject(collisionObject), 720 m_triangleMesh(triangleMesh) 615 721 { 616 617 btCollisionWorld::LocalConvexResult convexResult618 (m_collisionObject,619 &shapeInfo,620 hitNormalLocal,621 hitPointLocal,622 hitFraction);623 624 bool normalInWorldSpace = false;625 626 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);627 722 } 628 return hitFraction; 629 } 630 631 }; 632 633 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); 634 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 635 btVector3 boxMinLocal, boxMaxLocal; 636 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); 637 638 btVector3 rayAabbMinLocal = convexFromLocal; 639 rayAabbMinLocal.setMin(convexToLocal); 640 btVector3 rayAabbMaxLocal = convexFromLocal; 641 rayAabbMaxLocal.setMax(convexToLocal); 642 rayAabbMinLocal += boxMinLocal; 643 rayAabbMaxLocal += boxMaxLocal; 644 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal); 723 724 725 virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex ) 726 { 727 btCollisionWorld::LocalShapeInfo shapeInfo; 728 shapeInfo.m_shapePart = partId; 729 shapeInfo.m_triangleIndex = triangleIndex; 730 if (hitFraction <= m_resultCallback->m_closestHitFraction) 731 { 732 733 btCollisionWorld::LocalConvexResult convexResult 734 (m_collisionObject, 735 &shapeInfo, 736 hitNormalLocal, 737 hitPointLocal, 738 hitFraction); 739 740 bool normalInWorldSpace = false; 741 742 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace); 743 } 744 return hitFraction; 745 } 746 747 }; 748 749 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); 750 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 751 tccb.m_allowedPenetration = allowedPenetration; 752 btVector3 boxMinLocal, boxMaxLocal; 753 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); 754 755 btVector3 rayAabbMinLocal = convexFromLocal; 756 rayAabbMinLocal.setMin(convexToLocal); 757 btVector3 rayAabbMaxLocal = convexFromLocal; 758 rayAabbMaxLocal.setMax(convexToLocal); 759 rayAabbMinLocal += boxMinLocal; 760 rayAabbMaxLocal += boxMaxLocal; 761 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal); 762 } 645 763 } 646 764 } else { … … 667 785 { 668 786 m_closestHitFraction = m_userCallback->m_closestHitFraction; 787 } 788 virtual bool needsCollision(btBroadphaseProxy* p) const 789 { 790 return m_userCallback->needsCollision(p); 669 791 } 670 792 virtual btScalar addSingleResult (btCollisionWorld::LocalConvexResult& r, bool b) … … 1152 1274 1153 1275 int upAxis = capsuleShape->getUpAxis(); 1154 1155 1156 btVector3 capStart(0.f,0.f,0.f); 1157 capStart[upAxis] = -halfHeight; 1158 1159 btVector3 capEnd(0.f,0.f,0.f); 1160 capEnd[upAxis] = halfHeight; 1161 1162 // Draw the ends 1163 { 1164 1165 btTransform childTransform = worldTransform; 1166 childTransform.getOrigin() = worldTransform * capStart; 1167 getDebugDrawer()->drawSphere(radius, childTransform, color); 1168 } 1169 1170 { 1171 btTransform childTransform = worldTransform; 1172 childTransform.getOrigin() = worldTransform * capEnd; 1173 getDebugDrawer()->drawSphere(radius, childTransform, color); 1174 } 1175 1176 // Draw some additional lines 1177 btVector3 start = worldTransform.getOrigin(); 1178 1179 1180 capStart[(upAxis+1)%3] = radius; 1181 capEnd[(upAxis+1)%3] = radius; 1182 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1183 capStart[(upAxis+1)%3] = -radius; 1184 capEnd[(upAxis+1)%3] = -radius; 1185 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1186 1187 capStart[(upAxis+1)%3] = 0.f; 1188 capEnd[(upAxis+1)%3] = 0.f; 1189 1190 capStart[(upAxis+2)%3] = radius; 1191 capEnd[(upAxis+2)%3] = radius; 1192 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1193 capStart[(upAxis+2)%3] = -radius; 1194 capEnd[(upAxis+2)%3] = -radius; 1195 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1196 1197 1276 getDebugDrawer()->drawCapsule(radius, halfHeight, upAxis, worldTransform, color); 1198 1277 break; 1199 1278 } … … 1203 1282 btScalar radius = coneShape->getRadius();//+coneShape->getMargin(); 1204 1283 btScalar height = coneShape->getHeight();//+coneShape->getMargin(); 1205 btVector3 start = worldTransform.getOrigin();1206 1284 1207 1285 int upAxis= coneShape->getConeUpIndex(); 1208 1209 1210 btVector3 offsetHeight(0,0,0); 1211 offsetHeight[upAxis] = height * btScalar(0.5); 1212 btVector3 offsetRadius(0,0,0); 1213 offsetRadius[(upAxis+1)%3] = radius; 1214 btVector3 offset2Radius(0,0,0); 1215 offset2Radius[(upAxis+2)%3] = radius; 1216 1217 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); 1218 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); 1219 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color); 1220 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color); 1221 1222 // Drawing the base of the cone 1223 btVector3 yaxis(0,0,0); 1224 yaxis[upAxis] = btScalar(1.0); 1225 btVector3 xaxis(0,0,0); 1226 xaxis[(upAxis+1)%3] = btScalar(1.0); 1227 getDebugDrawer()->drawArc(start-worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,10.0); 1228 break; 1286 getDebugDrawer()->drawCone(radius, height, upAxis, worldTransform, color); 1287 break; 1229 1288 1230 1289 } … … 1235 1294 btScalar radius = cylinder->getRadius(); 1236 1295 btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis]; 1237 btVector3 start = worldTransform.getOrigin(); 1238 btVector3 offsetHeight(0,0,0); 1239 offsetHeight[upAxis] = halfHeight; 1240 btVector3 offsetRadius(0,0,0); 1241 offsetRadius[(upAxis+1)%3] = radius; 1242 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight+offsetRadius),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); 1243 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight-offsetRadius),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); 1244 1245 // Drawing top and bottom caps of the cylinder 1246 btVector3 yaxis(0,0,0); 1247 yaxis[upAxis] = btScalar(1.0); 1248 btVector3 xaxis(0,0,0); 1249 xaxis[(upAxis+1)%3] = btScalar(1.0); 1250 getDebugDrawer()->drawArc(start-worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,btScalar(10.0)); 1251 getDebugDrawer()->drawArc(start+worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,btScalar(10.0)); 1296 getDebugDrawer()->drawCylinder(radius, halfHeight, upAxis, worldTransform, color); 1252 1297 break; 1253 1298 } … … 1258 1303 btScalar planeConst = staticPlaneShape->getPlaneConstant(); 1259 1304 const btVector3& planeNormal = staticPlaneShape->getPlaneNormal(); 1260 btVector3 planeOrigin = planeNormal * planeConst; 1261 btVector3 vec0,vec1; 1262 btPlaneSpace1(planeNormal,vec0,vec1); 1263 btScalar vecLen = 100.f; 1264 btVector3 pt0 = planeOrigin + vec0*vecLen; 1265 btVector3 pt1 = planeOrigin - vec0*vecLen; 1266 btVector3 pt2 = planeOrigin + vec1*vecLen; 1267 btVector3 pt3 = planeOrigin - vec1*vecLen; 1268 getDebugDrawer()->drawLine(worldTransform*pt0,worldTransform*pt1,color); 1269 getDebugDrawer()->drawLine(worldTransform*pt2,worldTransform*pt3,color); 1305 getDebugDrawer()->drawPlane(planeNormal, planeConst,worldTransform, color); 1270 1306 break; 1271 1307 … … 1305 1341 1306 1342 int i; 1307 for (i=0;i<polyshape->getNumEdges();i++) 1308 { 1309 btVector3 a,b; 1310 polyshape->getEdge(i,a,b); 1311 btVector3 wa = worldTransform * a; 1312 btVector3 wb = worldTransform * b; 1313 getDebugDrawer()->drawLine(wa,wb,color); 1314 1343 if (polyshape->getConvexPolyhedron()) 1344 { 1345 const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron(); 1346 for (i=0;i<poly->m_faces.size();i++) 1347 { 1348 btVector3 centroid(0,0,0); 1349 int numVerts = poly->m_faces[i].m_indices.size(); 1350 if (numVerts) 1351 { 1352 int lastV = poly->m_faces[i].m_indices[numVerts-1]; 1353 for (int v=0;v<poly->m_faces[i].m_indices.size();v++) 1354 { 1355 int curVert = poly->m_faces[i].m_indices[v]; 1356 centroid+=poly->m_vertices[curVert]; 1357 getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color); 1358 lastV = curVert; 1359 } 1360 } 1361 centroid*= 1./btScalar(numVerts); 1362 1363 btVector3 normalColor(1,1,0); 1364 btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]); 1365 getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor); 1366 1367 1368 } 1369 1370 1371 } else 1372 { 1373 for (i=0;i<polyshape->getNumEdges();i++) 1374 { 1375 btVector3 a,b; 1376 polyshape->getEdge(i,a,b); 1377 btVector3 wa = worldTransform * a; 1378 btVector3 wb = worldTransform * b; 1379 getDebugDrawer()->drawLine(wa,wb,color); 1380 } 1315 1381 } 1316 1382 … … 1381 1447 btVector3 colorvec(1,0,0); 1382 1448 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); 1449 btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold); 1450 minAabb -= contactThreshold; 1451 maxAabb += contactThreshold; 1452 1453 btVector3 minAabb2,maxAabb2; 1454 1455 if(colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY) 1456 { 1457 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2); 1458 minAabb2 -= contactThreshold; 1459 maxAabb2 += contactThreshold; 1460 minAabb.setMin(minAabb2); 1461 maxAabb.setMax(maxAabb2); 1462 } 1463 1383 1464 m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec); 1384 1465 } -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
r8351 r8393 63 63 64 64 65 #ifndef COLLISION_WORLD_H66 #define COLLISION_WORLD_H65 #ifndef BT_COLLISION_WORLD_H 66 #define BT_COLLISION_WORLD_H 67 67 68 68 class btStackAlloc; … … 507 507 508 508 509 #endif // COLLISION_WORLD_H509 #endif //BT_COLLISION_WORLD_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
r8351 r8393 235 235 } 236 236 } 237 manifoldArray. clear();237 manifoldArray.resize(0); 238 238 } 239 239 } -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef COMPOUND_COLLISION_ALGORITHM_H17 #define COMPOUND_COLLISION_ALGORITHM_H16 #ifndef BT_COMPOUND_COLLISION_ALGORITHM_H 17 #define BT_COMPOUND_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 84 84 }; 85 85 86 #endif // COMPOUND_COLLISION_ALGORITHM_H86 #endif //BT_COMPOUND_COLLISION_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_2D_CONVEX_2D_ALGORITHM_H17 #define CONVEX_2D_CONVEX_2D_ALGORITHM_H16 #ifndef BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H 17 #define BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H 18 18 19 19 #include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" … … 93 93 }; 94 94 95 #endif // CONVEX_2D_CONVEX_2D_ALGORITHM_H95 #endif //BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
r8351 r8393 92 92 93 93 94 94 #if 0 95 95 ///debug drawing of the overlapping triangles 96 96 if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe )) … … 101 101 m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color); 102 102 m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color); 103 104 //btVector3 center = triangle[0] + triangle[1]+triangle[2]; 105 //center *= btScalar(0.333333); 106 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color); 107 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color); 108 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color); 109 110 } 111 112 113 //btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject); 103 } 104 #endif 114 105 115 106 if (m_convexBody->getCollisionShape()->isConvex()) … … 120 111 btCollisionShape* tmpShape = ob->getCollisionShape(); 121 112 ob->internalSetTemporaryCollisionShape( &tm ); 122 113 123 114 btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr); 124 115 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef CONVEX_CONCAVE_COLLISION_ALGORITHM_H17 #define CONVEX_CONCAVE_COLLISION_ALGORITHM_H16 #ifndef BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H 17 #define BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 114 114 }; 115 115 116 #endif // CONVEX_CONCAVE_COLLISION_ALGORITHM_H116 #endif //BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H -
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 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_CONVEX_ALGORITHM_H17 #define CONVEX_CONVEX_ALGORITHM_H16 #ifndef BT_CONVEX_CONVEX_ALGORITHM_H 17 #define BT_CONVEX_CONVEX_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 107 107 }; 108 108 109 #endif // CONVEX_CONVEX_ALGORITHM_H109 #endif //BT_CONVEX_CONVEX_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_PLANE_COLLISION_ALGORITHM_H17 #define CONVEX_PLANE_COLLISION_ALGORITHM_H16 #ifndef BT_CONVEX_PLANE_COLLISION_ALGORITHM_H 17 #define BT_CONVEX_PLANE_COLLISION_ALGORITHM_H 18 18 19 19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" … … 81 81 }; 82 82 83 #endif // CONVEX_PLANE_COLLISION_ALGORITHM_H83 #endif //BT_CONVEX_PLANE_COLLISION_ALGORITHM_H 84 84 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef EMPTY_ALGORITH17 #define EMPTY_ALGORITH16 #ifndef BT_EMPTY_ALGORITH 17 #define BT_EMPTY_ALGORITH 18 18 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" 19 19 #include "btCollisionCreateFunc.h" … … 52 52 } ATTRIBUTE_ALIGNED(16); 53 53 54 #endif // EMPTY_ALGORITH54 #endif //BT_EMPTY_ALGORITH -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp
r8351 r8393 2 2 3 3 #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" 4 #include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h" 4 5 #include "BulletCollision/CollisionShapes/btTriangleShape.h" 5 6 #include "BulletCollision/CollisionDispatch/btCollisionObject.h" … … 9 10 10 11 //#define DEBUG_INTERNAL_EDGE 11 12 12 13 13 #ifdef DEBUG_INTERNAL_EDGE … … 457 457 return; 458 458 459 btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape(); 460 btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap(); 459 btBvhTriangleMeshShape* trimesh = 0; 460 461 if( colObj0->getRootCollisionShape()->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE ) 462 trimesh = ((btScaledBvhTriangleMeshShape*)colObj0->getRootCollisionShape())->getChildShape(); 463 else 464 trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape(); 465 466 btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap(); 461 467 if (!triangleInfoMapPtr) 462 468 return; … … 502 508 btVector3 localContactNormalOnB = colObj0->getWorldTransform().getBasis().transpose() * cp.m_normalWorldOnB; 503 509 localContactNormalOnB.normalize();//is this necessary? 504 505 if ((info->m_edgeV0V1Angle)< SIMD_2_PI) 510 511 // Get closest edge 512 int bestedge=-1; 513 float disttobestedge=BT_LARGE_FLOAT; 514 // 515 // Edge 0 -> 1 516 if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 517 { 518 btVector3 nearest; 519 btNearestPointInLineSegment( cp.m_localPointB, v0, v1, nearest ); 520 float len=(contact-nearest).length(); 521 // 522 if( len < disttobestedge ) 523 { 524 bestedge=0; 525 disttobestedge=len; 526 } 527 } 528 // Edge 1 -> 2 529 if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 530 { 531 btVector3 nearest; 532 btNearestPointInLineSegment( cp.m_localPointB, v1, v2, nearest ); 533 float len=(contact-nearest).length(); 534 // 535 if( len < disttobestedge ) 536 { 537 bestedge=1; 538 disttobestedge=len; 539 } 540 } 541 // Edge 2 -> 0 542 if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 543 { 544 btVector3 nearest; 545 btNearestPointInLineSegment( cp.m_localPointB, v2, v0, nearest ); 546 float len=(contact-nearest).length(); 547 // 548 if( len < disttobestedge ) 549 { 550 bestedge=2; 551 disttobestedge=len; 552 } 553 } 554 555 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW 556 btVector3 upfix=tri_normal * btVector3(0.1f,0.1f,0.1f); 557 btDebugDrawLine(tr * v0 + upfix, tr * v1 + upfix, red ); 558 #endif 559 if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 506 560 { 507 561 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW … … 510 564 btScalar len = (contact-nearest).length(); 511 565 if(len<triangleInfoMapPtr->m_edgeDistanceThreshold) 566 if( bestedge==0 ) 512 567 { 513 568 btVector3 edge(v0-v1); … … 578 633 #endif //BT_INTERNAL_EDGE_DEBUG_DRAW 579 634 580 if ((info->m_edgeV1V2Angle)< SIMD_2_PI) 635 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW 636 btDebugDrawLine(tr * v1 + upfix, tr * v2 + upfix , green ); 637 #endif 638 639 if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 581 640 { 582 641 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW … … 588 647 btScalar len = (contact-nearest).length(); 589 648 if(len<triangleInfoMapPtr->m_edgeDistanceThreshold) 649 if( bestedge==1 ) 590 650 { 591 651 isNearEdge = true; … … 659 719 btDebugDrawLine(tr*nearest,tr*cp.m_localPointB,blue); 660 720 #endif //BT_INTERNAL_EDGE_DEBUG_DRAW 661 662 if ((info->m_edgeV2V0Angle)< SIMD_2_PI) 721 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW 722 btDebugDrawLine(tr * v2 + upfix, tr * v0 + upfix , blue ); 723 #endif 724 725 if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 663 726 { 664 727 … … 669 732 btScalar len = (contact-nearest).length(); 670 733 if(len<triangleInfoMapPtr->m_edgeDistanceThreshold) 734 if( bestedge==2 ) 671 735 { 672 736 isNearEdge = true; … … 760 824 } else 761 825 { 826 btVector3 newNormal = tri_normal *frontFacing; 827 //if the tri_normal is pointing opposite direction as the current local contact normal, skip it 828 btScalar d = newNormal.dot(localContactNormalOnB) ; 829 if (d< 0) 830 { 831 return; 832 } 762 833 //modify the normal to be the triangle normal (or backfacing normal) 763 cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *(tri_normal *frontFacing); 764 } 765 766 834 cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *newNormal; 835 } 836 767 837 // Reproject collision point along normal. 768 838 cp.m_positionWorldOnB = cp.m_positionWorldOnA - cp.m_normalWorldOnB * cp.m_distance1; -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp
r8351 r8393 64 64 btAssert(m_manifoldPtr); 65 65 //order in manifold needs to match 66 67 if (depth > m_manifoldPtr->getContactBreakingThreshold()) 66 67 // if (depth > m_manifoldPtr->getContactBreakingThreshold()) 68 if (depth > m_manifoldPtr->getContactProcessingThreshold()) 68 69 return; 69 70 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h
r8351 r8393 15 15 16 16 17 #ifndef MANIFOLD_RESULT_H18 #define MANIFOLD_RESULT_H17 #ifndef BT_MANIFOLD_RESULT_H 18 #define BT_MANIFOLD_RESULT_H 19 19 20 20 class btCollisionObject; … … 126 126 }; 127 127 128 #endif // MANIFOLD_RESULT_H128 #endif //BT_MANIFOLD_RESULT_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
r8351 r8393 393 393 394 394 395 bool islandSleeping = false;395 bool islandSleeping = true; 396 396 397 397 for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++) … … 400 400 btCollisionObject* colObj0 = collisionObjects[i]; 401 401 m_islandBodies.push_back(colObj0); 402 if ( !colObj0->isActive())403 islandSleeping = true;402 if (colObj0->isActive()) 403 islandSleeping = false; 404 404 } 405 405 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SIMULATION_ISLAND_MANAGER_H17 #define SIMULATION_ISLAND_MANAGER_H16 #ifndef BT_SIMULATION_ISLAND_MANAGER_H 17 #define BT_SIMULATION_ISLAND_MANAGER_H 18 18 19 19 #include "BulletCollision/CollisionDispatch/btUnionFind.h" … … 78 78 }; 79 79 80 #endif // SIMULATION_ISLAND_MANAGER_H80 #endif //BT_SIMULATION_ISLAND_MANAGER_H 81 81 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SPHERE_BOX_COLLISION_ALGORITHM_H17 #define SPHERE_BOX_COLLISION_ALGORITHM_H16 #ifndef BT_SPHERE_BOX_COLLISION_ALGORITHM_H 17 #define BT_SPHERE_BOX_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 72 72 }; 73 73 74 #endif // SPHERE_BOX_COLLISION_ALGORITHM_H74 #endif //BT_SPHERE_BOX_COLLISION_ALGORITHM_H 75 75 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SPHERE_SPHERE_COLLISION_ALGORITHM_H17 #define SPHERE_SPHERE_COLLISION_ALGORITHM_H16 #ifndef BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H 17 #define BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 63 63 }; 64 64 65 #endif // SPHERE_SPHERE_COLLISION_ALGORITHM_H65 #endif //BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H 66 66 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SPHERE_TRIANGLE_COLLISION_ALGORITHM_H17 #define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H16 #ifndef BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 17 #define BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 66 66 }; 67 67 68 #endif // SPHERE_TRIANGLE_COLLISION_ALGORITHM_H68 #endif //BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 69 69 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btUnionFind.h
r8351 r8393 14 14 */ 15 15 16 #ifndef UNION_FIND_H17 #define UNION_FIND_H16 #ifndef BT_UNION_FIND_H 17 #define BT_UNION_FIND_H 18 18 19 19 #include "LinearMath/btAlignedObjectArray.h" … … 127 127 128 128 129 #endif // UNION_FIND_H129 #endif //BT_UNION_FIND_H
Note: See TracChangeset
for help on using the changeset viewer.