| Bullet Collision Detection & Physics Library
    | 
 
 
 
Go to the documentation of this file.
   16 #ifndef BT_SERIALIZER_H 
   17 #define BT_SERIALIZER_H 
   22 #if !defined(__CELLOS_LV2__) && !defined(__MWERKS__) 
   76         virtual void finalizeChunk(
btChunk* chunk, 
const char* structType, 
int chunkCode, 
void* oldPtr) = 0;
 
  101 #define BT_HEADER_LENGTH 12 
  102 #if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined(__PPC__) || defined(__ppc__) || defined(__BIG_ENDIAN__) 
  103 #define BT_MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d)) 
  105 #define BT_MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a)) 
  108 #define BT_MULTIBODY_CODE BT_MAKE_ID('M', 'B', 'D', 'Y') 
  109 #define BT_MB_LINKCOLLIDER_CODE BT_MAKE_ID('M', 'B', 'L', 'C') 
  110 #define BT_SOFTBODY_CODE BT_MAKE_ID('S', 'B', 'D', 'Y') 
  111 #define BT_COLLISIONOBJECT_CODE BT_MAKE_ID('C', 'O', 'B', 'J') 
  112 #define BT_RIGIDBODY_CODE BT_MAKE_ID('R', 'B', 'D', 'Y') 
  113 #define BT_CONSTRAINT_CODE BT_MAKE_ID('C', 'O', 'N', 'S') 
  114 #define BT_BOXSHAPE_CODE BT_MAKE_ID('B', 'O', 'X', 'S') 
  115 #define BT_QUANTIZED_BVH_CODE BT_MAKE_ID('Q', 'B', 'V', 'H') 
  116 #define BT_TRIANLGE_INFO_MAP BT_MAKE_ID('T', 'M', 'A', 'P') 
  117 #define BT_SHAPE_CODE BT_MAKE_ID('S', 'H', 'A', 'P') 
  118 #define BT_ARRAY_CODE BT_MAKE_ID('A', 'R', 'A', 'Y') 
  119 #define BT_SBMATERIAL_CODE BT_MAKE_ID('S', 'B', 'M', 'T') 
  120 #define BT_SBNODE_CODE BT_MAKE_ID('S', 'B', 'N', 'D') 
  121 #define BT_DYNAMICSWORLD_CODE BT_MAKE_ID('D', 'W', 'L', 'D') 
  122 #define BT_CONTACTMANIFOLD_CODE BT_MAKE_ID('C', 'O', 'N', 'T') 
  123 #define BT_DNA_CODE BT_MAKE_ID('D', 'N', 'A', '1') 
  215                 int littleEndian = 1;
 
  216                 littleEndian = ((
char*)&littleEndian)[0];
 
  219                 memcpy(
m_dna, bdnaOrg, dnalen);
 
  226                 intPtr = (
int*)
m_dna;
 
  236                 if (strncmp((
const char*)
m_dna, 
"SDNA", 4) == 0)
 
  253                 for (i = 0; i < dataLen; i++)
 
  268                 btAssert(strncmp(cp, 
"TYPE", 4) == 0);
 
  278                 for (i = 0; i < dataLen; i++)
 
  295                 btAssert(strncmp(cp, 
"TLEN", 4) == 0);
 
  300                 shtPtr = (
short*)intPtr;
 
  301                 for (i = 0; i < dataLen; i++, shtPtr++)
 
  308                 if (dataLen & 1) shtPtr++;
 
  321                 intPtr = (
int*)shtPtr;
 
  323                 btAssert(strncmp(cp, 
"STRC", 4) == 0);
 
  331                 shtPtr = (
short*)intPtr;
 
  332                 for (i = 0; i < dataLen; i++)
 
  344                                 for (
int a = 0; a < len; a++, shtPtr += 2)
 
  352                                 shtPtr += (2 * shtPtr[1]) + 2;
 
  387                 const bool VOID_IS_8 = ((
sizeof(
void*) == 8));
 
  389 #ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES 
  407 #else   //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES 
  416 #endif  //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES 
  429                 const bool VOID_IS_8 = ((
sizeof(
void*) == 8));
 
  439                 const bool VOID_IS_8 = ((
sizeof(
void*) == 8));
 
  455 #ifdef BT_USE_DOUBLE_PRECISION 
  456                 memcpy(buffer, 
"BULLETd", 7);
 
  458                 memcpy(buffer, 
"BULLETf", 7);
 
  459 #endif  //BT_USE_DOUBLE_PRECISION 
  461                 int littleEndian = 1;
 
  462                 littleEndian = ((
char*)&littleEndian)[0];
 
  464                 if (
sizeof(
void*) == 8)
 
  511                         unsigned char* currentPtr = 
