forked from mirror/openmw-tes3mp
Don't remove uniform when spell glow ends
This commit is contained in:
parent
35c14bb9bb
commit
1910128e9c
1 changed files with 6 additions and 15 deletions
|
@ -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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -139,8 +138,8 @@ namespace
|
||||||
// the permanent glow to display its glow texture cycling properly.
|
// the permanent glow to display its glow texture cycling properly.
|
||||||
if (mWatchedSpellGlow != NULL && mWatchedSpellGlow->isDone())
|
if (mWatchedSpellGlow != NULL && mWatchedSpellGlow->isDone())
|
||||||
{
|
{
|
||||||
mNode->removeUpdateCallback(mWatchedSpellGlow);
|
mNode->removeUpdateCallback(mWatchedSpellGlow);
|
||||||
mWatchedSpellGlow = NULL;
|
mWatchedSpellGlow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the starting time to measure glow duration from if this is a temporary glow
|
// Set the starting time to measure glow duration from if this is a temporary glow
|
||||||
|
@ -160,15 +159,11 @@ 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…
Reference in a new issue