1- In a first time, we want to know why the following code doesn't work ?
Interesting. You need to shift
the child shapes, so that the world transform of the rigid body is aligned with the center of mass/principal axis of inertia.
There is a utility function in btCompoundShape to do this. Once you have this principal transform, there a 3 methods to shift
1) create a recursive compound, with the inverse principal transform
the transform for each child in-place
3) create a new compound with the updated transform
See attached file, implementing all 3 methods. (3) is fastest to build and performs better then a recursive btCompoundShape.
2- In a second time... Is it the good way to do that if you want to have a object composed of 100000 boxes ?
Should theoretically be possible. I just tried 5000 boxes, and the drawing becomes the bottleneck in the basic demo
, so you need a better renderer.
Do you have any nice model you can share?