279 m_ownManifold =
true;
290 btVector3 pointOnBWorld;
291#ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
296 btCapsuleShape* capsuleA = (btCapsuleShape*)min0;
297 btCapsuleShape* capsuleB = (btCapsuleShape*)min1;
302 capsuleB->getHalfHeight(), capsuleB->getRadius(), capsuleA->getUpAxis(), capsuleB->getUpAxis(),
305 if (dist < threshold)
318 btCapsuleShape* capsuleA = (btCapsuleShape*)min0;
324 0., capsuleB->getRadius(), capsuleA->getUpAxis(), 1,
327 if (dist < threshold)
341 btCapsuleShape* capsuleB = (btCapsuleShape*)min1;
346 capsuleB->getHalfHeight(), capsuleB->getRadius(), 1, capsuleB->getUpAxis(),
349 if (dist < threshold)
359#ifdef USE_SEPDISTANCE_UTIL2
362 m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(), body1->getWorldTransform());
376#ifdef USE_SEPDISTANCE_UTIL2
392 input.m_maximumDistanceSquared *= input.m_maximumDistanceSquared;
398#ifdef USE_SEPDISTANCE_UTIL2
411 if (min0->isPolyhedral() && min1->isPolyhedral())
415 btVector3 m_normalOnBInWorld;
416 btVector3 m_pointInWorld;
421 : m_hasContact(
false)
430 m_normalOnBInWorld = normalOnBInWorld;
431 m_pointInWorld = pointInWorld;
439 btVector3 m_reportedNormalOnWorld;
446 : m_originalResult(result),
447 m_marginOnA(marginOnA),
448 m_marginOnB(marginOnB),
455 virtual void addContactPoint(
const btVector3& normalOnBInWorld,
const btVector3& pointInWorldOrg,
btScalar depthOrg)
457 m_reportedDistance = depthOrg;
458 m_reportedNormalOnWorld = normalOnBInWorld;
460 btVector3 adjustedPointB = pointInWorldOrg - normalOnBInWorld * m_marginOnB;
461 m_reportedDistance = depthOrg + (m_marginOnA + m_marginOnB);
462 if (m_reportedDistance < 0.f)
464 m_foundResult =
true;
466 m_originalResult->
addContactPoint(normalOnBInWorld, adjustedPointB, m_reportedDistance);
477 btWithoutMarginResult withoutMargin(resultOut, min0Margin, min1Margin);
479 btPolyhedralConvexShape* polyhedronA = (btPolyhedralConvexShape*)min0;
480 btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*)min1;
481 if (polyhedronA->getConvexPolyhedron() && polyhedronB->getConvexPolyhedron())
486 btVector3 sepNormalWorldSpace;
487 bool foundSepAxis =
true;
492 *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
495 sepNormalWorldSpace, *resultOut);
510 sepNormalWorldSpace = withoutMargin.m_reportedNormalOnWorld;
512 minDist = withoutMargin.m_reportedDistance;
517 foundSepAxis = withoutMargin.m_foundResult && minDist < 0;
525 worldVertsB1.resize(0);
528 body1Wrap->
getWorldTransform(), minDist - threshold, threshold, worldVertsB1, worldVertsB2,
543 btTriangleShape* tri = (btTriangleShape*)polyhedronB;
552 btVector3 sepNormalWorldSpace;
556 bool foundSepAxis =
false;
557 bool useSatSepNormal =
true;
565 polyhedronB->initializePolyhedralFeatures();
569 btVector3 uniqueEdges[3] = {tri->m_vertices1[1] - tri->m_vertices1[0],
570 tri->m_vertices1[2] - tri->m_vertices1[1],
571 tri->m_vertices1[0] - tri->m_vertices1[2]};
573 uniqueEdges[0].normalize();
574 uniqueEdges[1].normalize();
575 uniqueEdges[2].normalize();
578 polyhedron.m_vertices.push_back(tri->m_vertices1[2]);
579 polyhedron.m_vertices.push_back(tri->m_vertices1[0]);
580 polyhedron.m_vertices.push_back(tri->m_vertices1[1]);
587 btVector3 faceNormal = uniqueEdges[0].cross(uniqueEdges[1]);
588 faceNormal.normalize();
598 combinedFaceA.
m_plane[0] = faceNormal[0];
599 combinedFaceA.
m_plane[1] = faceNormal[1];
600 combinedFaceA.
m_plane[2] = faceNormal[2];
601 combinedFaceA.
m_plane[3] = -planeEq;
602 polyhedron.m_faces.push_back(combinedFaceA);
609 btVector3 faceNormal = -uniqueEdges[0].cross(uniqueEdges[1]);
610 faceNormal.normalize();
621 combinedFaceB.
m_plane[0] = faceNormal[0];
622 combinedFaceB.
m_plane[1] = faceNormal[1];
623 combinedFaceB.
m_plane[2] = faceNormal[2];
624 combinedFaceB.
m_plane[3] = -planeEq;
625 polyhedron.m_faces.push_back(combinedFaceB);
628 polyhedron.m_uniqueEdges.push_back(uniqueEdges[0]);
629 polyhedron.m_uniqueEdges.push_back(uniqueEdges[1]);
630 polyhedron.m_uniqueEdges.push_back(uniqueEdges[2]);
631 polyhedron.initialize2();
633 polyhedronB->setPolyhedralFeatures(polyhedron);
637 *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
640 sepNormalWorldSpace, *resultOut);
652 if (dummy.m_hasContact && dummy.m_depth < 0)
656 if (dummy.m_normalOnBInWorld.dot(sepNormalWorldSpace) < 0.99)
665 sepNormalWorldSpace.setValue(0, 0, 1);
684 worldVertsB2.resize(0);
686 body0Wrap->
getWorldTransform(), worldSpaceVertices, worldVertsB2, minDist - threshold, maxDist, *resultOut);
704 if (m_numPerturbationIterations && resultOut->
getPersistentManifold()->getNumContacts() < m_minimumPointsPerturbationThreshold)
708 btVector3 sepNormalWorldSpace;
717 bool perturbeA =
true;
720 btScalar radiusA = min0->getAngularMotionDisc();
721 btScalar radiusB = min1->getAngularMotionDisc();
722 if (radiusA < radiusB)
732 if (perturbeAngle > angleLimit)
733 perturbeAngle = angleLimit;
738 unPerturbedTransform = input.m_transformA;
742 unPerturbedTransform = input.m_transformB;
745 for (i = 0; i < m_numPerturbationIterations; i++)
777#ifdef USE_SEPDISTANCE_UTIL2
780 m_sepDistance.initSeparatingDistance(gjkPairDetector.
getCachedSeparatingAxis(), sepDist, body0->getWorldTransform(), body1->getWorldTransform());
802 btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).
length2();
803 btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).
length2();
806 squareMot1 < col1->getCcdSquareMotionThreshold())
807 return resultFraction;
829 if (ccd1.
calcTimeOfImpact(col0->getWorldTransform(), col0->getInterpolationWorldTransform(),
830 col1->getWorldTransform(), col1->getInterpolationWorldTransform(), result))
834 if (col0->getHitFraction() > result.m_fraction)
835 col0->setHitFraction(result.m_fraction);
837 if (col1->getHitFraction() > result.m_fraction)
838 col1->setHitFraction(result.m_fraction);
840 if (resultFraction > result.m_fraction)
841 resultFraction = result.m_fraction;
856 if (ccd1.
calcTimeOfImpact(col0->getWorldTransform(), col0->getInterpolationWorldTransform(),
857 col1->getWorldTransform(), col1->getInterpolationWorldTransform(), result))
861 if (col0->getHitFraction() > result.m_fraction)
862 col0->setHitFraction(result.m_fraction);
864 if (col1->getHitFraction() > result.m_fraction)
865 col1->setHitFraction(result.m_fraction);
867 if (resultFraction > result.m_fraction)
868 resultFraction = result.m_fraction;
872 return resultFraction;