diff --git a/draw.cpp b/draw.cpp index 41a5dda..1721a35 100644 --- a/draw.cpp +++ b/draw.cpp @@ -960,9 +960,14 @@ void GraphicsWindow::Paint(int w, int h) { GLfloat ld1[4] = { (GLfloat)ld.x, (GLfloat)ld.y, (GLfloat)ld.z, 0 }; glLightfv(GL_LIGHT1, GL_POSITION, ld1); - // For debugging, draw the backs of the triangles in red, so that we - // notice when a shell is open - glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 1); + if(SS.drawBackFaces) { + // For debugging, draw the backs of the triangles in red, so that we + // notice when a shell is open + glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 1); + } else { + glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0); + } + GLfloat ambient[4] = { 0.4f, 0.4f, 0.4f, 1.0f }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); diff --git a/solvespace.cpp b/solvespace.cpp index 03e169b..ffcf987 100644 --- a/solvespace.cpp +++ b/solvespace.cpp @@ -49,6 +49,8 @@ void SolveSpace::Init(char *cmdLine) { edgeColor = CnfThawDWORD(RGB(0, 0, 0), "EdgeColor"); // Export scale factor exportScale = CnfThawFloat(1.0f, "ExportScale"); + // Draw back faces of triangles (when mesh is leaky/self-intersecting) + drawBackFaces = CnfThawDWORD(1, "DrawBackFaces"); // Recent files menus for(i = 0; i < MAX_RECENT; i++) { char name[100]; @@ -107,6 +109,8 @@ void SolveSpace::Exit(void) { CnfFreezeDWORD(edgeColor, "EdgeColor"); // Export scale (a float, stored as a DWORD) CnfFreezeFloat(exportScale, "ExportScale"); + // Draw back faces of triangles (when mesh is leaky/self-intersecting) + CnfFreezeDWORD(drawBackFaces, "DrawBackFaces"); ExitNow(); } diff --git a/solvespace.h b/solvespace.h index d9a1a26..c06aae2 100644 --- a/solvespace.h +++ b/solvespace.h @@ -370,6 +370,7 @@ public: double cameraTangent; DWORD edgeColor; float exportScale; + int drawBackFaces; int CircleSides(double r); typedef enum { diff --git a/textscreens.cpp b/textscreens.cpp index a10f5d7..ceb2eb1 100644 --- a/textscreens.cpp +++ b/textscreens.cpp @@ -595,6 +595,10 @@ void TextWindow::ScreenChangeExportScale(int link, DWORD v) { ShowTextEditControl(59, 3, str); SS.TW.edit.meaning = EDIT_EXPORT_SCALE; } +void TextWindow::ScreenChangeBackFaces(int link, DWORD v) { + SS.drawBackFaces = !SS.drawBackFaces; + InvalidateGraphics(); +} void TextWindow::ShowConfiguration(void) { int i; Printf(true, "%Ft material color-(r, g, b)"); @@ -648,6 +652,14 @@ void TextWindow::ShowConfiguration(void) { Printf(false, "%Ba %3 %Fl%Ll%f%D[change]%E", (double)SS.exportScale, &ScreenChangeExportScale, 0); + + Printf(false, ""); + Printf(false, "%Ft draw back faces: " + "%Fh%f%Ll%s%E%Fs%s%E / %Fh%f%Ll%s%E%Fs%s%E", + &ScreenChangeBackFaces, + (SS.drawBackFaces ? "" : "yes"), (SS.drawBackFaces ? "yes" : ""), + &ScreenChangeBackFaces, + (!SS.drawBackFaces ? "" : "no"), (!SS.drawBackFaces ? "no" : "")); } //----------------------------------------------------------------------------- diff --git a/ui.h b/ui.h index 3259607..d446db7 100644 --- a/ui.h +++ b/ui.h @@ -139,6 +139,8 @@ public: static void ScreenShowConfiguration(int link, DWORD v); static void ScreenGoToWebsite(int link, DWORD v); + static void ScreenChangeBackFaces(int link, DWORD v); + static void ScreenStepDimSteps(int link, DWORD v); static void ScreenStepDimFinish(int link, DWORD v); static void ScreenStepDimGo(int link, DWORD v);