I think I have the typical problem of a rigid body with btBoxShape sliding across multiple static btBvhTriangleMeshShapes.
So, I took an attempt at using btInternalEdgeUtility to solve the problem. Well, it got better and the box jumps a lot less on triangle edges, but it still jumps. Played around with btTriangleInfoMap coefficients, but didn't manage to get things any better.
My guess is that I might be using too small collision shapes or something. Perhaps with bigger shapes, these anomalies at the edges would become insignificant?
Anyway, here's what I do with the triangle meshes:
Code: Select all
// Let's assume that this works ok
shape = converter.createTrimesh();
btTriangleInfoMap* triangleInfoMap = new btTriangleInfoMap();
// btGenerateInternalEdgeInfo fills in the btTriangleInfoMap and stores it as a user
// pointer of trimeshShape (trimeshShape->setUserPointer(triangleInfoMap))
btGenerateInternalEdgeInfo( ( btBvhTriangleMeshShape * ) shape, triangleInfoMap );
Code: Select all
// Let's assume that creating rigid body works well
// and 'body' is a pointer to btRigidBody
body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK );
Code: Select all
// Let's assume that the assignment of contact_added_callback to ContactAddedCallback works well
// because fiddling around with the arguments of btAdjustInternalEdgeContacts changed the
// behavior of the jumping
static bool contact_added_callback(
btManifoldPoint& cp, const btCollisionObject* colObj0,
int partId0, int index0, const btCollisionObject* colObj1, int partId1, int index1 )
{
// Find the triangle mesh object and the other object
const btCollisionObject *trimesh = colObj0, *other = colObj1;
int trimesh_pid = partId0, other_pid = partId1;
int trimesh_id = index0, other_id = index1;
// Make sure we're giving btAdjustInternalEdgeContacts the right arguments
if ( colObj1->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE ) {
trimesh = colObj1;
trimesh_pid = partId1;
trimesh_id = index1;
other = colObj0;
other_pid = partId0;
other_id = index0;
}
btAdjustInternalEdgeContacts( cp, trimesh, other, trimesh_pid, trimesh_id );
return false;
}
Thanks