47 |
47 |
48 CFGENTRY (String, SelectColorBlend, "#0080FF") |
48 CFGENTRY (String, SelectColorBlend, "#0080FF") |
49 EXTERN_CFGENTRY (Bool, BlackEdges) |
49 EXTERN_CFGENTRY (Bool, BlackEdges) |
50 EXTERN_CFGENTRY (String, BackgroundColor) |
50 EXTERN_CFGENTRY (String, BackgroundColor) |
51 |
51 |
52 static QList<int> g_warnedColors; |
|
53 static const QColor g_BFCFrontColor (64, 192, 80); |
|
54 static const QColor g_BFCBackColor (208, 64, 64); |
|
55 |
|
56 // static QMap<LDObjectPtr, String> g_objectOrigins; |
52 // static QMap<LDObjectPtr, String> g_objectOrigins; |
57 |
53 |
58 // ============================================================================= |
54 // ============================================================================= |
59 // |
55 // |
60 void CheckGLErrorImpl (const char* file, int line) |
56 void CheckGLErrorImpl (const char* file, int line) |
133 // ============================================================================= |
129 // ============================================================================= |
134 // |
130 // |
135 QColor GLCompiler::getColorForPolygon (LDPolygon& poly, LDObjectPtr topobj, |
131 QColor GLCompiler::getColorForPolygon (LDPolygon& poly, LDObjectPtr topobj, |
136 EVBOComplement complement) const |
132 EVBOComplement complement) const |
137 { |
133 { |
|
134 static const QColor bfcFrontColor (64, 192, 80); |
|
135 static const QColor bfcBackColor (208, 64, 64); |
|
136 static const QColor bfcDisabledColor (64, 64, 208); |
|
137 static QList<int> warnedcolors; |
138 QColor qcol; |
138 QColor qcol; |
|
139 print ("Winding of %1 is %2", poly.id, (int) poly.winding); |
139 |
140 |
140 switch (complement) |
141 switch (complement) |
141 { |
142 { |
142 case VBOCM_Surfaces: |
143 case VBOCM_Surfaces: |
143 case VBOCM_NumComplements: |
144 case VBOCM_NumComplements: |
144 return QColor(); |
145 return QColor(); |
145 |
146 |
146 case VBOCM_BFCFrontColors: |
147 case VBOCM_BFCFrontColors: |
147 qcol = g_BFCFrontColor; |
148 qcol = (poly.winding != Winding::None) ? bfcFrontColor : bfcDisabledColor; |
148 break; |
149 break; |
149 |
150 |
150 case VBOCM_BFCBackColors: |
151 case VBOCM_BFCBackColors: |
151 qcol = g_BFCBackColor; |
152 qcol = (poly.winding != Winding::None) ? bfcBackColor : bfcDisabledColor; |
152 break; |
153 break; |
153 |
154 |
154 case VBOCM_PickColors: |
155 case VBOCM_PickColors: |
155 return indexColorForID (topobj->id()); |
156 return indexColorForID (topobj->id()); |
156 |
157 |
182 |
183 |
183 if (not qcol.isValid()) |
184 if (not qcol.isValid()) |
184 { |
185 { |
185 // The color was unknown. Use main color to make the polygon at least |
186 // The color was unknown. Use main color to make the polygon at least |
186 // not appear pitch-black. |
187 // not appear pitch-black. |
187 if (poly.num != 2 and poly.num != 5) |
188 qcol = (poly.num != 2 and poly.num != 5) ? GLRenderer::getMainColor() : Qt::black; |
188 qcol = GLRenderer::getMainColor(); |
|
189 else |
|
190 qcol = Qt::black; |
|
191 |
189 |
192 // Warn about the unknown color, but only once. |
190 // Warn about the unknown color, but only once. |
193 if (not g_warnedColors.contains (poly.color)) |
191 if (not warnedcolors.contains (poly.color)) |
194 { |
192 { |
195 print ("Unknown color %1!\n", poly.color); |
193 print ("Unknown color %1!\n", poly.color); |
196 g_warnedColors << poly.color; |
194 warnedcolors << poly.color; |
197 } |
195 } |
198 |
196 |
199 return qcol; |
197 return qcol; |
200 } |
198 } |
201 |
199 |
387 { |
385 { |
388 const int vbonum = vboNumber (surface, complement); |
386 const int vbonum = vboNumber (surface, complement); |
389 QVector<GLfloat>& vbodata = objinfo->data[vbonum]; |
387 QVector<GLfloat>& vbodata = objinfo->data[vbonum]; |
390 const QColor color = getColorForPolygon (poly, topobj, complement); |
388 const QColor color = getColorForPolygon (poly, topobj, complement); |
391 |
389 |
392 for (int vert = 0; vert < numverts; ++vert) |
390 bool inverted = (poly.winding != Winding::CCW); |
|
391 |
|
392 auto func = [&](int vert) |
393 { |
393 { |
394 if (complement == VBOCM_Surfaces) |
394 if (complement == VBOCM_Surfaces) |
395 { |
395 { |
396 // Write coordinates. Apparently Z must be flipped too? |
396 // Write coordinates. Apparently Z must be flipped too? |
397 vbodata << poly.vertices[vert].x() |
397 vbodata << poly.vertices[vert].x() |
403 vbodata << ((GLfloat) color.red()) / 255.0f |
403 vbodata << ((GLfloat) color.red()) / 255.0f |
404 << ((GLfloat) color.green()) / 255.0f |
404 << ((GLfloat) color.green()) / 255.0f |
405 << ((GLfloat) color.blue()) / 255.0f |
405 << ((GLfloat) color.blue()) / 255.0f |
406 << ((GLfloat) color.alpha()) / 255.0f; |
406 << ((GLfloat) color.alpha()) / 255.0f; |
407 } |
407 } |
|
408 }; |
|
409 |
|
410 if (not inverted) |
|
411 { |
|
412 for (int vert = 0; vert < numverts; ++vert) |
|
413 func (vert); |
|
414 } |
|
415 else |
|
416 { |
|
417 for (int vert = numverts - 1; vert >= 0; --vert) |
|
418 func (vert); |
408 } |
419 } |
409 } |
420 } |
410 } |
421 } |
411 |
422 |
412 void GLCompiler::setRenderer (GLRenderer* renderer) |
423 void GLCompiler::setRenderer (GLRenderer* renderer) |