From 2e2a2c694c28de7d669ebbec11548a016d3b507d Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 1 May 2011 13:56:35 +0100 Subject: [PATCH] Compile fixes for Linux. --- library/PolyVoxCore/include/SimpleVolume.inl | 17 ++++------------- .../PolyVoxCore/include/SimpleVolumeBlock.inl | 2 +- library/PolyVoxCore/include/SurfaceExtractor.h | 2 -- .../PolyVoxCore/include/SurfaceExtractor.inl | 8 ++++---- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/library/PolyVoxCore/include/SimpleVolume.inl b/library/PolyVoxCore/include/SimpleVolume.inl index 9efc847e..b21c7d7d 100644 --- a/library/PolyVoxCore/include/SimpleVolume.inl +++ b/library/PolyVoxCore/include/SimpleVolume.inl @@ -337,20 +337,11 @@ namespace PolyVox uint32_t SimpleVolume::calculateSizeInBytes(void) { uint32_t uSizeInBytes = sizeof(SimpleVolume); + + uint32_t uSizeOfBlockInBytes = m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength * sizeof(VoxelType); - //Memory used by the blocks - typename std::map::iterator i; - for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) - { - //Inaccurate - account for rest of loaded block. - uSizeInBytes += i->second.block.calculateSizeInBytes(); - } - - //Memory used by border data. - if(m_pUncompressedBorderData) - { - uSizeInBytes += m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength * sizeof(VoxelType); - } + //Memory used by the blocks ( + 1 is for border) + uSizeInBytes += uSizeOfBlockInBytes * (m_uNoOfBlocksInVolume + 1); return uSizeInBytes; } diff --git a/library/PolyVoxCore/include/SimpleVolumeBlock.inl b/library/PolyVoxCore/include/SimpleVolumeBlock.inl index f7298256..1de87868 100644 --- a/library/PolyVoxCore/include/SimpleVolumeBlock.inl +++ b/library/PolyVoxCore/include/SimpleVolumeBlock.inl @@ -126,7 +126,7 @@ namespace PolyVox template uint32_t SimpleVolume::Block::calculateSizeInBytes(void) { - uint32_t uSizeInBytes = sizeof(Block); + uint32_t uSizeInBytes = sizeof(Block); uSizeInBytes += sizeof(VoxelType) * m_uSideLength * m_uSideLength * m_uSideLength; return uSizeInBytes; } diff --git a/library/PolyVoxCore/include/SurfaceExtractor.h b/library/PolyVoxCore/include/SurfaceExtractor.h index e3334866..a1fd91a4 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.h +++ b/library/PolyVoxCore/include/SurfaceExtractor.h @@ -58,7 +58,6 @@ namespace PolyVox // NOTE: These two functions are in the .h file rather than the .inl due to an apparent bug in VC2010. //See http://stackoverflow.com/questions/1484885/strange-vc-compile-error-c2244 for details. //////////////////////////////////////////////////////////////////////////////// - template< template class VolumeType, typename VoxelType> Vector3DFloat computeCentralDifferenceGradient(const typename VolumeType::Sampler& volIter) { uint8_t voxel1nx = volIter.peekVoxel1nx0py0pz().getDensity(); @@ -78,7 +77,6 @@ namespace PolyVox ); } - template< template class VolumeType, typename VoxelType> Vector3DFloat computeSobelGradient(const typename VolumeType::Sampler& volIter) { static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { diff --git a/library/PolyVoxCore/include/SurfaceExtractor.inl b/library/PolyVoxCore/include/SurfaceExtractor.inl index 610f0bfe..3f52e3c7 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.inl +++ b/library/PolyVoxCore/include/SurfaceExtractor.inl @@ -429,14 +429,14 @@ namespace PolyVox m_sampVolume.setPosition(iXVolSpace,iYVolSpace,iZVolSpace); const VoxelType v000 = m_sampVolume.getVoxel(); - const Vector3DFloat n000 = computeCentralDifferenceGradient(m_sampVolume); + const Vector3DFloat n000 = computeCentralDifferenceGradient(m_sampVolume); /* Find the vertices where the surface intersects the cube */ if (edgeTable[iCubeIndex] & 1) { m_sampVolume.movePositiveX(); const VoxelType v100 = m_sampVolume.getVoxel(); - const Vector3DFloat n100 = computeCentralDifferenceGradient(m_sampVolume); + const Vector3DFloat n100 = computeCentralDifferenceGradient(m_sampVolume); //float fInterp = static_cast(v100.getDensity() - VoxelType::getMinDensity()) / static_cast(VoxelType::getMaxDensity() - VoxelType::getMinDensity()); float fInterp = static_cast(VoxelType::getThreshold() - v000.getDensity()) / static_cast(v100.getDensity() - v000.getDensity()); @@ -460,7 +460,7 @@ namespace PolyVox { m_sampVolume.movePositiveY(); const VoxelType v010 = m_sampVolume.getVoxel(); - const Vector3DFloat n010 = computeCentralDifferenceGradient(m_sampVolume); + const Vector3DFloat n010 = computeCentralDifferenceGradient(m_sampVolume); float fInterp = static_cast(VoxelType::getThreshold() - v000.getDensity()) / static_cast(v010.getDensity() - v000.getDensity()); //fInterp = 0.5f; @@ -483,7 +483,7 @@ namespace PolyVox { m_sampVolume.movePositiveZ(); const VoxelType v001 = m_sampVolume.getVoxel(); - const Vector3DFloat n001 = computeCentralDifferenceGradient(m_sampVolume); + const Vector3DFloat n001 = computeCentralDifferenceGradient(m_sampVolume); float fInterp = static_cast(VoxelType::getThreshold() - v000.getDensity()) / static_cast(v001.getDensity() - v000.getDensity()); //fInterp = 0.5f;