From 0a48e30ec0931e393e7fc36e59fc273d914cb49a Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 22 Oct 2023 18:48:08 -0700 Subject: [PATCH] Changed POV area lights to take the x/y vectors correctly. --- common/light.cpp | 30 ------------------------------ common/light.h | 10 +++++----- common/project.cpp | 14 ++++++++------ qt/lc_qpropertiestree.cpp | 31 ------------------------------- qt/lc_qpropertiestree.h | 2 -- 5 files changed, 13 insertions(+), 74 deletions(-) diff --git a/common/light.cpp b/common/light.cpp index 0f3fe33f..d1fb7fd7 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -33,7 +33,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType) mSpotExponent = 10.0f; mPOVRayExponent = 1.0f; mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f; - mAreaGrid = lcVector2(10.0f, 10.0f); UpdateLightType(); @@ -50,7 +49,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType) mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true); mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true); mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true); - mAreaGridKeys.ChangeKey(mAreaGrid, 1, true); UpdatePosition(1); } @@ -190,11 +188,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const break; case lcLightType::Area: - if (mPOVRayLight) - SaveAttribute(Stream, mAreaGrid, mAreaGridKeys, "LIGHT", "AREA_GRID"); - Stream << QLatin1String("0 !LEOCAD LIGHT AREA_SHAPE ") << gLightAreaShapes[static_cast(mAreaShape)] << LineEnding; - break; } @@ -344,18 +338,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream) // mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true); // } // } - else if (Token == QLatin1String("AREA_ROWS")) - { - mPOVRayLight = true; - Stream >> mAreaGrid[0]; - mAreaGridKeys.ChangeKey(mAreaGrid, 1, true); - } - else if (Token == QLatin1String("AREA_COLUMNS")) - { - mPOVRayLight = true; - Stream >> mAreaGrid[1]; - mAreaGridKeys.ChangeKey(mAreaGrid, 1, true); - } else if (Token == QLatin1String("DIFFUSE")) { Stream >>mLightDiffuse; @@ -396,8 +378,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream) } else if ((Token == QLatin1String("POWER_KEY")) || (Token == QLatin1String("STRENGTH_KEY"))) mSpotExponentKeys.LoadKeysLDraw(Stream); - else if (Token == QLatin1String("AREA_GRID_KEY")) - mAreaGridKeys.LoadKeysLDraw(Stream); else if (Token == QLatin1String("DIFFUSE_KEY")) mLightDiffuseKeys.LoadKeysLDraw(Stream); else if (Token == QLatin1String("SPECULAR_KEY")) @@ -470,10 +450,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property) mSpotExponentKeys.ChangeKey(mSpotExponent, Step, false); } break; - case LC_LIGHT_AREA_GRID: - mAreaGrid = Props.mAreaGrid; - mAreaGridKeys.ChangeKey(mAreaGrid, Step, false); - break; case LC_LIGHT_CUTOFF: mSpotCutoff = Props.mSpotCutoff; mSpotCutoffKeys.ChangeKey(mSpotCutoff, Step, false); @@ -754,7 +730,6 @@ void lcLight::InsertTime(lcStep Start, lcStep Time) mLightSpecularKeys.InsertTime(Start, Time); mSpotCutoffKeys.InsertTime(Start, Time); mSpotExponentKeys.InsertTime(Start, Time); - mAreaGridKeys.InsertTime(Start, Time); } void lcLight::RemoveTime(lcStep Start, lcStep Time) @@ -773,7 +748,6 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time) mLightSpecularKeys.RemoveTime(Start, Time); mSpotCutoffKeys.RemoveTime(Start, Time); mSpotExponentKeys.RemoveTime(Start, Time); - mAreaGridKeys.RemoveTime(Start, Time); } void lcLight::UpdatePosition(lcStep Step) @@ -803,7 +777,6 @@ void lcLight::UpdatePosition(lcStep Step) mLightSpecular = mLightSpecularKeys.CalculateKey(Step); mSpotCutoff = mSpotCutoffKeys.CalculateKey(Step); mSpotExponent = mSpotExponentKeys.CalculateKey(Step); - mAreaGrid = mAreaGridKeys.CalculateKey(Step); } void lcLight::DrawInterface(lcContext* Context, const lcScene& Scene) const @@ -1254,9 +1227,6 @@ void lcLight::RemoveKeyFrames() mSpotExponentKeys.RemoveAll(); mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true); - - mAreaGridKeys.RemoveAll(); - mAreaGridKeys.ChangeKey(mAreaGrid, 1, true); } bool lcLight::Setup(int LightIndex) diff --git a/common/light.h b/common/light.h index 7646e29f..2dc73b04 100644 --- a/common/light.h +++ b/common/light.h @@ -36,7 +36,6 @@ enum lcLightProperty LC_LIGHT_DIFFUSE, LC_LIGHT_SPECULAR, LC_LIGHT_EXPONENT, - LC_LIGHT_AREA_GRID, LC_LIGHT_CUTOFF, LC_LIGHT_USE_CUTOFF, LC_LIGHT_POVRAY @@ -44,7 +43,6 @@ enum lcLightProperty struct lcLightProperties { - lcVector2 mAreaGrid; float mLightDiffuse; float mLightSpecular; float mSpotExponent; @@ -221,6 +219,11 @@ public: return -lcVector3(mWorldMatrix[2]); } + const lcMatrix44& GetWorldMatrix() const + { + return mWorldMatrix; + } + void SaveLDraw(QTextStream& Stream) const; bool ParseLDrawLine(QTextStream& Stream); @@ -321,14 +324,12 @@ public: props.mSpotCutoff = mSpotCutoff; props.mPOVRayLight = mPOVRayLight; props.mEnableCutoff = mEnableCutoff; - props.mAreaGrid = mAreaGrid; return props; } lcMatrix44 mWorldMatrix; lcVector3 mAttenuation; - lcVector2 mAreaGrid; bool mSpotBlendSet; bool mSpotCutoffSet; bool mEnableCutoff; @@ -379,7 +380,6 @@ protected: lcObjectKeyArray mSpotTightnessKeys; lcObjectKeyArray mAttenuationKeys; - lcObjectKeyArray mAreaGridKeys; lcObjectKeyArray mLightSpecularKeys; lcObjectKeyArray mLightDiffuseKeys; lcObjectKeyArray mSpotCutoffKeys; diff --git a/common/project.cpp b/common/project.cpp index e5d102fc..5e77ad7a 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -2139,7 +2139,8 @@ bool Project::ExportPOVRay(const QString& FileName) (CameraName.isEmpty() ? "Camera" : CameraName.toLatin1().constData())); POVFile.WriteLine(Line); - lcVector2 AreaSize(200.0f, 200.0f), AreaGrid(10.0f, 10.0f); + lcVector3 AreaX(1.0f, 0.0f, 0.0f), AreaY(0.0f, 1.0f, 0.0f); + lcVector2 AreaSize(200.0f, 200.0f); int AreaCircle = 0, Shadowless = 0; lcLightType LightType = lcLightType::Area; float Power = 0, SpotRadius = 0, SpotFalloff = 0, SpotTightness = 0; @@ -2157,7 +2158,7 @@ bool Project::ExportPOVRay(const QString& FileName) for (int Idx = 0; Idx < 4; Idx++) { Power = Idx < 2 ? 0.75f : 0.5f; - sprintf(Line,"#ifndef (SkipLight%i)\nWriteLight(%i, %i, <%g, %g, %g>, <%g, %g, %g>, <%g, %g, %g>, %g, %g, %g, %g, %i, %i, %i, %i, %i)\n#end\n\n", + sprintf(Line,"#ifndef (SkipLight%i)\nWriteLight(%i, %i, <%g, %g, %g>, <%g, %g, %g>, <%g, %g, %g>, %g, %g, %g, %g, %i, <%g, %g, %g>, <%g, %g, %g>, %i, %i)\n#end\n\n", Idx, LightType, Shadowless, @@ -2166,7 +2167,7 @@ bool Project::ExportPOVRay(const QString& FileName) LightColor[0], LightColor[1], LightColor[2], Power, SpotRadius, SpotFalloff, SpotTightness, - AreaCircle, (int)AreaSize[0], (int)AreaSize[1], (int)AreaGrid[0], (int)AreaGrid[1]); + AreaCircle, AreaX[0], AreaX[1], AreaX[2], AreaY[0], AreaY[1], AreaY[2], (int)AreaSize[0], (int)AreaSize[1]); POVFile.WriteLine(Line); } } @@ -2198,14 +2199,15 @@ bool Project::ExportPOVRay(const QString& FileName) case lcLightType::Area: AreaCircle = (Light->GetAreaShape() == lcLightAreaShape::Disk || Light->GetAreaShape() == lcLightAreaShape::Ellipse) ? 1 : 0; AreaSize = Light->GetSize(); - AreaGrid = Light->mAreaGrid; + AreaX = lcVector3(Light->GetWorldMatrix()[0]); + AreaY = lcVector3(Light->GetWorldMatrix()[1]); break; case lcLightType::Count: break; } - sprintf(Line,"#ifndef (Skip%s)\n WriteLight(%i, %i, <%g, %g, %g>, <%g, %g, %g>, <%g, %g, %g>, %g, %g, %g, %g, %i, %i, %i, %i, %i)\n#end\n\n", + sprintf(Line,"#ifndef (Skip%s)\n WriteLight(%i, %i, <%g, %g, %g>, <%g, %g, %g>, <%g, %g, %g>, %g, %g, %g, %g, %i, <%g, %g, %g>, <%g, %g, %g>, %i, %i)\n#end\n\n", LightName.toLatin1().constData(), LightType, Shadowless, @@ -2214,7 +2216,7 @@ bool Project::ExportPOVRay(const QString& FileName) LightColor[0], LightColor[1], LightColor[2], Power, SpotRadius, SpotFalloff, SpotTightness, - AreaCircle, (int)AreaSize[0], (int)AreaSize[1], (int)AreaGrid[0], (int)AreaGrid[1]); + AreaCircle, AreaX[0], AreaX[1], AreaX[2], AreaY[0], AreaY[1], AreaY[2], (int)AreaSize[0], (int)AreaSize[1]); POVFile.WriteLine(Line); } } diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index bf1c2046..c4a07d32 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -886,16 +886,6 @@ void lcQPropertiesTree::slotReturnPressed() Model->UpdateLight(Light, Props, LC_LIGHT_CUTOFF); } - else if (Item == lightAreaGridRows || Item == lightAreaGridColumns) - { - float Value = lcParseValueLocalized(Editor->text()); - if (Item == lightAreaGridRows) - Props.mAreaGrid[0] = Value; - else if (Item == lightAreaGridColumns) - Props.mAreaGrid[1] = Value; - - Model->UpdateLight(Light, Props, LC_LIGHT_AREA_GRID); - } else if (Item == mLightNameItem) { QString Value = Editor->text(); @@ -1114,8 +1104,6 @@ void lcQPropertiesTree::SetEmpty() mLightSizeYItem = nullptr; lightFormat = nullptr; mLightCastShadowItem = nullptr; - lightAreaGridRows = nullptr; - lightAreaGridColumns = nullptr; mPositionItem = nullptr; mPositionXItem = nullptr; @@ -1379,7 +1367,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) lcVector3 Position(0.0f, 0.0f, 0.0f); QColor Color(Qt::white); float SpotConeAngle = 0.0f, SpotPenumbraAngle = 0.0f, SpotTightness = 0.0f; - lcVector2 AreaGrid(0.0f, 0.0f); if (Light) { @@ -1440,7 +1427,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) Cutoff = Light->mSpotCutoff; EnableCutoff = Light->mEnableCutoff; SpotTightness = Light->GetSpotTightness(); - AreaGrid = Light->mAreaGrid; } if (mWidgetMode != LC_PROPERTY_WIDGET_LIGHT || mLightType != LightType || mPOVRayLight != POVRayLight) @@ -1512,12 +1498,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) case lcLightAreaShape::Count: break; } - - if (POVRayLight) - { - lightAreaGridRows = addProperty(mLightAttributesItem, tr("Grid Rows"), PropertyFloat); - lightAreaGridColumns = addProperty(mLightAttributesItem, tr("Grid Columns"), PropertyFloat); - } break; case lcLightType::Count: @@ -1650,17 +1630,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus) case lcLightType::Area: mLightAreaShapeItem->setText(1, lcLight::GetAreaShapeString(LightAreaShape)); mLightAreaShapeItem->setData(0, PropertyValueRole, static_cast(LightAreaShape)); - - if (POVRayLight) - { - lightAreaGridRows->setText(1, lcFormatValueLocalized(AreaGrid[0])); - lightAreaGridRows->setData(0, PropertyValueRole, AreaGrid[0]); - lightAreaGridRows->setToolTip(1, tr("The number of sample rows in the area light.")); - - lightAreaGridColumns->setText(1, lcFormatValueLocalized(AreaGrid[1])); - lightAreaGridColumns->setData(0, PropertyValueRole, AreaGrid[1]); - lightAreaGridColumns->setToolTip(1, tr("The number of sample columns in the area light.")); - } break; case lcLightType::Count: diff --git a/qt/lc_qpropertiestree.h b/qt/lc_qpropertiestree.h index 2bdd490b..d6d1e8f2 100644 --- a/qt/lc_qpropertiestree.h +++ b/qt/lc_qpropertiestree.h @@ -133,8 +133,6 @@ protected: QTreeWidgetItem* mLightNameItem; QTreeWidgetItem* lightFormat; QTreeWidgetItem* mLightCastShadowItem; - QTreeWidgetItem* lightAreaGridRows; - QTreeWidgetItem* lightAreaGridColumns; QTreeWidgetItem* mPositionItem; QTreeWidgetItem* mPositionXItem;