16 #ifndef BT_SERIALIZER_H
17 #define BT_SERIALIZER_H
23 #if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
82 virtual void finalizeChunk(
btChunk* chunk,
const char* structType,
int chunkCode,
void* oldPtr)= 0;
107 #define BT_HEADER_LENGTH 12
108 #if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
109 # define BT_MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
111 # define BT_MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
114 #define BT_SOFTBODY_CODE BT_MAKE_ID('S','B','D','Y')
115 #define BT_COLLISIONOBJECT_CODE BT_MAKE_ID('C','O','B','J')
116 #define BT_RIGIDBODY_CODE BT_MAKE_ID('R','B','D','Y')
117 #define BT_CONSTRAINT_CODE BT_MAKE_ID('C','O','N','S')
118 #define BT_BOXSHAPE_CODE BT_MAKE_ID('B','O','X','S')
119 #define BT_QUANTIZED_BVH_CODE BT_MAKE_ID('Q','B','V','H')
120 #define BT_TRIANLGE_INFO_MAP BT_MAKE_ID('T','M','A','P')
121 #define BT_SHAPE_CODE BT_MAKE_ID('S','H','A','P')
122 #define BT_ARRAY_CODE BT_MAKE_ID('A','R','A','Y')
123 #define BT_SBMATERIAL_CODE BT_MAKE_ID('S','B','M','T')
124 #define BT_SBNODE_CODE BT_MAKE_ID('S','B','N','D')
125 #define BT_DYNAMICSWORLD_CODE BT_MAKE_ID('D','W','L','D')
126 #define BT_DNA_CODE BT_MAKE_ID('D','N','A','1')
208 littleEndian= ((
char*)&littleEndian)[0];
212 memcpy(
m_dna,bdnaOrg,dnalen);
217 char *cp = 0;
int dataLen =0;
218 intPtr = (
int*)
m_dna;
228 if (strncmp((
const char*)
m_dna,
"SDNA", 4)==0)
244 for ( i=0; i<dataLen; i++)
260 btAssert(strncmp(cp,
"TYPE", 4)==0); intPtr++;
270 for (i=0; i<dataLen; i++)
288 btAssert(strncmp(cp,
"TLEN", 4)==0); intPtr++;
292 shtPtr = (
short*)intPtr;
293 for (i=0; i<dataLen; i++, shtPtr++)
300 if (dataLen & 1) shtPtr++;
313 intPtr = (
int*)shtPtr;
315 btAssert(strncmp(cp,
"STRC", 4)==0); intPtr++;
323 shtPtr = (
short*)intPtr;
324 for (i=0; i<dataLen; i++)
336 for (
int a=0; a<len; a++, shtPtr+=2)
344 shtPtr+= (2*shtPtr[1])+2;
371 const bool VOID_IS_8 = ((
sizeof(
void*)==8));
373 #ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
390 #else //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
398 #endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
414 #ifdef BT_USE_DOUBLE_PRECISION
415 memcpy(buffer,
"BULLETd", 7);
417 memcpy(buffer,
"BULLETf", 7);
418 #endif //BT_USE_DOUBLE_PRECISION
421 littleEndian= ((
char*)&littleEndian)[0];
423 if (
sizeof(
void*)==8)
471 unsigned char* currentPtr =
m_buffer;
480 currentPtr+=curLength;
547 unsigned char* ptr = 0;
552 m_currentSize += int(size);
569 unsigned char* data = ptr +
sizeof(
btChunk);
573 chunk->m_oldPtr = data;
574 chunk->m_length = int(size)*numElements;
575 chunk->m_number = numElements;
586 if (namePtr && *namePtr)
610 int padding = ((newLen+3)&~3)-newLen;
615 char* destinationName = (
char*)chunk->
m_oldPtr;
616 for (
int i=0;i<len;i++)
618 destinationName[i] = name[i];
620 destinationName[len] = 0;
639 #endif //BT_SERIALIZER_H