m_buffer;
 
  520                                 currentPtr += curLength;
 
  593                 unsigned char* ptr = 0;
 
  613                 unsigned char* data = ptr + 
sizeof(
btChunk);
 
  617                 chunk->m_oldPtr = data;
 
  618                 chunk->m_length = int(
size) * numElements;
 
  619                 chunk->m_number = numElements;
 
  629                 if (namePtr && *namePtr)
 
  650                                 int newLen = len + 1;
 
  651                                 int padding = ((newLen + 3) & ~3) - newLen;
 
  656                                 char* destinationName = (
char*)chunk->
m_oldPtr;
 
  657                                 for (
int i = 0; i < len; i++)
 
  659                                         destinationName[i] = name[i];
 
  661                                 destinationName[len] = 0;
 
  692 #ifdef ENABLE_INMEMORY_SERIALIZER 
  702         btInMemorySerializer(
int totalSize = 0, 
unsigned char* buffer = 0)
 
  709                 m_uid2ChunkPtr.
clear();
 
  714         btChunk* findChunkFromUniquePointer(
void* uniquePointer)
 
  716                 btChunk** chkPtr = m_uid2ChunkPtr[uniquePointer];
 
  727                 m_names2Ptr.
insert(name, ptr);
 
  740                 btChunk* chunk = findChunkFromUniquePointer(oldPtr);
 
  747                         const char* n = (
const char*)oldPtr;
 
  748                         const void** ptr = m_names2Ptr[n];
 
  755                                 void** ptr2 = m_skipPointers[oldPtr];
 
  782                 m_chunkP.insert(oldPtr, oldPtr);  
 
  786                 m_uid2ChunkPtr.
insert(uid, chunk);
 
  792 #ifdef BT_USE_DOUBLE_PRECISION 
  801 #ifdef BT_USE_DOUBLE_PRECISION 
  803 #else   //BT_USE_DOUBLE_PRECISION 
  805 #endif  //BT_USE_DOUBLE_PRECISION 
  810 #ifdef BT_USE_DOUBLE_PRECISION 
  814 #endif  //BT_USE_DOUBLE_PRECISION 
  819 #ifdef BT_USE_DOUBLE_PRECISION 
  828 #ifdef BT_USE_DOUBLE_PRECISION 
  859                 return m_uid2ChunkPtr.
size();
 
  864                 return *m_uid2ChunkPtr.
getAtIndex(chunkIndex);
 
  867 #endif  //ENABLE_INMEMORY_SERIALIZER 
  869 #endif  //BT_SERIALIZER_H 
  
