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) 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() || (mGlowUpdater->isPermanentGlowUpdater() == true)))
{ {
if (mGlowUpdater && mGlowUpdater->isDone()) if (mGlowUpdater && mGlowUpdater->isDone())
@ -1502,11 +1497,12 @@ namespace MWRender
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater()) if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
{ {
mGlowUpdater->setColor(glowColor); mGlowUpdater->setColor(effect->getColor());
mGlowUpdater->setDuration(glowDuration); mGlowUpdater->setDuration(glowDuration);
} }
else 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 // Calculate combined light diffuse color from magical effects
osg::Vec4 lightDiffuseColor; osg::Vec4 lightDiffuseColor;
float lightDiffuseRed = 0.0f; for (const ESM::ENAMstruct& enam : effects.mList)
float lightDiffuseGreen = 0.0f;
float lightDiffuseBlue = 0.0f;
for (std::vector<ESM::ENAMstruct>::const_iterator iter(effects.mList.begin()); iter != effects.mList.end();
++iter)
{ {
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(iter->mEffectID); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(enam.mEffectID);
lightDiffuseRed += (static_cast<float>(magicEffect->mData.mRed) / 255.f); lightDiffuseColor += magicEffect->getColor();
lightDiffuseGreen += (static_cast<float>(magicEffect->mData.mGreen) / 255.f);
lightDiffuseBlue += (static_cast<float>(magicEffect->mData.mBlue) / 255.f);
} }
int numberOfEffects = effects.mList.size(); int numberOfEffects = effects.mList.size();
lightDiffuseColor = osg::Vec4(lightDiffuseRed / numberOfEffects, lightDiffuseGreen / numberOfEffects, lightDiffuseColor /= numberOfEffects;
lightDiffuseBlue / numberOfEffects, 1.0f);
return lightDiffuseColor; return lightDiffuseColor;
} }

@ -603,6 +603,14 @@ namespace ESM
mDescription.clear(); 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) const std::string& MagicEffect::indexToGmstString(int effectID)
{ {
if (effectID < 0 || static_cast<std::size_t>(effectID) >= sGmstEffectIds.size()) if (effectID < 0 || static_cast<std::size_t>(effectID) >= sGmstEffectIds.size())

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

Loading…
Cancel
Save