|
Bullet Collision Detection & Physics Library
|
Go to the documentation of this file.
76 btScalar denom = 1.0f - dirA_dot_dirB * dirA_dot_dirB;
78 if ( denom == 0.0f ) {
81 tA = ( dirA_dot_trans - dirB_dot_trans * dirA_dot_dirB ) / denom;
84 else if ( tA > hlenA )
88 tB = tA * dirA_dot_dirB - dirB_dot_trans;
92 tA = tB * dirA_dot_dirB + dirA_dot_trans;
96 else if ( tA > hlenA )
98 }
else if ( tB > hlenB ) {
100 tA = tB * dirA_dot_dirB + dirA_dot_trans;
104 else if ( tA > hlenA )
113 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 )
165 pointOnB = transformB.
getOrigin()+offsetB + normalOnB * capsuleRadiusB;
199 #ifdef USE_SEPDISTANCE_UTIL2
200 m_sepDistance((static_cast<
btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
201 (static_cast<
btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
259 btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth;
261 newDepth = (endPt - pointInWorld).
dot(normalOnBInWorld);
262 startPt = endPt+normalOnBInWorld*newDepth;
265 endPt = pointInWorld + normalOnBInWorld*orgDepth;
267 newDepth = (endPt - startPt).
dot(normalOnBInWorld);
272 #ifdef DEBUG_CONTACTS
276 #endif //DEBUG_CONTACTS
310 #ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
376 #endif //BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
381 #ifdef USE_SEPDISTANCE_UTIL2
384 m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform());
388 #endif //USE_SEPDISTANCE_UTIL2
400 #ifdef USE_SEPDISTANCE_UTIL2
405 #endif //USE_SEPDISTANCE_UTIL2
425 #ifdef USE_SEPDISTANCE_UTIL2
437 #endif //USE_SEPDISTANCE_UTIL2
445 virtual void setShapeIdentifiersA(
int partId0,
int index0){}
446 virtual void setShapeIdentifiersB(
int partId1,
int index1){}
463 :m_originalResult(result),
464 m_marginOnA(marginOnA),
465 m_marginOnB(marginOnB),
470 virtual void setShapeIdentifiersA(
int partId0,
int index0){}
471 virtual void setShapeIdentifiersB(
int partId1,
int index1){}
474 m_reportedDistance = depthOrg;
475 m_reportedNormalOnWorld = normalOnBInWorld;
477 btVector3 adjustedPointB = pointInWorldOrg - normalOnBInWorld*m_marginOnB;
478 m_reportedDistance = depthOrg+(m_marginOnA+m_marginOnB);
479 if (m_reportedDistance<0.f)
481 m_foundResult =
true;
483 m_originalResult->
addContactPoint(normalOnBInWorld,adjustedPointB,m_reportedDistance);
495 btWithoutMarginResult withoutMargin(resultOut, min0Margin,min1Margin);
509 bool foundSepAxis =
true;
517 sepNormalWorldSpace,*resultOut);
532 sepNormalWorldSpace = withoutMargin.m_reportedNormalOnWorld;
534 minDist = withoutMargin.m_reportedDistance;
539 foundSepAxis = withoutMargin.m_foundResult && minDist<0;
581 bool foundSepAxis =
false;
589 sepNormalWorldSpace,*resultOut);
654 bool perturbeA =
true;
659 if (radiusA < radiusB)
668 if ( perturbeAngle > angleLimit )
669 perturbeAngle = angleLimit;
693 #ifdef DEBUG_CONTACTS
695 #endif //DEBUG_CONTACTS
700 #ifdef DEBUG_CONTACTS
714 #ifdef USE_SEPDISTANCE_UTIL2
717 m_sepDistance.initSeparatingDistance(gjkPairDetector.
getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform());
719 #endif //USE_SEPDISTANCE_UTIL2
748 if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
750 return resultFraction;
825 return resultFraction;
btConvexPenetrationDepthSolver * m_pdSolver
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
btCollisionObject can be used to manage collision detection objects.
int m_numPerturbationIterations
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
void btPlaneSpace1(const T &n, T &p, T &q)
int m_minimumPointsPerturbationThreshold
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btScalar length() const
Return the length of the vector.
virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color)
btScalar getCachedSeparatingDistance() const
btDispatcher * m_dispatcher
bool m_useConvexConservativeDistanceUtil
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
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)
void setMinkowskiB(const btConvexShape *minkB)
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
btScalar m_convexConservativeDistanceThreshold
int getNumContacts() const
class btIDebugDraw * m_debugDraw
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...
virtual bool calcTimeOfImpact(const btTransform &fromA, const btTransform &toA, const btTransform &fromB, const btTransform &toB, CastResult &result)
cast a convex against another convex object
const btTransform & getWorldTransform() const
CreateFunc(btConvexPenetrationDepthSolver *pdSolver)
void setHitFraction(btScalar hitFraction)
btScalar getHalfHeight() const
const btVector3 & getCachedSeparatingAxis() const
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
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
btTransform & getWorldTransform()
RayResult stores the closest result alternatively, add a callback method to decide about closest/all ...
@ TRIANGLE_SHAPE_PROXYTYPE
btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points...
btPersistentManifold * m_manifoldPtr
btConvexPenetrationDepthSolver * m_pdSolver
@ CAPSULE_SHAPE_PROXYTYPE
btScalar getCcdSquareMotionThreshold() const
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
GjkConvexCast performs a raycast on a convex object using support mapping.
btManifoldResult is a helper class to manage contact results.
virtual ~btConvexConvexAlgorithm()
virtual btScalar getMargin() const =0
virtual void releaseManifold(btPersistentManifold *manifold)=0
btScalar gContactBreakingThreshold
const btCollisionShape * getCollisionShape() const
const btPersistentManifold * getPersistentManifold() const
void resize(int newsize, const T &fillData=T())
btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface
const btTransform & getInterpolationWorldTransform() const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
void setLowLevelOfDetail(bool useLowLevel)
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
const btCollisionObject * getCollisionObject() const
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
btVector3 can be used to represent 3D points and vectors.
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
void setPersistentManifold(btPersistentManifold *manifoldPtr)
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)=0
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
virtual bool initializePolyhedralFeatures(int shiftVerticesByMargin=0)
optional method mainly used to generate multiple contact points by clipping polyhedral features (face...
virtual btScalar getAngularMotionDisc() const
getAngularMotionDisc returns the maximum radius needed for Conservative Advancement to handle time-of...
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
int m_minimumPointsPerturbationThreshold
#define SIMD_FORCE_INLINE
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
btScalar getHitFraction() const
void refreshContactPoints()
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
bool isPolyhedral() const
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
void setIgnoreMargin(bool ignoreMargin)
don't use setIgnoreMargin, it's for Bullet's internal use
btScalar getCcdSweptSphereRadius() const
Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
void push_back(const T &_Val)
btVertexArray worldVertsB1
btVertexArray worldVertsB2
int m_numPerturbationIterations
btScalar getContactBreakingThreshold() const
btScalar m_closestPointDistanceThreshold
btScalar getRadius() const
btScalar length2() const
Return the length of the vector squared.
const btCollisionShape * getCollisionShape() const
const btConvexPolyhedron * getConvexPolyhedron() const
btScalar getRadius() const