more work on Bullet serialization (added support for btConvexHullSupport)

This commit is contained in:
erwin.coumans
2010-01-23 00:58:47 +00:00
parent 0f707603f1
commit 5378cf4c8a
16 changed files with 329 additions and 121 deletions

View File

@@ -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";
}

View File

@@ -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

View File

@@ -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";

View File

@@ -1,5 +1,5 @@
unsigned char sBulletDNAstr[]= {
83,68,78,65,78,65,77,69,68,0,0,0,109,95,115,105,122,101,0,109,
83,68,78,65,78,65,77,69,70,0,0,0,109,95,115,105,122,101,0,109,
95,99,97,112,97,99,105,116,121,0,42,109,95,100,97,116,97,0,109,95,
99,111,108,108,105,115,105,111,110,83,104,97,112,101,115,0,109,95,99,111,
108,108,105,115,105,111,110,79,98,106,101,99,116,115,0,109,95,99,111,110,
@@ -16,84 +16,89 @@ unsigned char sBulletDNAstr[]= {
101,120,73,110,116,101,114,110,97,108,83,104,97,112,101,68,97,116,97,0,
42,109,95,108,111,99,97,108,80,111,115,105,116,105,111,110,65,114,114,97,
121,80,116,114,0,109,95,108,111,99,97,108,80,111,115,105,116,105,111,110,
65,114,114,97,121,83,105,122,101,0,109,95,119,111,114,108,100,84,114,97,
110,115,102,111,114,109,0,109,95,105,110,116,101,114,112,111,108,97,116,105,
111,110,87,111,114,108,100,84,114,97,110,115,102,111,114,109,0,109,95,105,
110,116,101,114,112,111,108,97,116,105,111,110,76,105,110,101,97,114,86,101,
108,111,99,105,116,121,0,109,95,105,110,116,101,114,112,111,108,97,116,105,
111,110,65,110,103,117,108,97,114,86,101,108,111,99,105,116,121,0,109,95,
97,110,105,115,111,116,114,111,112,105,99,70,114,105,99,116,105,111,110,0,
109,95,104,97,115,65,110,105,115,111,116,114,111,112,105,99,70,114,105,99,
116,105,111,110,0,109,95,99,111,110,116,97,99,116,80,114,111,99,101,115,
115,105,110,103,84,104,114,101,115,104,111,108,100,0,42,109,95,98,114,111,
97,100,112,104,97,115,101,72,97,110,100,108,101,0,42,109,95,99,111,108,
108,105,115,105,111,110,83,104,97,112,101,0,42,109,95,114,111,111,116,67,
111,108,108,105,115,105,111,110,83,104,97,112,101,0,109,95,99,111,108,108,
105,115,105,111,110,70,108,97,103,115,0,109,95,105,115,108,97,110,100,84,
97,103,49,0,109,95,99,111,109,112,97,110,105,111,110,73,100,0,109,95,
97,99,116,105,118,97,116,105,111,110,83,116,97,116,101,49,0,109,95,100,
101,97,99,116,105,118,97,116,105,111,110,84,105,109,101,0,109,95,102,114,
105,99,116,105,111,110,0,109,95,114,101,115,116,105,116,117,116,105,111,110,
0,109,95,105,110,116,101,114,110,97,108,84,121,112,101,0,42,109,95,117,
115,101,114,79,98,106,101,99,116,80,111,105,110,116,101,114,0,109,95,104,
105,116,70,114,97,99,116,105,111,110,0,109,95,99,99,100,83,119,101,112,
116,83,112,104,101,114,101,82,97,100,105,117,115,0,109,95,99,99,100,77,
111,116,105,111,110,84,104,114,101,115,104,111,108,100,0,109,95,99,104,101,
99,107,67,111,108,108,105,100,101,87,105,116,104,0,109,95,99,111,108,108,
105,115,105,111,110,79,98,106,101,99,116,68,97,116,97,0,109,95,105,110,
118,73,110,101,114,116,105,97,84,101,110,115,111,114,87,111,114,108,100,0,
109,95,108,105,110,101,97,114,86,101,108,111,99,105,116,121,0,109,95,97,
110,103,117,108,97,114,86,101,108,111,99,105,116,121,0,109,95,105,110,118,
101,114,115,101,77,97,115,115,0,109,95,97,110,103,117,108,97,114,70,97,
99,116,111,114,0,109,95,108,105,110,101,97,114,70,97,99,116,111,114,0,
109,95,103,114,97,118,105,116,121,0,109,95,103,114,97,118,105,116,121,95,
97,99,99,101,108,101,114,97,116,105,111,110,0,109,95,105,110,118,73,110,
101,114,116,105,97,76,111,99,97,108,0,109,95,116,111,116,97,108,70,111,
114,99,101,0,109,95,116,111,116,97,108,84,111,114,113,117,101,0,109,95,
108,105,110,101,97,114,68,97,109,112,105,110,103,0,109,95,97,110,103,117,
108,97,114,68,97,109,112,105,110,103,0,109,95,97,100,100,105,116,105,111,
110,97,108,68,97,109,112,105,110,103,0,109,95,97,100,100,105,116,105,111,
110,97,108,68,97,109,112,105,110,103,70,97,99,116,111,114,0,109,95,97,
100,100,105,116,105,111,110,97,108,76,105,110,101,97,114,68,97,109,112,105,
65,114,114,97,121,83,105,122,101,0,42,109,95,117,110,115,99,97,108,101,
100,80,111,105,110,116,115,80,116,114,0,109,95,110,117,109,85,110,115,99,
97,108,101,100,80,111,105,110,116,115,0,109,95,119,111,114,108,100,84,114,
97,110,115,102,111,114,109,0,109,95,105,110,116,101,114,112,111,108,97,116,
105,111,110,87,111,114,108,100,84,114,97,110,115,102,111,114,109,0,109,95,
105,110,116,101,114,112,111,108,97,116,105,111,110,76,105,110,101,97,114,86,
101,108,111,99,105,116,121,0,109,95,105,110,116,101,114,112,111,108,97,116,
105,111,110,65,110,103,117,108,97,114,86,101,108,111,99,105,116,121,0,109,
95,97,110,105,115,111,116,114,111,112,105,99,70,114,105,99,116,105,111,110,
0,109,95,104,97,115,65,110,105,115,111,116,114,111,112,105,99,70,114,105,
99,116,105,111,110,0,109,95,99,111,110,116,97,99,116,80,114,111,99,101,
115,115,105,110,103,84,104,114,101,115,104,111,108,100,0,42,109,95,98,114,
111,97,100,112,104,97,115,101,72,97,110,100,108,101,0,42,109,95,99,111,
108,108,105,115,105,111,110,83,104,97,112,101,0,42,109,95,114,111,111,116,
67,111,108,108,105,115,105,111,110,83,104,97,112,101,0,109,95,99,111,108,
108,105,115,105,111,110,70,108,97,103,115,0,109,95,105,115,108,97,110,100,
84,97,103,49,0,109,95,99,111,109,112,97,110,105,111,110,73,100,0,109,
95,97,99,116,105,118,97,116,105,111,110,83,116,97,116,101,49,0,109,95,
100,101,97,99,116,105,118,97,116,105,111,110,84,105,109,101,0,109,95,102,
114,105,99,116,105,111,110,0,109,95,114,101,115,116,105,116,117,116,105,111,
110,0,109,95,105,110,116,101,114,110,97,108,84,121,112,101,0,42,109,95,
117,115,101,114,79,98,106,101,99,116,80,111,105,110,116,101,114,0,109,95,
104,105,116,70,114,97,99,116,105,111,110,0,109,95,99,99,100,83,119,101,
112,116,83,112,104,101,114,101,82,97,100,105,117,115,0,109,95,99,99,100,
77,111,116,105,111,110,84,104,114,101,115,104,111,108,100,0,109,95,99,104,
101,99,107,67,111,108,108,105,100,101,87,105,116,104,0,109,95,99,111,108,
108,105,115,105,111,110,79,98,106,101,99,116,68,97,116,97,0,109,95,105,
110,118,73,110,101,114,116,105,97,84,101,110,115,111,114,87,111,114,108,100,
0,109,95,108,105,110,101,97,114,86,101,108,111,99,105,116,121,0,109,95,
97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,0,109,95,105,110,
118,101,114,115,101,77,97,115,115,0,109,95,97,110,103,117,108,97,114,70,
97,99,116,111,114,0,109,95,108,105,110,101,97,114,70,97,99,116,111,114,
0,109,95,103,114,97,118,105,116,121,0,109,95,103,114,97,118,105,116,121,
95,97,99,99,101,108,101,114,97,116,105,111,110,0,109,95,105,110,118,73,
110,101,114,116,105,97,76,111,99,97,108,0,109,95,116,111,116,97,108,70,
111,114,99,101,0,109,95,116,111,116,97,108,84,111,114,113,117,101,0,109,
95,108,105,110,101,97,114,68,97,109,112,105,110,103,0,109,95,97,110,103,
117,108,97,114,68,97,109,112,105,110,103,0,109,95,97,100,100,105,116,105,
111,110,97,108,68,97,109,112,105,110,103,0,109,95,97,100,100,105,116,105,
111,110,97,108,68,97,109,112,105,110,103,70,97,99,116,111,114,0,109,95,
97,100,100,105,116,105,111,110,97,108,76,105,110,101,97,114,68,97,109,112,
105,110,103,84,104,114,101,115,104,111,108,100,83,113,114,0,109,95,97,100,
100,105,116,105,111,110,97,108,65,110,103,117,108,97,114,68,97,109,112,105,
110,103,84,104,114,101,115,104,111,108,100,83,113,114,0,109,95,97,100,100,
105,116,105,111,110,97,108,65,110,103,117,108,97,114,68,97,109,112,105,110,
103,84,104,114,101,115,104,111,108,100,83,113,114,0,109,95,97,100,100,105,
116,105,111,110,97,108,65,110,103,117,108,97,114,68,97,109,112,105,110,103,
70,97,99,116,111,114,0,109,95,108,105,110,101,97,114,83,108,101,101,112,
105,110,103,84,104,114,101,115,104,111,108,100,0,109,95,97,110,103,117,108,
97,114,83,108,101,101,112,105,110,103,84,104,114,101,115,104,111,108,100,0,
84,89,80,69,23,0,0,0,99,104,97,114,0,117,99,104,97,114,0,115,
104,111,114,116,0,117,115,104,111,114,116,0,105,110,116,0,108,111,110,103,
0,117,108,111,110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0,
118,111,105,100,0,98,116,83,99,97,108,97,114,0,80,111,105,110,116,101,
114,65,114,114,97,121,0,98,116,80,104,121,115,105,99,115,83,121,115,116,
101,109,0,76,105,115,116,66,97,115,101,0,98,116,86,101,99,116,111,114,
51,68,97,116,97,0,98,116,77,97,116,114,105,120,51,120,51,68,97,116,
97,0,98,116,84,114,97,110,115,102,111,114,109,68,97,116,97,0,98,116,
67,111,108,108,105,115,105,111,110,83,104,97,112,101,68,97,116,97,0,98,
116,67,111,110,118,101,120,73,110,116,101,114,110,97,108,83,104,97,112,101,
68,97,116,97,0,98,116,80,111,115,105,116,105,111,110,65,110,100,82,97,
100,105,117,115,0,98,116,77,117,108,116,105,83,112,104,101,114,101,83,104,
97,112,101,68,97,116,97,0,98,116,67,111,108,108,105,115,105,111,110,79,
98,106,101,99,116,68,97,116,97,0,98,116,82,105,103,105,100,66,111,100,
121,68,97,116,97,0,0,0,84,76,69,78,1,0,1,0,2,0,2,0,
4,0,4,0,4,0,4,0,8,0,0,0,4,0,12,0,36,0,8,0,
16,0,48,0,64,0,12,0,52,0,20,0,64,0,-8,0,-32,1,0,0,
83,84,82,67,12,0,0,0,11,0,3,0,4,0,0,0,4,0,1,0,
9,0,2,0,12,0,3,0,11,0,3,0,11,0,4,0,11,0,5,0,
13,0,2,0,9,0,6,0,9,0,7,0,14,0,1,0,10,0,8,0,
15,0,1,0,14,0,9,0,16,0,2,0,15,0,10,0,14,0,11,0,
17,0,3,0,9,0,12,0,4,0,13,0,0,0,14,0,18,0,5,0,
17,0,15,0,14,0,16,0,14,0,17,0,10,0,18,0,0,0,14,0,
19,0,2,0,14,0,19,0,10,0,20,0,20,0,4,0,18,0,21,0,
19,0,22,0,4,0,23,0,0,0,14,0,21,0,23,0,16,0,24,0,
16,0,25,0,14,0,26,0,14,0,27,0,14,0,28,0,4,0,29,0,
10,0,30,0,9,0,31,0,9,0,32,0,17,0,33,0,4,0,34,0,
4,0,35,0,4,0,36,0,4,0,37,0,10,0,38,0,10,0,39,0,
10,0,40,0,4,0,41,0,9,0,42,0,10,0,43,0,10,0,44,0,
10,0,45,0,4,0,46,0,22,0,21,0,21,0,47,0,15,0,48,0,
14,0,49,0,14,0,50,0,10,0,51,0,14,0,52,0,14,0,53,0,
14,0,54,0,14,0,55,0,14,0,56,0,14,0,57,0,14,0,58,0,
10,0,59,0,10,0,60,0,4,0,61,0,10,0,62,0,10,0,63,0,
10,0,64,0,10,0,65,0,10,0,66,0,10,0,67,0,};
103,70,97,99,116,111,114,0,109,95,108,105,110,101,97,114,83,108,101,101,
112,105,110,103,84,104,114,101,115,104,111,108,100,0,109,95,97,110,103,117,
108,97,114,83,108,101,101,112,105,110,103,84,104,114,101,115,104,111,108,100,
0,0,0,0,84,89,80,69,24,0,0,0,99,104,97,114,0,117,99,104,
97,114,0,115,104,111,114,116,0,117,115,104,111,114,116,0,105,110,116,0,
108,111,110,103,0,117,108,111,110,103,0,102,108,111,97,116,0,100,111,117,
98,108,101,0,118,111,105,100,0,98,116,83,99,97,108,97,114,0,80,111,
105,110,116,101,114,65,114,114,97,121,0,98,116,80,104,121,115,105,99,115,
83,121,115,116,101,109,0,76,105,115,116,66,97,115,101,0,98,116,86,101,
99,116,111,114,51,68,97,116,97,0,98,116,77,97,116,114,105,120,51,120,
51,68,97,116,97,0,98,116,84,114,97,110,115,102,111,114,109,68,97,116,
97,0,98,116,67,111,108,108,105,115,105,111,110,83,104,97,112,101,68,97,
116,97,0,98,116,67,111,110,118,101,120,73,110,116,101,114,110,97,108,83,
104,97,112,101,68,97,116,97,0,98,116,80,111,115,105,116,105,111,110,65,
110,100,82,97,100,105,117,115,0,98,116,77,117,108,116,105,83,112,104,101,
114,101,83,104,97,112,101,68,97,116,97,0,98,116,67,111,110,118,101,120,
72,117,108,108,83,104,97,112,101,68,97,116,97,0,98,116,67,111,108,108,
105,115,105,111,110,79,98,106,101,99,116,68,97,116,97,0,98,116,82,105,
103,105,100,66,111,100,121,68,97,116,97,0,84,76,69,78,1,0,1,0,
2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0,4,0,12,0,
36,0,8,0,16,0,48,0,64,0,12,0,52,0,20,0,64,0,64,0,
-8,0,-32,1,83,84,82,67,13,0,0,0,11,0,3,0,4,0,0,0,
4,0,1,0,9,0,2,0,12,0,3,0,11,0,3,0,11,0,4,0,
11,0,5,0,13,0,2,0,9,0,6,0,9,0,7,0,14,0,1,0,
10,0,8,0,15,0,1,0,14,0,9,0,16,0,2,0,15,0,10,0,
14,0,11,0,17,0,3,0,9,0,12,0,4,0,13,0,0,0,14,0,
18,0,5,0,17,0,15,0,14,0,16,0,14,0,17,0,10,0,18,0,
0,0,14,0,19,0,2,0,14,0,19,0,10,0,20,0,20,0,4,0,
18,0,21,0,19,0,22,0,4,0,23,0,0,0,14,0,21,0,4,0,
18,0,21,0,14,0,24,0,4,0,25,0,0,0,14,0,22,0,23,0,
16,0,26,0,16,0,27,0,14,0,28,0,14,0,29,0,14,0,30,0,
4,0,31,0,10,0,32,0,9,0,33,0,9,0,34,0,17,0,35,0,
4,0,36,0,4,0,37,0,4,0,38,0,4,0,39,0,10,0,40,0,
10,0,41,0,10,0,42,0,4,0,43,0,9,0,44,0,10,0,45,0,
10,0,46,0,10,0,47,0,4,0,48,0,23,0,21,0,22,0,49,0,
15,0,50,0,14,0,51,0,14,0,52,0,10,0,53,0,14,0,54,0,
14,0,55,0,14,0,56,0,14,0,57,0,14,0,58,0,14,0,59,0,
14,0,60,0,10,0,61,0,10,0,62,0,4,0,63,0,10,0,64,0,
10,0,65,0,10,0,66,0,10,0,67,0,10,0,68,0,10,0,69,0,
};
int sBulletDNAlen= sizeof(sBulletDNAstr);