77 btScalar denom = 1.0f - dirA_dot_dirB * dirA_dot_dirB;
79 if ( denom == 0.0f ) {
82 tA = ( dirA_dot_trans - dirB_dot_trans * dirA_dot_dirB ) / denom;
85 else if ( tA > hlenA )
89 tB = tA * dirA_dot_dirB - dirB_dot_trans;
93 tA = tB * dirA_dot_dirB + dirA_dot_trans;
97 else if ( tA > hlenA )
99 }
else if ( tB > hlenB ) {
101 tA = tB * dirA_dot_dirB + dirA_dot_trans;
105 else if ( tA > hlenA )
114 ptsVector = translation - offsetA + offsetB;
138 btVector3 translation = translationB - translationA;
148 directionA, capsuleLengthA, directionB, capsuleLengthB );
150 btScalar distance = ptsVector.
length() - capsuleRadiusA - capsuleRadiusB;
152 if ( distance > distanceThreshold )
166 pointOnB = transformB.
getOrigin()+offsetB + normalOnB * capsuleRadiusB;
200 #ifdef USE_SEPDISTANCE_UTIL2
201 m_sepDistance((static_cast<
btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
202 (static_cast<
btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
240 :m_originalManifoldResult(originalResult),
241 m_transformA(transformA),
242 m_transformB(transformB),
243 m_unPerturbedTransform(unPerturbedTransform),
244 m_perturbA(perturbA),
245 m_debugDrawer(debugDrawer)
260 btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth;
261 endPt = (m_unPerturbedTransform*m_transformA.
inverse())(endPtOrg);
262 newDepth = (endPt - pointInWorld).
dot(normalOnBInWorld);
263 startPt = endPt - normalOnBInWorld*newDepth;
266 endPt = pointInWorld + normalOnBInWorld*orgDepth;
267 startPt = (m_unPerturbedTransform*m_transformB.
inverse())(pointInWorld);
268 newDepth = (endPt - startPt).
dot(normalOnBInWorld);
273 #ifdef DEBUG_CONTACTS 277 #endif //DEBUG_CONTACTS 280 m_originalManifoldResult->
addContactPoint(normalOnBInWorld,startPt,newDepth);
311 #ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER 377 #endif //BT_DISABLE_CAPSULE_CAPSULE_COLLIDER 382 #ifdef USE_SEPDISTANCE_UTIL2 385 m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform());
401 #ifdef USE_SEPDISTANCE_UTIL2 406 #endif //USE_SEPDISTANCE_UTIL2 426 #ifdef USE_SEPDISTANCE_UTIL2 438 #endif //USE_SEPDISTANCE_UTIL2 453 : m_hasContact(
false)
458 virtual void setShapeIdentifiersA(
int partId0,
int index0){}
459 virtual void setShapeIdentifiersB(
int partId1,
int index1){}
463 m_normalOnBInWorld = normalOnBInWorld;
464 m_pointInWorld = pointInWorld;
480 :m_originalResult(result),
481 m_marginOnA(marginOnA),
482 m_marginOnB(marginOnB),
487 virtual void setShapeIdentifiersA(
int partId0,
int index0){}
488 virtual void setShapeIdentifiersB(
int partId1,
int index1){}
491 m_reportedDistance = depthOrg;
492 m_reportedNormalOnWorld = normalOnBInWorld;
494 btVector3 adjustedPointB = pointInWorldOrg - normalOnBInWorld*m_marginOnB;
495 m_reportedDistance = depthOrg+(m_marginOnA+m_marginOnB);
496 if (m_reportedDistance<0.f)
498 m_foundResult =
true;
500 m_originalResult->
addContactPoint(normalOnBInWorld,adjustedPointB,m_reportedDistance);
512 btWithoutMarginResult withoutMargin(resultOut, min0Margin,min1Margin);
526 bool foundSepAxis =
true;
534 sepNormalWorldSpace,*resultOut);
549 sepNormalWorldSpace = withoutMargin.m_reportedNormalOnWorld;
551 minDist = withoutMargin.m_reportedDistance;
556 foundSepAxis = withoutMargin.m_foundResult && minDist<0;
601 bool foundSepAxis =
false;
602 bool useSatSepNormal =
true;
645 combinedFaceA.
m_plane[0] = faceNormal[0];
646 combinedFaceA.
m_plane[1] = faceNormal[1];
647 combinedFaceA.
m_plane[2] = faceNormal[2];
648 combinedFaceA.
m_plane[3] = -planeEq;
668 combinedFaceB.
m_plane[0] = faceNormal[0];
669 combinedFaceB.
m_plane[1] = faceNormal[1];
670 combinedFaceB.
m_plane[2] = faceNormal[2];
671 combinedFaceB.
m_plane[3] = -planeEq;
690 sepNormalWorldSpace,*resultOut);
703 if (dummy.m_hasContact && dummy.m_depth<0)
708 if (dummy.m_normalOnBInWorld.dot(sepNormalWorldSpace)<0.99)
716 sepNormalWorldSpace.
setValue(0,0,1);
776 bool perturbeA =
true;
781 if (radiusA < radiusB)
790 if ( perturbeAngle > angleLimit )
791 perturbeAngle = angleLimit;
815 #ifdef DEBUG_CONTACTS 817 #endif //DEBUG_CONTACTS 822 #ifdef DEBUG_CONTACTS 836 #ifdef USE_SEPDISTANCE_UTIL2 839 m_sepDistance.initSeparatingDistance(gjkPairDetector.
getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform());
841 #endif //USE_SEPDISTANCE_UTIL2 870 if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
872 return resultFraction;
908 if (resultFraction > result.m_fraction)
909 resultFraction = result.m_fraction;
941 if (resultFraction > result.m_fraction)
942 resultFraction = result.m_fraction;
947 return resultFraction;
virtual void releaseManifold(btPersistentManifold *manifold)=0
const btPersistentManifold * getPersistentManifold() const
btAlignedObjectArray< btVector3 > m_vertices
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
void push_back(const T &_Val)
btScalar getCcdSweptSphereRadius() const
Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btScalar getContactBreakingThreshold() const
ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btScalar getCachedSeparatingDistance() const
void setMinkowskiB(const btConvexShape *minkB)
btScalar m_convexConservativeDistanceThreshold
int m_minimumPointsPerturbationThreshold
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
void setPersistentManifold(btPersistentManifold *manifoldPtr)
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
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...
void btPlaneSpace1(const T &n, T &p, T &q)
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
void setHitFraction(btScalar hitFraction)
void refreshContactPoints()
void setMinkowskiA(const btConvexShape *minkA)
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)
#define SIMD_FORCE_INLINE
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
btPersistentManifold * m_manifoldPtr
btAlignedObjectArray< btVector3 > m_uniqueEdges
btScalar getRadius() const
bool m_useConvexConservativeDistanceUtil
btManifoldResult is a helper class to manage contact results.
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
class btIDebugDraw * m_debugDraw
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
btScalar dot(const btVector3 &v) const
Return the dot product.
btDispatcher * m_dispatcher
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btScalar getCcdSquareMotionThreshold() const
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
const btTransform & getInterpolationWorldTransform() const
GjkConvexCast performs a raycast on a convex object using support mapping.
const btVector3 & getCachedSeparatingAxis() const
void setLowLevelOfDetail(bool useLowLevel)
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
virtual bool calcTimeOfImpact(const btTransform &fromA, const btTransform &toA, const btTransform &fromB, const btTransform &toB, CastResult &result)
cast a convex against another convex object
btTransform & getWorldTransform()
RayResult stores the closest result alternatively, add a callback method to decide about closest/all ...
btScalar m_closestPointDistanceThreshold
btAlignedObjectArray< int > m_indices
int size() const
return the number of elements in the array
btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points...
btAlignedObjectArray< btFace > m_faces
const btConvexPolyhedron * getConvexPolyhedron() const
virtual bool initializePolyhedralFeatures(int shiftVerticesByMargin=0)
optional method mainly used to generate multiple contact points by clipping polyhedral features (face...
virtual ~btConvexConvexAlgorithm()
btScalar gContactBreakingThreshold
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
const btTransform & getWorldTransform() const
btCollisionObject can be used to manage collision detection objects.
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
btScalar length() const
Return the length of the vector.
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
CreateFunc(btConvexPenetrationDepthSolver *pdSolver)
virtual btScalar getMargin() const =0
const btCollisionShape * getCollisionShape() const
virtual btScalar getAngularMotionDisc() const
getAngularMotionDisc returns the maximum radius needed for Conservative Advancement to handle time-of...
btScalar getHitFraction() const
btVector3 can be used to represent 3D points and vectors.
btScalar length2() const
Return the length of the vector squared.
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)=0
bool isPolyhedral() const
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
void resize(int newsize, const T &fillData=T())
int getNumContacts() const
btVertexArray worldVertsB1
int m_numPerturbationIterations
btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface
btVertexArray worldVertsB2
btConvexPenetrationDepthSolver * m_pdSolver
btScalar getRadius() const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
btScalar getHalfHeight() const
const btCollisionShape * getCollisionShape() const
virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color)
int m_minimumPointsPerturbationThreshold
virtual void setPolyhedralFeatures(btConvexPolyhedron &polyhedron)
btConvexPenetrationDepthSolver * m_pdSolver
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
const btCollisionObject * getCollisionObject() const
void setIgnoreMargin(bool ignoreMargin)
don't use setIgnoreMargin, it's for Bullet's internal use
int m_numPerturbationIterations