diff -r d820588bf4f1 -r 9c4fc9b433ae src/glCompiler.cc --- a/src/glCompiler.cc Sun Sep 07 04:15:54 2014 +0300 +++ b/src/glCompiler.cc Sun Sep 07 18:41:23 2014 +0300 @@ -49,10 +49,6 @@ EXTERN_CFGENTRY (Bool, BlackEdges) EXTERN_CFGENTRY (String, BackgroundColor) -static QList g_warnedColors; -static const QColor g_BFCFrontColor (64, 192, 80); -static const QColor g_BFCBackColor (208, 64, 64); - // static QMap g_objectOrigins; // ============================================================================= @@ -135,7 +131,12 @@ QColor GLCompiler::getColorForPolygon (LDPolygon& poly, LDObjectPtr topobj, EVBOComplement complement) const { + static const QColor bfcFrontColor (64, 192, 80); + static const QColor bfcBackColor (208, 64, 64); + static const QColor bfcDisabledColor (64, 64, 208); + static QList warnedcolors; QColor qcol; + print ("Winding of %1 is %2", poly.id, (int) poly.winding); switch (complement) { @@ -144,11 +145,11 @@ return QColor(); case VBOCM_BFCFrontColors: - qcol = g_BFCFrontColor; + qcol = (poly.winding != Winding::None) ? bfcFrontColor : bfcDisabledColor; break; case VBOCM_BFCBackColors: - qcol = g_BFCBackColor; + qcol = (poly.winding != Winding::None) ? bfcBackColor : bfcDisabledColor; break; case VBOCM_PickColors: @@ -184,16 +185,13 @@ { // The color was unknown. Use main color to make the polygon at least // not appear pitch-black. - if (poly.num != 2 and poly.num != 5) - qcol = GLRenderer::getMainColor(); - else - qcol = Qt::black; + qcol = (poly.num != 2 and poly.num != 5) ? GLRenderer::getMainColor() : Qt::black; // Warn about the unknown color, but only once. - if (not g_warnedColors.contains (poly.color)) + if (not warnedcolors.contains (poly.color)) { print ("Unknown color %1!\n", poly.color); - g_warnedColors << poly.color; + warnedcolors << poly.color; } return qcol; @@ -389,7 +387,9 @@ QVector& vbodata = objinfo->data[vbonum]; const QColor color = getColorForPolygon (poly, topobj, complement); - for (int vert = 0; vert < numverts; ++vert) + bool inverted = (poly.winding != Winding::CCW); + + auto func = [&](int vert) { if (complement == VBOCM_Surfaces) { @@ -405,6 +405,17 @@ << ((GLfloat) color.blue()) / 255.0f << ((GLfloat) color.alpha()) / 255.0f; } + }; + + if (not inverted) + { + for (int vert = 0; vert < numverts; ++vert) + func (vert); + } + else + { + for (int vert = numverts - 1; vert >= 0; --vert) + func (vert); } } }