Moved gradient calculation outside of class.
This commit is contained in:
		@@ -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<float>(controller.convertToDensity(volIter.peekVoxel1nx0py0pz()));
 | 
			
		||||
			float voxel1px = static_cast<float>(controller.convertToDensity(volIter.peekVoxel1px0py0pz()));
 | 
			
		||||
 | 
			
		||||
			float voxel1ny = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px1ny0pz()));
 | 
			
		||||
			float voxel1py = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px1py0pz()));
 | 
			
		||||
 | 
			
		||||
			float voxel1nz = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px0py1nz()));
 | 
			
		||||
			float voxel1pz = static_cast<float>(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.
 | 
			
		||||
 
 | 
			
		||||
@@ -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<float>(controller.convertToDensity(volIter.peekVoxel1nx0py0pz()));
 | 
			
		||||
		float voxel1px = static_cast<float>(controller.convertToDensity(volIter.peekVoxel1px0py0pz()));
 | 
			
		||||
 | 
			
		||||
		float voxel1ny = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px1ny0pz()));
 | 
			
		||||
		float voxel1py = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px1py0pz()));
 | 
			
		||||
 | 
			
		||||
		float voxel1nz = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px0py1nz()));
 | 
			
		||||
		float voxel1pz = static_cast<float>(controller.convertToDensity(volIter.peekVoxel0px0py1pz()));
 | 
			
		||||
 | 
			
		||||
		return Vector3DFloat
 | 
			
		||||
			(
 | 
			
		||||
			voxel1nx - voxel1px,
 | 
			
		||||
			voxel1ny - voxel1py,
 | 
			
		||||
			voxel1nz - voxel1pz
 | 
			
		||||
			);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	template<typename VolumeType, typename MeshType, typename ControllerType>
 | 
			
		||||
	MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::MarchingCubesSurfaceExtractor()
 | 
			
		||||
	{		
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user