mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Added option to disable mesh LOD. Closes #400.
This commit is contained in:
parent
9e41edfef0
commit
0ecc4b5966
12 changed files with 73 additions and 44 deletions
|
@ -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);
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
bool mDrawAxes;
|
||||
bool mDrawEdgeLines;
|
||||
float mLineWidth;
|
||||
bool mAllowLOD;
|
||||
bool mDrawGridStuds;
|
||||
quint32 mGridStudColor;
|
||||
bool mDrawGridLines;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<lcRenderMesh> mRenderMeshes;
|
||||
lcArray<int> mOpaqueMeshes;
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -225,14 +225,14 @@
|
|||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="axisIcon">
|
||||
<property name="text">
|
||||
<string>Axis icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Shading Mode:</string>
|
||||
|
@ -249,25 +249,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="ShadingMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Wireframe</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat Shading</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Default Lights</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="antiAliasingSamples">
|
||||
<item>
|
||||
|
@ -287,19 +268,6 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
|
@ -307,13 +275,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="edgeLines">
|
||||
<property name="text">
|
||||
<string>Edge lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="antiAliasing">
|
||||
<property name="text">
|
||||
|
@ -357,6 +318,52 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="edgeLines">
|
||||
<property name="text">
|
||||
<string>Edge lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="ShadingMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Wireframe</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat Shading</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Default Lights</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="MeshLOD">
|
||||
<property name="text">
|
||||
<string>Mesh LOD</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1100,6 +1107,7 @@
|
|||
<tabstop>studLogoCombo</tabstop>
|
||||
<tabstop>edgeLines</tabstop>
|
||||
<tabstop>lineWidth</tabstop>
|
||||
<tabstop>MeshLOD</tabstop>
|
||||
<tabstop>axisIcon</tabstop>
|
||||
<tabstop>ShadingMode</tabstop>
|
||||
<tabstop>gridStuds</tabstop>
|
||||
|
|
Loading…
Reference in a new issue