summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpsi29a <psi29a@gmail.com>2022-01-11 09:34:19 +0000
committerpsi29a <psi29a@gmail.com>2022-01-11 09:34:19 +0000
commit781b014183c90ed2f92d83de99a2a09363186812 (patch)
treedc5918fce535d933f247df2fef3383f65ee3ef1a
parent0826de7edf5a1990de093eb29ed023cafbee16f2 (diff)
parent8ec0a52605ac0dad211aeb0900cf6bd685fb8d39 (diff)
Merge branch 'toggable_daynightswitch' into 'master'
Toggable day night switch (#5928) Closes #5928 See merge request OpenMW/openmw!1549
-rw-r--r--CHANGELOG.md1
-rw-r--r--apps/launcher/advancedpage.cpp4
-rw-r--r--apps/opencs/model/prefs/state.cpp1
-rw-r--r--apps/opencs/view/render/lighting.cpp32
-rw-r--r--apps/opencs/view/render/scenewidget.cpp5
-rw-r--r--apps/opencs/view/world/previewsubview.cpp2
-rw-r--r--apps/openmw/mwrender/animation.cpp2
-rw-r--r--docs/source/reference/modding/settings/game.rst9
-rw-r--r--files/settings-default.cfg3
-rw-r--r--files/ui/advancedpage.ui19
10 files changed, 75 insertions, 3 deletions
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 <osg/LightSource>
#include <osg/NodeVisitor>
#include <osg/Switch>
+#include <osg/ValueObject>
#include <components/misc/constants.hpp>
+#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
@@ -558,6 +558,25 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="miscGroup">
+ <property name="title">
+ <string>Models</string>
+ </property>
+ <layout class="QGridLayout" name="miscLayout">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="nightDaySwitchesCheckBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If this setting is true, supporting models will make use of day night switch nodes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Day night switch nodes</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>