btAlignedObjectArray< struct btDynamicsWorldFloatData * > m_dynamicWorldInfoDataFloat
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btAlignedObjectArray< struct btQuantizedBvhDoubleData * > m_bvhsDouble
virtual void * getUniquePointer(void *oldPtr)
btHashMap< btHashInt, int > mStructReverse
void writeHeader(unsigned char *buffer) const
#define btAlignedFree(ptr)
The btDefaultSerializer is the main Bullet serialization class.
virtual const char * findNameForPointer(const void *ptr) const
#define BT_TRIANLGE_INFO_MAP
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btAlignedObjectArray< struct btDynamicsWorldDoubleData * > m_dynamicWorldInfoDataDouble
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
virtual void serializeName(const char *name)
btAlignedObjectArray< struct btRigidBodyDoubleData * > m_rigidBodyDataDouble
btAlignedObjectArray< btChunk * > m_chunkPtrs
int getReverseType(const char *type) const
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
const Value * getAtIndex(int index) const
virtual void * getUniquePointer(void *oldPtr)=0
btAlignedObjectArray< struct btQuantizedBvhFloatData * > m_bvhsFloat
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
#define BT_DYNAMICSWORLD_CODE
btAlignedObjectArray< short * > mStructs
#define btAlignedAlloc(size, alignment)
virtual const char * findNameForPointer(const void *ptr) const =0
T * btAlignPointer(T *unalignedPtr, size_t alignment)
align a pointer to the provided alignment, upwards
btHashMap< btHashPtr, const char * > m_nameMap
very basic hashable string implementation, compatible with btHashMap
#define BT_COLLISIONOBJECT_CODE
btAlignedObjectArray< struct btCollisionShapeData * > m_colShapeData
btHashMap< btHashPtr, void * > m_skipPointers
btAlignedObjectArray< struct btTypedConstraintData * > m_constraintData
btAlignedObjectArray< struct btTypedConstraintFloatData * > m_constraintDataFloat
btAlignedObjectArray< struct btSoftBodyFloatData * > m_softBodyFloatData
virtual void setSerializationFlags(int flags)
virtual int getSerializationFlags() const
virtual void finishSerialization()
btAlignedObjectArray< struct btSoftBodyDoubleData * > m_softBodyDoubleData
virtual void startSerialization()
#define BT_CONSTRAINT_CODE
virtual const unsigned char * getBufferPointer() const =0
btAlignedObjectArray< struct btCollisionObjectFloatData * > m_collisionObjectDataFloat
btBulletSerializedArrays()
btAlignedObjectArray< struct btCollisionObjectDoubleData * > m_collisionObjectDataDouble
#define BT_QUANTIZED_BVH_CODE
virtual unsigned char * internalAlloc(size_t size)
static int getMemoryDnaSizeInBytes()
virtual const btChunk * getChunk(int chunkIndex) const =0
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
unsigned btSwapEndian(unsigned val)
int btStrLen(const char *str)
virtual void serializeName(const char *ptr)=0
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)
virtual void finishSerialization()=0
virtual void registerNameForPointer(const void *ptr, const char *name)
virtual void startSerialization()=0
btHashMap< btHashPtr, void * > m_chunkP
btAlignedObjectArray< char * > mTypes
virtual void * findPointer(void *oldPtr)
virtual btChunk * allocate(size_t size, int numElements)
virtual void registerNameForPointer(const void *ptr, const char *name)=0
const Value * find(const Key &key) const
#define SIMD_FORCE_INLINE
virtual int getCurrentBufferSize() const =0
#define BT_SBMATERIAL_CODE
void insert(const Key &key, const Value &value)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
void initDNA(const char *bdnaOrg, int dnalen)
virtual int getNumChunks() const =0
virtual void * findPointer(void *oldPtr)=0
virtual int getSerializationFlags() const =0
btAlignedObjectArray< struct btRigidBodyFloatData * > m_rigidBodyDataFloat
btHashMap< btHashPtr, btPointerUid > m_uniquePointers
virtual int getCurrentBufferSize() const
const btChunk * getChunk(int chunkIndex) const
#define BT_RIGIDBODY_CODE
void push_back(const T &_Val)
btAlignedObjectArray< short > mTlens
btDefaultSerializer(int totalSize=0, unsigned char *buffer=0)
virtual void setSerializationFlags(int flags)=0
btAlignedObjectArray< struct btTypedConstraintDoubleData * > m_constraintDataDouble
btHashMap< btHashString, int > mTypeLookup
virtual const unsigned char * getBufferPointer() const
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static const char * getMemoryDna()
virtual btChunk * allocate(size_t size, int numElements)=0
const T & at(int n) const
int size() const
return the number of elements in the array
virtual ~btDefaultSerializer()