The main problem is that Bullet 2 (2.82, to be specific - and perhaps Bullet 3 too, haven't checked it yet) processes edge collisions lousily, generating skewed reaction normals.
Test case 1: a small btBoxShape
, positioned (0,9,0), aligned vertically, falls onto another box's (made from btBoxShape
also) face, coaligned. The normal is computed properly, the collision happens only in Y (vertical) axis. The box slightly bounces on OY axis and stays centered around it.
Test case 2: a small box, positioned (0,9,0) aligned vertically, (ditto) falls onto another box's face, (this time made from btBvhTriangleMeshShape
made from 2 coplanar triangles), also coaligned. The normal is computed improperly, the collision happens in all axes. The box bounces to the side, sometimes (depending on specific collision coordinates) very visibly.
Even hard-coding the normal and recalculating the collision points based on it (see below) doesn't help.
//newNormal was set to hard-coded value of (0,-1,0) before
cp.m_normalWorldOnB = colObj0Wrap -> getWorldTransform().getBasis() * newNormal;
cp.m_positionWorldOnB = cp.m_positionWorldOnA - cp.m_normalWorldOnB * cp.m_distance1;
cp.m_localPointB = colObj0Wrap -> getWorldTransform().invXform( cp.m_positionWorldOnB
NB using btAdjustInternalEdgeContacts
doesn't help in any visible way, despite setting tri info properly and verifying the code is executing alright. While it does work and gives some minor improvement to simulation's reliability (although at quite high CPU cost), it still doesn't solve this particular issue.
The question is: how to fix case 2's behaviour to match case 1's. Any advice how to avoid this situation (code kludges welcome), or why this doesn't work the way it should are welcome.
Further reference:
https://github.com/bulletphysics/bullet3/issues/92
http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=8113
https://bullet.googlecode.com/files/GDC10_Coumans_Erwin_Contact.pdf
https://code.google.com/p/bullet/issues/detail?id=27
http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4603