wow I realize that this function is misleading NewtonConvexCollisionCalculateInertialMatrix
basically that function calculate inertia relative to the origin of the shape, but that is not right. this is only correct when the center of mass and the origin of a body coincide.
here is an example say we have a big centered at the of the box.
function NewtonConvexCollisionCalculateInertialMatrix will give the Initia of a box with cent at the origin and the is correct.
now let us say the box has an origin at the lower bottom, the above function will report the inertia of a box with origin and the bottom and the origion at the lower bottom.
but the could be a problems if it si use wrong.
if we set the body cog at the center of the box, the above inertia is correct, but if we set the center at the origin reported by function NewtonConvexCollisionCalculateInertialMatrix
the this is a body that just happen to be a graphics origin different that the inertia center, but it inertia should be the inertia of a centered box.
when I set this I get it right, however I can how this can lead to many error
I will remove that function all together. and instead the inertia of the shape will allay be a property of the shape calculate at the time of creations.
The shape will have a Get Origin function in the shape, that can be use to set the COG of the body.
but the COG of a body can be set to any other value, if the user chooses to do so.
Then NewtonCalculateInertialMatrix will be a function of the Body that will calculate the inertia using the local inertia volume integral of each sub shape and build total instead using the central theorem for calculation offset inertia. This will be right in all cases all the time
I will do this two steps.
first complete changing the scale from global to local and check in. (almost ready)
then go over the inertia calculation.
and I will also add a density to the shape, so that the inertia takes that into account for heterogeneous mass distribution of inertia of compound collisions.