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

@@ -24,11 +24,11 @@ class btRigidBody;
#ifdef BT_USE_DOUBLE_PRECISION
#define btPoint2PointConstraintData btPoint2PointConstraintDoubleData
#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData"
#define btPoint2PointConstraintData2 btPoint2PointConstraintDoubleData2
#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData2"
#else
#define btPoint2PointConstraintData btPoint2PointConstraintFloatData
#define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData"
#define btPoint2PointConstraintData2 btPoint2PointConstraintFloatData2
#define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData2"
#endif //BT_USE_DOUBLE_PRECISION
struct btConstraintSetting
@@ -126,6 +126,24 @@ public:
};
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btPoint2PointConstraintFloatData2
{
btTypedConstraintFloatData m_typeConstraintData;
btVector3FloatData m_pivotInA;
btVector3FloatData m_pivotInB;
};
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btPoint2PointConstraintDoubleData2
{
btTypedConstraintDoubleData m_typeConstraintData;
btVector3DoubleData m_pivotInA;
btVector3DoubleData m_pivotInB;
};
#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
///this structure is not used, except for loading pre-2.82 .bullet files
struct btPoint2PointConstraintFloatData
{
btTypedConstraintData m_typeConstraintData;
@@ -140,18 +158,19 @@ struct btPoint2PointConstraintDoubleData
btVector3DoubleData m_pivotInA;
btVector3DoubleData m_pivotInB;
};
#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
SIMD_FORCE_INLINE int btPoint2PointConstraint::calculateSerializeBufferSize() const
{
return sizeof(btPoint2PointConstraintData);
return sizeof(btPoint2PointConstraintData2);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
{
btPoint2PointConstraintData* p2pData = (btPoint2PointConstraintData*)dataBuffer;
btPoint2PointConstraintData2* p2pData = (btPoint2PointConstraintData2*)dataBuffer;
btTypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
m_pivotInA.serialize(p2pData->m_pivotInA);