Add debug code for implicit normals

This commit is contained in:
Théophile Bastian 2018-02-13 14:02:20 +01:00
parent 385a03ddbc
commit d282b93298

View file

@ -2,6 +2,8 @@
#include <cassert> #include <cassert>
#include "GL/gl.h"
MarchingCubes::MarchingCubes( MarchingCubes::MarchingCubes(
const ImplicitSurface& surface, const ImplicitSurface& surface,
const Cuboid& box, const Cuboid& box,
@ -86,8 +88,24 @@ bool MarchingCubes::march_at(double x, double y, double z, Mesh& output) {
}; };
size_t vert_ids[3]; size_t vert_ids[3];
for(int i=0; i < 3; ++i) for(int i=0; i < 3; ++i) {
#ifdef DEBUG_DISPLAY_NORMAL
Point locVert = verts[i] + surface.getCenter();
Point normal = surface.normal_at(verts[i]);
Point outwards = locVert + normal;
Point inwards = locVert + ((-0.2) * normal);
glBegin(GL_LINES);
glColor3f(1., 0., 0.);
glVertex3f(locVert[0], locVert[1], locVert[2]);
glVertex3f(outwards[0], outwards[1], outwards[2]);
glColor3f(0., 0., 1.);
glVertex3f(locVert[0], locVert[1], locVert[2]);
glVertex3f(inwards[0], inwards[1], inwards[2]);
glEnd();
#endif // DEBUG_DISPLAY_NORMAL
vert_ids[i] = output.add_vertice(verts[i]); vert_ids[i] = output.add_vertice(verts[i]);
}
for(int i=0; i < 3; ++i) { for(int i=0; i < 3; ++i) {
output.add_face( output.add_face(