28 m_isSwapped(isSwapped)
70 if (
getSphereDistance(boxObjWrap, pOnBox, normalOnSurfaceB, penetrationDepth, sphereCenter, radius, maxContactDistance))
101 penetrationDepth = 1.0f;
116 btScalar intersectionDist = fRadius + boxMargin;
117 btScalar contactDist = intersectionDist + maxContactDistance;
118 normal = sphereRelPos - closestPoint;
122 if (dist2 > contactDist * contactDist)
136 distance = normal.
length();
140 pointOnBox = closestPoint + normal * boxMargin;
142 penetrationDepth = distance - intersectionDist;
160 closestPoint.
setX(boxHalfExtent.
getX());
163 faceDist = boxHalfExtent.
getX() + sphereRelPos.
getX();
164 if (faceDist < minDist)
167 closestPoint = sphereRelPos;
168 closestPoint.
setX(-boxHalfExtent.
getX());
172 faceDist = boxHalfExtent.
getY() - sphereRelPos.
getY();
173 if (faceDist < minDist)
176 closestPoint = sphereRelPos;
177 closestPoint.
setY(boxHalfExtent.
getY());
181 faceDist = boxHalfExtent.
getY() + sphereRelPos.
getY();
182 if (faceDist < minDist)
185 closestPoint = sphereRelPos;
186 closestPoint.
setY(-boxHalfExtent.
getY());
190 faceDist = boxHalfExtent.
getZ() - sphereRelPos.
getZ();
191 if (faceDist < minDist)
194 closestPoint = sphereRelPos;
195 closestPoint.
setZ(boxHalfExtent.
getZ());
199 faceDist = boxHalfExtent.
getZ() + sphereRelPos.
getZ();
200 if (faceDist < minDist)
203 closestPoint = sphereRelPos;
204 closestPoint.
setZ(-boxHalfExtent.
getZ());
const T & btMax(const T &a, const T &b)
const T & btMin(const T &a, const T &b)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
const btVector3 & getHalfExtentsWithoutMargin() const
btDispatcher * m_dispatcher
btCollisionObject can be used to manage collision detection objects.
virtual btScalar getMargin() const
virtual void releaseManifold(btPersistentManifold *manifold)=0
virtual bool needsCollision(const btCollisionObject *body0, const btCollisionObject *body1)=0
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
btManifoldResult is a helper class to manage contact results.
void setPersistentManifold(btPersistentManifold *manifoldPtr)
void refreshContactPoints()
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
int getNumContacts() const
btScalar getContactBreakingThreshold() const
btSphereBoxCollisionAlgorithm(btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
virtual ~btSphereBoxCollisionAlgorithm()
btPersistentManifold * m_manifoldPtr
bool getSphereDistance(const btCollisionObjectWrapper *boxObjWrap, btVector3 &v3PointOnBox, btVector3 &normal, btScalar &penetrationDepth, const btVector3 &v3SphereCenter, btScalar fRadius, btScalar maxContactDistance)
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btScalar getSpherePenetration(btVector3 const &boxHalfExtent, btVector3 const &sphereRelPos, btVector3 &closestPoint, btVector3 &normal)
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
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.
const btScalar & getZ() const
Return the z value.
void setZ(btScalar _z)
Set the z value.
btScalar length() const
Return the length of the vector.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
void setY(btScalar _y)
Set the y value.
void setX(btScalar _x)
Set the x value.
btScalar length2() const
Return the length of the vector squared.
const btScalar & getY() const
Return the y value.
const btScalar & getX() const
Return the x value.
const btCollisionShape * getCollisionShape() const
const btCollisionObject * getCollisionObject() const
const btTransform & getWorldTransform() const