mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
update bullet so it actually works
Moved the addSourceDirectory for physics/Bullet into the Engine/Source/CMakeLists.txt file that way it can actually appear where we expect it to in the solution explorer.
This commit is contained in:
parent
c7be48130a
commit
13fa178cf6
5986 changed files with 1811270 additions and 453803 deletions
|
|
@ -27,32 +27,27 @@ extern int DNAlen;
|
|||
extern unsigned char DNAstr64[];
|
||||
extern int DNAlen64;
|
||||
|
||||
|
||||
using namespace bParse;
|
||||
|
||||
bBlenderFile::bBlenderFile(const char* fileName)
|
||||
:bFile(fileName, "BLENDER")
|
||||
bBlenderFile::bBlenderFile(const char *fileName)
|
||||
: bFile(fileName, "BLENDER")
|
||||
{
|
||||
mMain= new bMain(this, fileName, mVersion);
|
||||
mMain = new bMain(this, fileName, mVersion);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bBlenderFile::bBlenderFile(char *memoryBuffer, int len)
|
||||
:bFile(memoryBuffer,len, "BLENDER"),
|
||||
mMain(0)
|
||||
: bFile(memoryBuffer, len, "BLENDER"),
|
||||
mMain(0)
|
||||
{
|
||||
mMain= new bMain(this, "memoryBuf", mVersion);
|
||||
mMain = new bMain(this, "memoryBuf", mVersion);
|
||||
}
|
||||
|
||||
|
||||
bBlenderFile::~bBlenderFile()
|
||||
{
|
||||
delete mMain;
|
||||
}
|
||||
|
||||
|
||||
bMain* bBlenderFile::getMain()
|
||||
bMain *bBlenderFile::getMain()
|
||||
{
|
||||
return mMain;
|
||||
}
|
||||
|
|
@ -60,20 +55,17 @@ bMain* bBlenderFile::getMain()
|
|||
// ----------------------------------------------------- //
|
||||
void bBlenderFile::parseData()
|
||||
{
|
||||
// printf ("Building datablocks\n");
|
||||
// printf ("Chunk size = %d\n",CHUNK_HEADER_LEN);
|
||||
// printf ("File chunk size = %d\n", ChunkUtils::getOffset(mFlags));
|
||||
// printf ("Building datablocks\n");
|
||||
// printf ("Chunk size = %d\n",CHUNK_HEADER_LEN);
|
||||
// printf ("File chunk size = %d\n", ChunkUtils::getOffset(mFlags));
|
||||
|
||||
const bool swap = (mFlags&FD_ENDIAN_SWAP)!=0;
|
||||
|
||||
const bool swap = (mFlags & FD_ENDIAN_SWAP) != 0;
|
||||
|
||||
|
||||
char *dataPtr = mFileBuffer+mDataStart;
|
||||
char *dataPtr = mFileBuffer + mDataStart;
|
||||
|
||||
bChunkInd dataChunk;
|
||||
dataChunk.code = 0;
|
||||
|
||||
|
||||
//dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
int seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
//dataPtr += ChunkUtils::getOffset(mFlags);
|
||||
|
|
@ -81,55 +73,46 @@ void bBlenderFile::parseData()
|
|||
|
||||
while (dataChunk.code != DNA1)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// one behind
|
||||
if (dataChunk.code == SDNA) break;
|
||||
//if (dataChunk.code == DNA1) break;
|
||||
|
||||
// same as (BHEAD+DATA dependency)
|
||||
dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags);
|
||||
dataPtrHead = dataPtr + ChunkUtils::getOffset(mFlags);
|
||||
char *id = readStruct(dataPtrHead, dataChunk);
|
||||
|
||||
// lookup maps
|
||||
if (id)
|
||||
{
|
||||
m_chunkPtrPtrMap.insert(dataChunk.oldPtr, dataChunk);
|
||||
mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)id);
|
||||
m_chunkPtrPtrMap.insert(dataChunk.oldPtr, dataChunk);
|
||||
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);
|
||||
listID->push_back((bStructHandle *)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == GLOB)
|
||||
{
|
||||
m_glob = (bStructHandle*) id;
|
||||
m_glob = (bStructHandle *)id;
|
||||
}
|
||||
|
||||
// next please!
|
||||
dataPtr += seek;
|
||||
|
||||
seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
if (seek < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void bBlenderFile::addDataBlock(char* dataBlock)
|
||||
void bBlenderFile::addDataBlock(char *dataBlock)
|
||||
{
|
||||
mMain->addDatablock(dataBlock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 32 && 64 bit versions
|
||||
extern unsigned char DNAstr[];
|
||||
extern int DNAlen;
|
||||
|
|
@ -137,88 +120,87 @@ extern int DNAlen;
|
|||
//unsigned char DNAstr[]={0};
|
||||
//int DNAlen=0;
|
||||
|
||||
|
||||
extern unsigned char DNAstr64[];
|
||||
extern int DNAlen64;
|
||||
|
||||
|
||||
void bBlenderFile::writeDNA(FILE* fp)
|
||||
void bBlenderFile::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);
|
||||
fwrite(&dataChunk, sizeof(bChunkInd), 1, fp);
|
||||
fwrite(DNAstr64, DNAlen64, 1, fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataChunk.len = DNAlen;
|
||||
dataChunk.oldPtr = DNAstr;
|
||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||
fwrite(DNAstr, DNAlen,1,fp);
|
||||
fwrite(&dataChunk, sizeof(bChunkInd), 1, fp);
|
||||
fwrite(DNAstr, DNAlen, 1, fp);
|
||||
}
|
||||
}
|
||||
|
||||
void bBlenderFile::parse(int verboseMode)
|
||||
void bBlenderFile::parse(int verboseMode)
|
||||
{
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
parseInternal(verboseMode,(char*)DNAstr64,DNAlen64);
|
||||
parseInternal(verboseMode, (char *)DNAstr64, DNAlen64);
|
||||
}
|
||||
else
|
||||
{
|
||||
parseInternal(verboseMode,(char*)DNAstr,DNAlen);
|
||||
parseInternal(verboseMode, (char *)DNAstr, DNAlen);
|
||||
}
|
||||
}
|
||||
|
||||
// experimental
|
||||
int bBlenderFile::write(const char* fileName, bool fixupPointers)
|
||||
int bBlenderFile::write(const char *fileName, bool fixupPointers)
|
||||
{
|
||||
FILE *fp = fopen(fileName, "wb");
|
||||
if (fp)
|
||||
{
|
||||
char header[SIZEOFBLENDERHEADER] ;
|
||||
char header[SIZEOFBLENDERHEADER];
|
||||
memcpy(header, m_headerString, 7);
|
||||
int endian= 1;
|
||||
endian= ((char*)&endian)[0];
|
||||
int endian = 1;
|
||||
endian = ((char *)&endian)[0];
|
||||
|
||||
if (endian)
|
||||
{
|
||||
header[7] = '_';
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
header[7] = '-';
|
||||
}
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
header[8]='V';
|
||||
} else
|
||||
header[8] = 'V';
|
||||
}
|
||||
else
|
||||
{
|
||||
header[8]='v';
|
||||
header[8] = 'v';
|
||||
}
|
||||
|
||||
header[9] = '2';
|
||||
header[10] = '4';
|
||||
header[11] = '9';
|
||||
|
||||
fwrite(header,SIZEOFBLENDERHEADER,1,fp);
|
||||
|
||||
fwrite(header, SIZEOFBLENDERHEADER, 1, fp);
|
||||
|
||||
writeChunks(fp, fixupPointers);
|
||||
|
||||
writeDNA(fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: cannot open file %s for writing\n",fileName);
|
||||
printf("Error: cannot open file %s for writing\n", fileName);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -16,48 +16,43 @@ subject to the following restrictions:
|
|||
#ifndef B_BLENDER_FILE_H
|
||||
#define B_BLENDER_FILE_H
|
||||
|
||||
|
||||
#include "bFile.h"
|
||||
|
||||
namespace bParse {
|
||||
namespace bParse
|
||||
{
|
||||
// ----------------------------------------------------- //
|
||||
class bBlenderFile : public bFile
|
||||
{
|
||||
protected:
|
||||
bMain* mMain;
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class bBlenderFile : public bFile
|
||||
bStructHandle* m_glob;
|
||||
|
||||
public:
|
||||
bBlenderFile(const char* fileName);
|
||||
|
||||
bBlenderFile(char* memoryBuffer, int len);
|
||||
|
||||
virtual ~bBlenderFile();
|
||||
|
||||
bMain* getMain();
|
||||
|
||||
virtual void addDataBlock(char* dataBlock);
|
||||
|
||||
bStructHandle* getFileGlobal()
|
||||
{
|
||||
return m_glob;
|
||||
}
|
||||
|
||||
protected:
|
||||
bMain* mMain;
|
||||
// experimental
|
||||
virtual int write(const char* fileName, bool fixupPointers = false);
|
||||
|
||||
bStructHandle* m_glob;
|
||||
virtual void parse(int verboseMode);
|
||||
|
||||
|
||||
public:
|
||||
virtual void parseData();
|
||||
|
||||
bBlenderFile(const char* fileName);
|
||||
|
||||
bBlenderFile(char *memoryBuffer, int len);
|
||||
|
||||
virtual ~bBlenderFile();
|
||||
|
||||
bMain* getMain();
|
||||
|
||||
virtual void addDataBlock(char* dataBlock);
|
||||
|
||||
bStructHandle* getFileGlobal()
|
||||
{
|
||||
return m_glob;
|
||||
}
|
||||
|
||||
// experimental
|
||||
virtual int write(const char* fileName, bool fixupPointers = false);
|
||||
|
||||
virtual void parse(int verboseMode);
|
||||
|
||||
virtual void parseData();
|
||||
|
||||
virtual void writeDNA(FILE* fp);
|
||||
|
||||
};
|
||||
virtual void writeDNA(FILE* fp);
|
||||
};
|
||||
}; // namespace bParse
|
||||
|
||||
#endif //B_BLENDER_FILE_H
|
||||
#endif //B_BLENDER_FILE_H
|
||||
|
|
|
|||
|
|
@ -21,51 +21,49 @@ subject to the following restrictions:
|
|||
|
||||
using namespace bParse;
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
bMain::bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion)
|
||||
: mFP(filePtr),
|
||||
mVersion(fileVersion),
|
||||
mName(baseName)
|
||||
: mFP(filePtr),
|
||||
mVersion(fileVersion),
|
||||
mName(baseName)
|
||||
{
|
||||
mData.insert(ID_SCE,bListBasePtr());
|
||||
mData.insert(ID_LI,bListBasePtr());
|
||||
mData.insert(ID_OB,bListBasePtr());
|
||||
mData.insert(ID_ME,bListBasePtr());
|
||||
mData.insert(ID_CU,bListBasePtr());
|
||||
mData.insert(ID_MB,bListBasePtr());
|
||||
mData.insert(ID_MA,bListBasePtr());
|
||||
mData.insert(ID_TE,bListBasePtr());
|
||||
mData.insert(ID_IM,bListBasePtr());
|
||||
mData.insert(ID_WV,bListBasePtr());
|
||||
mData.insert(ID_LT,bListBasePtr());
|
||||
mData.insert(ID_LA,bListBasePtr());
|
||||
mData.insert(ID_CA,bListBasePtr());
|
||||
mData.insert(ID_IP,bListBasePtr());
|
||||
mData.insert(ID_KE,bListBasePtr());
|
||||
mData.insert(ID_WO,bListBasePtr());
|
||||
mData.insert(ID_SCR,bListBasePtr());
|
||||
mData.insert(ID_VF,bListBasePtr());
|
||||
mData.insert(ID_TXT,bListBasePtr());
|
||||
mData.insert(ID_SO,bListBasePtr());
|
||||
mData.insert(ID_GR,bListBasePtr());
|
||||
mData.insert(ID_AR,bListBasePtr());
|
||||
mData.insert(ID_AC,bListBasePtr());
|
||||
mData.insert(ID_NT,bListBasePtr());
|
||||
mData.insert(ID_BR,bListBasePtr());
|
||||
mData.insert(ID_SCE, bListBasePtr());
|
||||
mData.insert(ID_LI, bListBasePtr());
|
||||
mData.insert(ID_OB, bListBasePtr());
|
||||
mData.insert(ID_ME, bListBasePtr());
|
||||
mData.insert(ID_CU, bListBasePtr());
|
||||
mData.insert(ID_MB, bListBasePtr());
|
||||
mData.insert(ID_MA, bListBasePtr());
|
||||
mData.insert(ID_TE, bListBasePtr());
|
||||
mData.insert(ID_IM, bListBasePtr());
|
||||
mData.insert(ID_WV, bListBasePtr());
|
||||
mData.insert(ID_LT, bListBasePtr());
|
||||
mData.insert(ID_LA, bListBasePtr());
|
||||
mData.insert(ID_CA, bListBasePtr());
|
||||
mData.insert(ID_IP, bListBasePtr());
|
||||
mData.insert(ID_KE, bListBasePtr());
|
||||
mData.insert(ID_WO, bListBasePtr());
|
||||
mData.insert(ID_SCR, bListBasePtr());
|
||||
mData.insert(ID_VF, bListBasePtr());
|
||||
mData.insert(ID_TXT, bListBasePtr());
|
||||
mData.insert(ID_SO, bListBasePtr());
|
||||
mData.insert(ID_GR, bListBasePtr());
|
||||
mData.insert(ID_AR, bListBasePtr());
|
||||
mData.insert(ID_AC, bListBasePtr());
|
||||
mData.insert(ID_NT, bListBasePtr());
|
||||
mData.insert(ID_BR, bListBasePtr());
|
||||
mData.insert(ID_SCRIPT, bListBasePtr());
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
bMain::~bMain()
|
||||
{
|
||||
// allocated data blocks!
|
||||
|
||||
int sz = mPool.size();
|
||||
for (int i=0;i<sz;i++)
|
||||
for (int i = 0; i < sz; i++)
|
||||
{
|
||||
delete [] mPool[i];
|
||||
delete[] mPool[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,30 +83,25 @@ const char *bMain::getName()
|
|||
void bMain::addDatablock(void *allocated)
|
||||
{
|
||||
assert(allocated);
|
||||
mPool.push_back((bStructHandle*)allocated);
|
||||
mPool.push_back((bStructHandle *)allocated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
void bMain::linkList(void *listBasePtr)
|
||||
{
|
||||
|
||||
struct ListBase // local Blender::ListBase
|
||||
struct ListBase // local Blender::ListBase
|
||||
{
|
||||
void *first;
|
||||
void *last;
|
||||
};
|
||||
|
||||
struct Link // local Blender::Link
|
||||
struct Link // local Blender::Link
|
||||
{
|
||||
void *next;
|
||||
void *prev;
|
||||
};
|
||||
|
||||
|
||||
ListBase *base = (ListBase*)listBasePtr;
|
||||
ListBase *base = (ListBase *)listBasePtr;
|
||||
|
||||
if (!base || !base->first)
|
||||
return;
|
||||
|
|
@ -121,18 +114,18 @@ void bMain::linkList(void *listBasePtr)
|
|||
}
|
||||
|
||||
void *prev = 0;
|
||||
Link *l = (Link*)base->first;
|
||||
Link *l = (Link *)base->first;
|
||||
while (l)
|
||||
{
|
||||
l->next = mFP->findLibPointer(l->next);
|
||||
l->prev = l->next;
|
||||
prev = l->next;
|
||||
l = (Link*)l->next;
|
||||
l = (Link *)l->next;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
bListBasePtr* bMain::getListBasePtr(int listBaseCode)
|
||||
bListBasePtr *bMain::getListBasePtr(int listBaseCode)
|
||||
{
|
||||
bListBasePtr *ptr = _findCode(listBaseCode);
|
||||
if (!ptr)
|
||||
|
|
@ -143,12 +136,10 @@ bListBasePtr* bMain::getListBasePtr(int listBaseCode)
|
|||
// ------------------------------------------------------------//
|
||||
bListBasePtr *bMain::_findCode(int code)
|
||||
{
|
||||
|
||||
bListBasePtr* lbPtr = mData.find(code);
|
||||
bListBasePtr *lbPtr = mData.find(code);
|
||||
return lbPtr;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
bListBasePtr *bMain::getScene()
|
||||
{
|
||||
|
|
@ -193,8 +184,6 @@ bListBasePtr *bMain::getCurve()
|
|||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
bListBasePtr *bMain::getMball()
|
||||
{
|
||||
|
|
@ -222,7 +211,6 @@ bListBasePtr *bMain::getTex()
|
|||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
bListBasePtr *bMain::getImage()
|
||||
{
|
||||
|
|
@ -295,7 +283,6 @@ bListBasePtr *bMain::getWorld()
|
|||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
bListBasePtr *bMain::getScreen()
|
||||
{
|
||||
|
|
@ -368,7 +355,6 @@ bListBasePtr *bMain::getAction()
|
|||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------//
|
||||
bListBasePtr *bMain::getNodetree()
|
||||
{
|
||||
|
|
@ -387,6 +373,4 @@ bListBasePtr *bMain::getBrush()
|
|||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//eof
|
||||
|
|
|
|||
|
|
@ -20,91 +20,77 @@ subject to the following restrictions:
|
|||
#include "bChunk.h"
|
||||
#include "LinearMath/btHashMap.h"
|
||||
|
||||
namespace bParse
|
||||
{
|
||||
class bDNA;
|
||||
|
||||
class bBlenderFile;
|
||||
}; // namespace bParse
|
||||
|
||||
namespace bParse
|
||||
{
|
||||
class bDNA;
|
||||
// ----------------------------------------------------- //
|
||||
|
||||
class bBlenderFile;
|
||||
};
|
||||
typedef btHashMap<btHashInt, bListBasePtr> bMainDataMap;
|
||||
|
||||
|
||||
|
||||
namespace bParse {
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
|
||||
typedef btHashMap<btHashInt,bListBasePtr> bMainDataMap;
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class bMain
|
||||
{
|
||||
// ----------------------------------------------------- //
|
||||
class bMain
|
||||
{
|
||||
//private:
|
||||
public:
|
||||
bBlenderFile* mFP;
|
||||
bListBasePtr mPool;
|
||||
public:
|
||||
bBlenderFile *mFP;
|
||||
bListBasePtr mPool;
|
||||
|
||||
int mVersion;
|
||||
const char* mName;
|
||||
int mVersion;
|
||||
const char *mName;
|
||||
|
||||
bMainDataMap mData;
|
||||
bMainDataMap mData;
|
||||
|
||||
|
||||
bListBasePtr *_findCode(int code);
|
||||
|
||||
public:
|
||||
bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion);
|
||||
~bMain();
|
||||
|
||||
bListBasePtr *_findCode(int code);
|
||||
int getVersion();
|
||||
const char *getName();
|
||||
|
||||
public:
|
||||
bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion);
|
||||
~bMain();
|
||||
bListBasePtr *getListBasePtr(int listBaseCode);
|
||||
|
||||
int getVersion();
|
||||
const char *getName();
|
||||
bListBasePtr *getScene();
|
||||
bListBasePtr *getLibrary();
|
||||
bListBasePtr *getObject();
|
||||
bListBasePtr *getMesh();
|
||||
bListBasePtr *getCurve();
|
||||
bListBasePtr *getMball();
|
||||
bListBasePtr *getMat();
|
||||
bListBasePtr *getTex();
|
||||
bListBasePtr *getImage();
|
||||
bListBasePtr *getWave();
|
||||
bListBasePtr *getLatt();
|
||||
bListBasePtr *getLamp();
|
||||
bListBasePtr *getCamera();
|
||||
bListBasePtr *getIpo();
|
||||
bListBasePtr *getKey();
|
||||
bListBasePtr *getWorld();
|
||||
bListBasePtr *getScreen();
|
||||
bListBasePtr *getScript();
|
||||
bListBasePtr *getVfont();
|
||||
bListBasePtr *getText();
|
||||
bListBasePtr *getSound();
|
||||
bListBasePtr *getGroup();
|
||||
bListBasePtr *getArmature();
|
||||
bListBasePtr *getAction();
|
||||
bListBasePtr *getNodetree();
|
||||
bListBasePtr *getBrush();
|
||||
|
||||
bListBasePtr *getListBasePtr(int listBaseCode);
|
||||
// tracking allocated memory
|
||||
void addDatablock(void *allocated);
|
||||
|
||||
// --
|
||||
|
||||
bListBasePtr *getScene();
|
||||
bListBasePtr *getLibrary();
|
||||
bListBasePtr *getObject();
|
||||
bListBasePtr *getMesh();
|
||||
bListBasePtr *getCurve();
|
||||
bListBasePtr *getMball();
|
||||
bListBasePtr *getMat();
|
||||
bListBasePtr *getTex();
|
||||
bListBasePtr *getImage();
|
||||
bListBasePtr *getWave();
|
||||
bListBasePtr *getLatt();
|
||||
bListBasePtr *getLamp();
|
||||
bListBasePtr *getCamera();
|
||||
bListBasePtr *getIpo();
|
||||
bListBasePtr *getKey();
|
||||
bListBasePtr *getWorld();
|
||||
bListBasePtr *getScreen();
|
||||
bListBasePtr *getScript();
|
||||
bListBasePtr *getVfont();
|
||||
bListBasePtr *getText();
|
||||
bListBasePtr *getSound();
|
||||
bListBasePtr *getGroup();
|
||||
bListBasePtr *getArmature();
|
||||
bListBasePtr *getAction();
|
||||
bListBasePtr *getNodetree();
|
||||
bListBasePtr *getBrush();
|
||||
void linkList(void *listBasePtr);
|
||||
};
|
||||
} // namespace bParse
|
||||
|
||||
|
||||
|
||||
// tracking allocated memory
|
||||
void addDatablock(void *allocated);
|
||||
|
||||
|
||||
// --
|
||||
|
||||
void linkList(void *listBasePtr);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BMAIN_H__
|
||||
#endif //__BMAIN_H__
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -34,7 +34,10 @@ IF (INSTALL_EXTRA_LIBS)
|
|||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||
INSTALL(TARGETS BulletFileLoader DESTINATION .)
|
||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||
INSTALL(TARGETS BulletFileLoader DESTINATION lib${LIB_SUFFIX})
|
||||
INSTALL(TARGETS BulletFileLoader
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||
INSTALL(
|
||||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ typedef struct bInvalidHandle {
|
|||
class btCapsuleShapeData;
|
||||
class btTriangleInfoData;
|
||||
class btTriangleInfoMapData;
|
||||
class btPersistentManifoldDoubleData;
|
||||
class btPersistentManifoldFloatData;
|
||||
class btGImpactMeshShapeData;
|
||||
class btConvexHullShapeData;
|
||||
class btCollisionObjectDoubleData;
|
||||
|
|
@ -110,6 +112,8 @@ typedef struct bInvalidHandle {
|
|||
class btMultiBodyLinkFloatData;
|
||||
class btMultiBodyDoubleData;
|
||||
class btMultiBodyFloatData;
|
||||
class btMultiBodyLinkColliderFloatData;
|
||||
class btMultiBodyLinkColliderDoubleData;
|
||||
// -------------------------------------------------- //
|
||||
class PointerArray
|
||||
{
|
||||
|
|
@ -512,6 +516,98 @@ typedef struct bInvalidHandle {
|
|||
};
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
class btPersistentManifoldDoubleData
|
||||
{
|
||||
public:
|
||||
btVector3DoubleData m_pointCacheLocalPointA[4];
|
||||
btVector3DoubleData m_pointCacheLocalPointB[4];
|
||||
btVector3DoubleData m_pointCachePositionWorldOnA[4];
|
||||
btVector3DoubleData m_pointCachePositionWorldOnB[4];
|
||||
btVector3DoubleData m_pointCacheNormalWorldOnB[4];
|
||||
btVector3DoubleData m_pointCacheLateralFrictionDir1[4];
|
||||
btVector3DoubleData m_pointCacheLateralFrictionDir2[4];
|
||||
double m_pointCacheDistance[4];
|
||||
double m_pointCacheAppliedImpulse[4];
|
||||
double m_pointCachePrevRHS[4];
|
||||
double m_pointCacheCombinedFriction[4];
|
||||
double m_pointCacheCombinedRollingFriction[4];
|
||||
double m_pointCacheCombinedSpinningFriction[4];
|
||||
double m_pointCacheCombinedRestitution[4];
|
||||
int m_pointCachePartId0[4];
|
||||
int m_pointCachePartId1[4];
|
||||
int m_pointCacheIndex0[4];
|
||||
int m_pointCacheIndex1[4];
|
||||
int m_pointCacheContactPointFlags[4];
|
||||
double m_pointCacheAppliedImpulseLateral1[4];
|
||||
double m_pointCacheAppliedImpulseLateral2[4];
|
||||
double m_pointCacheContactMotion1[4];
|
||||
double m_pointCacheContactMotion2[4];
|
||||
double m_pointCacheContactCFM[4];
|
||||
double m_pointCacheCombinedContactStiffness1[4];
|
||||
double m_pointCacheContactERP[4];
|
||||
double m_pointCacheCombinedContactDamping1[4];
|
||||
double m_pointCacheFrictionCFM[4];
|
||||
int m_pointCacheLifeTime[4];
|
||||
int m_numCachedPoints;
|
||||
int m_companionIdA;
|
||||
int m_companionIdB;
|
||||
int m_index1a;
|
||||
int m_objectType;
|
||||
double m_contactBreakingThreshold;
|
||||
double m_contactProcessingThreshold;
|
||||
int m_padding;
|
||||
btCollisionObjectDoubleData *m_body0;
|
||||
btCollisionObjectDoubleData *m_body1;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
class btPersistentManifoldFloatData
|
||||
{
|
||||
public:
|
||||
btVector3FloatData m_pointCacheLocalPointA[4];
|
||||
btVector3FloatData m_pointCacheLocalPointB[4];
|
||||
btVector3FloatData m_pointCachePositionWorldOnA[4];
|
||||
btVector3FloatData m_pointCachePositionWorldOnB[4];
|
||||
btVector3FloatData m_pointCacheNormalWorldOnB[4];
|
||||
btVector3FloatData m_pointCacheLateralFrictionDir1[4];
|
||||
btVector3FloatData m_pointCacheLateralFrictionDir2[4];
|
||||
float m_pointCacheDistance[4];
|
||||
float m_pointCacheAppliedImpulse[4];
|
||||
float m_pointCachePrevRHS[4];
|
||||
float m_pointCacheCombinedFriction[4];
|
||||
float m_pointCacheCombinedRollingFriction[4];
|
||||
float m_pointCacheCombinedSpinningFriction[4];
|
||||
float m_pointCacheCombinedRestitution[4];
|
||||
int m_pointCachePartId0[4];
|
||||
int m_pointCachePartId1[4];
|
||||
int m_pointCacheIndex0[4];
|
||||
int m_pointCacheIndex1[4];
|
||||
int m_pointCacheContactPointFlags[4];
|
||||
float m_pointCacheAppliedImpulseLateral1[4];
|
||||
float m_pointCacheAppliedImpulseLateral2[4];
|
||||
float m_pointCacheContactMotion1[4];
|
||||
float m_pointCacheContactMotion2[4];
|
||||
float m_pointCacheContactCFM[4];
|
||||
float m_pointCacheCombinedContactStiffness1[4];
|
||||
float m_pointCacheContactERP[4];
|
||||
float m_pointCacheCombinedContactDamping1[4];
|
||||
float m_pointCacheFrictionCFM[4];
|
||||
int m_pointCacheLifeTime[4];
|
||||
int m_numCachedPoints;
|
||||
int m_companionIdA;
|
||||
int m_companionIdB;
|
||||
int m_index1a;
|
||||
int m_objectType;
|
||||
float m_contactBreakingThreshold;
|
||||
float m_contactProcessingThreshold;
|
||||
int m_padding;
|
||||
btCollisionObjectFloatData *m_body0;
|
||||
btCollisionObjectFloatData *m_body1;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
class btGImpactMeshShapeData
|
||||
{
|
||||
|
|
@ -553,6 +649,8 @@ typedef struct bInvalidHandle {
|
|||
double m_deactivationTime;
|
||||
double m_friction;
|
||||
double m_rollingFriction;
|
||||
double m_contactDamping;
|
||||
double m_contactStiffness;
|
||||
double m_restitution;
|
||||
double m_hitFraction;
|
||||
double m_ccdSweptSphereRadius;
|
||||
|
|
@ -564,7 +662,9 @@ typedef struct bInvalidHandle {
|
|||
int m_activationState1;
|
||||
int m_internalType;
|
||||
int m_checkCollideWith;
|
||||
char m_padding[4];
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
int m_uniqueId;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -585,6 +685,8 @@ typedef struct bInvalidHandle {
|
|||
float m_deactivationTime;
|
||||
float m_friction;
|
||||
float m_rollingFriction;
|
||||
float m_contactDamping;
|
||||
float m_contactStiffness;
|
||||
float m_restitution;
|
||||
float m_hitFraction;
|
||||
float m_ccdSweptSphereRadius;
|
||||
|
|
@ -596,7 +698,9 @@ typedef struct bInvalidHandle {
|
|||
int m_activationState1;
|
||||
int m_internalType;
|
||||
int m_checkCollideWith;
|
||||
char m_padding[4];
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
int m_uniqueId;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -618,6 +722,7 @@ typedef struct bInvalidHandle {
|
|||
double m_splitImpulseTurnErp;
|
||||
double m_linearSlop;
|
||||
double m_warmstartingFactor;
|
||||
double m_articulatedWarmstartingFactor;
|
||||
double m_maxGyroscopicForce;
|
||||
double m_singleAxisRollingFrictionThreshold;
|
||||
int m_numIterations;
|
||||
|
|
@ -647,6 +752,7 @@ typedef struct bInvalidHandle {
|
|||
float m_splitImpulseTurnErp;
|
||||
float m_linearSlop;
|
||||
float m_warmstartingFactor;
|
||||
float m_articulatedWarmstartingFactor;
|
||||
float m_maxGyroscopicForce;
|
||||
float m_singleAxisRollingFrictionThreshold;
|
||||
int m_numIterations;
|
||||
|
|
@ -654,7 +760,6 @@ typedef struct bInvalidHandle {
|
|||
int m_restingContactRestitutionThreshold;
|
||||
int m_minimumSolverBatchSize;
|
||||
int m_splitImpulse;
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1349,11 +1454,15 @@ typedef struct bInvalidHandle {
|
|||
{
|
||||
public:
|
||||
btQuaternionDoubleData m_zeroRotParentToThis;
|
||||
btVector3DoubleData m_parentComToThisComOffset;
|
||||
btVector3DoubleData m_parentComToThisPivotOffset;
|
||||
btVector3DoubleData m_thisPivotToThisComOffset;
|
||||
btVector3DoubleData m_jointAxisTop[6];
|
||||
btVector3DoubleData m_jointAxisBottom[6];
|
||||
btVector3DoubleData m_linkInertia;
|
||||
btVector3DoubleData m_absFrameTotVelocityTop;
|
||||
btVector3DoubleData m_absFrameTotVelocityBottom;
|
||||
btVector3DoubleData m_absFrameLocVelocityTop;
|
||||
btVector3DoubleData m_absFrameLocVelocityBottom;
|
||||
double m_linkMass;
|
||||
int m_parentIndex;
|
||||
int m_jointType;
|
||||
|
|
@ -1364,6 +1473,10 @@ typedef struct bInvalidHandle {
|
|||
double m_jointTorque[6];
|
||||
double m_jointDamping;
|
||||
double m_jointFriction;
|
||||
double m_jointLowerLimit;
|
||||
double m_jointUpperLimit;
|
||||
double m_jointMaxForce;
|
||||
double m_jointMaxVelocity;
|
||||
char *m_linkName;
|
||||
char *m_jointName;
|
||||
btCollisionObjectDoubleData *m_linkCollider;
|
||||
|
|
@ -1376,11 +1489,15 @@ typedef struct bInvalidHandle {
|
|||
{
|
||||
public:
|
||||
btQuaternionFloatData m_zeroRotParentToThis;
|
||||
btVector3FloatData m_parentComToThisComOffset;
|
||||
btVector3FloatData m_parentComToThisPivotOffset;
|
||||
btVector3FloatData m_thisPivotToThisComOffset;
|
||||
btVector3FloatData m_jointAxisTop[6];
|
||||
btVector3FloatData m_jointAxisBottom[6];
|
||||
btVector3FloatData m_linkInertia;
|
||||
btVector3FloatData m_absFrameTotVelocityTop;
|
||||
btVector3FloatData m_absFrameTotVelocityBottom;
|
||||
btVector3FloatData m_absFrameLocVelocityTop;
|
||||
btVector3FloatData m_absFrameLocVelocityBottom;
|
||||
int m_dofCount;
|
||||
float m_linkMass;
|
||||
int m_parentIndex;
|
||||
|
|
@ -1391,6 +1508,10 @@ typedef struct bInvalidHandle {
|
|||
int m_posVarCount;
|
||||
float m_jointDamping;
|
||||
float m_jointFriction;
|
||||
float m_jointLowerLimit;
|
||||
float m_jointUpperLimit;
|
||||
float m_jointMaxForce;
|
||||
float m_jointMaxVelocity;
|
||||
char *m_linkName;
|
||||
char *m_jointName;
|
||||
btCollisionObjectFloatData *m_linkCollider;
|
||||
|
|
@ -1402,15 +1523,17 @@ typedef struct bInvalidHandle {
|
|||
class btMultiBodyDoubleData
|
||||
{
|
||||
public:
|
||||
btTransformDoubleData m_baseWorldTransform;
|
||||
btVector3DoubleData m_baseWorldPosition;
|
||||
btQuaternionDoubleData m_baseWorldOrientation;
|
||||
btVector3DoubleData m_baseLinearVelocity;
|
||||
btVector3DoubleData m_baseAngularVelocity;
|
||||
btVector3DoubleData m_baseInertia;
|
||||
double m_baseMass;
|
||||
int m_numLinks;
|
||||
char m_padding[4];
|
||||
char *m_baseName;
|
||||
btMultiBodyLinkDoubleData *m_links;
|
||||
btCollisionObjectDoubleData *m_baseCollider;
|
||||
char *m_paddingPtr;
|
||||
int m_numLinks;
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1418,13 +1541,38 @@ typedef struct bInvalidHandle {
|
|||
class btMultiBodyFloatData
|
||||
{
|
||||
public:
|
||||
char *m_baseName;
|
||||
btMultiBodyLinkFloatData *m_links;
|
||||
btCollisionObjectFloatData *m_baseCollider;
|
||||
btTransformFloatData m_baseWorldTransform;
|
||||
btVector3FloatData m_baseWorldPosition;
|
||||
btQuaternionFloatData m_baseWorldOrientation;
|
||||
btVector3FloatData m_baseLinearVelocity;
|
||||
btVector3FloatData m_baseAngularVelocity;
|
||||
btVector3FloatData m_baseInertia;
|
||||
float m_baseMass;
|
||||
int m_numLinks;
|
||||
char *m_baseName;
|
||||
btMultiBodyLinkFloatData *m_links;
|
||||
btCollisionObjectFloatData *m_baseCollider;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
class btMultiBodyLinkColliderFloatData
|
||||
{
|
||||
public:
|
||||
btCollisionObjectFloatData m_colObjData;
|
||||
btMultiBodyFloatData *m_multiBody;
|
||||
int m_link;
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------- //
|
||||
class btMultiBodyLinkColliderDoubleData
|
||||
{
|
||||
public:
|
||||
btCollisionObjectDoubleData m_colObjData;
|
||||
btMultiBodyDoubleData *m_multiBody;
|
||||
int m_link;
|
||||
char m_padding[4];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,13 @@ subject to the following restrictions:
|
|||
#include "bDefines.h"
|
||||
#include "bFile.h"
|
||||
|
||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||
#if !defined(__CELLOS_LV2__) && !defined(__MWERKS__)
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
|
||||
using namespace bParse;
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
short ChunkUtils::swapShort(short sht)
|
||||
{
|
||||
|
|
@ -57,19 +55,15 @@ int ChunkUtils::getOffset(int flags)
|
|||
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
if (flags &FD_BITS_VARIES)
|
||||
if (flags & FD_BITS_VARIES)
|
||||
res = sizeof(bChunkPtr4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flags &FD_BITS_VARIES)
|
||||
if (flags & FD_BITS_VARIES)
|
||||
res = sizeof(bChunkPtr8);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//eof
|
||||
|
|
|
|||
|
|
@ -16,77 +16,69 @@ subject to the following restrictions:
|
|||
#ifndef __BCHUNK_H__
|
||||
#define __BCHUNK_H__
|
||||
|
||||
#if defined (_WIN32) && ! defined (__MINGW32__)
|
||||
#define long64 __int64
|
||||
#elif defined (__MINGW32__)
|
||||
#include <stdint.h>
|
||||
#define long64 int64_t
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#define long64 __int64
|
||||
#elif defined(__MINGW32__)
|
||||
#include <stdint.h>
|
||||
#define long64 int64_t
|
||||
#else
|
||||
#define long64 long long
|
||||
#define long64 long long
|
||||
#endif
|
||||
|
||||
|
||||
namespace bParse {
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class bChunkPtr4
|
||||
{
|
||||
public:
|
||||
bChunkPtr4(){}
|
||||
int code;
|
||||
int len;
|
||||
union
|
||||
{
|
||||
int m_uniqueInt;
|
||||
};
|
||||
int dna_nr;
|
||||
int nr;
|
||||
namespace bParse
|
||||
{
|
||||
// ----------------------------------------------------- //
|
||||
class bChunkPtr4
|
||||
{
|
||||
public:
|
||||
bChunkPtr4() {}
|
||||
int code;
|
||||
int len;
|
||||
union {
|
||||
int m_uniqueInt;
|
||||
};
|
||||
int dna_nr;
|
||||
int nr;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class bChunkPtr8
|
||||
{
|
||||
public:
|
||||
bChunkPtr8(){}
|
||||
int code, len;
|
||||
union
|
||||
{
|
||||
long64 oldPrev;
|
||||
int m_uniqueInts[2];
|
||||
};
|
||||
int dna_nr, nr;
|
||||
// ----------------------------------------------------- //
|
||||
class bChunkPtr8
|
||||
{
|
||||
public:
|
||||
bChunkPtr8() {}
|
||||
int code, len;
|
||||
union {
|
||||
long64 oldPrev;
|
||||
int m_uniqueInts[2];
|
||||
};
|
||||
int dna_nr, nr;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class bChunkInd
|
||||
{
|
||||
public:
|
||||
bChunkInd(){}
|
||||
int code, len;
|
||||
void *oldPtr;
|
||||
int dna_nr, nr;
|
||||
};
|
||||
// ----------------------------------------------------- //
|
||||
class bChunkInd
|
||||
{
|
||||
public:
|
||||
bChunkInd() {}
|
||||
int code, len;
|
||||
void *oldPtr;
|
||||
int dna_nr, nr;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class ChunkUtils
|
||||
{
|
||||
public:
|
||||
// file chunk offset
|
||||
static int getOffset(int flags);
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class ChunkUtils
|
||||
{
|
||||
public:
|
||||
|
||||
// file chunk offset
|
||||
static int getOffset(int flags);
|
||||
// endian utils
|
||||
static short swapShort(short sht);
|
||||
static int swapInt(int inte);
|
||||
static long64 swapLong64(long64 lng);
|
||||
};
|
||||
|
||||
// endian utils
|
||||
static short swapShort(short sht);
|
||||
static int swapInt(int inte);
|
||||
static long64 swapLong64(long64 lng);
|
||||
const int CHUNK_HEADER_LEN = ((sizeof(bChunkInd)));
|
||||
const bool VOID_IS_8 = ((sizeof(void *) == 8));
|
||||
} // namespace bParse
|
||||
|
||||
};
|
||||
|
||||
|
||||
const int CHUNK_HEADER_LEN = ((sizeof(bChunkInd)));
|
||||
const bool VOID_IS_8 = ((sizeof(void*)==8));
|
||||
}
|
||||
|
||||
#endif//__BCHUNK_H__
|
||||
#endif //__BCHUNK_H__
|
||||
|
|
|
|||
|
|
@ -16,24 +16,25 @@ subject to the following restrictions:
|
|||
#ifndef __BCOMMON_H__
|
||||
#define __BCOMMON_H__
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
//#include "bLog.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "LinearMath/btHashMap.h"
|
||||
|
||||
namespace bParse {
|
||||
namespace bParse
|
||||
{
|
||||
class bMain;
|
||||
class bFileData;
|
||||
class bFile;
|
||||
class bDNA;
|
||||
|
||||
class bMain;
|
||||
class bFileData;
|
||||
class bFile;
|
||||
class bDNA;
|
||||
// delete void* undefined
|
||||
typedef struct bStructHandle
|
||||
{
|
||||
int unused;
|
||||
} bStructHandle;
|
||||
typedef btAlignedObjectArray<bStructHandle*> bListBasePtr;
|
||||
typedef btHashMap<btHashPtr, bStructHandle*> bPtrMap;
|
||||
} // namespace bParse
|
||||
|
||||
// delete void* undefined
|
||||
typedef struct bStructHandle {int unused;}bStructHandle;
|
||||
typedef btAlignedObjectArray<bStructHandle*> bListBasePtr;
|
||||
typedef btHashMap<btHashPtr, bStructHandle*> bPtrMap;
|
||||
}
|
||||
|
||||
|
||||
#endif//__BCOMMON_H__
|
||||
#endif //__BCOMMON_H__
|
||||
|
|
|
|||
|
|
@ -23,13 +23,11 @@ subject to the following restrictions:
|
|||
//this define will force traversal of structures, to check backward (and forward) compatibility
|
||||
//#define TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||
|
||||
|
||||
using namespace bParse;
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
bDNA::bDNA()
|
||||
: mPtrLen(0)
|
||||
: mPtrLen(0)
|
||||
{
|
||||
// --
|
||||
}
|
||||
|
|
@ -43,7 +41,7 @@ bDNA::~bDNA()
|
|||
// ----------------------------------------------------- //
|
||||
bool bDNA::lessThan(bDNA *file)
|
||||
{
|
||||
return ( m_Names.size() < file->m_Names.size());
|
||||
return (m_Names.size() < file->m_Names.size());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
|
|
@ -53,36 +51,31 @@ char *bDNA::getName(int ind)
|
|||
return m_Names[ind].m_name;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
char *bDNA::getType(int ind)
|
||||
{
|
||||
assert(ind<= (int)mTypes.size());
|
||||
assert(ind <= (int)mTypes.size());
|
||||
return mTypes[ind];
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
short *bDNA::getStruct(int ind)
|
||||
{
|
||||
assert(ind <= (int)mStructs.size());
|
||||
assert(ind <= (int)mStructs.size());
|
||||
return mStructs[ind];
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
short bDNA::getLength(int ind)
|
||||
{
|
||||
assert(ind <= (int)mTlens.size());
|
||||
assert(ind <= (int)mTlens.size());
|
||||
return mTlens[ind];
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
int bDNA::getReverseType(short type)
|
||||
{
|
||||
|
||||
int* intPtr = mStructReverse.find(type);
|
||||
int *intPtr = mStructReverse.find(type);
|
||||
if (intPtr)
|
||||
return *intPtr;
|
||||
|
||||
|
|
@ -92,12 +85,11 @@ int bDNA::getReverseType(short type)
|
|||
// ----------------------------------------------------- //
|
||||
int bDNA::getReverseType(const char *type)
|
||||
{
|
||||
|
||||
btHashString key(type);
|
||||
int* valuePtr = mTypeLookup.find(key);
|
||||
int *valuePtr = mTypeLookup.find(key);
|
||||
if (valuePtr)
|
||||
return *valuePtr;
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -110,22 +102,22 @@ int bDNA::getNumStructs()
|
|||
// ----------------------------------------------------- //
|
||||
bool bDNA::flagNotEqual(int dna_nr)
|
||||
{
|
||||
assert(dna_nr <= (int)mCMPFlags.size());
|
||||
assert(dna_nr <= (int)mCMPFlags.size());
|
||||
return mCMPFlags[dna_nr] == FDF_STRUCT_NEQU;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
bool bDNA::flagEqual(int dna_nr)
|
||||
{
|
||||
assert(dna_nr <= (int)mCMPFlags.size());
|
||||
assert(dna_nr <= (int)mCMPFlags.size());
|
||||
int flag = mCMPFlags[dna_nr];
|
||||
return flag == FDF_STRUCT_EQU;
|
||||
return flag == FDF_STRUCT_EQU;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
bool bDNA::flagNone(int dna_nr)
|
||||
{
|
||||
assert(dna_nr <= (int)mCMPFlags.size());
|
||||
assert(dna_nr <= (int)mCMPFlags.size());
|
||||
return mCMPFlags[dna_nr] == FDF_NONE;
|
||||
}
|
||||
|
||||
|
|
@ -143,15 +135,15 @@ void bDNA::initRecurseCmpFlags(int iter)
|
|||
short *oldStrc = mStructs[iter];
|
||||
short type = oldStrc[0];
|
||||
|
||||
for (int i=0; i<(int)mStructs.size(); i++)
|
||||
for (int i = 0; i < (int)mStructs.size(); i++)
|
||||
{
|
||||
if (i != iter && mCMPFlags[i] == FDF_STRUCT_EQU )
|
||||
if (i != iter && mCMPFlags[i] == FDF_STRUCT_EQU)
|
||||
{
|
||||
short *curStruct = mStructs[i];
|
||||
int eleLen = curStruct[1];
|
||||
curStruct+=2;
|
||||
curStruct += 2;
|
||||
|
||||
for (int j=0; j<eleLen; j++, curStruct+=2)
|
||||
for (int j = 0; j < eleLen; j++, curStruct += 2)
|
||||
{
|
||||
if (curStruct[0] == type)
|
||||
{
|
||||
|
|
@ -171,19 +163,15 @@ void bDNA::initRecurseCmpFlags(int iter)
|
|||
// ----------------------------------------------------- //
|
||||
void bDNA::initCmpFlags(bDNA *memDNA)
|
||||
{
|
||||
|
||||
// compare the file to memory
|
||||
// compare the file to memory
|
||||
// this ptr should be the file data
|
||||
|
||||
|
||||
assert(!(m_Names.size() == 0));//DNA empty!
|
||||
assert(!(m_Names.size() == 0)); //DNA empty!
|
||||
|
||||
mCMPFlags.resize(mStructs.size(), FDF_NONE);
|
||||
|
||||
|
||||
|
||||
int i;
|
||||
for ( i=0; i<(int)mStructs.size(); i++)
|
||||
for (i = 0; i < (int)mStructs.size(); i++)
|
||||
{
|
||||
short *oldStruct = mStructs[i];
|
||||
|
||||
|
|
@ -197,7 +185,7 @@ void bDNA::initCmpFlags(bDNA *memDNA)
|
|||
|
||||
//#define SLOW_FORWARD_COMPATIBLE 1
|
||||
#ifdef SLOW_FORWARD_COMPATIBLE
|
||||
char* typeName = mTypes[oldLookup];
|
||||
char *typeName = mTypes[oldLookup];
|
||||
int newLookup = memDNA->getReverseType(typeName);
|
||||
if (newLookup == -1)
|
||||
{
|
||||
|
|
@ -211,71 +199,61 @@ void bDNA::initCmpFlags(bDNA *memDNA)
|
|||
if (oldLookup < memDNA->mStructs.size())
|
||||
{
|
||||
short *curStruct = memDNA->mStructs[oldLookup];
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// rebuild...
|
||||
mCMPFlags[i] = FDF_STRUCT_NEQU;
|
||||
// rebuild...
|
||||
mCMPFlags[i] = FDF_STRUCT_NEQU;
|
||||
|
||||
#ifndef TEST_BACKWARD_FORWARD_COMPATIBILITY
|
||||
|
||||
if (curStruct[1] == oldStruct[1])
|
||||
if (curStruct[1] == oldStruct[1])
|
||||
{
|
||||
// type len same ...
|
||||
if (mTlens[oldStruct[0]] == memDNA->mTlens[curStruct[0]])
|
||||
{
|
||||
// type len same ...
|
||||
if (mTlens[oldStruct[0]] == memDNA->mTlens[curStruct[0]])
|
||||
bool isSame = true;
|
||||
int elementLength = oldStruct[1];
|
||||
|
||||
curStruct += 2;
|
||||
oldStruct += 2;
|
||||
|
||||
for (int j = 0; j < elementLength; j++, curStruct += 2, oldStruct += 2)
|
||||
{
|
||||
bool isSame = true;
|
||||
int elementLength = oldStruct[1];
|
||||
|
||||
|
||||
curStruct+=2;
|
||||
oldStruct+=2;
|
||||
|
||||
|
||||
for (int j=0; j<elementLength; j++, curStruct+=2, oldStruct+=2)
|
||||
// type the same
|
||||
//const char* typeFileDNA = mTypes[oldStruct[0]];
|
||||
//const char* typeMemDNA = mTypes[curStruct[0]];
|
||||
if (strcmp(mTypes[oldStruct[0]], memDNA->mTypes[curStruct[0]]) != 0)
|
||||
{
|
||||
// type the same
|
||||
//const char* typeFileDNA = mTypes[oldStruct[0]];
|
||||
//const char* typeMemDNA = mTypes[curStruct[0]];
|
||||
if (strcmp(mTypes[oldStruct[0]], memDNA->mTypes[curStruct[0]])!=0)
|
||||
{
|
||||
isSame=false;
|
||||
break;
|
||||
}
|
||||
|
||||
// name the same
|
||||
if (strcmp(m_Names[oldStruct[1]].m_name, memDNA->m_Names[curStruct[1]].m_name)!=0)
|
||||
{
|
||||
isSame=false;
|
||||
break;
|
||||
}
|
||||
isSame = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// name the same
|
||||
if (strcmp(m_Names[oldStruct[1]].m_name, memDNA->m_Names[curStruct[1]].m_name) != 0)
|
||||
{
|
||||
isSame = false;
|
||||
break;
|
||||
}
|
||||
// flag valid ==
|
||||
if (isSame)
|
||||
mCMPFlags[i] = FDF_STRUCT_EQU;
|
||||
}
|
||||
// flag valid ==
|
||||
if (isSame)
|
||||
mCMPFlags[i] = FDF_STRUCT_EQU;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// recurse in
|
||||
for ( i=0; i<(int)mStructs.size(); i++)
|
||||
{
|
||||
if (mCMPFlags[i] == FDF_STRUCT_NEQU)
|
||||
initRecurseCmpFlags(i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// recurse in
|
||||
for (i = 0; i < (int)mStructs.size(); i++)
|
||||
{
|
||||
if (mCMPFlags[i] == FDF_STRUCT_NEQU)
|
||||
initRecurseCmpFlags(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int name_is_array(char* name, int* dim1, int* dim2) {
|
||||
static int name_is_array(char *name, int *dim1, int *dim2)
|
||||
{
|
||||
int len = strlen(name);
|
||||
/*fprintf(stderr,"[%s]",name);*/
|
||||
/*if (len >= 1) {
|
||||
|
|
@ -285,58 +263,77 @@ static int name_is_array(char* name, int* dim1, int* dim2) {
|
|||
return 0;*/
|
||||
char *bp;
|
||||
int num;
|
||||
if (dim1) {
|
||||
if (dim1)
|
||||
{
|
||||
*dim1 = 1;
|
||||
}
|
||||
if (dim2) {
|
||||
if (dim2)
|
||||
{
|
||||
*dim2 = 1;
|
||||
}
|
||||
bp = strchr(name, '[');
|
||||
if (!bp) {
|
||||
if (!bp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
num = 0;
|
||||
while (++bp < name+len-1) {
|
||||
while (++bp < name + len - 1)
|
||||
{
|
||||
const char c = *bp;
|
||||
if (c == ']') {
|
||||
if (c == ']')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (c <= '9' && c >= '0') {
|
||||
if (c <= '9' && c >= '0')
|
||||
{
|
||||
num *= 10;
|
||||
num += (c - '0');
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("array parse error.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (dim2) {
|
||||
if (dim2)
|
||||
{
|
||||
*dim2 = num;
|
||||
}
|
||||
|
||||
/* find second dim, if any. */
|
||||
bp = strchr(bp, '[');
|
||||
if (!bp) {
|
||||
if (!bp)
|
||||
{
|
||||
return 1; /* at least we got the first dim. */
|
||||
}
|
||||
num = 0;
|
||||
while (++bp < name+len-1) {
|
||||
while (++bp < name + len - 1)
|
||||
{
|
||||
const char c = *bp;
|
||||
if (c == ']') {
|
||||
if (c == ']')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (c <= '9' && c >= '0') {
|
||||
if (c <= '9' && c >= '0')
|
||||
{
|
||||
num *= 10;
|
||||
num += (c - '0');
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("array2 parse error.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (dim1) {
|
||||
if (dim2) {
|
||||
if (dim1)
|
||||
{
|
||||
if (dim2)
|
||||
{
|
||||
*dim1 = *dim2;
|
||||
*dim2 = num;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*dim1 = num;
|
||||
}
|
||||
}
|
||||
|
|
@ -344,13 +341,15 @@ static int name_is_array(char* name, int* dim1, int* dim2) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
void bDNA::init(char *data, int len, bool swap)
|
||||
{
|
||||
int *intPtr=0;short *shtPtr=0;
|
||||
char *cp = 0;int dataLen =0;long nr=0;
|
||||
intPtr = (int*)data;
|
||||
int *intPtr = 0;
|
||||
short *shtPtr = 0;
|
||||
char *cp = 0;
|
||||
int dataLen = 0;
|
||||
//long nr=0;
|
||||
intPtr = (int *)data;
|
||||
|
||||
/*
|
||||
SDNA (4 bytes) (magic number)
|
||||
|
|
@ -360,39 +359,36 @@ void bDNA::init(char *data, int len, bool swap)
|
|||
<string>
|
||||
*/
|
||||
|
||||
if (strncmp(data, "SDNA", 4)==0)
|
||||
if (strncmp(data, "SDNA", 4) == 0)
|
||||
{
|
||||
// skip ++ NAME
|
||||
intPtr++; intPtr++;
|
||||
intPtr++;
|
||||
intPtr++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Parse names
|
||||
if (swap)
|
||||
if (swap)
|
||||
{
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
}
|
||||
dataLen = *intPtr;
|
||||
intPtr++;
|
||||
|
||||
cp = (char*)intPtr;
|
||||
cp = (char *)intPtr;
|
||||
int i;
|
||||
for ( i=0; i<dataLen; i++)
|
||||
for (i = 0; i < dataLen; i++)
|
||||
{
|
||||
bNameInfo info;
|
||||
info.m_name = cp;
|
||||
info.m_isPointer = (info.m_name[0] == '*') || (info.m_name[1] == '*');
|
||||
name_is_array(info.m_name,&info.m_dim0,&info.m_dim1);
|
||||
name_is_array(info.m_name, &info.m_dim0, &info.m_dim1);
|
||||
m_Names.push_back(info);
|
||||
while (*cp)cp++;
|
||||
while (*cp) cp++;
|
||||
cp++;
|
||||
}
|
||||
|
||||
cp = btAlignPointer(cp, 4);
|
||||
|
||||
|
||||
cp = btAlignPointer(cp,4);
|
||||
|
||||
/*
|
||||
TYPE (4 bytes)
|
||||
<nr> amount of types (int)
|
||||
|
|
@ -400,26 +396,27 @@ void bDNA::init(char *data, int len, bool swap)
|
|||
<string>
|
||||
*/
|
||||
|
||||
intPtr = (int*)cp;
|
||||
assert(strncmp(cp, "TYPE", 4)==0); intPtr++;
|
||||
intPtr = (int *)cp;
|
||||
assert(strncmp(cp, "TYPE", 4) == 0);
|
||||
intPtr++;
|
||||
|
||||
if (swap)
|
||||
if (swap)
|
||||
{
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
}
|
||||
dataLen = *intPtr;
|
||||
intPtr++;
|
||||
|
||||
cp = (char*)intPtr;
|
||||
for ( i=0; i<dataLen; i++)
|
||||
cp = (char *)intPtr;
|
||||
for (i = 0; i < dataLen; i++)
|
||||
{
|
||||
mTypes.push_back(cp);
|
||||
while (*cp)cp++;
|
||||
while (*cp) cp++;
|
||||
cp++;
|
||||
}
|
||||
|
||||
cp = btAlignPointer(cp,4);
|
||||
|
||||
cp = btAlignPointer(cp, 4);
|
||||
|
||||
/*
|
||||
TLEN (4 bytes)
|
||||
<len> (short) the lengths of types
|
||||
|
|
@ -427,13 +424,14 @@ void bDNA::init(char *data, int len, bool swap)
|
|||
*/
|
||||
|
||||
// Parse type lens
|
||||
intPtr = (int*)cp;
|
||||
assert(strncmp(cp, "TLEN", 4)==0); intPtr++;
|
||||
intPtr = (int *)cp;
|
||||
assert(strncmp(cp, "TLEN", 4) == 0);
|
||||
intPtr++;
|
||||
|
||||
dataLen = (int)mTypes.size();
|
||||
|
||||
shtPtr = (short*)intPtr;
|
||||
for ( i=0; i<dataLen; i++, shtPtr++)
|
||||
shtPtr = (short *)intPtr;
|
||||
for (i = 0; i < dataLen; i++, shtPtr++)
|
||||
{
|
||||
if (swap)
|
||||
shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]);
|
||||
|
|
@ -453,94 +451,89 @@ void bDNA::init(char *data, int len, bool swap)
|
|||
<namenr>
|
||||
*/
|
||||
|
||||
intPtr = (int*)shtPtr;
|
||||
cp = (char*)intPtr;
|
||||
assert(strncmp(cp, "STRC", 4)==0); intPtr++;
|
||||
intPtr = (int *)shtPtr;
|
||||
cp = (char *)intPtr;
|
||||
assert(strncmp(cp, "STRC", 4) == 0);
|
||||
intPtr++;
|
||||
|
||||
if (swap)
|
||||
if (swap)
|
||||
{
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
}
|
||||
dataLen = *intPtr;
|
||||
intPtr++;
|
||||
|
||||
|
||||
shtPtr = (short*)intPtr;
|
||||
for ( i=0; i<dataLen; i++)
|
||||
shtPtr = (short *)intPtr;
|
||||
for (i = 0; i < dataLen; i++)
|
||||
{
|
||||
mStructs.push_back (shtPtr);
|
||||
mStructs.push_back(shtPtr);
|
||||
if (swap)
|
||||
{
|
||||
shtPtr[0]= ChunkUtils::swapShort(shtPtr[0]);
|
||||
shtPtr[1]= ChunkUtils::swapShort(shtPtr[1]);
|
||||
shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]);
|
||||
shtPtr[1] = ChunkUtils::swapShort(shtPtr[1]);
|
||||
|
||||
int len = shtPtr[1];
|
||||
shtPtr+= 2;
|
||||
shtPtr += 2;
|
||||
|
||||
for (int a=0; a<len; a++, shtPtr+=2)
|
||||
for (int a = 0; a < len; a++, shtPtr += 2)
|
||||
{
|
||||
shtPtr[0]= ChunkUtils::swapShort(shtPtr[0]);
|
||||
shtPtr[1]= ChunkUtils::swapShort(shtPtr[1]);
|
||||
shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]);
|
||||
shtPtr[1] = ChunkUtils::swapShort(shtPtr[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
shtPtr+= (2*shtPtr[1])+2;
|
||||
shtPtr += (2 * shtPtr[1]) + 2;
|
||||
}
|
||||
|
||||
|
||||
// build reverse lookups
|
||||
for ( i=0; i<(int)mStructs.size(); i++)
|
||||
for (i = 0; i < (int)mStructs.size(); i++)
|
||||
{
|
||||
short *strc = mStructs.at(i);
|
||||
if (!mPtrLen && strcmp(mTypes[strc[0]],"ListBase")==0)
|
||||
if (!mPtrLen && strcmp(mTypes[strc[0]], "ListBase") == 0)
|
||||
{
|
||||
mPtrLen = mTlens[strc[0]]/2;
|
||||
mPtrLen = mTlens[strc[0]] / 2;
|
||||
}
|
||||
|
||||
mStructReverse.insert(strc[0], i);
|
||||
mTypeLookup.insert(btHashString(mTypes[strc[0]]),i);
|
||||
mTypeLookup.insert(btHashString(mTypes[strc[0]]), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
int bDNA::getArraySize(char* string)
|
||||
int bDNA::getArraySize(char *string)
|
||||
{
|
||||
int ret = 1;
|
||||
int len = strlen(string);
|
||||
|
||||
|
||||
char* next = 0;
|
||||
for (int i=0; i<len; i++)
|
||||
char *next = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = string[i];
|
||||
|
||||
if (c == '[')
|
||||
next = &string[i+1];
|
||||
else if (c==']')
|
||||
next = &string[i + 1];
|
||||
else if (c == ']')
|
||||
if (next)
|
||||
ret *= atoi(next);
|
||||
}
|
||||
|
||||
// print (string << ' ' << ret);
|
||||
// print (string << ' ' << ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void bDNA::dumpTypeDefinitions()
|
||||
{
|
||||
int i;
|
||||
|
||||
int numTypes = mTypes.size();
|
||||
|
||||
for (i=0;i<numTypes;i++)
|
||||
{
|
||||
|
||||
for (i = 0; i < numTypes; i++)
|
||||
{
|
||||
}
|
||||
|
||||
for ( i=0; i<(int)mStructs.size(); i++)
|
||||
for (i = 0; i < (int)mStructs.size(); i++)
|
||||
{
|
||||
int totalBytes=0;
|
||||
int totalBytes = 0;
|
||||
short *oldStruct = mStructs[i];
|
||||
|
||||
int oldLookup = getReverseType(oldStruct[0]);
|
||||
|
|
@ -550,44 +543,46 @@ void bDNA::dumpTypeDefinitions()
|
|||
continue;
|
||||
}
|
||||
|
||||
short* newStruct = mStructs[oldLookup];
|
||||
char* typeName = mTypes[newStruct[0]];
|
||||
printf("%3d: %s ",i,typeName);
|
||||
|
||||
short *newStruct = mStructs[oldLookup];
|
||||
char *typeName = mTypes[newStruct[0]];
|
||||
printf("%3d: %s ", i, typeName);
|
||||
|
||||
//char *name = mNames[oldStruct[1]];
|
||||
int len = oldStruct[1];
|
||||
printf(" (%d fields) ",len);
|
||||
oldStruct+=2;
|
||||
printf(" (%d fields) ", len);
|
||||
oldStruct += 2;
|
||||
|
||||
printf("{");
|
||||
int j;
|
||||
for (j=0; j<len; ++j,oldStruct+=2) {
|
||||
const char* name = m_Names[oldStruct[1]].m_name;
|
||||
printf("%s %s", mTypes[oldStruct[0]],name);
|
||||
int elemNumBytes= 0;
|
||||
for (j = 0; j < len; ++j, oldStruct += 2)
|
||||
{
|
||||
const char *name = m_Names[oldStruct[1]].m_name;
|
||||
printf("%s %s", mTypes[oldStruct[0]], name);
|
||||
int elemNumBytes = 0;
|
||||
int arrayDimensions = getArraySizeNew(oldStruct[1]);
|
||||
|
||||
if (m_Names[oldStruct[1]].m_isPointer)
|
||||
{
|
||||
elemNumBytes = VOID_IS_8 ? 8 : 4;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
elemNumBytes = getLength(oldStruct[0]);
|
||||
}
|
||||
printf(" /* %d bytes */",elemNumBytes*arrayDimensions);
|
||||
|
||||
if (j == len-1) {
|
||||
printf(" /* %d bytes */", elemNumBytes * arrayDimensions);
|
||||
|
||||
if (j == len - 1)
|
||||
{
|
||||
printf(";}");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("; ");
|
||||
}
|
||||
totalBytes+=elemNumBytes*arrayDimensions;
|
||||
totalBytes += elemNumBytes * arrayDimensions;
|
||||
}
|
||||
printf("\ntotalBytes=%d\n\n",totalBytes);
|
||||
|
||||
printf("\ntotalBytes=%d\n\n", totalBytes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/* dump out display of types and their sizes */
|
||||
|
|
@ -617,12 +612,6 @@ void bDNA::dumpTypeDefinitions()
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//eof
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,95 +16,86 @@ subject to the following restrictions:
|
|||
#ifndef __BDNA_H__
|
||||
#define __BDNA_H__
|
||||
|
||||
|
||||
#include "bCommon.h"
|
||||
|
||||
namespace bParse {
|
||||
namespace bParse
|
||||
{
|
||||
struct bNameInfo
|
||||
{
|
||||
char *m_name;
|
||||
bool m_isPointer;
|
||||
int m_dim0;
|
||||
int m_dim1;
|
||||
};
|
||||
|
||||
struct bNameInfo
|
||||
class bDNA
|
||||
{
|
||||
public:
|
||||
bDNA();
|
||||
~bDNA();
|
||||
|
||||
void init(char *data, int len, bool swap = false);
|
||||
|
||||
int getArraySize(char *str);
|
||||
int getArraySizeNew(short name)
|
||||
{
|
||||
char* m_name;
|
||||
bool m_isPointer;
|
||||
int m_dim0;
|
||||
int m_dim1;
|
||||
const bNameInfo &nameInfo = m_Names[name];
|
||||
return nameInfo.m_dim0 * nameInfo.m_dim1;
|
||||
}
|
||||
int getElementSize(short type, short name)
|
||||
{
|
||||
const bNameInfo &nameInfo = m_Names[name];
|
||||
int size = nameInfo.m_isPointer ? mPtrLen * nameInfo.m_dim0 * nameInfo.m_dim1 : mTlens[type] * nameInfo.m_dim0 * nameInfo.m_dim1;
|
||||
return size;
|
||||
}
|
||||
|
||||
int getNumNames() const
|
||||
{
|
||||
return m_Names.size();
|
||||
}
|
||||
|
||||
char *getName(int ind);
|
||||
char *getType(int ind);
|
||||
short *getStruct(int ind);
|
||||
short getLength(int ind);
|
||||
int getReverseType(short type);
|
||||
int getReverseType(const char *type);
|
||||
|
||||
int getNumStructs();
|
||||
|
||||
//
|
||||
bool lessThan(bDNA *other);
|
||||
|
||||
void initCmpFlags(bDNA *memDNA);
|
||||
bool flagNotEqual(int dna_nr);
|
||||
bool flagEqual(int dna_nr);
|
||||
bool flagNone(int dna_nr);
|
||||
|
||||
int getPointerSize();
|
||||
|
||||
void dumpTypeDefinitions();
|
||||
|
||||
private:
|
||||
enum FileDNAFlags
|
||||
{
|
||||
FDF_NONE = 0,
|
||||
FDF_STRUCT_NEQU,
|
||||
FDF_STRUCT_EQU
|
||||
};
|
||||
|
||||
class bDNA
|
||||
{
|
||||
public:
|
||||
bDNA();
|
||||
~bDNA();
|
||||
void initRecurseCmpFlags(int i);
|
||||
|
||||
void init(char *data, int len, bool swap=false);
|
||||
btAlignedObjectArray<int> mCMPFlags;
|
||||
|
||||
int getArraySize(char* str);
|
||||
int getArraySizeNew(short name)
|
||||
{
|
||||
const bNameInfo& nameInfo = m_Names[name];
|
||||
return nameInfo.m_dim0*nameInfo.m_dim1;
|
||||
}
|
||||
int getElementSize(short type, short name)
|
||||
{
|
||||
const bNameInfo& nameInfo = m_Names[name];
|
||||
int size = nameInfo.m_isPointer ? mPtrLen*nameInfo.m_dim0*nameInfo.m_dim1 : mTlens[type]*nameInfo.m_dim0*nameInfo.m_dim1;
|
||||
return size;
|
||||
}
|
||||
btAlignedObjectArray<bNameInfo> m_Names;
|
||||
btAlignedObjectArray<char *> mTypes;
|
||||
btAlignedObjectArray<short *> mStructs;
|
||||
btAlignedObjectArray<short> mTlens;
|
||||
btHashMap<btHashInt, int> mStructReverse;
|
||||
btHashMap<btHashString, int> mTypeLookup;
|
||||
|
||||
int getNumNames() const
|
||||
{
|
||||
return m_Names.size();
|
||||
}
|
||||
int mPtrLen;
|
||||
};
|
||||
} // namespace bParse
|
||||
|
||||
char *getName(int ind);
|
||||
char *getType(int ind);
|
||||
short *getStruct(int ind);
|
||||
short getLength(int ind);
|
||||
int getReverseType(short type);
|
||||
int getReverseType(const char *type);
|
||||
|
||||
|
||||
int getNumStructs();
|
||||
|
||||
//
|
||||
bool lessThan(bDNA* other);
|
||||
|
||||
void initCmpFlags(bDNA *memDNA);
|
||||
bool flagNotEqual(int dna_nr);
|
||||
bool flagEqual(int dna_nr);
|
||||
bool flagNone(int dna_nr);
|
||||
|
||||
|
||||
int getPointerSize();
|
||||
|
||||
void dumpTypeDefinitions();
|
||||
|
||||
|
||||
private:
|
||||
enum FileDNAFlags
|
||||
{
|
||||
FDF_NONE=0,
|
||||
FDF_STRUCT_NEQU,
|
||||
FDF_STRUCT_EQU
|
||||
};
|
||||
|
||||
void initRecurseCmpFlags(int i);
|
||||
|
||||
btAlignedObjectArray<int> mCMPFlags;
|
||||
|
||||
btAlignedObjectArray<bNameInfo> m_Names;
|
||||
btAlignedObjectArray<char*> mTypes;
|
||||
btAlignedObjectArray<short*> mStructs;
|
||||
btAlignedObjectArray<short> mTlens;
|
||||
btHashMap<btHashInt, int> mStructReverse;
|
||||
btHashMap<btHashString,int> mTypeLookup;
|
||||
|
||||
int mPtrLen;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BDNA_H__
|
||||
#endif //__BDNA_H__
|
||||
|
|
|
|||
|
|
@ -19,121 +19,134 @@
|
|||
#ifndef __B_DEFINES_H__
|
||||
#define __B_DEFINES_H__
|
||||
|
||||
|
||||
// MISC defines, see BKE_global.h, BKE_utildefines.h
|
||||
#define SIZEOFBLENDERHEADER 12
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
|
||||
# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
|
||||
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined(__PPC__) || defined(__ppc__) || defined(__BIG_ENDIAN__)
|
||||
#define MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d))
|
||||
#else
|
||||
# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
|
||||
# define MAKE_ID2(c, d) ( (c)<<8 | (d) )
|
||||
# define MOST_SIG_BYTE 0
|
||||
# define BBIG_ENDIAN
|
||||
#else
|
||||
# define MAKE_ID2(c, d) ( (d)<<8 | (c) )
|
||||
# define MOST_SIG_BYTE 1
|
||||
# define BLITTLE_ENDIAN
|
||||
#define MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#define ID_SCE MAKE_ID2('S', 'C')
|
||||
#define ID_LI MAKE_ID2('L', 'I')
|
||||
#define ID_OB MAKE_ID2('O', 'B')
|
||||
#define ID_ME MAKE_ID2('M', 'E')
|
||||
#define ID_CU MAKE_ID2('C', 'U')
|
||||
#define ID_MB MAKE_ID2('M', 'B')
|
||||
#define ID_MA MAKE_ID2('M', 'A')
|
||||
#define ID_TE MAKE_ID2('T', 'E')
|
||||
#define ID_IM MAKE_ID2('I', 'M')
|
||||
#define ID_IK MAKE_ID2('I', 'K')
|
||||
#define ID_WV MAKE_ID2('W', 'V')
|
||||
#define ID_LT MAKE_ID2('L', 'T')
|
||||
#define ID_SE MAKE_ID2('S', 'E')
|
||||
#define ID_LF MAKE_ID2('L', 'F')
|
||||
#define ID_LA MAKE_ID2('L', 'A')
|
||||
#define ID_CA MAKE_ID2('C', 'A')
|
||||
#define ID_IP MAKE_ID2('I', 'P')
|
||||
#define ID_KE MAKE_ID2('K', 'E')
|
||||
#define ID_WO MAKE_ID2('W', 'O')
|
||||
#define ID_SCR MAKE_ID2('S', 'R')
|
||||
#define ID_VF MAKE_ID2('V', 'F')
|
||||
#define ID_TXT MAKE_ID2('T', 'X')
|
||||
#define ID_SO MAKE_ID2('S', 'O')
|
||||
#define ID_SAMPLE MAKE_ID2('S', 'A')
|
||||
#define ID_GR MAKE_ID2('G', 'R')
|
||||
#define ID_ID MAKE_ID2('I', 'D')
|
||||
#define ID_AR MAKE_ID2('A', 'R')
|
||||
#define ID_AC MAKE_ID2('A', 'C')
|
||||
#define ID_SCRIPT MAKE_ID2('P', 'Y')
|
||||
#define ID_FLUIDSIM MAKE_ID2('F', 'S')
|
||||
#define ID_NT MAKE_ID2('N', 'T')
|
||||
#define ID_BR MAKE_ID2('B', 'R')
|
||||
|
||||
|
||||
#define ID_SEQ MAKE_ID2('S', 'Q')
|
||||
#define ID_CO MAKE_ID2('C', 'O')
|
||||
#define ID_PO MAKE_ID2('A', 'C')
|
||||
#define ID_NLA MAKE_ID2('N', 'L')
|
||||
|
||||
#define ID_VS MAKE_ID2('V', 'S')
|
||||
#define ID_VN MAKE_ID2('V', 'N')
|
||||
|
||||
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined(__PPC__) || defined(__ppc__) || defined(__BIG_ENDIAN__)
|
||||
#define MAKE_ID2(c, d) ((c) << 8 | (d))
|
||||
#define MOST_SIG_BYTE 0
|
||||
#define BBIG_ENDIAN
|
||||
#else
|
||||
#define MAKE_ID2(c, d) ((d) << 8 | (c))
|
||||
#define MOST_SIG_BYTE 1
|
||||
#define BLITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#define FORM MAKE_ID('F','O','R','M')
|
||||
#define DDG1 MAKE_ID('3','D','G','1')
|
||||
#define DDG2 MAKE_ID('3','D','G','2')
|
||||
#define DDG3 MAKE_ID('3','D','G','3')
|
||||
#define DDG4 MAKE_ID('3','D','G','4')
|
||||
#define GOUR MAKE_ID('G','O','U','R')
|
||||
#define BLEN MAKE_ID('B','L','E','N')
|
||||
#define DER_ MAKE_ID('D','E','R','_')
|
||||
#define V100 MAKE_ID('V','1','0','0')
|
||||
#define DATA MAKE_ID('D','A','T','A')
|
||||
#define GLOB MAKE_ID('G','L','O','B')
|
||||
#define IMAG MAKE_ID('I','M','A','G')
|
||||
#define USER MAKE_ID('U','S','E','R')
|
||||
#define ID_SCE MAKE_ID2('S', 'C')
|
||||
#define ID_LI MAKE_ID2('L', 'I')
|
||||
#define ID_OB MAKE_ID2('O', 'B')
|
||||
#define ID_ME MAKE_ID2('M', 'E')
|
||||
#define ID_CU MAKE_ID2('C', 'U')
|
||||
#define ID_MB MAKE_ID2('M', 'B')
|
||||
#define ID_MA MAKE_ID2('M', 'A')
|
||||
#define ID_TE MAKE_ID2('T', 'E')
|
||||
#define ID_IM MAKE_ID2('I', 'M')
|
||||
#define ID_IK MAKE_ID2('I', 'K')
|
||||
#define ID_WV MAKE_ID2('W', 'V')
|
||||
#define ID_LT MAKE_ID2('L', 'T')
|
||||
#define ID_SE MAKE_ID2('S', 'E')
|
||||
#define ID_LF MAKE_ID2('L', 'F')
|
||||
#define ID_LA MAKE_ID2('L', 'A')
|
||||
#define ID_CA MAKE_ID2('C', 'A')
|
||||
#define ID_IP MAKE_ID2('I', 'P')
|
||||
#define ID_KE MAKE_ID2('K', 'E')
|
||||
#define ID_WO MAKE_ID2('W', 'O')
|
||||
#define ID_SCR MAKE_ID2('S', 'R')
|
||||
#define ID_VF MAKE_ID2('V', 'F')
|
||||
#define ID_TXT MAKE_ID2('T', 'X')
|
||||
#define ID_SO MAKE_ID2('S', 'O')
|
||||
#define ID_SAMPLE MAKE_ID2('S', 'A')
|
||||
#define ID_GR MAKE_ID2('G', 'R')
|
||||
#define ID_ID MAKE_ID2('I', 'D')
|
||||
#define ID_AR MAKE_ID2('A', 'R')
|
||||
#define ID_AC MAKE_ID2('A', 'C')
|
||||
#define ID_SCRIPT MAKE_ID2('P', 'Y')
|
||||
#define ID_FLUIDSIM MAKE_ID2('F', 'S')
|
||||
#define ID_NT MAKE_ID2('N', 'T')
|
||||
#define ID_BR MAKE_ID2('B', 'R')
|
||||
|
||||
#define ID_SEQ MAKE_ID2('S', 'Q')
|
||||
#define ID_CO MAKE_ID2('C', 'O')
|
||||
#define ID_PO MAKE_ID2('A', 'C')
|
||||
#define ID_NLA MAKE_ID2('N', 'L')
|
||||
|
||||
#define ID_VS MAKE_ID2('V', 'S')
|
||||
#define ID_VN MAKE_ID2('V', 'N')
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#define DNA1 MAKE_ID('D','N','A','1')
|
||||
#define REND MAKE_ID('R','E','N','D')
|
||||
#define ENDB MAKE_ID('E','N','D','B')
|
||||
#define NAME MAKE_ID('N','A','M','E')
|
||||
#define SDNA MAKE_ID('S','D','N','A')
|
||||
#define TYPE MAKE_ID('T','Y','P','E')
|
||||
#define TLEN MAKE_ID('T','L','E','N')
|
||||
#define STRC MAKE_ID('S','T','R','C')
|
||||
|
||||
#define FORM MAKE_ID('F', 'O', 'R', 'M')
|
||||
#define DDG1 MAKE_ID('3', 'D', 'G', '1')
|
||||
#define DDG2 MAKE_ID('3', 'D', 'G', '2')
|
||||
#define DDG3 MAKE_ID('3', 'D', 'G', '3')
|
||||
#define DDG4 MAKE_ID('3', 'D', 'G', '4')
|
||||
#define GOUR MAKE_ID('G', 'O', 'U', 'R')
|
||||
#define BLEN MAKE_ID('B', 'L', 'E', 'N')
|
||||
#define DER_ MAKE_ID('D', 'E', 'R', '_')
|
||||
#define V100 MAKE_ID('V', '1', '0', '0')
|
||||
#define DATA MAKE_ID('D', 'A', 'T', 'A')
|
||||
#define GLOB MAKE_ID('G', 'L', 'O', 'B')
|
||||
#define IMAG MAKE_ID('I', 'M', 'A', 'G')
|
||||
#define USER MAKE_ID('U', 'S', 'E', 'R')
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#define SWITCH_INT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
|
||||
s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
|
||||
#define DNA1 MAKE_ID('D', 'N', 'A', '1')
|
||||
#define REND MAKE_ID('R', 'E', 'N', 'D')
|
||||
#define ENDB MAKE_ID('E', 'N', 'D', 'B')
|
||||
#define NAME MAKE_ID('N', 'A', 'M', 'E')
|
||||
#define SDNA MAKE_ID('S', 'D', 'N', 'A')
|
||||
#define TYPE MAKE_ID('T', 'Y', 'P', 'E')
|
||||
#define TLEN MAKE_ID('T', 'L', 'E', 'N')
|
||||
#define STRC MAKE_ID('S', 'T', 'R', 'C')
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#define SWITCH_SHORT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
|
||||
#define SWITCH_INT(a) \
|
||||
{ \
|
||||
char s_i, *p_i; \
|
||||
p_i = (char *)&(a); \
|
||||
s_i = p_i[0]; \
|
||||
p_i[0] = p_i[3]; \
|
||||
p_i[3] = s_i; \
|
||||
s_i = p_i[1]; \
|
||||
p_i[1] = p_i[2]; \
|
||||
p_i[2] = s_i; \
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#define SWITCH_LONGINT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
|
||||
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
|
||||
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
|
||||
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
|
||||
#define SWITCH_SHORT(a) \
|
||||
{ \
|
||||
char s_i, *p_i; \
|
||||
p_i = (char *)&(a); \
|
||||
s_i = p_i[0]; \
|
||||
p_i[0] = p_i[1]; \
|
||||
p_i[1] = s_i; \
|
||||
}
|
||||
|
||||
#endif//__B_DEFINES_H__
|
||||
// ------------------------------------------------------------
|
||||
#define SWITCH_LONGINT(a) \
|
||||
{ \
|
||||
char s_i, *p_i; \
|
||||
p_i = (char *)&(a); \
|
||||
s_i = p_i[0]; \
|
||||
p_i[0] = p_i[7]; \
|
||||
p_i[7] = s_i; \
|
||||
s_i = p_i[1]; \
|
||||
p_i[1] = p_i[6]; \
|
||||
p_i[6] = s_i; \
|
||||
s_i = p_i[2]; \
|
||||
p_i[2] = p_i[5]; \
|
||||
p_i[5] = s_i; \
|
||||
s_i = p_i[3]; \
|
||||
p_i[3] = p_i[4]; \
|
||||
p_i[4] = s_i; \
|
||||
}
|
||||
|
||||
#endif //__B_DEFINES_H__
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -20,156 +20,147 @@ subject to the following restrictions:
|
|||
#include "bChunk.h"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace bParse {
|
||||
namespace bParse
|
||||
{
|
||||
// ----------------------------------------------------- //
|
||||
enum bFileFlags
|
||||
{
|
||||
FD_INVALID = 0,
|
||||
FD_OK = 1,
|
||||
FD_VOID_IS_8 = 2,
|
||||
FD_ENDIAN_SWAP = 4,
|
||||
FD_FILE_64 = 8,
|
||||
FD_BITS_VARIES = 16,
|
||||
FD_VERSION_VARIES = 32,
|
||||
FD_DOUBLE_PRECISION = 64,
|
||||
FD_BROKEN_DNA = 128,
|
||||
FD_FILEDNA_IS_MEMDNA = 256
|
||||
};
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
enum bFileFlags
|
||||
enum bFileVerboseMode
|
||||
{
|
||||
FD_VERBOSE_EXPORT_XML = 1,
|
||||
FD_VERBOSE_DUMP_DNA_TYPE_DEFINITIONS = 2,
|
||||
FD_VERBOSE_DUMP_CHUNKS = 4,
|
||||
FD_VERBOSE_DUMP_FILE_INFO = 8,
|
||||
};
|
||||
// ----------------------------------------------------- //
|
||||
class bFile
|
||||
{
|
||||
protected:
|
||||
char m_headerString[7];
|
||||
|
||||
bool mOwnsBuffer;
|
||||
char* mFileBuffer;
|
||||
int mFileLen;
|
||||
int mVersion;
|
||||
|
||||
bPtrMap mLibPointers;
|
||||
|
||||
int mDataStart;
|
||||
bDNA* mFileDNA;
|
||||
bDNA* mMemoryDNA;
|
||||
|
||||
btAlignedObjectArray<char*> m_pointerFixupArray;
|
||||
btAlignedObjectArray<char*> m_pointerPtrFixupArray;
|
||||
|
||||
btAlignedObjectArray<bChunkInd> m_chunks;
|
||||
btHashMap<btHashPtr, bChunkInd> m_chunkPtrPtrMap;
|
||||
|
||||
//
|
||||
|
||||
bPtrMap mDataPointers;
|
||||
|
||||
int mFlags;
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// buffer offset util
|
||||
int getNextBlock(bChunkInd* dataChunk, const char* dataPtr, const int flags);
|
||||
void safeSwapPtr(char* dst, const char* src);
|
||||
|
||||
virtual void parseHeader();
|
||||
|
||||
virtual void parseData() = 0;
|
||||
|
||||
void resolvePointersMismatch();
|
||||
void resolvePointersChunk(const bChunkInd& dataChunk, int verboseMode);
|
||||
|
||||
int resolvePointersStructRecursive(char* strcPtr, int old_dna, int verboseMode, int recursion);
|
||||
//void swapPtr(char *dst, char *src);
|
||||
|
||||
void parseStruct(char* strcPtr, char* dtPtr, int old_dna, int new_dna, bool fixupPointers);
|
||||
void getMatchingFileDNA(short* old, const char* lookupName, const char* lookupType, char* strcData, char* data, bool fixupPointers);
|
||||
char* getFileElement(short* firstStruct, char* lookupName, char* lookupType, char* data, short** foundPos);
|
||||
|
||||
void swap(char* head, class bChunkInd& ch, bool ignoreEndianFlag);
|
||||
void swapData(char* data, short type, int arraySize, bool ignoreEndianFlag);
|
||||
void swapStruct(int dna_nr, char* data, bool ignoreEndianFlag);
|
||||
void swapLen(char* dataPtr);
|
||||
void swapDNA(char* ptr);
|
||||
|
||||
char* readStruct(char* head, class bChunkInd& chunk);
|
||||
char* getAsString(int code);
|
||||
|
||||
virtual void parseInternal(int verboseMode, char* memDna, int memDnaLength);
|
||||
|
||||
public:
|
||||
bFile(const char* filename, const char headerString[7]);
|
||||
|
||||
//todo: make memoryBuffer const char
|
||||
//bFile( const char *memoryBuffer, int len);
|
||||
bFile(char* memoryBuffer, int len, const char headerString[7]);
|
||||
virtual ~bFile();
|
||||
|
||||
bDNA* getFileDNA()
|
||||
{
|
||||
FD_INVALID =0,
|
||||
FD_OK =1,
|
||||
FD_VOID_IS_8 =2,
|
||||
FD_ENDIAN_SWAP =4,
|
||||
FD_FILE_64 =8,
|
||||
FD_BITS_VARIES =16,
|
||||
FD_VERSION_VARIES = 32,
|
||||
FD_DOUBLE_PRECISION =64,
|
||||
FD_BROKEN_DNA = 128,
|
||||
FD_FILEDNA_IS_MEMDNA = 256
|
||||
};
|
||||
return mFileDNA;
|
||||
}
|
||||
|
||||
enum bFileVerboseMode
|
||||
virtual void addDataBlock(char* dataBlock) = 0;
|
||||
|
||||
int getFlags() const
|
||||
{
|
||||
FD_VERBOSE_EXPORT_XML = 1,
|
||||
FD_VERBOSE_DUMP_DNA_TYPE_DEFINITIONS = 2,
|
||||
FD_VERBOSE_DUMP_CHUNKS = 4,
|
||||
FD_VERBOSE_DUMP_FILE_INFO=8,
|
||||
};
|
||||
// ----------------------------------------------------- //
|
||||
class bFile
|
||||
return mFlags;
|
||||
}
|
||||
|
||||
void setFileDNAisMemoryDNA()
|
||||
{
|
||||
protected:
|
||||
|
||||
char m_headerString[7];
|
||||
mFlags |= FD_FILEDNA_IS_MEMDNA;
|
||||
}
|
||||
|
||||
bool mOwnsBuffer;
|
||||
char* mFileBuffer;
|
||||
int mFileLen;
|
||||
int mVersion;
|
||||
bPtrMap& getLibPointers()
|
||||
{
|
||||
return mLibPointers;
|
||||
}
|
||||
|
||||
void* findLibPointer(void* ptr);
|
||||
|
||||
bPtrMap mLibPointers;
|
||||
bool ok();
|
||||
|
||||
int mDataStart;
|
||||
bDNA* mFileDNA;
|
||||
bDNA* mMemoryDNA;
|
||||
virtual void parse(int verboseMode) = 0;
|
||||
|
||||
btAlignedObjectArray<char*> m_pointerFixupArray;
|
||||
btAlignedObjectArray<char*> m_pointerPtrFixupArray;
|
||||
|
||||
btAlignedObjectArray<bChunkInd> m_chunks;
|
||||
btHashMap<btHashPtr, bChunkInd> m_chunkPtrPtrMap;
|
||||
virtual int write(const char* fileName, bool fixupPointers = false) = 0;
|
||||
|
||||
//
|
||||
|
||||
bPtrMap mDataPointers;
|
||||
virtual void writeChunks(FILE* fp, bool fixupPointers);
|
||||
|
||||
|
||||
int mFlags;
|
||||
virtual void writeDNA(FILE* fp) = 0;
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void updateOldPointers();
|
||||
void resolvePointers(int verboseMode);
|
||||
|
||||
// buffer offset util
|
||||
int getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int flags);
|
||||
void safeSwapPtr(char *dst, const char *src);
|
||||
void dumpChunks(bDNA* dna);
|
||||
|
||||
virtual void parseHeader();
|
||||
|
||||
virtual void parseData() = 0;
|
||||
virtual void setFileDNA(int verboseMode, char* buffer, int len);
|
||||
|
||||
void resolvePointersMismatch();
|
||||
void resolvePointersChunk(const bChunkInd& dataChunk, int verboseMode);
|
||||
int getVersion() const
|
||||
{
|
||||
return mVersion;
|
||||
}
|
||||
//pre-swap the endianness, so that data loaded on a target with different endianness doesn't need to be swapped
|
||||
void preSwap();
|
||||
void writeFile(const char* fileName);
|
||||
};
|
||||
} // namespace bParse
|
||||
|
||||
int resolvePointersStructRecursive(char *strcPtr, int old_dna, int verboseMode, int recursion);
|
||||
//void swapPtr(char *dst, char *src);
|
||||
|
||||
void parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bool fixupPointers);
|
||||
void getMatchingFileDNA(short* old, const char* lookupName, const char* lookupType, char *strcData, char *data, bool fixupPointers);
|
||||
char* getFileElement(short *firstStruct, char *lookupName, char *lookupType, char *data, short **foundPos);
|
||||
|
||||
|
||||
void swap(char *head, class bChunkInd& ch, bool ignoreEndianFlag);
|
||||
void swapData(char *data, short type, int arraySize, bool ignoreEndianFlag);
|
||||
void swapStruct(int dna_nr, char *data, bool ignoreEndianFlag);
|
||||
void swapLen(char *dataPtr);
|
||||
void swapDNA(char* ptr);
|
||||
|
||||
|
||||
char* readStruct(char *head, class bChunkInd& chunk);
|
||||
char *getAsString(int code);
|
||||
|
||||
virtual void parseInternal(int verboseMode, char* memDna,int memDnaLength);
|
||||
|
||||
public:
|
||||
bFile(const char *filename, const char headerString[7]);
|
||||
|
||||
//todo: make memoryBuffer const char
|
||||
//bFile( const char *memoryBuffer, int len);
|
||||
bFile( char *memoryBuffer, int len, const char headerString[7]);
|
||||
virtual ~bFile();
|
||||
|
||||
bDNA* getFileDNA()
|
||||
{
|
||||
return mFileDNA;
|
||||
}
|
||||
|
||||
virtual void addDataBlock(char* dataBlock) = 0;
|
||||
|
||||
int getFlags() const
|
||||
{
|
||||
return mFlags;
|
||||
}
|
||||
|
||||
void setFileDNAisMemoryDNA()
|
||||
{
|
||||
mFlags |= FD_FILEDNA_IS_MEMDNA;
|
||||
}
|
||||
|
||||
bPtrMap& getLibPointers()
|
||||
{
|
||||
return mLibPointers;
|
||||
}
|
||||
|
||||
void* findLibPointer(void *ptr);
|
||||
|
||||
bool ok();
|
||||
|
||||
virtual void parse(int verboseMode) = 0;
|
||||
|
||||
virtual int write(const char* fileName, bool fixupPointers=false) = 0;
|
||||
|
||||
virtual void writeChunks(FILE* fp, bool fixupPointers );
|
||||
|
||||
virtual void writeDNA(FILE* fp) = 0;
|
||||
|
||||
void updateOldPointers();
|
||||
void resolvePointers(int verboseMode);
|
||||
|
||||
void dumpChunks(bDNA* dna);
|
||||
|
||||
virtual void setFileDNA(int verboseMode, char* buffer, int len);
|
||||
|
||||
int getVersion() const
|
||||
{
|
||||
return mVersion;
|
||||
}
|
||||
//pre-swap the endianness, so that data loaded on a target with different endianness doesn't need to be swapped
|
||||
void preSwap();
|
||||
void writeFile(const char* fileName);
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif//__BFILE_H__
|
||||
#endif //__BFILE_H__
|
||||
|
|
|
|||
|
|
@ -17,12 +17,11 @@ subject to the following restrictions:
|
|||
#include "bDefines.h"
|
||||
#include "bDNA.h"
|
||||
|
||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||
#if !defined(__CELLOS_LV2__) && !defined(__MWERKS__)
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// 32 && 64 bit versions
|
||||
#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#ifdef _WIN64
|
||||
|
|
@ -31,134 +30,123 @@ extern int sBulletDNAlen64;
|
|||
#else
|
||||
extern char sBulletDNAstr[];
|
||||
extern int sBulletDNAlen;
|
||||
#endif //_WIN64
|
||||
#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#endif //_WIN64
|
||||
#else //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
|
||||
extern char sBulletDNAstr64[];
|
||||
extern int sBulletDNAlen64;
|
||||
extern char sBulletDNAstr[];
|
||||
extern int sBulletDNAlen;
|
||||
|
||||
#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
|
||||
using namespace bParse;
|
||||
|
||||
btBulletFile::btBulletFile()
|
||||
:bFile("", "BULLET ")
|
||||
: bFile("", "BULLET ")
|
||||
{
|
||||
mMemoryDNA = new bDNA(); //this memory gets released in the bFile::~bFile destructor,@todo not consistent with the rule 'who allocates it, has to deallocate it"
|
||||
mMemoryDNA = new bDNA(); //this memory gets released in the bFile::~bFile destructor,@todo not consistent with the rule 'who allocates it, has to deallocate it"
|
||||
|
||||
m_DnaCopy = 0;
|
||||
|
||||
|
||||
#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#ifdef _WIN64
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64);
|
||||
#else//_WIN64
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen);
|
||||
#endif//_WIN64
|
||||
#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64);
|
||||
mMemoryDNA->init(m_DnaCopy, sBulletDNAlen64);
|
||||
#else //_WIN64
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen);
|
||||
mMemoryDNA->init(m_DnaCopy, sBulletDNAlen);
|
||||
#endif //_WIN64
|
||||
#else //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
m_DnaCopy = (char*) btAlignedAlloc(sBulletDNAlen64,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64);
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64);
|
||||
mMemoryDNA->init(m_DnaCopy, sBulletDNAlen64);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DnaCopy =(char*) btAlignedAlloc(sBulletDNAlen,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
||||
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen);
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen);
|
||||
mMemoryDNA->init(m_DnaCopy, sBulletDNAlen);
|
||||
}
|
||||
#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
}
|
||||
|
||||
|
||||
|
||||
btBulletFile::btBulletFile(const char* fileName)
|
||||
:bFile(fileName, "BULLET ")
|
||||
: bFile(fileName, "BULLET ")
|
||||
{
|
||||
m_DnaCopy = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
btBulletFile::btBulletFile(char *memoryBuffer, int len)
|
||||
:bFile(memoryBuffer,len, "BULLET ")
|
||||
btBulletFile::btBulletFile(char* memoryBuffer, int len)
|
||||
: bFile(memoryBuffer, len, "BULLET ")
|
||||
{
|
||||
m_DnaCopy = 0;
|
||||
}
|
||||
|
||||
|
||||
btBulletFile::~btBulletFile()
|
||||
{
|
||||
if (m_DnaCopy)
|
||||
btAlignedFree(m_DnaCopy);
|
||||
|
||||
|
||||
while (m_dataBlocks.size())
|
||||
{
|
||||
char* dataBlock = m_dataBlocks[m_dataBlocks.size()-1];
|
||||
char* dataBlock = m_dataBlocks[m_dataBlocks.size() - 1];
|
||||
delete[] dataBlock;
|
||||
m_dataBlocks.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
void btBulletFile::parseData()
|
||||
{
|
||||
// printf ("Building datablocks");
|
||||
// printf ("Chunk size = %d",CHUNK_HEADER_LEN);
|
||||
// printf ("File chunk size = %d",ChunkUtils::getOffset(mFlags));
|
||||
// printf ("Building datablocks");
|
||||
// printf ("Chunk size = %d",CHUNK_HEADER_LEN);
|
||||
// printf ("File chunk size = %d",ChunkUtils::getOffset(mFlags));
|
||||
|
||||
const bool brokenDNA = (mFlags&FD_BROKEN_DNA)!=0;
|
||||
const bool brokenDNA = (mFlags & FD_BROKEN_DNA) != 0;
|
||||
|
||||
//const bool swap = (mFlags&FD_ENDIAN_SWAP)!=0;
|
||||
|
||||
|
||||
int remain = mFileLen;
|
||||
|
||||
mDataStart = 12;
|
||||
remain-=12;
|
||||
|
||||
remain -= 12;
|
||||
|
||||
char *dataPtr = mFileBuffer+mDataStart;
|
||||
//invalid/empty file?
|
||||
if (remain < sizeof(bChunkInd))
|
||||
return;
|
||||
|
||||
char* dataPtr = mFileBuffer + mDataStart;
|
||||
|
||||
bChunkInd dataChunk;
|
||||
dataChunk.code = 0;
|
||||
|
||||
|
||||
//dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
int seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
|
||||
|
||||
if (mFlags &FD_ENDIAN_SWAP)
|
||||
|
||||
if (mFlags & FD_ENDIAN_SWAP)
|
||||
swapLen(dataPtr);
|
||||
|
||||
//dataPtr += ChunkUtils::getOffset(mFlags);
|
||||
char *dataPtrHead = 0;
|
||||
char* dataPtrHead = 0;
|
||||
|
||||
while (dataChunk.code != DNA1)
|
||||
{
|
||||
if (!brokenDNA || (dataChunk.code != BT_QUANTIZED_BVH_CODE) )
|
||||
if (!brokenDNA || (dataChunk.code != BT_QUANTIZED_BVH_CODE))
|
||||
{
|
||||
|
||||
// one behind
|
||||
if (dataChunk.code == SDNA) break;
|
||||
//if (dataChunk.code == DNA1) break;
|
||||
|
||||
// same as (BHEAD+DATA dependency)
|
||||
dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags);
|
||||
if (dataChunk.dna_nr>=0)
|
||||
dataPtrHead = dataPtr + ChunkUtils::getOffset(mFlags);
|
||||
if (dataChunk.dna_nr >= 0)
|
||||
{
|
||||
char *id = readStruct(dataPtrHead, dataChunk);
|
||||
char* id = readStruct(dataPtrHead, dataChunk);
|
||||
|
||||
// lookup maps
|
||||
if (id)
|
||||
|
|
@ -173,106 +161,110 @@ void btBulletFile::parseData()
|
|||
// listID->push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_CONTACTMANIFOLD_CODE)
|
||||
{
|
||||
m_contactManifolds.push_back((bStructHandle*)id);
|
||||
}
|
||||
if (dataChunk.code == BT_MULTIBODY_CODE)
|
||||
{
|
||||
m_multiBodies.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_MB_LINKCOLLIDER_CODE)
|
||||
{
|
||||
m_multiBodyLinkColliders.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_SOFTBODY_CODE)
|
||||
{
|
||||
m_softBodies.push_back((bStructHandle*) id);
|
||||
m_softBodies.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
|
||||
if (dataChunk.code == BT_RIGIDBODY_CODE)
|
||||
{
|
||||
m_rigidBodies.push_back((bStructHandle*) id);
|
||||
m_rigidBodies.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_DYNAMICSWORLD_CODE)
|
||||
{
|
||||
m_dynamicsWorldInfo.push_back((bStructHandle*) id);
|
||||
m_dynamicsWorldInfo.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_CONSTRAINT_CODE)
|
||||
{
|
||||
m_constraints.push_back((bStructHandle*) id);
|
||||
m_constraints.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_QUANTIZED_BVH_CODE)
|
||||
{
|
||||
m_bvhs.push_back((bStructHandle*) id);
|
||||
m_bvhs.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_TRIANLGE_INFO_MAP)
|
||||
{
|
||||
m_triangleInfoMaps.push_back((bStructHandle*) id);
|
||||
m_triangleInfoMaps.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_COLLISIONOBJECT_CODE)
|
||||
{
|
||||
m_collisionObjects.push_back((bStructHandle*) id);
|
||||
m_collisionObjects.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
if (dataChunk.code == BT_SHAPE_CODE)
|
||||
{
|
||||
m_collisionShapes.push_back((bStructHandle*) id);
|
||||
m_collisionShapes.push_back((bStructHandle*)id);
|
||||
}
|
||||
|
||||
// if (dataChunk.code == GLOB)
|
||||
// {
|
||||
// m_glob = (bStructHandle*) id;
|
||||
// }
|
||||
} else
|
||||
// if (dataChunk.code == GLOB)
|
||||
// {
|
||||
// m_glob = (bStructHandle*) id;
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("unknown chunk\n");
|
||||
|
||||
mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)dataPtrHead);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("skipping BT_QUANTIZED_BVH_CODE due to broken DNA\n");
|
||||
}
|
||||
|
||||
|
||||
dataPtr += seek;
|
||||
remain-=seek;
|
||||
if (remain<=0)
|
||||
remain -= seek;
|
||||
if (remain <= 0)
|
||||
break;
|
||||
|
||||
seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
if (mFlags &FD_ENDIAN_SWAP)
|
||||
seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||
if (mFlags & FD_ENDIAN_SWAP)
|
||||
swapLen(dataPtr);
|
||||
|
||||
if (seek < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void btBulletFile::addDataBlock(char* dataBlock)
|
||||
void btBulletFile::addDataBlock(char* dataBlock)
|
||||
{
|
||||
m_dataBlocks.push_back(dataBlock);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void btBulletFile::writeDNA(FILE* fp)
|
||||
void btBulletFile::writeDNA(FILE* fp)
|
||||
{
|
||||
|
||||
bChunkInd dataChunk;
|
||||
dataChunk.code = DNA1;
|
||||
dataChunk.dna_nr = 0;
|
||||
dataChunk.nr = 1;
|
||||
#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
dataChunk.len = sBulletDNAlen64;
|
||||
dataChunk.oldPtr = sBulletDNAstr64;
|
||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||
fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp);
|
||||
fwrite(&dataChunk, sizeof(bChunkInd), 1, fp);
|
||||
fwrite(sBulletDNAstr64, sBulletDNAlen64, 1, fp);
|
||||
#else
|
||||
btAssert(0);
|
||||
#endif
|
||||
|
|
@ -282,43 +274,42 @@ void btBulletFile::writeDNA(FILE* fp)
|
|||
#ifndef _WIN64
|
||||
dataChunk.len = sBulletDNAlen;
|
||||
dataChunk.oldPtr = sBulletDNAstr;
|
||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||
fwrite(sBulletDNAstr, sBulletDNAlen,1,fp);
|
||||
#else//_WIN64
|
||||
fwrite(&dataChunk, sizeof(bChunkInd), 1, fp);
|
||||
fwrite(sBulletDNAstr, sBulletDNAlen, 1, fp);
|
||||
#else //_WIN64
|
||||
btAssert(0);
|
||||
#endif//_WIN64
|
||||
#endif //_WIN64
|
||||
}
|
||||
#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#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);
|
||||
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);
|
||||
fwrite(&dataChunk, sizeof(bChunkInd), 1, fp);
|
||||
fwrite(sBulletDNAstr, sBulletDNAlen, 1, fp);
|
||||
}
|
||||
#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
}
|
||||
|
||||
|
||||
void btBulletFile::parse(int verboseMode)
|
||||
void btBulletFile::parse(int verboseMode)
|
||||
{
|
||||
#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
|
||||
|
||||
if (m_DnaCopy)
|
||||
delete m_DnaCopy;
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
||||
parseInternal(verboseMode,(char*)sBulletDNAstr64,sBulletDNAlen64);
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64);
|
||||
parseInternal(verboseMode, (char*)sBulletDNAstr64, sBulletDNAlen64);
|
||||
#else
|
||||
btAssert(0);
|
||||
#endif
|
||||
|
|
@ -329,93 +320,92 @@ void btBulletFile::parse(int verboseMode)
|
|||
|
||||
if (m_DnaCopy)
|
||||
delete m_DnaCopy;
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
||||
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen);
|
||||
parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen);
|
||||
#else
|
||||
btAssert(0);
|
||||
#endif
|
||||
}
|
||||
#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
#else //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
if (m_DnaCopy)
|
||||
delete m_DnaCopy;
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
|
||||
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen64);
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16);
|
||||
memset(m_DnaCopy, 0, sBulletDNAlen64);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64);
|
||||
parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen64);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_DnaCopy)
|
||||
delete m_DnaCopy;
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen,16);
|
||||
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
|
||||
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen);
|
||||
parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen);
|
||||
}
|
||||
#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
|
||||
//the parsing will convert to cpu endian
|
||||
mFlags &=~FD_ENDIAN_SWAP;
|
||||
#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
|
||||
|
||||
int littleEndian= 1;
|
||||
littleEndian= ((char*)&littleEndian)[0];
|
||||
|
||||
mFileBuffer[8] = littleEndian?'v':'V';
|
||||
|
||||
//the parsing will convert to cpu endian
|
||||
mFlags &= ~FD_ENDIAN_SWAP;
|
||||
|
||||
int littleEndian = 1;
|
||||
littleEndian = ((char*)&littleEndian)[0];
|
||||
|
||||
mFileBuffer[8] = littleEndian ? 'v' : 'V';
|
||||
}
|
||||
|
||||
// experimental
|
||||
int btBulletFile::write(const char* fileName, bool fixupPointers)
|
||||
int btBulletFile::write(const char* fileName, bool fixupPointers)
|
||||
{
|
||||
FILE *fp = fopen(fileName, "wb");
|
||||
FILE* fp = fopen(fileName, "wb");
|
||||
if (fp)
|
||||
{
|
||||
char header[SIZEOFBLENDERHEADER] ;
|
||||
char header[SIZEOFBLENDERHEADER];
|
||||
memcpy(header, m_headerString, 7);
|
||||
int endian= 1;
|
||||
endian= ((char*)&endian)[0];
|
||||
int endian = 1;
|
||||
endian = ((char*)&endian)[0];
|
||||
|
||||
if (endian)
|
||||
{
|
||||
header[7] = '_';
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
header[7] = '-';
|
||||
}
|
||||
if (VOID_IS_8)
|
||||
{
|
||||
header[8]='V';
|
||||
} else
|
||||
header[8] = 'V';
|
||||
}
|
||||
else
|
||||
{
|
||||
header[8]='v';
|
||||
header[8] = 'v';
|
||||
}
|
||||
|
||||
header[9] = '2';
|
||||
header[10] = '7';
|
||||
header[11] = '5';
|
||||
|
||||
fwrite(header,SIZEOFBLENDERHEADER,1,fp);
|
||||
|
||||
fwrite(header, SIZEOFBLENDERHEADER, 1, fp);
|
||||
|
||||
writeChunks(fp, fixupPointers);
|
||||
|
||||
writeDNA(fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: cannot open file %s for writing\n",fileName);
|
||||
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)
|
||||
void btBulletFile::addStruct(const char* structType, void* data, int len, void* oldPtr, int code)
|
||||
{
|
||||
|
||||
bParse::bChunkInd dataChunk;
|
||||
dataChunk.code = code;
|
||||
dataChunk.nr = 1;
|
||||
|
|
@ -424,13 +414,12 @@ void btBulletFile::addStruct(const char* structType,void* data, int len, void* o
|
|||
dataChunk.oldPtr = oldPtr;
|
||||
|
||||
///Perform structure size validation
|
||||
short* structInfo= mMemoryDNA->getStruct(dataChunk.dna_nr);
|
||||
short* structInfo = mMemoryDNA->getStruct(dataChunk.dna_nr);
|
||||
int elemBytes;
|
||||
elemBytes= mMemoryDNA->getLength(structInfo[0]);
|
||||
// int elemBytes = mMemoryDNA->getElementSize(structInfo[0],structInfo[1]);
|
||||
assert(len==elemBytes);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,71 +16,65 @@ subject to the following restrictions:
|
|||
#ifndef BT_BULLET_FILE_H
|
||||
#define BT_BULLET_FILE_H
|
||||
|
||||
|
||||
#include "bFile.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "bDefines.h"
|
||||
|
||||
|
||||
#include "LinearMath/btSerializer.h"
|
||||
|
||||
namespace bParse
|
||||
{
|
||||
// ----------------------------------------------------- //
|
||||
class btBulletFile : public bFile
|
||||
{
|
||||
protected:
|
||||
char* m_DnaCopy;
|
||||
|
||||
public:
|
||||
btAlignedObjectArray<bStructHandle*> m_multiBodies;
|
||||
|
||||
namespace bParse {
|
||||
btAlignedObjectArray<bStructHandle*> m_multiBodyLinkColliders;
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
class btBulletFile : public bFile
|
||||
{
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_softBodies;
|
||||
|
||||
protected:
|
||||
|
||||
char* m_DnaCopy;
|
||||
|
||||
public:
|
||||
btAlignedObjectArray<bStructHandle*> m_rigidBodies;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_multiBodies;
|
||||
btAlignedObjectArray<bStructHandle*> m_collisionObjects;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_softBodies;
|
||||
btAlignedObjectArray<bStructHandle*> m_collisionShapes;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_rigidBodies;
|
||||
btAlignedObjectArray<bStructHandle*> m_constraints;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_collisionObjects;
|
||||
btAlignedObjectArray<bStructHandle*> m_bvhs;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_collisionShapes;
|
||||
btAlignedObjectArray<bStructHandle*> m_triangleInfoMaps;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_constraints;
|
||||
btAlignedObjectArray<bStructHandle*> m_dynamicsWorldInfo;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_bvhs;
|
||||
btAlignedObjectArray<bStructHandle*> m_contactManifolds;
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_triangleInfoMaps;
|
||||
btAlignedObjectArray<char*> m_dataBlocks;
|
||||
btBulletFile();
|
||||
|
||||
btAlignedObjectArray<bStructHandle*> m_dynamicsWorldInfo;
|
||||
btBulletFile(const char* fileName);
|
||||
|
||||
btAlignedObjectArray<char*> m_dataBlocks;
|
||||
btBulletFile();
|
||||
btBulletFile(char* memoryBuffer, int len);
|
||||
|
||||
btBulletFile(const char* fileName);
|
||||
virtual ~btBulletFile();
|
||||
|
||||
btBulletFile(char *memoryBuffer, int len);
|
||||
virtual void addDataBlock(char* dataBlock);
|
||||
|
||||
virtual ~btBulletFile();
|
||||
// experimental
|
||||
virtual int write(const char* fileName, bool fixupPointers = false);
|
||||
|
||||
virtual void addDataBlock(char* dataBlock);
|
||||
|
||||
|
||||
// experimental
|
||||
virtual int write(const char* fileName, bool fixupPointers=false);
|
||||
virtual void parse(int verboseMode);
|
||||
|
||||
virtual void parse(int verboseMode);
|
||||
virtual void parseData();
|
||||
|
||||
virtual void parseData();
|
||||
virtual void writeDNA(FILE* fp);
|
||||
|
||||
virtual void writeDNA(FILE* fp);
|
||||
|
||||
void addStruct(const char* structType,void* data, int len, void* oldPtr, int code);
|
||||
|
||||
};
|
||||
void addStruct(const char* structType, void* data, int len, void* oldPtr, int code);
|
||||
};
|
||||
}; // namespace bParse
|
||||
|
||||
#endif //BT_BULLET_FILE_H
|
||||
#endif //BT_BULLET_FILE_H
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
kind "StaticLib"
|
||||
|
||||
if os.is("Linux") then
|
||||
buildoptions{"-fPIC"}
|
||||
end
|
||||
|
||||
includedirs {
|
||||
"../../../src"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ INCLUDE_DIRECTORIES(
|
|||
|
||||
ADD_LIBRARY(
|
||||
BulletWorldImporter
|
||||
btMultiBodyWorldImporter.cpp
|
||||
btBulletWorldImporter.cpp
|
||||
btBulletWorldImporter.h
|
||||
btWorldImporter.cpp
|
||||
|
|
@ -25,7 +26,10 @@ IF (INSTALL_EXTRA_LIBS)
|
|||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||
INSTALL(TARGETS BulletWorldImporter DESTINATION .)
|
||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||
INSTALL(TARGETS BulletWorldImporter DESTINATION lib${LIB_SUFFIX})
|
||||
INSTALL(TARGETS BulletWorldImporter
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ subject to the following restrictions:
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "btBulletWorldImporter.h"
|
||||
#include "../BulletFileLoader/btBulletFile.h"
|
||||
|
||||
|
|
@ -22,14 +21,13 @@ subject to the following restrictions:
|
|||
#include "BulletCollision/Gimpact/btGImpactShape.h"
|
||||
#endif
|
||||
|
||||
|
||||
//#define USE_INTERNAL_EDGE_UTILITY
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
#include "BulletCollision/CollisionDispatch/btInternalEdgeUtility.h"
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
|
||||
btBulletWorldImporter::btBulletWorldImporter(btDynamicsWorld* world)
|
||||
:btWorldImporter(world)
|
||||
: btWorldImporter(world)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -37,12 +35,10 @@ btBulletWorldImporter::~btBulletWorldImporter()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
bool btBulletWorldImporter::loadFile( const char* fileName, const char* preSwapFilenameOut)
|
||||
bool btBulletWorldImporter::loadFile(const char* fileName, const char* preSwapFilenameOut)
|
||||
{
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
|
||||
|
||||
|
||||
bool result = loadFileFromMemory(bulletFile2);
|
||||
//now you could save the file in 'native' format using
|
||||
//bulletFile2->writeFile("native.bullet");
|
||||
|
|
@ -53,19 +49,15 @@ bool btBulletWorldImporter::loadFile( const char* fileName, const char* preSwapF
|
|||
bulletFile2->preSwap();
|
||||
bulletFile2->writeFile(preSwapFilenameOut);
|
||||
}
|
||||
|
||||
}
|
||||
delete bulletFile2;
|
||||
|
||||
return result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool btBulletWorldImporter::loadFileFromMemory( char* memoryBuffer, int len)
|
||||
bool btBulletWorldImporter::loadFileFromMemory(char* memoryBuffer, int len)
|
||||
{
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(memoryBuffer,len);
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(memoryBuffer, len);
|
||||
|
||||
bool result = loadFileFromMemory(bulletFile2);
|
||||
|
||||
|
|
@ -74,36 +66,31 @@ bool btBulletWorldImporter::loadFileFromMemory( char* memoryBuffer, int len)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
|
||||
bool btBulletWorldImporter::loadFileFromMemory(bParse::btBulletFile* bulletFile2)
|
||||
{
|
||||
bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
|
||||
|
||||
bool ok = (bulletFile2->getFlags() & bParse::FD_OK) != 0;
|
||||
|
||||
if (ok)
|
||||
bulletFile2->parse(m_verboseMode);
|
||||
else
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
if (m_verboseMode & bParse::FD_VERBOSE_DUMP_CHUNKS)
|
||||
{
|
||||
bulletFile2->dumpChunks(bulletFile2->getFileDNA());
|
||||
}
|
||||
|
||||
return convertAllObjects(bulletFile2);
|
||||
|
||||
}
|
||||
|
||||
bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile2)
|
||||
bool btBulletWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
{
|
||||
|
||||
m_shapeMap.clear();
|
||||
m_bodyMap.clear();
|
||||
|
||||
int i;
|
||||
|
||||
for (i=0;i<bulletFile2->m_bvhs.size();i++)
|
||||
|
||||
for (i = 0; i < bulletFile2->m_bvhs.size(); i++)
|
||||
{
|
||||
btOptimizedBvh* bvh = createOptimizedBvh();
|
||||
|
||||
|
|
@ -111,41 +98,34 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
{
|
||||
btQuantizedBvhDoubleData* bvhData = (btQuantizedBvhDoubleData*)bulletFile2->m_bvhs[i];
|
||||
bvh->deSerializeDouble(*bvhData);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btQuantizedBvhFloatData* bvhData = (btQuantizedBvhFloatData*)bulletFile2->m_bvhs[i];
|
||||
bvh->deSerializeFloat(*bvhData);
|
||||
}
|
||||
m_bvhMap.insert(bulletFile2->m_bvhs[i],bvh);
|
||||
m_bvhMap.insert(bulletFile2->m_bvhs[i], bvh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionShapes.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_collisionShapes.size(); i++)
|
||||
{
|
||||
btCollisionShapeData* shapeData = (btCollisionShapeData*)bulletFile2->m_collisionShapes[i];
|
||||
btCollisionShape* shape = convertCollisionShape(shapeData);
|
||||
if (shape)
|
||||
{
|
||||
// printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
|
||||
m_shapeMap.insert(shapeData,shape);
|
||||
// printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
|
||||
m_shapeMap.insert(shapeData, shape);
|
||||
}
|
||||
|
||||
if (shape&& shapeData->m_name)
|
||||
if (shape && shapeData->m_name)
|
||||
{
|
||||
char* newname = duplicateName(shapeData->m_name);
|
||||
m_objectNameMap.insert(shape,newname);
|
||||
m_nameShapeMap.insert(newname,shape);
|
||||
m_objectNameMap.insert(shape, newname);
|
||||
m_nameShapeMap.insert(newname, shape);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i=0;i<bulletFile2->m_dynamicsWorldInfo.size();i++)
|
||||
for (int i = 0; i < bulletFile2->m_dynamicsWorldInfo.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
|
|
@ -169,21 +149,22 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
solverInfo.m_globalCfm = btScalar(solverInfoData->m_solverInfo.m_globalCfm);
|
||||
solverInfo.m_splitImpulsePenetrationThreshold = btScalar(solverInfoData->m_solverInfo.m_splitImpulsePenetrationThreshold);
|
||||
solverInfo.m_splitImpulseTurnErp = btScalar(solverInfoData->m_solverInfo.m_splitImpulseTurnErp);
|
||||
|
||||
|
||||
solverInfo.m_linearSlop = btScalar(solverInfoData->m_solverInfo.m_linearSlop);
|
||||
solverInfo.m_warmstartingFactor = btScalar(solverInfoData->m_solverInfo.m_warmstartingFactor);
|
||||
solverInfo.m_maxGyroscopicForce = btScalar(solverInfoData->m_solverInfo.m_maxGyroscopicForce);
|
||||
solverInfo.m_singleAxisRollingFrictionThreshold = btScalar(solverInfoData->m_solverInfo.m_singleAxisRollingFrictionThreshold);
|
||||
|
||||
|
||||
solverInfo.m_numIterations = solverInfoData->m_solverInfo.m_numIterations;
|
||||
solverInfo.m_solverMode = solverInfoData->m_solverInfo.m_solverMode;
|
||||
solverInfo.m_restingContactRestitutionThreshold = solverInfoData->m_solverInfo.m_restingContactRestitutionThreshold;
|
||||
solverInfo.m_minimumSolverBatchSize = solverInfoData->m_solverInfo.m_minimumSolverBatchSize;
|
||||
|
||||
|
||||
solverInfo.m_splitImpulse = solverInfoData->m_solverInfo.m_splitImpulse;
|
||||
|
||||
setDynamicsWorldInfo(gravity,solverInfo);
|
||||
} else
|
||||
setDynamicsWorldInfo(gravity, solverInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
btDynamicsWorldFloatData* solverInfoData = (btDynamicsWorldFloatData*)bulletFile2->m_dynamicsWorldInfo[i];
|
||||
btContactSolverInfo solverInfo;
|
||||
|
|
@ -205,40 +186,38 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
solverInfo.m_globalCfm = solverInfoData->m_solverInfo.m_globalCfm;
|
||||
solverInfo.m_splitImpulsePenetrationThreshold = solverInfoData->m_solverInfo.m_splitImpulsePenetrationThreshold;
|
||||
solverInfo.m_splitImpulseTurnErp = solverInfoData->m_solverInfo.m_splitImpulseTurnErp;
|
||||
|
||||
|
||||
solverInfo.m_linearSlop = solverInfoData->m_solverInfo.m_linearSlop;
|
||||
solverInfo.m_warmstartingFactor = solverInfoData->m_solverInfo.m_warmstartingFactor;
|
||||
solverInfo.m_maxGyroscopicForce = solverInfoData->m_solverInfo.m_maxGyroscopicForce;
|
||||
solverInfo.m_singleAxisRollingFrictionThreshold = solverInfoData->m_solverInfo.m_singleAxisRollingFrictionThreshold;
|
||||
|
||||
|
||||
solverInfo.m_numIterations = solverInfoData->m_solverInfo.m_numIterations;
|
||||
solverInfo.m_solverMode = solverInfoData->m_solverInfo.m_solverMode;
|
||||
solverInfo.m_restingContactRestitutionThreshold = solverInfoData->m_solverInfo.m_restingContactRestitutionThreshold;
|
||||
solverInfo.m_minimumSolverBatchSize = solverInfoData->m_solverInfo.m_minimumSolverBatchSize;
|
||||
|
||||
|
||||
solverInfo.m_splitImpulse = solverInfoData->m_solverInfo.m_splitImpulse;
|
||||
|
||||
setDynamicsWorldInfo(gravity,solverInfo);
|
||||
setDynamicsWorldInfo(gravity, solverInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_rigidBodies.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
btRigidBodyDoubleData* colObjData = (btRigidBodyDoubleData*)bulletFile2->m_rigidBodies[i];
|
||||
convertRigidBodyDouble(colObjData);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btRigidBodyFloatData* colObjData = (btRigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||
convertRigidBodyFloat(colObjData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionObjects.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_collisionObjects.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
|
|
@ -249,29 +228,30 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
btTransform startTransform;
|
||||
colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
|
||||
startTransform.deSerializeDouble(colObjData->m_worldTransform);
|
||||
|
||||
|
||||
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
|
||||
btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
|
||||
btCollisionObject* body = createCollisionObject(startTransform, shape, colObjData->m_name);
|
||||
body->setFriction(btScalar(colObjData->m_friction));
|
||||
body->setRestitution(btScalar(colObjData->m_restitution));
|
||||
|
||||
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)shape;
|
||||
if (trimesh->getTriangleInfoMap())
|
||||
{
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
}
|
||||
}
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData,body);
|
||||
} else
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData, body);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error: no shape found\n");
|
||||
}
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btCollisionObjectFloatData* colObjData = (btCollisionObjectFloatData*)bulletFile2->m_collisionObjects[i];
|
||||
btCollisionShape** shapePtr = m_shapeMap.find(colObjData->m_collisionShape);
|
||||
|
|
@ -280,9 +260,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
btTransform startTransform;
|
||||
colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
|
||||
startTransform.deSerializeFloat(colObjData->m_worldTransform);
|
||||
|
||||
|
||||
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
|
||||
btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
|
||||
btCollisionObject* body = createCollisionObject(startTransform, shape, colObjData->m_name);
|
||||
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
|
|
@ -290,25 +270,22 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)shape;
|
||||
if (trimesh->getTriangleInfoMap())
|
||||
{
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
}
|
||||
}
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData,body);
|
||||
} else
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData, body);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error: no shape found\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<bulletFile2->m_constraints.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_constraints.size(); i++)
|
||||
{
|
||||
btTypedConstraintData2* constraintData = (btTypedConstraintData2*)bulletFile2->m_constraints[i];
|
||||
btTypedConstraintFloatData* singleC = (btTypedConstraintFloatData*)bulletFile2->m_constraints[i];
|
||||
btTypedConstraintDoubleData* doubleC = (btTypedConstraintDoubleData*)bulletFile2->m_constraints[i];
|
||||
|
||||
btCollisionObject** colAptr = m_bodyMap.find(constraintData->m_rbA);
|
||||
btCollisionObject** colBptr = m_bodyMap.find(constraintData->m_rbB);
|
||||
|
|
@ -330,34 +307,31 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
|||
}
|
||||
if (!rbA && !rbB)
|
||||
continue;
|
||||
|
||||
bool isDoublePrecisionData = (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)!=0;
|
||||
|
||||
|
||||
bool isDoublePrecisionData = (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) != 0;
|
||||
|
||||
if (isDoublePrecisionData)
|
||||
{
|
||||
if (bulletFile2->getVersion()>=282)
|
||||
if (bulletFile2->getVersion() >= 282)
|
||||
{
|
||||
btTypedConstraintDoubleData* dc = (btTypedConstraintDoubleData*)constraintData;
|
||||
convertConstraintDouble(dc, rbA,rbB, bulletFile2->getVersion());
|
||||
} else
|
||||
convertConstraintDouble(dc, rbA, rbB, bulletFile2->getVersion());
|
||||
}
|
||||
else
|
||||
{
|
||||
//double-precision constraints were messed up until 2.82, try to recover data...
|
||||
|
||||
btTypedConstraintData* oldData = (btTypedConstraintData*)constraintData;
|
||||
|
||||
convertConstraintBackwardsCompatible281(oldData, rbA,rbB, bulletFile2->getVersion());
|
||||
|
||||
btTypedConstraintData* oldData = (btTypedConstraintData*)constraintData;
|
||||
|
||||
convertConstraintBackwardsCompatible281(oldData, rbA, rbB, bulletFile2->getVersion());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btTypedConstraintFloatData* dc = (btTypedConstraintFloatData*)constraintData;
|
||||
convertConstraintFloat(dc, rbA,rbB, bulletFile2->getVersion());
|
||||
convertConstraintFloat(dc, rbA, rbB, bulletFile2->getVersion());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,56 +13,40 @@ subject to the following restrictions:
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BULLET_WORLD_IMPORTER_H
|
||||
#define BULLET_WORLD_IMPORTER_H
|
||||
|
||||
|
||||
#include "btWorldImporter.h"
|
||||
|
||||
|
||||
class btBulletFile;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace bParse
|
||||
{
|
||||
class btBulletFile;
|
||||
|
||||
class btBulletFile;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
///The btBulletWorldImporter is a starting point to import .bullet files.
|
||||
///note that not all data is converted yet. You are expected to override or modify this class.
|
||||
///See Bullet/Demos/SerializeDemo for a derived class that extract btSoftBody objects too.
|
||||
class btBulletWorldImporter : public btWorldImporter
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
btBulletWorldImporter(btDynamicsWorld* world=0);
|
||||
btBulletWorldImporter(btDynamicsWorld* world = 0);
|
||||
|
||||
virtual ~btBulletWorldImporter();
|
||||
|
||||
///if you pass a valid preSwapFilenameOut, it will save a new file with a different endianness
|
||||
///if you pass a valid preSwapFilenameOut, it will save a new file with a different endianness
|
||||
///this pre-swapped file can be loaded without swapping on a target platform of different endianness
|
||||
bool loadFile(const char* fileName, const char* preSwapFilenameOut=0);
|
||||
bool loadFile(const char* fileName, const char* preSwapFilenameOut = 0);
|
||||
|
||||
///the memoryBuffer might be modified (for example if endian swaps are necessary)
|
||||
bool loadFileFromMemory(char *memoryBuffer, int len);
|
||||
bool loadFileFromMemory(char* memoryBuffer, int len);
|
||||
|
||||
bool loadFileFromMemory(bParse::btBulletFile* file);
|
||||
bool loadFileFromMemory(bParse::btBulletFile* file);
|
||||
|
||||
//call make sure bulletFile2 has been parsed, either using btBulletFile::parse or btBulletWorldImporter::loadFileFromMemory
|
||||
virtual bool convertAllObjects(bParse::btBulletFile* file);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool convertAllObjects(bParse::btBulletFile* file);
|
||||
};
|
||||
|
||||
#endif //BULLET_WORLD_IMPORTER_H
|
||||
|
||||
#endif //BULLET_WORLD_IMPORTER_H
|
||||
|
|
|
|||
|
|
@ -0,0 +1,571 @@
|
|||
#include "btMultiBodyWorldImporter.h"
|
||||
|
||||
#include "LinearMath/btSerializer.h"
|
||||
#include "../BulletFileLoader/btBulletFile.h"
|
||||
#include "btBulletWorldImporter.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "BulletDynamics/Featherstone/btMultiBody.h"
|
||||
#include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h"
|
||||
#include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h"
|
||||
|
||||
struct btMultiBodyWorldImporterInternalData
|
||||
{
|
||||
btMultiBodyDynamicsWorld* m_mbDynamicsWorld;
|
||||
btHashMap<btHashPtr, btMultiBody*> m_mbMap;
|
||||
};
|
||||
|
||||
btMultiBodyWorldImporter::btMultiBodyWorldImporter(btMultiBodyDynamicsWorld* world)
|
||||
: btBulletWorldImporter(world)
|
||||
{
|
||||
m_data = new btMultiBodyWorldImporterInternalData;
|
||||
m_data->m_mbDynamicsWorld = world;
|
||||
}
|
||||
|
||||
btMultiBodyWorldImporter::~btMultiBodyWorldImporter()
|
||||
{
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
void btMultiBodyWorldImporter::deleteAllData()
|
||||
{
|
||||
btBulletWorldImporter::deleteAllData();
|
||||
}
|
||||
|
||||
static btCollisionObjectDoubleData* getBody0FromContactManifold(btPersistentManifoldDoubleData* manifold)
|
||||
{
|
||||
return (btCollisionObjectDoubleData*)manifold->m_body0;
|
||||
}
|
||||
static btCollisionObjectDoubleData* getBody1FromContactManifold(btPersistentManifoldDoubleData* manifold)
|
||||
{
|
||||
return (btCollisionObjectDoubleData*)manifold->m_body1;
|
||||
}
|
||||
static btCollisionObjectFloatData* getBody0FromContactManifold(btPersistentManifoldFloatData* manifold)
|
||||
{
|
||||
return (btCollisionObjectFloatData*)manifold->m_body0;
|
||||
}
|
||||
static btCollisionObjectFloatData* getBody1FromContactManifold(btPersistentManifoldFloatData* manifold)
|
||||
{
|
||||
return (btCollisionObjectFloatData*)manifold->m_body1;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void syncContactManifolds(T** contactManifolds, int numContactManifolds, btMultiBodyWorldImporterInternalData* m_data)
|
||||
{
|
||||
m_data->m_mbDynamicsWorld->updateAabbs();
|
||||
m_data->m_mbDynamicsWorld->computeOverlappingPairs();
|
||||
btDispatcher* dispatcher = m_data->m_mbDynamicsWorld->getDispatcher();
|
||||
|
||||
btDispatcherInfo& dispatchInfo = m_data->m_mbDynamicsWorld->getDispatchInfo();
|
||||
|
||||
if (dispatcher)
|
||||
{
|
||||
btOverlappingPairCache* pairCache = m_data->m_mbDynamicsWorld->getBroadphase()->getOverlappingPairCache();
|
||||
if (dispatcher)
|
||||
{
|
||||
dispatcher->dispatchAllCollisionPairs(pairCache, dispatchInfo, dispatcher);
|
||||
}
|
||||
int numExistingManifolds = m_data->m_mbDynamicsWorld->getDispatcher()->getNumManifolds();
|
||||
btManifoldArray manifoldArray;
|
||||
for (int i = 0; i < pairCache->getNumOverlappingPairs(); i++)
|
||||
{
|
||||
btBroadphasePair& pair = pairCache->getOverlappingPairArray()[i];
|
||||
if (pair.m_algorithm)
|
||||
{
|
||||
pair.m_algorithm->getAllContactManifolds(manifoldArray);
|
||||
//for each existing manifold, search a matching manifoldData and reconstruct
|
||||
for (int m = 0; m < manifoldArray.size(); m++)
|
||||
{
|
||||
btPersistentManifold* existingManifold = manifoldArray[m];
|
||||
int uid0 = existingManifold->getBody0()->getBroadphaseHandle()->m_uniqueId;
|
||||
int uid1 = existingManifold->getBody1()->getBroadphaseHandle()->m_uniqueId;
|
||||
int matchingManifoldIndex = -1;
|
||||
for (int q = 0; q < numContactManifolds; q++)
|
||||
{
|
||||
if (uid0 == getBody0FromContactManifold(contactManifolds[q])->m_uniqueId && uid1 == getBody1FromContactManifold(contactManifolds[q])->m_uniqueId)
|
||||
{
|
||||
matchingManifoldIndex = q;
|
||||
}
|
||||
}
|
||||
if (matchingManifoldIndex >= 0)
|
||||
{
|
||||
existingManifold->deSerialize(contactManifolds[matchingManifoldIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
existingManifold->setNumContacts(0);
|
||||
//printf("Issue: cannot find maching contact manifold (%d, %d), may cause issues in determinism.\n", uid0, uid1);
|
||||
}
|
||||
|
||||
manifoldArray.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void syncMultiBody(T* mbd, btMultiBody* mb, btMultiBodyWorldImporterInternalData* m_data, btAlignedObjectArray<btQuaternion>& scratchQ, btAlignedObjectArray<btVector3>& scratchM)
|
||||
{
|
||||
bool isFixedBase = mbd->m_baseMass == 0;
|
||||
bool canSleep = false;
|
||||
btVector3 baseInertia;
|
||||
baseInertia.deSerialize(mbd->m_baseInertia);
|
||||
|
||||
btVector3 baseWorldPos;
|
||||
baseWorldPos.deSerialize(mbd->m_baseWorldPosition);
|
||||
mb->setBasePos(baseWorldPos);
|
||||
btQuaternion baseWorldRot;
|
||||
baseWorldRot.deSerialize(mbd->m_baseWorldOrientation);
|
||||
mb->setWorldToBaseRot(baseWorldRot.inverse());
|
||||
btVector3 baseLinVal;
|
||||
baseLinVal.deSerialize(mbd->m_baseLinearVelocity);
|
||||
btVector3 baseAngVel;
|
||||
baseAngVel.deSerialize(mbd->m_baseAngularVelocity);
|
||||
mb->setBaseVel(baseLinVal);
|
||||
mb->setBaseOmega(baseAngVel);
|
||||
|
||||
for (int i = 0; i < mbd->m_numLinks; i++)
|
||||
{
|
||||
mb->getLink(i).m_absFrameTotVelocity.m_topVec.deSerialize(mbd->m_links[i].m_absFrameTotVelocityTop);
|
||||
mb->getLink(i).m_absFrameTotVelocity.m_bottomVec.deSerialize(mbd->m_links[i].m_absFrameTotVelocityBottom);
|
||||
mb->getLink(i).m_absFrameLocVelocity.m_topVec.deSerialize(mbd->m_links[i].m_absFrameLocVelocityTop);
|
||||
mb->getLink(i).m_absFrameLocVelocity.m_bottomVec.deSerialize(mbd->m_links[i].m_absFrameLocVelocityBottom);
|
||||
|
||||
switch (mbd->m_links[i].m_jointType)
|
||||
{
|
||||
case btMultibodyLink::eFixed:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::ePrismatic:
|
||||
{
|
||||
mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]);
|
||||
mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]);
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::eRevolute:
|
||||
{
|
||||
mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]);
|
||||
mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]);
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::eSpherical:
|
||||
{
|
||||
btScalar jointPos[4] = {(btScalar)mbd->m_links[i].m_jointPos[0], (btScalar)mbd->m_links[i].m_jointPos[1], (btScalar)mbd->m_links[i].m_jointPos[2], (btScalar)mbd->m_links[i].m_jointPos[3]};
|
||||
btScalar jointVel[3] = {(btScalar)mbd->m_links[i].m_jointVel[0], (btScalar)mbd->m_links[i].m_jointVel[1], (btScalar)mbd->m_links[i].m_jointVel[2]};
|
||||
mb->setJointPosMultiDof(i, jointPos);
|
||||
mb->setJointVelMultiDof(i, jointVel);
|
||||
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::ePlanar:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
mb->forwardKinematics(scratchQ, scratchM);
|
||||
mb->updateCollisionObjectWorldTransforms(scratchQ, scratchM);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void convertMultiBody(T* mbd, btMultiBodyWorldImporterInternalData* m_data)
|
||||
{
|
||||
bool isFixedBase = mbd->m_baseMass == 0;
|
||||
bool canSleep = false;
|
||||
btVector3 baseInertia;
|
||||
baseInertia.deSerialize(mbd->m_baseInertia);
|
||||
btMultiBody* mb = new btMultiBody(mbd->m_numLinks, mbd->m_baseMass, baseInertia, isFixedBase, canSleep);
|
||||
mb->setHasSelfCollision(false);
|
||||
|
||||
btVector3 baseWorldPos;
|
||||
baseWorldPos.deSerialize(mbd->m_baseWorldPosition);
|
||||
|
||||
btQuaternion baseWorldOrn;
|
||||
baseWorldOrn.deSerialize(mbd->m_baseWorldOrientation);
|
||||
mb->setBasePos(baseWorldPos);
|
||||
mb->setWorldToBaseRot(baseWorldOrn.inverse());
|
||||
|
||||
m_data->m_mbMap.insert(mbd, mb);
|
||||
for (int i = 0; i < mbd->m_numLinks; i++)
|
||||
{
|
||||
btVector3 localInertiaDiagonal;
|
||||
localInertiaDiagonal.deSerialize(mbd->m_links[i].m_linkInertia);
|
||||
btQuaternion parentRotToThis;
|
||||
parentRotToThis.deSerialize(mbd->m_links[i].m_zeroRotParentToThis);
|
||||
btVector3 parentComToThisPivotOffset;
|
||||
parentComToThisPivotOffset.deSerialize(mbd->m_links[i].m_parentComToThisPivotOffset);
|
||||
btVector3 thisPivotToThisComOffset;
|
||||
thisPivotToThisComOffset.deSerialize(mbd->m_links[i].m_thisPivotToThisComOffset);
|
||||
|
||||
switch (mbd->m_links[i].m_jointType)
|
||||
{
|
||||
case btMultibodyLink::eFixed:
|
||||
{
|
||||
mb->setupFixed(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex,
|
||||
parentRotToThis, parentComToThisPivotOffset, thisPivotToThisComOffset);
|
||||
//search for the collider
|
||||
//mbd->m_links[i].m_linkCollider
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::ePrismatic:
|
||||
{
|
||||
btVector3 jointAxis;
|
||||
jointAxis.deSerialize(mbd->m_links[i].m_jointAxisBottom[0]);
|
||||
bool disableParentCollision = true; //todo
|
||||
mb->setupPrismatic(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex,
|
||||
parentRotToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision);
|
||||
mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]);
|
||||
mb->finalizeMultiDof();
|
||||
mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]);
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::eRevolute:
|
||||
{
|
||||
btVector3 jointAxis;
|
||||
jointAxis.deSerialize(mbd->m_links[i].m_jointAxisTop[0]);
|
||||
bool disableParentCollision = true; //todo
|
||||
mb->setupRevolute(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex,
|
||||
parentRotToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision);
|
||||
mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]);
|
||||
mb->finalizeMultiDof();
|
||||
mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]);
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::eSpherical:
|
||||
{
|
||||
btAssert(0);
|
||||
bool disableParentCollision = true; //todo
|
||||
mb->setupSpherical(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex,
|
||||
parentRotToThis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision);
|
||||
btScalar jointPos[4] = {(btScalar)mbd->m_links[i].m_jointPos[0], (btScalar)mbd->m_links[i].m_jointPos[1], (btScalar)mbd->m_links[i].m_jointPos[2], (btScalar)mbd->m_links[i].m_jointPos[3]};
|
||||
btScalar jointVel[3] = {(btScalar)mbd->m_links[i].m_jointVel[0], (btScalar)mbd->m_links[i].m_jointVel[1], (btScalar)mbd->m_links[i].m_jointVel[2]};
|
||||
mb->setJointPosMultiDof(i, jointPos);
|
||||
mb->finalizeMultiDof();
|
||||
mb->setJointVelMultiDof(i, jointVel);
|
||||
|
||||
break;
|
||||
}
|
||||
case btMultibodyLink::ePlanar:
|
||||
{
|
||||
btAssert(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool btMultiBodyWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
{
|
||||
bool result = false;
|
||||
btAlignedObjectArray<btQuaternion> scratchQ;
|
||||
btAlignedObjectArray<btVector3> scratchM;
|
||||
|
||||
if (m_importerFlags & eRESTORE_EXISTING_OBJECTS)
|
||||
{
|
||||
//check if the snapshot is valid for the existing world
|
||||
//equal number of objects, # links etc
|
||||
if ((bulletFile2->m_multiBodies.size() != m_data->m_mbDynamicsWorld->getNumMultibodies()))
|
||||
{
|
||||
printf("btMultiBodyWorldImporter::convertAllObjects error: expected %d multibodies, got %d.\n", m_data->m_mbDynamicsWorld->getNumMultibodies(), bulletFile2->m_multiBodies.size());
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
result = true;
|
||||
|
||||
//convert all multibodies
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
//for (int i = 0; i < bulletFile2->m_multiBodies.size(); i++)
|
||||
for (int i = bulletFile2->m_multiBodies.size() - 1; i >= 0; i--)
|
||||
{
|
||||
btMultiBodyDoubleData* mbd = (btMultiBodyDoubleData*)bulletFile2->m_multiBodies[i];
|
||||
btMultiBody* mb = m_data->m_mbDynamicsWorld->getMultiBody(i);
|
||||
if (mbd->m_numLinks != mb->getNumLinks())
|
||||
{
|
||||
printf("btMultiBodyWorldImporter::convertAllObjects error: mismatch in number of links in a body (expected %d, found %d).\n", mbd->m_numLinks, mb->getNumLinks() );
|
||||
result = false;
|
||||
return result;
|
||||
} else
|
||||
{
|
||||
syncMultiBody(mbd, mb, m_data, scratchQ, scratchM);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = bulletFile2->m_rigidBodies.size() - 1; i >= 0; i--)
|
||||
{
|
||||
btRigidBodyDoubleData* rbd = (btRigidBodyDoubleData*)bulletFile2->m_rigidBodies[i];
|
||||
int foundRb = -1;
|
||||
int uid = rbd->m_collisionObjectData.m_uniqueId;
|
||||
for (int i = 0; i < m_data->m_mbDynamicsWorld->getNumCollisionObjects(); i++)
|
||||
{
|
||||
if (uid == m_data->m_mbDynamicsWorld->getCollisionObjectArray()[i]->getBroadphaseHandle()->m_uniqueId)
|
||||
{
|
||||
foundRb = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundRb >= 0)
|
||||
{
|
||||
btRigidBody* rb = btRigidBody::upcast(m_data->m_mbDynamicsWorld->getCollisionObjectArray()[foundRb]);
|
||||
if (rb)
|
||||
{
|
||||
btTransform tr;
|
||||
tr.deSerializeDouble(rbd->m_collisionObjectData.m_worldTransform);
|
||||
rb->setWorldTransform(tr);
|
||||
btVector3 linVel, angVel;
|
||||
linVel.deSerializeDouble(rbd->m_linearVelocity);
|
||||
angVel.deSerializeDouble(rbd->m_angularVelocity);
|
||||
rb->setLinearVelocity(linVel);
|
||||
rb->setAngularVelocity(angVel);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("btMultiBodyWorldImporter::convertAllObjects error: cannot find btRigidBody with bodyUniqueId %d\n", uid);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error in btMultiBodyWorldImporter::convertAllObjects: didn't find bodyUniqueId: %d\n", uid);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
//todo: check why body1 pointer is not properly deserialized
|
||||
for (int i = 0; i < bulletFile2->m_contactManifolds.size(); i++)
|
||||
{
|
||||
btPersistentManifoldDoubleData* manifoldData = (btPersistentManifoldDoubleData*)bulletFile2->m_contactManifolds[i];
|
||||
{
|
||||
void* ptr = bulletFile2->findLibPointer(manifoldData->m_body0);
|
||||
if (ptr)
|
||||
{
|
||||
manifoldData->m_body0 = (btCollisionObjectDoubleData*)ptr;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
void* ptr = bulletFile2->findLibPointer(manifoldData->m_body1);
|
||||
if (ptr)
|
||||
{
|
||||
manifoldData->m_body1 = (btCollisionObjectDoubleData*)ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bulletFile2->m_contactManifolds.size())
|
||||
{
|
||||
syncContactManifolds((btPersistentManifoldDoubleData**)&bulletFile2->m_contactManifolds[0], bulletFile2->m_contactManifolds.size(), m_data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//single precision version
|
||||
//for (int i = 0; i < bulletFile2->m_multiBodies.size(); i++)
|
||||
for (int i = bulletFile2->m_multiBodies.size() - 1; i >= 0; i--)
|
||||
{
|
||||
btMultiBodyFloatData* mbd = (btMultiBodyFloatData*)bulletFile2->m_multiBodies[i];
|
||||
btMultiBody* mb = m_data->m_mbDynamicsWorld->getMultiBody(i);
|
||||
if (mbd->m_numLinks != mb->getNumLinks())
|
||||
{
|
||||
printf("btMultiBodyWorldImporter::convertAllObjects error: mismatch in number of links in a body (expected %d, found %d).\n", mbd->m_numLinks, mb->getNumLinks() );
|
||||
result = false;
|
||||
return result;
|
||||
} else
|
||||
{
|
||||
syncMultiBody(mbd, mb, m_data, scratchQ, scratchM);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = bulletFile2->m_rigidBodies.size() - 1; i >= 0; i--)
|
||||
{
|
||||
btRigidBodyFloatData* rbd = (btRigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||
int foundRb = -1;
|
||||
int uid = rbd->m_collisionObjectData.m_uniqueId;
|
||||
for (int i = 0; i < m_data->m_mbDynamicsWorld->getNumCollisionObjects(); i++)
|
||||
{
|
||||
if (uid == m_data->m_mbDynamicsWorld->getCollisionObjectArray()[i]->getBroadphaseHandle()->m_uniqueId)
|
||||
{
|
||||
foundRb = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundRb >= 0)
|
||||
{
|
||||
btRigidBody* rb = btRigidBody::upcast(m_data->m_mbDynamicsWorld->getCollisionObjectArray()[foundRb]);
|
||||
if (rb)
|
||||
{
|
||||
btTransform tr;
|
||||
tr.deSerializeFloat(rbd->m_collisionObjectData.m_worldTransform);
|
||||
rb->setWorldTransform(tr);
|
||||
btVector3 linVel, angVel;
|
||||
linVel.deSerializeFloat(rbd->m_linearVelocity);
|
||||
angVel.deSerializeFloat(rbd->m_angularVelocity);
|
||||
rb->setLinearVelocity(linVel);
|
||||
rb->setAngularVelocity(angVel);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("btMultiBodyWorldImporter::convertAllObjects error: cannot find btRigidBody with bodyUniqueId %d\n", uid);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error in btMultiBodyWorldImporter::convertAllObjects: didn't find bodyUniqueId: %d\n", uid);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
//todo: check why body1 pointer is not properly deserialized
|
||||
for (int i = 0; i < bulletFile2->m_contactManifolds.size(); i++)
|
||||
{
|
||||
btPersistentManifoldFloatData* manifoldData = (btPersistentManifoldFloatData*)bulletFile2->m_contactManifolds[i];
|
||||
{
|
||||
void* ptr = bulletFile2->findLibPointer(manifoldData->m_body0);
|
||||
if (ptr)
|
||||
{
|
||||
manifoldData->m_body0 = (btCollisionObjectFloatData*)ptr;
|
||||
}
|
||||
}
|
||||
{
|
||||
void* ptr = bulletFile2->findLibPointer(manifoldData->m_body1);
|
||||
if (ptr)
|
||||
{
|
||||
manifoldData->m_body1 = (btCollisionObjectFloatData*)ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bulletFile2->m_contactManifolds.size())
|
||||
{
|
||||
syncContactManifolds((btPersistentManifoldFloatData**)&bulletFile2->m_contactManifolds[0], bulletFile2->m_contactManifolds.size(), m_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = btBulletWorldImporter::convertAllObjects(bulletFile2);
|
||||
|
||||
//convert all multibodies
|
||||
for (int i = 0; i < bulletFile2->m_multiBodies.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
btMultiBodyDoubleData* mbd = (btMultiBodyDoubleData*)bulletFile2->m_multiBodies[i];
|
||||
convertMultiBody(mbd, m_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
btMultiBodyFloatData* mbd = (btMultiBodyFloatData*)bulletFile2->m_multiBodies[i];
|
||||
convertMultiBody(mbd, m_data);
|
||||
}
|
||||
}
|
||||
|
||||
//forward kinematics, so that the link world transforms are valid, for collision detection
|
||||
for (int i = 0; i < m_data->m_mbMap.size(); i++)
|
||||
{
|
||||
btMultiBody** ptr = m_data->m_mbMap.getAtIndex(i);
|
||||
if (ptr)
|
||||
{
|
||||
btMultiBody* mb = *ptr;
|
||||
mb->finalizeMultiDof();
|
||||
btVector3 linvel = mb->getBaseVel();
|
||||
btVector3 angvel = mb->getBaseOmega();
|
||||
mb->forwardKinematics(scratchQ, scratchM);
|
||||
}
|
||||
}
|
||||
|
||||
//convert all multibody link colliders
|
||||
for (int i = 0; i < bulletFile2->m_multiBodyLinkColliders.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
btMultiBodyLinkColliderDoubleData* mblcd = (btMultiBodyLinkColliderDoubleData*)bulletFile2->m_multiBodyLinkColliders[i];
|
||||
|
||||
btMultiBody** ptr = m_data->m_mbMap[mblcd->m_multiBody];
|
||||
if (ptr)
|
||||
{
|
||||
btMultiBody* multiBody = *ptr;
|
||||
|
||||
btCollisionShape** shapePtr = m_shapeMap.find(mblcd->m_colObjData.m_collisionShape);
|
||||
if (shapePtr && *shapePtr)
|
||||
{
|
||||
btTransform startTransform;
|
||||
mblcd->m_colObjData.m_worldTransform.m_origin.m_floats[3] = 0.f;
|
||||
startTransform.deSerializeDouble(mblcd->m_colObjData.m_worldTransform);
|
||||
|
||||
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
|
||||
if (shape)
|
||||
{
|
||||
btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(multiBody, mblcd->m_link);
|
||||
col->setCollisionShape(shape);
|
||||
//btCollisionObject* body = createCollisionObject(startTransform,shape,mblcd->m_colObjData.m_name);
|
||||
col->setFriction(btScalar(mblcd->m_colObjData.m_friction));
|
||||
col->setRestitution(btScalar(mblcd->m_colObjData.m_restitution));
|
||||
//m_bodyMap.insert(colObjData,body);
|
||||
if (mblcd->m_link == -1)
|
||||
{
|
||||
col->setWorldTransform(multiBody->getBaseWorldTransform());
|
||||
multiBody->setBaseCollider(col);
|
||||
}
|
||||
else
|
||||
{
|
||||
col->setWorldTransform(multiBody->getLink(mblcd->m_link).m_cachedWorldTransform);
|
||||
multiBody->getLink(mblcd->m_link).m_collider = col;
|
||||
}
|
||||
int mbLinkIndex = mblcd->m_link;
|
||||
|
||||
bool isDynamic = (mbLinkIndex < 0 && multiBody->hasFixedBase()) ? false : true;
|
||||
int collisionFilterGroup = isDynamic ? int(btBroadphaseProxy::DefaultFilter) : int(btBroadphaseProxy::StaticFilter);
|
||||
int collisionFilterMask = isDynamic ? int(btBroadphaseProxy::AllFilter) : int(btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
|
||||
|
||||
#if 0
|
||||
int colGroup = 0, colMask = 0;
|
||||
int collisionFlags = mblcd->m_colObjData.m_collisionFlags;
|
||||
if (collisionFlags & URDF_HAS_COLLISION_GROUP)
|
||||
{
|
||||
collisionFilterGroup = colGroup;
|
||||
}
|
||||
if (collisionFlags & URDF_HAS_COLLISION_MASK)
|
||||
{
|
||||
collisionFilterMask = colMask;
|
||||
}
|
||||
#endif
|
||||
m_data->m_mbDynamicsWorld->addCollisionObject(col, collisionFilterGroup, collisionFilterMask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error: no shape found\n");
|
||||
}
|
||||
#if 0
|
||||
//base and fixed? -> static, otherwise flag as dynamic
|
||||
|
||||
world1->addCollisionObject(col, collisionFilterGroup, collisionFilterMask);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_data->m_mbMap.size(); i++)
|
||||
{
|
||||
btMultiBody** ptr = m_data->m_mbMap.getAtIndex(i);
|
||||
if (ptr)
|
||||
{
|
||||
btMultiBody* mb = *ptr;
|
||||
mb->finalizeMultiDof();
|
||||
|
||||
m_data->m_mbDynamicsWorld->addMultiBody(mb);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef BT_MULTIBODY_WORLD_IMPORTER_H
|
||||
#define BT_MULTIBODY_WORLD_IMPORTER_H
|
||||
|
||||
#include "btBulletWorldImporter.h"
|
||||
|
||||
class btMultiBodyWorldImporter : public btBulletWorldImporter
|
||||
{
|
||||
struct btMultiBodyWorldImporterInternalData* m_data;
|
||||
|
||||
public:
|
||||
btMultiBodyWorldImporter(class btMultiBodyDynamicsWorld* world);
|
||||
virtual ~btMultiBodyWorldImporter();
|
||||
|
||||
virtual bool convertAllObjects(bParse::btBulletFile* bulletFile2);
|
||||
|
||||
virtual void deleteAllData();
|
||||
};
|
||||
|
||||
#endif //BT_MULTIBODY_WORLD_IMPORTER_H
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -13,7 +13,6 @@ subject to the following restrictions:
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BT_WORLD_IMPORTER_H
|
||||
#define BT_WORLD_IMPORTER_H
|
||||
|
||||
|
|
@ -57,71 +56,73 @@ struct btRigidBodyFloatData;
|
|||
#define btRigidBodyData btRigidBodyDoubleData
|
||||
#else
|
||||
#define btRigidBodyData btRigidBodyFloatData
|
||||
#endif//BT_USE_DOUBLE_PRECISION
|
||||
#endif //BT_USE_DOUBLE_PRECISION
|
||||
|
||||
enum btWorldImporterFlags
|
||||
{
|
||||
eRESTORE_EXISTING_OBJECTS = 1, //don't create new objects
|
||||
};
|
||||
|
||||
class btWorldImporter
|
||||
{
|
||||
protected:
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
int m_verboseMode;
|
||||
|
||||
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
|
||||
int m_verboseMode;
|
||||
int m_importerFlags;
|
||||
|
||||
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
|
||||
btAlignedObjectArray<btCollisionObject*> m_allocatedRigidBodies;
|
||||
btAlignedObjectArray<btTypedConstraint*> m_allocatedConstraints;
|
||||
btAlignedObjectArray<btOptimizedBvh*> m_allocatedBvhs;
|
||||
btAlignedObjectArray<btOptimizedBvh*> m_allocatedBvhs;
|
||||
btAlignedObjectArray<btTriangleInfoMap*> m_allocatedTriangleInfoMaps;
|
||||
btAlignedObjectArray<btTriangleIndexVertexArray*> m_allocatedTriangleIndexArrays;
|
||||
btAlignedObjectArray<btStridingMeshInterfaceData*> m_allocatedbtStridingMeshInterfaceDatas;
|
||||
|
||||
btAlignedObjectArray<char*> m_allocatedNames;
|
||||
btAlignedObjectArray<char*> m_allocatedNames;
|
||||
|
||||
btAlignedObjectArray<int*> m_indexArrays;
|
||||
btAlignedObjectArray<short int*> m_shortIndexArrays;
|
||||
btAlignedObjectArray<unsigned char*> m_charIndexArrays;
|
||||
btAlignedObjectArray<int*> m_indexArrays;
|
||||
btAlignedObjectArray<short int*> m_shortIndexArrays;
|
||||
btAlignedObjectArray<unsigned char*> m_charIndexArrays;
|
||||
|
||||
btAlignedObjectArray<btVector3FloatData*> m_floatVertexArrays;
|
||||
btAlignedObjectArray<btVector3DoubleData*> m_doubleVertexArrays;
|
||||
btAlignedObjectArray<btVector3FloatData*> m_floatVertexArrays;
|
||||
btAlignedObjectArray<btVector3DoubleData*> m_doubleVertexArrays;
|
||||
|
||||
btHashMap<btHashPtr, btOptimizedBvh*> m_bvhMap;
|
||||
btHashMap<btHashPtr, btTriangleInfoMap*> m_timMap;
|
||||
|
||||
btHashMap<btHashPtr,btOptimizedBvh*> m_bvhMap;
|
||||
btHashMap<btHashPtr,btTriangleInfoMap*> m_timMap;
|
||||
|
||||
btHashMap<btHashString,btCollisionShape*> m_nameShapeMap;
|
||||
btHashMap<btHashString,btRigidBody*> m_nameBodyMap;
|
||||
btHashMap<btHashString,btTypedConstraint*> m_nameConstraintMap;
|
||||
btHashMap<btHashPtr,const char*> m_objectNameMap;
|
||||
|
||||
btHashMap<btHashPtr,btCollisionShape*> m_shapeMap;
|
||||
btHashMap<btHashPtr,btCollisionObject*> m_bodyMap;
|
||||
btHashMap<btHashString, btCollisionShape*> m_nameShapeMap;
|
||||
btHashMap<btHashString, btRigidBody*> m_nameBodyMap;
|
||||
btHashMap<btHashString, btTypedConstraint*> m_nameConstraintMap;
|
||||
btHashMap<btHashPtr, const char*> m_objectNameMap;
|
||||
|
||||
btHashMap<btHashPtr, btCollisionShape*> m_shapeMap;
|
||||
btHashMap<btHashPtr, btCollisionObject*> m_bodyMap;
|
||||
|
||||
//methods
|
||||
|
||||
static btRigidBody& getFixedBody();
|
||||
|
||||
char* duplicateName(const char* name);
|
||||
char* duplicateName(const char* name);
|
||||
|
||||
btCollisionShape* convertCollisionShape( btCollisionShapeData* shapeData );
|
||||
|
||||
void convertConstraintBackwardsCompatible281(btTypedConstraintData* constraintData, btRigidBody* rbA, btRigidBody* rbB, int fileVersion);
|
||||
void convertConstraintFloat(btTypedConstraintFloatData* constraintData, btRigidBody* rbA, btRigidBody* rbB, int fileVersion);
|
||||
void convertConstraintDouble(btTypedConstraintDoubleData* constraintData, btRigidBody* rbA, btRigidBody* rbB, int fileVersion);
|
||||
void convertRigidBodyFloat(btRigidBodyFloatData* colObjData);
|
||||
void convertRigidBodyDouble( btRigidBodyDoubleData* colObjData);
|
||||
btCollisionShape* convertCollisionShape(btCollisionShapeData* shapeData);
|
||||
|
||||
void convertConstraintBackwardsCompatible281(btTypedConstraintData* constraintData, btRigidBody* rbA, btRigidBody* rbB, int fileVersion);
|
||||
void convertConstraintFloat(btTypedConstraintFloatData* constraintData, btRigidBody* rbA, btRigidBody* rbB, int fileVersion);
|
||||
void convertConstraintDouble(btTypedConstraintDoubleData* constraintData, btRigidBody* rbA, btRigidBody* rbB, int fileVersion);
|
||||
void convertRigidBodyFloat(btRigidBodyFloatData* colObjData);
|
||||
void convertRigidBodyDouble(btRigidBodyDoubleData* colObjData);
|
||||
|
||||
public:
|
||||
|
||||
btWorldImporter(btDynamicsWorld* world);
|
||||
|
||||
|
||||
virtual ~btWorldImporter();
|
||||
|
||||
///delete all memory collision shapes, rigid bodies, constraints etc. allocated during the load.
|
||||
///delete all memory collision shapes, rigid bodies, constraints etc. allocated during the load.
|
||||
///make sure you don't use the dynamics world containing objects after you call this method
|
||||
virtual void deleteAllData();
|
||||
|
||||
void setVerboseMode(int verboseMode)
|
||||
void setVerboseMode(int verboseMode)
|
||||
{
|
||||
m_verboseMode = verboseMode;
|
||||
}
|
||||
|
|
@ -131,85 +132,96 @@ public:
|
|||
return m_verboseMode;
|
||||
}
|
||||
|
||||
// query for data
|
||||
int getNumCollisionShapes() const;
|
||||
void setImporterFlags(int importerFlags)
|
||||
{
|
||||
m_importerFlags = importerFlags;
|
||||
}
|
||||
|
||||
int getImporterFlags() const
|
||||
{
|
||||
return m_importerFlags;
|
||||
}
|
||||
|
||||
// query for data
|
||||
int getNumCollisionShapes() const;
|
||||
btCollisionShape* getCollisionShapeByIndex(int index);
|
||||
int getNumRigidBodies() const;
|
||||
btCollisionObject* getRigidBodyByIndex(int index) const;
|
||||
int getNumConstraints() const;
|
||||
btTypedConstraint* getConstraintByIndex(int index) const;
|
||||
int getNumBvhs() const;
|
||||
btOptimizedBvh* getBvhByIndex(int index) const;
|
||||
btOptimizedBvh* getBvhByIndex(int index) const;
|
||||
int getNumTriangleInfoMaps() const;
|
||||
btTriangleInfoMap* getTriangleInfoMapByIndex(int index) const;
|
||||
|
||||
|
||||
// queris involving named objects
|
||||
btCollisionShape* getCollisionShapeByName(const char* name);
|
||||
btRigidBody* getRigidBodyByName(const char* name);
|
||||
btTypedConstraint* getConstraintByName(const char* name);
|
||||
const char* getNameForPointer(const void* ptr) const;
|
||||
const char* getNameForPointer(const void* ptr) const;
|
||||
|
||||
///those virtuals are called by load and can be overridden by the user
|
||||
|
||||
virtual void setDynamicsWorldInfo(const btVector3& gravity, const btContactSolverInfo& solverInfo);
|
||||
virtual void setDynamicsWorldInfo(const btVector3& gravity, const btContactSolverInfo& solverInfo);
|
||||
|
||||
//bodies
|
||||
virtual btRigidBody* createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform, btCollisionShape* shape,const char* bodyName);
|
||||
virtual btCollisionObject* createCollisionObject( const btTransform& startTransform, btCollisionShape* shape,const char* bodyName);
|
||||
virtual btRigidBody* createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform, btCollisionShape* shape, const char* bodyName);
|
||||
virtual btCollisionObject* createCollisionObject(const btTransform& startTransform, btCollisionShape* shape, const char* bodyName);
|
||||
|
||||
///shapes
|
||||
|
||||
virtual btCollisionShape* createPlaneShape(const btVector3& planeNormal,btScalar planeConstant);
|
||||
virtual btCollisionShape* createPlaneShape(const btVector3& planeNormal, btScalar planeConstant);
|
||||
virtual btCollisionShape* createBoxShape(const btVector3& halfExtents);
|
||||
virtual btCollisionShape* createSphereShape(btScalar radius);
|
||||
virtual btCollisionShape* createCapsuleShapeX(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createCapsuleShapeY(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createCapsuleShapeZ(btScalar radius, btScalar height);
|
||||
|
||||
virtual btCollisionShape* createCylinderShapeX(btScalar radius,btScalar height);
|
||||
virtual btCollisionShape* createCylinderShapeY(btScalar radius,btScalar height);
|
||||
virtual btCollisionShape* createCylinderShapeZ(btScalar radius,btScalar height);
|
||||
virtual btCollisionShape* createConeShapeX(btScalar radius,btScalar height);
|
||||
virtual btCollisionShape* createConeShapeY(btScalar radius,btScalar height);
|
||||
virtual btCollisionShape* createConeShapeZ(btScalar radius,btScalar height);
|
||||
virtual class btTriangleIndexVertexArray* createTriangleMeshContainer();
|
||||
virtual btBvhTriangleMeshShape* createBvhTriangleMeshShape(btStridingMeshInterface* trimesh, btOptimizedBvh* bvh);
|
||||
|
||||
virtual btCollisionShape* createCylinderShapeX(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createCylinderShapeY(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createCylinderShapeZ(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createConeShapeX(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createConeShapeY(btScalar radius, btScalar height);
|
||||
virtual btCollisionShape* createConeShapeZ(btScalar radius, btScalar height);
|
||||
virtual class btTriangleIndexVertexArray* createTriangleMeshContainer();
|
||||
virtual btBvhTriangleMeshShape* createBvhTriangleMeshShape(btStridingMeshInterface* trimesh, btOptimizedBvh* bvh);
|
||||
virtual btCollisionShape* createConvexTriangleMeshShape(btStridingMeshInterface* trimesh);
|
||||
virtual btGImpactMeshShape* createGimpactShape(btStridingMeshInterface* trimesh);
|
||||
virtual btStridingMeshInterfaceData* createStridingMeshInterfaceData(btStridingMeshInterfaceData* interfaceData);
|
||||
|
||||
virtual class btConvexHullShape* createConvexHullShape();
|
||||
virtual class btCompoundShape* createCompoundShape();
|
||||
virtual class btScaledBvhTriangleMeshShape* createScaledTrangleMeshShape(btBvhTriangleMeshShape* meshShape,const btVector3& localScalingbtBvhTriangleMeshShape);
|
||||
virtual class btScaledBvhTriangleMeshShape* createScaledTrangleMeshShape(btBvhTriangleMeshShape* meshShape, const btVector3& localScalingbtBvhTriangleMeshShape);
|
||||
|
||||
virtual class btMultiSphereShape* createMultiSphereShape(const btVector3* positions,const btScalar* radi,int numSpheres);
|
||||
virtual class btMultiSphereShape* createMultiSphereShape(const btVector3* positions, const btScalar* radi, int numSpheres);
|
||||
|
||||
virtual btTriangleIndexVertexArray* createMeshInterface(btStridingMeshInterfaceData& meshData);
|
||||
|
||||
virtual class btHeightfieldTerrainShape* createHeightfieldShape(int heightStickWidth, int heightStickLength,
|
||||
const void* heightfieldData, btScalar heightScale,
|
||||
btScalar minHeight, btScalar maxHeight,
|
||||
int upAxis, int heightDataType,
|
||||
bool flipQuadEdges);
|
||||
|
||||
///acceleration and connectivity structures
|
||||
virtual btOptimizedBvh* createOptimizedBvh();
|
||||
virtual btOptimizedBvh* createOptimizedBvh();
|
||||
virtual btTriangleInfoMap* createTriangleInfoMap();
|
||||
|
||||
///constraints
|
||||
virtual btPoint2PointConstraint* createPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB);
|
||||
virtual btPoint2PointConstraint* createPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA);
|
||||
virtual btHingeConstraint* createHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA=false);
|
||||
virtual btHingeConstraint* createHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame, bool useReferenceFrameA=false);
|
||||
virtual btConeTwistConstraint* createConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTransform& rbAFrame, const btTransform& rbBFrame);
|
||||
virtual btConeTwistConstraint* createConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame);
|
||||
virtual btGeneric6DofConstraint* createGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
|
||||
virtual btGeneric6DofConstraint* createGeneric6DofConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB);
|
||||
virtual btGeneric6DofSpringConstraint* createGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
|
||||
virtual btGeneric6DofSpring2Constraint* createGeneric6DofSpring2Constraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, int rotateOrder );
|
||||
|
||||
virtual btSliderConstraint* createSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
|
||||
virtual btSliderConstraint* createSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameA);
|
||||
virtual btGearConstraint* createGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA,const btVector3& axisInB, btScalar ratio);
|
||||
|
||||
|
||||
|
||||
virtual btPoint2PointConstraint* createPoint2PointConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& pivotInA, const btVector3& pivotInB);
|
||||
virtual btPoint2PointConstraint* createPoint2PointConstraint(btRigidBody& rbA, const btVector3& pivotInA);
|
||||
virtual btHingeConstraint* createHingeConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA = false);
|
||||
virtual btHingeConstraint* createHingeConstraint(btRigidBody& rbA, const btTransform& rbAFrame, bool useReferenceFrameA = false);
|
||||
virtual btConeTwistConstraint* createConeTwistConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame);
|
||||
virtual btConeTwistConstraint* createConeTwistConstraint(btRigidBody& rbA, const btTransform& rbAFrame);
|
||||
virtual btGeneric6DofConstraint* createGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA);
|
||||
virtual btGeneric6DofConstraint* createGeneric6DofConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB);
|
||||
virtual btGeneric6DofSpringConstraint* createGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA);
|
||||
virtual btGeneric6DofSpring2Constraint* createGeneric6DofSpring2Constraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, int rotateOrder);
|
||||
|
||||
virtual btSliderConstraint* createSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA);
|
||||
virtual btSliderConstraint* createSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameA);
|
||||
virtual btGearConstraint* createGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA, const btVector3& axisInB, btScalar ratio);
|
||||
};
|
||||
|
||||
|
||||
#endif //BT_WORLD_IMPORTER_H
|
||||
#endif //BT_WORLD_IMPORTER_H
|
||||
|
|
@ -6,7 +6,11 @@
|
|||
"../BulletFileLoader",
|
||||
"../../../src"
|
||||
}
|
||||
|
||||
|
||||
if os.is("Linux") then
|
||||
buildoptions{"-fPIC"}
|
||||
end
|
||||
|
||||
files {
|
||||
"**.cpp",
|
||||
"**.h"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ INCLUDE_DIRECTORIES(
|
|||
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/tinyxml2
|
||||
)
|
||||
|
||||
ADD_LIBRARY(
|
||||
|
|
@ -10,12 +11,7 @@ ADD_LIBRARY(
|
|||
btBulletXmlWorldImporter.h
|
||||
string_split.cpp
|
||||
string_split.h
|
||||
tinyxml.cpp
|
||||
tinyxml.h
|
||||
tinystr.cpp
|
||||
tinystr.h
|
||||
tinyxmlerror.cpp
|
||||
tinyxmlparser.cpp
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES(BulletXmlWorldImporter PROPERTIES VERSION ${BULLET_VERSION})
|
||||
|
|
@ -32,7 +28,11 @@ IF (INSTALL_EXTRA_LIBS)
|
|||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||
INSTALL(TARGETS BulletXmlWorldImporter DESTINATION .)
|
||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||
INSTALL(TARGETS BulletXmlWorldImporter DESTINATION lib${LIB_SUFFIX})
|
||||
INSTALL(TARGETS BulletXmlWorldImporter
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||
|
||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,12 @@ subject to the following restrictions:
|
|||
#include "LinearMath/btScalar.h"
|
||||
|
||||
class btDynamicsWorld;
|
||||
class TiXmlNode;
|
||||
|
||||
namespace tinyxml2
|
||||
{
|
||||
class XMLNode;
|
||||
};
|
||||
|
||||
struct btConvexInternalShapeData;
|
||||
struct btCollisionShapeData;
|
||||
#ifdef BT_USE_DOUBLE_PRECISION
|
||||
|
|
@ -32,8 +37,7 @@ struct btRigidBodyFloatData;
|
|||
struct btTypedConstraintFloatData;
|
||||
#define btTypedConstraintData2 btTypedConstraintFloatData
|
||||
#define btRigidBodyData btRigidBodyFloatData
|
||||
#endif//BT_USE_DOUBLE_PRECISION
|
||||
|
||||
#endif //BT_USE_DOUBLE_PRECISION
|
||||
|
||||
struct btCompoundShapeChildData;
|
||||
|
||||
|
|
@ -42,46 +46,44 @@ struct btCompoundShapeChildData;
|
|||
|
||||
class btBulletXmlWorldImporter : public btWorldImporter
|
||||
{
|
||||
|
||||
protected:
|
||||
btAlignedObjectArray<btCollisionShapeData*> m_collisionShapeData;
|
||||
btAlignedObjectArray<btAlignedObjectArray<btCompoundShapeChildData>* > m_compoundShapeChildDataArrays;
|
||||
btAlignedObjectArray<btRigidBodyData*> m_rigidBodyData;
|
||||
btAlignedObjectArray<btTypedConstraintData2*> m_constraintData;
|
||||
btHashMap<btHashPtr,void*> m_pointerLookup;
|
||||
int m_fileVersion;
|
||||
bool m_fileOk;
|
||||
btAlignedObjectArray<btCollisionShapeData*> m_collisionShapeData;
|
||||
btAlignedObjectArray<btAlignedObjectArray<btCompoundShapeChildData>*> m_compoundShapeChildDataArrays;
|
||||
btAlignedObjectArray<btRigidBodyData*> m_rigidBodyData;
|
||||
btAlignedObjectArray<btTypedConstraintData2*> m_constraintData;
|
||||
btHashMap<btHashPtr, void*> m_pointerLookup;
|
||||
int m_fileVersion;
|
||||
bool m_fileOk;
|
||||
|
||||
void auto_serialize_root_level_children(TiXmlNode* pParent);
|
||||
void auto_serialize(TiXmlNode* pParent);
|
||||
void auto_serialize_root_level_children(tinyxml2::XMLNode* pParent);
|
||||
void auto_serialize(tinyxml2::XMLNode* pParent);
|
||||
|
||||
void deSerializeVector3FloatData(TiXmlNode* pParent,btAlignedObjectArray<btVector3FloatData>& vectors);
|
||||
void deSerializeVector3FloatData(tinyxml2::XMLNode* pParent, btAlignedObjectArray<btVector3FloatData>& vectors);
|
||||
|
||||
void fixupCollisionDataPointers(btCollisionShapeData* shapeData);
|
||||
void fixupConstraintData(btTypedConstraintData2* tcd);
|
||||
void fixupCollisionDataPointers(btCollisionShapeData* shapeData);
|
||||
void fixupConstraintData(btTypedConstraintData2* tcd);
|
||||
|
||||
//collision shapes data
|
||||
void deSerializeCollisionShapeData(TiXmlNode* pParent,btCollisionShapeData* colShapeData);
|
||||
void deSerializeConvexInternalShapeData(TiXmlNode* pParent);
|
||||
void deSerializeStaticPlaneShapeData(TiXmlNode* pParent);
|
||||
void deSerializeCompoundShapeData(TiXmlNode* pParent);
|
||||
void deSerializeCompoundShapeChildData(TiXmlNode* pParent);
|
||||
void deSerializeConvexHullShapeData(TiXmlNode* pParent);
|
||||
void deSerializeDynamicsWorldData(TiXmlNode* parent);
|
||||
|
||||
void deSerializeCollisionShapeData(tinyxml2::XMLNode* pParent, btCollisionShapeData* colShapeData);
|
||||
void deSerializeConvexInternalShapeData(tinyxml2::XMLNode* pParent);
|
||||
void deSerializeStaticPlaneShapeData(tinyxml2::XMLNode* pParent);
|
||||
void deSerializeCompoundShapeData(tinyxml2::XMLNode* pParent);
|
||||
void deSerializeCompoundShapeChildData(tinyxml2::XMLNode* pParent);
|
||||
void deSerializeConvexHullShapeData(tinyxml2::XMLNode* pParent);
|
||||
void deSerializeDynamicsWorldData(tinyxml2::XMLNode* parent);
|
||||
|
||||
///bodies
|
||||
void deSerializeRigidBodyFloatData(TiXmlNode* pParent);
|
||||
void deSerializeRigidBodyFloatData(tinyxml2::XMLNode* pParent);
|
||||
|
||||
///constraints
|
||||
void deSerializeGeneric6DofConstraintData(TiXmlNode* pParent);
|
||||
void deSerializeGeneric6DofConstraintData(tinyxml2::XMLNode* pParent);
|
||||
|
||||
public:
|
||||
btBulletXmlWorldImporter(btDynamicsWorld* world);
|
||||
public:
|
||||
btBulletXmlWorldImporter(btDynamicsWorld* world);
|
||||
|
||||
virtual ~btBulletXmlWorldImporter();
|
||||
|
||||
bool loadFile(const char* fileName);
|
||||
virtual ~btBulletXmlWorldImporter();
|
||||
|
||||
bool loadFile(const char* fileName);
|
||||
};
|
||||
|
||||
#endif //BT_BULLET_XML_WORLD_IMPORTER_H
|
||||
#endif //BT_BULLET_XML_WORLD_IMPORTER_H
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
project "BulletXmlWorldImporter"
|
||||
|
||||
kind "StaticLib"
|
||||
targetdir "../../lib"
|
||||
--targetdir "../../lib"
|
||||
includedirs {
|
||||
"../BulletWorldImporter",
|
||||
"../BulletFileLoader",
|
||||
"../../../src"
|
||||
"../../../src",
|
||||
"../../../examples/ThirdPartyLibs/tinyxml2"
|
||||
}
|
||||
|
||||
files {
|
||||
"**.cpp",
|
||||
"**.h"
|
||||
}
|
||||
"**.h",
|
||||
"../../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,18 +25,16 @@ subject to the following restrictions:
|
|||
|
||||
namespace bullet_utils
|
||||
{
|
||||
void split( btAlignedObjectArray<std::string>&pieces, const std::string& vector_str, const std::string& separator)
|
||||
{
|
||||
char** strArray = str_split(vector_str.c_str(),separator.c_str());
|
||||
int numSubStr = str_array_len(strArray);
|
||||
for (int i=0;i<numSubStr;i++)
|
||||
pieces.push_back(std::string(strArray[i]));
|
||||
str_array_free(strArray);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void split(btAlignedObjectArray<std::string> &pieces, const std::string &vector_str, const std::string &separator)
|
||||
{
|
||||
char **strArray = str_split(vector_str.c_str(), separator.c_str());
|
||||
int numSubStr = str_array_len(strArray);
|
||||
for (int i = 0; i < numSubStr; i++)
|
||||
pieces.push_back(std::string(strArray[i]));
|
||||
str_array_free(strArray);
|
||||
}
|
||||
|
||||
}; // namespace bullet_utils
|
||||
|
||||
/* Append an item to a dynamically allocated array of strings. On failure,
|
||||
return NULL, in which case the original array is intact. The item
|
||||
|
|
@ -44,207 +42,220 @@ namespace bullet_utils
|
|||
array. Otherwise, extend the array. Make sure the array is always
|
||||
NULL-terminated. Input string might not be '\0'-terminated. */
|
||||
char **str_array_append(char **array, size_t nitems, const char *item,
|
||||
size_t itemlen)
|
||||
size_t itemlen)
|
||||
{
|
||||
/* Make a dynamic copy of the item. */
|
||||
char *copy;
|
||||
if (item == NULL)
|
||||
copy = NULL;
|
||||
else {
|
||||
copy = (char*)malloc(itemlen + 1);
|
||||
if (copy == NULL)
|
||||
return NULL;
|
||||
memcpy(copy, item, itemlen);
|
||||
copy[itemlen] = '\0';
|
||||
}
|
||||
|
||||
/* Extend array with one element. Except extend it by two elements,
|
||||
/* Make a dynamic copy of the item. */
|
||||
char *copy;
|
||||
if (item == NULL)
|
||||
copy = NULL;
|
||||
else
|
||||
{
|
||||
copy = (char *)malloc(itemlen + 1);
|
||||
if (copy == NULL)
|
||||
return NULL;
|
||||
memcpy(copy, item, itemlen);
|
||||
copy[itemlen] = '\0';
|
||||
}
|
||||
|
||||
/* Extend array with one element. Except extend it by two elements,
|
||||
in case it did not yet exist. This might mean it is a teeny bit
|
||||
too big, but we don't care. */
|
||||
array = (char**)realloc(array, (nitems + 2) * sizeof(array[0]));
|
||||
if (array == NULL) {
|
||||
free(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add copy of item to array, and return it. */
|
||||
array[nitems] = copy;
|
||||
array[nitems+1] = NULL;
|
||||
return array;
|
||||
}
|
||||
array = (char **)realloc(array, (nitems + 2) * sizeof(array[0]));
|
||||
if (array == NULL)
|
||||
{
|
||||
free(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add copy of item to array, and return it. */
|
||||
array[nitems] = copy;
|
||||
array[nitems + 1] = NULL;
|
||||
return array;
|
||||
}
|
||||
|
||||
/* Free a dynamic array of dynamic strings. */
|
||||
void str_array_free(char **array)
|
||||
{
|
||||
if (array == NULL)
|
||||
return;
|
||||
for (size_t i = 0; array[i] != NULL; ++i)
|
||||
free(array[i]);
|
||||
free(array);
|
||||
if (array == NULL)
|
||||
return;
|
||||
for (size_t i = 0; array[i] != NULL; ++i)
|
||||
free(array[i]);
|
||||
free(array);
|
||||
}
|
||||
|
||||
|
||||
/* Split a string into substrings. Return dynamic array of dynamically
|
||||
allocated substrings, or NULL if there was an error. Caller is
|
||||
expected to free the memory, for example with str_array_free. */
|
||||
char **str_split(const char *input, const char *sep)
|
||||
{
|
||||
size_t nitems = 0;
|
||||
char **array = NULL;
|
||||
const char *start = input;
|
||||
const char *next = strstr(start, sep);
|
||||
size_t seplen = strlen(sep);
|
||||
const char *item;
|
||||
size_t itemlen;
|
||||
|
||||
for (;;) {
|
||||
next = strstr(start, sep);
|
||||
if (next == NULL) {
|
||||
/* Add the remaining string (or empty string, if input ends with
|
||||
separator. */
|
||||
char **newstr = str_array_append(array, nitems, start, strlen(start));
|
||||
if (newstr == NULL) {
|
||||
str_array_free(array);
|
||||
return NULL;
|
||||
}
|
||||
array = newstr;
|
||||
++nitems;
|
||||
break;
|
||||
} else if (next == input) {
|
||||
/* Input starts with separator. */
|
||||
item = "";
|
||||
itemlen = 0;
|
||||
} else {
|
||||
item = start;
|
||||
itemlen = next - item;
|
||||
}
|
||||
char **newstr = str_array_append(array, nitems, item, itemlen);
|
||||
if (newstr == NULL) {
|
||||
str_array_free(array);
|
||||
return NULL;
|
||||
}
|
||||
array = newstr;
|
||||
++nitems;
|
||||
start = next + seplen;
|
||||
}
|
||||
|
||||
if (nitems == 0) {
|
||||
/* Input does not contain separator at all. */
|
||||
assert(array == NULL);
|
||||
array = str_array_append(array, nitems, input, strlen(input));
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
size_t nitems = 0;
|
||||
char **array = NULL;
|
||||
const char *start = input;
|
||||
const char *next = strstr(start, sep);
|
||||
size_t seplen = strlen(sep);
|
||||
const char *item;
|
||||
size_t itemlen;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
next = strstr(start, sep);
|
||||
if (next == NULL)
|
||||
{
|
||||
/* Add the remaining string (or empty string, if input ends with
|
||||
separator. */
|
||||
char **newstr = str_array_append(array, nitems, start, strlen(start));
|
||||
if (newstr == NULL)
|
||||
{
|
||||
str_array_free(array);
|
||||
return NULL;
|
||||
}
|
||||
array = newstr;
|
||||
++nitems;
|
||||
break;
|
||||
}
|
||||
else if (next == input)
|
||||
{
|
||||
/* Input starts with separator. */
|
||||
item = "";
|
||||
itemlen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = start;
|
||||
itemlen = next - item;
|
||||
}
|
||||
char **newstr = str_array_append(array, nitems, item, itemlen);
|
||||
if (newstr == NULL)
|
||||
{
|
||||
str_array_free(array);
|
||||
return NULL;
|
||||
}
|
||||
array = newstr;
|
||||
++nitems;
|
||||
start = next + seplen;
|
||||
}
|
||||
|
||||
if (nitems == 0)
|
||||
{
|
||||
/* Input does not contain separator at all. */
|
||||
assert(array == NULL);
|
||||
array = str_array_append(array, nitems, input, strlen(input));
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/* Return length of a NULL-delimited array of strings. */
|
||||
size_t str_array_len(char **array)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for (len = 0; array[len] != NULL; ++len)
|
||||
continue;
|
||||
return len;
|
||||
size_t len;
|
||||
|
||||
for (len = 0; array[len] != NULL; ++len)
|
||||
continue;
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifdef UNIT_TEST_STRING
|
||||
|
||||
#define MAX_OUTPUT 20
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct {
|
||||
const char *input;
|
||||
const char *sep;
|
||||
char *output[MAX_OUTPUT];
|
||||
} tab[] = {
|
||||
/* Input is empty string. Output should be a list with an empty
|
||||
struct
|
||||
{
|
||||
const char *input;
|
||||
const char *sep;
|
||||
char *output[MAX_OUTPUT];
|
||||
} tab[] = {
|
||||
/* Input is empty string. Output should be a list with an empty
|
||||
string. */
|
||||
{
|
||||
"",
|
||||
"and",
|
||||
{
|
||||
"",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
/* Input is exactly the separator. Output should be two empty
|
||||
{
|
||||
"",
|
||||
"and",
|
||||
{
|
||||
"",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
/* Input is exactly the separator. Output should be two empty
|
||||
strings. */
|
||||
{
|
||||
"and",
|
||||
"and",
|
||||
{
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
/* Input is non-empty, but does not have separator. Output should
|
||||
{
|
||||
"and",
|
||||
"and",
|
||||
{
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
/* Input is non-empty, but does not have separator. Output should
|
||||
be the same string. */
|
||||
{
|
||||
"foo",
|
||||
"and",
|
||||
{
|
||||
"foo",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
/* Input is non-empty, and does have separator. */
|
||||
{
|
||||
"foo bar 1 and foo bar 2",
|
||||
" and ",
|
||||
{
|
||||
"foo bar 1",
|
||||
"foo bar 2",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
};
|
||||
const int tab_len = sizeof(tab) / sizeof(tab[0]);
|
||||
bool errors;
|
||||
|
||||
errors = false;
|
||||
|
||||
for (int i = 0; i < tab_len; ++i) {
|
||||
printf("test %d\n", i);
|
||||
|
||||
char **output = str_split(tab[i].input, tab[i].sep);
|
||||
if (output == NULL) {
|
||||
fprintf(stderr, "output is NULL\n");
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
size_t num_output = str_array_len(output);
|
||||
printf("num_output %lu\n", (unsigned long) num_output);
|
||||
|
||||
size_t num_correct = str_array_len(tab[i].output);
|
||||
if (num_output != num_correct) {
|
||||
fprintf(stderr, "wrong number of outputs (%lu, not %lu)\n",
|
||||
(unsigned long) num_output, (unsigned long) num_correct);
|
||||
errors = true;
|
||||
} else {
|
||||
for (size_t j = 0; j < num_output; ++j) {
|
||||
if (strcmp(tab[i].output[j], output[j]) != 0) {
|
||||
fprintf(stderr, "output[%lu] is '%s' not '%s'\n",
|
||||
(unsigned long) j, output[j], tab[i].output[j]);
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str_array_free(output);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (errors)
|
||||
return EXIT_FAILURE;
|
||||
return 0;
|
||||
{
|
||||
"foo",
|
||||
"and",
|
||||
{
|
||||
"foo",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
/* Input is non-empty, and does have separator. */
|
||||
{
|
||||
"foo bar 1 and foo bar 2",
|
||||
" and ",
|
||||
{
|
||||
"foo bar 1",
|
||||
"foo bar 2",
|
||||
NULL,
|
||||
},
|
||||
},
|
||||
};
|
||||
const int tab_len = sizeof(tab) / sizeof(tab[0]);
|
||||
bool errors;
|
||||
|
||||
errors = false;
|
||||
|
||||
for (int i = 0; i < tab_len; ++i)
|
||||
{
|
||||
printf("test %d\n", i);
|
||||
|
||||
char **output = str_split(tab[i].input, tab[i].sep);
|
||||
if (output == NULL)
|
||||
{
|
||||
fprintf(stderr, "output is NULL\n");
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
size_t num_output = str_array_len(output);
|
||||
printf("num_output %lu\n", (unsigned long)num_output);
|
||||
|
||||
size_t num_correct = str_array_len(tab[i].output);
|
||||
if (num_output != num_correct)
|
||||
{
|
||||
fprintf(stderr, "wrong number of outputs (%lu, not %lu)\n",
|
||||
(unsigned long)num_output, (unsigned long)num_correct);
|
||||
errors = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t j = 0; j < num_output; ++j)
|
||||
{
|
||||
if (strcmp(tab[i].output[j], output[j]) != 0)
|
||||
{
|
||||
fprintf(stderr, "output[%lu] is '%s' not '%s'\n",
|
||||
(unsigned long)j, output[j], tab[i].output[j]);
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str_array_free(output);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (errors)
|
||||
return EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif//
|
||||
|
||||
|
||||
#endif //
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ subject to the following restrictions:
|
|||
///The string split C code is by Lars Wirzenius
|
||||
///See http://stackoverflow.com/questions/2531605/how-to-split-a-string-with-a-delimiter-larger-than-one-single-char
|
||||
|
||||
|
||||
#ifndef STRING_SPLIT_H
|
||||
#define STRING_SPLIT_H
|
||||
|
||||
|
|
@ -27,17 +26,16 @@ subject to the following restrictions:
|
|||
|
||||
namespace bullet_utils
|
||||
{
|
||||
void split( btAlignedObjectArray<std::string>&pieces, const std::string& vector_str, const std::string& separator);
|
||||
void split(btAlignedObjectArray<std::string>& pieces, const std::string& vector_str, const std::string& separator);
|
||||
};
|
||||
|
||||
///The string split C code is by Lars Wirzenius
|
||||
///See http://stackoverflow.com/questions/2531605/how-to-split-a-string-with-a-delimiter-larger-than-one-single-char
|
||||
|
||||
|
||||
/* Split a string into substrings. Return dynamic array of dynamically
|
||||
allocated substrings, or NULL if there was an error. Caller is
|
||||
expected to free the memory, for example with str_array_free. */
|
||||
char** str_split(const char* input, const char* sep);
|
||||
char** str_split(const char* input, const char* sep);
|
||||
|
||||
/* Free a dynamic array of dynamic strings. */
|
||||
void str_array_free(char** array);
|
||||
|
|
@ -45,5 +43,4 @@ void str_array_free(char** array);
|
|||
/* Return length of a NULL-delimited array of strings. */
|
||||
size_t str_array_len(char** array);
|
||||
|
||||
#endif //STRING_SPLIT_H
|
||||
|
||||
#endif //STRING_SPLIT_H
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
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 TIXML_USE_STL
|
||||
|
||||
#include "tinystr.h"
|
||||
|
||||
// Error value for find primitive
|
||||
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
|
||||
|
||||
|
||||
// Null rep.
|
||||
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
|
||||
|
||||
|
||||
void TiXmlString::reserve (size_type cap)
|
||||
{
|
||||
if (cap > capacity())
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.init(length(), cap);
|
||||
memcpy(tmp.start(), data(), length());
|
||||
swap(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlString& TiXmlString::assign(const char* str, size_type len)
|
||||
{
|
||||
size_type cap = capacity();
|
||||
if (len > cap || cap > 3*(len + 8))
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.init(len);
|
||||
memcpy(tmp.start(), str, len);
|
||||
swap(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(start(), str, len);
|
||||
set_size(len);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TiXmlString& TiXmlString::append(const char* str, size_type len)
|
||||
{
|
||||
size_type newsize = length() + len;
|
||||
if (newsize > capacity())
|
||||
{
|
||||
reserve (newsize + capacity());
|
||||
}
|
||||
memmove(finish(), str, len);
|
||||
set_size(newsize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.reserve(a.length() + b.length());
|
||||
tmp += a;
|
||||
tmp += b;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const char* b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
|
||||
tmp.reserve(a.length() + b_len);
|
||||
tmp += a;
|
||||
tmp.append(b, b_len);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
TiXmlString operator + (const char* a, const TiXmlString & b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
|
||||
tmp.reserve(a_len + b.length());
|
||||
tmp.append(a, a_len);
|
||||
tmp += b;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
#endif // TIXML_USE_STL
|
||||
|
|
@ -1,305 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
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 TIXML_USE_STL
|
||||
|
||||
#ifndef TIXML_STRING_INCLUDED
|
||||
#define TIXML_STRING_INCLUDED
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The support for explicit isn't that universal, and it isn't really
|
||||
required - it is used to check that the TiXmlString class isn't incorrectly
|
||||
used. Be nice to old compilers and macro it here:
|
||||
*/
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||
// Microsoft visual studio, version 6 and higher.
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||
// GCC version 3 and higher.s
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#else
|
||||
#define TIXML_EXPLICIT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
TiXmlString is an emulation of a subset of the std::string template.
|
||||
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
|
||||
Only the member functions relevant to the TinyXML project have been implemented.
|
||||
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
|
||||
a string and there's no more room, we allocate a buffer twice as big as we need.
|
||||
*/
|
||||
class TiXmlString
|
||||
{
|
||||
public :
|
||||
// The size type used
|
||||
typedef size_t size_type;
|
||||
|
||||
// Error value for find primitive
|
||||
static const size_type npos; // = -1;
|
||||
|
||||
|
||||
// TiXmlString empty constructor
|
||||
TiXmlString () : rep_(&nullrep_)
|
||||
{
|
||||
}
|
||||
|
||||
// TiXmlString copy constructor
|
||||
TiXmlString ( const TiXmlString & copy) : rep_(0)
|
||||
{
|
||||
init(copy.length());
|
||||
memcpy(start(), copy.data(), length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
|
||||
{
|
||||
init( static_cast<size_type>( strlen(copy) ));
|
||||
memcpy(start(), copy, length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
|
||||
{
|
||||
init(len);
|
||||
memcpy(start(), str, len);
|
||||
}
|
||||
|
||||
// TiXmlString destructor
|
||||
~TiXmlString ()
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
TiXmlString& operator = (const char * copy)
|
||||
{
|
||||
return assign( copy, (size_type)strlen(copy));
|
||||
}
|
||||
|
||||
TiXmlString& operator = (const TiXmlString & copy)
|
||||
{
|
||||
return assign(copy.start(), copy.length());
|
||||
}
|
||||
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const char * suffix)
|
||||
{
|
||||
return append(suffix, static_cast<size_type>( strlen(suffix) ));
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (char single)
|
||||
{
|
||||
return append(&single, 1);
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const TiXmlString & suffix)
|
||||
{
|
||||
return append(suffix.data(), suffix.length());
|
||||
}
|
||||
|
||||
|
||||
// Convert a TiXmlString into a null-terminated char *
|
||||
const char * c_str () const { return rep_->str; }
|
||||
|
||||
// Convert a TiXmlString into a char * (need not be null terminated).
|
||||
const char * data () const { return rep_->str; }
|
||||
|
||||
// Return the length of a TiXmlString
|
||||
size_type length () const { return rep_->size; }
|
||||
|
||||
// Alias for length()
|
||||
size_type size () const { return rep_->size; }
|
||||
|
||||
// Checks if a TiXmlString is empty
|
||||
bool empty () const { return rep_->size == 0; }
|
||||
|
||||
// Return capacity of string
|
||||
size_type capacity () const { return rep_->capacity; }
|
||||
|
||||
|
||||
// single char extraction
|
||||
const char& at (size_type index) const
|
||||
{
|
||||
assert( index < length() );
|
||||
return rep_->str[ index ];
|
||||
}
|
||||
|
||||
// [] operator
|
||||
char& operator [] (size_type index) const
|
||||
{
|
||||
assert( index < length() );
|
||||
return rep_->str[ index ];
|
||||
}
|
||||
|
||||
// find a char in a string. Return TiXmlString::npos if not found
|
||||
size_type find (char lookup) const
|
||||
{
|
||||
return find(lookup, 0);
|
||||
}
|
||||
|
||||
// find a char in a string from an offset. Return TiXmlString::npos if not found
|
||||
size_type find (char tofind, size_type offset) const
|
||||
{
|
||||
if (offset >= length()) return npos;
|
||||
|
||||
for (const char* p = c_str() + offset; *p != '\0'; ++p)
|
||||
{
|
||||
if (*p == tofind) return static_cast< size_type >( p - c_str() );
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
void clear ()
|
||||
{
|
||||
//Lee:
|
||||
//The original was just too strange, though correct:
|
||||
// TiXmlString().swap(*this);
|
||||
//Instead use the quit & re-init:
|
||||
quit();
|
||||
init(0,0);
|
||||
}
|
||||
|
||||
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
|
||||
function DOES NOT clear the content of the TiXmlString if any exists.
|
||||
*/
|
||||
void reserve (size_type cap);
|
||||
|
||||
TiXmlString& assign (const char* str, size_type len);
|
||||
|
||||
TiXmlString& append (const char* str, size_type len);
|
||||
|
||||
void swap (TiXmlString& other)
|
||||
{
|
||||
Rep* r = rep_;
|
||||
rep_ = other.rep_;
|
||||
other.rep_ = r;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void init(size_type sz) { init(sz, sz); }
|
||||
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
|
||||
char* start() const { return rep_->str; }
|
||||
char* finish() const { return rep_->str + rep_->size; }
|
||||
|
||||
struct Rep
|
||||
{
|
||||
size_type size, capacity;
|
||||
char str[1];
|
||||
};
|
||||
|
||||
void init(size_type sz, size_type cap)
|
||||
{
|
||||
if (cap)
|
||||
{
|
||||
// Lee: the original form:
|
||||
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
|
||||
// doesn't work in some cases of new being overloaded. Switching
|
||||
// to the normal allocation, although use an 'int' for systems
|
||||
// that are overly picky about structure alignment.
|
||||
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
|
||||
|
||||
rep_->str[ rep_->size = sz ] = '\0';
|
||||
rep_->capacity = cap;
|
||||
}
|
||||
else
|
||||
{
|
||||
rep_ = &nullrep_;
|
||||
}
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
if (rep_ != &nullrep_)
|
||||
{
|
||||
// The rep_ is really an array of ints. (see the allocator, above).
|
||||
// Cast it back before delete, so the compiler won't incorrectly call destructors.
|
||||
delete [] ( reinterpret_cast<int*>( rep_ ) );
|
||||
}
|
||||
}
|
||||
|
||||
Rep * rep_;
|
||||
static Rep nullrep_;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
inline bool operator == (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
return ( a.length() == b.length() ) // optimization on some platforms
|
||||
&& ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
|
||||
}
|
||||
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||
}
|
||||
|
||||
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
|
||||
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
|
||||
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
|
||||
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
|
||||
|
||||
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
|
||||
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
|
||||
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
|
||||
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
|
||||
TiXmlString operator + (const TiXmlString & a, const char* b);
|
||||
TiXmlString operator + (const char* a, const TiXmlString & b);
|
||||
|
||||
|
||||
/*
|
||||
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
|
||||
Only the operators that we need for TinyXML have been developped.
|
||||
*/
|
||||
class TiXmlOutStream : public TiXmlString
|
||||
{
|
||||
public :
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream & operator << (const TiXmlString & in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream & operator << (const char * in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
#endif // TIXML_STRING_INCLUDED
|
||||
#endif // TIXML_USE_STL
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.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 "tinyxml.h"
|
||||
|
||||
// The goal of the seperate error file is to make the first
|
||||
// step towards localization. tinyxml (currently) only supports
|
||||
// english error messages, but the could now be translated.
|
||||
//
|
||||
// It also cleans up the code a bit.
|
||||
//
|
||||
|
||||
const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
|
||||
{
|
||||
"No error",
|
||||
"Error",
|
||||
"Failed to open file",
|
||||
"Error parsing Element.",
|
||||
"Failed to read Element name",
|
||||
"Error reading Element value.",
|
||||
"Error reading Attributes.",
|
||||
"Error: empty tag.",
|
||||
"Error reading end tag.",
|
||||
"Error parsing Unknown.",
|
||||
"Error parsing Comment.",
|
||||
"Error parsing Declaration.",
|
||||
"Error document empty.",
|
||||
"Error null (0) or unexpected EOF found in input stream.",
|
||||
"Error parsing CDATA.",
|
||||
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
IF (BUILD_BLEND_DEMO OR INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
||||
SUBDIRS(BlenderSerialize )
|
||||
#SUBDIRS(BlenderSerialize )
|
||||
ENDIF()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ SET(includes
|
|||
|
||||
|
||||
LINK_LIBRARIES(
|
||||
BulletFileLoader BlenderSerialize LinearMath
|
||||
BulletFileLoader LinearMath
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${includes})
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@
|
|||
#include "bDNA.h"
|
||||
#include "bBlenderFile.h"
|
||||
#include "btBulletFile.h"
|
||||
#include "LinearMath/btSerializer.h"
|
||||
#include "bCommon.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
|
||||
bool isBulletFile = false;
|
||||
bool isBulletFile = true;
|
||||
|
||||
using namespace bParse;
|
||||
typedef std::string bString;
|
||||
|
|
@ -35,13 +36,11 @@ typedef std::map<bString, bString> bStringMap;
|
|||
typedef std::vector<class bVariable> bVariableList;
|
||||
typedef std::vector<bString> bStringList;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static FILE *dump = 0;
|
||||
static bDNA *mDNA =0;
|
||||
static bDNA *mDNA = 0;
|
||||
static bStringMap mStructs;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class bVariable
|
||||
{
|
||||
|
|
@ -49,11 +48,9 @@ public:
|
|||
bVariable();
|
||||
~bVariable();
|
||||
|
||||
|
||||
bString dataType;
|
||||
bString variableName;
|
||||
|
||||
|
||||
bString functionName;
|
||||
bString classCtor;
|
||||
|
||||
|
|
@ -61,7 +58,6 @@ public:
|
|||
bString memberDataType;
|
||||
bString functionArgs;
|
||||
|
||||
|
||||
void initialize(bString dataType, bString variable, bStringMap refDataTable);
|
||||
|
||||
bool isPtr;
|
||||
|
|
@ -102,26 +98,25 @@ bool dataTypeStandard(bString dataType)
|
|||
void writeTemplate(short *structData)
|
||||
{
|
||||
bString type = mDNA->getType(structData[0]);
|
||||
bString className=type;
|
||||
bString prefix = isBulletFile? "bullet_" : "blender_";
|
||||
|
||||
int thisLen = structData[1];
|
||||
structData+=2;
|
||||
bString className = type;
|
||||
bString prefix = isBulletFile ? "bullet_" : "blender_";
|
||||
|
||||
bString fileName = prefix+type;
|
||||
int thisLen = structData[1];
|
||||
structData += 2;
|
||||
|
||||
bString fileName = prefix + type;
|
||||
|
||||
bVariableList dataTypes;
|
||||
bStringMap includeFiles;
|
||||
|
||||
|
||||
for (int dataVal =0; dataVal<thisLen; dataVal++, structData+=2)
|
||||
for (int dataVal = 0; dataVal < thisLen; dataVal++, structData += 2)
|
||||
{
|
||||
bString dataType = mDNA->getType(structData[0]);
|
||||
bString dataName = mDNA->getName(structData[1]);
|
||||
{
|
||||
bString newDataType = "";
|
||||
bString newDataName = "";
|
||||
|
||||
|
||||
bStringMap::iterator addB = mStructs.find(dataType);
|
||||
if (addB != mStructs.end())
|
||||
{
|
||||
|
|
@ -129,7 +124,7 @@ void writeTemplate(short *structData)
|
|||
newDataName = dataName;
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
{
|
||||
if (dataTypeStandard(dataType))
|
||||
{
|
||||
|
|
@ -147,8 +142,7 @@ void writeTemplate(short *structData)
|
|||
if (dataName[0] != '*')
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!newDataType.empty() && !newDataName.empty())
|
||||
|
|
@ -159,28 +153,26 @@ void writeTemplate(short *structData)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bStringMap::iterator include = mStructs.find(dataType);
|
||||
if (include != mStructs.end())
|
||||
{
|
||||
if (dataName[0] != '*')
|
||||
if (dataName[0] != '*')
|
||||
{
|
||||
if (includeFiles.find(dataType)== includeFiles.end())
|
||||
if (includeFiles.find(dataType) == includeFiles.end())
|
||||
{
|
||||
includeFiles[dataType]=prefix+dataType;
|
||||
includeFiles[dataType] = prefix + dataType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fprintf(dump, "###############################################################\n");
|
||||
fprintf(dump, "%s = bStructClass()\n", fileName.c_str());
|
||||
fprintf(dump, "%s.name = '%s'\n", fileName.c_str(), className.c_str());
|
||||
fprintf(dump, "%s.filename = '%s'\n", fileName.c_str(), fileName.c_str());
|
||||
|
||||
bVariableList::iterator vars = dataTypes.begin();
|
||||
while (vars!= dataTypes.end())
|
||||
while (vars != dataTypes.end())
|
||||
{
|
||||
fprintf(dump, "%s.dataTypes.append('%s %s')\n", fileName.c_str(), vars->dataType.c_str(), vars->variableName.c_str());
|
||||
vars++;
|
||||
|
|
@ -195,23 +187,20 @@ void writeTemplate(short *structData)
|
|||
fprintf(dump, "DataTypeList.append(%s)\n", fileName.c_str());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
char data[] = {
|
||||
"\n"
|
||||
"class bStructClass:\n"
|
||||
" def __init__(self):\n"
|
||||
" self.name = \"\";\n"
|
||||
" self.filename = \"\";\n"
|
||||
" self.includes = []\n"
|
||||
" self.dataTypes = []\n"
|
||||
"\n\n"
|
||||
"DataTypeList = []\n"};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
char data[]={
|
||||
"\n"
|
||||
"class bStructClass:\n"
|
||||
" def __init__(self):\n"
|
||||
" self.name = \"\";\n"
|
||||
" self.filename = \"\";\n"
|
||||
" self.includes = []\n"
|
||||
" self.dataTypes = []\n"
|
||||
"\n\n"
|
||||
"DataTypeList = []\n"
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int main(int argc,char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
using namespace bParse;
|
||||
dump = fopen("dump.py", "w");
|
||||
|
|
@ -219,7 +208,7 @@ int main(int argc,char** argv)
|
|||
if (!dump) return 0;
|
||||
fprintf(dump, "%s\n", data);
|
||||
|
||||
|
||||
#if 0
|
||||
char* filename = "../../../../data/r2d2_multibody.bullet";
|
||||
|
||||
if (argc==2)
|
||||
|
|
@ -269,73 +258,68 @@ int main(int argc,char** argv)
|
|||
bBlenderFile f(memBuf,len);
|
||||
swap = (f.getFlags() & FD_ENDIAN_SWAP)!=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#else
|
||||
isBulletFile = true;
|
||||
bool swap = false;
|
||||
char *memBuf = sBulletDNAstr;
|
||||
int len = sBulletDNAlen;
|
||||
#endif
|
||||
|
||||
char *blenderData = memBuf;
|
||||
int sdnaPos=0;
|
||||
int sdnaPos = 0;
|
||||
int mDataStart = 12;
|
||||
|
||||
char *tempBuffer = blenderData;
|
||||
for (int i=0; i<len; i++)
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
// looking for the data's starting position
|
||||
// and the start of SDNA decls
|
||||
|
||||
if (!mDataStart && strncmp(tempBuffer, "REND", 4)==0)
|
||||
if (!mDataStart && strncmp(tempBuffer, "REND", 4) == 0)
|
||||
mDataStart = i;
|
||||
if (!sdnaPos && strncmp(tempBuffer, "SDNA", 4)==0)
|
||||
if (!sdnaPos && strncmp(tempBuffer, "SDNA", 4) == 0)
|
||||
sdnaPos = i;
|
||||
|
||||
if (mDataStart && sdnaPos) break;
|
||||
tempBuffer++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FILE* fpdna = fopen("dnaString.txt","w");
|
||||
FILE *fpdna = fopen("dnaString.txt", "w");
|
||||
char buf[1024];
|
||||
|
||||
for (int i=0;i<len-sdnaPos;i++)
|
||||
for (int i = 0; i < len - sdnaPos; i++)
|
||||
{
|
||||
int dnaval = (memBuf+sdnaPos)[i];
|
||||
int dnaval = (memBuf + sdnaPos)[i];
|
||||
|
||||
if ((i%32)==0)
|
||||
if ((i % 32) == 0)
|
||||
{
|
||||
sprintf(buf,"%d,\n",dnaval);
|
||||
|
||||
} else
|
||||
{
|
||||
sprintf(buf,"%d,",dnaval);
|
||||
sprintf(buf, "%d,\n", dnaval);
|
||||
}
|
||||
|
||||
|
||||
fwrite(buf,strlen(buf),1,fpdna);
|
||||
else
|
||||
{
|
||||
sprintf(buf, "%d,", dnaval);
|
||||
}
|
||||
|
||||
fwrite(buf, strlen(buf), 1, fpdna);
|
||||
}
|
||||
|
||||
fclose(fpdna);
|
||||
|
||||
|
||||
|
||||
mDNA = new bDNA();
|
||||
//mDNA->initMemory();
|
||||
|
||||
mDNA->init(memBuf+sdnaPos, len-sdnaPos, swap);
|
||||
|
||||
|
||||
for (int i=0; i<mDNA->getNumStructs(); i++)
|
||||
mDNA->init(memBuf + sdnaPos, len - sdnaPos, swap);
|
||||
|
||||
for (int i = 0; i < mDNA->getNumStructs(); i++)
|
||||
{
|
||||
short *structData = mDNA->getStruct(i);
|
||||
bString type = mDNA->getType(structData[0]);
|
||||
|
||||
bString className = type;
|
||||
mStructs[type]=className;
|
||||
mStructs[type] = className;
|
||||
}
|
||||
|
||||
|
||||
for (int i=0; i<mDNA->getNumStructs(); i++)
|
||||
for (int i = 0; i < mDNA->getNumStructs(); i++)
|
||||
{
|
||||
short *structData = mDNA->getStruct(i);
|
||||
writeTemplate(structData);
|
||||
|
|
@ -347,23 +331,22 @@ int main(int argc,char** argv)
|
|||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int _getArraySize(char* str)
|
||||
int _getArraySize(char *str)
|
||||
{
|
||||
int a, mul=1;
|
||||
char stri[100], *cp=0;
|
||||
int a, mul = 1;
|
||||
char stri[100], *cp = 0;
|
||||
int len = (int)strlen(str);
|
||||
|
||||
memcpy(stri, str, len+1);
|
||||
for (a=0; a<len; a++)
|
||||
memcpy(stri, str, len + 1);
|
||||
for (a = 0; a < len; a++)
|
||||
{
|
||||
if (str[a]== '[')
|
||||
cp= &(stri[a+1]);
|
||||
else if ( str[a]==']' && cp)
|
||||
if (str[a] == '[')
|
||||
cp = &(stri[a + 1]);
|
||||
else if (str[a] == ']' && cp)
|
||||
{
|
||||
stri[a]= 0;
|
||||
mul*= atoi(cp);
|
||||
stri[a] = 0;
|
||||
mul *= atoi(cp);
|
||||
}
|
||||
}
|
||||
return mul;
|
||||
|
|
@ -371,27 +354,26 @@ int _getArraySize(char* str)
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
bVariable::bVariable()
|
||||
: dataType("invalid"),
|
||||
variableName("invalid"),
|
||||
functionName(""),
|
||||
classCtor(""),
|
||||
memberVariable(""),
|
||||
memberDataType(""),
|
||||
functionArgs(""),
|
||||
isPtr(false),
|
||||
isFunctionPtr(false),
|
||||
isPtrToPtr(false),
|
||||
isArray(false),
|
||||
isCharArray(false),
|
||||
isListBase(false),
|
||||
isPadding(false),
|
||||
isCommentedOut(false),
|
||||
isGeneratedType(false),
|
||||
isbString(false)
|
||||
: dataType("invalid"),
|
||||
variableName("invalid"),
|
||||
functionName(""),
|
||||
classCtor(""),
|
||||
memberVariable(""),
|
||||
memberDataType(""),
|
||||
functionArgs(""),
|
||||
isPtr(false),
|
||||
isFunctionPtr(false),
|
||||
isPtrToPtr(false),
|
||||
isArray(false),
|
||||
isCharArray(false),
|
||||
isListBase(false),
|
||||
isPadding(false),
|
||||
isCommentedOut(false),
|
||||
isGeneratedType(false),
|
||||
isbString(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
bVariable::~bVariable()
|
||||
{
|
||||
|
|
@ -399,7 +381,6 @@ bVariable::~bVariable()
|
|||
variableName.clear();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void bVariable::initialize(bString type, bString variable, bStringMap refDataTable)
|
||||
{
|
||||
|
|
@ -416,7 +397,7 @@ void bVariable::initialize(bString type, bString variable, bStringMap refDataTab
|
|||
if (variableName[1] == '*')
|
||||
isFunctionPtr = true;
|
||||
|
||||
if (variableName[variableName.size()-1] == ']')
|
||||
if (variableName[variableName.size() - 1] == ']')
|
||||
{
|
||||
isArray = true;
|
||||
if (type == "char")
|
||||
|
|
@ -428,14 +409,13 @@ void bVariable::initialize(bString type, bString variable, bStringMap refDataTab
|
|||
|
||||
if (variableName[0] == 'p')
|
||||
{
|
||||
bString sub = variableName.substr(0,3);
|
||||
bString sub = variableName.substr(0, 3);
|
||||
if (sub == "pad")
|
||||
isPadding = true;
|
||||
}
|
||||
if (dataType[0] == '/' && dataType[1] == '/')
|
||||
isCommentedOut = true;
|
||||
|
||||
|
||||
if (refDataTable.find(dataType) != refDataTable.end())
|
||||
isGeneratedType = true;
|
||||
|
||||
|
|
@ -444,13 +424,13 @@ void bVariable::initialize(bString type, bString variable, bStringMap refDataTab
|
|||
// replace valid float arrays
|
||||
if (dataType == "float" && isArray)
|
||||
{
|
||||
int size = _getArraySize((char*)variableName.c_str());
|
||||
if (size==3)
|
||||
int size = _getArraySize((char *)variableName.c_str());
|
||||
if (size == 3)
|
||||
{
|
||||
dataType = "vec3f";
|
||||
variableName = variableName.substr(0, variableName.find_first_of("["));
|
||||
}
|
||||
if (size==4)
|
||||
if (size == 4)
|
||||
{
|
||||
dataType = "vec4f";
|
||||
variableName = variableName.substr(0, variableName.find_first_of("["));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import dump
|
||||
|
||||
|
||||
header = """/* Copyright (C) 2006 Charlie C
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
|
|
@ -27,27 +26,30 @@ dtList = dump.DataTypeList
|
|||
out = "../BlenderSerialize/autogenerated/"
|
||||
spaces = 4
|
||||
|
||||
|
||||
def addSpaces(file, space):
|
||||
for i in range(0, space):
|
||||
file.write(" ")
|
||||
for i in range(0, space):
|
||||
file.write(" ")
|
||||
|
||||
|
||||
def write(file, spaces, string):
|
||||
addSpaces(file, spaces)
|
||||
file.write(string)
|
||||
addSpaces(file, spaces)
|
||||
file.write(string)
|
||||
|
||||
|
||||
###################################################################################
|
||||
blender = open(out+"blender.h", 'w')
|
||||
blender = open(out + "blender.h", 'w')
|
||||
blender.write(header)
|
||||
blender.write("#ifndef __BLENDER_H__\n")
|
||||
blender.write("#define __BLENDER_H__\n")
|
||||
for dt in dtList:
|
||||
blender.write("#include \"%s.h\"\n"%dt.filename)
|
||||
blender.write("#include \"%s.h\"\n" % dt.filename)
|
||||
|
||||
blender.write("#endif//__BLENDER_H__")
|
||||
blender.close()
|
||||
|
||||
###################################################################################
|
||||
blenderC = open(out+"blender_Common.h", 'w')
|
||||
blenderC = open(out + "blender_Common.h", 'w')
|
||||
blenderC.write(header)
|
||||
blenderC.write("#ifndef __BLENDERCOMMON_H__\n")
|
||||
blenderC.write("#define __BLENDERCOMMON_H__\n")
|
||||
|
|
@ -63,49 +65,43 @@ blenderC.write(strUnRes)
|
|||
|
||||
blenderC.write("namespace Blender {\n")
|
||||
for dt in dtList:
|
||||
write(blenderC, 4, "class %s;\n"%dt.name)
|
||||
write(blenderC, 4, "class %s;\n" % dt.name)
|
||||
|
||||
blenderC.write("}\n")
|
||||
blenderC.write("#endif//__BLENDERCOMMON_H__")
|
||||
blenderC.close()
|
||||
|
||||
|
||||
for dt in dtList:
|
||||
fp = open(out+dt.filename+".h", 'w')
|
||||
|
||||
fp.write(header)
|
||||
strUpper = dt.filename.upper()
|
||||
|
||||
fp.write("#ifndef __%s__H__\n"%strUpper)
|
||||
fp.write("#define __%s__H__\n"%strUpper)
|
||||
fp.write("\n\n")
|
||||
|
||||
|
||||
fp.write("// -------------------------------------------------- //\n")
|
||||
fp.write("#include \"blender_Common.h\"\n")
|
||||
fp = open(out + dt.filename + ".h", 'w')
|
||||
|
||||
for i in dt.includes:
|
||||
fp.write("#include \"%s\"\n"%i)
|
||||
fp.write(header)
|
||||
strUpper = dt.filename.upper()
|
||||
|
||||
fp.write("\nnamespace Blender {\n")
|
||||
fp.write("\n\n")
|
||||
fp.write("#ifndef __%s__H__\n" % strUpper)
|
||||
fp.write("#define __%s__H__\n" % strUpper)
|
||||
fp.write("\n\n")
|
||||
|
||||
addSpaces(fp,4)
|
||||
fp.write("// ---------------------------------------------- //\n")
|
||||
fp.write("// -------------------------------------------------- //\n")
|
||||
fp.write("#include \"blender_Common.h\"\n")
|
||||
|
||||
for i in dt.includes:
|
||||
fp.write("#include \"%s\"\n" % i)
|
||||
|
||||
write(fp, 4, "class %s\n"%dt.name)
|
||||
fp.write("\nnamespace Blender {\n")
|
||||
fp.write("\n\n")
|
||||
|
||||
write(fp, 4, "{\n")
|
||||
write(fp, 4, "public:\n")
|
||||
for i in dt.dataTypes:
|
||||
write(fp, 8, i+";\n")
|
||||
addSpaces(fp, 4)
|
||||
fp.write("// ---------------------------------------------- //\n")
|
||||
|
||||
write(fp, 4, "class %s\n" % dt.name)
|
||||
|
||||
write(fp, 4, "};\n")
|
||||
fp.write("}\n")
|
||||
fp.write("\n\n")
|
||||
fp.write("#endif//__%s__H__\n"%strUpper)
|
||||
fp.close()
|
||||
write(fp, 4, "{\n")
|
||||
write(fp, 4, "public:\n")
|
||||
for i in dt.dataTypes:
|
||||
write(fp, 8, i + ";\n")
|
||||
|
||||
|
||||
write(fp, 4, "};\n")
|
||||
fp.write("}\n")
|
||||
fp.write("\n\n")
|
||||
fp.write("#endif//__%s__H__\n" % strUpper)
|
||||
fp.close()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import sys
|
||||
sys.path.append(".")
|
||||
import dump
|
||||
|
||||
|
||||
header = """/* Copyright (C) 2011 Erwin Coumans & Charlie C
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
|
|
@ -27,23 +28,25 @@ dtList = dump.DataTypeList
|
|||
out = "autogenerated/"
|
||||
spaces = 4
|
||||
|
||||
|
||||
def addSpaces(file, space):
|
||||
for i in range(0, space):
|
||||
file.write(" ")
|
||||
for i in range(0, space):
|
||||
file.write(" ")
|
||||
|
||||
|
||||
def write(file, spaces, string):
|
||||
addSpaces(file, spaces)
|
||||
file.write(string)
|
||||
addSpaces(file, spaces)
|
||||
file.write(string)
|
||||
|
||||
|
||||
###################################################################################
|
||||
blender = open(out+"bullet.h", 'w')
|
||||
blender = open(out + "bullet.h", 'w')
|
||||
blender.write(header)
|
||||
blender.write("#ifndef __BULLET_H__\n")
|
||||
blender.write("#define __BULLET_H__\n")
|
||||
#for dt in dtList:
|
||||
# blender.write("struct %s;\n"%dt.filename)
|
||||
|
||||
|
||||
###################################################################################
|
||||
|
||||
blender.write("namespace Bullet {\n")
|
||||
|
|
@ -58,26 +61,25 @@ typedef struct bInvalidHandle {
|
|||
blender.write(strUnRes)
|
||||
|
||||
for dt in dtList:
|
||||
write(blender, 4, "class %s;\n"%dt.name)
|
||||
|
||||
write(blender, 4, "class %s;\n" % dt.name)
|
||||
|
||||
for dt in dtList:
|
||||
|
||||
strUpper = dt.filename.upper()
|
||||
|
||||
blender.write("// -------------------------------------------------- //\n")
|
||||
|
||||
write(blender, 4, "class %s\n"%dt.name)
|
||||
strUpper = dt.filename.upper()
|
||||
|
||||
write(blender, 4, "{\n")
|
||||
write(blender, 4, "public:\n")
|
||||
for i in dt.dataTypes:
|
||||
write(blender, 8, i+";\n")
|
||||
blender.write("// -------------------------------------------------- //\n")
|
||||
|
||||
write(blender, 4, "class %s\n" % dt.name)
|
||||
|
||||
write(blender, 4, "{\n")
|
||||
write(blender, 4, "public:\n")
|
||||
for i in dt.dataTypes:
|
||||
write(blender, 8, i + ";\n")
|
||||
|
||||
write(blender, 4, "};\n")
|
||||
|
||||
blender.write("\n\n")
|
||||
|
||||
write(blender, 4, "};\n")
|
||||
|
||||
blender.write("\n\n")
|
||||
|
||||
blender.write("}\n")
|
||||
blender.write("#endif//__BULLET_H__")
|
||||
blender.close()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
///work-in-progress
|
||||
///work-in-progress
|
||||
///This ReadBulletSample is kept as simple as possible without dependencies to the Bullet SDK.
|
||||
///It can be used to load .bullet data for other physics SDKs
|
||||
///For a more complete example how to load and convert Bullet data using the Bullet SDK check out
|
||||
|
|
@ -22,8 +22,8 @@ enum LocalBroadphaseNativeTypes
|
|||
CONVEX_HULL_SHAPE_PROXYTYPE,
|
||||
CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
|
||||
CUSTOM_POLYHEDRAL_SHAPE_TYPE,
|
||||
//implicit convex shapes
|
||||
IMPLICIT_CONVEX_SHAPES_START_HERE,
|
||||
//implicit convex shapes
|
||||
IMPLICIT_CONVEX_SHAPES_START_HERE,
|
||||
SPHERE_SHAPE_PROXYTYPE,
|
||||
MULTI_SPHERE_SHAPE_PROXYTYPE,
|
||||
CAPSULE_SHAPE_PROXYTYPE,
|
||||
|
|
@ -36,8 +36,8 @@ IMPLICIT_CONVEX_SHAPES_START_HERE,
|
|||
BOX_2D_SHAPE_PROXYTYPE,
|
||||
CONVEX_2D_SHAPE_PROXYTYPE,
|
||||
CUSTOM_CONVEX_SHAPE_TYPE,
|
||||
//concave shapes
|
||||
CONCAVE_SHAPES_START_HERE,
|
||||
//concave shapes
|
||||
CONCAVE_SHAPES_START_HERE,
|
||||
//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
|
||||
TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||
SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||
|
|
@ -45,15 +45,15 @@ CONCAVE_SHAPES_START_HERE,
|
|||
FAST_CONCAVE_MESH_PROXYTYPE,
|
||||
//terrain
|
||||
TERRAIN_SHAPE_PROXYTYPE,
|
||||
///Used for GIMPACT Trimesh integration
|
||||
///Used for GIMPACT Trimesh integration
|
||||
GIMPACT_SHAPE_PROXYTYPE,
|
||||
///Multimaterial mesh
|
||||
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
|
||||
|
||||
///Multimaterial mesh
|
||||
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
|
||||
|
||||
EMPTY_SHAPE_PROXYTYPE,
|
||||
STATIC_PLANE_PROXYTYPE,
|
||||
CUSTOM_CONCAVE_SHAPE_TYPE,
|
||||
CONCAVE_SHAPES_END_HERE,
|
||||
CONCAVE_SHAPES_END_HERE,
|
||||
|
||||
COMPOUND_SHAPE_PROXYTYPE,
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ CONCAVE_SHAPES_END_HERE,
|
|||
INVALID_SHAPE_PROXYTYPE,
|
||||
|
||||
MAX_BROADPHASE_COLLISION_TYPES
|
||||
|
||||
|
||||
};
|
||||
|
||||
btBulletDataExtractor::btBulletDataExtractor()
|
||||
|
|
@ -78,28 +78,25 @@ void btBulletDataExtractor::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionShapes.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_collisionShapes.size(); i++)
|
||||
{
|
||||
btCollisionShapeData* shapeData = (btCollisionShapeData*)bulletFile2->m_collisionShapes[i];
|
||||
if (shapeData->m_name)
|
||||
printf("converting shape %s\n", shapeData->m_name);
|
||||
void* shape = convertCollisionShape(shapeData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void* btBulletDataExtractor::convertCollisionShape( btCollisionShapeData* shapeData )
|
||||
void* btBulletDataExtractor::convertCollisionShape(btCollisionShapeData* shapeData)
|
||||
{
|
||||
void* shape = 0;
|
||||
|
||||
switch (shapeData->m_shapeType)
|
||||
{
|
||||
case STATIC_PLANE_PROXYTYPE:
|
||||
{
|
||||
case STATIC_PLANE_PROXYTYPE:
|
||||
{
|
||||
btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*)shapeData;
|
||||
void* shape = createPlaneShape(planeData->m_planeNormal,planeData->m_planeConstant, planeData->m_localScaling);
|
||||
void* shape = createPlaneShape(planeData->m_planeNormal, planeData->m_planeConstant, planeData->m_localScaling);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -109,21 +106,21 @@ void* btBulletDataExtractor::convertCollisionShape( btCollisionShapeData* shape
|
|||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btConvexInternalShapeData* bsd = (btConvexInternalShapeData*)shapeData;
|
||||
|
||||
switch (shapeData->m_shapeType)
|
||||
{
|
||||
btConvexInternalShapeData* bsd = (btConvexInternalShapeData*)shapeData;
|
||||
|
||||
switch (shapeData->m_shapeType)
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
{
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
{
|
||||
shape = createBoxShape(bsd->m_implicitShapeDimensions, bsd->m_localScaling,bsd->m_collisionMargin);
|
||||
break;
|
||||
}
|
||||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
shape = createSphereShape(bsd->m_implicitShapeDimensions.m_floats[0],bsd->m_localScaling, bsd->m_collisionMargin);
|
||||
break;
|
||||
}
|
||||
shape = createBoxShape(bsd->m_implicitShapeDimensions, bsd->m_localScaling, bsd->m_collisionMargin);
|
||||
break;
|
||||
}
|
||||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
shape = createSphereShape(bsd->m_implicitShapeDimensions.m_floats[0], bsd->m_localScaling, bsd->m_collisionMargin);
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
case CAPSULE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
|
|
@ -221,14 +218,14 @@ void* btBulletDataExtractor::convertCollisionShape( btCollisionShapeData* shape
|
|||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
{
|
||||
printf("error: cannot create shape type (%d)\n",shapeData->m_shapeType);
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("error: cannot create shape type (%d)\n", shapeData->m_shapeType);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
||||
{
|
||||
|
|
@ -257,7 +254,7 @@ void* btBulletDataExtractor::convertCollisionShape( btCollisionShapeData* shape
|
|||
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
gContactAddedCallback = btAdjustInternalEdgeContactsCallback;
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -313,33 +310,30 @@ void* btBulletDataExtractor::convertCollisionShape( btCollisionShapeData* shape
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
printf("unsupported shape type (%d)\n",shapeData->m_shapeType);
|
||||
}
|
||||
{
|
||||
printf("unsupported shape type (%d)\n", shapeData->m_shapeType);
|
||||
}
|
||||
}
|
||||
|
||||
return shape;
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
void* btBulletDataExtractor::createBoxShape( const Bullet::btVector3FloatData& halfDimensions, const Bullet::btVector3FloatData& localScaling, float collisionMargin)
|
||||
void* btBulletDataExtractor::createBoxShape(const Bullet::btVector3FloatData& halfDimensions, const Bullet::btVector3FloatData& localScaling, float collisionMargin)
|
||||
{
|
||||
printf("createBoxShape with halfDimensions %f,%f,%f\n",halfDimensions.m_floats[0], halfDimensions.m_floats[1],halfDimensions.m_floats[2]);
|
||||
printf("createBoxShape with halfDimensions %f,%f,%f\n", halfDimensions.m_floats[0], halfDimensions.m_floats[1], halfDimensions.m_floats[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* btBulletDataExtractor::createSphereShape( float radius, const Bullet::btVector3FloatData& localScaling, float collisionMargin)
|
||||
void* btBulletDataExtractor::createSphereShape(float radius, const Bullet::btVector3FloatData& localScaling, float collisionMargin)
|
||||
{
|
||||
printf("createSphereShape with radius %f\n",radius);
|
||||
printf("createSphereShape with radius %f\n", radius);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void* btBulletDataExtractor::createPlaneShape( const btVector3FloatData& planeNormal, float planeConstant, const Bullet::btVector3FloatData& localScaling)
|
||||
void* btBulletDataExtractor::createPlaneShape(const btVector3FloatData& planeNormal, float planeConstant, const Bullet::btVector3FloatData& localScaling)
|
||||
{
|
||||
printf("createPlaneShape with normal %f,%f,%f and planeConstant\n",planeNormal.m_floats[0], planeNormal.m_floats[1],planeNormal.m_floats[2],planeConstant);
|
||||
printf("createPlaneShape with normal %f,%f,%f and planeConstant\n", planeNormal.m_floats[0], planeNormal.m_floats[1], planeNormal.m_floats[2], planeConstant);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,29 @@
|
|||
#ifndef BULLET_DATA_EXTRACTOR_H
|
||||
#define BULLET_DATA_EXTRACTOR_H
|
||||
|
||||
|
||||
#include "../BulletFileLoader/autogenerated/bullet.h"
|
||||
|
||||
namespace bParse
|
||||
{
|
||||
class btBulletFile;
|
||||
class btBulletFile;
|
||||
};
|
||||
|
||||
class btBulletDataExtractor
|
||||
{
|
||||
public:
|
||||
|
||||
public:
|
||||
btBulletDataExtractor();
|
||||
|
||||
|
||||
virtual ~btBulletDataExtractor();
|
||||
|
||||
|
||||
virtual void convertAllObjects(bParse::btBulletFile* bulletFile);
|
||||
|
||||
virtual void* convertCollisionShape( Bullet::btCollisionShapeData* shapeData );
|
||||
|
||||
virtual void* createPlaneShape( const Bullet::btVector3FloatData& planeNormal, float planeConstant, const Bullet::btVector3FloatData& localScaling);
|
||||
|
||||
virtual void* createBoxShape( const Bullet::btVector3FloatData& halfDimensions, const Bullet::btVector3FloatData& localScaling, float collisionMargin);
|
||||
virtual void* convertCollisionShape(Bullet::btCollisionShapeData* shapeData);
|
||||
|
||||
virtual void* createSphereShape( float radius, const Bullet::btVector3FloatData& localScaling, float collisionMargin);
|
||||
virtual void* createPlaneShape(const Bullet::btVector3FloatData& planeNormal, float planeConstant, const Bullet::btVector3FloatData& localScaling);
|
||||
|
||||
virtual void* createBoxShape(const Bullet::btVector3FloatData& halfDimensions, const Bullet::btVector3FloatData& localScaling, float collisionMargin);
|
||||
|
||||
virtual void* createSphereShape(float radius, const Bullet::btVector3FloatData& localScaling, float collisionMargin);
|
||||
};
|
||||
|
||||
#endif //BULLET_DATA_EXTRACTOR_H
|
||||
|
||||
#endif //BULLET_DATA_EXTRACTOR_H
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2011 Erwin Coumans https://bulletphysics.org
|
||||
|
||||
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.
|
||||
|
|
@ -13,7 +13,6 @@ subject to the following restrictions:
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../BulletFileLoader/btBulletFile.h"
|
||||
#include "BulletDataExtractor.h"
|
||||
|
|
@ -25,39 +24,37 @@ subject to the following restrictions:
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const char* fileName="testFile.bullet";
|
||||
const char* fileName = "testFile.bullet";
|
||||
bool verboseDumpAllTypes = false;
|
||||
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
|
||||
|
||||
bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
|
||||
|
||||
bool ok = (bulletFile2->getFlags() & bParse::FD_OK) != 0;
|
||||
|
||||
if (ok)
|
||||
bulletFile2->parse(verboseDumpAllTypes);
|
||||
else
|
||||
{
|
||||
printf("Error loading file %s.\n",fileName);
|
||||
printf("Error loading file %s.\n", fileName);
|
||||
exit(0);
|
||||
}
|
||||
ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
|
||||
ok = (bulletFile2->getFlags() & bParse::FD_OK) != 0;
|
||||
if (!ok)
|
||||
{
|
||||
printf("Error parsing file %s.\n",fileName);
|
||||
printf("Error parsing file %s.\n", fileName);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
if (verboseDumpAllTypes)
|
||||
{
|
||||
bulletFile2->dumpChunks(bulletFile2->getFileDNA());
|
||||
}
|
||||
|
||||
|
||||
btBulletDataExtractor extractor;
|
||||
|
||||
|
||||
extractor.convertAllObjects(bulletFile2);
|
||||
|
||||
delete bulletFile2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,15 +23,29 @@ SET (INC_FILES
|
|||
SET(SRC makesdna.cpp)
|
||||
ADD_EXECUTABLE(makesdna ${SRC} ${INC_FILES})
|
||||
|
||||
# Output BulletDNA.c
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp
|
||||
COMMAND ${CMAKE_CFG_INTDIR}/makesdna ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/CommonSerialize/
|
||||
DEPENDS makesdna
|
||||
)
|
||||
IF (CMAKE_CL_64)
|
||||
# Output BulletDNA.c
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer64.cpp
|
||||
COMMAND ${CMAKE_CFG_INTDIR}/makesdna ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer64.cpp ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/CommonSerialize/
|
||||
DEPENDS makesdna
|
||||
)
|
||||
SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer64.cpp)
|
||||
|
||||
ELSE()
|
||||
# Output BulletDNA.c
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp
|
||||
COMMAND ${CMAKE_CFG_INTDIR}/makesdna ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/CommonSerialize/
|
||||
DEPENDS makesdna
|
||||
)
|
||||
SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp)
|
||||
|
||||
ENDIF()
|
||||
|
||||
# Build bf_dna library
|
||||
SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp)
|
||||
|
||||
|
||||
ADD_LIBRARY(BulletDNA ${SRC} ${INC_FILES})
|
||||
|
||||
MESSAGE(STATUS "Configuring makesdna")
|
||||
|
|
|
|||
|
|
@ -1,21 +1,33 @@
|
|||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
http://bulletphysics.org
|
||||
|
||||
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 DNA_RIGIDBODY_H
|
||||
#define DNA_RIGIDBODY_H
|
||||
|
||||
|
||||
struct PointerArray
|
||||
struct PointerArray
|
||||
{
|
||||
int m_size;
|
||||
int m_capacity;
|
||||
void *m_data;
|
||||
int m_size;
|
||||
int m_capacity;
|
||||
void *m_data;
|
||||
};
|
||||
|
||||
|
||||
struct btPhysicsSystem
|
||||
{
|
||||
PointerArray m_collisionShapes;
|
||||
PointerArray m_collisionObjects;
|
||||
PointerArray m_constraints;
|
||||
PointerArray m_collisionShapes;
|
||||
PointerArray m_collisionObjects;
|
||||
PointerArray m_constraints;
|
||||
};
|
||||
|
||||
///we need this to compute the pointer sizes
|
||||
|
|
@ -25,5 +37,4 @@ struct ListBase
|
|||
void *last;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue