Implement the NegativeLight flag

revert-6246b479
Evil Eye 1 year ago
parent bb8ac466d1
commit 7573004efc

@ -1490,11 +1490,6 @@ namespace MWRender
void Animation::addSpellCastGlow(const ESM::MagicEffect* effect, float glowDuration)
{
osg::Vec4f glowColor(1, 1, 1, 1);
glowColor.x() = effect->mData.mRed / 255.f;
glowColor.y() = effect->mData.mGreen / 255.f;
glowColor.z() = effect->mData.mBlue / 255.f;
if (!mGlowUpdater || (mGlowUpdater->isDone() || (mGlowUpdater->isPermanentGlowUpdater() == true)))
{
if (mGlowUpdater && mGlowUpdater->isDone())
@ -1502,11 +1497,12 @@ namespace MWRender
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
{
mGlowUpdater->setColor(glowColor);
mGlowUpdater->setColor(effect->getColor());
mGlowUpdater->setDuration(glowDuration);
}
else
mGlowUpdater = SceneUtil::addEnchantedGlow(mObjectRoot, mResourceSystem, glowColor, glowDuration);
mGlowUpdater
= SceneUtil::addEnchantedGlow(mObjectRoot, mResourceSystem, effect->getColor(), glowDuration);
}
}

@ -136,21 +136,14 @@ namespace
{
// Calculate combined light diffuse color from magical effects
osg::Vec4 lightDiffuseColor;
float lightDiffuseRed = 0.0f;
float lightDiffuseGreen = 0.0f;
float lightDiffuseBlue = 0.0f;
for (std::vector<ESM::ENAMstruct>::const_iterator iter(effects.mList.begin()); iter != effects.mList.end();
++iter)
for (const ESM::ENAMstruct& enam : effects.mList)
{
const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(iter->mEffectID);
lightDiffuseRed += (static_cast<float>(magicEffect->mData.mRed) / 255.f);
lightDiffuseGreen += (static_cast<float>(magicEffect->mData.mGreen) / 255.f);
lightDiffuseBlue += (static_cast<float>(magicEffect->mData.mBlue) / 255.f);
= MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(enam.mEffectID);
lightDiffuseColor += magicEffect->getColor();
}
int numberOfEffects = effects.mList.size();
lightDiffuseColor = osg::Vec4(lightDiffuseRed / numberOfEffects, lightDiffuseGreen / numberOfEffects,
lightDiffuseBlue / numberOfEffects, 1.0f);
lightDiffuseColor /= numberOfEffects;
return lightDiffuseColor;
}

@ -603,6 +603,14 @@ namespace ESM
mDescription.clear();
}
osg::Vec4f MagicEffect::getColor() const
{
osg::Vec4f color{ mData.mRed / 255.f, mData.mGreen / 255.f, mData.mBlue / 255.f, 1.f };
if (mData.mFlags & NegativeLight)
return osg::Vec4f(1.f, 1.f, 1.f, 2.f) - color;
return color;
}
const std::string& MagicEffect::indexToGmstString(int effectID)
{
if (effectID < 0 || static_cast<std::size_t>(effectID) >= sGmstEffectIds.size())

@ -10,6 +10,8 @@
#include "components/esm/refid.hpp"
#include "components/misc/strings/algorithm.hpp"
#include <osg/Vec4>
namespace ESM
{
@ -55,7 +57,7 @@ namespace ESM
// Originally modifiable flags
AllowSpellmaking = 0x200, // Can be used for spellmaking
AllowEnchanting = 0x400, // Can be used for enchanting
NegativeLight = 0x800 // Unused
NegativeLight = 0x800 // Inverts the effect's color
};
enum MagnitudeDisplayType
@ -113,6 +115,8 @@ namespace ESM
/// Set record to default state (does not touch the ID/index).
void blank();
osg::Vec4f getColor() const;
enum Effects
{
WaterBreathing = 0,

Loading…
Cancel
Save