added serialization support for btCompoundShape, btCapsuleShapeX/Z, btCylinderShapeX,Z
make some serialization methods const prepare for constraint serialization
This commit is contained in:
@@ -88,6 +88,13 @@ public:
|
||||
m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
|
||||
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
///btCapsuleShapeX represents a capsule around the Z axis
|
||||
@@ -125,5 +132,30 @@ public:
|
||||
};
|
||||
|
||||
|
||||
struct btCapsuleShapeData
|
||||
{
|
||||
btConvexInternalShapeData m_convexInternalShapeData;
|
||||
|
||||
int m_upAxis;
|
||||
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE int btCapsuleShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btCapsuleShapeData);
|
||||
}
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
SIMD_FORCE_INLINE const char* btCapsuleShape::serialize(void* dataBuffer, btSerializer* serializer) const
|
||||
{
|
||||
btCapsuleShapeData* shapeData = (btCapsuleShapeData*) dataBuffer;
|
||||
|
||||
btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
|
||||
|
||||
shapeData->m_upAxis = m_upAxis;
|
||||
|
||||
return "btCapsuleShapeData";
|
||||
}
|
||||
|
||||
#endif //BT_CAPSULE_SHAPE_H
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
return m_userPointer;
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
@@ -133,7 +133,7 @@ struct btCollisionShapeData
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btCollisionShapeData);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ subject to the following restrictions:
|
||||
#include "btCompoundShape.h"
|
||||
#include "btCollisionShape.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btDbvt.h"
|
||||
#include "LinearMath/btSerializer.h"
|
||||
|
||||
btCompoundShape::btCompoundShape(bool enableDynamicAabbTree)
|
||||
: m_localAabbMin(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)),
|
||||
@@ -278,5 +279,36 @@ void btCompoundShape::setLocalScaling(const btVector3& scaling)
|
||||
updateChildTransform(i, childTrans);
|
||||
recalculateLocalAabb();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
const char* btCompoundShape::serialize(void* dataBuffer, btSerializer* serializer) const
|
||||
{
|
||||
|
||||
btCompoundShapeData* shapeData = (btCompoundShapeData*) dataBuffer;
|
||||
btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer);
|
||||
|
||||
shapeData->m_collisionMargin = float(m_collisionMargin);
|
||||
shapeData->m_numChildShapes = m_children.size();
|
||||
shapeData->m_childShapePtr = 0;
|
||||
if (shapeData->m_numChildShapes)
|
||||
{
|
||||
btChunk* chunk = serializer->allocate(sizeof(btCompoundShapeChildData),shapeData->m_numChildShapes);
|
||||
btCompoundShapeChildData* memPtr = (btCompoundShapeChildData*)chunk->m_oldPtr;
|
||||
shapeData->m_childShapePtr = memPtr;
|
||||
|
||||
for (int i=0;i<shapeData->m_numChildShapes;i++,memPtr++)
|
||||
{
|
||||
memPtr->m_childMargin = float(m_children[i].m_childMargin);
|
||||
memPtr->m_childShape = (btCollisionShapeData*)m_children[i].m_childShape;
|
||||
memPtr->m_childShapeType = m_children[i].m_childShapeType;
|
||||
m_children[i].m_transform.serializeFloat(memPtr->m_transform);
|
||||
}
|
||||
serializer->finalizeChunk(chunk,"btCompoundShapeChildData",BT_ARRAY_CODE,chunk->m_oldPtr);
|
||||
}
|
||||
return "btCompoundShapeData";
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,11 @@ ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape
|
||||
///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
|
||||
int m_updateRevision;
|
||||
|
||||
btScalar m_collisionMargin;
|
||||
|
||||
protected:
|
||||
btVector3 m_localScaling;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
@@ -158,13 +163,46 @@ public:
|
||||
return m_updateRevision;
|
||||
}
|
||||
|
||||
private:
|
||||
btScalar m_collisionMargin;
|
||||
protected:
|
||||
btVector3 m_localScaling;
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct btCompoundShapeChildData
|
||||
{
|
||||
btTransformFloatData m_transform;
|
||||
btCollisionShapeData *m_childShape;
|
||||
int m_childShapeType;
|
||||
float m_childMargin;
|
||||
};
|
||||
|
||||
|
||||
struct btCompoundShapeData
|
||||
{
|
||||
btCollisionShapeData m_collisionShapeData;
|
||||
|
||||
btCompoundShapeChildData *m_childShapePtr;
|
||||
|
||||
int m_numChildShapes;
|
||||
|
||||
float m_collisionMargin;
|
||||
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btCompoundShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btCompoundShapeData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //COMPOUND_SHAPE_H
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
///in case we receive negative scaling
|
||||
virtual void setLocalScaling(const btVector3& scaling);
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
@@ -110,7 +110,7 @@ struct btConvexHullShapeData
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btConvexHullShapeData);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
@@ -135,7 +135,7 @@ struct btConvexInternalShapeData
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btConvexInternalShape::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE int btConvexInternalShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btConvexInternalShapeData);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,10 @@ public:
|
||||
return "CylinderY";
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -157,5 +160,33 @@ public:
|
||||
};
|
||||
|
||||
|
||||
struct btCylinderShapeData
|
||||
{
|
||||
btConvexInternalShapeData m_convexInternalShapeData;
|
||||
|
||||
int m_upAxis;
|
||||
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE int btCylinderShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btCylinderShapeData);
|
||||
}
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
SIMD_FORCE_INLINE const char* btCylinderShape::serialize(void* dataBuffer, btSerializer* serializer) const
|
||||
{
|
||||
btCylinderShapeData* shapeData = (btCylinderShapeData*) dataBuffer;
|
||||
|
||||
btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
|
||||
|
||||
shapeData->m_upAxis = m_upAxis;
|
||||
|
||||
return "btCylinderShapeData";
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //CYLINDER_MINKOWSKI_H
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
return "MultiSphere";
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
@@ -89,7 +89,7 @@ struct btMultiSphereShapeData
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btMultiSphereShapeData);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class btStridingMeshInterface
|
||||
m_scaling = scaling;
|
||||
}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
@@ -132,7 +132,7 @@ struct btStridingMeshInterfaceData
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btStridingMeshInterface::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE int btStridingMeshInterface::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btStridingMeshInterfaceData);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
//debugging
|
||||
virtual const char* getName()const {return "TRIANGLEMESH";}
|
||||
|
||||
virtual int calculateSerializeBufferSize();
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
@@ -101,7 +101,7 @@ struct btTriangleMeshShapeData
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btTriangleMeshShape::calculateSerializeBufferSize()
|
||||
SIMD_FORCE_INLINE int btTriangleMeshShape::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btTriangleMeshShapeData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user