forked from mirror/openmw-tes3mp
Move part of addGlow() to addSpellCastGlow()
This commit is contained in:
parent
1c76c93ed8
commit
83b715734f
1 changed files with 45 additions and 49 deletions
|
@ -1199,28 +1199,22 @@ namespace MWRender
|
||||||
glowColor.y() = effect->mData.mGreen / 255.f;
|
glowColor.y() = effect->mData.mGreen / 255.f;
|
||||||
glowColor.z() = effect->mData.mBlue / 255.f;
|
glowColor.z() = effect->mData.mBlue / 255.f;
|
||||||
|
|
||||||
if (!mGlowUpdater) // If there is no glow on object
|
if (!mGlowUpdater || (mGlowUpdater->isDone() || (mGlowUpdater->isPermanentGlowUpdater() == true)))
|
||||||
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())
|
if (mGlowUpdater && mGlowUpdater->isDone())
|
||||||
node->removeUpdateCallback(mGlowUpdater);
|
mObjectRoot->removeUpdateCallback(mGlowUpdater);
|
||||||
|
|
||||||
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
|
|
||||||
node->accept(findLowestUnusedTexUnitVisitor);
|
|
||||||
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
|
|
||||||
|
|
||||||
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
||||||
{
|
{
|
||||||
mGlowUpdater->setColor(glowColor);
|
mGlowUpdater->setColor(glowColor);
|
||||||
mGlowUpdater->setDuration(glowDuration);
|
mGlowUpdater->setDuration(1.5); // Glow length measured from original engine as about 1.5 seconds
|
||||||
}
|
}
|
||||||
else
|
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;
|
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
|
||||||
for (int i=0; i<32; ++i)
|
for (int i=0; i<32; ++i)
|
||||||
|
@ -1241,11 +1235,14 @@ namespace MWRender
|
||||||
textures.push_back(tex);
|
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);
|
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
|
||||||
mGlowUpdater = glowUpdater;
|
mGlowUpdater = glowUpdater;
|
||||||
node->addUpdateCallback(glowUpdater);
|
node->addUpdateCallback(glowUpdater);
|
||||||
|
|
||||||
|
|
||||||
// set a texture now so that the ShaderVisitor can find it
|
// set a texture now so that the ShaderVisitor can find it
|
||||||
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
||||||
if (!node->getStateSet())
|
if (!node->getStateSet())
|
||||||
|
@ -1259,7 +1256,6 @@ namespace MWRender
|
||||||
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
||||||
mResourceSystem->getSceneManager()->recreateShaders(node);
|
mResourceSystem->getSceneManager()->recreateShaders(node);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Should not be here
|
// TODO: Should not be here
|
||||||
osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const
|
osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const
|
||||||
|
|
Loading…
Reference in a new issue