for for btBvhTriangleMeshShape with short int indices serialization
disable bvh serialization, it has issues (needs testing)
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include "bullet_btPositionAndRadius.h"
|
||||
#include "bullet_btMultiSphereShapeData.h"
|
||||
#include "bullet_btIntIndexData.h"
|
||||
#include "bullet_btShortIntIndexData.h"
|
||||
#include "bullet_btShortIntIndexTripletData.h"
|
||||
#include "bullet_btMeshPartData.h"
|
||||
#include "bullet_btStridingMeshInterfaceData.h"
|
||||
#include "bullet_btTriangleMeshShapeData.h"
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Bullet {
|
||||
class btPositionAndRadius;
|
||||
class btMultiSphereShapeData;
|
||||
class btIntIndexData;
|
||||
class btShortIntIndexData;
|
||||
class btShortIntIndexTripletData;
|
||||
class btMeshPartData;
|
||||
class btStridingMeshInterfaceData;
|
||||
class btTriangleMeshShapeData;
|
||||
|
||||
@@ -33,9 +33,7 @@ namespace Bullet {
|
||||
public:
|
||||
int m_rootNodeIndex;
|
||||
int m_subtreeSize;
|
||||
short int;
|
||||
short m_quantizedAabbMin[3];
|
||||
short int;
|
||||
short m_quantizedAabbMax[3];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Bullet {
|
||||
btVector3FloatData *m_vertices3f;
|
||||
btVector3DoubleData *m_vertices3d;
|
||||
btIntIndexData *m_indices32;
|
||||
btShortIntIndexData *m_indices16;
|
||||
btShortIntIndexTripletData *m_3indices16;
|
||||
int m_numTriangles;
|
||||
int m_numVertices;
|
||||
};
|
||||
|
||||
@@ -31,11 +31,9 @@ namespace Bullet {
|
||||
class btQuantizedBvhNodeData
|
||||
{
|
||||
public:
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
short int;
|
||||
short m_quantizedAabbMin[3];
|
||||
short int;
|
||||
short m_quantizedAabbMax[3];
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// Auto generated from makesdna dna.c
|
||||
#ifndef __BULLET_BTSHORTINTINDEXDATA__H__
|
||||
#define __BULLET_BTSHORTINTINDEXDATA__H__
|
||||
#ifndef __BULLET_BTSHORTINTINDEXTRIPLETDATA__H__
|
||||
#define __BULLET_BTSHORTINTINDEXTRIPLETDATA__H__
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
@@ -28,13 +28,13 @@ namespace Bullet {
|
||||
|
||||
|
||||
// ---------------------------------------------- //
|
||||
class btShortIntIndexData
|
||||
class btShortIntIndexTripletData
|
||||
{
|
||||
public:
|
||||
short int;
|
||||
short m_value;
|
||||
short m_values[3];
|
||||
char m_pad[2];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BULLET_BTSHORTINTINDEXDATA__H__
|
||||
#endif//__BULLET_BTSHORTINTINDEXTRIPLETDATA__H__
|
||||
@@ -23,6 +23,8 @@ subject to the following restrictions:
|
||||
#define MAX_ARRAY_LENGTH 512
|
||||
using namespace bParse;
|
||||
|
||||
//this define will force traversal of structures, to check backward (and forward) compatibility
|
||||
//#define TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||
|
||||
int numallocs = 0;
|
||||
|
||||
@@ -260,7 +262,11 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
||||
|
||||
|
||||
|
||||
#ifdef TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||
if (1)
|
||||
#else
|
||||
if (!mFileDNA->flagEqual(dataChunk.dna_nr))
|
||||
#endif
|
||||
{
|
||||
// Ouch! need to rebuild the struct
|
||||
short *oldStruct,*curStruct;
|
||||
@@ -938,7 +944,11 @@ void bFile::resolvePointers(bool verboseDumpAllBlocks)
|
||||
{
|
||||
const bChunkInd& dataChunk = m_chunks.at(i);
|
||||
|
||||
#ifdef TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||
if (1)
|
||||
#else
|
||||
if (!mFileDNA || fileDna->flagEqual(dataChunk.dna_nr))
|
||||
#endif
|
||||
{
|
||||
//dataChunk.len
|
||||
short int* oldStruct = fileDna->getStruct(dataChunk.dna_nr);
|
||||
|
||||
@@ -106,8 +106,8 @@ btTriangleIndexVertexArray* btBulletWorldImporter::createMeshInterface(btStridin
|
||||
} else
|
||||
{
|
||||
meshPart.m_indexType = PHY_SHORT;
|
||||
meshPart.m_triangleIndexStride = 3*sizeof(short int);
|
||||
meshPart.m_triangleIndexBase = (const unsigned char*)meshData.m_meshPartsPtr[i].m_indices16;
|
||||
meshPart.m_triangleIndexStride = sizeof(btShortIntIndexTripletData);
|
||||
meshPart.m_triangleIndexBase = (const unsigned char*)meshData.m_meshPartsPtr[i].m_3indices16;
|
||||
}
|
||||
|
||||
if (meshData.m_meshPartsPtr[i].m_vertices3f)
|
||||
@@ -344,7 +344,7 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
|
||||
|
||||
|
||||
btOptimizedBvh* bvh = 0;
|
||||
|
||||
#if 1
|
||||
if (trimesh->m_quantizedFloatBvh)
|
||||
{
|
||||
btOptimizedBvh** bvhPtr = m_bvhMap.find(trimesh->m_quantizedFloatBvh);
|
||||
@@ -369,6 +369,7 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
|
||||
bvh->deSerializeDouble(*trimesh->m_quantizedDoubleBvh);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
btBvhTriangleMeshShape* trimeshShape = createBvhTriangleMeshShape(meshInterface,bvh);
|
||||
@@ -481,7 +482,10 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil
|
||||
btCollisionShapeData* shapeData = (btCollisionShapeData*)bulletFile2->m_collisionShapes[i];
|
||||
btCollisionShape* shape = convertCollisionShape(shapeData);
|
||||
if (shape)
|
||||
{
|
||||
// printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
|
||||
shapeMap.insert(shapeData,shape);
|
||||
}
|
||||
|
||||
if (shape&& shapeData->m_name)
|
||||
{
|
||||
|
||||
@@ -1321,6 +1321,7 @@ const char* btQuantizedBvh::serialize(void* dataBuffer, btSerializer* serializer
|
||||
}
|
||||
|
||||
quantizedData->m_numQuantizedContiguousNodes = m_quantizedContiguousNodes.size();
|
||||
// printf("quantizedData->m_numQuantizedContiguousNodes=%d\n",quantizedData->m_numQuantizedContiguousNodes);
|
||||
quantizedData->m_quantizedContiguousNodesPtr =(btQuantizedBvhNodeData*) (m_quantizedContiguousNodes.size() ? &m_quantizedContiguousNodes[0] : 0);
|
||||
if (quantizedData->m_quantizedContiguousNodesPtr)
|
||||
{
|
||||
|
||||
@@ -502,8 +502,8 @@ struct btBvhSubtreeInfoData
|
||||
{
|
||||
int m_rootNodeIndex;
|
||||
int m_subtreeSize;
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
unsigned short int m_quantizedAabbMax[3];
|
||||
unsigned short m_quantizedAabbMin[3];
|
||||
unsigned short m_quantizedAabbMax[3];
|
||||
};
|
||||
|
||||
struct btOptimizedBvhNodeFloatData
|
||||
@@ -511,9 +511,9 @@ struct btOptimizedBvhNodeFloatData
|
||||
btVector3FloatData m_aabbMinOrg;
|
||||
btVector3FloatData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
char m_pad[4];
|
||||
};
|
||||
|
||||
struct btOptimizedBvhNodeDoubleData
|
||||
@@ -521,17 +521,17 @@ struct btOptimizedBvhNodeDoubleData
|
||||
btVector3DoubleData m_aabbMinOrg;
|
||||
btVector3DoubleData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
char m_pad[4];
|
||||
};
|
||||
|
||||
|
||||
struct btQuantizedBvhNodeData
|
||||
{
|
||||
unsigned short m_quantizedAabbMin[3];
|
||||
unsigned short m_quantizedAabbMax[3];
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
unsigned short int m_quantizedAabbMax[3];
|
||||
};
|
||||
|
||||
struct btQuantizedBvhFloatData
|
||||
@@ -545,10 +545,10 @@ struct btQuantizedBvhFloatData
|
||||
int m_numQuantizedContiguousNodes;
|
||||
btOptimizedBvhNodeFloatData *m_contiguousNodesPtr;
|
||||
btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
|
||||
|
||||
btBvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
int m_traversalMode;
|
||||
int m_numSubtreeHeaders;
|
||||
btBvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
|
||||
};
|
||||
|
||||
struct btQuantizedBvhDoubleData
|
||||
|
||||
@@ -221,7 +221,7 @@ const char* btStridingMeshInterface::serialize(void* dataBuffer, btSerializer* s
|
||||
memPtr->m_numTriangles = numtriangles;//indices = 3*numtriangles
|
||||
memPtr->m_numVertices = numverts;
|
||||
memPtr->m_indices32 = 0;
|
||||
memPtr->m_indices16 = 0;
|
||||
memPtr->m_3indices16 = 0;
|
||||
memPtr->m_vertices3f = 0;
|
||||
memPtr->m_vertices3d = 0;
|
||||
|
||||
@@ -249,23 +249,21 @@ const char* btStridingMeshInterface::serialize(void* dataBuffer, btSerializer* s
|
||||
}
|
||||
case PHY_SHORT:
|
||||
{
|
||||
int numindices = numtriangles*3;
|
||||
if (numindices)
|
||||
if (numtriangles)
|
||||
{
|
||||
btChunk* chunk = serializer->allocate(sizeof(btShortIntIndexData),numindices);
|
||||
btShortIntIndexData* tmpIndices = (btShortIntIndexData*)chunk->m_oldPtr;
|
||||
memPtr->m_indices16 = tmpIndices;
|
||||
btChunk* chunk = serializer->allocate(sizeof(btShortIntIndexTripletData),numtriangles);
|
||||
btShortIntIndexTripletData* tmpIndices = (btShortIntIndexTripletData*)chunk->m_oldPtr;
|
||||
memPtr->m_3indices16 = tmpIndices;
|
||||
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
||||
{
|
||||
unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
|
||||
tmpIndices[gfxindex*3].m_value = tri_indices[0];
|
||||
tmpIndices[gfxindex*3+1].m_value = tri_indices[1];
|
||||
tmpIndices[gfxindex*3+2].m_value = tri_indices[2];
|
||||
tmpIndices[gfxindex].m_values[0] = tri_indices[0];
|
||||
tmpIndices[gfxindex].m_values[1] = tri_indices[1];
|
||||
tmpIndices[gfxindex].m_values[2] = tri_indices[2];
|
||||
}
|
||||
serializer->finalizeChunk(chunk,"btShortIntIndexData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
|
||||
serializer->finalizeChunk(chunk,"btShortIntIndexTripletData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -104,9 +104,12 @@ struct btIntIndexData
|
||||
int m_value;
|
||||
};
|
||||
|
||||
struct btShortIntIndexData
|
||||
|
||||
|
||||
struct btShortIntIndexTripletData
|
||||
{
|
||||
short int m_value;
|
||||
short m_values[3];
|
||||
char m_pad[2];
|
||||
};
|
||||
|
||||
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
|
||||
@@ -116,8 +119,9 @@ struct btMeshPartData
|
||||
btVector3DoubleData *m_vertices3d;
|
||||
|
||||
btIntIndexData *m_indices32;
|
||||
btShortIntIndexData *m_indices16;
|
||||
int m_numTriangles;//length of m_indices = 3*m_numTriangles
|
||||
btShortIntIndexTripletData *m_3indices16;
|
||||
|
||||
int m_numTriangles;//length of m_indices = m_numTriangles
|
||||
int m_numVertices;
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user