forked from teamnwah/openmw-tes3coop
Don't add the same AlphaFader to multiple nodes
This commit is contained in:
parent
d6f45c3390
commit
5ca0ae5232
3 changed files with 16 additions and 12 deletions
|
@ -1196,14 +1196,13 @@ public:
|
||||||
mat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,0,mAlpha));
|
mat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,0,mAlpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper for adding AlphaFader to a subgraph
|
// Helper for adding AlphaFaders to a subgraph
|
||||||
class SetupVisitor : public osg::NodeVisitor
|
class SetupVisitor : public osg::NodeVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SetupVisitor()
|
SetupVisitor()
|
||||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||||
{
|
{
|
||||||
mAlphaFader = new AlphaFader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(osg::Node &node)
|
virtual void apply(osg::Node &node)
|
||||||
|
@ -1225,22 +1224,26 @@ public:
|
||||||
callback = callback->getNestedCallback();
|
callback = callback->getNestedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::ref_ptr<AlphaFader> alphaFader (new AlphaFader);
|
||||||
|
|
||||||
if (composite)
|
if (composite)
|
||||||
composite->addController(mAlphaFader);
|
composite->addController(alphaFader);
|
||||||
else
|
else
|
||||||
node.addUpdateCallback(mAlphaFader);
|
node.addUpdateCallback(alphaFader);
|
||||||
|
|
||||||
|
mAlphaFaders.push_back(alphaFader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
traverse(node);
|
traverse(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<AlphaFader> getAlphaFader()
|
std::vector<osg::ref_ptr<AlphaFader> > getAlphaFaders()
|
||||||
{
|
{
|
||||||
return mAlphaFader;
|
return mAlphaFaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
osg::ref_ptr<AlphaFader> mAlphaFader;
|
std::vector<osg::ref_ptr<AlphaFader> > mAlphaFaders;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1437,7 +1440,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
||||||
{
|
{
|
||||||
mParticleNode->removeChild(mParticleEffect);
|
mParticleNode->removeChild(mParticleEffect);
|
||||||
mParticleEffect = NULL;
|
mParticleEffect = NULL;
|
||||||
mParticleFader = NULL;
|
mParticleFaders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentParticleEffect.empty())
|
if (mCurrentParticleEffect.empty())
|
||||||
|
@ -1464,7 +1467,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
||||||
|
|
||||||
AlphaFader::SetupVisitor alphaFaderSetupVisitor;
|
AlphaFader::SetupVisitor alphaFaderSetupVisitor;
|
||||||
mParticleEffect->accept(alphaFaderSetupVisitor);
|
mParticleEffect->accept(alphaFaderSetupVisitor);
|
||||||
mParticleFader = alphaFaderSetupVisitor.getAlphaFader();
|
mParticleFaders = alphaFaderSetupVisitor.getAlphaFaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1545,8 +1548,8 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
||||||
|
|
||||||
if (mRainFader)
|
if (mRainFader)
|
||||||
mRainFader->setAlpha(weather.mEffectFade * 0.6); // * Rain_Threshold?
|
mRainFader->setAlpha(weather.mEffectFade * 0.6); // * Rain_Threshold?
|
||||||
if (mParticleFader)
|
for (std::vector<osg::ref_ptr<AlphaFader> >::const_iterator it = mParticleFaders.begin(); it != mParticleFaders.end(); ++it)
|
||||||
mParticleFader->setAlpha(weather.mEffectFade);
|
(*it)->setAlpha(weather.mEffectFade);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyManager::sunEnable()
|
void SkyManager::sunEnable()
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace MWRender
|
||||||
|
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
|
osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
|
||||||
osg::ref_ptr<osg::Node> mParticleEffect;
|
osg::ref_ptr<osg::Node> mParticleEffect;
|
||||||
osg::ref_ptr<AlphaFader> mParticleFader;
|
std::vector<osg::ref_ptr<AlphaFader> > mParticleFaders;
|
||||||
|
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> mCloudNode;
|
osg::ref_ptr<osg::PositionAttitudeTransform> mCloudNode;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace SceneUtil
|
||||||
/// the first StateSet is the one we can write to, the second is the one currently in use by the draw traversal of the last frame.
|
/// the first StateSet is the one we can write to, the second is the one currently in use by the draw traversal of the last frame.
|
||||||
/// After a frame is completed the places are swapped.
|
/// After a frame is completed the places are swapped.
|
||||||
/// @par Must be set as UpdateCallback on a Node.
|
/// @par Must be set as UpdateCallback on a Node.
|
||||||
|
/// @note Do not add the same StateSetUpdater to multiple nodes.
|
||||||
/// @note Do not add multiple StateSetControllers on the same Node as they will conflict - instead use the CompositeStateSetUpdater.
|
/// @note Do not add multiple StateSetControllers on the same Node as they will conflict - instead use the CompositeStateSetUpdater.
|
||||||
class StateSetUpdater : public osg::NodeCallback
|
class StateSetUpdater : public osg::NodeCallback
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue