pull/35/head
Allofich 9 years ago
parent 775162ccdf
commit 9b2cb2fb8c

@ -572,13 +572,12 @@ namespace MWMechanics
short effectId = effect.mId; short effectId = effect.mId;
if (target.getClass().canLock(target)) if (target.getClass().canLock(target))
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magiceffect;
magiceffect = store.get<ESM::MagicEffect>().find(effectId);
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
animation->addSpellCastGlow(magiceffect);
if (effectId == ESM::MagicEffect::Lock) if (effectId == ESM::MagicEffect::Lock)
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magiceffect = store.get<ESM::MagicEffect>().find(effectId);
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
animation->addSpellCastGlow(magiceffect);
if (target.getCellRef().getLockLevel() < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude if (target.getCellRef().getLockLevel() < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude
{ {
if (caster == getPlayer()) if (caster == getPlayer())
@ -589,6 +588,10 @@ namespace MWMechanics
} }
else if (effectId == ESM::MagicEffect::Open) else if (effectId == ESM::MagicEffect::Open)
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magiceffect = store.get<ESM::MagicEffect>().find(effectId);
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
animation->addSpellCastGlow(magiceffect);
if (target.getCellRef().getLockLevel() <= magnitude) if (target.getCellRef().getLockLevel() <= magnitude)
{ {
if (target.getCellRef().getLockLevel() > 0) if (target.getCellRef().getLockLevel() > 0)

@ -268,26 +268,29 @@ namespace MWRender
virtual void setDefaults(osg::StateSet *stateset) virtual void setDefaults(osg::StateSet *stateset)
{ {
stateset->setTextureMode(mTexUnit, GL_TEXTURE_2D, osg::StateAttribute::ON); if (mDone)
{
osg::TexGen* texGen = new osg::TexGen; stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE);
texGen->setMode(osg::TexGen::SPHERE_MAP); stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXGEN);
}
stateset->setTextureAttributeAndModes(mTexUnit, texGen, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); else
{
stateset->setTextureMode(mTexUnit, GL_TEXTURE_2D, osg::StateAttribute::ON);
osg::TexGen* texGen = new osg::TexGen;
texGen->setMode(osg::TexGen::SPHERE_MAP);
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine; stateset->setTextureAttributeAndModes(mTexUnit, texGen, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
texEnv->setSource0_RGB(osg::TexEnvCombine::CONSTANT);
texEnv->setConstantColor(mColor);
texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
texEnv->setSource2_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
stateset->setTextureAttributeAndModes(mTexUnit, texEnv, osg::StateAttribute::ON); osg::TexEnvCombine* texEnv = new osg::TexEnvCombine;
texEnv->setSource0_RGB(osg::TexEnvCombine::CONSTANT);
texEnv->setConstantColor(mColor);
texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
texEnv->setSource2_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
// Reduce the texture list back down by one when a temporary glow finishes stateset->setTextureAttributeAndModes(mTexUnit, texEnv, osg::StateAttribute::ON);
// to allow FindLowestUnusedTexUnitVisitor to choose the same texunit again. stateset->addUniform(new osg::Uniform("envMapColor", mColor));
if (mDone) }
stateset->getTextureAttributeList().resize(stateset->getTextureAttributeList().size() - 1);
} }
virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv) virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv)
@ -295,7 +298,6 @@ namespace MWRender
if (mColorChanged){ if (mColorChanged){
this->reset(); this->reset();
setDefaults(stateset); setDefaults(stateset);
mResourceSystem->getSceneManager()->recreateShaders(mNode);
mColorChanged = false; mColorChanged = false;
} }
if (mDone) if (mDone)
@ -313,10 +315,10 @@ namespace MWRender
{ {
if (mOriginalDuration >= 0) // if this glowupdater was a temporary glow since its creation if (mOriginalDuration >= 0) // if this glowupdater was a temporary glow since its creation
{ {
for (size_t i = 0; i < mTextures.size(); i++) stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE);
stateset->removeTextureAttribute(mTexUnit, mTextures[i]);
this->reset(); this->reset();
mDone = true; mDone = true;
mResourceSystem->getSceneManager()->recreateShaders(mNode);
} }
if (mOriginalDuration < 0) // if this glowupdater was originally a permanent glow if (mOriginalDuration < 0) // if this glowupdater was originally a permanent glow
{ {
@ -325,9 +327,7 @@ namespace MWRender
mColor = mOriginalColor; mColor = mOriginalColor;
this->reset(); this->reset();
setDefaults(stateset); setDefaults(stateset);
stateset->addUniform(new osg::Uniform("envMapColor", mColor));
} }
mResourceSystem->getSceneManager()->recreateShaders(mNode);
} }
} }

Loading…
Cancel
Save