diff --git a/include/PolyVox/MarchingCubesSurfaceExtractor.h b/include/PolyVox/MarchingCubesSurfaceExtractor.h index dde8acdf..ee6fd518 100644 --- a/include/PolyVox/MarchingCubesSurfaceExtractor.h +++ b/include/PolyVox/MarchingCubesSurfaceExtractor.h @@ -156,37 +156,6 @@ namespace PolyVox MarchingCubesSurfaceExtractor(); void execute(VolumeType* volData, Region region, MeshType* result, ControllerType controller); - - private: - - //////////////////////////////////////////////////////////////////////////////// - // 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. - //////////////////////////////////////////////////////////////////////////////// - Vector3DFloat computeCentralDifferenceGradient(const typename VolumeType::Sampler& volIter, ControllerType& controller) - { - //FIXME - Should actually use DensityType here, both in principle and because the maths may be - //faster (and to reduce casts). So it would be good to add a way to get DensityType from a voxel. - //But watch out for when the DensityType is unsigned and the difference could be negative. - float voxel1nx = static_cast(controller.convertToDensity(volIter.peekVoxel1nx0py0pz())); - float voxel1px = static_cast(controller.convertToDensity(volIter.peekVoxel1px0py0pz())); - - float voxel1ny = static_cast(controller.convertToDensity(volIter.peekVoxel0px1ny0pz())); - float voxel1py = static_cast(controller.convertToDensity(volIter.peekVoxel0px1py0pz())); - - float voxel1nz = static_cast(controller.convertToDensity(volIter.peekVoxel0px0py1nz())); - float voxel1pz = static_cast(controller.convertToDensity(volIter.peekVoxel0px0py1pz())); - - return Vector3DFloat - ( - voxel1nx - voxel1px, - voxel1ny - voxel1py, - voxel1nz - voxel1pz - ); - } - //////////////////////////////////////////////////////////////////////////////// - // End of compiler bug workaroumd. - //////////////////////////////////////////////////////////////////////////////// }; // This version of the function performs the extraction into a user-provided mesh rather than allocating a mesh automatically. diff --git a/include/PolyVox/MarchingCubesSurfaceExtractor.inl b/include/PolyVox/MarchingCubesSurfaceExtractor.inl index e70b7374..0ed3d28d 100644 --- a/include/PolyVox/MarchingCubesSurfaceExtractor.inl +++ b/include/PolyVox/MarchingCubesSurfaceExtractor.inl @@ -25,6 +25,29 @@ freely, subject to the following restrictions: namespace PolyVox { + template< typename Sampler, typename ControllerType> + Vector3DFloat computeCentralDifferenceGradient(const Sampler& volIter, ControllerType& controller) + { + //FIXME - Should actually use DensityType here, both in principle and because the maths may be + //faster (and to reduce casts). So it would be good to add a way to get DensityType from a voxel. + //But watch out for when the DensityType is unsigned and the difference could be negative. + float voxel1nx = static_cast(controller.convertToDensity(volIter.peekVoxel1nx0py0pz())); + float voxel1px = static_cast(controller.convertToDensity(volIter.peekVoxel1px0py0pz())); + + float voxel1ny = static_cast(controller.convertToDensity(volIter.peekVoxel0px1ny0pz())); + float voxel1py = static_cast(controller.convertToDensity(volIter.peekVoxel0px1py0pz())); + + float voxel1nz = static_cast(controller.convertToDensity(volIter.peekVoxel0px0py1nz())); + float voxel1pz = static_cast(controller.convertToDensity(volIter.peekVoxel0px0py1pz())); + + return Vector3DFloat + ( + voxel1nx - voxel1px, + voxel1ny - voxel1py, + voxel1nz - voxel1pz + ); + } + template MarchingCubesSurfaceExtractor::MarchingCubesSurfaceExtractor() {