Erwin Coumans wrote:pico wrote:
I added the callback and it got executed. There was no visible difference in behavior.
Did you double-check that your callback is actually executed?
You should enable the callback, only for the objects that need it (triangle mesh).
Code: Select all
//enable custom material callback
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
See the ConcaveDemo.
Hope this helps,
Erwin
Yes, i double checked as i had a breakpoint in the callback. I also have the callback only for the trimesh.
The cp.m_normalWorldOnA/B got changed but the visual result was still wrong.
I was also expecting this should work. Tho I think Dirk is right that penetration depth may matter.
I actually don't know the inner Bullet workings and how penetration depth is handled.
Maybe you could modify the below code to reflect PD?
Then i could try right away:
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
btCollisionShape* col0Shape= (btCollisionShape*)colObj0->getCollisionShape();
btCollisionShape* col1Shape= (btCollisionShape*)colObj1->getCollisionShape();
if (col0Shape->getShapeType()==TRIANGLE_SHAPE_PROXYTYPE)
{
btTriangleShape* triangle = (btTriangleShape*)col0Shape;
const btVector3* vertices = &triangle->getVertexPtr(0);
cp.m_normalWorldOnB = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
}
else if (col1Shape->getShapeType()==TRIANGLE_SHAPE_PROXYTYPE)
{
btTriangleShape* triangle = (btTriangleShape*)col1Shape;
const btVector3* vertices = &triangle->getVertexPtr(0);
cp.m_normalWorldOnB = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
}
return true;
}