1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:53:53 +00:00

Move part of addGlow() to addSpellCastGlow()

This commit is contained in:
Allofich 2016-08-10 02:50:30 +09:00
parent 1c76c93ed8
commit 83b715734f

View file

@ -1199,28 +1199,22 @@ namespace MWRender
glowColor.y() = effect->mData.mGreen / 255.f;
glowColor.z() = effect->mData.mBlue / 255.f;
if (!mGlowUpdater) // If there is no glow on object
addGlow(mObjectRoot, glowColor, 1.5); // Glow length measured from original engine as about 1.5 seconds
else if (mGlowUpdater->isDone() || (mGlowUpdater->isPermanentGlowUpdater() == true))
addGlow(mObjectRoot, glowColor, 1.5);
}
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor, float glowDuration)
if (!mGlowUpdater || (mGlowUpdater->isDone() || (mGlowUpdater->isPermanentGlowUpdater() == true)))
{
if (mGlowUpdater && mGlowUpdater->isDone())
node->removeUpdateCallback(mGlowUpdater);
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
node->accept(findLowestUnusedTexUnitVisitor);
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
mObjectRoot->removeUpdateCallback(mGlowUpdater);
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
{
mGlowUpdater->setColor(glowColor);
mGlowUpdater->setDuration(glowDuration);
mGlowUpdater->setDuration(1.5); // Glow length measured from original engine as about 1.5 seconds
}
else
addGlow(mObjectRoot, glowColor, 1.5);
}
}
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor, float glowDuration)
{
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
for (int i=0; i<32; ++i)
@ -1241,11 +1235,14 @@ namespace MWRender
textures.push_back(tex);
}
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
node->accept(findLowestUnusedTexUnitVisitor);
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
mGlowUpdater = glowUpdater;
node->addUpdateCallback(glowUpdater);
// set a texture now so that the ShaderVisitor can find it
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
if (!node->getStateSet())
@ -1259,7 +1256,6 @@ namespace MWRender
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
mResourceSystem->getSceneManager()->recreateShaders(node);
}
}
// TODO: Should not be here
osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const