230 } |
230 } |
231 |
231 |
232 static QColor getColorForPolygon( |
232 static QColor getColorForPolygon( |
233 const gl::Polygon& polygon, |
233 const gl::Polygon& polygon, |
234 const gl::RenderPreferences& preferences, |
234 const gl::RenderPreferences& preferences, |
235 const ldraw::ColorTable& colorTable) |
235 const ColorTable& colorTable) |
236 { |
236 { |
237 QColor color; |
237 QColor color; |
238 // For normal colors, use the polygon's color. |
238 // For normal colors, use the polygon's color. |
239 if (polygon.color == ldraw::MAIN_COLOR) |
239 if (polygon.color == MAIN_COLOR) |
240 { |
240 { |
241 color = preferences.mainColor; |
241 color = preferences.mainColor; |
242 } |
242 } |
243 else if (polygon.color == ldraw::EDGE_COLOR) |
243 else if (polygon.color == EDGE_COLOR) |
244 { |
244 { |
245 // Edge color is black, unless we have a dark background, in which case lines need to be bright. |
245 // Edge color is black, unless we have a dark background, in which case lines need to be bright. |
246 color = luma(preferences.backgroundColor) > (40.0 / 256.0) ? Qt::black : Qt::white; |
246 color = luma(preferences.backgroundColor) > (40.0 / 256.0) ? Qt::black : Qt::white; |
247 } |
247 } |
248 else |
248 else |
249 { |
249 { |
250 // Not main or edge color, use the polygon's color as is. |
250 // Not main or edge color, use the polygon's color as is. |
251 color = colorTable[polygon.color].faceColor; |
251 color = colorFace(polygon.color, colorTable).value_or(Qt::black); |
252 } |
252 } |
253 return color; |
253 return color; |
254 } |
254 } |
255 |
255 |
256 /** |
256 /** |
273 * @brief gl::build Creates GL vertices for objects in the model and buffers them to shaders. |
273 * @brief gl::build Creates GL vertices for objects in the model and buffers them to shaders. |
274 */ |
274 */ |
275 void gl::build( |
275 void gl::build( |
276 gl::ModelShaders* shaders, |
276 gl::ModelShaders* shaders, |
277 Model* model, |
277 Model* model, |
278 const ldraw::ColorTable& colorTable, |
278 const ColorTable& colorTable, |
279 DocumentManager* context, |
279 DocumentManager* context, |
280 const gl::RenderPreferences& preferences) |
280 const gl::RenderPreferences& preferences) |
281 { |
281 { |
282 for (gl::ModelShaders::ShaderObject& shader : shaders->shaderObjects) { |
282 for (gl::ModelShaders::ShaderObject& shader : shaders->shaderObjects) { |
283 shader.cachedData.clear(); |
283 shader.cachedData.clear(); |