Got mesh smoothing working.
Cleaning up code. Various changes made without internet access.
This commit is contained in:
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -21,6 +42,37 @@ namespace PolyVox
|
||||
);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeIterator<VoxelType>& volIter)
|
||||
{
|
||||
boost::uint16_t initialX = volIter.getPosX();
|
||||
boost::uint16_t initialY = volIter.getPosY();
|
||||
boost::uint16_t initialZ = volIter.getPosZ();
|
||||
|
||||
//FIXME - bitwise way of doing this?
|
||||
volIter.setPosition(initialX-1, initialY, initialZ);
|
||||
float voxel1nx = volIter.getAveragedVoxel(1);
|
||||
volIter.setPosition(initialX+1, initialY, initialZ);
|
||||
float voxel1px = volIter.getAveragedVoxel(1);
|
||||
|
||||
volIter.setPosition(initialX, initialY-1, initialZ);
|
||||
float voxel1ny = volIter.getAveragedVoxel(1);
|
||||
volIter.setPosition(initialX, initialY+1, initialZ);
|
||||
float voxel1py = volIter.getAveragedVoxel(1);
|
||||
|
||||
volIter.setPosition(initialX, initialY, initialZ-1);
|
||||
float voxel1nz = volIter.getAveragedVoxel(1);
|
||||
volIter.setPosition(initialX, initialY, initialZ+1);
|
||||
float voxel1pz = volIter.getAveragedVoxel(1);
|
||||
|
||||
return Vector3DFloat
|
||||
(
|
||||
voxel1px - voxel1nx,
|
||||
voxel1py - voxel1ny,
|
||||
voxel1pz - voxel1nz
|
||||
);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& volIter)
|
||||
{
|
||||
|
Reference in New Issue
Block a user