diff --git a/src/Features/InverseSquareLighting.cpp b/src/Features/InverseSquareLighting.cpp index a602079470..03e830456d 100644 --- a/src/Features/InverseSquareLighting.cpp +++ b/src/Features/InverseSquareLighting.cpp @@ -1,18 +1,9 @@ #include "InverseSquareLighting.h" #include "Features/InverseSquareLighting/Common.h" #include "LightLimitFix.h" +#include "WeatherEditor/EditorWindow.h" #include -void InverseSquareLighting::DrawSettings() -{ - editor.DrawSettings(); -} - -void InverseSquareLighting::EarlyPrepass() -{ - editor.GatherLights(); -} - void InverseSquareLighting::PostPostLoad() { stl::detour_thunk(REL::RelocationID(17208, 17610)); @@ -55,13 +46,14 @@ void InverseSquareLighting::ProcessLight(LightLimitFix::LightData& light, RE::BS runtimeData->flags.set(LightLimitFix::LightFlags::Initialised); } - editor.ApplyOverrides(niLight, runtimeData); + const auto& editorRef = EditorWindow::GetSingleton()->lightEditor; + editorRef.ApplyOverrides(niLight, runtimeData); light.lightFlags = runtimeData->flags; light.color = { runtimeData->diffuse.red, runtimeData->diffuse.green, runtimeData->diffuse.blue }; const bool isInvSq = light.lightFlags.any(LightLimitFix::LightFlags::InverseSquare); - if (bsLight->pointLight && editor.enabled && ((isInvSq && editor.disableInvSqLights) || (!isInvSq && editor.disableRegularLights))) + if (bsLight->pointLight && ((isInvSq && editorRef.disableInvSqLights) || (!isInvSq && editorRef.disableRegularLights))) light.lightFlags.set(LightLimitFix::LightFlags::Disabled); if (bsLight->pointLight && isInvSq) { diff --git a/src/Features/InverseSquareLighting.h b/src/Features/InverseSquareLighting.h index 70699c3ac3..fdf65676d0 100644 --- a/src/Features/InverseSquareLighting.h +++ b/src/Features/InverseSquareLighting.h @@ -1,5 +1,4 @@ #pragma once -#include "Features/InverseSquareLighting/LightEditor.h" #include "LightLimitFix.h" struct InverseSquareLighting : Feature @@ -21,17 +20,12 @@ struct InverseSquareLighting : Feature "Lights smoothly fade out at a configurable cutoff, solving the infinite distance problem", "Does not modify any existing lighting", "Requires the use of mods with lights enabled for inverse square falloff.", - "Full integration with Light Placer", - "Built in Light Editor for mod authors to preview lighting changes in real-time" } + "Full integration with Light Placer" } }; } inline bool HasShaderDefine(RE::BSShader::Type) override { return true; }; - virtual void DrawSettings() override; - - virtual void EarlyPrepass() override; - virtual bool SupportsVR() override { return true; } virtual void PostPostLoad() override; @@ -56,8 +50,6 @@ struct InverseSquareLighting : Feature virtual bool IsCore() const override { return true; }; private: - LightEditor editor = LightEditor(); - static constexpr float DefaultCutoff = 0.05f; static constexpr float DefaultShadowCasterCutoff = 0.022f; diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index 7f84372e48..9d31591f82 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -213,7 +213,9 @@ void EditorWindow::ShowObjectsWindow() ImGui::Spacing(); // List of categories - const char* categories[] = { "Weather", "ImageSpace", "Lighting Template", "Cell Lighting", "Volumetric Lighting", "Shader Particle Geometry", "Lens Flare", "Visual Effect", "Interior Only" }; + const char* categories[] = { "Weather", "ImageSpace", "Lighting Template", "Cell Lighting", + "Volumetric Lighting", "Shader Particle Geometry", "Lens Flare", "Visual Effect", + "Interior Only", "Lighting editor" }; for (int i = 0; i < IM_ARRAYSIZE(categories); ++i) { // Highlight the selected category if (ImGui::Selectable(categories[i], m_selectedCategory == categories[i])) { @@ -238,6 +240,16 @@ void EditorWindow::ShowObjectsWindow() return; } + if (m_selectedCategory == "Lighting editor") { + BeginScrollableContent("##LightEditorScroll"); + lightEditor.DrawSettings(); + EndScrollableContent(); + ImGui::EndChild(); + ImGui::EndTable(); + ImGui::End(); + return; + } + // Returns the widget collection for a given category; Cell Lighting and unknown // categories return an empty collection since they have no standalone widget list. auto getWidgetsForCategory = [&](const std::string& cat) -> const std::vector>& { @@ -1402,6 +1414,7 @@ void EditorWindow::UpdateOpenState() BackgroundBlur::SetWeatherEditorActive(IsViewportActive()); } else if (!open && wasOpen) { + lightEditor.ResetOverrides(); RestoreVanityCamera(); ShowGameMenus(); BackgroundBlur::SetWeatherEditorActive(false); @@ -1412,6 +1425,9 @@ void EditorWindow::UpdateOpenState() void EditorWindow::Draw() { + if (open) + lightEditor.GatherLights(); + // Keep background blur in sync when HDR toggles while the editor stays open { static bool prevViewportActive = false; diff --git a/src/WeatherEditor/EditorWindow.h b/src/WeatherEditor/EditorWindow.h index e53c3cc8a1..266a75f961 100644 --- a/src/WeatherEditor/EditorWindow.h +++ b/src/WeatherEditor/EditorWindow.h @@ -10,6 +10,7 @@ #include "Weather/ReferenceEffectWidget.h" #include "Weather/VolumetricLightingWidget.h" #include "Weather/WeatherWidget.h" +#include "LightEditor.h" #include "WeatherUtils.h" #include "Widget.h" @@ -63,6 +64,8 @@ class EditorWindow // Owned by EditorWindow, created on demand in ShowObjectsWindow(), released in destructor std::unique_ptr currentCellLightingWidget; + LightEditor lightEditor; + // Weather locking for editing RE::TESWeather* lockedWeather = nullptr; bool weatherLockActive = false; diff --git a/src/Features/InverseSquareLighting/LightEditor.cpp b/src/WeatherEditor/LightEditor.cpp similarity index 96% rename from src/Features/InverseSquareLighting/LightEditor.cpp rename to src/WeatherEditor/LightEditor.cpp index abcfdb0a11..f405f53568 100644 --- a/src/Features/InverseSquareLighting/LightEditor.cpp +++ b/src/WeatherEditor/LightEditor.cpp @@ -1,7 +1,7 @@ -#include "Features/InverseSquareLighting/LightEditor.h" -#include "Features/InverseSquareLighting.h" -#include "Features/LightLimitFix.h" -#include "Menu.h" +#include "LightEditor.h" +#include "../Features/InverseSquareLighting.h" +#include "../Features/LightLimitFix.h" +#include "../Menu.h" #include #include @@ -10,21 +10,6 @@ void LightEditor::DrawSettings() { - ImGui::Checkbox("Enable Light Editor", &enabled); - if (auto _tt = Util::HoverTooltipWrapper()) { - ImGui::Text( - "Allows for modifying lights in real-time to preview changes. " - "Light Placer lights can be saved back to their JSON configs. " - "Not intended for gameplay use."); - } - - if (!enabled) - return; - - ImGui::Spacing(); - ImGui::Separator(); - ImGui::Spacing(); - ImGui::Checkbox("Disable Regular Falloff Lights", &disableRegularLights); ImGui::Checkbox("Disable Inverse Square Falloff Lights", &disableInvSqLights); @@ -168,10 +153,8 @@ std::string LightEditor::GetLightName(LightInfo& lightInfo) void LightEditor::GatherLights() { - if (!enabled || !Menu::GetSingleton()->ShouldSwallowInput()) { - RestoreOriginal(); - selected = {}; - previous = {}; + if (!Menu::GetSingleton()->ShouldSwallowInput()) { + ResetOverrides(); return; } @@ -287,6 +270,13 @@ void LightEditor::GatherLights() SortLights(); } +void LightEditor::ResetOverrides() +{ + RestoreOriginal(); + selected = {}; + previous = {}; +} + void LightEditor::UpdateSelectedLight(RE::TESObjectREFR* refr, RE::TESObjectLIGH* ligh, RE::NiLight* niLight) { const auto runtimeData = ISLCommon::RuntimeLightDataExt::Get(niLight); @@ -372,7 +362,7 @@ void LightEditor::UpdateSelectedLight(RE::TESObjectREFR* refr, RE::TESObjectLIGH bool LightEditor::ApplyOverrides(RE::NiLight* niLight, ISLCommon::RuntimeLightDataExt* runtimeData) const { - if (!enabled || niLight != activeNiLight.get()) + if (niLight != activeNiLight.get()) return false; runtimeData->diffuse = current.data.diffuse; @@ -707,4 +697,4 @@ void LightEditor::SortLights() default: break; } -} \ No newline at end of file +} diff --git a/src/Features/InverseSquareLighting/LightEditor.h b/src/WeatherEditor/LightEditor.h similarity index 94% rename from src/Features/InverseSquareLighting/LightEditor.h rename to src/WeatherEditor/LightEditor.h index 1748fa34fd..48be6b33c7 100644 --- a/src/Features/InverseSquareLighting/LightEditor.h +++ b/src/WeatherEditor/LightEditor.h @@ -1,15 +1,15 @@ -#pragma once -#include "Features/InverseSquareLighting/Common.h" +#pragma once +#include "../Features/InverseSquareLighting/Common.h" struct LightEditor { - bool enabled; - bool disableInvSqLights; - bool disableRegularLights; + bool disableInvSqLights = false; + bool disableRegularLights = false; bool shadowsOnly = false; void DrawSettings(); void GatherLights(); + void ResetOverrides(); bool ApplyOverrides(RE::NiLight* niLight, ISLCommon::RuntimeLightDataExt* runtimeData) const;