Closed GoogleCodeExporter closed 8 years ago
Since then we managed to check the inertia problem in
btWorldImporter::convertRigidBodyFloat/Double. We suggest to use the saved
inertia members (colObjData->m_invInertiaLocal and
colObjData->m_invInertiaTensorWorld) instead of recalculating those because of
the following reasons:
- btWorldImporter::createRigidBody uses the
btCollisionObject::setWorldTransform function of the created rigid body to set
its world/center of mass transformation, but this function does not update the
inertia tensor (contrary to btRigidBody::setCenterOfMassTransform). This way
the inertia tensor will not be restored correctly.
Though it is true that calling the btRigidBody::updateInertiaTensor would be
enough after setting the world transform of the newly created rigid body, but
it would not solve the second problem that follows.
- there are cases when the original mass can not be restored from the inverse
mass because of finite floating point precision. In this case considering the
usual setup of inertia and mass (see below), the mass can not be restored
exactly from saved data and this way the localInertia can not be restored
exactly:
// Creating rigid body having a btScalar mass, a btCollisionShape* shape
btVector3 localInertia;
localInertia.setZero();
if (mass)
shape->calculateLocalInertia(mass,localInertia); // Local inertia is calculated from mass
btRigidBody* body = new btRigidBody(mass,0,shape,localInertia); // btRigidBody only stores inverse mass
...
// This is how btWorldImporter tries to restore it:
btScalar mass = btScalar(colObjData->m_inverseMass? 1.f/colObjData->m_inverseMass : 0.f);
...
btVector3 localInertia;
localInertia.setZero();
if (mass)
shape->calculateLocalInertia(mass,localInertia); // Problem here, mass is not the same as when rigid body was created
btRigidBody* body = new btRigidBody(mass,0,shape,localInertia); // No real problem here, 1 / mass will evaluate to the same as when created
We attached a patch where the inertia is deserialized to the created rigid body
based on the original revision 2712 but we can also provide a patch where all
the serialization modifications are included if needed.
Original comment by nsark...@gmail.com
on 13 Nov 2013 at 12:49
Attachments:
That is a long wall of text, I hope to find some time to digest and test all.
>> or the makesdna should be improved to give a warning/error
>>about this case and a special padding member should be used
Yes, we need new padding rules/warnings for double-precision to avoid issues
indeed.
Original comment by erwin.coumans
on 17 Nov 2013 at 8:16
moved to github https://github.com/bulletphysics/bullet3/issues/74
Original comment by erwin.coumans
on 30 Mar 2014 at 5:36
Original issue reported on code.google.com by
nsark...@gmail.com
on 11 Nov 2013 at 3:40Attachments: