Here is another fix for when using float volumes. this time the bug is when extracting the surface of a float type volume the normals all end up 0,0,0.
After some playing around here is a simple fix. At line 62 of SurfaceExtractor.h
Code:
Vector3DFloat computeCentralDifferenceGradient(const typename VolumeType<VoxelType>::Sampler& volIter)
{
float voxel1nx = static_cast<float>(volIter.peekVoxel1nx0py0pz().getDensity());
float voxel1px = static_cast<float>(volIter.peekVoxel1px0py0pz().getDensity());
float voxel1ny = static_cast<float>(volIter.peekVoxel0px1ny0pz().getDensity());
float voxel1py = static_cast<float>(volIter.peekVoxel0px1py0pz().getDensity());
float voxel1nz = static_cast<float>(volIter.peekVoxel0px0py1nz().getDensity());
float voxel1pz = static_cast<float>(volIter.peekVoxel0px0py1pz().getDensity());
return Vector3DFloat
(
voxel1nx - voxel1px,
voxel1ny - voxel1py,
voxel1nz - voxel1pz
);
}
All I did was move the static_casts to where the values are allocated to the variables, and turned the variables into type float.
Also these last couple of fixes I posted up are my very first 'contribution' to OSS :3
[edit] This patch also solves normal calculations with densities with negative density:
Incorrect normals:
http://66.240.163.101/withUint.jpgCorrect normals:
http://66.240.163.101/withint.jpg