65 btScalar radius = sphere0->getRadius();
66 btScalar maxContactDistance = m_manifoldPtr->getContactBreakingThreshold();
70 if (
getSphereDistance(boxObjWrap, pOnBox, normalOnSurfaceB, penetrationDepth, sphereCenter, radius, maxContactDistance))
78 if (m_manifoldPtr->getNumContacts())
99 btVector3 const& boxHalfExtent = boxShape->getHalfExtentsWithoutMargin();
100 btScalar boxMargin = boxShape->getMargin();
101 penetrationDepth = 1.0f;
105 btVector3 sphereRelPos = m44T.invXform(sphereCenter);
109 closestPoint.setX(
btMin(boxHalfExtent.getX(), closestPoint.getX()));
110 closestPoint.setX(
btMax(-boxHalfExtent.getX(), closestPoint.getX()));
111 closestPoint.setY(
btMin(boxHalfExtent.getY(), closestPoint.getY()));
112 closestPoint.setY(
btMax(-boxHalfExtent.getY(), closestPoint.getY()));
113 closestPoint.setZ(
btMin(boxHalfExtent.getZ(), closestPoint.getZ()));
114 closestPoint.setZ(
btMax(-boxHalfExtent.getZ(), closestPoint.getZ()));
116 btScalar intersectionDist = fRadius + boxMargin;
117 btScalar contactDist = intersectionDist + maxContactDistance;
118 normal = sphereRelPos - closestPoint;
122 if (dist2 > contactDist * contactDist)
140 pointOnBox = closestPoint +
normal * boxMargin;
142 penetrationDepth =
distance - intersectionDist;
149 tmp = m44T.getBasis() *
normal;
158 btScalar faceDist = boxHalfExtent.getX() - sphereRelPos.getX();
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());
btBoxShape(const btVector3 &boxHalfExtents)
btPersistentManifold * m_manifoldPtr
SIMD_FORCE_INLINE const T & btMin(const T &a, const T &b)
SIMD_FORCE_INLINE const T & btMax(const T &a, const T &b)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btSphereShape(btScalar radius)
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
btDispatcher * m_dispatcher
virtual void releaseManifold(btPersistentManifold *manifold)=0
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
virtual bool needsCollision(const btCollisionObject *body0, const btCollisionObject *body1)=0
btManifoldResult is a helper class to manage contact results.
void setPersistentManifold(btPersistentManifold *manifoldPtr)
SIMD_FORCE_INLINE void refreshContactPoints()
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
btSphereBoxCollisionAlgorithm(btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
virtual ~btSphereBoxCollisionAlgorithm()
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)
SyclQueue void void size_t num_bytes void
IconTextureDrawCall normal
T distance(const T &a, const T &b)
SIMD_FORCE_INLINE const btCollisionShape * getCollisionShape() const
SIMD_FORCE_INLINE const btTransform & getWorldTransform() const
SIMD_FORCE_INLINE const btCollisionObject * getCollisionObject() const