Block now working with new MinizCompressor. Removing some old compression code.
This commit is contained in:
parent
804a766037
commit
a1cdf78250
@ -98,7 +98,6 @@ SET(CORE_INC_FILES
|
||||
)
|
||||
|
||||
SET(IMPL_SRC_FILES
|
||||
source/Impl/Compression.cpp
|
||||
source/Impl/ErrorHandling.cpp
|
||||
source/Impl/MarchingCubesTables.cpp
|
||||
source/Impl/RandomUnitVectors.cpp
|
||||
@ -113,7 +112,6 @@ SET(IMPL_INC_FILES
|
||||
include/PolyVoxCore/Impl/Block.h
|
||||
include/PolyVoxCore/Impl/Block.inl
|
||||
include/PolyVoxCore/Impl/CompilerCapabilities.h
|
||||
include/PolyVoxCore/Impl/Compression.h
|
||||
include/PolyVoxCore/Impl/Config.h
|
||||
include/PolyVoxCore/Impl/ErrorHandling.h
|
||||
include/PolyVoxCore/Impl/MarchingCubesTables.h
|
||||
|
@ -64,7 +64,7 @@ namespace PolyVox
|
||||
void uncompress(void);
|
||||
|
||||
std::vector< RunlengthEntry<uint16_t> > m_vecCompressedData;
|
||||
uint8_t* m_pCompressedData;
|
||||
void* m_pCompressedData;
|
||||
uint32_t m_uCompressedDataLength;
|
||||
VoxelType* m_tUncompressedData;
|
||||
uint16_t m_uSideLength;
|
||||
|
@ -21,10 +21,10 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Impl/Compression.h"
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
#include "PolyVoxCore/Impl/Utility.h"
|
||||
|
||||
#include "PolyVoxCore/MinizCompressor.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
@ -151,14 +151,29 @@ namespace PolyVox
|
||||
//modified then we don't need to redo the compression.
|
||||
if(m_bIsUncompressedDataModified)
|
||||
{
|
||||
Data src;
|
||||
void* pSrcData = reinterpret_cast<void*>(m_tUncompressedData);
|
||||
void* pDstData = reinterpret_cast<void*>( new uint8_t[1000000] );
|
||||
uint32_t uSrcLength = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType);
|
||||
uint32_t uDstLength = 1000000;
|
||||
|
||||
MinizCompressor compressor;
|
||||
uint32_t uCompressedLength = compressor.compress(pSrcData, uSrcLength, pDstData, uDstLength);
|
||||
|
||||
m_pCompressedData = reinterpret_cast<void*>( new uint8_t[uCompressedLength] );
|
||||
memcpy(m_pCompressedData, pDstData, uCompressedLength);
|
||||
m_uCompressedDataLength = uCompressedLength;
|
||||
|
||||
delete pDstData;
|
||||
|
||||
|
||||
/*Data src;
|
||||
src.ptr = reinterpret_cast<uint8_t*>(m_tUncompressedData);
|
||||
src.length = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType);
|
||||
|
||||
Data compressedResult = polyvox_compress(src);
|
||||
|
||||
m_pCompressedData = compressedResult.ptr;
|
||||
m_uCompressedDataLength = compressedResult.length;
|
||||
m_uCompressedDataLength = compressedResult.length;*/
|
||||
|
||||
/*uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength;
|
||||
m_vecCompressedData.clear();
|
||||
@ -212,7 +227,15 @@ namespace PolyVox
|
||||
|
||||
m_tUncompressedData = new VoxelType[m_uSideLength * m_uSideLength * m_uSideLength];
|
||||
|
||||
Data src;
|
||||
void* pSrcData = reinterpret_cast<void*>(m_pCompressedData);
|
||||
void* pDstData = reinterpret_cast<void*>(m_tUncompressedData);
|
||||
uint32_t uSrcLength = m_uCompressedDataLength;
|
||||
uint32_t uDstLength = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType);
|
||||
|
||||
MinizCompressor compressor;
|
||||
uint32_t uUncompressedLength = compressor.decompress(pSrcData, uSrcLength, pDstData, uDstLength);
|
||||
|
||||
/*Data src;
|
||||
src.ptr = m_pCompressedData;
|
||||
src.length = m_uCompressedDataLength;
|
||||
|
||||
@ -220,9 +243,9 @@ namespace PolyVox
|
||||
dst.ptr = reinterpret_cast<uint8_t*>(m_tUncompressedData);
|
||||
dst.length = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType);
|
||||
|
||||
polyvox_decompress(src, dst);
|
||||
polyvox_decompress(src, dst);*/
|
||||
|
||||
POLYVOX_ASSERT(dst.length == m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType), "Destination length has changed.");
|
||||
POLYVOX_ASSERT(uUncompressedLength == m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType), "Destination length has changed.");
|
||||
|
||||
//m_tUncompressedData = reinterpret_cast<VoxelType*>(uncompressedResult.ptr);
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-2009 David Williams
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __PolyVox_Compression_H__
|
||||
#define __PolyVox_Compression_H__
|
||||
|
||||
#include "PolyVoxCore/Impl/TypeDef.h"
|
||||
|
||||
struct Data
|
||||
{
|
||||
uint8_t* ptr;
|
||||
unsigned long length; // Think what type this should be.
|
||||
};
|
||||
|
||||
Data polyvox_compress(Data src);
|
||||
void polyvox_decompress(Data src, Data dst);
|
||||
|
||||
#endif //__PolyVox_Compression_H__
|
@ -1,63 +0,0 @@
|
||||
#include "PolyVoxCore/Impl/Compression.h"
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
|
||||
// The miniz library is supplied only as a single .c file without a header.
|
||||
// Apparently the only way to use it would then be to #include it directly
|
||||
// which is what the examples do.
|
||||
#include "PolyVoxCore/Impl/miniz.c"
|
||||
|
||||
Data polyvox_compress(Data src)
|
||||
{
|
||||
POLYVOX_ASSERT(src.ptr != 0, "Source data cannot be null");
|
||||
|
||||
unsigned char* buffer;
|
||||
mz_ulong compressedDataLength = compressBound(src.length);
|
||||
buffer = new unsigned char[compressedDataLength];
|
||||
|
||||
int iCompressionResult = compress(buffer, &compressedDataLength, static_cast<const unsigned char*>(src.ptr), src.length);
|
||||
|
||||
// Debug more checking
|
||||
POLYVOX_ASSERT(iCompressionResult == Z_OK, "Data compression failed.");
|
||||
|
||||
// Release mode checking
|
||||
if (iCompressionResult != Z_OK)
|
||||
{
|
||||
delete[] buffer;
|
||||
POLYVOX_THROW(std::runtime_error, "Data compression failed.");
|
||||
}
|
||||
|
||||
Data dst;
|
||||
dst.length = compressedDataLength;
|
||||
dst.ptr = new uint8_t[dst.length];
|
||||
|
||||
memcpy(dst.ptr, buffer, compressedDataLength);
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
void polyvox_decompress(Data src, Data dst)
|
||||
{
|
||||
/*unsigned char* buffer;
|
||||
mz_ulong uncompressedDataLength = 1000000;
|
||||
buffer = new unsigned char[uncompressedDataLength];*/
|
||||
|
||||
int iUncompressionResult = uncompress(dst.ptr, &dst.length, src.ptr, src.length);
|
||||
|
||||
if (iUncompressionResult != Z_OK)
|
||||
{
|
||||
//delete[] buffer;
|
||||
POLYVOX_THROW(std::runtime_error, "Data decompression failed.");
|
||||
}
|
||||
|
||||
/*Data dst;
|
||||
dst.length = uncompressedDataLength;
|
||||
dst.ptr = new uint8_t[dst.length];
|
||||
|
||||
memcpy(dst.ptr, buffer, uncompressedDataLength);
|
||||
|
||||
delete[] buffer;*/
|
||||
|
||||
//return dst;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user