More work on block compression with miniz.
This commit is contained in:
parent
7bb7be0dec
commit
68ee094cec
@ -210,13 +210,21 @@ namespace PolyVox
|
|||||||
pUncompressedData += m_vecCompressedData[ct].length;
|
pUncompressedData += m_vecCompressedData[ct].length;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
m_tUncompressedData = new VoxelType[m_uSideLength * m_uSideLength * m_uSideLength];
|
||||||
|
|
||||||
Data src;
|
Data src;
|
||||||
src.ptr = m_pCompressedData;
|
src.ptr = m_pCompressedData;
|
||||||
src.length = m_uCompressedDataLength;
|
src.length = m_uCompressedDataLength;
|
||||||
|
|
||||||
Data uncompressedResult = polyvox_decompress(src);
|
Data dst;
|
||||||
|
dst.ptr = reinterpret_cast<uint8_t*>(m_tUncompressedData);
|
||||||
|
dst.length = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType);
|
||||||
|
|
||||||
m_tUncompressedData = reinterpret_cast<VoxelType*>(uncompressedResult.ptr);
|
polyvox_decompress(src, dst);
|
||||||
|
|
||||||
|
POLYVOX_ASSERT(dst.length == m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType), "Destination length has changed.");
|
||||||
|
|
||||||
|
//m_tUncompressedData = reinterpret_cast<VoxelType*>(uncompressedResult.ptr);
|
||||||
|
|
||||||
m_bIsCompressed = false;
|
m_bIsCompressed = false;
|
||||||
m_bIsUncompressedDataModified = false;
|
m_bIsUncompressedDataModified = false;
|
||||||
|
@ -33,6 +33,6 @@ struct Data
|
|||||||
};
|
};
|
||||||
|
|
||||||
Data polyvox_compress(Data src);
|
Data polyvox_compress(Data src);
|
||||||
Data polyvox_decompress(Data src);
|
void polyvox_decompress(Data src, Data dst);
|
||||||
|
|
||||||
#endif //__PolyVox_Compression_H__
|
#endif //__PolyVox_Compression_H__
|
@ -37,27 +37,27 @@ Data polyvox_compress(Data src)
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data polyvox_decompress(Data src)
|
void polyvox_decompress(Data src, Data dst)
|
||||||
{
|
{
|
||||||
unsigned char* buffer;
|
/*unsigned char* buffer;
|
||||||
mz_ulong uncompressedDataLength = 1000000;
|
mz_ulong uncompressedDataLength = 1000000;
|
||||||
buffer = new unsigned char[uncompressedDataLength];
|
buffer = new unsigned char[uncompressedDataLength];*/
|
||||||
|
|
||||||
int iUncompressionResult = uncompress(buffer, &uncompressedDataLength, src.ptr, src.length);
|
int iUncompressionResult = uncompress(dst.ptr, &dst.length, src.ptr, src.length);
|
||||||
|
|
||||||
if (iUncompressionResult != Z_OK)
|
if (iUncompressionResult != Z_OK)
|
||||||
{
|
{
|
||||||
delete[] buffer;
|
//delete[] buffer;
|
||||||
POLYVOX_THROW(std::runtime_error, "Data decompression failed.");
|
POLYVOX_THROW(std::runtime_error, "Data decompression failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Data dst;
|
/*Data dst;
|
||||||
dst.length = uncompressedDataLength;
|
dst.length = uncompressedDataLength;
|
||||||
dst.ptr = new uint8_t[dst.length];
|
dst.ptr = new uint8_t[dst.length];
|
||||||
|
|
||||||
memcpy(dst.ptr, buffer, uncompressedDataLength);
|
memcpy(dst.ptr, buffer, uncompressedDataLength);
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;*/
|
||||||
|
|
||||||
return dst;
|
//return dst;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user