more work on serialization (work-in-progress)
This commit is contained in:
@@ -1267,7 +1267,7 @@ void btCollisionWorld::serializeCollisionObjects(btDefaultSerializer* serializer
|
||||
//serialize all collision shapes
|
||||
int len = shape->calculateSerializeBufferSize();
|
||||
btChunk* chunk = serializer->allocate(len,1);
|
||||
const char* structType = shape->serialize(chunk->m_oldPtr);
|
||||
const char* structType = shape->serialize(chunk->m_oldPtr, serializer);
|
||||
chunk->m_dna_nr = serializer->getReverseType(structType);
|
||||
chunk->m_chunkCode = BT_SHAPE_CODE;
|
||||
chunk->m_oldPtr = shape;
|
||||
|
||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/btMatrix3x3.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
|
||||
|
||||
class btDefaultSerializer;
|
||||
|
||||
|
||||
///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
virtual int calculateSerializeBufferSize();
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer) const;
|
||||
virtual const char* serialize(void* dataBuffer, btDefaultSerializer* serializer) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -139,7 +139,7 @@ SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize()
|
||||
}
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
SIMD_FORCE_INLINE const char* btCollisionShape::serialize(void* dataBuffer) const
|
||||
SIMD_FORCE_INLINE const char* btCollisionShape::serialize(void* dataBuffer, btDefaultSerializer* serializer) const
|
||||
{
|
||||
btCollisionShapeData* shapeData = (btCollisionShapeData*) dataBuffer;
|
||||
shapeData->m_userPointer = m_userPointer;
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
virtual int calculateSerializeBufferSize();
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer) const;
|
||||
virtual const char* serialize(void* dataBuffer, btDefaultSerializer* serializer) const;
|
||||
|
||||
|
||||
};
|
||||
@@ -142,10 +142,10 @@ SIMD_FORCE_INLINE int btConvexInternalShape::calculateSerializeBufferSize()
|
||||
}
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
SIMD_FORCE_INLINE const char* btConvexInternalShape::serialize(void* dataBuffer) const
|
||||
SIMD_FORCE_INLINE const char* btConvexInternalShape::serialize(void* dataBuffer, btDefaultSerializer* serializer) const
|
||||
{
|
||||
btConvexInternalShapeData* shapeData = (btConvexInternalShapeData*) dataBuffer;
|
||||
btCollisionShape::serialize(&shapeData->m_collisionShapeData);
|
||||
btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer);
|
||||
|
||||
m_implicitShapeDimensions.serialize(shapeData->m_implicitShapeDimensions);
|
||||
m_localScaling.serialize(shapeData->m_localScaling);
|
||||
|
||||
@@ -18,6 +18,7 @@ subject to the following restrictions:
|
||||
#include "btMultiSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
||||
#include "LinearMath/btQuaternion.h"
|
||||
#include "LinearMath/btSerializer.h"
|
||||
|
||||
btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres)
|
||||
:btConvexInternalAabbCachingShape ()
|
||||
@@ -138,3 +139,41 @@ void btMultiSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||
}
|
||||
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
const char* btMultiSphereShape::serialize(void* dataBuffer, btDefaultSerializer* serializer) const
|
||||
{
|
||||
btMultiSphereShapeData* shapeData = (btMultiSphereShapeData*) dataBuffer;
|
||||
btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData, serializer);
|
||||
|
||||
shapeData->m_localPositionArrayPtr = 0;
|
||||
int numElem = m_localPositionArray.size();
|
||||
|
||||
|
||||
shapeData->m_localPositionArraySize = numElem;
|
||||
if (numElem)
|
||||
{
|
||||
void* oldPtr = (void*)&m_localPositionArray[0].getX();
|
||||
shapeData->m_localPositionArrayPtr = (btVector3Data*)oldPtr;
|
||||
|
||||
int sz = sizeof(btVector3Data);
|
||||
|
||||
btChunk* chunk = serializer->allocate(sz,numElem);
|
||||
const char* structType = "btVector3Data";
|
||||
btVector3Data* memPtr = (btVector3Data*)chunk->m_oldPtr;
|
||||
for (int i=0;i<numElem;i++)
|
||||
{
|
||||
m_localPositionArray[i].serialize(*memPtr);
|
||||
memPtr++;
|
||||
}
|
||||
chunk->m_dna_nr = serializer->getReverseType("btVector3Data");
|
||||
chunk->m_chunkCode = BT_VECTOR3_CODE;
|
||||
chunk->m_oldPtr = oldPtr;
|
||||
}
|
||||
|
||||
shapeData->m_radiArrayPtr = 0;
|
||||
shapeData->m_radiArraySize = 0;
|
||||
|
||||
return "btMultiSphereShapeData";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,8 +61,30 @@ public:
|
||||
return "MultiSphere";
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btDefaultSerializer* serializer) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct btMultiSphereShapeData
|
||||
{
|
||||
btConvexInternalShapeData m_convexInternalShapeData;
|
||||
|
||||
btVector3Data *m_localPositionArrayPtr;
|
||||
btScalar *m_radiArrayPtr;
|
||||
int m_localPositionArraySize;
|
||||
int m_radiArraySize;
|
||||
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btMultiSphereShapeData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //MULTI_SPHERE_MINKOWSKI_H
|
||||
|
||||
Reference in New Issue
Block a user