From 5c239e7868842195189c9c5782ba8a07c948f1e5 Mon Sep 17 00:00:00 2001 From: clifford Date: Thu, 2 Jul 2009 21:21:05 +0000 Subject: Clifford Wolf: Don't try rendering a CSG tree with more than 1000 elements. git-svn-id: http://svn.clifford.at/openscad/trunk@48 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/mainwin.cc b/mainwin.cc index fa3a970..63cb35b 100644 --- a/mainwin.cc +++ b/mainwin.cc @@ -50,6 +50,7 @@ MainWindow::MainWindow(const char *filename) highlights_chain = NULL; root_node = NULL; + enableOpenCSG = false; s1 = new QSplitter(Qt::Horizontal, this); editor = new QTextEdit(s1); @@ -247,6 +248,7 @@ void MainWindow::compile() highlights_chain = NULL; } root_node = NULL; + enableOpenCSG = false; root_module = parse(editor->toPlainText().toAscii().data(), false); @@ -301,6 +303,13 @@ void MainWindow::compile() root_chain = new CSGChain(); root_chain->import(root_norm_term); + if (root_chain->polysets.size() > 1000) { + PRINTF("WARNING: Normalized tree has %d elements!", root_chain->polysets.size()); + PRINTF("WARNING: OpenCSG rendering has been disabled."); + } else { + enableOpenCSG = true; + } + if (highlight_terms.size() > 0) { PRINTF("Compiling highlights (%d CSG Trees)...", highlight_terms.size()); @@ -321,9 +330,11 @@ void MainWindow::compile() if (1) { PRINT("Compilation finished."); + QApplication::processEvents(); } else { fail: PRINT("ERROR: Compilation failed!"); + QApplication::processEvents(); } } @@ -515,6 +526,7 @@ static void report_func(const class AbstractNode*, void *vp, int mark) void MainWindow::actionRenderCGAL() { current_win = this; + console->clear(); compile(); @@ -656,7 +668,7 @@ static void renderCSGChainviaOpenCSG(CSGChain *chain, GLint *shaderinfo, bool hi if (last || chain->types[i] == CSGTerm::UNION) { - OpenCSG::render(primitives, OpenCSG::Goldfeather, OpenCSG::NoDepthComplexitySampling); + OpenCSG::render(primitives); glDepthFunc(GL_EQUAL); if (shaderinfo) glUseProgram(shaderinfo[0]); @@ -688,9 +700,15 @@ static void renderCSGChainviaOpenCSG(CSGChain *chain, GLint *shaderinfo, bool hi } } +static void renderGLThrownTogether(void *vp); + static void renderGLviaOpenCSG(void *vp) { MainWindow *m = (MainWindow*)vp; + if (!m->enableOpenCSG) { + renderGLThrownTogether(vp); + return; + } static int glew_initialized = 0; if (!glew_initialized) { glew_initialized = 1; diff --git a/openscad.h b/openscad.h index 4ad5765..27b0c70 100644 --- a/openscad.h +++ b/openscad.h @@ -500,6 +500,7 @@ public: QVector highlight_terms; CSGChain *highlights_chain; AbstractNode *root_node; + bool enableOpenCSG; MainWindow(const char *filename = 0); ~MainWindow(); -- cgit v0.10.1