mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 18:40:01 +00:00
Merge pull request #2153 from akortunov/glowing_windows
Native glowing windows support
This commit is contained in:
commit
f4313c02e1
@ -32,6 +32,7 @@
|
|||||||
Feature #4673: Weapon sheathing
|
Feature #4673: Weapon sheathing
|
||||||
Feature #4730: Native animated containers support
|
Feature #4730: Native animated containers support
|
||||||
Feature #4812: Support NiSwitchNode
|
Feature #4812: Support NiSwitchNode
|
||||||
|
Feature #4836: Daytime node switch
|
||||||
Task #4686: Upgrade media decoder to a more current FFmpeg API
|
Task #4686: Upgrade media decoder to a more current FFmpeg API
|
||||||
|
|
||||||
0.45.0
|
0.45.0
|
||||||
|
@ -1,5 +1,38 @@
|
|||||||
#include "lighting.hpp"
|
#include "lighting.hpp"
|
||||||
|
|
||||||
#include <osg/LightSource>
|
#include <osg/LightSource>
|
||||||
|
#include <osg/NodeVisitor>
|
||||||
|
#include <osg/Switch>
|
||||||
|
|
||||||
|
#include <components/misc/constants.hpp>
|
||||||
|
|
||||||
|
class DayNightSwitchVisitor : public osg::NodeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DayNightSwitchVisitor(int index)
|
||||||
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||||
|
, mIndex(index)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void apply(osg::Switch &switchNode)
|
||||||
|
{
|
||||||
|
if (switchNode.getName() == Constants::NightDayLabel)
|
||||||
|
switchNode.setSingleChildOn(mIndex);
|
||||||
|
|
||||||
|
traverse(switchNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mIndex;
|
||||||
|
};
|
||||||
|
|
||||||
CSVRender::Lighting::~Lighting() {}
|
CSVRender::Lighting::~Lighting() {}
|
||||||
|
|
||||||
|
void CSVRender::Lighting::updateDayNightMode(int index)
|
||||||
|
{
|
||||||
|
if (mRootNode == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DayNightSwitchVisitor visitor(index);
|
||||||
|
mRootNode->accept(visitor);
|
||||||
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace CSVRender
|
|||||||
Lighting() : mRootNode(0) {}
|
Lighting() : mRootNode(0) {}
|
||||||
virtual ~Lighting();
|
virtual ~Lighting();
|
||||||
|
|
||||||
virtual void activate (osg::Group* rootNode) = 0;
|
virtual void activate (osg::Group* rootNode, bool isExterior) = 0;
|
||||||
|
|
||||||
virtual void deactivate() = 0;
|
virtual void deactivate() = 0;
|
||||||
|
|
||||||
@ -27,6 +27,8 @@ namespace CSVRender
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void updateDayNightMode(int index);
|
||||||
|
|
||||||
osg::ref_ptr<osg::LightSource> mLightSource;
|
osg::ref_ptr<osg::LightSource> mLightSource;
|
||||||
osg::Group* mRootNode;
|
osg::Group* mRootNode;
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
CSVRender::LightingBright::LightingBright() {}
|
CSVRender::LightingBright::LightingBright() {}
|
||||||
|
|
||||||
void CSVRender::LightingBright::activate (osg::Group* rootNode)
|
void CSVRender::LightingBright::activate (osg::Group* rootNode, bool /*isExterior*/)
|
||||||
{
|
{
|
||||||
mRootNode = rootNode;
|
mRootNode = rootNode;
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ void CSVRender::LightingBright::activate (osg::Group* rootNode)
|
|||||||
mLightSource->setLight(light);
|
mLightSource->setLight(light);
|
||||||
|
|
||||||
mRootNode->addChild(mLightSource);
|
mRootNode->addChild(mLightSource);
|
||||||
|
|
||||||
|
updateDayNightMode(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingBright::deactivate()
|
void CSVRender::LightingBright::deactivate()
|
||||||
|
@ -17,7 +17,7 @@ namespace CSVRender
|
|||||||
|
|
||||||
LightingBright();
|
LightingBright();
|
||||||
|
|
||||||
virtual void activate (osg::Group* rootNode);
|
virtual void activate (osg::Group* rootNode, bool /*isExterior*/);
|
||||||
|
|
||||||
virtual void deactivate();
|
virtual void deactivate();
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
CSVRender::LightingDay::LightingDay(){}
|
CSVRender::LightingDay::LightingDay(){}
|
||||||
|
|
||||||
void CSVRender::LightingDay::activate (osg::Group* rootNode)
|
void CSVRender::LightingDay::activate (osg::Group* rootNode, bool /*isExterior*/)
|
||||||
{
|
{
|
||||||
mRootNode = rootNode;
|
mRootNode = rootNode;
|
||||||
|
|
||||||
@ -19,6 +19,8 @@ void CSVRender::LightingDay::activate (osg::Group* rootNode)
|
|||||||
|
|
||||||
mLightSource->setLight(light);
|
mLightSource->setLight(light);
|
||||||
mRootNode->addChild(mLightSource);
|
mRootNode->addChild(mLightSource);
|
||||||
|
|
||||||
|
updateDayNightMode(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingDay::deactivate()
|
void CSVRender::LightingDay::deactivate()
|
||||||
|
@ -11,7 +11,7 @@ namespace CSVRender
|
|||||||
|
|
||||||
LightingDay();
|
LightingDay();
|
||||||
|
|
||||||
virtual void activate (osg::Group* rootNode);
|
virtual void activate (osg::Group* rootNode, bool /*isExterior*/);
|
||||||
|
|
||||||
virtual void deactivate();
|
virtual void deactivate();
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
CSVRender::LightingNight::LightingNight() {}
|
CSVRender::LightingNight::LightingNight() {}
|
||||||
|
|
||||||
void CSVRender::LightingNight::activate (osg::Group* rootNode)
|
void CSVRender::LightingNight::activate (osg::Group* rootNode, bool isExterior)
|
||||||
{
|
{
|
||||||
mRootNode = rootNode;
|
mRootNode = rootNode;
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ void CSVRender::LightingNight::activate (osg::Group* rootNode)
|
|||||||
mLightSource->setLight(light);
|
mLightSource->setLight(light);
|
||||||
|
|
||||||
mRootNode->addChild(mLightSource);
|
mRootNode->addChild(mLightSource);
|
||||||
|
|
||||||
|
updateDayNightMode(isExterior ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingNight::deactivate()
|
void CSVRender::LightingNight::deactivate()
|
||||||
|
@ -11,7 +11,7 @@ namespace CSVRender
|
|||||||
|
|
||||||
LightingNight();
|
LightingNight();
|
||||||
|
|
||||||
virtual void activate (osg::Group* rootNode);
|
virtual void activate (osg::Group* rootNode, bool isExterior);
|
||||||
virtual void deactivate();
|
virtual void deactivate();
|
||||||
|
|
||||||
virtual osg::Vec4f getAmbientColour(osg::Vec4f *defaultAmbient);
|
virtual osg::Vec4f getAmbientColour(osg::Vec4f *defaultAmbient);
|
||||||
|
@ -20,6 +20,8 @@ CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
|
|||||||
connect (&mData, SIGNAL (assetTablesChanged ()),
|
connect (&mData, SIGNAL (assetTablesChanged ()),
|
||||||
this, SLOT (assetTablesChanged ()));
|
this, SLOT (assetTablesChanged ()));
|
||||||
|
|
||||||
|
setExterior(false);
|
||||||
|
|
||||||
if (!referenceable)
|
if (!referenceable)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *references =
|
QAbstractItemModel *references =
|
||||||
|
@ -195,6 +195,7 @@ SceneWidget::SceneWidget(std::shared_ptr<Resource::ResourceSystem> resourceSyste
|
|||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
, mLighting(nullptr)
|
, mLighting(nullptr)
|
||||||
, mHasDefaultAmbient(false)
|
, mHasDefaultAmbient(false)
|
||||||
|
, mIsExterior(true)
|
||||||
, mPrevMouseX(0)
|
, mPrevMouseX(0)
|
||||||
, mPrevMouseY(0)
|
, mPrevMouseY(0)
|
||||||
, mCamPositionSet(false)
|
, mCamPositionSet(false)
|
||||||
@ -250,7 +251,7 @@ void SceneWidget::setLighting(Lighting *lighting)
|
|||||||
mLighting->deactivate();
|
mLighting->deactivate();
|
||||||
|
|
||||||
mLighting = lighting;
|
mLighting = lighting;
|
||||||
mLighting->activate (mRootNode);
|
mLighting->activate (mRootNode, mIsExterior);
|
||||||
|
|
||||||
osg::Vec4f ambient = mLighting->getAmbientColour(mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
osg::Vec4f ambient = mLighting->getAmbientColour(mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
||||||
setAmbient(ambient);
|
setAmbient(ambient);
|
||||||
@ -315,6 +316,11 @@ void SceneWidget::setDefaultAmbient (const osg::Vec4f& colour)
|
|||||||
setAmbient(mLighting->getAmbientColour(&mDefaultAmbient));
|
setAmbient(mLighting->getAmbientColour(&mDefaultAmbient));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneWidget::setExterior (bool isExterior)
|
||||||
|
{
|
||||||
|
mIsExterior = isExterior;
|
||||||
|
}
|
||||||
|
|
||||||
void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
mCurrentCamControl->handleMouseMoveEvent(event->x() - mPrevMouseX, event->y() - mPrevMouseY);
|
mCurrentCamControl->handleMouseMoveEvent(event->x() - mPrevMouseX, event->y() - mPrevMouseY);
|
||||||
|
@ -89,6 +89,8 @@ namespace CSVRender
|
|||||||
void setDefaultAmbient (const osg::Vec4f& colour);
|
void setDefaultAmbient (const osg::Vec4f& colour);
|
||||||
///< \note The actual ambient colour may differ based on lighting settings.
|
///< \note The actual ambient colour may differ based on lighting settings.
|
||||||
|
|
||||||
|
void setExterior (bool isExterior);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setLighting (Lighting *lighting);
|
void setLighting (Lighting *lighting);
|
||||||
///< \attention The ownership of \a lighting is not transferred to *this.
|
///< \attention The ownership of \a lighting is not transferred to *this.
|
||||||
@ -104,6 +106,7 @@ namespace CSVRender
|
|||||||
|
|
||||||
osg::Vec4f mDefaultAmbient;
|
osg::Vec4f mDefaultAmbient;
|
||||||
bool mHasDefaultAmbient;
|
bool mHasDefaultAmbient;
|
||||||
|
bool mIsExterior;
|
||||||
LightingDay mLightingDay;
|
LightingDay mLightingDay;
|
||||||
LightingNight mLightingNight;
|
LightingNight mLightingNight;
|
||||||
LightingBright mLightingBright;
|
LightingBright mLightingBright;
|
||||||
|
@ -28,6 +28,11 @@ void CSVRender::UnpagedWorldspaceWidget::update()
|
|||||||
|
|
||||||
setDefaultAmbient (colour);
|
setDefaultAmbient (colour);
|
||||||
|
|
||||||
|
bool isInterior = (record.get().mData.mFlags & ESM::Cell::Interior) != 0;
|
||||||
|
bool behaveLikeExterior = (record.get().mData.mFlags & ESM::Cell::QuasiEx) != 0;
|
||||||
|
|
||||||
|
setExterior(behaveLikeExterior || !isInterior);
|
||||||
|
|
||||||
/// \todo deal with mSunlight and mFog/mForDensity
|
/// \todo deal with mSunlight and mFog/mForDensity
|
||||||
|
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
@ -226,6 +226,8 @@ namespace MWBase
|
|||||||
|
|
||||||
virtual int getCurrentWeather() const = 0;
|
virtual int getCurrentWeather() const = 0;
|
||||||
|
|
||||||
|
virtual unsigned int getNightDayMode() const = 0;
|
||||||
|
|
||||||
virtual int getMasserPhase() const = 0;
|
virtual int getMasserPhase() const = 0;
|
||||||
|
|
||||||
virtual int getSecundaPhase() const = 0;
|
virtual int getSecundaPhase() const = 0;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <osg/BlendFunc>
|
#include <osg/BlendFunc>
|
||||||
#include <osg/Material>
|
#include <osg/Material>
|
||||||
#include <osg/PositionAttitudeTransform>
|
#include <osg/PositionAttitudeTransform>
|
||||||
|
#include <osg/Switch>
|
||||||
|
|
||||||
#include <osgParticle/ParticleSystem>
|
#include <osgParticle/ParticleSystem>
|
||||||
#include <osgParticle/ParticleProcessor>
|
#include <osgParticle/ParticleProcessor>
|
||||||
@ -33,6 +34,7 @@
|
|||||||
#include <components/sceneutil/lightutil.hpp>
|
#include <components/sceneutil/lightutil.hpp>
|
||||||
#include <components/sceneutil/skeleton.hpp>
|
#include <components/sceneutil/skeleton.hpp>
|
||||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||||
|
#include <components/sceneutil/util.hpp>
|
||||||
|
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
@ -91,6 +93,47 @@ namespace
|
|||||||
std::vector<osg::ref_ptr<osg::Node> > mToRemove;
|
std::vector<osg::ref_ptr<osg::Node> > mToRemove;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DayNightCallback : public osg::NodeCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DayNightCallback() : mCurrentState(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||||
|
{
|
||||||
|
unsigned int state = MWBase::Environment::get().getWorld()->getNightDayMode();
|
||||||
|
const unsigned int newState = node->asGroup()->getNumChildren() > state ? state : 0;
|
||||||
|
|
||||||
|
if (newState != mCurrentState)
|
||||||
|
{
|
||||||
|
mCurrentState = newState;
|
||||||
|
node->asSwitch()->setSingleChildOn(mCurrentState);
|
||||||
|
}
|
||||||
|
|
||||||
|
traverse(node, nv);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int mCurrentState;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AddSwitchCallbacksVisitor : public osg::NodeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AddSwitchCallbacksVisitor()
|
||||||
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void apply(osg::Switch &switchNode)
|
||||||
|
{
|
||||||
|
if (switchNode.getName() == Constants::NightDayLabel)
|
||||||
|
switchNode.addUpdateCallback(new DayNightCallback());
|
||||||
|
|
||||||
|
traverse(switchNode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
NifOsg::TextKeyMap::const_iterator findGroupStart(const NifOsg::TextKeyMap &keys, const std::string &groupname)
|
NifOsg::TextKeyMap::const_iterator findGroupStart(const NifOsg::TextKeyMap &keys, const std::string &groupname)
|
||||||
{
|
{
|
||||||
NifOsg::TextKeyMap::const_iterator iter(keys.begin());
|
NifOsg::TextKeyMap::const_iterator iter(keys.begin());
|
||||||
@ -1933,6 +1976,12 @@ namespace MWRender
|
|||||||
mObjectRoot->accept(visitor);
|
mObjectRoot->accept(visitor);
|
||||||
visitor.remove();
|
visitor.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel))
|
||||||
|
{
|
||||||
|
AddSwitchCallbacksVisitor visitor;
|
||||||
|
mObjectRoot->accept(visitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::AnimState::~AnimState()
|
Animation::AnimState::~AnimState()
|
||||||
|
@ -547,6 +547,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fall
|
|||||||
, mFastForward(false)
|
, mFastForward(false)
|
||||||
, mWeatherUpdateTime(mHoursBetweenWeatherChanges)
|
, mWeatherUpdateTime(mHoursBetweenWeatherChanges)
|
||||||
, mTransitionFactor(0)
|
, mTransitionFactor(0)
|
||||||
|
, mNightDayMode(Default)
|
||||||
, mCurrentWeather(0)
|
, mCurrentWeather(0)
|
||||||
, mNextWeather(0)
|
, mNextWeather(0)
|
||||||
, mQueuedWeather(0)
|
, mQueuedWeather(0)
|
||||||
@ -683,6 +684,14 @@ void WeatherManager::update(float duration, bool paused, const TimeStamp& time,
|
|||||||
updateWeatherTransitions(duration);
|
updateWeatherTransitions(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDay = time.getHour() >= mSunriseTime && time.getHour() <= mTimeSettings.mNightStart;
|
||||||
|
if (isExterior && !isDay)
|
||||||
|
mNightDayMode = ExteriorNight;
|
||||||
|
else if (!isExterior && isDay && mWeatherSettings[mCurrentWeather].mGlareView >= 0.5f)
|
||||||
|
mNightDayMode = InteriorDay;
|
||||||
|
else
|
||||||
|
mNightDayMode = Default;
|
||||||
|
|
||||||
if(!isExterior)
|
if(!isExterior)
|
||||||
{
|
{
|
||||||
mRendering.setSkyEnabled(false);
|
mRendering.setSkyEnabled(false);
|
||||||
@ -823,6 +832,11 @@ unsigned int WeatherManager::getWeatherID() const
|
|||||||
return mCurrentWeather;
|
return mCurrentWeather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NightDayMode WeatherManager::getNightDayMode() const
|
||||||
|
{
|
||||||
|
return mNightDayMode;
|
||||||
|
}
|
||||||
|
|
||||||
bool WeatherManager::useTorches(float hour) const
|
bool WeatherManager::useTorches(float hour) const
|
||||||
{
|
{
|
||||||
bool isDark = hour < mSunriseTime || hour > mTimeSettings.mNightStart;
|
bool isDark = hour < mSunriseTime || hour > mTimeSettings.mNightStart;
|
||||||
|
@ -40,6 +40,13 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
class TimeStamp;
|
class TimeStamp;
|
||||||
|
|
||||||
|
enum NightDayMode
|
||||||
|
{
|
||||||
|
Default = 0,
|
||||||
|
ExteriorNight = 1,
|
||||||
|
InteriorDay = 2
|
||||||
|
};
|
||||||
|
|
||||||
struct WeatherSetting
|
struct WeatherSetting
|
||||||
{
|
{
|
||||||
float mPreSunriseTime;
|
float mPreSunriseTime;
|
||||||
@ -277,6 +284,7 @@ namespace MWWorld
|
|||||||
void stopSounds();
|
void stopSounds();
|
||||||
|
|
||||||
float getWindSpeed() const;
|
float getWindSpeed() const;
|
||||||
|
NightDayMode getNightDayMode() const;
|
||||||
|
|
||||||
/// Are we in an ash or blight storm?
|
/// Are we in an ash or blight storm?
|
||||||
bool isInStorm() const;
|
bool isInStorm() const;
|
||||||
@ -329,6 +337,7 @@ namespace MWWorld
|
|||||||
bool mFastForward;
|
bool mFastForward;
|
||||||
float mWeatherUpdateTime;
|
float mWeatherUpdateTime;
|
||||||
float mTransitionFactor;
|
float mTransitionFactor;
|
||||||
|
NightDayMode mNightDayMode;
|
||||||
int mCurrentWeather;
|
int mCurrentWeather;
|
||||||
int mNextWeather;
|
int mNextWeather;
|
||||||
int mQueuedWeather;
|
int mQueuedWeather;
|
||||||
|
@ -2024,6 +2024,11 @@ namespace MWWorld
|
|||||||
return mWeatherManager->getWeatherID();
|
return mWeatherManager->getWeatherID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int World::getNightDayMode() const
|
||||||
|
{
|
||||||
|
return mWeatherManager->getNightDayMode();
|
||||||
|
}
|
||||||
|
|
||||||
void World::changeWeather(const std::string& region, const unsigned int id)
|
void World::changeWeather(const std::string& region, const unsigned int id)
|
||||||
{
|
{
|
||||||
mWeatherManager->changeWeather(region, id);
|
mWeatherManager->changeWeather(region, id);
|
||||||
|
@ -337,6 +337,8 @@ namespace MWWorld
|
|||||||
|
|
||||||
int getCurrentWeather() const override;
|
int getCurrentWeather() const override;
|
||||||
|
|
||||||
|
unsigned int getNightDayMode() const override;
|
||||||
|
|
||||||
int getMasserPhase() const override;
|
int getMasserPhase() const override;
|
||||||
|
|
||||||
int getSecundaPhase() const override;
|
int getSecundaPhase() const override;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef OPENMW_CONSTANTS_H
|
#ifndef OPENMW_CONSTANTS_H
|
||||||
#define OPENMW_CONSTANTS_H
|
#define OPENMW_CONSTANTS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Constants
|
namespace Constants
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -22,6 +24,9 @@ const float GravityConst = 8.96f;
|
|||||||
// Size of one exterior cell in game units
|
// Size of one exterior cell in game units
|
||||||
const int CellSizeInUnits = 8192;
|
const int CellSizeInUnits = 8192;
|
||||||
|
|
||||||
|
// A label to mark night/day visual switches
|
||||||
|
const std::string NightDayLabel = "NightDaySwitch";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
// resource
|
// resource
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/misc/constants.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
#include <components/resource/imagemanager.hpp>
|
#include <components/resource/imagemanager.hpp>
|
||||||
|
#include <components/sceneutil/util.hpp>
|
||||||
|
|
||||||
// particle
|
// particle
|
||||||
#include <osgParticle/ParticleSystem>
|
#include <osgParticle/ParticleSystem>
|
||||||
@ -608,6 +610,10 @@ namespace NifOsg
|
|||||||
const Nif::NiSwitchNode* niSwitchNode = static_cast<const Nif::NiSwitchNode*>(nifNode);
|
const Nif::NiSwitchNode* niSwitchNode = static_cast<const Nif::NiSwitchNode*>(nifNode);
|
||||||
osg::ref_ptr<osg::Switch> switchNode = handleSwitchNode(niSwitchNode);
|
osg::ref_ptr<osg::Switch> switchNode = handleSwitchNode(niSwitchNode);
|
||||||
node->addChild(switchNode);
|
node->addChild(switchNode);
|
||||||
|
|
||||||
|
if (niSwitchNode->name == Constants::NightDayLabel && !SceneUtil::hasUserDescription(rootNode, Constants::NightDayLabel))
|
||||||
|
rootNode->getOrCreateUserDataContainer()->addDescription(Constants::NightDayLabel);
|
||||||
|
|
||||||
const Nif::NodeList &children = niSwitchNode->children;
|
const Nif::NodeList &children = niSwitchNode->children;
|
||||||
for(size_t i = 0;i < children.length();++i)
|
for(size_t i = 0;i < children.length();++i)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
|
#include <osg/Node>
|
||||||
|
|
||||||
namespace SceneUtil
|
namespace SceneUtil
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,4 +55,22 @@ float makeOsgColorComponent(unsigned int value, unsigned int shift)
|
|||||||
return float((value >> shift) & 0xFFu) / 255.0f;
|
return float((value >> shift) & 0xFFu) / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasUserDescription(const osg::Node* node, const std::string pattern)
|
||||||
|
{
|
||||||
|
if (node == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const osg::UserDataContainer* udc = node->getUserDataContainer();
|
||||||
|
if (udc && udc->getNumDescriptions() > 0)
|
||||||
|
{
|
||||||
|
for (auto& descr : udc->getDescriptions())
|
||||||
|
{
|
||||||
|
if (descr == pattern)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ namespace SceneUtil
|
|||||||
|
|
||||||
float makeOsgColorComponent (unsigned int value, unsigned int shift);
|
float makeOsgColorComponent (unsigned int value, unsigned int shift);
|
||||||
|
|
||||||
|
bool hasUserDescription(const osg::Node* node, const std::string pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user