worked a bit more on the serialization, and added a preliminary SerializeDemo.
This commit is contained in:
@@ -1235,6 +1235,25 @@ void btCollisionWorld::debugDrawWorld()
|
||||
}
|
||||
|
||||
|
||||
void btCollisionWorld::serializeCollisionObjects(btDefaultSerializer* serializer)
|
||||
{
|
||||
int i;
|
||||
//serialize all collision objects
|
||||
for (i=0;i<m_collisionObjects.size();i++)
|
||||
{
|
||||
btCollisionObject* colObj = m_collisionObjects[i];
|
||||
if (colObj->getInternalType() == btCollisionObject::CO_COLLISION_OBJECT)
|
||||
{
|
||||
int len = colObj->calculateSerializeBufferSize();
|
||||
btChunk* chunk = serializer->allocate(len,1);
|
||||
const char* structType = colObj->serialize(chunk->m_oldPtr);
|
||||
chunk->m_dna_nr = serializer->getReverseType(structType);
|
||||
chunk->m_chunkCode = BT_COLLISIONOBJECT_CODE;
|
||||
chunk->m_oldPtr = colObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void btCollisionWorld::serialize(btDefaultSerializer* serializer)
|
||||
{
|
||||
@@ -1252,20 +1271,7 @@ void btCollisionWorld::serialize(btDefaultSerializer* serializer)
|
||||
serializer->initDNA((const char*)sBulletDNAstr,sBulletDNAlen);
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
//serialize all collision objects
|
||||
for (i=0;i<m_collisionObjects.size();i++)
|
||||
{
|
||||
btCollisionObject* colObj = m_collisionObjects[i];
|
||||
int len = colObj->calculateSerializeBufferSize();
|
||||
btChunk* chunk = serializer->allocate(len,1);
|
||||
const char* structType = colObj->serialize(chunk->m_oldPtr);
|
||||
chunk->m_dna_nr = serializer->getReverseType(structType);
|
||||
chunk->m_chunkCode = BT_COLLISIONOBJECT_CODE;
|
||||
chunk->m_oldPtr = colObj;
|
||||
}
|
||||
|
||||
serializeCollisionObjects(serializer);
|
||||
|
||||
#if 0
|
||||
{
|
||||
|
||||
@@ -100,6 +100,8 @@ protected:
|
||||
///it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB)
|
||||
bool m_forceUpdateAllAabbs;
|
||||
|
||||
void serializeCollisionObjects(btDefaultSerializer* serializer);
|
||||
|
||||
public:
|
||||
|
||||
//this constructor doesn't own the dispatcher and paircache/broadphase
|
||||
@@ -422,8 +424,8 @@ public:
|
||||
m_forceUpdateAllAabbs = forceUpdateAllAabbs;
|
||||
}
|
||||
|
||||
///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (to be added in the Bullet/Extras)
|
||||
void serialize(btDefaultSerializer* serializer);
|
||||
///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo)
|
||||
virtual void serialize(btDefaultSerializer* serializer);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ public:
|
||||
|
||||
struct btBoxShapeData
|
||||
{
|
||||
btCollisionShapeData m_collisionShapeData;
|
||||
btVector3Data m_halfExtents;
|
||||
btVector3Data m_localScaling;
|
||||
};
|
||||
@@ -338,6 +339,7 @@ SIMD_FORCE_INLINE int btBoxShape::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE const char* btBoxShape::serialize(void* dataBuffer) const
|
||||
{
|
||||
btBoxShapeData* boxData = (btBoxShapeData*) dataBuffer;
|
||||
btCollisionShape::serialize(&boxData->m_collisionShapeData);
|
||||
|
||||
m_implicitShapeDimensions.serialize(boxData->m_halfExtents);
|
||||
m_localScaling.serialize(boxData->m_localScaling);
|
||||
|
||||
@@ -118,6 +118,11 @@ public:
|
||||
return m_userPointer;
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer) const;
|
||||
|
||||
};
|
||||
|
||||
///for serialization
|
||||
@@ -128,6 +133,20 @@ struct btCollisionShapeData
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btCollisionShapeData);
|
||||
}
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
SIMD_FORCE_INLINE const char* btCollisionShape::serialize(void* dataBuffer) const
|
||||
{
|
||||
btCollisionShapeData* shapeData = (btCollisionShapeData*) dataBuffer;
|
||||
shapeData->m_userPointer = m_userPointer;
|
||||
shapeData->m_shapeType = m_shapeType;
|
||||
//shapeData->m_padding//??
|
||||
return "btCollisionShapeData";
|
||||
}
|
||||
|
||||
#endif //COLLISION_SHAPE_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user