Don't remove uniform when spell glow ends

pull/35/head
Allofich 9 years ago
parent 35c14bb9bb
commit 1910128e9c

@ -90,7 +90,7 @@ namespace
{ {
public: public:
GlowUpdater(int texUnit, osg::Vec4f color, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures, GlowUpdater(int texUnit, osg::Vec4f color, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures,
osg::ref_ptr<osg::Node> node, float maxduration, Resource::ResourceSystem* resourcesystem, osg::Uniform* uniform) osg::ref_ptr<osg::Node> node, float maxduration, Resource::ResourceSystem* resourcesystem)
: mTexUnit(texUnit) : mTexUnit(texUnit)
, mColor(color) , mColor(color)
, mTextures(textures) , mTextures(textures)
@ -99,7 +99,6 @@ namespace
, mStartingTime(0) , mStartingTime(0)
, mResourceSystem(resourcesystem) , mResourceSystem(resourcesystem)
, mDone(false) , mDone(false)
, mUniform(uniform)
, mWatchedSpellGlow(NULL) , mWatchedSpellGlow(NULL)
{ {
} }
@ -160,13 +159,9 @@ namespace
writableStateSet = osg::clone(mNode->getStateSet(), osg::CopyOp::SHALLOW_COPY); writableStateSet = osg::clone(mNode->getStateSet(), osg::CopyOp::SHALLOW_COPY);
for (size_t i = 0; i < mTextures.size(); i++) for (size_t i = 0; i < mTextures.size(); i++)
{
writableStateSet->removeTextureAttribute(mTexUnit, mTextures[i]); writableStateSet->removeTextureAttribute(mTexUnit, mTextures[i]);
}
writableStateSet->removeUniform(mUniform); // remove the uniform given to the temporary glow in addglow()
mNode->setStateSet(writableStateSet); mNode->setStateSet(writableStateSet);
this->reset(); // without this a texture from the glow will continue to show on the object this->reset(); // without this a texture from the glow will continue to show on the object
mResourceSystem->getSceneManager()->recreateShaders(mNode); mResourceSystem->getSceneManager()->recreateShaders(mNode);
mDone = true; mDone = true;
@ -212,7 +207,6 @@ namespace
float mStartingTime; float mStartingTime;
Resource::ResourceSystem* mResourceSystem; Resource::ResourceSystem* mResourceSystem;
bool mDone; bool mDone;
osg::Uniform* mUniform;
osg::ref_ptr<GlowUpdater> mWatchedSpellGlow; osg::ref_ptr<GlowUpdater> mWatchedSpellGlow;
}; };
@ -1246,10 +1240,7 @@ namespace MWRender
node->accept(findLowestUnusedTexUnitVisitor); node->accept(findLowestUnusedTexUnitVisitor);
texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit; texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
osg::Uniform* uniform = new osg::Uniform("envMapColor", glowColor); osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem, uniform);
node->addUpdateCallback(glowUpdater); node->addUpdateCallback(glowUpdater);
if (node->getUpdateCallback() && if (node->getUpdateCallback() &&
@ -1267,7 +1258,7 @@ namespace MWRender
node->setStateSet(writableStateSet); node->setStateSet(writableStateSet);
} }
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON); writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
writableStateSet->addUniform(uniform); writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
mResourceSystem->getSceneManager()->recreateShaders(node); mResourceSystem->getSceneManager()->recreateShaders(node);
} }

Loading…
Cancel
Save