From 321b9389ede4d6f03e7eea0c929bc7c3867c0483 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 17 Dec 2023 12:16:32 -0800 Subject: [PATCH] Removed unused light options. Specular is EEVEE only and Diffuse/Cutoff are unknown. --- common/light.cpp | 93 --------------------------------------- common/light.h | 21 --------- qt/lc_qpropertiestree.cpp | 74 +------------------------------ qt/lc_qpropertiestree.h | 4 -- 4 files changed, 2 insertions(+), 190 deletions(-) diff --git a/common/light.cpp b/common/light.cpp index f57f7583..17d3cef6 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -26,12 +26,8 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType) mWorldMatrix = lcMatrix44Translation(Position); mPOVRayLight = false; - mEnableCutoff = false; - mLightDiffuse = 1.0f; - mLightSpecular = 1.0f; mSpotExponent = 10.0f; mPOVRayExponent = 1.0f; - mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f; UpdateLightType(); @@ -46,9 +42,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType) mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true); mAreaGridKeys.ChangeKey(mAreaGrid, 1, true); - mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true); - mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true); - mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true); mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true); UpdatePosition(1); @@ -161,19 +154,8 @@ void lcLight::SaveLDraw(QTextStream& Stream) const SaveAttribute(Stream, mAttenuationDistance, mAttenuationDistanceKeys, "LIGHT", "ATTENUATION_DISTANCE"); SaveAttribute(Stream, mAttenuationPower, mAttenuationPowerKeys, "LIGHT", "ATTENUATION_POWER"); - if (!mPOVRayLight) - { - SaveAttribute(Stream, mLightDiffuse, mLightDiffuseKeys, "LIGHT", "DIFFUSE"); - SaveAttribute(Stream, mLightSpecular, mLightSpecularKeys, "LIGHT", "SPECULAR"); - } - // SaveAttribute(Stream, (mPOVRayLight ? mPOVRayExponent : mSpotExponent), mSpotExponentKeys, "LIGHT", "POWER"); - if (mEnableCutoff && !mPOVRayLight) - { - SaveAttribute(Stream, mSpotCutoff, mSpotCutoffKeys, "LIGHT", "CUTOFF_DISTANCE"); - } - switch (mLightType) { case lcLightType::Count: @@ -348,22 +330,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream) // mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true); // } // } - else if (Token == QLatin1String("DIFFUSE")) - { - Stream >>mLightDiffuse; - mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true); - } - else if (Token == QLatin1String("SPECULAR")) - { - Stream >>mLightSpecular; - mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true); - } - else if ((mSpotCutoffSet = Token == QLatin1String("CUTOFF_DISTANCE"))) - { - mEnableCutoff = true; - Stream >> mSpotCutoff; - mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true); - } else if (Token == QLatin1String("TYPE")) { QString Type; @@ -388,37 +354,11 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream) } else if ((Token == QLatin1String("POWER_KEY")) || (Token == QLatin1String("STRENGTH_KEY"))) mSpotExponentKeys.LoadKeysLDraw(Stream); - else if (Token == QLatin1String("DIFFUSE_KEY")) - mLightDiffuseKeys.LoadKeysLDraw(Stream); - else if (Token == QLatin1String("SPECULAR_KEY")) - mLightSpecularKeys.LoadKeysLDraw(Stream); - else if (Token == QLatin1String("CUTOFF_DISTANCE_KEY")) - mSpotCutoffKeys.LoadKeysLDraw(Stream); else if (Token == QLatin1String("NAME")) { mName = Stream.readAll().trimmed(); mName.replace("\"", ""); - // Set default settings per light type - switch (mLightType) - { - case lcLightType::Point: - case lcLightType::Spot: - break; - - case lcLightType::Directional: - if (!mSpotCutoffSet) - { - mSpotCutoff = 0.0f; - mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true); - } - break; - - case lcLightType::Area: - case lcLightType::Count: - break; - } - return true; } } @@ -440,14 +380,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property) { switch(Property) { - case LC_LIGHT_DIFFUSE: - mLightDiffuse = Props.mLightDiffuse; - mLightDiffuseKeys.ChangeKey(mLightDiffuse, Step, false); - break; - case LC_LIGHT_SPECULAR: - mLightSpecular = Props.mLightSpecular; - mLightSpecularKeys.ChangeKey(mLightSpecular, Step, false); - break; case LC_LIGHT_EXPONENT: if (Props.mPOVRayLight) { @@ -460,13 +392,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property) mSpotExponentKeys.ChangeKey(mSpotExponent, Step, false); } break; - case LC_LIGHT_CUTOFF: - mSpotCutoff = Props.mSpotCutoff; - mSpotCutoffKeys.ChangeKey(mSpotCutoff, Step, false); - break; - case LC_LIGHT_USE_CUTOFF: - mEnableCutoff = Props.mEnableCutoff; - break; case LC_LIGHT_POVRAY: mPOVRayLight = Props.mPOVRayLight; break; @@ -755,9 +680,6 @@ void lcLight::InsertTime(lcStep Start, lcStep Time) mAttenuationDistanceKeys.InsertTime(Start, Time); mAttenuationPowerKeys.InsertTime(Start, Time); - mLightDiffuseKeys.InsertTime(Start, Time); - mLightSpecularKeys.InsertTime(Start, Time); - mSpotCutoffKeys.InsertTime(Start, Time); mSpotExponentKeys.InsertTime(Start, Time); } @@ -775,9 +697,6 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time) mAttenuationDistanceKeys.RemoveTime(Start, Time); mAttenuationPowerKeys.RemoveTime(Start, Time); - mLightDiffuseKeys.RemoveTime(Start, Time); - mLightSpecularKeys.RemoveTime(Start, Time); - mSpotCutoffKeys.RemoveTime(Start, Time); mSpotExponentKeys.RemoveTime(Start, Time); } @@ -806,9 +725,6 @@ void lcLight::UpdatePosition(lcStep Step) mAttenuationDistance = mAttenuationDistanceKeys.CalculateKey(Step); mAttenuationPower = mAttenuationPowerKeys.CalculateKey(Step); - mLightDiffuse = mLightDiffuseKeys.CalculateKey(Step); - mLightSpecular = mLightSpecularKeys.CalculateKey(Step); - mSpotCutoff = mSpotCutoffKeys.CalculateKey(Step); mSpotExponent = mSpotExponentKeys.CalculateKey(Step); } @@ -1255,15 +1171,6 @@ void lcLight::RemoveKeyFrames() mAttenuationPowerKeys.RemoveAll(); mAttenuationPowerKeys.ChangeKey(mAttenuationPower, 1, true); - mLightDiffuseKeys.RemoveAll(); - mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true); - - mLightSpecularKeys.RemoveAll(); - mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true); - - mSpotCutoffKeys.RemoveAll(); - mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true); - mSpotExponentKeys.RemoveAll(); mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true); } diff --git a/common/light.h b/common/light.h index b70435ea..14d598a4 100644 --- a/common/light.h +++ b/common/light.h @@ -33,21 +33,13 @@ enum class lcLightAreaShape enum lcLightProperty { - LC_LIGHT_DIFFUSE, - LC_LIGHT_SPECULAR, LC_LIGHT_EXPONENT, - LC_LIGHT_CUTOFF, - LC_LIGHT_USE_CUTOFF, LC_LIGHT_POVRAY }; struct lcLightProperties { - float mLightDiffuse; - float mLightSpecular; float mSpotExponent; - float mSpotCutoff; - bool mEnableCutoff; bool mPOVRayLight; }; @@ -339,24 +331,14 @@ public: lcLightProperties GetLightProperties() const { lcLightProperties props; - props.mLightDiffuse = mLightDiffuse; - props.mLightSpecular = mLightSpecular; props.mSpotExponent = mSpotExponent; - props.mSpotCutoff = mSpotCutoff; props.mPOVRayLight = mPOVRayLight; - props.mEnableCutoff = mEnableCutoff; return props; } lcMatrix44 mWorldMatrix; - bool mSpotBlendSet; - bool mSpotCutoffSet; - bool mEnableCutoff; bool mPOVRayLight; - float mLightDiffuse; - float mLightSpecular; - float mSpotCutoff; float mSpotExponent; float mPOVRayExponent; @@ -405,9 +387,6 @@ protected: lcObjectKeyArray mSpotTightnessKeys; lcObjectKeyArray mAreaGridKeys; - lcObjectKeyArray mLightSpecularKeys; - lcObjectKeyArray mLightDiffuseKeys; - lcObjectKeyArray mSpotCutoffKeys; lcObjectKeyArray mSpotExponentKeys; static constexpr float mTargetDistance = 50.0f; diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index cf46027b..a5ebc50c 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -658,13 +658,7 @@ void lcQPropertiesTree::slotToggled(bool Value) if (Light) { - if (Item == lightEnableCutoff) - { - lcLightProperties Props = Light->GetLightProperties(); - Props.mEnableCutoff = Value; - Model->UpdateLight(Light, Props, LC_LIGHT_USE_CUTOFF); - } - else if (Item == mLightCastShadowItem) + if (Item == mLightCastShadowItem) { Model->SetLightCastShadow(Light, Value); } @@ -902,30 +896,12 @@ void lcQPropertiesTree::slotReturnPressed() Model->SetLightPower(Light, Value); } - else if (Item == lightDiffuse) - { - Props.mLightDiffuse = lcParseValueLocalized(Editor->text()); - - Model->UpdateLight(Light, Props, LC_LIGHT_DIFFUSE); - } - else if (Item == lightSpecular) - { - Props.mLightSpecular = lcParseValueLocalized(Editor->text()); - - Model->UpdateLight(Light, Props, LC_LIGHT_SPECULAR); - } else if (Item == lightExponent) { Props.mSpotExponent = lcParseValueLocalized(Editor->text()); Model->UpdateLight(Light, Props, LC_LIGHT_EXPONENT); } - else if (Item == lightCutoff) - { - Props.mSpotCutoff = lcParseValueLocalized(Editor->text()); - - Model->UpdateLight(Light, Props, LC_LIGHT_CUTOFF); - } else if (Item == mLightNameItem) { QString Value = Editor->text(); @@ -1129,10 +1105,6 @@ void lcQPropertiesTree::SetEmpty() mLightColorItem = nullptr; mLightPowerItem = nullptr; mLightAttributesItem = nullptr; - lightDiffuse = nullptr; - lightSpecular = nullptr; - lightCutoff = nullptr; - lightEnableCutoff = nullptr; lightExponent = nullptr; mLightTypeItem = nullptr; mLightNameItem = nullptr; @@ -1394,8 +1366,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) QString Name = tr("Light"); QString ExponentLabel = tr("Exponent"); - QString FactorALabel = QLatin1String("FactorA"); - QString Format, ExponentToolTip, FactorAToolTip, FactorBToolTip; + QString Format, ExponentToolTip; lcLightType LightType = lcLightType::Point; lcLightAreaShape LightAreaShape = lcLightAreaShape::Rectangle; lcVector2 LightSize(0.0f, 0.0f); @@ -1404,8 +1375,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) float AttenuationDistance = 0.0f; float AttenuationPower = 0.0f; int FormatIndex = 0; - float Diffuse = 0.0f; - float Specular = 0.0f; float Cutoff = 0.0f; float Exponent = 0.0f; bool EnableCutoff = false; @@ -1444,7 +1413,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) break; case lcLightType::Spot: - FactorBToolTip = tr("The softness of the spotlight edge."); ExponentLabel = tr("Power"); break; @@ -1459,9 +1427,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) break; } - Diffuse = Light->mLightDiffuse; - Specular = Light->mLightSpecular; - if (POVRayLight) { Exponent = Light->mPOVRayExponent; @@ -1474,8 +1439,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) } ExponentLabel = LightType == lcLightType::Directional ? tr("Strength") : tr("Power"); - Cutoff = Light->mSpotCutoff; - EnableCutoff = Light->mEnableCutoff; SpotTightness = Light->GetSpotTightness(); } @@ -1571,18 +1534,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat); - if (!POVRayLight) - { - if (LightType != lcLightType::Directional) - { - lightEnableCutoff = addProperty(mLightAttributesItem, tr("Cutoff"), PropertyBool); - lightCutoff = addProperty(mLightAttributesItem, tr("Cutoff Distance"), PropertyFloat); - } - - lightDiffuse = addProperty(mLightAttributesItem, tr("Diffuse"), PropertyFloat); - lightSpecular = addProperty(mLightAttributesItem, tr("Specular"), PropertyFloat); - } - // Configuration lightConfiguration = addProperty(nullptr, tr("Configuration"), PropertyGroup); lightFormat = addProperty(lightConfiguration, tr("Format"), PropertyLightFormat); @@ -1715,27 +1666,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) break; } - if (!POVRayLight) - { - if (LightType != lcLightType::Directional) - { - lightEnableCutoff->setCheckState(1, EnableCutoff ? Qt::Checked : Qt::Unchecked); - lightEnableCutoff->setData(0, PropertyValueRole, EnableCutoff); - - lightCutoff->setText(1, lcFormatValueLocalized(Cutoff)); - lightCutoff->setData(0, PropertyValueRole, Cutoff); - lightCutoff->setToolTip(1, tr("Distance at which the light influence will be set to 0.")); - } - - lightDiffuse->setText(1, lcFormatValueLocalized(Diffuse)); - lightDiffuse->setData(0, PropertyValueRole, Diffuse); - lightDiffuse->setToolTip(1, tr("Diffuse reflection multiplier factor.")); - - lightSpecular->setText(1, lcFormatValueLocalized(Specular)); - lightSpecular->setData(0, PropertyValueRole, Specular); - lightSpecular->setToolTip(1, tr("Specular reflection multiplier factor.")); - } - mLightNameItem->setText(1, Name); mLightNameItem->setData(0, PropertyValueRole, QVariant::fromValue(Name)); } diff --git a/qt/lc_qpropertiestree.h b/qt/lc_qpropertiestree.h index 1eabd9ef..25eae636 100644 --- a/qt/lc_qpropertiestree.h +++ b/qt/lc_qpropertiestree.h @@ -119,10 +119,6 @@ protected: QTreeWidgetItem* mLightColorItem; QTreeWidgetItem* mLightPowerItem; QTreeWidgetItem* mLightAttributesItem; - QTreeWidgetItem* lightDiffuse; - QTreeWidgetItem* lightSpecular; - QTreeWidgetItem* lightCutoff; - QTreeWidgetItem* lightEnableCutoff; QTreeWidgetItem* lightExponent; QTreeWidgetItem* mLightTypeItem; QTreeWidgetItem* mLightAttenuationDistanceItem;