The first problem I was having was that a sphere bouncing on flat ground would come to rest much sooner than expected. I tracked this down to this line of code:
Code: Select all
btSequentialImpulseConstraintSolver::setupContactConstraint( ... )
...
velocityError -= penetration / infoGlobal.m_timeStep;
Code: Select all
SphereTriangleDetector::collide( ... )
...
if (isInsideContactPlane) {
if (facecontains(sphereCenter,vertices,normal)) {
...
} else {
// !!! The code here sets the contact point to a point on one of the edges of the triangle rather a point that is towards the sphere's center
Code: Select all
// if the triangle is part of a triangle mesh and is perfectly flat on the ground,
// then we want the contact point to be perfectly below the ball, not off to the side a bit (which causes
// the ball to skip up off the ground)
if ( hasContact ) {
contactPoint = sphereCenter - normal*distanceFromPlane;
}