diff --git a/common/lc_application.cpp b/common/lc_application.cpp index abcbe9d1..dcb65eaa 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -20,6 +20,7 @@ void lcPreferences::LoadDefaults() mDrawAxes = lcGetProfileInt(LC_PROFILE_DRAW_AXES); mDrawEdgeLines = lcGetProfileInt(LC_PROFILE_DRAW_EDGE_LINES); mLineWidth = lcGetProfileFloat(LC_PROFILE_LINE_WIDTH); + mAllowLOD = lcGetProfileFloat(LC_PROFILE_ALLOW_LOD); mDrawGridStuds = lcGetProfileInt(LC_PROFILE_GRID_STUDS); mGridStudColor = lcGetProfileInt(LC_PROFILE_GRID_STUD_COLOR); mDrawGridLines = lcGetProfileInt(LC_PROFILE_GRID_LINES); @@ -41,6 +42,7 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_DRAW_AXES, mDrawAxes); lcSetProfileInt(LC_PROFILE_DRAW_EDGE_LINES, mDrawEdgeLines); lcSetProfileFloat(LC_PROFILE_LINE_WIDTH, mLineWidth); + lcSetProfileInt(LC_PROFILE_ALLOW_LOD, mAllowLOD); lcSetProfileInt(LC_PROFILE_GRID_STUDS, mDrawGridStuds); lcSetProfileInt(LC_PROFILE_GRID_STUD_COLOR, mGridStudColor); lcSetProfileInt(LC_PROFILE_GRID_LINES, mDrawGridLines); diff --git a/common/lc_application.h b/common/lc_application.h index adad26d4..78706107 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -33,6 +33,7 @@ public: bool mDrawAxes; bool mDrawEdgeLines; float mLineWidth; + bool mAllowLOD; bool mDrawGridStuds; quint32 mGridStudColor; bool mDrawGridLines; diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index 0f0135b5..5d628bda 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -377,6 +377,7 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex) lcScene Scene; Scene.SetAllowWireframe(false); + Scene.SetAllowLOD(false); Scene.Begin(ViewMatrix); Info->AddRenderMeshes(Scene, lcMatrix44Identity(), mColorIndex, lcRenderMeshState::NORMAL, false); diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 58b353c4..e7f6f700 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -57,6 +57,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = { lcProfileEntry("Settings", "FixedAxes", false), // LC_PROFILE_FIXED_AXES lcProfileEntry("Settings", "LineWidth", 1.0f), // LC_PROFILE_LINE_WIDTH + lcProfileEntry("Settings", "AllowLOD", true), // LC_PROFILE_ALLOW_LOD lcProfileEntry("Settings", "ShadingMode", LC_SHADING_DEFAULT_LIGHTS), // LC_PROFILE_SHADING_MODE lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES lcProfileEntry("Settings", "DrawEdgeLines", 1), // LC_PROFILE_DRAW_EDGE_LINES diff --git a/common/lc_profile.h b/common/lc_profile.h index ffab40a5..eeef40ae 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -5,6 +5,7 @@ enum LC_PROFILE_KEY // Settings. LC_PROFILE_FIXED_AXES, LC_PROFILE_LINE_WIDTH, + LC_PROFILE_ALLOW_LOD, LC_PROFILE_SHADING_MODE, LC_PROFILE_DRAW_AXES, LC_PROFILE_DRAW_EDGE_LINES, diff --git a/common/lc_scene.cpp b/common/lc_scene.cpp index 19e05e3c..14f056c3 100644 --- a/common/lc_scene.cpp +++ b/common/lc_scene.cpp @@ -12,6 +12,7 @@ lcScene::lcScene() { mActiveSubmodelInstance = nullptr; mAllowWireframe = true; + mAllowLOD = true; } void lcScene::Begin(const lcMatrix44& ViewMatrix) @@ -60,7 +61,7 @@ void lcScene::AddMesh(lcMesh* Mesh, const lcMatrix44& WorldMatrix, int ColorInde RenderMesh.ColorIndex = ColorIndex; RenderMesh.State = State; float Distance = fabsf(lcMul31(WorldMatrix[3], mViewMatrix).z); - RenderMesh.LodIndex = RenderMesh.Mesh->GetLodIndex(Distance); + RenderMesh.LodIndex = mAllowLOD ? RenderMesh.Mesh->GetLodIndex(Distance) : LC_MESH_LOD_HIGH; bool Translucent = lcIsColorTranslucent(ColorIndex); lcMeshFlags Flags = Mesh->mFlags; diff --git a/common/lc_scene.h b/common/lc_scene.h index 3baf577a..1945fae6 100644 --- a/common/lc_scene.h +++ b/common/lc_scene.h @@ -64,6 +64,11 @@ public: mAllowWireframe = AllowWireframe; } + void SetAllowLOD(bool AllowLOD) + { + mAllowLOD = AllowLOD; + } + lcMatrix44 ApplyActiveSubmodelTransform(const lcMatrix44& WorldMatrix) const { return !mActiveSubmodelInstance ? WorldMatrix : lcMul(WorldMatrix, mActiveSubmodelTransform); @@ -91,6 +96,7 @@ protected: lcPiece* mActiveSubmodelInstance; bool mDrawInterface; bool mAllowWireframe; + bool mAllowLOD; lcArray mRenderMeshes; lcArray mOpaqueMeshes; diff --git a/common/minifig.cpp b/common/minifig.cpp index b215cf83..343eae25 100644 --- a/common/minifig.cpp +++ b/common/minifig.cpp @@ -385,6 +385,7 @@ void MinifigWizard::OnDraw() lcScene Scene; Scene.Begin(ViewMatrix); + Scene.SetAllowLOD(false); for (int PieceIdx = 0; PieceIdx < LC_MFW_NUMITEMS; PieceIdx++) if (mMinifig.Parts[PieceIdx]) diff --git a/common/project.cpp b/common/project.cpp index 9a3f3840..a3ac6005 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1569,6 +1569,8 @@ QImage Project::CreatePartsListImage(lcModel* Model, lcStep Step) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); lcScene Scene; + Scene.SetAllowWireframe(false); + Scene.SetAllowLOD(false); Scene.Begin(ViewMatrix); Image.Info->AddRenderMeshes(Scene, lcMatrix44Identity(), Image.ColorIndex, lcRenderMeshState::NORMAL, true); @@ -1957,6 +1959,8 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options) Context->SetProjectionMatrix(ProjectionMatrix); lcScene Scene; + Scene.SetAllowWireframe(false); + Scene.SetAllowLOD(false); Scene.Begin(ViewMatrix); Info->AddRenderMeshes(Scene, lcMatrix44Identity(), Options.PartImagesColor, lcRenderMeshState::NORMAL, true); diff --git a/common/view.cpp b/common/view.cpp index 4f0b0446..a624c035 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -804,7 +804,10 @@ void View::OnDraw() if (!mModel) return; + const lcPreferences& Preferences = lcGetPreferences(); + bool DrawInterface = mWidget != nullptr; + mScene.SetAllowLOD(Preferences.mAllowLOD && mWidget != nullptr); mModel->GetScene(mScene, mCamera, DrawInterface, mHighlight, mActiveSubmodelInstance, mActiveSubmodelTransform); @@ -838,8 +841,6 @@ void View::OnDraw() } } - const lcPreferences& Preferences = lcGetPreferences(); - for (int CurrentTileRow = 0; CurrentTileRow < TotalTileRows; CurrentTileRow++) { for (int CurrentTileColumn = 0; CurrentTileColumn < TotalTileColumns; CurrentTileColumn++) diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index 782e55e0..07821587 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -54,6 +54,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO ui->antiAliasingSamples->setCurrentIndex(0); ui->edgeLines->setChecked(mOptions->Preferences.mDrawEdgeLines); ui->lineWidth->setText(lcFormatValueLocalized(mOptions->Preferences.mLineWidth)); + ui->MeshLOD->setChecked(mOptions->Preferences.mAllowLOD); ui->gridStuds->setChecked(mOptions->Preferences.mDrawGridStuds); ui->gridLines->setChecked(mOptions->Preferences.mDrawGridLines); ui->gridLineSpacing->setText(QString::number(mOptions->Preferences.mGridLineSpacing)); @@ -167,6 +168,7 @@ void lcQPreferencesDialog::accept() mOptions->Preferences.mDrawEdgeLines = ui->edgeLines->isChecked(); mOptions->Preferences.mLineWidth = lcParseValueLocalized(ui->lineWidth->text()); + mOptions->Preferences.mAllowLOD = ui->MeshLOD->isChecked(); mOptions->Preferences.mDrawGridStuds = ui->gridStuds->isChecked(); mOptions->Preferences.mDrawGridLines = ui->gridLines->isChecked(); diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index 97c88fab..77c12fee 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -225,14 +225,14 @@ - + Axis icon - + Shading Mode: @@ -249,25 +249,6 @@ - - - - - Wireframe - - - - - Flat Shading - - - - - Default Lights - - - - @@ -287,19 +268,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -307,13 +275,6 @@ - - - - Edge lines - - - @@ -357,6 +318,52 @@ + + + + Edge lines + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Wireframe + + + + + Flat Shading + + + + + Default Lights + + + + + + + + Mesh LOD + + + @@ -1100,6 +1107,7 @@ studLogoCombo edgeLines lineWidth + MeshLOD axisIcon ShadingMode gridStuds