more fixes in serialization/BVH/endianness
This commit is contained in:
@@ -201,7 +201,7 @@ void ConcaveDemo::initPhysics()
|
||||
void* buffer = 0;
|
||||
int numBytes = trimeshShape->getOptimizedBvh()->calculateSerializeBufferSize();
|
||||
buffer = btAlignedAlloc(numBytes,16);
|
||||
bool swapEndian = true;
|
||||
bool swapEndian = false;
|
||||
trimeshShape->getOptimizedBvh()->serialize(buffer,numBytes,swapEndian);
|
||||
FILE* file = fopen("bvh.bin","wb");
|
||||
fwrite(buffer,1,numBytes,file);
|
||||
@@ -225,12 +225,14 @@ void ConcaveDemo::initPhysics()
|
||||
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
void* buffer = btAlignedAlloc(size,16);
|
||||
int buffersize = size+btOptimizedBvh::getAlignmentSerializationPadding();
|
||||
|
||||
void* buffer = btAlignedAlloc(buffersize,16);
|
||||
//memset(buffer,0xcc,size);
|
||||
int read = fread(buffer,1,size,file);
|
||||
fclose(file);
|
||||
bool swapEndian = true;
|
||||
bvh = btOptimizedBvh::deSerializeInPlace(buffer,size,swapEndian);
|
||||
bool swapEndian = false;
|
||||
bvh = btOptimizedBvh::deSerializeInPlace(buffer,buffersize,swapEndian);
|
||||
}
|
||||
|
||||
trimeshShape->setOptimizedBvh(bvh);
|
||||
|
||||
@@ -898,10 +898,14 @@ static const unsigned BVH_ALIGNMENT_BLOCKS = 2;
|
||||
|
||||
|
||||
|
||||
unsigned int btOptimizedBvh::getAlignmentSerializationPadding()
|
||||
{
|
||||
return BVH_ALIGNMENT_BLOCKS * BVH_ALIGNMENT;
|
||||
}
|
||||
|
||||
unsigned btOptimizedBvh::calculateSerializeBufferSize()
|
||||
{
|
||||
unsigned baseSize = sizeof(btOptimizedBvh) + BVH_ALIGNMENT_BLOCKS * BVH_ALIGNMENT;
|
||||
unsigned baseSize = sizeof(btOptimizedBvh) + getAlignmentSerializationPadding();
|
||||
baseSize += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
|
||||
if (m_useQuantization)
|
||||
{
|
||||
|
||||
@@ -344,6 +344,8 @@ public:
|
||||
///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
|
||||
static btOptimizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian);
|
||||
|
||||
static unsigned int getAlignmentSerializationPadding();
|
||||
|
||||
inline bool isQuantized()
|
||||
{
|
||||
return m_useQuantization;
|
||||
|
||||
Reference in New Issue
Block a user