add the 'extras' and Bullet 2 tests, to make it easier to create a new intermediate release

This commit is contained in:
erwin coumans
2014-05-07 08:54:08 -07:00
parent e0784b2da6
commit 2cf7806c87
172 changed files with 42937 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BlenderSerialize
)
ADD_LIBRARY(BlenderSerialize dna249.cpp dna249-64bit.cpp bBlenderFile.cpp bBlenderFile.h bMain.cpp bMain.h )

View File

@@ -0,0 +1,225 @@
/*
bParse
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "bBlenderFile.h"
#include "bMain.h"
#include "bDefines.h"
#include "bDNA.h"
#include <stdio.h>
#include <string.h>
// 32 && 64 bit versions
extern unsigned char DNAstr[];
extern int DNAlen;
extern unsigned char DNAstr64[];
extern int DNAlen64;
using namespace bParse;
bBlenderFile::bBlenderFile(const char* fileName)
:bFile(fileName, "BLENDER")
{
mMain= new bMain(this, fileName, mVersion);
}
bBlenderFile::bBlenderFile(char *memoryBuffer, int len)
:bFile(memoryBuffer,len, "BLENDER"),
mMain(0)
{
mMain= new bMain(this, "memoryBuf", mVersion);
}
bBlenderFile::~bBlenderFile()
{
delete mMain;
}
bMain* bBlenderFile::getMain()
{
return mMain;
}
// ----------------------------------------------------- //
void bBlenderFile::parseData()
{
// 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;
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);
char *dataPtrHead = 0;
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);
char *id = readStruct(dataPtrHead, dataChunk);
// lookup maps
if (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);
}
if (dataChunk.code == GLOB)
{
m_glob = (bStructHandle*) id;
}
// next please!
dataPtr += seek;
seek = getNextBlock(&dataChunk, dataPtr, mFlags);
if (seek < 0)
break;
}
}
void bBlenderFile::addDataBlock(char* dataBlock)
{
mMain->addDatablock(dataBlock);
}
// 32 && 64 bit versions
extern unsigned char DNAstr[];
extern int DNAlen;
//unsigned char DNAstr[]={0};
//int DNAlen=0;
extern unsigned char DNAstr64[];
extern int DNAlen64;
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);
}
else
{
dataChunk.len = DNAlen;
dataChunk.oldPtr = DNAstr;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(DNAstr, DNAlen,1,fp);
}
}
void bBlenderFile::parse(int verboseMode)
{
if (VOID_IS_8)
{
parseInternal(verboseMode,(char*)DNAstr64,DNAlen64);
}
else
{
parseInternal(verboseMode,(char*)DNAstr,DNAlen);
}
}
// experimental
int bBlenderFile::write(const char* fileName, bool fixupPointers)
{
FILE *fp = fopen(fileName, "wb");
if (fp)
{
char header[SIZEOFBLENDERHEADER] ;
memcpy(header, m_headerString, 7);
int endian= 1;
endian= ((char*)&endian)[0];
if (endian)
{
header[7] = '_';
} else
{
header[7] = '-';
}
if (VOID_IS_8)
{
header[8]='V';
} else
{
header[8]='v';
}
header[9] = '2';
header[10] = '4';
header[11] = '9';
fwrite(header,SIZEOFBLENDERHEADER,1,fp);
writeChunks(fp, fixupPointers);
writeDNA(fp);
fclose(fp);
} else
{
printf("Error: cannot open file %s for writing\n",fileName);
return 0;
}
return 1;
}

View File

@@ -0,0 +1,63 @@
/*
bParse
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B_BLENDER_FILE_H
#define B_BLENDER_FILE_H
#include "bFile.h"
namespace bParse {
// ----------------------------------------------------- //
class bBlenderFile : public bFile
{
protected:
bMain* mMain;
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;
}
// experimental
virtual int write(const char* fileName, bool fixupPointers = false);
virtual void parse(int verboseMode);
virtual void parseData();
virtual void writeDNA(FILE* fp);
};
};
#endif //B_BLENDER_FILE_H

View File

@@ -0,0 +1,392 @@
/*
bParse
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "bMain.h"
#include "bBlenderFile.h"
#include "bDefines.h"
#include "bChunk.h"
#include "bDNA.h"
using namespace bParse;
// ----------------------------------------------------- //
bMain::bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion)
: 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_SCRIPT, bListBasePtr());
}
// ----------------------------------------------------- //
bMain::~bMain()
{
// allocated data blocks!
int sz = mPool.size();
for (int i=0;i<sz;i++)
{
delete [] mPool[i];
}
}
// ----------------------------------------------------- //
int bMain::getVersion()
{
return mVersion;
}
// ----------------------------------------------------- //
const char *bMain::getName()
{
return mName;
}
// ----------------------------------------------------- //
void bMain::addDatablock(void *allocated)
{
assert(allocated);
mPool.push_back((bStructHandle*)allocated);
}
// ------------------------------------------------------------//
void bMain::linkList(void *listBasePtr)
{
struct ListBase // local Blender::ListBase
{
void *first;
void *last;
};
struct Link // local Blender::Link
{
void *next;
void *prev;
};
ListBase *base = (ListBase*)listBasePtr;
if (!base || !base->first)
return;
base->first = mFP->findLibPointer(base->first);
if (!base->first)
{
base->last = 0;
return;
}
void *prev = 0;
Link *l = (Link*)base->first;
while (l)
{
l->next = mFP->findLibPointer(l->next);
l->prev = l->next;
prev = l->next;
l = (Link*)l->next;
}
}
// ------------------------------------------------------------//
bListBasePtr* bMain::getListBasePtr(int listBaseCode)
{
bListBasePtr *ptr = _findCode(listBaseCode);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::_findCode(int code)
{
bListBasePtr* lbPtr = mData.find(code);
return lbPtr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getScene()
{
bListBasePtr *ptr = _findCode(ID_SCE);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getLibrary()
{
bListBasePtr *ptr = _findCode(ID_LI);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getObject()
{
bListBasePtr *ptr = _findCode(ID_OB);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getMesh()
{
bListBasePtr *ptr = _findCode(ID_ME);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getCurve()
{
bListBasePtr *ptr = _findCode(ID_CU);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getMball()
{
bListBasePtr *ptr = _findCode(ID_MB);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getMat()
{
bListBasePtr *ptr = _findCode(ID_MA);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getTex()
{
bListBasePtr *ptr = _findCode(ID_TE);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getImage()
{
bListBasePtr *ptr = _findCode(ID_IM);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getWave()
{
bListBasePtr *ptr = _findCode(ID_WV);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getLatt()
{
bListBasePtr *ptr = _findCode(ID_LT);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getLamp()
{
bListBasePtr *ptr = _findCode(ID_LA);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getCamera()
{
bListBasePtr *ptr = _findCode(ID_CA);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getIpo()
{
bListBasePtr *ptr = _findCode(ID_IP);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getKey()
{
bListBasePtr *ptr = _findCode(ID_KE);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getWorld()
{
bListBasePtr *ptr = _findCode(ID_WO);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getScreen()
{
bListBasePtr *ptr = _findCode(ID_SCR);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getScript()
{
bListBasePtr *ptr = _findCode(ID_SCRIPT);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getVfont()
{
bListBasePtr *ptr = _findCode(ID_VF);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getText()
{
bListBasePtr *ptr = _findCode(ID_TXT);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getSound()
{
bListBasePtr *ptr = _findCode(ID_SO);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getGroup()
{
bListBasePtr *ptr = _findCode(ID_GR);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getArmature()
{
bListBasePtr *ptr = _findCode(ID_AR);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getAction()
{
bListBasePtr *ptr = _findCode(ID_AC);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getNodetree()
{
bListBasePtr *ptr = _findCode(ID_NT);
if (!ptr)
return 0;
return ptr;
}
// ------------------------------------------------------------//
bListBasePtr *bMain::getBrush()
{
bListBasePtr *ptr = _findCode(ID_BR);
if (!ptr)
return 0;
return ptr;
}
//eof

View File

@@ -0,0 +1,110 @@
/*
bParse
Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef __BMAIN_H__
#define __BMAIN_H__
#include "bCommon.h"
#include "bChunk.h"
#include "LinearMath/btHashMap.h"
namespace bParse
{
class bDNA;
class bBlenderFile;
};
namespace bParse {
// ----------------------------------------------------- //
typedef btHashMap<btHashInt,bListBasePtr> bMainDataMap;
// ----------------------------------------------------- //
class bMain
{
//private:
public:
bBlenderFile* mFP;
bListBasePtr mPool;
int mVersion;
const char* mName;
bMainDataMap mData;
bListBasePtr *_findCode(int code);
public:
bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion);
~bMain();
int getVersion();
const char *getName();
bListBasePtr *getListBasePtr(int listBaseCode);
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();
// tracking allocated memory
void addDatablock(void *allocated);
// --
void linkList(void *listBasePtr);
};
}
#endif//__BMAIN_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff