mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
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));
|
||||
}
|
||||
|
||||
// Helper for adding AlphaFader to a subgraph
|
||||
// Helper for adding AlphaFaders to a subgraph
|
||||
class SetupVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
SetupVisitor()
|
||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||
{
|
||||
mAlphaFader = new AlphaFader;
|
||||
}
|
||||
|
||||
virtual void apply(osg::Node &node)
|
||||
|
@ -1225,22 +1224,26 @@ public:
|
|||
callback = callback->getNestedCallback();
|
||||
}
|
||||
|
||||
osg::ref_ptr<AlphaFader> alphaFader (new AlphaFader);
|
||||
|
||||
if (composite)
|
||||
composite->addController(mAlphaFader);
|
||||
composite->addController(alphaFader);
|
||||
else
|
||||
node.addUpdateCallback(mAlphaFader);
|
||||
node.addUpdateCallback(alphaFader);
|
||||
|
||||
mAlphaFaders.push_back(alphaFader);
|
||||
}
|
||||
}
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
osg::ref_ptr<AlphaFader> getAlphaFader()
|
||||
std::vector<osg::ref_ptr<AlphaFader> > getAlphaFaders()
|
||||
{
|
||||
return mAlphaFader;
|
||||
return mAlphaFaders;
|
||||
}
|
||||
|
||||
private:
|
||||
osg::ref_ptr<AlphaFader> mAlphaFader;
|
||||
std::vector<osg::ref_ptr<AlphaFader> > mAlphaFaders;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -1437,7 +1440,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||
{
|
||||
mParticleNode->removeChild(mParticleEffect);
|
||||
mParticleEffect = NULL;
|
||||
mParticleFader = NULL;
|
||||
mParticleFaders.clear();
|
||||
}
|
||||
|
||||
if (mCurrentParticleEffect.empty())
|
||||
|
@ -1464,7 +1467,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||
|
||||
AlphaFader::SetupVisitor alphaFaderSetupVisitor;
|
||||
mParticleEffect->accept(alphaFaderSetupVisitor);
|
||||
mParticleFader = alphaFaderSetupVisitor.getAlphaFader();
|
||||
mParticleFaders = alphaFaderSetupVisitor.getAlphaFaders();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1545,8 +1548,8 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||
|
||||
if (mRainFader)
|
||||
mRainFader->setAlpha(weather.mEffectFade * 0.6); // * Rain_Threshold?
|
||||
if (mParticleFader)
|
||||
mParticleFader->setAlpha(weather.mEffectFade);
|
||||
for (std::vector<osg::ref_ptr<AlphaFader> >::const_iterator it = mParticleFaders.begin(); it != mParticleFaders.end(); ++it)
|
||||
(*it)->setAlpha(weather.mEffectFade);
|
||||
}
|
||||
|
||||
void SkyManager::sunEnable()
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace MWRender
|
|||
|
||||
osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
|
||||
osg::ref_ptr<osg::Node> mParticleEffect;
|
||||
osg::ref_ptr<AlphaFader> mParticleFader;
|
||||
std::vector<osg::ref_ptr<AlphaFader> > mParticleFaders;
|
||||
|
||||
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.
|
||||
/// After a frame is completed the places are swapped.
|
||||
/// @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.
|
||||
class StateSetUpdater : public osg::NodeCallback
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue