Small volume fixes.

This commit is contained in:
David Williams 2009-04-25 15:47:20 +00:00
parent 76fa702ea7
commit ed5bff9ee1
3 changed files with 12 additions and 4 deletions

View File

@ -146,7 +146,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void BlockData<VoxelType>::fill(VoxelType tValue) void BlockData<VoxelType>::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 <typename VoxelType> template <typename VoxelType>

View File

@ -40,6 +40,16 @@ namespace PolyVox
:m_pBlocks(0) :m_pBlocks(0)
,m_uCurrentBlockForTidying(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 //Debug mode validation
assert(isPowerOf2(uWidth)); assert(isPowerOf2(uWidth));
assert(isPowerOf2(uHeight)); assert(isPowerOf2(uHeight));

View File

@ -51,9 +51,7 @@ namespace PolyVox
m_uVolumeDepthInRegions = volumeData->getDepth() / m_uRegionSideLength; m_uVolumeDepthInRegions = volumeData->getDepth() / m_uRegionSideLength;
m_uRegionSideLengthPower = PolyVox::logBase2(m_uRegionSideLength); m_uRegionSideLengthPower = PolyVox::logBase2(m_uRegionSideLength);
uint16_t uShortestSideLengthInRegions = (std::min)((std::min)(m_uVolumeWidthInRegions,m_uVolumeHeightInRegions),m_uVolumeDepthInRegions); volRegionLastModified = new Volume<int32_t>(m_uVolumeWidthInRegions, m_uVolumeHeightInRegions, m_uVolumeDepthInRegions, 0);
volRegionLastModified = new Volume<int32_t>(m_uVolumeWidthInRegions, m_uVolumeHeightInRegions, m_uVolumeDepthInRegions, uShortestSideLengthInRegions); //FIXME - Maybe using a block here isn't optimal as it must always be cubic...
} }
VolumeChangeTracker::~VolumeChangeTracker() VolumeChangeTracker::~VolumeChangeTracker()