Separated gradient estimation code.

This commit is contained in:
David Williams 2008-04-20 21:58:14 +00:00
parent 286ba35b42
commit 83d6a7327b
6 changed files with 152 additions and 157 deletions

View File

@ -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

View File

@ -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 <typename VoxelType>
Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator<VoxelType>& volIter);
template <typename VoxelType>
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& volIter);
}
#include "GradientEstimators.inl"
#endif //__PolyVox_GradientEstimators_H__

View File

@ -0,0 +1,119 @@
namespace PolyVox
{
template <typename VoxelType>
Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator<VoxelType>& 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 <typename VoxelType>
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& 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);
}
}

View File

@ -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);

View File

@ -131,161 +131,19 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat VolumeIterator<VoxelType>::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 <typename VoxelType>
Vector3DFloat VolumeIterator<VoxelType>::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 <typename VoxelType>
Vector3DFloat VolumeIterator<VoxelType>::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 <typename VoxelType>
uint16_t VolumeIterator<VoxelType>::getPosX(void)
uint16_t VolumeIterator<VoxelType>::getPosX(void) const
{
return mXPosInVolume;
}
template <typename VoxelType>
uint16_t VolumeIterator<VoxelType>::getPosY(void)
uint16_t VolumeIterator<VoxelType>::getPosY(void) const
{
return mYPosInVolume;
}
template <typename VoxelType>
uint16_t VolumeIterator<VoxelType>::getPosZ(void)
uint16_t VolumeIterator<VoxelType>::getPosZ(void) const
{
return mZPosInVolume;
}

View File

@ -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<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(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<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
@ -574,7 +575,7 @@ namespace PolyVox
{
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(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<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(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<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
@ -598,7 +599,7 @@ namespace PolyVox
{
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
}
const Vector3DFloat gradCeil = volIter.getCentralDifferenceGradient();
const Vector3DFloat gradCeil = computeCentralDifferenceGradient(volIter);
result = ((gradFloor + gradCeil) * -1.0);
if(result.lengthSquared() < 0.0001)
{