Binary serialization in the .bullet file format (work-in-progress)

This commit is contained in:
erwin.coumans
2009-12-08 18:02:37 +00:00
parent 385c16e309
commit 3edd806b88
14 changed files with 1057 additions and 522 deletions

View File

@@ -310,8 +310,41 @@ public:
}
}
virtual int calculateSerializeBufferSize();
///fills the dataBuffer and returns the struct name (and 0 on failure)
virtual const char* serialize(void* dataBuffer) const;
};
struct btBoxShapeData
{
btVector3Data m_halfExtents;
btVector3Data m_localScaling;
};
SIMD_FORCE_INLINE int btBoxShape::calculateSerializeBufferSize()
{
return sizeof(btBoxShapeData);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btBoxShape::serialize(void* dataBuffer) const
{
btBoxShapeData* boxData = (btBoxShapeData*) dataBuffer;
m_implicitShapeDimensions.serialize(boxData->m_halfExtents);
m_localScaling.serialize(boxData->m_localScaling);
return "btBoxShapeData";
}
#endif //OBB_BOX_MINKOWSKI_H

View File

@@ -21,6 +21,8 @@ subject to the following restrictions:
#include "LinearMath/btMatrix3x3.h"
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
class btCollisionShape
{
@@ -113,5 +115,14 @@ public:
};
///for serialization
struct btCollisionShapeData
{
void *m_userPointer;
int m_shapeType;
char m_padding[4];
};
#endif //COLLISION_SHAPE_H

View File

@@ -47,7 +47,7 @@ public:
void updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index);
/// Data buffer MUST be 16 byte aligned
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian)
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
{
return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian);