more work on Bullet serialization (added support for btConvexHullSupport)
This commit is contained in:
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
||||
|
||||
#include "LinearMath/btQuaternion.h"
|
||||
|
||||
#include "LinearMath/btSerializer.h"
|
||||
|
||||
btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexAabbCachingShape ()
|
||||
{
|
||||
@@ -186,3 +186,28 @@ bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
const char* btConvexHullShape::serialize(void* dataBuffer, btSerializer* serializer) const
|
||||
{
|
||||
btConvexHullShapeData* shapeData = (btConvexHullShapeData*) dataBuffer;
|
||||
btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData, serializer);
|
||||
|
||||
int numElem = m_unscaledPoints.size();
|
||||
shapeData->m_numUnscaledPoints = numElem;
|
||||
shapeData->m_unscaledPointsPtr = numElem ? (btVector3Data*)&m_unscaledPoints[0]: 0;
|
||||
|
||||
if (numElem)
|
||||
{
|
||||
btChunk* chunk = serializer->allocate(sizeof(btVector3Data),numElem);
|
||||
btVector3Data* memPtr = (btVector3Data*)chunk->m_oldPtr;
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
m_unscaledPoints[i].serialize(*memPtr);
|
||||
}
|
||||
serializer->finalizeChunk(chunk,"btVector3Data",BT_ARRAY_CODE,(void*)&m_unscaledPoints[0]);
|
||||
}
|
||||
|
||||
return "btConvexHullShapeData";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,8 +89,29 @@ public:
|
||||
///in case we receive negative scaling
|
||||
virtual void setLocalScaling(const btVector3& scaling);
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct btConvexHullShapeData
|
||||
{
|
||||
btConvexInternalShapeData m_convexInternalShapeData;
|
||||
|
||||
btVector3Data *m_unscaledPointsPtr;
|
||||
int m_numUnscaledPoints;
|
||||
char m_padding[4];
|
||||
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btConvexHullShapeData);
|
||||
}
|
||||
|
||||
|
||||
#endif //CONVEX_HULL_SHAPE_H
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ const char* btMultiSphereShape::serialize(void* dataBuffer, btSerializer* serial
|
||||
m_localPositionArray[i].serialize(memPtr->m_pos);
|
||||
memPtr->m_radius = m_radiArray[i];
|
||||
}
|
||||
serializer->finalizeChunk(chunk,"btVector3Data",BT_ARRAY_CODE,(void*)&m_localPositionArray[0]);
|
||||
serializer->finalizeChunk(chunk,"btPositionAndRadius",BT_ARRAY_CODE,(void*)&m_localPositionArray[0]);
|
||||
}
|
||||
|
||||
return "btMultiSphereShapeData";
|
||||
|
||||
Reference in New Issue
Block a user