diff --git a/CMakeLists.txt b/CMakeLists.txt index a8cf995b..ab514441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,9 @@ SET(SRC_FILES SET(INC_FILES include/Block.h include/Block.inl - include/Constants.h + include/Constants.h + include/GradientEstimators.h + include/GradientEstimators.inl include/IndexedSurfacePatch.h include/MarchingCubesTables.h include/PolyVoxForwardDeclarations.h diff --git a/include/GradientEstimators.h b/include/GradientEstimators.h new file mode 100644 index 00000000..05203b15 --- /dev/null +++ b/include/GradientEstimators.h @@ -0,0 +1,18 @@ +#ifndef __PolyVox_GradientEstimators_H__ +#define __PolyVox_GradientEstimators_H__ + +#include "VolumeIterator.h" + +namespace PolyVox +{ + //FIXME - gradient can be expressed with ints. + template + Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator& volIter); + + template + Vector3DFloat computeSobelGradient(const VolumeIterator& volIter); +} + +#include "GradientEstimators.inl" + +#endif //__PolyVox_GradientEstimators_H__ \ No newline at end of file diff --git a/include/GradientEstimators.inl b/include/GradientEstimators.inl new file mode 100644 index 00000000..924eda4d --- /dev/null +++ b/include/GradientEstimators.inl @@ -0,0 +1,119 @@ +namespace PolyVox +{ + template + Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator& volIter) + { + //FIXME - should this test be here? + if((volIter.getPosX() < 1) || (volIter.getPosX() > POLYVOX_VOLUME_SIDE_LENGTH-2) || + (volIter.getPosY() < 1) || (volIter.getPosY() > POLYVOX_VOLUME_SIDE_LENGTH-2) || + (volIter.getPosZ() < 1) || (volIter.getPosZ() > POLYVOX_VOLUME_SIDE_LENGTH-2)) + { + //LogManager::getSingleton().logMessage("Out of range"); + return Vector3DFloat(0.0,0.0,0.0); + } + + //FIXME - bitwise way of doing this? + VoxelType voxel1nx = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0; + VoxelType voxel1px = volIter.peekVoxel1px0py0pz() > 0 ? 1: 0; + + VoxelType voxel1ny = volIter.peekVoxel0px1ny0pz() > 0 ? 1: 0; + VoxelType voxel1py = volIter.peekVoxel0px1py0pz() > 0 ? 1: 0; + + VoxelType voxel1nz = volIter.peekVoxel0px0py1nz() > 0 ? 1: 0; + VoxelType voxel1pz = volIter.peekVoxel0px0py1pz() > 0 ? 1: 0; + + return Vector3DFloat(int(voxel1px) - int(voxel1nx),int(voxel1py) - int(voxel1ny),int(voxel1pz) - int(voxel1nz)); + } + + template + Vector3DFloat computeSobelGradient(const VolumeIterator& volIter) + { + //FIXME - should this test be here? + if((volIter.getPosX() < 1) || (volIter.getPosX() > POLYVOX_VOLUME_SIDE_LENGTH-2) || + (volIter.getPosY() < 1) || (volIter.getPosY() > POLYVOX_VOLUME_SIDE_LENGTH-2) || + (volIter.getPosZ() < 1) || (volIter.getPosZ() > POLYVOX_VOLUME_SIDE_LENGTH-2)) + { + //LogManager::getSingleton().logMessage("Out of range"); + return Vector3DFloat(0.0,0.0,0.0); + } + + static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { + {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; + + const VoxelType pVoxel1nx1ny1nz = volIter.peekVoxel1nx1ny1nz() > 0 ? 1: 0; + const VoxelType pVoxel1nx1ny0pz = volIter.peekVoxel1nx1ny0pz() > 0 ? 1: 0; + const VoxelType pVoxel1nx1ny1pz = volIter.peekVoxel1nx1ny1pz() > 0 ? 1: 0; + const VoxelType pVoxel1nx0py1nz = volIter.peekVoxel1nx0py1nz() > 0 ? 1: 0; + const VoxelType pVoxel1nx0py0pz = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0; + const VoxelType pVoxel1nx0py1pz = volIter.peekVoxel1nx0py1pz() > 0 ? 1: 0; + const VoxelType pVoxel1nx1py1nz = volIter.peekVoxel1nx1py1nz() > 0 ? 1: 0; + const VoxelType pVoxel1nx1py0pz = volIter.peekVoxel1nx1py0pz() > 0 ? 1: 0; + const VoxelType pVoxel1nx1py1pz = volIter.peekVoxel1nx1py1pz() > 0 ? 1: 0; + + const VoxelType pVoxel0px1ny1nz = volIter.peekVoxel0px1ny1nz() > 0 ? 1: 0; + const VoxelType pVoxel0px1ny0pz = volIter.peekVoxel0px1ny0pz() > 0 ? 1: 0; + const VoxelType pVoxel0px1ny1pz = volIter.peekVoxel0px1ny1pz() > 0 ? 1: 0; + const VoxelType pVoxel0px0py1nz = volIter.peekVoxel0px0py1nz() > 0 ? 1: 0; + //const VoxelType pVoxel0px0py0pz = volIter.peekVoxel0px0py0pz() > 0 ? 1: 0; + const VoxelType pVoxel0px0py1pz = volIter.peekVoxel0px0py1pz() > 0 ? 1: 0; + const VoxelType pVoxel0px1py1nz = volIter.peekVoxel0px1py1nz() > 0 ? 1: 0; + const VoxelType pVoxel0px1py0pz = volIter.peekVoxel0px1py0pz() > 0 ? 1: 0; + const VoxelType pVoxel0px1py1pz = volIter.peekVoxel0px1py1pz() > 0 ? 1: 0; + + const VoxelType pVoxel1px1ny1nz = volIter.peekVoxel1px1ny1nz() > 0 ? 1: 0; + const VoxelType pVoxel1px1ny0pz = volIter.peekVoxel1px1ny0pz() > 0 ? 1: 0; + const VoxelType pVoxel1px1ny1pz = volIter.peekVoxel1px1ny1pz() > 0 ? 1: 0; + const VoxelType pVoxel1px0py1nz = volIter.peekVoxel1px0py1nz() > 0 ? 1: 0; + const VoxelType pVoxel1px0py0pz = volIter.peekVoxel1px0py0pz() > 0 ? 1: 0; + const VoxelType pVoxel1px0py1pz = volIter.peekVoxel1px0py1pz() > 0 ? 1: 0; + const VoxelType pVoxel1px1py1nz = volIter.peekVoxel1px1py1nz() > 0 ? 1: 0; + const VoxelType pVoxel1px1py0pz = volIter.peekVoxel1px1py0pz() > 0 ? 1: 0; + const VoxelType pVoxel1px1py1pz = volIter.peekVoxel1px1py1pz() > 0 ? 1: 0; + + + + const int xGrad(- weights[0][0][0] * ( pVoxel1nx1ny1nz) - + weights[1][0][0] * ( pVoxel1nx1ny0pz) - weights[2][0][0] * + ( pVoxel1nx1ny1pz) - weights[0][1][0] * ( pVoxel1nx0py1nz) - + weights[1][1][0] * ( pVoxel1nx0py0pz) - weights[2][1][0] * + ( pVoxel1nx0py1pz) - weights[0][2][0] * ( pVoxel1nx1py1nz) - + weights[1][2][0] * ( pVoxel1nx1py0pz) - weights[2][2][0] * + ( pVoxel1nx1py1pz) + weights[0][0][2] * ( pVoxel1px1ny1nz) + + weights[1][0][2] * ( pVoxel1px1ny0pz) + weights[2][0][2] * + ( pVoxel1px1ny1pz) + weights[0][1][2] * ( pVoxel1px0py1nz) + + weights[1][1][2] * ( pVoxel1px0py0pz) + weights[2][1][2] * + ( pVoxel1px0py1pz) + weights[0][2][2] * ( pVoxel1px1py1nz) + + weights[1][2][2] * ( pVoxel1px1py0pz) + weights[2][2][2] * + ( pVoxel1px1py1pz)); + + const int yGrad(- weights[0][0][0] * ( pVoxel1nx1ny1nz) - + weights[1][0][0] * ( pVoxel1nx1ny0pz) - weights[2][0][0] * + ( pVoxel1nx1ny1pz) + weights[0][2][0] * ( pVoxel1nx1py1nz) + + weights[1][2][0] * ( pVoxel1nx1py0pz) + weights[2][2][0] * + ( pVoxel1nx1py1pz) - weights[0][0][1] * ( pVoxel0px1ny1nz) - + weights[1][0][1] * ( pVoxel0px1ny0pz) - weights[2][0][1] * + ( pVoxel0px1ny1pz) + weights[0][2][1] * ( pVoxel0px1py1nz) + + weights[1][2][1] * ( pVoxel0px1py0pz) + weights[2][2][1] * + ( pVoxel0px1py1pz) - weights[0][0][2] * ( pVoxel1px1ny1nz) - + weights[1][0][2] * ( pVoxel1px1ny0pz) - weights[2][0][2] * + ( pVoxel1px1ny1pz) + weights[0][2][2] * ( pVoxel1px1py1nz) + + weights[1][2][2] * ( pVoxel1px1py0pz) + weights[2][2][2] * + ( pVoxel1px1py1pz)); + + const int zGrad(- weights[0][0][0] * ( pVoxel1nx1ny1nz) + + weights[2][0][0] * ( pVoxel1nx1ny1pz) - weights[0][1][0] * + ( pVoxel1nx0py1nz) + weights[2][1][0] * ( pVoxel1nx0py1pz) - + weights[0][2][0] * ( pVoxel1nx1py1nz) + weights[2][2][0] * + ( pVoxel1nx1py1pz) - weights[0][0][1] * ( pVoxel0px1ny1nz) + + weights[2][0][1] * ( pVoxel0px1ny1pz) - weights[0][1][1] * + ( pVoxel0px0py1nz) + weights[2][1][1] * ( pVoxel0px0py1pz) - + weights[0][2][1] * ( pVoxel0px1py1nz) + weights[2][2][1] * + ( pVoxel0px1py1pz) - weights[0][0][2] * ( pVoxel1px1ny1nz) + + weights[2][0][2] * ( pVoxel1px1ny1pz) - weights[0][1][2] * + ( pVoxel1px0py1nz) + weights[2][1][2] * ( pVoxel1px0py1pz) - + weights[0][2][2] * ( pVoxel1px1py1nz) + weights[2][2][2] * + ( pVoxel1px1py1pz)); + + return Vector3DFloat(xGrad,yGrad,zGrad); + } +} \ No newline at end of file diff --git a/include/VolumeIterator.h b/include/VolumeIterator.h index 4753afa5..3f492632 100644 --- a/include/VolumeIterator.h +++ b/include/VolumeIterator.h @@ -39,14 +39,11 @@ namespace PolyVox float getAveragedVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, boost::uint16_t size) const; - //FIXME - this shouldn't return float vector - Vector3DFloat getCentralDifferenceGradient(void) const; - Vector3DFloat getAveragedCentralDifferenceGradient(void) const; - Vector3DFloat getSobelGradient(void) const; + - boost::uint16_t getPosX(void); - boost::uint16_t getPosY(void); - boost::uint16_t getPosZ(void); + boost::uint16_t getPosX(void) const; + boost::uint16_t getPosY(void) const; + boost::uint16_t getPosZ(void) const; void setPosition(boost::uint16_t xPos, boost::uint16_t yPos, boost::uint16_t zPos); void setValidRegion(boost::uint16_t xFirst, boost::uint16_t yFirst, boost::uint16_t zFirst, boost::uint16_t xLast, boost::uint16_t yLast, boost::uint16_t zLast); diff --git a/include/VolumeIterator.inl b/include/VolumeIterator.inl index a0c8fc90..afbb4a5e 100644 --- a/include/VolumeIterator.inl +++ b/include/VolumeIterator.inl @@ -131,161 +131,19 @@ namespace PolyVox } template - Vector3DFloat VolumeIterator::getCentralDifferenceGradient(void) const - { - //FIXME - should this test be here? - if((mXPosInVolume < 1) || (mXPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-2) || - (mYPosInVolume < 1) || (mYPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-2) || - (mZPosInVolume < 1) || (mZPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-2)) - { - //LogManager::getSingleton().logMessage("Out of range"); - return Vector3DFloat(0.0,0.0,0.0); - } - - //FIXME - bitwise way of doing this? - VoxelType voxel1nx = peekVoxel1nx0py0pz() > 0 ? 1: 0; - VoxelType voxel1px = peekVoxel1px0py0pz() > 0 ? 1: 0; - - VoxelType voxel1ny = peekVoxel0px1ny0pz() > 0 ? 1: 0; - VoxelType voxel1py = peekVoxel0px1py0pz() > 0 ? 1: 0; - - VoxelType voxel1nz = peekVoxel0px0py1nz() > 0 ? 1: 0; - VoxelType voxel1pz = peekVoxel0px0py1pz() > 0 ? 1: 0; - - return Vector3DFloat(int(voxel1px) - int(voxel1nx),int(voxel1py) - int(voxel1ny),int(voxel1pz) - int(voxel1nz)); - } - - template - Vector3DFloat VolumeIterator::getAveragedCentralDifferenceGradient(void) const - { - //FIXME - should this test be here? - if((mXPosInVolume < 2) || (mXPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-3) || - (mYPosInVolume < 2) || (mYPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-3) || - (mZPosInVolume < 2) || (mZPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-3)) - { - //LogManager::getSingleton().logMessage("Out of range"); - return Vector3DFloat(0.0,0.0,0.0); - } - - //FIXME - bitwise way of doing this? - float voxel1nx = getAveragedVoxelAt(mXPosInVolume-1,mYPosInVolume ,mZPosInVolume, 2); - float voxel1px = getAveragedVoxelAt(mXPosInVolume+1,mYPosInVolume ,mZPosInVolume, 2); - - float voxel1ny = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume-1,mZPosInVolume, 2); - float voxel1py = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume+1,mZPosInVolume, 2); - - float voxel1nz = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume ,mZPosInVolume-1,2); - float voxel1pz = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume ,mZPosInVolume+1,2); - - return Vector3DFloat(voxel1px - voxel1nx,voxel1py - voxel1ny,voxel1pz - voxel1nz); - } - - template - Vector3DFloat VolumeIterator::getSobelGradient(void) const - { - //FIXME - should this test be here? - if((mXPosInVolume < 1) || (mXPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-2) || - (mYPosInVolume < 1) || (mYPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-2) || - (mZPosInVolume < 1) || (mZPosInVolume > POLYVOX_VOLUME_SIDE_LENGTH-2)) - { - //LogManager::getSingleton().logMessage("Out of range"); - return Vector3DFloat(0.0,0.0,0.0); - } - - static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { - {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; - - const VoxelType pVoxel1nx1ny1nz = peekVoxel1nx1ny1nz() > 0 ? 1: 0; - const VoxelType pVoxel1nx1ny0pz = peekVoxel1nx1ny0pz() > 0 ? 1: 0; - const VoxelType pVoxel1nx1ny1pz = peekVoxel1nx1ny1pz() > 0 ? 1: 0; - const VoxelType pVoxel1nx0py1nz = peekVoxel1nx0py1nz() > 0 ? 1: 0; - const VoxelType pVoxel1nx0py0pz = peekVoxel1nx0py0pz() > 0 ? 1: 0; - const VoxelType pVoxel1nx0py1pz = peekVoxel1nx0py1pz() > 0 ? 1: 0; - const VoxelType pVoxel1nx1py1nz = peekVoxel1nx1py1nz() > 0 ? 1: 0; - const VoxelType pVoxel1nx1py0pz = peekVoxel1nx1py0pz() > 0 ? 1: 0; - const VoxelType pVoxel1nx1py1pz = peekVoxel1nx1py1pz() > 0 ? 1: 0; - - const VoxelType pVoxel0px1ny1nz = peekVoxel0px1ny1nz() > 0 ? 1: 0; - const VoxelType pVoxel0px1ny0pz = peekVoxel0px1ny0pz() > 0 ? 1: 0; - const VoxelType pVoxel0px1ny1pz = peekVoxel0px1ny1pz() > 0 ? 1: 0; - const VoxelType pVoxel0px0py1nz = peekVoxel0px0py1nz() > 0 ? 1: 0; - //const VoxelType pVoxel0px0py0pz = peekVoxel0px0py0pz() > 0 ? 1: 0; - const VoxelType pVoxel0px0py1pz = peekVoxel0px0py1pz() > 0 ? 1: 0; - const VoxelType pVoxel0px1py1nz = peekVoxel0px1py1nz() > 0 ? 1: 0; - const VoxelType pVoxel0px1py0pz = peekVoxel0px1py0pz() > 0 ? 1: 0; - const VoxelType pVoxel0px1py1pz = peekVoxel0px1py1pz() > 0 ? 1: 0; - - const VoxelType pVoxel1px1ny1nz = peekVoxel1px1ny1nz() > 0 ? 1: 0; - const VoxelType pVoxel1px1ny0pz = peekVoxel1px1ny0pz() > 0 ? 1: 0; - const VoxelType pVoxel1px1ny1pz = peekVoxel1px1ny1pz() > 0 ? 1: 0; - const VoxelType pVoxel1px0py1nz = peekVoxel1px0py1nz() > 0 ? 1: 0; - const VoxelType pVoxel1px0py0pz = peekVoxel1px0py0pz() > 0 ? 1: 0; - const VoxelType pVoxel1px0py1pz = peekVoxel1px0py1pz() > 0 ? 1: 0; - const VoxelType pVoxel1px1py1nz = peekVoxel1px1py1nz() > 0 ? 1: 0; - const VoxelType pVoxel1px1py0pz = peekVoxel1px1py0pz() > 0 ? 1: 0; - const VoxelType pVoxel1px1py1pz = peekVoxel1px1py1pz() > 0 ? 1: 0; - - - - const int xGrad(- weights[0][0][0] * ( pVoxel1nx1ny1nz) - - weights[1][0][0] * ( pVoxel1nx1ny0pz) - weights[2][0][0] * - ( pVoxel1nx1ny1pz) - weights[0][1][0] * ( pVoxel1nx0py1nz) - - weights[1][1][0] * ( pVoxel1nx0py0pz) - weights[2][1][0] * - ( pVoxel1nx0py1pz) - weights[0][2][0] * ( pVoxel1nx1py1nz) - - weights[1][2][0] * ( pVoxel1nx1py0pz) - weights[2][2][0] * - ( pVoxel1nx1py1pz) + weights[0][0][2] * ( pVoxel1px1ny1nz) + - weights[1][0][2] * ( pVoxel1px1ny0pz) + weights[2][0][2] * - ( pVoxel1px1ny1pz) + weights[0][1][2] * ( pVoxel1px0py1nz) + - weights[1][1][2] * ( pVoxel1px0py0pz) + weights[2][1][2] * - ( pVoxel1px0py1pz) + weights[0][2][2] * ( pVoxel1px1py1nz) + - weights[1][2][2] * ( pVoxel1px1py0pz) + weights[2][2][2] * - ( pVoxel1px1py1pz)); - - const int yGrad(- weights[0][0][0] * ( pVoxel1nx1ny1nz) - - weights[1][0][0] * ( pVoxel1nx1ny0pz) - weights[2][0][0] * - ( pVoxel1nx1ny1pz) + weights[0][2][0] * ( pVoxel1nx1py1nz) + - weights[1][2][0] * ( pVoxel1nx1py0pz) + weights[2][2][0] * - ( pVoxel1nx1py1pz) - weights[0][0][1] * ( pVoxel0px1ny1nz) - - weights[1][0][1] * ( pVoxel0px1ny0pz) - weights[2][0][1] * - ( pVoxel0px1ny1pz) + weights[0][2][1] * ( pVoxel0px1py1nz) + - weights[1][2][1] * ( pVoxel0px1py0pz) + weights[2][2][1] * - ( pVoxel0px1py1pz) - weights[0][0][2] * ( pVoxel1px1ny1nz) - - weights[1][0][2] * ( pVoxel1px1ny0pz) - weights[2][0][2] * - ( pVoxel1px1ny1pz) + weights[0][2][2] * ( pVoxel1px1py1nz) + - weights[1][2][2] * ( pVoxel1px1py0pz) + weights[2][2][2] * - ( pVoxel1px1py1pz)); - - const int zGrad(- weights[0][0][0] * ( pVoxel1nx1ny1nz) + - weights[2][0][0] * ( pVoxel1nx1ny1pz) - weights[0][1][0] * - ( pVoxel1nx0py1nz) + weights[2][1][0] * ( pVoxel1nx0py1pz) - - weights[0][2][0] * ( pVoxel1nx1py1nz) + weights[2][2][0] * - ( pVoxel1nx1py1pz) - weights[0][0][1] * ( pVoxel0px1ny1nz) + - weights[2][0][1] * ( pVoxel0px1ny1pz) - weights[0][1][1] * - ( pVoxel0px0py1nz) + weights[2][1][1] * ( pVoxel0px0py1pz) - - weights[0][2][1] * ( pVoxel0px1py1nz) + weights[2][2][1] * - ( pVoxel0px1py1pz) - weights[0][0][2] * ( pVoxel1px1ny1nz) + - weights[2][0][2] * ( pVoxel1px1ny1pz) - weights[0][1][2] * - ( pVoxel1px0py1nz) + weights[2][1][2] * ( pVoxel1px0py1pz) - - weights[0][2][2] * ( pVoxel1px1py1nz) + weights[2][2][2] * - ( pVoxel1px1py1pz)); - - return Vector3DFloat(xGrad,yGrad,zGrad); - } - - template - uint16_t VolumeIterator::getPosX(void) + uint16_t VolumeIterator::getPosX(void) const { return mXPosInVolume; } template - uint16_t VolumeIterator::getPosY(void) + uint16_t VolumeIterator::getPosY(void) const { return mYPosInVolume; } template - uint16_t VolumeIterator::getPosZ(void) + uint16_t VolumeIterator::getPosZ(void) const { return mZPosInVolume; } diff --git a/source/PolyVoxSceneManager.cpp b/source/PolyVoxSceneManager.cpp index b5784f6b..5b54d321 100644 --- a/source/PolyVoxSceneManager.cpp +++ b/source/PolyVoxSceneManager.cpp @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ******************************************************************************/ +#include "GradientEstimators.h" #include "IndexedSurfacePatch.h" #include "MarchingCubesTables.h" #include "PolyVoxSceneManager.h" @@ -561,7 +562,7 @@ namespace PolyVox if(normalGenerationMethod == SOBEL) { volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); - const Vector3DFloat gradFloor = volIter.getSobelGradient(); + const Vector3DFloat gradFloor = computeSobelGradient(volIter); if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { volIter.setPosition(static_cast(posX+1.0),static_cast(posY),static_cast(posZ)); @@ -574,7 +575,7 @@ namespace PolyVox { volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ+1.0)); } - const Vector3DFloat gradCeil = volIter.getSobelGradient(); + const Vector3DFloat gradCeil = computeSobelGradient(volIter); result = ((gradFloor + gradCeil) * -1.0); if(result.lengthSquared() < 0.0001) { @@ -585,7 +586,7 @@ namespace PolyVox if(normalGenerationMethod == CENTRAL_DIFFERENCE) { volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); - const Vector3DFloat gradFloor = volIter.getCentralDifferenceGradient(); + const Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter); if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { volIter.setPosition(static_cast(posX+1.0),static_cast(posY),static_cast(posZ)); @@ -598,7 +599,7 @@ namespace PolyVox { volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ+1.0)); } - const Vector3DFloat gradCeil = volIter.getCentralDifferenceGradient(); + const Vector3DFloat gradCeil = computeCentralDifferenceGradient(volIter); result = ((gradFloor + gradCeil) * -1.0); if(result.lengthSquared() < 0.0001) {