Your calling challenge is "Internal Border Collision." I just found a solution a few hours ago. If you are using btHeightfieldTerrainShape for your world, then you should use btBvhTriangleMeshShape to solve this problem.
Here's the answer.
Add this callback:
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp,const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1) { btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1); return true; } extern ContactAddedCallback gContactAddedCallback;
Then create btBvhTriangleMeshShape and add this code where pGround is your btBvhTriangleMeshShape :
// Enable custom material callback pGround->setCollisionFlags(pGround->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); btTriangleInfoMap* triangleInfoMap = new btTriangleInfoMap(); btGenerateInternalEdgeInfo(pGroundShape, triangleInfoMap);
Or you can open the InternalEdgeDemo example in Bullet to find out how to implement it in detail.
source share