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

@ -571,14 +571,13 @@ namespace MWMechanics
{ {
short effectId = effect.mId; short effectId = effect.mId;
if (target.getClass().canLock(target)) if (target.getClass().canLock(target))
{
if (effectId == ESM::MagicEffect::Lock)
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magiceffect; const ESM::MagicEffect *magiceffect = store.get<ESM::MagicEffect>().find(effectId);
magiceffect = store.get<ESM::MagicEffect>().find(effectId);
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
animation->addSpellCastGlow(magiceffect); animation->addSpellCastGlow(magiceffect);
if (effectId == ESM::MagicEffect::Lock)
{
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)

@ -267,9 +267,15 @@ namespace MWRender
} }
virtual void setDefaults(osg::StateSet *stateset) virtual void setDefaults(osg::StateSet *stateset)
{
if (mDone)
{
stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE);
stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXGEN);
}
else
{ {
stateset->setTextureMode(mTexUnit, GL_TEXTURE_2D, osg::StateAttribute::ON); stateset->setTextureMode(mTexUnit, GL_TEXTURE_2D, osg::StateAttribute::ON);
osg::TexGen* texGen = new osg::TexGen; osg::TexGen* texGen = new osg::TexGen;
texGen->setMode(osg::TexGen::SPHERE_MAP); texGen->setMode(osg::TexGen::SPHERE_MAP);
@ -283,11 +289,8 @@ namespace MWRender
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR); texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
stateset->setTextureAttributeAndModes(mTexUnit, texEnv, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(mTexUnit, texEnv, osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("envMapColor", mColor));
// Reduce the texture list back down by one when a temporary glow finishes }
// to allow FindLowestUnusedTexUnitVisitor to choose the same texunit again.
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