71 btScalar denom = 1.0f - dirA_dot_dirB * dirA_dot_dirB;
79 tA = (dirA_dot_trans - dirB_dot_trans * dirA_dot_dirB) / denom;
86 tB = tA * dirA_dot_dirB - dirB_dot_trans;
91 tA = tB * dirA_dot_dirB + dirA_dot_trans;
101 tA = tB * dirA_dot_dirB + dirA_dot_trans;
114 ptsVector = translation - offsetA + offsetB;
137 btVector3 translation = translationB - translationA;
147 directionA, capsuleLengthA, directionB, capsuleLengthB);
149 btScalar distance = ptsVector.
length() - capsuleRadiusA - capsuleRadiusB;
151 if (distance > distanceThreshold)
166 pointOnB = transformB.
getOrigin() + offsetB + normalOnB * capsuleRadiusB;
190#ifdef USE_SEPDISTANCE_UTIL2
191 m_sepDistance((static_cast<
btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
192 (static_cast<
btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
210void btConvexConvexAlgorithm ::setLowLevelOfDetail(
bool useLowLevel)
212 m_lowLevelOfDetail = useLowLevel;
245 btVector3 endPtOrg = pointInWorld + normalOnBInWorld * orgDepth;
247 newDepth = (endPt - pointInWorld).
dot(normalOnBInWorld);
248 startPt = endPt - normalOnBInWorld * newDepth;
252 endPt = pointInWorld + normalOnBInWorld * orgDepth;
254 newDepth = (endPt - startPt).
dot(normalOnBInWorld);
279 m_ownManifold =
true;
291#ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
305 if (dist < threshold)
327 if (dist < threshold)
349 if (dist < threshold)
359#ifdef USE_SEPDISTANCE_UTIL2
362 m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(), body1->getWorldTransform());
376#ifdef USE_SEPDISTANCE_UTIL2
398#ifdef USE_SEPDISTANCE_UTIL2
421 : m_hasContact(
false)
430 m_normalOnBInWorld = normalOnBInWorld;
431 m_pointInWorld = pointInWorld;
446 : m_originalResult(result),
447 m_marginOnA(marginOnA),
448 m_marginOnB(marginOnB),
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);
487 bool foundSepAxis =
true;
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,
556 bool foundSepAxis =
false;
557 bool useSatSepNormal =
true;
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;
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;
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);
717 bool perturbeA =
true;
722 if (radiusA < radiusB)
732 if (perturbeAngle > angleLimit)
733 perturbeAngle = angleLimit;
745 for (i = 0; i < m_numPerturbationIterations; i++)
777#ifdef USE_SEPDISTANCE_UTIL2
780 m_sepDistance.initSeparatingDistance(gjkPairDetector.
getCachedSeparatingAxis(), sepDist, body0->getWorldTransform(), body1->getWorldTransform());
805 if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
806 squareMot1 < col1->getCcdSquareMotionThreshold())
807 return resultFraction;
872 return resultFraction;
@ TRIANGLE_SHAPE_PROXYTYPE
@ CAPSULE_SHAPE_PROXYTYPE
static btScalar capsuleCapsuleDistance(btVector3 &normalOnB, btVector3 &pointOnB, btScalar capsuleLengthA, btScalar capsuleRadiusA, btScalar capsuleLengthB, btScalar capsuleRadiusB, int capsuleAxisA, int capsuleAxisB, const btTransform &transformA, const btTransform &transformB, btScalar distanceThreshold)
static void segmentsClosestPoints(btVector3 &ptsVector, btVector3 &offsetA, btVector3 &offsetB, btScalar &tA, btScalar &tB, const btVector3 &translation, const btVector3 &dirA, btScalar hlenA, const btVector3 &dirB, btScalar hlenB)
Specialized capsule-capsule collision algorithm has been added for Bullet 2.75 release to increase ra...
btScalar gContactBreakingThreshold
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define SIMD_FORCE_INLINE
void btPlaneSpace1(const T &n, T &p, T &q)
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
int size() const
return the number of elements in the array
void push_back(const T &_Val)
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
btScalar getRadius() const
btScalar getHalfHeight() const
btDispatcher * m_dispatcher
btCollisionObject can be used to manage collision detection objects.
btScalar getHitFraction() const
btTransform & getWorldTransform()
const btTransform & getInterpolationWorldTransform() const
const btCollisionShape * getCollisionShape() const
void setHitFraction(btScalar hitFraction)
btScalar getCcdSweptSphereRadius() const
Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
virtual btScalar getAngularMotionDisc() const
getAngularMotionDisc returns the maximum radius needed for Conservative Advancement to handle time-of...
virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const
bool isPolyhedral() const
btPersistentManifold * m_manifoldPtr
virtual ~btConvexConvexAlgorithm()
btConvexPenetrationDepthSolver * m_pdSolver
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btConvexConvexAlgorithm(btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, btConvexPenetrationDepthSolver *pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
cache separating vector to speedup collision detection
int m_minimumPointsPerturbationThreshold
int m_numPerturbationIterations
ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
btAlignedObjectArray< btVector3 > m_vertices
btAlignedObjectArray< btFace > m_faces
btAlignedObjectArray< btVector3 > m_uniqueEdges
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
virtual btScalar getMargin() const =0
virtual void releaseManifold(btPersistentManifold *manifold)=0
GjkConvexCast performs a raycast on a convex object using support mapping.
virtual bool calcTimeOfImpact(const btTransform &fromA, const btTransform &toA, const btTransform &fromB, const btTransform &toB, CastResult &result)
cast a convex against another convex object
btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface
const btVector3 & getCachedSeparatingAxis() const
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
btScalar getCachedSeparatingDistance() const
void setIgnoreMargin(bool ignoreMargin)
don't use setIgnoreMargin, it's for Bullet's internal use
void setMinkowskiA(const btConvexShape *minkA)
void setMinkowskiB(const btConvexShape *minkB)
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color)
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
btManifoldResult is a helper class to manage contact results.
const btPersistentManifold * getPersistentManifold() const
void setPersistentManifold(btPersistentManifold *manifoldPtr)
btScalar m_closestPointDistanceThreshold
void refreshContactPoints()
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
int getNumContacts() const
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
virtual bool initializePolyhedralFeatures(int shiftVerticesByMargin=0)
optional method mainly used to generate multiple contact points by clipping polyhedral features (face...
virtual void setPolyhedralFeatures(btConvexPolyhedron &polyhedron)
const btConvexPolyhedron * getConvexPolyhedron() const
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
btScalar getRadius() const
btVector3 can be used to represent 3D points and vectors.
btScalar length() const
Return the length of the vector.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btScalar length2() const
Return the length of the vector squared.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points...
const btCollisionShape * getCollisionShape() const
const btCollisionObject * getCollisionObject() const
const btTransform & getWorldTransform() const
RayResult stores the closest result alternatively, add a callback method to decide about closest/all ...
CreateFunc(btConvexPenetrationDepthSolver *pdSolver)
int m_numPerturbationIterations
int m_minimumPointsPerturbationThreshold
btConvexPenetrationDepthSolver * m_pdSolver
virtual void setShapeIdentifiersA(int partId0, int index0)=0
setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material comb...
virtual void setShapeIdentifiersB(int partId1, int index1)=0
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)=0
bool m_useConvexConservativeDistanceUtil
btScalar m_convexConservativeDistanceThreshold
class btIDebugDraw * m_debugDraw
btAlignedObjectArray< int > m_indices