Added functions for accessing compressed data in block.
This commit is contained in:
parent
785ac611b9
commit
e80fa3de7d
@ -51,10 +51,13 @@ namespace PolyVox
|
||||
public:
|
||||
Block(uint16_t uSideLength = 0);
|
||||
|
||||
const uint8_t* getCompressedData(void) const;
|
||||
const uint32_t getCompressedDataLength(void) const;
|
||||
uint16_t getSideLength(void) const;
|
||||
VoxelType getVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const;
|
||||
VoxelType getVoxel(const Vector3DUint16& v3dPos) const;
|
||||
|
||||
void setCompressedData(const uint8_t* const data, uint32_t dataLength);
|
||||
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
|
||||
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
||||
|
||||
|
@ -51,6 +51,24 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
const uint8_t* Block<VoxelType>::getCompressedData(void) const
|
||||
{
|
||||
POLYVOX_ASSERT(m_bIsCompressed, "You cannot call getCompressedData() when the block is not compressed");
|
||||
POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL");
|
||||
|
||||
return m_pCompressedData;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
const uint32_t Block<VoxelType>::getCompressedDataLength(void) const
|
||||
{
|
||||
POLYVOX_ASSERT(m_bIsCompressed, "You cannot call getCompressedData() when the block is not compressed");
|
||||
POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL");
|
||||
|
||||
return m_uCompressedDataLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
uint16_t Block<VoxelType>::getSideLength(void) const
|
||||
{
|
||||
@ -64,6 +82,7 @@ namespace PolyVox
|
||||
POLYVOX_ASSERT(uXPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uYPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uZPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(!m_bIsCompressed, "You cannot call getVoxel() when a block is compressed");
|
||||
POLYVOX_ASSERT(m_tUncompressedData, "No uncompressed data - block must be decompressed before accessing voxels.");
|
||||
|
||||
return m_tUncompressedData
|
||||
@ -80,6 +99,20 @@ namespace PolyVox
|
||||
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::setCompressedData(const uint8_t* const data, uint32_t dataLength)
|
||||
{
|
||||
POLYVOX_ASSERT(m_bIsCompressed, "You cannot call setCompressedData() when the block is not compressed");
|
||||
POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL");
|
||||
POLYVOX_ASSERT(m_pCompressedData != data, "Attempting to copy data onto itself");
|
||||
|
||||
delete[] m_pCompressedData;
|
||||
|
||||
m_uCompressedDataLength = dataLength;
|
||||
m_pCompressedData = new uint8_t[dataLength];
|
||||
memcpy(m_pCompressedData, data, dataLength);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue)
|
||||
{
|
||||
@ -87,6 +120,7 @@ namespace PolyVox
|
||||
POLYVOX_ASSERT(uXPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uYPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uZPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(!m_bIsCompressed, "You cannot call setVoxelAt() when a block is compressed");
|
||||
POLYVOX_ASSERT(m_tUncompressedData, "No uncompressed data - block must be decompressed before accessing voxels.");
|
||||
|
||||
m_tUncompressedData
|
||||
|
Loading…
x
Reference in New Issue
Block a user