Improve the loading of serialized Bullet files, so that

after 'loadFileFromMemory' you can save the existing memory back to disk converted to native architecture endianness.
Fixed a bug that prevented big endian machines to load cloth data (due to wrong endian swap of pointer array)
Also improved the 'preswap' so that you can swap endianness on big endian machines (to little endian)
This commit is contained in:
erwin.coumans
2012-11-10 00:51:51 +00:00
parent f35621eb01
commit c4db79791c
5 changed files with 90 additions and 18 deletions

View File

@@ -133,6 +133,11 @@ void btBulletFile::parseData()
//dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags);
int seek = getNextBlock(&dataChunk, dataPtr, mFlags);
if (mFlags &FD_ENDIAN_SWAP)
swapLen(dataPtr);
//dataPtr += ChunkUtils::getOffset(mFlags);
char *dataPtrHead = 0;
@@ -219,10 +224,13 @@ void btBulletFile::parseData()
printf("skipping BT_QUANTIZED_BVH_CODE due to broken DNA\n");
}
// next please!
dataPtr += seek;
seek = getNextBlock(&dataChunk, dataPtr, mFlags);
if (mFlags &FD_ENDIAN_SWAP)
swapLen(dataPtr);
if (seek < 0)
break;
}
@@ -334,6 +342,15 @@ void btBulletFile::parse(int verboseMode)
parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen);
}
#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES
//the parsing will convert to cpu endian
mFlags &=~FD_ENDIAN_SWAP;
int littleEndian= 1;
littleEndian= ((char*)&littleEndian)[0];
mFileBuffer[8] = littleEndian?'v':'V';
}
// experimental