refactor constraint serialization, so that double precision is maintained,

changes are backwards compatible (btBulletWorldImporter can load old .bullet files)
but not forwards compatible (constraints in new .bullet files are ignored/unrecognized by old Bullet SDK)
This commit is for Issue 734. Some more work needs to be done for btGImpactMeshShapeDoubleData and thus btStridingMeshInterfaceDoubleData and btMeshPartDoubleData
This commit is contained in:
erwin.coumans
2013-09-14 06:08:50 +00:00
parent e94a2137b0
commit 1aac33f6b6
16 changed files with 1523 additions and 665 deletions

View File

@@ -52,6 +52,7 @@ bool btBulletWorldImporter::loadFile( const char* fileName, const char* preSwapF
bulletFile2->preSwap();
bulletFile2->writeFile(preSwapFilenameOut);
}
}
delete bulletFile2;
@@ -304,7 +305,10 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
for (i=0;i<bulletFile2->m_constraints.size();i++)
{
btTypedConstraintData* constraintData = (btTypedConstraintData*)bulletFile2->m_constraints[i];
btTypedConstraintData2* constraintData = (btTypedConstraintData2*)bulletFile2->m_constraints[i];
btTypedConstraintFloatData* singleC = (btTypedConstraintFloatData*)bulletFile2->m_constraints[i];
btTypedConstraintDoubleData* doubleC = (btTypedConstraintDoubleData*)bulletFile2->m_constraints[i];
btCollisionObject** colAptr = m_bodyMap.find(constraintData->m_rbA);
btCollisionObject** colBptr = m_bodyMap.find(constraintData->m_rbB);
@@ -327,7 +331,29 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
continue;
bool isDoublePrecisionData = (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)!=0;
convertConstraint(constraintData, rbA,rbB,isDoublePrecisionData, bulletFile2->getVersion());
if (isDoublePrecisionData)
{
if (bulletFile2->getVersion()>=282)
{
btTypedConstraintDoubleData* dc = (btTypedConstraintDoubleData*)constraintData;
convertConstraintDouble(dc, rbA,rbB, bulletFile2->getVersion());
} else
{
//double-precision constraints were messed up until 2.82, try to recover data...
btTypedConstraintData* oldData = (btTypedConstraintData*)constraintData;
convertConstraintBackwardsCompatible281(oldData, rbA,rbB, bulletFile2->getVersion());
}
}
else
{
btTypedConstraintFloatData* dc = (btTypedConstraintFloatData*)constraintData;
convertConstraintFloat(dc, rbA,rbB, bulletFile2->getVersion());
}
}