Thanks a lot for your reply!
The character's restitution I had already set to zero, but increasing the character's gravity definitely helps minimizing the bouncing even though it's still there. With normal gravity the maximum distance from the ground is ~ 0.2 (for reference the character/capsule is ~ 2 units) and with a gravity -50.0f the value decreases to ~0.04.
This is a gif of the character with increased gravity and the bouncing is only noticeable if you're really paying attention to it.
https://gfycat.com/hugeagreeablecurlew
So while it works and I will keep it for now this solution seems to be a little hacky and I would prefer a cleaner solution, so if anyone has any other ideas I'm all ears.
EDIT:
I just found out that the solution of the first link (
https://stackoverflow.com/questions/256 ... ith-bullet) also works for btHeightfieldTerrainShape and not only the btBvhTriangleMeshShape, so generating a btTriangleInfoMap and implementing a custom callback for the terrain shape fixes the bouncing completely.
Code: Select all
#include <BulletCollision/CollisionDispatch/btInternalEdgeUtility.h>
....
//register callback function
gContactAddedCallback = collisionCallback;
....
//generate triangle info map
terrainTriangleInfo = new btTriangleInfoMap();
btGenerateInternalEdgeInfo(terrainShape, terrainTriangleInfo);
terrainShape->setTriangleInfoMap(terrainTriangleInfo);
....
//create rigid body for the terrain shape
btRigidBody::btRigidBodyConstructionInfo bodyInfo(0.0f, motionState, terrainShape, btVector3(0,0,0));
btRigidBody* body = new btRigidBody(bodyInfo);
//enable custom callback
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
....
//custom callback function
bool BulletPhysics::collisionCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* obj1, int id1, int index1, const btCollisionObjectWrapper* obj2, int id2, int index2)
{
btAdjustInternalEdgeContacts(cp, obj2, obj1, id2, index2);
return true;
}