Update:
Using Visual Studio 2008;
the problem does not appear in debug mode, only in release mode.
Issue appears to occur around:
btSphereBoxCollisionAlgorithm.cpp:
btSphereBoxCollisionAlgorithm::getSphereDistance(), lines 112-123:
Code: Select all
// Determine the closest point to the sphere center in the box
btVector3 closestPoint = sphereRelPos;
closestPoint.setX( btMin(boxHalfExtent.getX(), closestPoint.getX()) );
closestPoint.setX( btMax(-boxHalfExtent.getX(), closestPoint.getX()) );
closestPoint.setY( btMin(boxHalfExtent.getY(), closestPoint.getY()) );
closestPoint.setY( btMax(-boxHalfExtent.getY(), closestPoint.getY()) );
closestPoint.setZ( btMin(boxHalfExtent.getZ(), closestPoint.getZ()) );
closestPoint.setZ( btMax(-boxHalfExtent.getZ(), closestPoint.getZ()) );
btScalar intersectionDist = fRadius + boxMargin;
btScalar contactDist = intersectionDist + maxContactDistance;
normal = sphereRelPos - closestPoint;
//Original post below
There may be some issues with btSphereShape-btBoxShape collision.
On occasion, the normal appears to point in the opposite direction.
Edit BasicDemo.cpp:
Replace line 28:
#define START_POS_Y -5
with:
#define START_POS_Y -30 //Causes rigid bodies to spawn within the large box rigid body
Change lines 141 and 142 from:
btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
to:
//btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
When btBoxShape is used, the boxes are always pushed out of the large box.
When btSphereShape is used, some spheres move downwards into the large box and others oscillate.
Eventually, the spheres still embedded in the large box are put to sleep.