rename to b3 convention, to avoid naming conflicts when using in combination with Bullet 2.x

This commit is contained in:
erwincoumans
2013-04-29 15:19:36 -07:00
parent 7366e262fd
commit 55b69201a9
88 changed files with 1682 additions and 1584 deletions

View File

@@ -19,7 +19,7 @@
// Auto generated from Bullet/Extras/HeaderGenerator/bulletGenerate.py
#ifndef __BULLET_H__
#define __BULLET_H__
namespace Bullet {
namespace Bullet3SerializeBullet2 {
// put an empty struct in the case
typedef struct bInvalidHandle {

View File

@@ -14,8 +14,8 @@ subject to the following restrictions:
*/
#include "b3BulletFile.h"
#include "bDefines.h"
#include "bDNA.h"
#include "b3Defines.h"
#include "b3DNA.h"
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
#include <memory.h>
@@ -26,18 +26,18 @@ subject to the following restrictions:
// 32 && 64 bit versions
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
#ifdef _WIN64
extern char sBulletDNAstr64[];
extern int sBulletDNAlen64;
extern char b3s_bulletDNAstr64[];
extern int b3s_bulletDNAlen64;
#else
extern char sBulletDNAstr[];
extern int sBulletDNAlen;
extern char b3s_bulletDNAstr[];
extern int b3s_bulletDNAlen;
#endif //_WIN64
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
extern char sBulletDNAstr64[];
extern int sBulletDNAlen64;
extern char sBulletDNAstr[];
extern int sBulletDNAlen;
extern char b3s_bulletDNAstr64[];
extern int b3s_bulletDNAlen64;
extern char b3s_bulletDNAstr[];
extern int b3s_bulletDNAlen;
#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
@@ -53,26 +53,26 @@ b3BulletFile::b3BulletFile()
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
#ifdef _WIN64
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16);
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64);
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen64);
#else//_WIN64
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16);
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen);
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen);
#endif//_WIN64
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
if (VOID_IS_8)
{
m_DnaCopy = (char*) b3AlignedAlloc(sBulletDNAlen64,16);
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64);
m_DnaCopy = (char*) b3AlignedAlloc(b3s_bulletDNAlen64,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen64);
}
else
{
m_DnaCopy =(char*) b3AlignedAlloc(sBulletDNAlen,16);
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
mMemoryDNA->init(m_DnaCopy,sBulletDNAlen);
m_DnaCopy =(char*) b3AlignedAlloc(b3s_bulletDNAlen,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
mMemoryDNA->init(m_DnaCopy,b3s_bulletDNAlen);
}
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
}
@@ -141,13 +141,13 @@ void b3BulletFile::parseData()
//dataPtr += ChunkUtils::getOffset(mFlags);
char *dataPtrHead = 0;
while (dataChunk.code != DNA1)
while (dataChunk.code != B3_DNA1)
{
if (!brokenDNA || (dataChunk.code != B3_QUANTIZED_BVH_CODE) )
{
// one behind
if (dataChunk.code == SDNA) break;
if (dataChunk.code == B3_SDNA) break;
//if (dataChunk.code == DNA1) break;
// same as (BHEAD+DATA dependency)
@@ -250,17 +250,17 @@ void b3BulletFile::writeDNA(FILE* fp)
{
bChunkInd dataChunk;
dataChunk.code = DNA1;
dataChunk.code = B3_DNA1;
dataChunk.dna_nr = 0;
dataChunk.nr = 1;
#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
if (VOID_IS_8)
{
#ifdef _WIN64
dataChunk.len = sBulletDNAlen64;
dataChunk.oldPtr = sBulletDNAstr64;
dataChunk.len = b3s_bulletDNAlen64;
dataChunk.oldPtr = b3s_bulletDNAstr64;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp);
fwrite(b3s_bulletDNAstr64, b3s_bulletDNAlen64,1,fp);
#else
b3Assert(0);
#endif
@@ -268,10 +268,10 @@ void b3BulletFile::writeDNA(FILE* fp)
else
{
#ifndef _WIN64
dataChunk.len = sBulletDNAlen;
dataChunk.oldPtr = sBulletDNAstr;
dataChunk.len = b3s_bulletDNAlen;
dataChunk.oldPtr = b3s_bulletDNAstr;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(sBulletDNAstr, sBulletDNAlen,1,fp);
fwrite(b3s_bulletDNAstr, b3s_bulletDNAlen,1,fp);
#else//_WIN64
b3Assert(0);
#endif//_WIN64
@@ -279,17 +279,17 @@ void b3BulletFile::writeDNA(FILE* fp)
#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
if (VOID_IS_8)
{
dataChunk.len = sBulletDNAlen64;
dataChunk.oldPtr = sBulletDNAstr64;
dataChunk.len = b3s_bulletDNAlen64;
dataChunk.oldPtr = b3s_bulletDNAstr64;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp);
fwrite(b3s_bulletDNAstr64, b3s_bulletDNAlen64,1,fp);
}
else
{
dataChunk.len = sBulletDNAlen;
dataChunk.oldPtr = sBulletDNAstr;
dataChunk.len = b3s_bulletDNAlen;
dataChunk.oldPtr = b3s_bulletDNAstr;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(sBulletDNAstr, sBulletDNAlen,1,fp);
fwrite(b3s_bulletDNAstr, b3s_bulletDNAlen,1,fp);
}
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
}
@@ -304,9 +304,9 @@ void b3BulletFile::parse(int verboseMode)
if (m_DnaCopy)
delete m_DnaCopy;
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16);
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
parseInternal(verboseMode,(char*)sBulletDNAstr64,sBulletDNAlen64);
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
parseInternal(verboseMode,(char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64);
#else
b3Assert(0);
#endif
@@ -317,9 +317,9 @@ void b3BulletFile::parse(int verboseMode)
if (m_DnaCopy)
delete m_DnaCopy;
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16);
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen);
#else
b3Assert(0);
#endif
@@ -329,17 +329,17 @@ void b3BulletFile::parse(int verboseMode)
{
if (m_DnaCopy)
delete m_DnaCopy;
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16);
memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64);
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen64);
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen64,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr64,b3s_bulletDNAlen64);
parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen64);
}
else
{
if (m_DnaCopy)
delete m_DnaCopy;
m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16);
memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen);
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
m_DnaCopy = (char*)b3AlignedAlloc(b3s_bulletDNAlen,16);
memcpy(m_DnaCopy,b3s_bulletDNAstr,b3s_bulletDNAlen);
parseInternal(verboseMode,m_DnaCopy,b3s_bulletDNAlen);
}
#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
@@ -359,7 +359,7 @@ int b3BulletFile::write(const char* fileName, bool fixupPointers)
FILE *fp = fopen(fileName, "wb");
if (fp)
{
char header[SIZEOFBLENDERHEADER] ;
char header[B3_SIZEOFBLENDERHEADER] ;
memcpy(header, m_headerString, 7);
int endian= 1;
endian= ((char*)&endian)[0];
@@ -383,7 +383,7 @@ int b3BulletFile::write(const char* fileName, bool fixupPointers)
header[10] = '7';
header[11] = '5';
fwrite(header,SIZEOFBLENDERHEADER,1,fp);
fwrite(header,B3_SIZEOFBLENDERHEADER,1,fp);
writeChunks(fp, fixupPointers);

View File

@@ -17,9 +17,9 @@ subject to the following restrictions:
#define B3_BULLET_FILE_H
#include "bFile.h"
#include "b3File.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "bDefines.h"
#include "b3Defines.h"
#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h"

View File

@@ -13,9 +13,9 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#include "bChunk.h"
#include "bDefines.h"
#include "bFile.h"
#include "b3Chunk.h"
#include "b3Defines.h"
#include "b3File.h"
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
#include <memory.h>
@@ -29,21 +29,21 @@ using namespace bParse;
// ----------------------------------------------------- //
short ChunkUtils::swapShort(short sht)
{
SWITCH_SHORT(sht);
B3_SWITCH_SHORT(sht);
return sht;
}
// ----------------------------------------------------- //
int ChunkUtils::swapInt(int inte)
{
SWITCH_INT(inte);
B3_SWITCH_INT(inte);
return inte;
}
// ----------------------------------------------------- //
long64 ChunkUtils::swapLong64(long64 lng)
b3Long64 ChunkUtils::swapLong64(b3Long64 lng)
{
SWITCH_LONGINT(lng);
B3_SWITCH_LONGINT(lng);
return lng;
}

View File

@@ -17,12 +17,12 @@ subject to the following restrictions:
#define __BCHUNK_H__
#if defined (_WIN32) && ! defined (__MINGW32__)
#define long64 __int64
#define b3Long64 __int64
#elif defined (__MINGW32__)
#include <stdint.h>
#define long64 int64_t
#define b3Long64 int64_t
#else
#define long64 long long
#define b3Long64 long long
#endif
@@ -52,7 +52,7 @@ namespace bParse {
int code, len;
union
{
long64 oldPrev;
b3Long64 oldPrev;
int m_uniqueInts[2];
};
int dna_nr, nr;
@@ -80,7 +80,7 @@ namespace bParse {
// endian utils
static short swapShort(short sht);
static int swapInt(int inte);
static long64 swapLong64(long64 lng);
static b3Long64 swapLong64(b3Long64 lng);
};

View File

@@ -14,8 +14,8 @@ subject to the following restrictions:
*/
#include <assert.h>
#include "bDNA.h"
#include "bChunk.h"
#include "b3DNA.h"
#include "b3Chunk.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

View File

@@ -17,7 +17,7 @@ subject to the following restrictions:
#define __BDNA_H__
#include "bCommon.h"
#include "b3Common.h"
namespace bParse {

View File

@@ -0,0 +1,136 @@
/* 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_DEFINES_H__
#define __B_DEFINES_H__
// MISC defines, see BKE_global.h, BKE_utildefines.h
#define B3_SIZEOFBLENDERHEADER 12
// ------------------------------------------------------------
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
# define B3_MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
#else
# define B3_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 B3_MAKE_ID2(c, d) ( (c)<<8 | (d) )
#else
# define B3_MAKE_ID2(c, d) ( (d)<<8 | (c) )
#endif
// ------------------------------------------------------------
#define B3_ID_SCE B3_MAKE_ID2('S', 'C')
#define B3_ID_LI B3_MAKE_ID2('L', 'I')
#define B3_ID_OB B3_MAKE_ID2('O', 'B')
#define B3_ID_ME B3_MAKE_ID2('M', 'E')
#define B3_ID_CU B3_MAKE_ID2('C', 'U')
#define B3_ID_MB B3_MAKE_ID2('M', 'B')
#define B3_ID_MA B3_MAKE_ID2('M', 'A')
#define B3_ID_TE B3_MAKE_ID2('T', 'E')
#define B3_ID_IM B3_MAKE_ID2('I', 'M')
#define B3_ID_IK B3_MAKE_ID2('I', 'K')
#define B3_ID_WV B3_MAKE_ID2('W', 'V')
#define B3_ID_LT B3_MAKE_ID2('L', 'T')
#define B3_ID_SE B3_MAKE_ID2('S', 'E')
#define B3_ID_LF B3_MAKE_ID2('L', 'F')
#define B3_ID_LA B3_MAKE_ID2('L', 'A')
#define B3_ID_CA B3_MAKE_ID2('C', 'A')
#define B3_ID_IP B3_MAKE_ID2('I', 'P')
#define B3_ID_KE B3_MAKE_ID2('K', 'E')
#define B3_ID_WO B3_MAKE_ID2('W', 'O')
#define B3_ID_SCR B3_MAKE_ID2('S', 'R')
#define B3_ID_VF B3_MAKE_ID2('V', 'F')
#define B3_ID_TXT B3_MAKE_ID2('T', 'X')
#define B3_ID_SO B3_MAKE_ID2('S', 'O')
#define B3_ID_SAMPLE B3_MAKE_ID2('S', 'A')
#define B3_ID_GR B3_MAKE_ID2('G', 'R')
#define B3_ID_ID B3_MAKE_ID2('I', 'D')
#define B3_ID_AR B3_MAKE_ID2('A', 'R')
#define B3_ID_AC B3_MAKE_ID2('A', 'C')
#define B3_ID_SCRIPT B3_MAKE_ID2('P', 'Y')
#define B3_ID_FLUIDSIM B3_MAKE_ID2('F', 'S')
#define B3_ID_NT B3_MAKE_ID2('N', 'T')
#define B3_ID_BR B3_MAKE_ID2('B', 'R')
#define B3_ID_SEQ B3_MAKE_ID2('S', 'Q')
#define B3_ID_CO B3_MAKE_ID2('C', 'O')
#define B3_ID_PO B3_MAKE_ID2('A', 'C')
#define B3_ID_NLA B3_MAKE_ID2('N', 'L')
#define B3_ID_VS B3_MAKE_ID2('V', 'S')
#define B3_ID_VN B3_MAKE_ID2('V', 'N')
// ------------------------------------------------------------
#define B3_FORM B3_MAKE_ID('F','O','R','M')
#define B3_DDG1 B3_MAKE_ID('3','D','G','1')
#define B3_DDG2 B3_MAKE_ID('3','D','G','2')
#define B3_DDG3 B3_MAKE_ID('3','D','G','3')
#define B3_DDG4 B3_MAKE_ID('3','D','G','4')
#define B3_GOUR B3_MAKE_ID('G','O','U','R')
#define B3_BLEN B3_MAKE_ID('B','L','E','N')
#define B3_DER_ B3_MAKE_ID('D','E','R','_')
#define B3_V100 B3_MAKE_ID('V','1','0','0')
#define B3_DATA B3_MAKE_ID('D','A','T','A')
#define B3_GLOB B3_MAKE_ID('G','L','O','B')
#define B3_IMAG B3_MAKE_ID('I','M','A','G')
#define B3_TEST B3_MAKE_ID('T','E','S','T')
#define B3_USER B3_MAKE_ID('U','S','E','R')
// ------------------------------------------------------------
#define B3_DNA1 B3_MAKE_ID('D','N','A','1')
#define B3_REND B3_MAKE_ID('R','E','N','D')
#define B3_ENDB B3_MAKE_ID('E','N','D','B')
#define B3_NAME B3_MAKE_ID('N','A','M','E')
#define B3_SDNA B3_MAKE_ID('S','D','N','A')
#define B3_TYPE B3_MAKE_ID('T','Y','P','E')
#define B3_TLEN B3_MAKE_ID('T','L','E','N')
#define B3_STRC B3_MAKE_ID('S','T','R','C')
// ------------------------------------------------------------
#define B3_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 B3_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 B3_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__

View File

@@ -12,19 +12,19 @@ subject to the following restrictions:
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 "bFile.h"
#include "bCommon.h"
#include "bChunk.h"
#include "bDNA.h"
#include "b3File.h"
#include "b3Common.h"
#include "b3Chunk.h"
#include "b3DNA.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "bDefines.h"
#include "b3Defines.h"
#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h"
#include "Bullet3Common/b3AlignedAllocator.h"
#include "Bullet3Common/b3MinMax.h"
#define SIZEOFBLENDERHEADER 12
#define B3_SIZEOFBLENDERHEADER 12
#define MAX_ARRAY_LENGTH 512
using namespace bParse;
#define MAX_STRLEN 1024
@@ -49,7 +49,6 @@ const char* getCleanName(const char* memName, char* buffer)
}
int numallocs = 0;
// ----------------------------------------------------- //
bFile::bFile(const char *filename, const char headerString[7])
@@ -133,13 +132,13 @@ void bFile::parseHeader()
return;
char *blenderBuf = mFileBuffer;
char header[SIZEOFBLENDERHEADER+1] ;
memcpy(header, blenderBuf, SIZEOFBLENDERHEADER);
header[SIZEOFBLENDERHEADER]='\0';
char header[B3_SIZEOFBLENDERHEADER+1] ;
memcpy(header, blenderBuf, B3_SIZEOFBLENDERHEADER);
header[B3_SIZEOFBLENDERHEADER]='\0';
if (strncmp(header, m_headerString, 6)!=0)
{
memcpy(header, m_headerString, SIZEOFBLENDERHEADER);
memcpy(header, m_headerString, B3_SIZEOFBLENDERHEADER);
return;
}
@@ -344,17 +343,17 @@ void bFile::swapLen(char *dataPtr)
bChunkPtr4*c = (bChunkPtr4*) dataPtr;
if ((c->code & 0xFFFF)==0)
c->code >>=16;
SWITCH_INT(c->len);
SWITCH_INT(c->dna_nr);
SWITCH_INT(c->nr);
B3_SWITCH_INT(c->len);
B3_SWITCH_INT(c->dna_nr);
B3_SWITCH_INT(c->nr);
} else
{
bChunkPtr8* c = (bChunkPtr8*) dataPtr;
if ((c->code & 0xFFFF)==0)
c->code >>=16;
SWITCH_INT(c->len);
SWITCH_INT(c->dna_nr);
SWITCH_INT(c->nr);
B3_SWITCH_INT(c->len);
B3_SWITCH_INT(c->dna_nr);
B3_SWITCH_INT(c->nr);
}
} else
@@ -364,19 +363,19 @@ void bFile::swapLen(char *dataPtr)
bChunkPtr8*c = (bChunkPtr8*) dataPtr;
if ((c->code & 0xFFFF)==0)
c->code >>=16;
SWITCH_INT(c->len);
SWITCH_INT(c->dna_nr);
SWITCH_INT(c->nr);
B3_SWITCH_INT(c->len);
B3_SWITCH_INT(c->dna_nr);
B3_SWITCH_INT(c->nr);
} else
{
bChunkPtr4* c = (bChunkPtr4*) dataPtr;
if ((c->code & 0xFFFF)==0)
c->code >>=16;
SWITCH_INT(c->len);
B3_SWITCH_INT(c->len);
SWITCH_INT(c->dna_nr);
SWITCH_INT(c->nr);
B3_SWITCH_INT(c->dna_nr);
B3_SWITCH_INT(c->nr);
}
}
@@ -596,7 +595,7 @@ void bFile::preSwap()
while (1)
{
// one behind
if (dataChunk.code == SDNA || dataChunk.code==DNA1 || dataChunk.code == TYPE || dataChunk.code == TLEN || dataChunk.code==STRC)
if (dataChunk.code == B3_SDNA || dataChunk.code==B3_DNA1 || dataChunk.code == B3_TYPE || dataChunk.code == B3_TLEN || dataChunk.code==B3_STRC)
{
swapDNA(dataPtr);
@@ -678,7 +677,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
dest[i] = src[i];
if (mFlags &FD_ENDIAN_SWAP)
{
SWITCH_SHORT(dest[i]);
B3_SWITCH_SHORT(dest[i]);
}
}
addDataBlock(dataAlloc);
@@ -709,7 +708,6 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!");
numallocs++;
// numBlocks * length
int allocLen = (curLen);
@@ -851,14 +849,14 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo
// ----------------------------------------------------- //
static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData)
{
#define getEle(value, current, type, cast, size, ptr)\
#define b3GetEle(value, current, type, cast, size, ptr)\
if (strcmp(current, type)==0)\
{\
value = (*(cast*)ptr);\
ptr += size;\
}
#define setEle(value, current, type, cast, size, ptr)\
#define b3SetEle(value, current, type, cast, size, ptr)\
if (strcmp(current, type)==0)\
{\
(*(cast*)ptr) = (cast)value;\
@@ -868,20 +866,20 @@ static void getElement(int arrayLen, const char *cur, const char *old, char *old
for (int i=0; i<arrayLen; i++)
{
getEle(value, old, "char", char, sizeof(char), oldPtr);
setEle(value, cur, "char", char, sizeof(char), curData);
getEle(value, old, "short", short, sizeof(short), oldPtr);
setEle(value, cur, "short", short, sizeof(short), curData);
getEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr);
setEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData);
getEle(value, old, "int", int, sizeof(int), oldPtr);
setEle(value, cur, "int", int, sizeof(int), curData);
getEle(value, old, "long", int, sizeof(int), oldPtr);
setEle(value, cur, "long", int, sizeof(int), curData);
getEle(value, old, "float", float, sizeof(float), oldPtr);
setEle(value, cur, "float", float, sizeof(float), curData);
getEle(value, old, "double", double, sizeof(double), oldPtr);
setEle(value, cur, "double", double, sizeof(double), curData);
b3GetEle(value, old, "char", char, sizeof(char), oldPtr);
b3SetEle(value, cur, "char", char, sizeof(char), curData);
b3GetEle(value, old, "short", short, sizeof(short), oldPtr);
b3SetEle(value, cur, "short", short, sizeof(short), curData);
b3GetEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr);
b3SetEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData);
b3GetEle(value, old, "int", int, sizeof(int), oldPtr);
b3SetEle(value, cur, "int", int, sizeof(int), curData);
b3GetEle(value, old, "long", int, sizeof(int), oldPtr);
b3SetEle(value, cur, "long", int, sizeof(int), curData);
b3GetEle(value, old, "float", float, sizeof(float), oldPtr);
b3SetEle(value, cur, "float", float, sizeof(float), curData);
b3GetEle(value, old, "double", double, sizeof(double), oldPtr);
b3SetEle(value, cur, "double", double, sizeof(double), curData);
}
}
@@ -947,10 +945,10 @@ void bFile::safeSwapPtr(char *dst, const char *src)
{
//deal with pointers the Blender .blend style way, see
//readfile.c in the Blender source tree
long64 longValue = *((long64*)src);
b3Long64 longValue = *((b3Long64*)src);
//endian swap for 64bit pointer otherwise truncation will fail due to trailing zeros
if (mFlags & FD_ENDIAN_SWAP)
SWITCH_LONGINT(longValue);
B3_SWITCH_LONGINT(longValue);
*((int*)dst) = (int)(longValue>>3);
}
@@ -965,7 +963,7 @@ void bFile::safeSwapPtr(char *dst, const char *src)
newPtr->m_uniqueIds[1] = 0;
} else
{
*((long64*)dst)= *((int*)src);
*((b3Long64*)dst)= *((int*)src);
}
}
else
@@ -1654,9 +1652,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
if ((chunk.code & 0xFFFF)==0)
chunk.code >>=16;
SWITCH_INT(chunk.len);
SWITCH_INT(chunk.dna_nr);
SWITCH_INT(chunk.nr);
B3_SWITCH_INT(chunk.len);
B3_SWITCH_INT(chunk.dna_nr);
B3_SWITCH_INT(chunk.nr);
}
@@ -1672,9 +1670,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
if ((c.code & 0xFFFF)==0)
c.code >>=16;
SWITCH_INT(c.len);
SWITCH_INT(c.dna_nr);
SWITCH_INT(c.nr);
B3_SWITCH_INT(c.len);
B3_SWITCH_INT(c.dna_nr);
B3_SWITCH_INT(c.nr);
}
memcpy(dataChunk, &c, sizeof(bChunkInd));
@@ -1697,10 +1695,10 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
chunk.m_uniqueInt = head.m_uniqueInts[0];
} else
{
long64 oldPtr =0;
b3Long64 oldPtr =0;
memcpy(&oldPtr, &head.m_uniqueInts[0], 8);
if (swap)
SWITCH_LONGINT(oldPtr);
B3_SWITCH_LONGINT(oldPtr);
chunk.m_uniqueInt = (int)(oldPtr >> 3);
}
@@ -1713,9 +1711,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
if ((chunk.code & 0xFFFF)==0)
chunk.code >>=16;
SWITCH_INT(chunk.len);
SWITCH_INT(chunk.dna_nr);
SWITCH_INT(chunk.nr);
B3_SWITCH_INT(chunk.len);
B3_SWITCH_INT(chunk.dna_nr);
B3_SWITCH_INT(chunk.nr);
}
memcpy(dataChunk, &chunk, sizeof(bChunkInd));
@@ -1730,9 +1728,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
if ((c.code & 0xFFFF)==0)
c.code >>=16;
SWITCH_INT(c.len);
SWITCH_INT(c.dna_nr);
SWITCH_INT(c.nr);
B3_SWITCH_INT(c.len);
B3_SWITCH_INT(c.dna_nr);
B3_SWITCH_INT(c.nr);
}
memcpy(dataChunk, &c, sizeof(bChunkInd));
}

View File

@@ -16,8 +16,8 @@ subject to the following restrictions:
#ifndef __BFILE_H__
#define __BFILE_H__
#include "bCommon.h"
#include "bChunk.h"
#include "b3Common.h"
#include "b3Chunk.h"
#include <stdio.h>
namespace bParse {

View File

@@ -1,4 +1,4 @@
char sBulletDNAstr[]= {
char b3s_bulletDNAstr[]= {
char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109),
char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95),
char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111),
@@ -451,8 +451,8 @@ char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),cha
char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1),
char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1),
char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),};
int sBulletDNAlen= sizeof(sBulletDNAstr);
char sBulletDNAstr64[]= {
int b3s_bulletDNAlen= sizeof(b3s_bulletDNAstr);
char b3s_bulletDNAstr64[]= {
char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109),
char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95),
char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111),
@@ -905,4 +905,4 @@ char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),cha
char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1),
char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1),
char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),};
int sBulletDNAlen64= sizeof(sBulletDNAstr64);
int b3s_bulletDNAlen64= sizeof(b3s_bulletDNAstr64);

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef B3_SERIALIZER_H
#define B3_SERIALIZER_H
#include "Bullet3Common/b3Scalar.h" // has definitions like SIMD_FORCE_INLINE
#include "Bullet3Common/b3Scalar.h" // has definitions like B3_FORCE_INLINE
#include "Bullet3Common/b3StackAlloc.h"
#include "Bullet3Common/b3HashMap.h"
@@ -27,13 +27,12 @@ subject to the following restrictions:
///only the 32bit versions for now
extern char sBulletDNAstr[];
extern int sBulletDNAlen;
extern char sBulletDNAstr64[];
extern int sBulletDNAlen64;
extern char b3s_bulletDNAstr[];
extern int b3s_bulletDNAlen;
extern char b3s_bulletDNAstr64[];
extern int b3s_bulletDNAlen64;
SIMD_FORCE_INLINE int b3StrLen(const char* str)
B3_FORCE_INLINE int b3StrLen(const char* str)
{
if (!str)
return(0);
@@ -374,14 +373,14 @@ public:
if (VOID_IS_8)
{
#if _WIN64
initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64);
initDNA((const char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64);
#else
b3Assert(0);
#endif
} else
{
#ifndef _WIN64
initDNA((const char*)sBulletDNAstr,sBulletDNAlen);
initDNA((const char*)b3s_bulletDNAstr,b3s_bulletDNAlen);
#else
b3Assert(0);
#endif
@@ -390,10 +389,10 @@ public:
#else //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
if (VOID_IS_8)
{
initDNA((const char*)sBulletDNAstr64,sBulletDNAlen64);
initDNA((const char*)b3s_bulletDNAstr64,b3s_bulletDNAlen64);
} else
{
initDNA((const char*)sBulletDNAstr,sBulletDNAlen);
initDNA((const char*)b3s_bulletDNAstr,b3s_bulletDNAlen);
}
#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES

View File

@@ -1,140 +0,0 @@
/* 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_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) )
#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
#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')
// ------------------------------------------------------------
#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 TEST MAKE_ID('T','E','S','T')
#define USER MAKE_ID('U','S','E','R')
// ------------------------------------------------------------
#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_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_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_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__