diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl index 1a5854bb..c0502af2 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl @@ -48,7 +48,7 @@ namespace PolyVox template void CubicSurfaceExtractor::execute() { - uint32_t arraySize[3]= {m_regSizeInVoxels.width()+2, m_regSizeInVoxels.height()+2, MaxQuadsSharingVertex}; + uint32_t arraySize[3]= {m_regSizeInVoxels.getWidth()+2, m_regSizeInVoxels.getHeight()+2, MaxQuadsSharingVertex}; m_previousSliceVertices.resize(arraySize); m_currentSliceVertices.resize(arraySize); memset(m_previousSliceVertices.getRawData(), 0xff, m_previousSliceVertices.getNoOfElements() * sizeof(IndexAndMaterial)); diff --git a/library/PolyVoxCore/include/Filters.inl b/library/PolyVoxCore/include/Filters.inl index f8db8a51..c0c34994 100644 --- a/library/PolyVoxCore/include/Filters.inl +++ b/library/PolyVoxCore/include/Filters.inl @@ -7,7 +7,7 @@ namespace PolyVox { Region croppedRegion = regionToSmooth; - Array<3, uint16_t> temp(ArraySizes(croppedRegion.width())(croppedRegion.height())(croppedRegion.depth())); + Array<3, uint16_t> temp(ArraySizes(croppedRegion.getWidth())(croppedRegion.getHeight())(croppedRegion.getDepth())); for (int z = croppedRegion.getLowerCorner().getZ(); z < croppedRegion.getUpperCorner().getZ(); z++) { diff --git a/library/PolyVoxCore/include/Region.h b/library/PolyVoxCore/include/Region.h index a4af688a..d8177a35 100644 --- a/library/PolyVoxCore/include/Region.h +++ b/library/PolyVoxCore/include/Region.h @@ -36,25 +36,35 @@ namespace PolyVox #endif { public: + + const static Region MaxRegion; + Region(); Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner); + uint32_t getDepth(void) const; + Vector3DUint32 getDimensions(void); + uint32_t getHeight(void) const; const Vector3DInt32& getLowerCorner(void) const; const Vector3DInt32& getUpperCorner(void) const; + uint32_t getWidth(void) const; void setLowerCorner(const Vector3DInt32& v3dLowerCorner); void setUpperCorner(const Vector3DInt32& v3dUpperCorner); - void setToMaxSize(void); bool containsPoint(const Vector3DFloat& pos, float boundary = 0.0f) const; bool containsPoint(const Vector3DInt32& pos, uint8_t boundary = 0) const; void cropTo(const Region& other); + /// Deprecated and wrong by 1 - use getDepth() instead. int32_t depth(void) const; + /// Deprecated and wrong by 1 - use getHeight() instead. int32_t height(void) const; void shift(const Vector3DInt32& amount); void shiftLowerCorner(const Vector3DInt32& amount); void shiftUpperCorner(const Vector3DInt32& amount); + /// Deprecated and wrong by 1 - use getDimensions() instead. Vector3DInt32 dimensions(void); + /// Deprecated and wrong by 1 - use getWidth() instead. int32_t width(void) const; private: diff --git a/library/PolyVoxCore/include/SurfaceExtractor.inl b/library/PolyVoxCore/include/SurfaceExtractor.inl index 746dcba7..d5d65d6d 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.inl +++ b/library/PolyVoxCore/include/SurfaceExtractor.inl @@ -46,7 +46,7 @@ namespace PolyVox template void SurfaceExtractor::execute() { - uint32_t arraySizes[2]= {m_regSizeInVoxels.width()+1, m_regSizeInVoxels.height()+1}; // Array dimensions + uint32_t arraySizes[2]= {m_regSizeInVoxels.getWidth(), m_regSizeInVoxels.getHeight()}; // Array dimensions //For edge indices Array2DInt32 m_pPreviousVertexIndicesX(arraySizes); diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index cdeb8566..753d420f 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -124,6 +124,8 @@ namespace PolyVox /// Constructor Volume(uint16_t uBlockSideLength = 32); /// Constructor + Volume(const Region& regValid, uint16_t uBlockSideLength = 32); + /// Constructor Volume(int32_t uWidth, int32_t uHeight, int32_t uDepth, uint16_t uBlockSideLength = 32); /// Destructor ~Volume(); @@ -163,9 +165,9 @@ namespace PolyVox void clearBlockCache(void); float calculateCompressionRatio(void); uint32_t calculateSizeInBytes(void); - /// Resizes the volume to the specified dimensions - void resize(uint16_t uBlockSideLength = 32); - void resize(int32_t uWidth, int32_t uHeight, int32_t uDepth, uint16_t uBlockSideLength); + + /// Deprecated - I don't think we should expose this function? Let us know if you disagree... + void resize(const Region& regValidRegion, uint16_t uBlockSideLength); /// gets called when a new region is allocated and needs to be filled /// NOTE: accessing ANY voxels outside this region during the process of this function /// is absolutely unsafe @@ -202,37 +204,15 @@ namespace PolyVox //the VolumeIterator can do it's usual pointer arithmetic without needing to know it's gone outside the volume. VoxelType* m_pUncompressedBorderData; - /*int32_t m_uMinX; - int32_t m_uMinY; - int32_t m_uMinZ; - - int32_t m_uMaxX; - int32_t m_uMaxY; - int32_t m_uMaxZ;*/ - + //The size of the volume Region m_regValidRegion; - - /*int32_t m_uBlockMinX; - int32_t m_uBlockMinY; - int32_t m_uBlockMinZ; - - int32_t m_uBlockMaxX; - int32_t m_uBlockMaxY; - int32_t m_uBlockMaxZ;*/ - Region m_regValidRegionInBlocks; - int32_t m_uWidthInBlocks; - int32_t m_uHeightInBlocks; - int32_t m_uDepthInBlocks; - - int32_t m_uWidth; - int32_t m_uHeight; - int32_t m_uDepth; - - uint8_t m_uBlockSideLengthPower; + //The size of the blocks uint16_t m_uBlockSideLength; + uint8_t m_uBlockSideLengthPower; + //Some useful sizes int32_t m_uLongestSideLength; int32_t m_uShortestSideLength; float m_fDiagonalLength; diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index fe195d66..9ab7b973 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -49,23 +49,9 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// template Volume::Volume(uint16_t uBlockSideLength) - : - m_uTimestamper(0) - ,m_uMaxUncompressedBlockCacheSize(256) - ,m_uMaxBlocksLoaded(4096) - ,m_uBlockSideLength(uBlockSideLength) - ,m_pUncompressedBorderData(0) - ,m_v3dLastAccessedBlockPos((std::numeric_limits::max)(), (std::numeric_limits::max)(), (std::numeric_limits::max)()) //An invalid index { - setBlockCacheSize(m_uMaxUncompressedBlockCacheSize); - - m_regValidRegion.setToMaxSize(); - - m_regValidRegionInBlocks.setLowerCorner(m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); - m_regValidRegionInBlocks.setUpperCorner(m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); - //Create a volume of the right size. - resize(uBlockSideLength); + resize(Region::MaxRegion,uBlockSideLength); } //////////////////////////////////////////////////////////////////////////////// @@ -82,23 +68,28 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// template Volume::Volume(int32_t uWidth, int32_t uHeight, int32_t uDepth, uint16_t uBlockSideLength) - :m_uTimestamper(0) - ,m_uMaxUncompressedBlockCacheSize(256) - ,m_uBlockSideLength(uBlockSideLength) - ,m_pUncompressedBorderData(0) - ,m_uMaxBlocksLoaded(4096) - ,m_v3dLastAccessedBlockPos((std::numeric_limits::max)(), (std::numeric_limits::max)(), (std::numeric_limits::max)()) //An invalid index { - setBlockCacheSize(m_uMaxUncompressedBlockCacheSize); - - m_regValidRegion.setLowerCorner(Vector3DInt32(0,0,0)); - m_regValidRegion.setUpperCorner(Vector3DInt32(uWidth - 1,uHeight - 1,uDepth - 1)); - - m_regValidRegionInBlocks.setLowerCorner(m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); - m_regValidRegionInBlocks.setUpperCorner(m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); + Region regValid(Vector3DInt32(0,0,0), Vector3DInt32(uWidth - 1,uHeight - 1,uDepth - 1)); + resize(Region(Vector3DInt32(0,0,0), Vector3DInt32(uWidth - 1,uHeight - 1,uDepth - 1)), uBlockSideLength); + } + //////////////////////////////////////////////////////////////////////////////// + /// Builds a volume of the desired dimensions + /// \param uWidth The desired width in voxels. This must be a power of two. + /// \param uHeight The desired height in voxels. This must be a power of two. + /// \param uDepth The desired depth in voxels. This must be a power of two. + /// \param uBlockSideLength The size of the blocks which make up the volume. Small + /// blocks are more likely to be homogeneous (so more easily shared) and have better + /// cache behaviour. However, there is a memory overhead per block so if they are + /// not shared it could actually be less efficient (this will depend on the data). + /// The size of the volume may also be a factor when choosing block size. Accept + /// the default if you are not sure what to choose here. + //////////////////////////////////////////////////////////////////////////////// + template + Volume::Volume(const Region& regValid, uint16_t uBlockSideLength) + { //Create a volume of the right size. - resize(uWidth, uHeight, uDepth, uBlockSideLength); + resize(regValid,uBlockSideLength); } //////////////////////////////////////////////////////////////////////////////// @@ -121,8 +112,6 @@ namespace PolyVox template VoxelType Volume::getBorderValue(void) const { - /*Block* pUncompressedBorderBlock = getUncompressedBlock(const_cast*>(&m_pBorderBlock)); - return pUncompressedBorderBlock->getVoxelAt(0,0,0);*/ return *m_pUncompressedBorderData; } @@ -135,7 +124,7 @@ namespace PolyVox template Region Volume::getEnclosingRegion(void) const { - return Region(Vector3DInt32(0,0,0), Vector3DInt32(m_uWidth-1,m_uHeight-1,m_uDepth-1)); + return m_regValidRegion; } //////////////////////////////////////////////////////////////////////////////// @@ -145,7 +134,7 @@ namespace PolyVox template int32_t Volume::getWidth(void) const { - return m_uWidth; + return m_regValidRegion.getWidth(); } //////////////////////////////////////////////////////////////////////////////// @@ -155,7 +144,7 @@ namespace PolyVox template int32_t Volume::getHeight(void) const { - return m_uHeight; + return m_regValidRegion.getHeight(); } //////////////////////////////////////////////////////////////////////////////// @@ -165,7 +154,7 @@ namespace PolyVox template int32_t Volume::getDepth(void) const { - return m_uDepth; + return m_regValidRegion.getDepth(); } //////////////////////////////////////////////////////////////////////////////// @@ -211,17 +200,24 @@ namespace PolyVox template VoxelType Volume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - const int32_t blockX = uXPos >> m_uBlockSideLengthPower; - const int32_t blockY = uYPos >> m_uBlockSideLengthPower; - const int32_t blockZ = uZPos >> m_uBlockSideLengthPower; + if(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + { + const int32_t blockX = uXPos >> m_uBlockSideLengthPower; + const int32_t blockY = uYPos >> m_uBlockSideLengthPower; + const int32_t blockZ = uZPos >> m_uBlockSideLengthPower; - const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower); - const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); - const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); + const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower); + const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); + const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); - Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ); + Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ); - return pUncompressedBlock->getVoxelAt(xOffset,yOffset,zOffset); + return pUncompressedBlock->getVoxelAt(xOffset,yOffset,zOffset); + } + else + { + return getBorderValue(); + } } //////////////////////////////////////////////////////////////////////////////// @@ -293,6 +289,8 @@ namespace PolyVox template bool Volume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { + assert(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; const int32_t blockZ = uZPos >> m_uBlockSideLengthPower; @@ -331,43 +329,6 @@ namespace PolyVox m_vecUncompressedBlockCache.clear(); } - //////////////////////////////////////////////////////////////////////////////// - /// Note: Calling this function will destroy all existing data in the volume. - /// \param uBlockSideLength The size of the blocks which make up the volume. Small - /// blocks are more likely to be homogeneous (so more easily shared) and have better - /// cache behaviour. However, there is a memory overhead per block so if they are - /// not shared it could actually be less efficient (this will depend on the data). - /// The size of the volume may also be a factor when choosing block size. Accept - /// the default if you are not sure what to choose here. - //////////////////////////////////////////////////////////////////////////////// - template - void Volume::resize(uint16_t uBlockSideLength) - { - //Debug mode validation - assert(uBlockSideLength > 0); - assert(isPowerOf2(uBlockSideLength)); - - //Release mode validation - if(uBlockSideLength == 0) - { - throw std::invalid_argument("Block side length cannot be zero."); - } - if(!isPowerOf2(uBlockSideLength)) - { - throw std::invalid_argument("Block side length must be a power of two."); - } - - //Clear the previous data - m_pBlocks.clear(); - m_pUncompressedTimestamps.clear(); - - m_pUncompressedTimestamps.resize(m_uMaxUncompressedBlockCacheSize, 0); - - //Compute the block side length - m_uBlockSideLength = uBlockSideLength; - m_uBlockSideLengthPower = logBase2(m_uBlockSideLength); - } - //////////////////////////////////////////////////////////////////////////////// /// Note: Calling this function will destroy all existing data in the volume. /// \param uWidth The desired width in voxels. This must be a power of two. @@ -381,18 +342,11 @@ namespace PolyVox /// the default if you are not sure what to choose here. //////////////////////////////////////////////////////////////////////////////// template - void Volume::resize(int32_t uWidth, int32_t uHeight, int32_t uDepth, uint16_t uBlockSideLength) + void Volume::resize(const Region& regValidRegion, uint16_t uBlockSideLength) { //Debug mode validation assert(uBlockSideLength > 0); - assert(isPowerOf2(uBlockSideLength)); - assert(uBlockSideLength <= uWidth); - assert(uBlockSideLength <= uHeight); - assert(uBlockSideLength <= uDepth); - assert(0 < uWidth); - assert(0 < uHeight); - assert(0 < uDepth); - + //Release mode validation if(uBlockSideLength == 0) { @@ -402,49 +356,29 @@ namespace PolyVox { throw std::invalid_argument("Block side length must be a power of two."); } - if(uBlockSideLength > uWidth) - { - throw std::invalid_argument("Block side length cannot be greater than volume width."); - } - if(uBlockSideLength > uHeight) - { - throw std::invalid_argument("Block side length cannot be greater than volume height."); - } - if(uBlockSideLength > uDepth) - { - throw std::invalid_argument("Block side length cannot be greater than volume depth."); - } - if(0 >= uWidth) - { - throw std::invalid_argument("Volume width cannot be smaller than 1."); - } - if(0 >= uHeight) - { - throw std::invalid_argument("Volume height cannot be smaller than 1."); - } - if(0 >= uDepth) - { - throw std::invalid_argument("Volume depth cannot be smaller than 1."); - } + + m_uTimestamper = 0; + m_uMaxUncompressedBlockCacheSize = 256; + m_uBlockSideLength = uBlockSideLength; + m_pUncompressedBorderData = 0; + m_uMaxBlocksLoaded = 4096; + m_v3dLastAccessedBlockPos = Vector3DInt32((std::numeric_limits::max)(), (std::numeric_limits::max)(), (std::numeric_limits::max)()); //An invalid index + + m_regValidRegion = regValidRegion; + + m_regValidRegionInBlocks.setLowerCorner(m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setUpperCorner(m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); + + setBlockCacheSize(m_uMaxUncompressedBlockCacheSize); //Clear the previous data m_pBlocks.clear(); m_pUncompressedTimestamps.clear(); - //Compute the volume side lengths - m_uWidth = uWidth; - m_uHeight = uHeight; - m_uDepth = uDepth; - //Compute the block side length m_uBlockSideLength = uBlockSideLength; m_uBlockSideLengthPower = logBase2(m_uBlockSideLength); - //Compute the side lengths in blocks - m_uWidthInBlocks = m_uWidth / m_uBlockSideLength; - m_uHeightInBlocks = m_uHeight / m_uBlockSideLength; - m_uDepthInBlocks = m_uDepth / m_uBlockSideLength; - //Clear the previous data m_pBlocks.clear(); m_pUncompressedTimestamps.clear(); @@ -456,9 +390,9 @@ namespace PolyVox std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType()); //Other properties we might find useful later - m_uLongestSideLength = (std::max)((std::max)(m_uWidth,m_uHeight),m_uDepth); - m_uShortestSideLength = (std::min)((std::min)(m_uWidth,m_uHeight),m_uDepth); - m_fDiagonalLength = sqrtf(static_cast(m_uWidth * m_uWidth + m_uHeight * m_uHeight + m_uDepth * m_uDepth)); + m_uLongestSideLength = (std::max)((std::max)(getWidth(),getHeight()),getDepth()); + m_uShortestSideLength = (std::min)((std::min)(getWidth(),getHeight()),getDepth()); + m_fDiagonalLength = sqrtf(static_cast(getWidth() * getWidth() + getHeight() * getHeight() + getDepth() * getDepth())); } template diff --git a/library/PolyVoxCore/include/VolumeSampler.inl b/library/PolyVoxCore/include/VolumeSampler.inl index 6a4e3d3f..92591a56 100644 --- a/library/PolyVoxCore/include/VolumeSampler.inl +++ b/library/PolyVoxCore/include/VolumeSampler.inl @@ -153,15 +153,8 @@ namespace PolyVox uYPosInBlock * mVolume->m_uBlockSideLength + uZPosInBlock * mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; - //if((uXBlock < mVolume->m_uWidthInBlocks) && (uYBlock < mVolume->m_uHeightInBlocks) && (uZBlock < mVolume->m_uDepthInBlocks) && (uXBlock >= 0) && (uYBlock >= 0) && (uZBlock >=0)) - //if((uXBlock <= mVolume->m_uBlockMaxX) && (uYBlock <= mVolume->m_uBlockMaxY) && (uZBlock <= mVolume->m_uBlockMaxZ) && (uXBlock >= mVolume->m_uBlockMinX) && (uYBlock >= mVolume->m_uBlockMinY) && (uZBlock >= mVolume->m_uBlockMinZ)) if(mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock))) { - /*const uint32_t uBlockIndexInVolume = uXBlock + - uYBlock * mVolume->m_uWidthInBlocks + - uZBlock * mVolume->m_uWidthInBlocks * mVolume->m_uHeightInBlocks; - const Block& currentBlock = mVolume->m_pBlocks[uBlockIndexInVolume];*/ - Block* pUncompressedCurrentBlock = mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock; diff --git a/library/PolyVoxCore/source/Region.cpp b/library/PolyVoxCore/source/Region.cpp index 3c0cb174..d76ed9b0 100644 --- a/library/PolyVoxCore/source/Region.cpp +++ b/library/PolyVoxCore/source/Region.cpp @@ -25,6 +25,13 @@ freely, subject to the following restrictions: namespace PolyVox { + const Region Region::MaxRegion + ( + Vector3DInt32((std::numeric_limits::min)(), (std::numeric_limits::min)(), (std::numeric_limits::min)()), + Vector3DInt32((std::numeric_limits::max)(), (std::numeric_limits::max)(), (std::numeric_limits::max)()) + ); + + Region::Region() :m_v3dLowerCorner(0,0,0) ,m_v3dUpperCorner(0,0,0) @@ -35,6 +42,36 @@ namespace PolyVox :m_v3dLowerCorner(v3dLowerCorner) ,m_v3dUpperCorner(v3dUpperCorner) { + //Check the region is valid. + assert(m_v3dUpperCorner.getX() >= m_v3dLowerCorner.getX()); + assert(m_v3dUpperCorner.getY() >= m_v3dLowerCorner.getY()); + assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); + } + + uint32_t Region::getDepth(void) const + { + //We're returning the result as unsigned, so ensure that + //the upper value is at least as big as the lower value. + assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); + return m_v3dUpperCorner.getZ() - m_v3dLowerCorner.getZ() + 1; + } + + Vector3DUint32 Region::getDimensions(void) + { + //We're returning the result as unsigned, so ensure that + //the upper value is at least as big as the lower value. + assert(m_v3dUpperCorner.getX() >= m_v3dLowerCorner.getX()); + assert(m_v3dUpperCorner.getY() >= m_v3dLowerCorner.getY()); + assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); + return static_cast(m_v3dUpperCorner - m_v3dLowerCorner) + Vector3DUint32(1,1,1); + } + + uint32_t Region::getHeight(void) const + { + //We're returning the result as unsigned, so ensure that + //the upper value is at least as big as the lower value. + assert(m_v3dUpperCorner.getY() >= m_v3dLowerCorner.getY()); + return m_v3dUpperCorner.getY() - m_v3dLowerCorner.getY() + 1; } const Vector3DInt32& Region::getLowerCorner(void) const @@ -47,6 +84,14 @@ namespace PolyVox return m_v3dUpperCorner; } + uint32_t Region::getWidth(void) const + { + //We're returning the result as unsigned, so ensure that + //the upper value is at least as big as the lower value. + assert(m_v3dUpperCorner.getX() >= m_v3dLowerCorner.getX()); + return m_v3dUpperCorner.getX() - m_v3dLowerCorner.getX() + 1; + } + void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner) { m_v3dLowerCorner = v3dLowerCorner; @@ -57,14 +102,6 @@ namespace PolyVox m_v3dUpperCorner = v3dUpperCorner; } - void Region::setToMaxSize(void) - { - int32_t iMin = (std::numeric_limits::min)(); - int32_t iMax = (std::numeric_limits::max)(); - m_v3dLowerCorner = Vector3DInt32(iMin, iMin,iMin); - m_v3dUpperCorner = Vector3DInt32(iMax, iMax,iMax); - } - bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const { return (pos.getX() <= m_v3dUpperCorner.getX() - boundary) @@ -97,11 +134,15 @@ namespace PolyVox int32_t Region::depth(void) const { + //This function is deprecated and wrong. Use getDepth() instead. + assert(false); return m_v3dUpperCorner.getZ() - m_v3dLowerCorner.getZ(); } int32_t Region::height(void) const { + //This function is deprecated and wrong. Use getHeight() instead. + assert(false); return m_v3dUpperCorner.getY() - m_v3dLowerCorner.getY(); } @@ -123,11 +164,15 @@ namespace PolyVox Vector3DInt32 Region::dimensions(void) { + //This function is deprecated and wrong. Use getDimensions() instead. + assert(false); return m_v3dUpperCorner - m_v3dLowerCorner; } int32_t Region::width(void) const { + //This function is deprecated and wrong. Use getWidth() instead. + assert(false); return m_v3dUpperCorner.getX() - m_v3dLowerCorner.getX(); } } diff --git a/library/PolyVoxUtil/include/Serialization.inl b/library/PolyVoxUtil/include/Serialization.inl index f04e73e6..4ac8e923 100644 --- a/library/PolyVoxUtil/include/Serialization.inl +++ b/library/PolyVoxUtil/include/Serialization.inl @@ -320,7 +320,8 @@ namespace PolyVox stream.read(reinterpret_cast(&volumeDepth), sizeof(volumeDepth)); //Resize the volume - volume.resize(volumeWidth, volumeHeight, volumeDepth); + //HACK - Forces block size to 32. This functions needs reworking anyway due to large volume support. + volume.resize(Region(Vector3DInt32(0,0,0), Vector3DInt32(volumeWidth, volumeHeight, volumeDepth)), 32); //Read data bool firstTime = true;