1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 21:53:52 +00:00
openmw/apps/opencs/view/render/lighting.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
1.7 KiB
C++
Raw Normal View History

2014-03-23 14:14:26 +00:00
#include "lighting.hpp"
2022-10-10 11:41:36 +00:00
#include <string>
#include <osg/Group>
2015-03-28 20:26:16 +00:00
#include <osg/LightSource>
#include <osg/NodeVisitor>
2022-10-10 11:41:36 +00:00
#include <osg/Object>
#include <osg/Switch>
2022-01-11 09:34:19 +00:00
#include <osg/ValueObject>
2022-10-10 11:41:36 +00:00
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <components/misc/constants.hpp>
2022-01-11 09:34:19 +00:00
#include "../../model/prefs/state.hpp"
class DayNightSwitchVisitor : public osg::NodeVisitor
{
public:
DayNightSwitchVisitor(int index)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mIndex(index)
{
}
void apply(osg::Switch& switchNode) override
{
2022-01-11 09:34:19 +00:00
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);
}
private:
int mIndex;
};
2015-03-28 20:26:16 +00:00
2015-03-11 14:54:45 +00:00
CSVRender::Lighting::~Lighting() {}
void CSVRender::Lighting::updateDayNightMode(int index)
{
if (mRootNode == nullptr)
return;
DayNightSwitchVisitor visitor(index);
mRootNode->accept(visitor);
}