diff --git a/Demos/SerializeDemo/SerializeDemo.cpp b/Demos/SerializeDemo/SerializeDemo.cpp index 308beefba..bb67b2440 100644 --- a/Demos/SerializeDemo/SerializeDemo.cpp +++ b/Demos/SerializeDemo/SerializeDemo.cpp @@ -16,9 +16,9 @@ subject to the following restrictions: #define TEST_SERIALIZATION 1 -#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES -#define CREATE_NEW_BULLETFILE 1 -#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +//#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +//#define CREATE_NEW_BULLETFILE 1 +//#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES ///create 125 (5x5x5) dynamic object #define ARRAY_SIZE_X 5 @@ -235,9 +235,14 @@ void SerializeDemo::initPhysics() //now try again from the loaded file setupEmptyDynamicsWorld(); + printf("loading file\n"); btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld); - - fileLoader->loadFile("testFile.bullet"); + //fileLoader->setVerboseMode(true); + + if (fileLoader->loadFile("testFile.bullet")) + { + printf("loaded fine\n"); + } diff --git a/Demos/SerializeDemo/SerializeDemo.h b/Demos/SerializeDemo/SerializeDemo.h index 8f275d2d9..0b3340258 100644 --- a/Demos/SerializeDemo/SerializeDemo.h +++ b/Demos/SerializeDemo/SerializeDemo.h @@ -1,3 +1,4 @@ + /* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2010 Erwin Coumans http://continuousphysics.com/Bullet/ diff --git a/Demos/SerializeDemo/btBulletFile.cpp b/Demos/SerializeDemo/btBulletFile.cpp deleted file mode 100644 index 8f09ba3bc..000000000 --- a/Demos/SerializeDemo/btBulletFile.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* -bParse -Copyright (c) 2006-2010 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btBulletFile.h" -#include "bDefines.h" -#include "bDNA.h" -#include - - -// 32 && 64 bit versions -extern unsigned char sBulletDNAstr[]; -extern int sBulletDNAlen; - -//not yetto. extern unsigned char DNAstr64[]; -//not yetto. extern int DNAlen64; - - -using namespace bParse; - -btBulletFile::btBulletFile() -:bFile("", "BULLET ") -{ - mMemoryDNA = new bDNA(); - mMemoryDNA->init((char*)sBulletDNAstr,sBulletDNAlen); -} - - -btBulletFile::btBulletFile(const char* fileName) -:bFile(fileName, "BULLET ") -{ -} - - - -btBulletFile::btBulletFile(char *memoryBuffer, int len) -:bFile(memoryBuffer,len, "BULLET ") -{ - -} - - -btBulletFile::~btBulletFile() -{ - -} - - - -// ----------------------------------------------------- // -void btBulletFile::parseData() -{ - printf ("Building datablocks"); - printf ("Chunk size = %d",CHUNK_HEADER_LEN); - printf ("File chunk size = %d",ChunkUtils::getOffset(mFlags)); - - const bool swap = (mFlags&FD_ENDIAN_SWAP)!=0; - - - mDataStart = 12; - - char *dataPtr = mFileBuffer+mDataStart; - - bChunkInd dataChunk; - dataChunk.code = 0; - - - //dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - int seek = ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - //dataPtr += ChunkUtils::getOffset(mFlags); - char *dataPtrHead = 0; - - while (dataChunk.code != DNA1) - { - - - - - // one behind - if (dataChunk.code == SDNA) break; - //if (dataChunk.code == DNA1) break; - - // same as (BHEAD+DATA dependancy) - dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags); - char *id = readStruct(dataPtrHead, dataChunk); - - // lookup maps - if (id) - { - mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)id); - - m_chunks.push_back(dataChunk); - // block it - //bListBasePtr *listID = mMain->getListBasePtr(dataChunk.code); - //if (listID) - // listID->push_back((bStructHandle*)id); - } - - if (dataChunk.code == BT_RIGIDBODY_CODE) - { - m_rigidBodies.push_back((bStructHandle*) id); - } - - if (dataChunk.code == BT_COLLISIONOBJECT_CODE) - { - m_collisionObjects.push_back((bStructHandle*) id); - } - - if (dataChunk.code == BT_SHAPE_CODE) - { - m_collisionShapes.push_back((bStructHandle*) id); - } - -// if (dataChunk.code == GLOB) -// { -// m_glob = (bStructHandle*) id; -// } - - // next please! - dataPtr += seek; - - seek = ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - if (seek < 0) - break; - } - -} - -void btBulletFile::addDataBlock(char* dataBlock) -{ - //mMain->addDatablock(dataBlock); -} - - - - -void btBulletFile::writeDNA(FILE* fp) -{ - - bChunkInd dataChunk; - dataChunk.code = DNA1; - dataChunk.dna_nr = 0; - dataChunk.nr = 1; - - if (VOID_IS_8) - { - //dataChunk.len = DNAlen64; - //dataChunk.oldPtr = DNAstr64; - //fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - //fwrite(DNAstr64, DNAlen64,1,fp); - } - else - { - dataChunk.len = sBulletDNAlen; - dataChunk.oldPtr = sBulletDNAstr; - fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); - } -} - -void btBulletFile::parse(bool verboseDumpAllTypes) -{ - if (VOID_IS_8) - { - exit(0); - //parseInternal(verboseDumpAllTypes,(char*)DNAstr64,DNAlen64); - } - else - { - parseInternal(verboseDumpAllTypes,(char*)sBulletDNAstr,sBulletDNAlen); - } -} - -// experimental -int btBulletFile::write(const char* fileName, bool fixupPointers) -{ - FILE *fp = fopen(fileName, "wb"); - if (fp) - { - char header[SIZEOFBLENDERHEADER] ; - memcpy(header, m_headerString, 7); - int endian= 1; - endian= ((char*)&endian)[0]; - - if (endian) - { - header[7] = '_'; - } else - { - header[7] = '-'; - } - if (VOID_IS_8) - { - header[8]='V'; - } else - { - header[8]='v'; - } - - header[9] = '2'; - header[10] = '7'; - header[11] = '5'; - - fwrite(header,SIZEOFBLENDERHEADER,1,fp); - - writeChunks(fp, fixupPointers); - - writeDNA(fp); - - fclose(fp); - - } else - { - printf("Error: cannot open file %s for writing\n",fileName); - return 0; - } - return 1; -} - - - -void btBulletFile::addStruct(const char* structType,void* data, int len, void* oldPtr, int code) -{ - - bParse::bChunkInd dataChunk; - dataChunk.code = code; - dataChunk.nr = 1; - dataChunk.len = len; - dataChunk.dna_nr = mMemoryDNA->getReverseType(structType); - dataChunk.oldPtr = oldPtr; - - ///Perform structure size validation - short* structInfo= mMemoryDNA->getStruct(dataChunk.dna_nr); - int elemBytes = mMemoryDNA->getLength(structInfo[0]); -// int elemBytes = mMemoryDNA->getElementSize(structInfo[0],structInfo[1]); - assert(len==elemBytes); - - mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)data); - m_chunks.push_back(dataChunk); -} \ No newline at end of file diff --git a/Demos/SerializeDemo/btBulletFile.h b/Demos/SerializeDemo/btBulletFile.h deleted file mode 100644 index c9f2de655..000000000 --- a/Demos/SerializeDemo/btBulletFile.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -bParse -Copyright (c) 2006-2010 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_BULLET_FILE_H -#define BT_BULLET_FILE_H - - -#include "bFile.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "bDefines.h" - -#define BT_COLLISIONOBJECT_CODE MAKE_ID('C','O','B','J') -#define BT_RIGIDBODY_CODE MAKE_ID('R','B','D','Y') -#define BT_BOXSHAPE_CODE MAKE_ID('B','O','X','S') -#define BT_SHAPE_CODE MAKE_ID('S','H','A','P') - - -namespace bParse { - - // ----------------------------------------------------- // - class btBulletFile : public bFile - { - - protected: - - - public: - - btAlignedObjectArray m_rigidBodies; - - btAlignedObjectArray m_collisionObjects; - - btAlignedObjectArray m_collisionShapes; - - btBulletFile(); - - btBulletFile(const char* fileName); - - btBulletFile(char *memoryBuffer, int len); - - virtual ~btBulletFile(); - - virtual void addDataBlock(char* dataBlock); - - - // experimental - virtual int write(const char* fileName, bool fixupPointers=false); - - virtual void parse(bool verboseDumpAllTypes); - - virtual void parseData(); - - virtual void writeDNA(FILE* fp); - - void addStruct(const char* structType,void* data, int len, void* oldPtr, int code); - - }; -}; - -#endif //BT_BULLET_FILE_H diff --git a/Extras/Serialize/BulletFileLoader/btBulletFile.cpp b/Extras/Serialize/BulletFileLoader/btBulletFile.cpp index 7a6f6b51e..bd70e1289 100644 --- a/Extras/Serialize/BulletFileLoader/btBulletFile.cpp +++ b/Extras/Serialize/BulletFileLoader/btBulletFile.cpp @@ -20,6 +20,7 @@ subject to the following restrictions: // 32 && 64 bit versions +#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES #ifdef _WIN64 extern unsigned char sBulletDNAstr64[]; extern int sBulletDNAlen64; @@ -27,7 +28,14 @@ extern int sBulletDNAlen64; extern unsigned char sBulletDNAstr[]; extern int sBulletDNAlen; #endif //_WIN64 +#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +extern unsigned char sBulletDNAstr64[]; +extern int sBulletDNAlen64; +extern unsigned char sBulletDNAstr[]; +extern int sBulletDNAlen; + +#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES using namespace bParse; @@ -35,14 +43,19 @@ btBulletFile::btBulletFile() :bFile("", "BULLET ") { mMemoryDNA = new bDNA(); -#ifdef _WIN64 -//if (VOID_IS_8) - mMemoryDNA->init((char*)sBulletDNAstr64,sBulletDNAlen64); -// else -#else - mMemoryDNA->init((char*)sBulletDNAstr,sBulletDNAlen); -#endif +#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#ifdef _WIN64 + mMemoryDNA->init((char*)sBulletDNAstr64,sBulletDNAlen64); +#else//_WIN64 + mMemoryDNA->init((char*)sBulletDNAstr,sBulletDNAlen); +#endif//_WIN64 +#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES + if (VOID_IS_8) + mMemoryDNA->init((char*)sBulletDNAstr64,sBulletDNAlen64); + else + mMemoryDNA->init((char*)sBulletDNAstr,sBulletDNAlen); +#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } @@ -173,7 +186,7 @@ void btBulletFile::writeDNA(FILE* fp) dataChunk.code = DNA1; dataChunk.dna_nr = 0; dataChunk.nr = 1; - +#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { #ifdef _WIN64 @@ -192,15 +205,32 @@ void btBulletFile::writeDNA(FILE* fp) dataChunk.oldPtr = sBulletDNAstr; fwrite(&dataChunk,sizeof(bChunkInd),1,fp); fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); -#else +#else//_WIN64 btAssert(0); -#endif +#endif//_WIN64 } +#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES + if (VOID_IS_8) + { + dataChunk.len = sBulletDNAlen64; + dataChunk.oldPtr = sBulletDNAstr64; + fwrite(&dataChunk,sizeof(bChunkInd),1,fp); + fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp); + } + else + { + dataChunk.len = sBulletDNAlen; + dataChunk.oldPtr = sBulletDNAstr; + fwrite(&dataChunk,sizeof(bChunkInd),1,fp); + fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); + } +#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } void btBulletFile::parse(bool verboseDumpAllTypes) { +#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { #ifdef _WIN64 @@ -217,6 +247,16 @@ void btBulletFile::parse(bool verboseDumpAllTypes) btAssert(0); #endif } +#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES + if (VOID_IS_8) + { + parseInternal(verboseDumpAllTypes,(char*)sBulletDNAstr64,sBulletDNAlen64); + } + else + { + parseInternal(verboseDumpAllTypes,(char*)sBulletDNAstr,sBulletDNAlen); + } +#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } // experimental diff --git a/src/BulletCollision/BroadphaseCollision/btDbvt.h b/src/BulletCollision/BroadphaseCollision/btDbvt.h index fb47a4e73..f46629c3d 100644 --- a/src/BulletCollision/BroadphaseCollision/btDbvt.h +++ b/src/BulletCollision/BroadphaseCollision/btDbvt.h @@ -92,7 +92,7 @@ subject to the following restrictions: #endif #if DBVT_USE_MEMMOVE -#ifndef __CELLOS_LV2__ +#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) #include #endif #include diff --git a/src/BulletCollision/CollisionShapes/btCompoundShape.h b/src/BulletCollision/CollisionShapes/btCompoundShape.h index 6aed5b33e..179bb0091 100644 --- a/src/BulletCollision/CollisionShapes/btCompoundShape.h +++ b/src/BulletCollision/CollisionShapes/btCompoundShape.h @@ -143,8 +143,6 @@ public: return "Compound"; } - //this is optional, but should make collision queries faster, by culling non-overlapping nodes - void createAabbTreeFromChildren(); btDbvt* getDynamicAabbTree() { diff --git a/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h b/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h index 231c58549..d42ba1143 100644 --- a/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h +++ b/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h @@ -37,7 +37,6 @@ public: { m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; - btVector3 m_triangle[3]; const unsigned char *vertexbase; int numverts; PHY_ScalarType type; @@ -71,7 +70,6 @@ public: { m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; - btVector3 m_triangle[3]; const unsigned char *vertexbase; int numverts; PHY_ScalarType type;