The same dynamic bodies penetrate much deeper into a static btBvhTriangleMeshShape body,
than they do into the same sized static btBoxShape body.
For test, one big 10x10x10 box is created, then 9 dynamic boxes are dropped on top of each other, similarly what MultipleBoxes example do.
Test #1 - The big white box, the ground is a btBvhTriangleMeshShape.
https://youtu.be/DW_K707RAhw
1-2 dynamic boxes are even tunneling, and pass through the static body.
Test #2 - The big white box, the ground is a btBoxShape.
https://youtu.be/idsYQVISD7I
There is some penetration here too (no idea why), but at least no tunneling and passing through dynamic bodies.
In my example, I don't think i have problem with simulation step.
The loop is independent from the rendering, and deterministic (repeating the tests gives exactly the same results always, and boxes land on the same spots).
Physics simulation is stepped like this:
Code: Select all
mDynamicsWorld->stepSimulation((btScalar)mPhysicsTimer.getElapsedMilliseconds() / 1000.0f, 7, 1.0f/60.0f);
CCD could be solution too, but the bodies are not even fast, only gravity affected, so I would keep CCD only for bullets, and missles not slow moving boxes.
Does anybody experienced similar issues with BT, like:
1. Different shapes have different collision accuracy.
2. Inaccurate collision, slight tunneling, as seen even in Test#2, and Test#3.
Thank you!
Dynamic box properties:
- Dimensions: 0.5 x 0.5 x 0.5
- Mass: 1
- Friction: 0.9
- Restitution: 0
- Inertia: 0 0 0 (calculated by calculateLocalInertia on creation)
- Restitution: 1 1 1
Static ground, the big white box properties:
- Dimensions: 10 x 10 x 10
- Mass: 0
- Friction: 1.0
- Restitution: 0
- Inertia: 0 0 0
- Restitution: 0 0 0
P.S.: The btBvhTriangleMeshShape is created like this:
I use this to load entire maps, and complex shapes without any issue, except for the tunneling artifact.
Code: Select all
btIndexedMesh indexedMesh;
indexedMesh.m_numTriangles = mVertexIndexes.size() / 3;
indexedMesh.m_triangleIndexBase = (unsigned char*)&mVertexIndexes[0];
indexedMesh.m_triangleIndexStride = 3 * sizeof(vUshort);
indexedMesh.m_numVertices = mVertexPositions.size();
indexedMesh.m_vertexBase = (unsigned char*)&mVertexPositions[0];
indexedMesh.m_vertexStride = sizeof(glm::vec3);
mTriangleIndexVertexArray = new btTriangleIndexVertexArray();
mTriangleIndexVertexArray->addIndexedMesh(indexedMesh, PHY_SHORT);
mCollisionShape = new btBvhTriangleMeshShape( mTriangleIndexVertexArray, true, true);