See attached executable, and VisualStudio 2017 solution.
Just extract it to C drive, and run.
Video, for those who don't want to download the sample:
Could anybody help me understand, why the falling box penetrates the ground?
Where does my small example code fails?
I try to aim for a 1/60 fixed stepped, frame rate independent, and deterministic game loop as described here:
http://www.bulletphysics.org/mediawiki- ... _Game_Loop
http://www.bulletphysics.org/mediawiki- ... _The_World
Which I think its already in place.
I have read a lot about inaccuracy problems, but none of these should happen in such a small case example like this.
All these workarounds are overshoot, at least to me.
Known workarounds for tunneling:
- Increase tessellation (make the ground smaller here):
This mitigates the problem, but unacceptable in real scenarios, where you cannot tessellate all surfaces to 1 unit wide triangles.
- Increase the fixed timestep resolution (3rd parameter in stepSimulation).
1/240 value seems to solve the issue, but the cost is heavy on the CPU.
With 1/60 values we can smoothly simulate hundreds of falling boxes, but with 1/240 only few dozens.
- Enable CCD on the dynamic body.
This is overshoot for simple falling body pulled by only gravity. CCD should be used only for FAST, and SMALL objects like bullets.
Or is there a fundamental problem with my implementation?
Any help on the topic is greatly appreciated.
Here are some debate how 1/60 should be more than enough for a simulation like this:
https://www.gamedev.net/forums/topic/63 ... -timestep/
Some more clarification:
The scene is simple, and consists of only 2 objects:
1. One small dynamic box, falling down from 7 meters
2. One large static box, with btBvhTriangleMeshShape.
btBvhTriangleMeshShape was choosen for the static ground, as it is flexible to create more complex static shapes, like a simple game map, but right now it's just a thick box.
In the 'void render()' function, the MotionState is used to get interpolated transformation for the to be rendered falling box.