mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 09:41:33 +00:00
fixes setActorFade logic errors (#3195)
* resets state updater to apply light settings (#3141) resets state updater to apply light settings With this PR we achieve the same effect with fewer lines of code. * fixes LightSource logic errors We currently update `LightSource::setActorFade` in `TransparencyUpdater`. There are several logic errors inherent in this approach: 1. We fail to update `LightSource::setActorFade` for off screen actors because their `TransparencyUpdater` cull callback is not invoked. 2. We fail to update `LightSource::setActorFade` in the instant that a `TransparencyUpdater` is removed. 3. We fail to update `setActorFade` when an `mExtraLightSource` is created after calling `Animation::setAlpha`. With this PR we avoid such issues by updating `LightSource::setActorFade` in `Animation::setAlpha` and `Animation::addExtraLightSource` instead.
This commit is contained in:
parent
f684c1da52
commit
3042c000c6
1 changed files with 3 additions and 9 deletions
|
@ -389,11 +389,6 @@ namespace MWRender
|
||||||
mAlpha = alpha;
|
mAlpha = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLightSource(const osg::ref_ptr<SceneUtil::LightSource>& lightSource)
|
|
||||||
{
|
|
||||||
mLightSource = lightSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setDefaults(osg::StateSet* stateset) override
|
void setDefaults(osg::StateSet* stateset) override
|
||||||
{
|
{
|
||||||
|
@ -416,13 +411,10 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
osg::Material* material = static_cast<osg::Material*>(stateset->getAttribute(osg::StateAttribute::MATERIAL));
|
osg::Material* material = static_cast<osg::Material*>(stateset->getAttribute(osg::StateAttribute::MATERIAL));
|
||||||
material->setAlpha(osg::Material::FRONT_AND_BACK, mAlpha);
|
material->setAlpha(osg::Material::FRONT_AND_BACK, mAlpha);
|
||||||
if (mLightSource)
|
|
||||||
mLightSource->setActorFade(mAlpha);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
osg::ref_ptr<SceneUtil::LightSource> mLightSource;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Animation::AnimSource
|
struct Animation::AnimSource
|
||||||
|
@ -1485,6 +1477,7 @@ namespace MWRender
|
||||||
bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior();
|
bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior();
|
||||||
|
|
||||||
mExtraLightSource = SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior);
|
mExtraLightSource = SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior);
|
||||||
|
mExtraLightSource->setActorFade(mAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture)
|
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture)
|
||||||
|
@ -1639,7 +1632,6 @@ namespace MWRender
|
||||||
if (mTransparencyUpdater == nullptr)
|
if (mTransparencyUpdater == nullptr)
|
||||||
{
|
{
|
||||||
mTransparencyUpdater = new TransparencyUpdater(alpha);
|
mTransparencyUpdater = new TransparencyUpdater(alpha);
|
||||||
mTransparencyUpdater->setLightSource(mExtraLightSource);
|
|
||||||
mObjectRoot->addCullCallback(mTransparencyUpdater);
|
mObjectRoot->addCullCallback(mTransparencyUpdater);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1650,6 +1642,8 @@ namespace MWRender
|
||||||
mObjectRoot->removeCullCallback(mTransparencyUpdater);
|
mObjectRoot->removeCullCallback(mTransparencyUpdater);
|
||||||
mTransparencyUpdater = nullptr;
|
mTransparencyUpdater = nullptr;
|
||||||
}
|
}
|
||||||
|
if (mExtraLightSource)
|
||||||
|
mExtraLightSource->setActorFade(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::setLightEffect(float effect)
|
void Animation::setLightEffect(float effect)
|
||||||
|
|
Loading…
Reference in a new issue