From ed5bff9ee13fddd7724e069f69fc75d29452fe6d Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 25 Apr 2009 15:47:20 +0000 Subject: [PATCH] Small volume fixes. --- library/PolyVoxCore/include/Block.inl | 2 +- library/PolyVoxCore/include/Volume.inl | 10 ++++++++++ library/PolyVoxUtil/source/VolumeChangeTracker.cpp | 4 +--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/library/PolyVoxCore/include/Block.inl b/library/PolyVoxCore/include/Block.inl index f9ff372d..0872cae1 100644 --- a/library/PolyVoxCore/include/Block.inl +++ b/library/PolyVoxCore/include/Block.inl @@ -146,7 +146,7 @@ namespace PolyVox template void BlockData::fill(VoxelType tValue) { - memset(m_tData, tValue, m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType)); + memset(m_tData, (int)tValue, m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType)); } template diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index a39a4437..7cefe893 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -40,6 +40,16 @@ namespace PolyVox :m_pBlocks(0) ,m_uCurrentBlockForTidying(0) { + //A values of zero for a block side length is a special value to indicate that the block + //side length should simply be made as large as possible. This can be useful if you are + //creating only a small volume which doesn't need to be broken down into many blocks. This + //'largest possible block size' will be equal to the shortest volume dimension, as a volume + //dimension can never be less than a block side length. + if(uBlockSideLength == 0) + { + uBlockSideLength = (std::min)((std::min)(uWidth,uHeight),uDepth); + } + //Debug mode validation assert(isPowerOf2(uWidth)); assert(isPowerOf2(uHeight)); diff --git a/library/PolyVoxUtil/source/VolumeChangeTracker.cpp b/library/PolyVoxUtil/source/VolumeChangeTracker.cpp index 824ddd37..4af768f8 100644 --- a/library/PolyVoxUtil/source/VolumeChangeTracker.cpp +++ b/library/PolyVoxUtil/source/VolumeChangeTracker.cpp @@ -51,9 +51,7 @@ namespace PolyVox m_uVolumeDepthInRegions = volumeData->getDepth() / m_uRegionSideLength; m_uRegionSideLengthPower = PolyVox::logBase2(m_uRegionSideLength); - uint16_t uShortestSideLengthInRegions = (std::min)((std::min)(m_uVolumeWidthInRegions,m_uVolumeHeightInRegions),m_uVolumeDepthInRegions); - - volRegionLastModified = new Volume(m_uVolumeWidthInRegions, m_uVolumeHeightInRegions, m_uVolumeDepthInRegions, uShortestSideLengthInRegions); //FIXME - Maybe using a block here isn't optimal as it must always be cubic... + volRegionLastModified = new Volume(m_uVolumeWidthInRegions, m_uVolumeHeightInRegions, m_uVolumeDepthInRegions, 0); } VolumeChangeTracker::~VolumeChangeTracker()