add support for double precision and 64bit serialization (and compatibility between all versions)
fix some issue in serialization of nested array data add some tesing files
This commit is contained in:
@@ -189,22 +189,32 @@ bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
const char* btConvexHullShape::serialize(void* dataBuffer, btSerializer* serializer) const
|
||||
{
|
||||
int szc = sizeof(btConvexHullShapeData);
|
||||
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;
|
||||
#ifdef BT_USE_DOUBLE_PRECISION
|
||||
shapeData->m_unscaledPointsFloatPtr = 0;
|
||||
shapeData->m_unscaledPointsDoublePtr = numElem ? (btVector3Data*)&m_unscaledPoints[0]: 0;
|
||||
#else
|
||||
shapeData->m_unscaledPointsFloatPtr = numElem ? (btVector3Data*)&m_unscaledPoints[0]: 0;
|
||||
shapeData->m_unscaledPointsDoublePtr = 0;
|
||||
#endif
|
||||
|
||||
if (numElem)
|
||||
{
|
||||
btChunk* chunk = serializer->allocate(sizeof(btVector3Data),numElem);
|
||||
int sz = sizeof(btVector3Data);
|
||||
int sz2 = sizeof(btVector3DoubleData);
|
||||
int sz3 = sizeof(btVector3FloatData);
|
||||
btChunk* chunk = serializer->allocate(sz,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]);
|
||||
serializer->finalizeChunk(chunk,btVector3DataName,BT_ARRAY_CODE,(void*)&m_unscaledPoints[0]);
|
||||
}
|
||||
|
||||
return "btConvexHullShapeData";
|
||||
|
||||
@@ -101,12 +101,15 @@ struct btConvexHullShapeData
|
||||
{
|
||||
btConvexInternalShapeData m_convexInternalShapeData;
|
||||
|
||||
btVector3Data *m_unscaledPointsPtr;
|
||||
btVector3FloatData *m_unscaledPointsFloatPtr;
|
||||
btVector3DoubleData *m_unscaledPointsDoublePtr;
|
||||
|
||||
int m_numUnscaledPoints;
|
||||
char m_padding[4];
|
||||
char m_padding3[4];
|
||||
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btConvexHullShapeData);
|
||||
|
||||
@@ -19,6 +19,7 @@ subject to the following restrictions:
|
||||
#include "btConvexShape.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
|
||||
|
||||
///The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
|
||||
class btConvexInternalShape : public btConvexShape
|
||||
{
|
||||
@@ -118,19 +119,17 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct btConvexInternalShapeData
|
||||
{
|
||||
btCollisionShapeData m_collisionShapeData;
|
||||
|
||||
btVector3Data m_localScaling;
|
||||
btVector3FloatData m_localScaling;
|
||||
|
||||
btVector3Data m_implicitShapeDimensions;
|
||||
btVector3FloatData m_implicitShapeDimensions;
|
||||
|
||||
btScalar m_collisionMargin;
|
||||
float m_collisionMargin;
|
||||
|
||||
char m_padding[4];
|
||||
int m_padding;
|
||||
|
||||
};
|
||||
|
||||
@@ -147,9 +146,9 @@ SIMD_FORCE_INLINE const char* btConvexInternalShape::serialize(void* dataBuffer,
|
||||
btConvexInternalShapeData* shapeData = (btConvexInternalShapeData*) dataBuffer;
|
||||
btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer);
|
||||
|
||||
m_implicitShapeDimensions.serialize(shapeData->m_implicitShapeDimensions);
|
||||
m_localScaling.serialize(shapeData->m_localScaling);
|
||||
shapeData->m_collisionMargin = m_collisionMargin;
|
||||
m_implicitShapeDimensions.serializeFloat(shapeData->m_implicitShapeDimensions);
|
||||
m_localScaling.serializeFloat(shapeData->m_localScaling);
|
||||
shapeData->m_collisionMargin = float(m_collisionMargin);
|
||||
|
||||
return "btConvexInternalShapeData";
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ const char* btMultiSphereShape::serialize(void* dataBuffer, btSerializer* serial
|
||||
btPositionAndRadius* memPtr = (btPositionAndRadius*)chunk->m_oldPtr;
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
m_localPositionArray[i].serialize(memPtr->m_pos);
|
||||
memPtr->m_radius = m_radiArray[i];
|
||||
m_localPositionArray[i].serializeFloat(memPtr->m_pos);
|
||||
memPtr->m_radius = float(m_radiArray[i]);
|
||||
}
|
||||
serializer->finalizeChunk(chunk,"btPositionAndRadius",BT_ARRAY_CODE,(void*)&m_localPositionArray[0]);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
|
||||
|
||||
|
||||
///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes.
|
||||
///It is possible to animate the spheres for deformation, but call 'recalcLocalAabb' after changing any sphere position/radius
|
||||
class btMultiSphereShape : public btConvexInternalAabbCachingShape
|
||||
@@ -69,10 +71,11 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct btPositionAndRadius
|
||||
{
|
||||
btVector3Data m_pos;
|
||||
btScalar m_radius;
|
||||
btVector3FloatData m_pos;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
struct btMultiSphereShapeData
|
||||
@@ -82,9 +85,10 @@ struct btMultiSphereShapeData
|
||||
btPositionAndRadius *m_localPositionArrayPtr;
|
||||
int m_localPositionArraySize;
|
||||
char m_padding[4];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btMultiSphereShapeData);
|
||||
|
||||
@@ -327,6 +327,6 @@ const char* btStridingMeshInterface::serialize(void* dataBuffer, btSerializer* s
|
||||
}
|
||||
|
||||
|
||||
m_scaling.serialize(trimeshData->m_scaling);
|
||||
m_scaling.serializeFloat(trimeshData->m_scaling);
|
||||
return "btStridingMeshInterfaceData";
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// The btStridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
|
||||
/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
|
||||
/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
|
||||
@@ -118,19 +120,18 @@ struct btMeshPartData
|
||||
int m_numVertices;
|
||||
};
|
||||
|
||||
|
||||
struct btStridingMeshInterfaceData
|
||||
{
|
||||
btMeshPartData *m_meshPartsPtr;
|
||||
|
||||
btVector3FloatData m_scaling;
|
||||
int m_numMeshParts;
|
||||
|
||||
btVector3Data m_scaling;
|
||||
|
||||
char m_padding[4];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btStridingMeshInterface::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btStridingMeshInterfaceData);
|
||||
|
||||
@@ -218,7 +218,7 @@ const char* btTriangleMeshShape::serialize(void* dataBuffer, btSerializer* seria
|
||||
|
||||
m_meshInterface->serialize(&trimeshData->m_meshInterface, serializer);
|
||||
|
||||
trimeshData->m_collisionMargin = m_collisionMargin;
|
||||
trimeshData->m_collisionMargin = float(m_collisionMargin);
|
||||
|
||||
return "btTriangleMeshShapeData";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ subject to the following restrictions:
|
||||
#include "btStridingMeshInterface.h"
|
||||
|
||||
|
||||
|
||||
///The btTriangleMeshShape is an internal concave triangle mesh interface. Don't use this class directly, use btBvhTriangleMeshShape instead.
|
||||
class btTriangleMeshShape : public btConcaveShape
|
||||
{
|
||||
@@ -90,14 +91,16 @@ public:
|
||||
|
||||
struct btTriangleMeshShapeData
|
||||
{
|
||||
//btConcaveShapeData m_concaveShapeData;
|
||||
btCollisionShapeData m_collisionShapeData;
|
||||
|
||||
btStridingMeshInterfaceData m_meshInterface;
|
||||
|
||||
btScalar m_collisionMargin;
|
||||
float m_collisionMargin;
|
||||
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btTriangleMeshShape::calculateSerializeBufferSize()
|
||||
{
|
||||
return sizeof(btTriangleMeshShapeData);
|
||||
|
||||
Reference in New Issue
Block a user