diff --git a/common/lc_global.h b/common/lc_global.h index c827691e..25b63144 100644 --- a/common/lc_global.h +++ b/common/lc_global.h @@ -66,6 +66,7 @@ typedef std::map> lcPartsList; struct lcModelPartsEntry; struct lcMinifig; enum class lcViewpoint; +enum class lcShadingMode; class lcInstructions; struct lcInstructionsPageSetup; struct lcObjectRayTest; diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 03a6ad86..b4c5b5dc 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1389,7 +1389,13 @@ QImage lcModel::GetPartsListImage(int MaxWidth, lcStep Step) const Context->ClearColorAndDepth(lcVector4(1.0f, 1.0f, 1.0f, 0.0f)); lcScene Scene; - Scene.SetAllowWireframe(false); + + const lcPreferences& Preferences = lcGetPreferences(); + lcShadingMode ShadingMode = Preferences.mShadingMode; + if (ShadingMode == lcShadingMode::Wireframe) + ShadingMode = lcShadingMode::Flat; + + Scene.SetShadingMode(ShadingMode); Scene.SetAllowLOD(false); Scene.Begin(ViewMatrix); diff --git a/common/lc_scene.cpp b/common/lc_scene.cpp index 6897bc01..0415745a 100644 --- a/common/lc_scene.cpp +++ b/common/lc_scene.cpp @@ -12,7 +12,7 @@ lcScene::lcScene() { mActiveSubmodelInstance = nullptr; mDrawInterface = false; - mAllowWireframe = true; + mShadingMode = lcShadingMode::DefaultLights; mAllowLOD = true; mMeshLODDistance = 250.0f; mHasFadedParts = false; @@ -207,10 +207,20 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy switch (RenderMesh.State) { case lcRenderMeshState::Default: - if (ColorIndex == gEdgeColor) - Context->SetEdgeColorIndex(RenderMesh.ColorIndex); + if (mShadingMode != lcShadingMode::Wireframe) + { + if (ColorIndex != gEdgeColor) + Context->SetColorIndex(ColorIndex); + else + Context->SetEdgeColorIndex(RenderMesh.ColorIndex); + } else + { + if (ColorIndex == gEdgeColor) + ColorIndex = RenderMesh.ColorIndex; + Context->SetColorIndex(ColorIndex); + } break; case lcRenderMeshState::Selected: @@ -423,11 +433,11 @@ void lcScene::Draw(lcContext* Context) const constexpr bool DrawConditional = false; const lcPreferences& Preferences = lcGetPreferences(); - lcShadingMode ShadingMode = Preferences.mShadingMode; - if (ShadingMode == lcShadingMode::Wireframe && !mAllowWireframe) - ShadingMode = lcShadingMode::Flat; +// lcShadingMode ShadingMode = Preferences.mShadingMode; +// if (ShadingMode == lcShadingMode::Wireframe && !mAllowWireframe) +// ShadingMode = lcShadingMode::Flat; - if (ShadingMode == lcShadingMode::Wireframe) + if (mShadingMode == lcShadingMode::Wireframe) { int PrimitiveTypes = LC_MESH_LINES; @@ -439,7 +449,7 @@ void lcScene::Draw(lcContext* Context) const if (mPreTranslucentCallback) mPreTranslucentCallback(); } - else if (ShadingMode == lcShadingMode::Flat) + else if (mShadingMode == lcShadingMode::Flat) { const bool DrawLines = Preferences.mDrawEdgeLines && Preferences.mLineWidth != 0.0f; diff --git a/common/lc_scene.h b/common/lc_scene.h index 81ce728b..0e404dfb 100644 --- a/common/lc_scene.h +++ b/common/lc_scene.h @@ -59,9 +59,9 @@ public: return mDrawInterface; } - void SetAllowWireframe(bool AllowWireframe) + void SetShadingMode(lcShadingMode ShadingMode) { - mAllowWireframe = AllowWireframe; + mShadingMode = ShadingMode; } void SetAllowLOD(bool AllowLOD) @@ -104,8 +104,8 @@ protected: lcMatrix44 mViewMatrix; lcMatrix44 mActiveSubmodelTransform; lcPiece* mActiveSubmodelInstance; + lcShadingMode mShadingMode; bool mDrawInterface; - bool mAllowWireframe; bool mAllowLOD; float mMeshLODDistance; diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 58824338..573da7ad 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -835,7 +835,11 @@ void lcView::OnDraw() const bool DrawOverlays = mWidget != nullptr; const bool DrawInterface = mWidget != nullptr && mViewType == lcViewType::View; - mScene->SetAllowWireframe(mWidget != nullptr); + lcShadingMode ShadingMode = Preferences.mShadingMode; + if (ShadingMode == lcShadingMode::Wireframe && !mWidget) + ShadingMode = lcShadingMode::Flat; + + mScene->SetShadingMode(ShadingMode); mScene->SetAllowLOD(Preferences.mAllowLOD && mWidget != nullptr); mScene->SetLODDistance(Preferences.mMeshLODDistance);