diff --git a/CHANGELOG.md b/CHANGELOG.md index 3be525b001..4165c7d579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Bug #5842: GetDisposition adds temporary disposition change from different actors Bug #5863: GetEffect should return true after the player has teleported Bug #5913: Failed assertion during Ritual of Trees quest + Bug #5928: Glow in the Dahrk functionality used without mod installed Bug #5937: Lights always need to be rotated by 90 degrees Bug #6037: Morrowind Content Language Cannot be Set to English in OpenMW Launcher Bug #6051: NaN water height in ESM file is not handled gracefully diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index b9d35b3c95..fc1d84a61f 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -143,6 +143,8 @@ bool Launcher::AdvancedPage::loadSettings() loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); viewingDistanceComboBox->setValue(convertToCells(Settings::Manager::getInt("viewing distance", "Camera"))); objectPagingMinSizeComboBox->setValue(Settings::Manager::getDouble("object paging min size", "Terrain")); + + loadSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game"); } // Audio @@ -298,6 +300,8 @@ void Launcher::AdvancedPage::saveSettings() double objectPagingMinSize = objectPagingMinSizeComboBox->value(); if (objectPagingMinSize != Settings::Manager::getDouble("object paging min size", "Terrain")) Settings::Manager::setDouble("object paging min size", "Terrain", objectPagingMinSize); + + saveSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game"); } // Audio diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 58a0f296e2..06dc1f4a2e 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -223,6 +223,7 @@ void CSMPrefs::State::declare() declareColour ("scene-night-gradient-colour", "Scene Night Gradient Colour", QColor (47, 51, 51, 255)). setTooltip("Sets the gradient color to use in conjunction with the night background color. Ignored if " "the gradient option is disabled."); + declareBool("scene-day-night-switch-nodes", "Use Day/Night Switch Nodes", true); declareCategory ("Tooltips"); declareBool ("scene", "Show Tooltips in 3D scenes", true); diff --git a/apps/opencs/view/render/lighting.cpp b/apps/opencs/view/render/lighting.cpp index 82ad43e6ad..c7bee79289 100644 --- a/apps/opencs/view/render/lighting.cpp +++ b/apps/opencs/view/render/lighting.cpp @@ -3,9 +3,12 @@ #include #include #include +#include #include +#include "../../model/prefs/state.hpp" + class DayNightSwitchVisitor : public osg::NodeVisitor { public: @@ -16,8 +19,33 @@ public: void apply(osg::Switch &switchNode) override { - if (switchNode.getName() == Constants::NightDayLabel) - switchNode.setSingleChildOn(mIndex); + constexpr int NoIndex = -1; + + int initialIndex = NoIndex; + if (!switchNode.getUserValue("initialIndex", initialIndex)) + { + for (size_t i = 0; i < switchNode.getValueList().size(); ++i) + { + if (switchNode.getValueList()[i]) + { + initialIndex = i; + break; + } + } + + if (initialIndex != NoIndex) + switchNode.setUserValue("initialIndex", initialIndex); + } + + if (CSMPrefs::get()["Rendering"]["scene-day-night-switch-nodes"].isTrue()) + { + if (switchNode.getName() == Constants::NightDayLabel) + switchNode.setSingleChildOn(mIndex); + } + else if (initialIndex != NoIndex) + { + switchNode.setSingleChildOn(initialIndex); + } traverse(switchNode); } diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index dbed1ba97c..b0c2140da9 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -550,6 +550,11 @@ void SceneWidget::settingChanged (const CSMPrefs::Setting *setting) { updateCameraParameters(); } + else if (*setting == "Rendering/scene-day-night-switch-nodes") + { + if (mLighting) + setLighting(mLighting); + } } void RenderWidget::updateCameraParameters(double overrideAspect) diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index f3312bb208..cb231b4782 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -25,6 +25,8 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo else mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this); + mScene->setExterior(true); + CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this); CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 732ffd33aa..b1c7bc89c4 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1831,7 +1831,7 @@ namespace MWRender visitor.remove(); } - if (SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel)) + if (Settings::Manager::getBool("day night switches", "Game") && SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel)) { AddSwitchCallbacksVisitor visitor; mObjectRoot->accept(visitor); diff --git a/docs/source/reference/modding/settings/game.rst b/docs/source/reference/modding/settings/game.rst index 6b19885557..f407c6a126 100644 --- a/docs/source/reference/modding/settings/game.rst +++ b/docs/source/reference/modding/settings/game.rst @@ -465,3 +465,12 @@ default actor pathfind half extents Actor half extents used for exterior cells to generate navmesh. Changing the value will invalidate navmesh disk cache. + +day night switches +------------------ + +:Type: boolean +:Range: True/False +:Default: True + +Some mods add models which change visuals based on time of day. When this setting is enabled, supporting models will automatically make use of Day/night state. diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 06e080fdfd..f1f3206661 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -373,6 +373,9 @@ allow actors to follow over water surface = true # Default size of actor for navmesh generation default actor pathfind half extents = 29.27999496459961 28.479997634887695 66.5 +# Enables use of day/night switch nodes +day night switches = true + [General] # Anisotropy reduces distortion in textures at low angles (e.g. 0 to 16). diff --git a/files/ui/advancedpage.ui b/files/ui/advancedpage.ui index 3a2e7c49fc..8e976df42d 100644 --- a/files/ui/advancedpage.ui +++ b/files/ui/advancedpage.ui @@ -557,6 +557,25 @@ + + + + Models + + + + + + <html><head/><body><p>If this setting is true, supporting models will make use of day night switch nodes.</p></body></html> + + + Day night switch nodes + + + + + +