diff options
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 113 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 128 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 47 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.h | 12 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 654 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 71 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.cpp | 107 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.h | 103 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 105 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 79 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.h | 10 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 16 |
12 files changed, 1082 insertions, 363 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 4aab3dee3b..0ee71de3a1 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -69,25 +69,99 @@ const U32 LLSettingsBase::Validator::VALIDATION_PARTIAL(0x01 << 0); LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), mDirty(true), - mBlendedFactor(0.0) + mLLSDDirty(true), + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { } LLSettingsBase::LLSettingsBase(const LLSD setting) : mSettings(setting), + mLLSDDirty(true), mDirty(true), - mBlendedFactor(0.0) + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { } +//virtual +void LLSettingsBase::loadValuesFromLLSD() +{ + mLLSDDirty = false; + + mAssetId = mSettings[SETTING_ASSETID].asUUID(); + mSettingId = getValue(SETTING_ID).asUUID(); + mSettingName = getValue(SETTING_NAME).asString(); + if (mSettings.has(SETTING_FLAGS)) + { + mSettingFlags = (U32)mSettings[SETTING_FLAGS].asInteger(); + } + else + { + mSettingFlags = 0; + } +} + +//virtual +void LLSettingsBase::saveValuesToLLSD() +{ + mLLSDDirty = false; + + mSettings[SETTING_NAME] = mSettingName; + if (mAssetId.isNull()) + { + mSettings.erase(SETTING_ASSETID); + } + else + { + mSettings[SETTING_ASSETID] = mAssetId; + } + mSettings[SETTING_FLAGS] = LLSD::Integer(mSettingFlags); +} + +void LLSettingsBase::saveValuesIfNeeded() +{ + if (mLLSDDirty) + { + saveValuesToLLSD(); + } +} + //========================================================================= -void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix) +void LLSettingsBase::lerpSettings(LLSettingsBase &other, F64 mix) { - mSettings = interpolateSDMap(mSettings, other.mSettings, other.getParameterMap(), mix); + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + saveValuesIfNeeded(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mSettings = interpolateSDMap(mSettings, other.getSettings(), other.getParameterMap(), mix, skip, slerps); setDirtyFlag(true); + loadValuesFromLLSD(); +} + +void LLSettingsBase::lerpVector2(LLVector2& a, const LLVector2& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); } -LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) const +void LLSettingsBase::lerpVector3(LLVector3& a, const LLVector3& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); + a.mV[2] = lerp(a.mV[2], b.mV[2], mix); +} + +void LLSettingsBase::lerpColor(LLColor3& a, const LLColor3& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); + a.mV[2] = lerp(a.mV[2], b.mV[2], mix); +} + +LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) { LLSD newSettings; @@ -161,13 +235,10 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons return newSettings; } -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix) const +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix, const stringset_t& skip, const stringset_t& slerps) { LLSD newSettings; - stringset_t skip = getSkipInterpolateKeys(); - stringset_t slerps = getSlerpKeys(); - llassert(mix >= 0.0f && mix <= 1.0f); for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) @@ -204,7 +275,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c } } - newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, skip, slerps); } // Special handling cases @@ -233,12 +304,12 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c if (def_iter != defaults.end()) { // Blend against default value - newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, skip, slerps); } else if ((*it).second.type() == LLSD::TypeMap) { // interpolate in case there are defaults inside (part of legacy) - newSettings[key_name] = interpolateSDValue(key_name, LLSDMap(), (*it).second, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, LLSDMap(), (*it).second, defaults, mix, skip, slerps); } // else do nothing when no known defaults // TODO: Should I blend this out instead? @@ -260,7 +331,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c return newSettings; } -LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const +LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps) { LLSD new_value; @@ -286,7 +357,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD break; case LLSD::TypeMap: // deep copy. - new_value = interpolateSDMap(value, other_value, defaults, mix); + new_value = interpolateSDMap(value, other_value, defaults, mix, skip, slerps); break; case LLSD::TypeArray: @@ -348,13 +419,15 @@ LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const return skipSet; } -LLSD LLSettingsBase::getSettings() const +LLSD& LLSettingsBase::getSettings() { + saveValuesIfNeeded(); return mSettings; } -LLSD LLSettingsBase::cloneSettings() const +LLSD LLSettingsBase::cloneSettings() { + saveValuesIfNeeded(); LLSD settings(combineSDMaps(getSettings(), LLSD())); if (U32 flags = getFlags()) { @@ -363,7 +436,7 @@ LLSD LLSettingsBase::cloneSettings() const return settings; } -size_t LLSettingsBase::getHash() const +size_t LLSettingsBase::getHash() { // get a shallow copy of the LLSD filtering out values to not include in the hash LLSD hash_settings = llsd_shallow(getSettings(), LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true)); @@ -381,7 +454,9 @@ bool LLSettingsBase::validate() mSettings[SETTING_TYPE] = getSettingsType(); } + saveValuesIfNeeded(); LLSD result = LLSettingsBase::settingValidation(mSettings, validations); + loadValuesFromLLSD(); if (result["errors"].size() > 0) { @@ -704,7 +779,7 @@ F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_ if (mTarget) { - mTarget->replaceSettings(mInitial->getSettings()); + mTarget->replaceSettings(mInitial); mTarget->blend(mFinal, blendf); } else @@ -719,7 +794,7 @@ void LLSettingsBlender::triggerComplete() { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; if (mTarget) - mTarget->replaceSettings(mFinal->getSettings()); + mTarget->replaceSettings(mFinal); LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon mTarget->update(); mOnFinished(shared_from_this()); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 9d8d746b7e..816ff3e111 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -109,72 +109,59 @@ public: virtual bool isDirty() const { return mDirty; } virtual bool isVeryDirty() const { return mReplaced; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; clearAssetId(); } + inline void setReplaced() { mReplaced = true; } - size_t getHash() const; // Hash will not include Name, ID or a previously stored Hash + size_t getHash(); // Hash will not include Name, ID or a previously stored Hash inline LLUUID getId() const { - return getValue(SETTING_ID).asUUID(); + return mSettingId; } inline std::string getName() const { - return getValue(SETTING_NAME).asString(); + return mSettingName; } inline void setName(std::string val) { - setValue(SETTING_NAME, val); + mSettingName = val; + setDirtyFlag(true); + setLLSDDirty(); } inline LLUUID getAssetId() const { - if (mSettings.has(SETTING_ASSETID)) - return mSettings[SETTING_ASSETID].asUUID(); - return LLUUID(); + return mAssetId; } inline U32 getFlags() const { - if (mSettings.has(SETTING_FLAGS)) - return static_cast<U32>(mSettings[SETTING_FLAGS].asInteger()); - return 0; + return mSettingFlags; } inline void setFlags(U32 value) { - setLLSD(SETTING_FLAGS, LLSD::Integer(value)); + mSettingFlags = value; + setDirtyFlag(true); + setLLSDDirty(); } inline bool getFlag(U32 flag) const { - if (mSettings.has(SETTING_FLAGS)) - return ((U32)mSettings[SETTING_FLAGS].asInteger() & flag) == flag; - return false; + return (mSettingFlags & flag) == flag; } inline void setFlag(U32 flag) { - U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0); - - flags |= flag; - - if (flags) - mSettings[SETTING_FLAGS] = LLSD::Integer(flags); - else - mSettings.erase(SETTING_FLAGS); + mSettingFlags |= flag; + setLLSDDirty(); } inline void clearFlag(U32 flag) { - U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0); - - flags &= ~flag; - - if (flags) - mSettings[SETTING_FLAGS] = LLSD::Integer(flags); - else - mSettings.erase(SETTING_FLAGS); + mSettingFlags &= ~flag; + setLLSDDirty(); } virtual void replaceSettings(LLSD settings) @@ -183,14 +170,41 @@ public: setDirtyFlag(true); mReplaced = true; mSettings = settings; + loadValuesFromLLSD(); + } + + virtual void replaceSettings(const ptr_t& other) + { + mBlendedFactor = 0.0; + setDirtyFlag(true); + mReplaced = true; + mSettingFlags = other->getFlags(); + mSettingName = other->getName(); + mSettingId = other->getId(); + mAssetId = other->getAssetId(); + setLLSDDirty(); + } + + void setSettings(LLSD settings) + { + setDirtyFlag(true); + mSettings = settings; + loadValuesFromLLSD(); } - virtual LLSD getSettings() const; + // if you are using getSettings to edit them, call setSettings(settings), + // replaceSettings(settings) or loadValuesFromLLSD() afterwards + virtual LLSD& getSettings(); + virtual void setLLSDDirty() + { + mLLSDDirty = true; + } //--------------------------------------------------------------------- // inline void setLLSD(const std::string &name, const LLSD &value) { + saveValuesIfNeeded(); mSettings[name] = value; mDirty = true; if (name != SETTING_ASSETID) @@ -202,8 +216,9 @@ public: setLLSD(name, value); } - inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) { + saveValuesIfNeeded(); if (!mSettings.has(name)) return deflt; return mSettings[name]; @@ -259,11 +274,11 @@ public: (const_cast<LLSettingsBase *>(this))->updateSettings(); } - virtual void blend(const ptr_t &end, BlendFactor blendf) = 0; + virtual void blend(ptr_t &end, BlendFactor blendf) = 0; virtual bool validate(); - virtual ptr_t buildDerivedClone() const = 0; + virtual ptr_t buildDerivedClone() = 0; class Validator { @@ -310,17 +325,24 @@ public: inline void setAssetId(LLUUID value) { // note that this skips setLLSD - mSettings[SETTING_ASSETID] = value; + mAssetId = value; + mLLSDDirty = true; } inline void clearAssetId() { - if (mSettings.has(SETTING_ASSETID)) - mSettings.erase(SETTING_ASSETID); + mAssetId.setNull(); + mLLSDDirty = true; } // Calculate any custom settings that may need to be cached. virtual void updateSettings() { mDirty = false; mReplaced = false; } + LLSD cloneSettings(); + + static void lerpVector2(LLVector2& a, const LLVector2& b, F32 mix); + static void lerpVector3(LLVector3& a, const LLVector3& b, F32 mix); + static void lerpColor(LLColor3& a, const LLColor3& b, F32 mix); + protected: LLSettingsBase(); @@ -331,7 +353,7 @@ protected: typedef std::set<std::string> stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix); + virtual void lerpSettings(LLSettingsBase &other, BlendFactor mix); // combining settings maps where it can based on mix rate // @settings initial value (mix==0) @@ -339,8 +361,8 @@ protected: // @defaults list of default values for legacy fields and (re)setting shaders // @mix from 0 to 1, ratio or rate of transition from initial 'settings' to 'other' // return interpolated and combined LLSD map - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix) const; - LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const; + static LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps); + static LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps); /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -353,32 +375,40 @@ protected: virtual validation_list_t getValidationList() const = 0; - // Apply any settings that need special handling. - virtual void applySpecial(void *, bool force = false) { }; + // Apply settings. + virtual void applyToUniforms(void *) { }; + virtual void applySpecial(void*, bool force = false) { }; virtual parammapping_t getParameterMap() const { return parammapping_t(); } - LLSD mSettings; - - LLSD cloneSettings() const; - inline void setBlendFactor(BlendFactor blendfactor) { mBlendedFactor = blendfactor; } - void replaceWith(LLSettingsBase::ptr_t other) + virtual void replaceWith(const LLSettingsBase::ptr_t other) { - replaceSettings(other->cloneSettings()); + replaceSettings(other); setBlendFactor(other->getBlendFactor()); } + virtual void loadValuesFromLLSD(); + virtual void saveValuesToLLSD(); + void saveValuesIfNeeded(); + + LLUUID mAssetId; + LLUUID mSettingId; + std::string mSettingName; + U32 mSettingFlags; + private: + bool mLLSDDirty; bool mDirty; bool mReplaced; // super dirty! - LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; + static LLSD combineSDMaps(const LLSD &first, const LLSD &other); + LLSD mSettings; BlendFactor mBlendedFactor; }; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 1e7de94414..2b189e7cca 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -124,33 +124,42 @@ static const F32 DEFAULT_MULTISLIDER_INCREMENT(0.005f); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + loadValuesFromLLSD(); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + replaceSettings(defaults()); } //========================================================================= -LLSD LLSettingsDay::getSettings() const +LLSD& LLSettingsDay::getSettings() { - LLSD settings(LLSD::emptyMap()); + if (!mDaySettings.emptyMap()) + { + return mDaySettings; + } + mDaySettings = LLSD::emptyMap(); + LLSD& settings = LLSettingsBase::getSettings(); - if (mSettings.has(SETTING_NAME)) - settings[SETTING_NAME] = mSettings[SETTING_NAME]; + if (settings.has(SETTING_NAME)) + mDaySettings[SETTING_NAME] = settings[SETTING_NAME]; - if (mSettings.has(SETTING_ID)) - settings[SETTING_ID] = mSettings[SETTING_ID]; + if (settings.has(SETTING_ID)) + mDaySettings[SETTING_ID] = settings[SETTING_ID]; - if (mSettings.has(SETTING_ASSETID)) - settings[SETTING_ASSETID] = mSettings[SETTING_ASSETID]; + if (settings.has(SETTING_ASSETID)) + mDaySettings[SETTING_ASSETID] = settings[SETTING_ASSETID]; - settings[SETTING_TYPE] = getSettingsType(); + mDaySettings[SETTING_TYPE] = getSettingsType(); std::map<std::string, LLSettingsBase::ptr_t> in_use; @@ -174,7 +183,7 @@ LLSD LLSettingsDay::getSettings() const } tracks.append(trackout); } - settings[SETTING_TRACKS] = tracks; + mDaySettings[SETTING_TRACKS] = tracks; LLSD frames(LLSD::emptyMap()); for (std::map<std::string, LLSettingsBase::ptr_t>::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) @@ -184,9 +193,15 @@ LLSD LLSettingsDay::getSettings() const frames[(*itFrame).first] = framesettings; } - settings[SETTING_FRAMES] = frames; + mDaySettings[SETTING_FRAMES] = frames; - return settings; + return mDaySettings; +} + +void LLSettingsDay::setLLSDDirty() +{ + mDaySettings = LLSD::emptyMap(); + LLSettingsBase::setLLSDDirty(); } bool LLSettingsDay::initialize(bool validate_frames) @@ -392,6 +407,8 @@ bool LLSettingsDay::initialize(bool validate_frames) mSettings[SETTING_ASSETID] = assetid; } + loadValuesFromLLSD(); + mInitialized = true; return true; } @@ -449,7 +466,7 @@ LLSD LLSettingsDay::defaults() return dfltsetting; } -void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F64 mix) +void LLSettingsDay::blend(LLSettingsBase::ptr_t &other, F64 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; } diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 917b0870f2..d37423ea9a 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -81,9 +81,10 @@ public: bool initialize(bool validate_frames = false); - virtual ptr_t buildClone() const = 0; - virtual ptr_t buildDeepCloneAndUncompress() const = 0; - virtual LLSD getSettings() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() = 0; + virtual ptr_t buildDeepCloneAndUncompress() = 0; + virtual LLSD& getSettings() SETTINGS_OVERRIDE; + virtual void setLLSDDirty() override; virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_DAYCYCLE; } @@ -91,7 +92,7 @@ public: virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -127,7 +128,7 @@ public: virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } LLSettingsBase::TrackPosition getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); LLSettingsBase::TrackPosition getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); @@ -143,6 +144,7 @@ protected: private: CycleList_t mDayTracks; + LLSD mDaySettings; LLSettingsBase::Seconds mLastUpdateTime; diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index cbec2f4906..3685915ffd 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -407,10 +407,11 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) : mNextRainbowTextureId(), mNextHaloTextureId() { + loadValuesFromLLSD(); } LLSettingsSky::LLSettingsSky(): - LLSettingsBase(), + LLSettingsBase(LLSettingsSky::defaults()), mNextSunTextureId(), mNextMoonTextureId(), mNextCloudTextureId(), @@ -418,6 +419,7 @@ LLSettingsSky::LLSettingsSky(): mNextRainbowTextureId(), mNextHaloTextureId() { + replaceSettings(defaults()); } void LLSettingsSky::replaceSettings(LLSD settings) @@ -431,7 +433,80 @@ void LLSettingsSky::replaceSettings(LLSD settings) mNextHaloTextureId.setNull(); } -void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) +void LLSettingsSky::replaceSettings(const LLSettingsBase::ptr_t& other_sky) +{ + LLSettingsBase::replaceSettings(other_sky); + + llassert(getSettingsType() == other_sky->getSettingsType()); + + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(other_sky); + + mCanAutoAdjust = other->mCanAutoAdjust; + mReflectionProbeAmbiance = other->mReflectionProbeAmbiance; + + mSunScale = other->mSunScale; + mSunRotation = other->mSunRotation; + mSunlightColor = other->mSunlightColor; + mStarBrightness = other->mStarBrightness; + mMoonBrightness = other->mMoonBrightness; + mMoonScale = other->mMoonScale; + mMoonRotation = other->mMoonRotation; + mMaxY = other->mMaxY; + mGlow = other->mGlow; + mGamma = other->mGamma; + mCloudVariance = other->mCloudVariance; + mCloudShadow = other->mCloudShadow; + mScrollRate = other->mScrollRate; + mCloudScale = other->mCloudScale; + mCloudPosDensity1 = other->mCloudPosDensity1; + mCloudPosDensity2 = other->mCloudPosDensity2; + mCloudColor = other->mCloudColor; + + mAbsorptionConfigs = other->mAbsorptionConfigs; + mMieConfigs = other->mMieConfigs; + mRayleighConfigs = other->mRayleighConfigs; + + mSunArcRadians = other->mSunArcRadians; + mSkyTopRadius = other->mSkyTopRadius; + mSkyBottomRadius = other->mSkyBottomRadius; + mSkyMoistureLevel = other->mSkyMoistureLevel; + mSkyDropletRadius = other->mSkyDropletRadius; + mSkyIceLevel = other->mSkyIceLevel; + mPlanetRadius = other->mPlanetRadius; + + mHasLegacyHaze = other->mHasLegacyHaze; + mDistanceMultiplier = other->mDistanceMultiplier; + mDensityMultiplier = other->mDensityMultiplier; + mHazeHorizon = other->mHazeHorizon; + mHazeDensity = other->mHazeDensity; + mBlueHorizon = other->mBlueHorizon; + mBlueDensity = other->mBlueDensity; + mAmbientColor = other->mAmbientColor; + + mLegacyDistanceMultiplier = other->mLegacyDistanceMultiplier; + mLegacyDensityMultiplier = other->mLegacyDensityMultiplier; + mLegacyHazeHorizon = other->mLegacyHazeHorizon; + mLegacyHazeDensity = other->mLegacyHazeDensity; + mLegacyBlueHorizon = other->mLegacyBlueHorizon; + mLegacyBlueDensity = other->mLegacyBlueDensity; + mLegacyAmbientColor = other->mLegacyAmbientColor; + + mSunTextureId = other->mSunTextureId; + mMoonTextureId = other->mMoonTextureId; + mCloudTextureId = other->mCloudTextureId; + mHaloTextureId = other->mHaloTextureId; + mRainbowTextureId = other->mRainbowTextureId; + mBloomTextureId = other->mBloomTextureId; + + mNextSunTextureId.setNull(); + mNextMoonTextureId.setNull(); + mNextCloudTextureId.setNull(); + mNextBloomTextureId.setNull(); + mNextRainbowTextureId.setNull(); + mNextHaloTextureId.setNull(); +} + +void LLSettingsSky::replaceWithSky(const LLSettingsSky::ptr_t& pother) { replaceWith(pother); @@ -443,61 +518,158 @@ void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) mNextHaloTextureId = pother->mNextHaloTextureId; } -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +bool lerp_legacy_color(LLColor3& a, bool& a_has_legacy, const LLColor3& b, bool b_has_legacy, const LLColor3& def, F32 mix) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - llassert(getSettingsType() == end->getSettingsType()); + if (b_has_legacy) + { + if (a_has_legacy) + { + LLSettingsBase::lerpColor(a, b, mix); + } + else + { + a = def; + LLSettingsBase::lerpColor(a, b, mix); + a_has_legacy = true; + } + } + else if (a_has_legacy) + { + LLSettingsBase::lerpColor(a, def, mix); + } + else + { + LLSettingsBase::lerpColor(a, b, mix); + } + return a_has_legacy; +} - LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); - if (other) +bool lerp_legacy_float(F32& a, bool& a_has_legacy, F32 b, bool b_has_legacy, F32 def, F32 mix) +{ + if (b_has_legacy) { - if (other->mSettings.has(SETTING_LEGACY_HAZE)) + if (a_has_legacy) { - if (!mSettings.has(SETTING_LEGACY_HAZE) || !mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - // Special case since SETTING_AMBIENT is both in outer and legacy maps, we prioritize legacy one - // see getAmbientColor(), we are about to replaceSettings(), so we are free to set it - setAmbientColor(getAmbientColor()); - } + a = lerp(a, b, mix); } else { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - // Special case due to ambient's duality - // We need to match 'other's' structure for interpolation. - // We are free to change mSettings, since we are about to reset it - mSettings[SETTING_AMBIENT] = getAmbientColor().getValue(); - mSettings[SETTING_LEGACY_HAZE].erase(SETTING_AMBIENT); - } + a = lerp(def, b, mix); + a_has_legacy = true; } + } + else if (!a_has_legacy) + { + a = lerp(a, b, mix); + } + else + { + a = lerp(a, def, mix); + } + return a_has_legacy; +} +void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + llassert(getSettingsType() == end->getSettingsType()); + + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); + if (other) + { LLUUID cloud_noise_id = getCloudNoiseTextureId(); LLUUID cloud_noise_id_next = other->getCloudNoiseTextureId(); - F64 cloud_shadow = 0; if (!cloud_noise_id.isNull() && cloud_noise_id_next.isNull()) { // If there is no cloud texture in destination, reduce coverage to imitate disappearance // See LLDrawPoolWLSky::renderSkyClouds... we don't blend present texture with null // Note: Probably can be done by shader - cloud_shadow = lerp((F32)mSettings[SETTING_CLOUD_SHADOW].asReal(), 0.f, (F32)blendf); + mCloudShadow = lerp(mCloudShadow, 0.f, (F32)blendf); cloud_noise_id_next = cloud_noise_id; } else if (cloud_noise_id.isNull() && !cloud_noise_id_next.isNull()) { // Source has no cloud texture, reduce initial coverage to imitate appearance // use same texture as destination - cloud_shadow = lerp(0.f, (F32)other->mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); + mCloudShadow = lerp(0.f, mCloudShadow, (F32)blendf); setCloudNoiseTextureId(cloud_noise_id_next); } else { - cloud_shadow = lerp((F32)mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)other->mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); + mCloudShadow = lerp(mCloudShadow, (F32)other->mCloudShadow, (F32)blendf); + } + + mSettingFlags |= other->mSettingFlags; + + mCanAutoAdjust = false; // no point? + + mSunRotation = slerp((F32)blendf, mSunRotation, other->mSunRotation); + mMoonRotation = slerp((F32)blendf, mMoonRotation, other->mMoonRotation); + lerpColor(mSunlightColor, other->mSunlightColor, (F32)blendf); + lerpColor(mGlow, other->mGlow, (F32)blendf); + mReflectionProbeAmbiance = lerp(mReflectionProbeAmbiance, other->mReflectionProbeAmbiance, (F32)blendf); + mSunScale = lerp(mSunScale, other->mSunScale, (F32)blendf); + mStarBrightness = lerp(mStarBrightness, other->mStarBrightness, (F32)blendf); + mMoonBrightness = lerp(mMoonBrightness, other->mMoonBrightness, (F32)blendf); + mMoonScale = lerp(mMoonScale, other->mMoonScale, (F32)blendf); + mMaxY = lerp(mMaxY, other->mMaxY, (F32)blendf); + mGamma = lerp(mGamma, other->mGamma, (F32)blendf); + mCloudVariance = lerp(mCloudVariance, other->mCloudVariance, (F32)blendf); + mCloudShadow = lerp(mCloudShadow, other->mCloudShadow, (F32)blendf); + mCloudScale = lerp(mCloudScale, other->mCloudScale, (F32)blendf); + lerpVector2(mScrollRate, other->mScrollRate, (F32)blendf); + lerpColor(mCloudPosDensity1, other->mCloudPosDensity1, (F32)blendf); + lerpColor(mCloudPosDensity2, other->mCloudPosDensity2, (F32)blendf); + lerpColor(mCloudColor, other->mCloudColor, (F32)blendf); + + mSunArcRadians = lerp(mSunArcRadians, other->mSunArcRadians, (F32)blendf); + mSkyTopRadius = lerp(mSkyTopRadius, other->mSkyTopRadius, (F32)blendf); + mSkyBottomRadius = lerp(mSkyBottomRadius, other->mSkyBottomRadius, (F32)blendf); + mSkyMoistureLevel = lerp(mSkyMoistureLevel, other->mSkyMoistureLevel, (F32)blendf); + mSkyDropletRadius = lerp(mSkyDropletRadius, other->mSkyDropletRadius, (F32)blendf); + mSkyIceLevel = lerp(mSkyIceLevel, other->mSkyIceLevel, (F32)blendf); + mPlanetRadius = lerp(mPlanetRadius, other->mPlanetRadius, (F32)blendf); + + // Legacy settings + + if (other->mHasLegacyHaze) + { + if (!mHasLegacyHaze || !mLegacyAmbientColor) + { + // Special case since SETTING_AMBIENT is both in outer and legacy maps, + // we prioritize legacy one + setAmbientColor(other->getAmbientColor()); + mLegacyAmbientColor = true; + mHasLegacyHaze = true; + } + } + else + { + if (mLegacyAmbientColor) + { + // Special case due to ambient's duality + mLegacyAmbientColor = false; + } } - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); - blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(cloud_shadow); - replaceSettings(blenddata); + mHasLegacyHaze |= lerp_legacy_float(mHazeHorizon, mLegacyHazeHorizon, other->mHazeHorizon, other->mLegacyHazeHorizon, 0.19f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mHazeDensity, mLegacyHazeDensity, other->mHazeDensity, other->mLegacyHazeDensity, 0.7f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mDistanceMultiplier, mLegacyDistanceMultiplier, other->mDistanceMultiplier, other->mLegacyDistanceMultiplier, 0.8f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mDensityMultiplier, mLegacyDensityMultiplier, other->mDensityMultiplier, other->mLegacyDensityMultiplier, 0.0001f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_color(mBlueHorizon, mLegacyBlueHorizon, other->mBlueHorizon, other->mLegacyBlueHorizon, LLColor3(0.4954f, 0.4954f, 0.6399f), (F32)blendf); + mHasLegacyHaze |= lerp_legacy_color(mBlueDensity, mLegacyBlueDensity, other->mBlueDensity, other->mLegacyBlueDensity, LLColor3(0.2447f, 0.4487f, 0.7599f), (F32)blendf); + + parammapping_t defaults = other->getParameterMap(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mAbsorptionConfigs = interpolateSDMap(mAbsorptionConfigs, other->mAbsorptionConfigs, defaults, blendf, skip, slerps); + mMieConfigs = interpolateSDMap(mMieConfigs, other->mMieConfigs, defaults, blendf, skip, slerps); + mRayleighConfigs = interpolateSDMap(mRayleighConfigs, other->mRayleighConfigs, defaults, blendf, skip, slerps); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); mNextCloudTextureId = cloud_noise_id_next; @@ -955,6 +1127,184 @@ void LLSettingsSky::updateSettings() calculateLightSettings(); } + +F32 get_float(bool &use_legacy, LLSD& settings, std::string key, F32 default_value) +{ + if (settings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && settings[LLSettingsSky::SETTING_LEGACY_HAZE].has(key)) + { + use_legacy = true; + return (F32)settings[LLSettingsSky::SETTING_LEGACY_HAZE][key].asReal(); + } + if (settings.has(key)) + { + return (F32)settings[key].asReal(); + } + use_legacy = true; + return default_value; +} + +LLColor3 get_color(bool& use_legacy, LLSD& settings, const std::string& key, const LLColor3& default_value) +{ + if (settings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && settings[LLSettingsSky::SETTING_LEGACY_HAZE].has(key)) + { + use_legacy = true; + return LLColor3(settings[LLSettingsSky::SETTING_LEGACY_HAZE][key]); + } + use_legacy = false; + if (settings.has(key)) + { + return LLColor3(settings[key]); + } + use_legacy = true; + return default_value; +} + + +void LLSettingsSky::loadValuesFromLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::loadValuesFromLLSD(); + + LLSD& settings = getSettings(); + mCanAutoAdjust = !settings.has(SETTING_REFLECTION_PROBE_AMBIANCE); + if (mCanAutoAdjust) + { + mReflectionProbeAmbiance = 0; + } + else + { + mReflectionProbeAmbiance = (F32)settings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + } + + mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID(); + mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID(); + mCloudTextureId = settings[SETTING_CLOUD_TEXTUREID].asUUID(); + mHaloTextureId = settings[SETTING_HALO_TEXTUREID].asUUID(); + mRainbowTextureId = settings[SETTING_RAINBOW_TEXTUREID].asUUID(); + mBloomTextureId = settings[SETTING_BLOOM_TEXTUREID].asUUID(); + + mSunScale = (F32)settings[SETTING_SUN_SCALE].asReal(); + mSunRotation = LLQuaternion(settings[SETTING_SUN_ROTATION]); + mSunlightColor = LLColor3(settings[SETTING_SUNLIGHT_COLOR]); + mStarBrightness = (F32)settings[SETTING_STAR_BRIGHTNESS].asReal(); + mMoonBrightness = (F32)settings[SETTING_MOON_BRIGHTNESS].asReal(); + mMoonScale = (F32)settings[SETTING_MOON_SCALE].asReal(); + mMoonRotation = LLQuaternion(settings[SETTING_MOON_ROTATION]); + mMaxY = (F32)settings[SETTING_MAX_Y].asReal(); + mGlow = LLColor3(settings[SETTING_GLOW]); + mGamma = (F32)settings[SETTING_GAMMA].asReal(); + mCloudVariance = (F32)settings[SETTING_CLOUD_VARIANCE].asReal(); + mCloudShadow = (F32)settings[SETTING_CLOUD_SHADOW].asReal(); + mScrollRate = LLVector2(settings[SETTING_CLOUD_SCROLL_RATE]); + mCloudScale = (F32)settings[SETTING_CLOUD_SCALE].asReal(); + mCloudPosDensity1 = LLColor3(settings[SETTING_CLOUD_POS_DENSITY1]); + mCloudPosDensity2 = LLColor3(settings[SETTING_CLOUD_POS_DENSITY2]); + mCloudColor = LLColor3(settings[SETTING_CLOUD_COLOR]); + mAbsorptionConfigs = settings[SETTING_ABSORPTION_CONFIG]; + mMieConfigs = settings[SETTING_MIE_CONFIG]; + mRayleighConfigs = settings[SETTING_RAYLEIGH_CONFIG]; + mSunArcRadians = (F32)settings[SETTING_SUN_ARC_RADIANS].asReal(); + mSkyTopRadius = (F32)settings[SETTING_SKY_TOP_RADIUS].asReal(); + mSkyBottomRadius = (F32)settings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + mSkyMoistureLevel = (F32)settings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + mSkyDropletRadius = (F32)settings[SETTING_SKY_DROPLET_RADIUS].asReal(); + mSkyIceLevel = (F32)settings[SETTING_SKY_ICE_LEVEL].asReal(); + mPlanetRadius = (F32)settings[SETTING_PLANET_RADIUS].asReal(); + + // special case for legacy handling + mHasLegacyHaze = settings.has(LLSettingsSky::SETTING_LEGACY_HAZE); + mDistanceMultiplier = get_float(mLegacyDistanceMultiplier, settings, SETTING_DISTANCE_MULTIPLIER, 0.8f); + mDensityMultiplier = get_float(mLegacyDensityMultiplier, settings, SETTING_DENSITY_MULTIPLIER, 0.0001f); + mHazeHorizon = get_float(mLegacyHazeHorizon, settings, SETTING_HAZE_HORIZON, 0.19f); + mHazeDensity = get_float(mLegacyHazeDensity, settings, SETTING_HAZE_DENSITY, 0.7f); + mBlueHorizon = get_color(mLegacyBlueHorizon, settings, SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); + mBlueDensity = get_color(mLegacyBlueDensity, settings, SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); + mAmbientColor = get_color(mLegacyAmbientColor, settings, SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + // one of these values might be true despite not having SETTING_LEGACY_HAZE if defaults were used + mHasLegacyHaze |= mLegacyDistanceMultiplier + || mLegacyDensityMultiplier + || mLegacyHazeHorizon + || mLegacyHazeDensity + || mLegacyBlueHorizon + || mLegacyBlueDensity + || mLegacyAmbientColor; +} + +void set_legacy(LLSD &settings, LLSD &legacy, const std::string& key, bool has_value, const LLSD & value) +{ + if (has_value) + { + legacy[key] = value; + } + else + { + settings[key] = value; + legacy.erase(key); + } +} + +void LLSettingsSky::saveValuesToLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::saveValuesToLLSD(); + + LLSD& settings = getSettings(); + + if (mCanAutoAdjust) + { + settings.erase(SETTING_REFLECTION_PROBE_AMBIANCE); + } + else + { + settings[SETTING_REFLECTION_PROBE_AMBIANCE] = mReflectionProbeAmbiance; + } + settings[SETTING_SUN_TEXTUREID] = mSunTextureId; + settings[SETTING_MOON_TEXTUREID] = mMoonTextureId; + settings[SETTING_CLOUD_TEXTUREID] = mCloudTextureId; + settings[SETTING_HALO_TEXTUREID] = mHaloTextureId; + settings[SETTING_RAINBOW_TEXTUREID] = mRainbowTextureId; + settings[SETTING_BLOOM_TEXTUREID] = mBloomTextureId; + + settings[SETTING_SUN_SCALE] = mSunScale; + settings[SETTING_SUN_ROTATION] = mSunRotation.getValue(); + settings[SETTING_SUNLIGHT_COLOR] = mSunlightColor.getValue(); + settings[SETTING_STAR_BRIGHTNESS] = mStarBrightness; + settings[SETTING_MOON_BRIGHTNESS] = mMoonBrightness; + settings[SETTING_MOON_SCALE] = mMoonScale; + settings[SETTING_MOON_ROTATION] = mMoonRotation.getValue(); + settings[SETTING_MAX_Y] = mMaxY; + settings[SETTING_GLOW] = mGlow.getValue(); + settings[SETTING_GAMMA] = mGamma; + settings[SETTING_CLOUD_VARIANCE] = mCloudVariance; + settings[SETTING_CLOUD_SHADOW] = mCloudShadow; + settings[SETTING_CLOUD_SCROLL_RATE] = mScrollRate.getValue(); + settings[SETTING_CLOUD_SCALE] = mCloudScale; + settings[SETTING_CLOUD_POS_DENSITY1] = mCloudPosDensity1.getValue(); + settings[SETTING_CLOUD_POS_DENSITY2] = mCloudPosDensity2.getValue(); + settings[SETTING_CLOUD_COLOR] = mCloudColor.getValue(); + settings[SETTING_ABSORPTION_CONFIG] = mAbsorptionConfigs; + settings[SETTING_MIE_CONFIG] = mMieConfigs; + settings[SETTING_RAYLEIGH_CONFIG] = mRayleighConfigs; + settings[SETTING_SUN_ARC_RADIANS] = mSunArcRadians; + settings[SETTING_SKY_TOP_RADIUS] = mSkyTopRadius; + settings[SETTING_SKY_BOTTOM_RADIUS] = mSkyBottomRadius; + settings[SETTING_SKY_MOISTURE_LEVEL] = mSkyMoistureLevel; + settings[SETTING_SKY_DROPLET_RADIUS] = mSkyDropletRadius; + settings[SETTING_SKY_ICE_LEVEL] = mSkyIceLevel; + settings[SETTING_PLANET_RADIUS] = mPlanetRadius; + + LLSD& legacy = settings[SETTING_LEGACY_HAZE]; + set_legacy(settings, legacy, SETTING_DISTANCE_MULTIPLIER, mLegacyDistanceMultiplier, LLSD::Real(mDistanceMultiplier)); + set_legacy(settings, legacy, SETTING_DENSITY_MULTIPLIER, mLegacyDensityMultiplier, LLSD::Real(mDensityMultiplier)); + set_legacy(settings, legacy, SETTING_HAZE_HORIZON, mLegacyHazeHorizon, LLSD::Real(mHazeHorizon)); + set_legacy(settings, legacy, SETTING_HAZE_DENSITY, mLegacyHazeDensity, LLSD::Real(mHazeDensity)); + set_legacy(settings, legacy, SETTING_BLUE_HORIZON, mLegacyBlueHorizon, mBlueHorizon.getValue()); + set_legacy(settings, legacy, SETTING_BLUE_DENSITY, mLegacyBlueDensity, mBlueDensity.getValue()); + set_legacy(settings, legacy, SETTING_AMBIENT, mLegacyAmbientColor, mAmbientColor.getValue()); +} + F32 LLSettingsSky::getSunMoonGlowFactor() const { return getIsSunUp() ? 1.0f : @@ -1024,37 +1374,40 @@ LLColor3 LLSettingsSky::getLightDiffuse() const return LLColor3::white; } -LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) const +LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + LLSD& settings = getSettings(); + if (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(key)) { - return LLColor3(mSettings[SETTING_LEGACY_HAZE][key]); + return LLColor3(settings[SETTING_LEGACY_HAZE][key]); } - if (mSettings.has(key)) + if (settings.has(key)) { - return LLColor3(mSettings[key]); + return LLColor3(settings[key]); } return default_value; } -F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) const +F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + + LLSD& settings = getSettings(); + if (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(key)) { - return (F32)mSettings[SETTING_LEGACY_HAZE][key].asReal(); + return (F32)settings[SETTING_LEGACY_HAZE][key].asReal(); } - if (mSettings.has(key)) + if (settings.has(key)) { - return (F32)mSettings[key].asReal(); + return (F32)settings[key].asReal(); } return default_value; } LLColor3 LLSettingsSky::getAmbientColor() const { - return getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + return mAmbientColor; } LLColor3 LLSettingsSky::getAmbientColorClamped() const @@ -1072,119 +1425,143 @@ LLColor3 LLSettingsSky::getAmbientColorClamped() const LLColor3 LLSettingsSky::getBlueDensity() const { - return getColor(SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); + return mBlueDensity; } LLColor3 LLSettingsSky::getBlueHorizon() const { - return getColor(SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); + return mBlueHorizon; } F32 LLSettingsSky::getHazeDensity() const { - return getFloat(SETTING_HAZE_DENSITY, 0.7f); + return mHazeDensity; } F32 LLSettingsSky::getHazeHorizon() const { - return getFloat(SETTING_HAZE_HORIZON, 0.19f); + return mHazeHorizon; } F32 LLSettingsSky::getDensityMultiplier() const { - return getFloat(SETTING_DENSITY_MULTIPLIER, 0.0001f); + return mDensityMultiplier; } F32 LLSettingsSky::getDistanceMultiplier() const { - return getFloat(SETTING_DISTANCE_MULTIPLIER, 0.8f); + return mDistanceMultiplier; } void LLSettingsSky::setPlanetRadius(F32 radius) { - mSettings[SETTING_PLANET_RADIUS] = radius; + mPlanetRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyBottomRadius(F32 radius) { - mSettings[SETTING_SKY_BOTTOM_RADIUS] = radius; + mSkyBottomRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyTopRadius(F32 radius) { - mSettings[SETTING_SKY_TOP_RADIUS] = radius; + mSkyTopRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSunArcRadians(F32 radians) { - mSettings[SETTING_SUN_ARC_RADIANS] = radians; + mSunArcRadians = radians; + setDirtyFlag(true); } void LLSettingsSky::setMieAnisotropy(F32 aniso_factor) { getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR] = aniso_factor; + setDirtyFlag(true); } void LLSettingsSky::setSkyMoistureLevel(F32 moisture_level) { - setValue(SETTING_SKY_MOISTURE_LEVEL, moisture_level); + mSkyMoistureLevel = moisture_level; + setDirtyFlag(true); } void LLSettingsSky::setSkyDropletRadius(F32 radius) { - setValue(SETTING_SKY_DROPLET_RADIUS,radius); + mSkyDropletRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyIceLevel(F32 ice_level) { - setValue(SETTING_SKY_ICE_LEVEL, ice_level); + mSkyIceLevel = ice_level; + setDirtyFlag(true); } void LLSettingsSky::setReflectionProbeAmbiance(F32 ambiance) { - setValue(SETTING_REFLECTION_PROBE_AMBIANCE, ambiance); + mReflectionProbeAmbiance = ambiance; + mCanAutoAdjust = false; + setLLSDDirty(); } void LLSettingsSky::setAmbientColor(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = val.getValue(); + mAmbientColor = val; + mLegacyAmbientColor = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueDensity(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY] = val.getValue(); + mBlueDensity = val; + mLegacyBlueDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueHorizon(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON] = val.getValue(); + mBlueHorizon = val; + mLegacyBlueHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDensityMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER] = val; + mDensityMultiplier = val; + mLegacyDensityMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDistanceMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER] = val; + mDistanceMultiplier = val; + mLegacyDistanceMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeDensity(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY] = val; + mHazeDensity = val; + mLegacyHazeDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeHorizon(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON] = val; + mHazeHorizon = val; + mLegacyHazeHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } // Get total from rayleigh and mie density values for normalization @@ -1299,7 +1676,7 @@ LLColor3 LLSettingsSky::getMoonlightColor() const return getSunlightColor(); //moon and sun share light color } -void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const +void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) { F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]); if (max_color > scale) @@ -1415,22 +1792,22 @@ LLUUID LLSettingsSky::GetDefaultHaloTextureId() F32 LLSettingsSky::getPlanetRadius() const { - return (F32)mSettings[SETTING_PLANET_RADIUS].asReal(); + return mPlanetRadius; } F32 LLSettingsSky::getSkyMoistureLevel() const { - return (F32)mSettings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + return mSkyMoistureLevel; } F32 LLSettingsSky::getSkyDropletRadius() const { - return (F32)mSettings[SETTING_SKY_DROPLET_RADIUS].asReal(); + return mSkyDropletRadius; } F32 LLSettingsSky::getSkyIceLevel() const { - return (F32)mSettings[SETTING_SKY_ICE_LEVEL].asReal(); + return mSkyIceLevel; } F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const @@ -1440,22 +1817,22 @@ F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const return sAutoAdjustProbeAmbiance; } - return (F32)mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + return mReflectionProbeAmbiance; } F32 LLSettingsSky::getSkyBottomRadius() const { - return (F32)mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + return mSkyBottomRadius; } F32 LLSettingsSky::getSkyTopRadius() const { - return (F32)mSettings[SETTING_SKY_TOP_RADIUS].asReal(); + return mSkyTopRadius; } F32 LLSettingsSky::getSunArcRadians() const { - return (F32)mSettings[SETTING_SUN_ARC_RADIANS].asReal(); + return mSunArcRadians; } F32 LLSettingsSky::getMieAnisotropy() const @@ -1465,158 +1842,171 @@ F32 LLSettingsSky::getMieAnisotropy() const LLSD LLSettingsSky::getRayleighConfig() const { - LLSD copy = *(mSettings[SETTING_RAYLEIGH_CONFIG].beginArray()); + LLSD copy = *(mRayleighConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getMieConfig() const { - LLSD copy = *(mSettings[SETTING_MIE_CONFIG].beginArray()); + LLSD copy = *(mMieConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getAbsorptionConfig() const { - LLSD copy = *(mSettings[SETTING_ABSORPTION_CONFIG].beginArray()); + LLSD copy = *(mAbsorptionConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getRayleighConfigs() const { - return mSettings[SETTING_RAYLEIGH_CONFIG]; + return mRayleighConfigs; } LLSD LLSettingsSky::getMieConfigs() const { - return mSettings[SETTING_MIE_CONFIG]; + return mMieConfigs; } LLSD LLSettingsSky::getAbsorptionConfigs() const { - return mSettings[SETTING_ABSORPTION_CONFIG]; + return mAbsorptionConfigs; } void LLSettingsSky::setRayleighConfigs(const LLSD& rayleighConfig) { - mSettings[SETTING_RAYLEIGH_CONFIG] = rayleighConfig; + mRayleighConfigs = rayleighConfig; + setLLSDDirty(); } void LLSettingsSky::setMieConfigs(const LLSD& mieConfig) { - mSettings[SETTING_MIE_CONFIG] = mieConfig; + mMieConfigs = mieConfig; + setLLSDDirty(); } void LLSettingsSky::setAbsorptionConfigs(const LLSD& absorptionConfig) { - mSettings[SETTING_ABSORPTION_CONFIG] = absorptionConfig; + mAbsorptionConfigs = absorptionConfig; + setLLSDDirty(); } LLUUID LLSettingsSky::getBloomTextureId() const { - return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); + return mBloomTextureId; } LLUUID LLSettingsSky::getRainbowTextureId() const { - return mSettings[SETTING_RAINBOW_TEXTUREID].asUUID(); + return mRainbowTextureId; } LLUUID LLSettingsSky::getHaloTextureId() const { - return mSettings[SETTING_HALO_TEXTUREID].asUUID(); + return mHaloTextureId; } //--------------------------------------------------------------------- LLColor3 LLSettingsSky::getCloudColor() const { - return LLColor3(mSettings[SETTING_CLOUD_COLOR]); + return mCloudColor; } void LLSettingsSky::setCloudColor(const LLColor3 &val) { - setValue(SETTING_CLOUD_COLOR, val); + mCloudColor = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getCloudNoiseTextureId() const { - return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); + return mCloudTextureId; } void LLSettingsSky::setCloudNoiseTextureId(const LLUUID &id) { - setValue(SETTING_CLOUD_TEXTUREID, id); + mCloudTextureId = id; + setLLSDDirty(); } LLColor3 LLSettingsSky::getCloudPosDensity1() const { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); + return mCloudPosDensity1; } void LLSettingsSky::setCloudPosDensity1(const LLColor3 &val) { - setValue(SETTING_CLOUD_POS_DENSITY1, val); + mCloudPosDensity1 = val; + setLLSDDirty(); } LLColor3 LLSettingsSky::getCloudPosDensity2() const { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); + return mCloudPosDensity2; } void LLSettingsSky::setCloudPosDensity2(const LLColor3 &val) { - setValue(SETTING_CLOUD_POS_DENSITY2, val); + mCloudPosDensity2 = val; + setLLSDDirty(); } F32 LLSettingsSky::getCloudScale() const { - return (F32)mSettings[SETTING_CLOUD_SCALE].asReal(); + return mCloudScale; } void LLSettingsSky::setCloudScale(F32 val) { - setValue(SETTING_CLOUD_SCALE, val); + mCloudScale = val; + setLLSDDirty(); } LLVector2 LLSettingsSky::getCloudScrollRate() const { - return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); + return mScrollRate; } void LLSettingsSky::setCloudScrollRate(const LLVector2 &val) { - setValue(SETTING_CLOUD_SCROLL_RATE, val); + mScrollRate = val; + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateX(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; + mScrollRate.mV[0] = val; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateY(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; + mScrollRate.mV[1] = val; setDirtyFlag(true); + setLLSDDirty(); } F32 LLSettingsSky::getCloudShadow() const { - return (F32)mSettings[SETTING_CLOUD_SHADOW].asReal(); + return mCloudShadow; } void LLSettingsSky::setCloudShadow(F32 val) { - setValue(SETTING_CLOUD_SHADOW, val); + mCloudShadow = val; + setLLSDDirty(); } F32 LLSettingsSky::getCloudVariance() const { - return (F32)mSettings[SETTING_CLOUD_VARIANCE].asReal(); + return mCloudVariance; } void LLSettingsSky::setCloudVariance(F32 val) { - setValue(SETTING_CLOUD_VARIANCE, val); + mCloudVariance = val; + setLLSDDirty(); } F32 LLSettingsSky::getDomeOffset() const @@ -1633,88 +2023,95 @@ F32 LLSettingsSky::getDomeRadius() const F32 LLSettingsSky::getGamma() const { - return (F32)mSettings[SETTING_GAMMA].asReal(); + return mGamma; } void LLSettingsSky::setGamma(F32 val) { - mSettings[SETTING_GAMMA] = LLSD::Real(val); + mGamma = val; setDirtyFlag(true); + setLLSDDirty(); } - LLColor3 LLSettingsSky::getGlow() const { - return LLColor3(mSettings[SETTING_GLOW]); + return mGlow; } void LLSettingsSky::setGlow(const LLColor3 &val) { - setValue(SETTING_GLOW, val); + mGlow = val; + setLLSDDirty(); } F32 LLSettingsSky::getMaxY() const { - return (F32)mSettings[SETTING_MAX_Y].asReal(); + return mMaxY; } void LLSettingsSky::setMaxY(F32 val) { - setValue(SETTING_MAX_Y, val); + mMaxY = val; + setLLSDDirty(); } LLQuaternion LLSettingsSky::getMoonRotation() const { - return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); + return mMoonRotation; } void LLSettingsSky::setMoonRotation(const LLQuaternion &val) { - setValue(SETTING_MOON_ROTATION, val); + mMoonRotation = val; + setLLSDDirty(); } F32 LLSettingsSky::getMoonScale() const { - return (F32)mSettings[SETTING_MOON_SCALE].asReal(); + return mMoonScale; } void LLSettingsSky::setMoonScale(F32 val) { - setValue(SETTING_MOON_SCALE, val); + mMoonScale = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getMoonTextureId() const { - return mSettings[SETTING_MOON_TEXTUREID].asUUID(); + return mMoonTextureId; } void LLSettingsSky::setMoonTextureId(LLUUID id) { - setValue(SETTING_MOON_TEXTUREID, id); + mMoonTextureId = id; + setLLSDDirty(); } F32 LLSettingsSky::getMoonBrightness() const { - return (F32)mSettings[SETTING_MOON_BRIGHTNESS].asReal(); + return mMoonBrightness; } void LLSettingsSky::setMoonBrightness(F32 brightness_factor) { - setValue(SETTING_MOON_BRIGHTNESS, brightness_factor); + mMoonBrightness = brightness_factor; + setLLSDDirty(); } F32 LLSettingsSky::getStarBrightness() const { - return (F32)mSettings[SETTING_STAR_BRIGHTNESS].asReal(); + return mStarBrightness; } void LLSettingsSky::setStarBrightness(F32 val) { - setValue(SETTING_STAR_BRIGHTNESS, val); + mStarBrightness = val; + setLLSDDirty(); } LLColor3 LLSettingsSky::getSunlightColor() const { - return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); + return mSunlightColor; } LLColor3 LLSettingsSky::getSunlightColorClamped() const @@ -1733,38 +2130,41 @@ LLColor3 LLSettingsSky::getSunlightColorClamped() const void LLSettingsSky::setSunlightColor(const LLColor3 &val) { - setValue(SETTING_SUNLIGHT_COLOR, val); + mSunlightColor = val; + setLLSDDirty(); } LLQuaternion LLSettingsSky::getSunRotation() const { - return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); + return mSunRotation; } void LLSettingsSky::setSunRotation(const LLQuaternion &val) { - setValue(SETTING_SUN_ROTATION, val); + mSunRotation = val; + setLLSDDirty(); } - F32 LLSettingsSky::getSunScale() const { - return (F32)mSettings[SETTING_SUN_SCALE].asReal(); + return mSunScale; } void LLSettingsSky::setSunScale(F32 val) { - setValue(SETTING_SUN_SCALE, val); + mSunScale = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getSunTextureId() const { - return mSettings[SETTING_SUN_TEXTUREID].asUUID(); + return mSunTextureId; } void LLSettingsSky::setSunTextureId(LLUUID id) { - setValue(SETTING_SUN_TEXTUREID, id); + mSunTextureId = id; + setLLSDDirty(); } LLUUID LLSettingsSky::getNextSunTextureId() const @@ -1790,5 +2190,5 @@ LLUUID LLSettingsSky::getNextBloomTextureId() const // if true, this sky is a candidate for auto-adjustment bool LLSettingsSky::canAutoAdjust() const { - return !mSettings.has(SETTING_REFLECTION_PROBE_AMBIANCE); + return mCanAutoAdjust; } diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 40bb337a48..38c0368423 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -111,20 +111,24 @@ public: LLSettingsSky(const LLSD &data); virtual ~LLSettingsSky() { }; - virtual ptr_t buildClone() const = 0; + virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("sky"); } virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_SKY; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; + virtual void replaceSettings(const LLSettingsBase::ptr_t& other_sky) override; - void replaceWithSky(LLSettingsSky::ptr_t pother); + void replaceWithSky(const LLSettingsSky::ptr_t& pother); static LLSD defaults(const LLSettingsBase::TrackPosition& position = 0.0f); + void loadValuesFromLLSD() override; + void saveValuesToLLSD() override; + F32 getPlanetRadius() const; F32 getSkyBottomRadius() const; F32 getSkyTopRadius() const; @@ -306,7 +310,7 @@ public: LLColor3 getSunlightColorClamped() const; LLColor3 getAmbientColorClamped() const; - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultSunTextureId(); @@ -348,6 +352,12 @@ protected: virtual stringset_t getSlerpKeys() const SETTINGS_OVERRIDE; virtual stringset_t getSkipInterpolateKeys() const SETTINGS_OVERRIDE; + LLUUID mSunTextureId; + LLUUID mMoonTextureId; + LLUUID mCloudTextureId; + LLUUID mBloomTextureId; + LLUUID mRainbowTextureId; + LLUUID mHaloTextureId; LLUUID mNextSunTextureId; LLUUID mNextMoonTextureId; LLUUID mNextCloudTextureId; @@ -355,17 +365,64 @@ protected: LLUUID mNextRainbowTextureId; LLUUID mNextHaloTextureId; + bool mCanAutoAdjust; + LLQuaternion mSunRotation; + LLQuaternion mMoonRotation; + LLColor3 mSunlightColor; + LLColor3 mGlow; + F32 mReflectionProbeAmbiance; + F32 mSunScale; + F32 mStarBrightness; + F32 mMoonBrightness; + F32 mMoonScale; + F32 mMaxY; + F32 mGamma; + F32 mCloudVariance; + F32 mCloudShadow; + F32 mCloudScale; + LLVector2 mScrollRate; + LLColor3 mCloudPosDensity1; + LLColor3 mCloudPosDensity2; + LLColor3 mCloudColor; + LLSD mAbsorptionConfigs; + LLSD mMieConfigs; + LLSD mRayleighConfigs; + F32 mSunArcRadians; + F32 mSkyTopRadius; + F32 mSkyBottomRadius; + F32 mSkyMoistureLevel; + F32 mSkyDropletRadius; + F32 mSkyIceLevel; + F32 mPlanetRadius; + + F32 mHazeHorizon; + F32 mHazeDensity; + F32 mDistanceMultiplier; + F32 mDensityMultiplier; + LLColor3 mBlueHorizon; + LLColor3 mBlueDensity; + LLColor3 mAmbientColor; + + bool mHasLegacyHaze; + bool mLegacyHazeHorizon; + bool mLegacyHazeDensity; + bool mLegacyDistanceMultiplier; + bool mLegacyDensityMultiplier; + bool mLegacyBlueHorizon; + bool mLegacyBlueDensity; + bool mLegacyAmbientColor; + private: static LLSD rayleighConfigDefault(); static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); - LLColor3 getColor(const std::string& key, const LLColor3& default_value) const; - F32 getFloat(const std::string& key, F32 default_value) const; + LLColor3 getColor(const std::string& key, const LLColor3& default_value); + F32 getFloat(const std::string& key, F32 default_value); void calculateHeavenlyBodyPositions() const; void calculateLightSettings() const; - void clampColor(LLColor3& color, F32 gamma, const F32 scale = 1.0f) const; + static void clampColor(LLColor3& color, F32 gamma, const F32 scale = 1.0f); mutable LLVector3 mSunDirection; mutable LLVector3 mMoonDirection; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 161b8cda25..08e18ea26e 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -68,14 +68,18 @@ static const LLUUID DEFAULT_OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf8631 //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : LLSettingsBase(data), - mNextNormalMapID() + mNextNormalMapID(), + mNextTransparentTextureID() { + loadValuesFromLLSD(); } LLSettingsWater::LLSettingsWater() : LLSettingsBase(), - mNextNormalMapID() + mNextNormalMapID(), + mNextTransparentTextureID() { + replaceSettings(defaults()); } //========================================================================= @@ -109,6 +113,53 @@ LLSD LLSettingsWater::defaults(const LLSettingsBase::TrackPosition& position) return dfltsetting; } +void LLSettingsWater::loadValuesFromLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::loadValuesFromLLSD(); + + LLSD& settings = getSettings(); + + mBlurMultiplier = (F32)settings[SETTING_BLUR_MULTIPLIER].asReal(); + mWaterFogColor = LLColor3(settings[SETTING_FOG_COLOR]); + mWaterFogDensity = (F32)settings[SETTING_FOG_DENSITY].asReal(); + mFogMod = (F32)settings[SETTING_FOG_MOD].asReal(); + mFresnelOffset = (F32)settings[SETTING_FRESNEL_OFFSET].asReal(); + mFresnelScale = (F32)settings[SETTING_FRESNEL_SCALE].asReal(); + mNormalScale = LLVector3(settings[SETTING_NORMAL_SCALE]); + mScaleAbove = (F32)settings[SETTING_SCALE_ABOVE].asReal(); + mScaleBelow = (F32)settings[SETTING_SCALE_BELOW].asReal(); + mWave1Dir = LLVector2(settings[SETTING_WAVE1_DIR]); + mWave2Dir = LLVector2(settings[SETTING_WAVE2_DIR]); + + mNormalMapID = getNormalMapID(); + mTransparentTextureID = getTransparentTextureID(); +} + +void LLSettingsWater::saveValuesToLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::saveValuesToLLSD(); + + LLSD & settings = getSettings(); + settings[SETTING_BLUR_MULTIPLIER] = LLSD::Real(mBlurMultiplier); + settings[SETTING_FOG_COLOR] = mWaterFogColor.getValue(); + settings[SETTING_FOG_DENSITY] = LLSD::Real(mWaterFogDensity); + settings[SETTING_FOG_MOD] = LLSD::Real(mFogMod); + settings[SETTING_FRESNEL_OFFSET] = LLSD::Real(mFresnelOffset); + settings[SETTING_FRESNEL_SCALE] = LLSD::Real(mFresnelScale); + settings[SETTING_NORMAL_SCALE] = mNormalScale.getValue(); + settings[SETTING_SCALE_ABOVE] = LLSD::Real(mScaleAbove); + settings[SETTING_SCALE_BELOW] = LLSD::Real(mScaleBelow); + settings[SETTING_WAVE1_DIR] = mWave1Dir.getValue(); + settings[SETTING_WAVE2_DIR] = mWave2Dir.getValue(); + + settings[SETTING_NORMAL_MAP] = mNormalMapID; + settings[SETTING_TRANSPARENT_TEXTURE] = mTransparentTextureID; +} + LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) { bool converted_something(false); @@ -180,13 +231,30 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) return newsettings; } -void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +void LLSettingsWater::blend(LLSettingsBase::ptr_t &end, F64 blendf) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast<LLSettingsWater>(end); if (other) { - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); - replaceSettings(blenddata); + mSettingFlags |= other->mSettingFlags; + + mBlurMultiplier = lerp((F32)blendf, mBlurMultiplier, other->mBlurMultiplier); + lerpColor(mWaterFogColor, other->mWaterFogColor, (F32)blendf); + mWaterFogDensity = lerp((F32)blendf, mWaterFogDensity, other->mWaterFogDensity); + mFogMod = lerp((F32)blendf, mFogMod, other->mFogMod); + mFresnelOffset = lerp((F32)blendf, mFresnelOffset, other->mFresnelOffset); + mFresnelScale = lerp((F32)blendf, mFresnelScale, other->mFresnelScale); + lerpVector3(mNormalScale, other->mNormalScale, (F32)blendf); + mScaleAbove = lerp((F32)blendf, mScaleAbove, other->mScaleAbove); + mScaleBelow = lerp((F32)blendf, mScaleBelow, other->mScaleBelow); + lerpVector2(mWave1Dir, other->mWave1Dir, (F32)blendf); + lerpVector2(mWave2Dir, other->mWave2Dir, (F32)blendf); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + mNextNormalMapID = other->getNormalMapID(); mNextTransparentTextureID = other->getTransparentTextureID(); } @@ -204,7 +272,34 @@ void LLSettingsWater::replaceSettings(LLSD settings) mNextTransparentTextureID.setNull(); } -void LLSettingsWater::replaceWithWater(LLSettingsWater::ptr_t other) +void LLSettingsWater::replaceSettings(const LLSettingsBase::ptr_t& other_water) +{ + LLSettingsBase::replaceSettings(other_water); + + llassert(getSettingsType() == other_water->getSettingsType()); + + LLSettingsWater::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsWater>(other_water); + + mBlurMultiplier = other->mBlurMultiplier; + mWaterFogColor = other->mWaterFogColor; + mWaterFogDensity = other->mWaterFogDensity; + mFogMod = other->mFogMod; + mFresnelOffset = other->mFresnelOffset; + mFresnelScale = other->mFresnelScale; + mNormalScale = other->mNormalScale; + mScaleAbove = other->mScaleAbove; + mScaleBelow = other->mScaleBelow; + mWave1Dir = other->mWave1Dir; + mWave2Dir = other->mWave2Dir; + + mNormalMapID = other->mNormalMapID; + mTransparentTextureID = other->mTransparentTextureID; + + mNextNormalMapID.setNull(); + mNextTransparentTextureID.setNull(); +} + +void LLSettingsWater::replaceWithWater(const LLSettingsWater::ptr_t& other) { replaceWith(other); diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 9e7ff61272..82fc37cfb3 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -55,151 +55,181 @@ public: LLSettingsWater(const LLSD &data); virtual ~LLSettingsWater() { }; - virtual ptr_t buildClone() const = 0; + virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("water"); } virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_WATER; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; - void replaceWithWater(LLSettingsWater::ptr_t other); + virtual void replaceSettings(const LLSettingsBase::ptr_t& other_water) override; + void replaceWithWater(const LLSettingsWater::ptr_t& other); static LLSD defaults(const LLSettingsBase::TrackPosition& position = 0.0f); + void loadValuesFromLLSD() override; + void saveValuesToLLSD() override; + //--------------------------------------------------------------------- F32 getBlurMultiplier() const { - return (F32)mSettings[SETTING_BLUR_MULTIPLIER].asReal(); + return mBlurMultiplier; } void setBlurMultiplier(F32 val) { - setValue(SETTING_BLUR_MULTIPLIER, val); + mBlurMultiplier = val; + setDirtyFlag(true); + setLLSDDirty(); } LLColor3 getWaterFogColor() const { - return LLColor3(mSettings[SETTING_FOG_COLOR]); + return mWaterFogColor; } void setWaterFogColor(LLColor3 val) { - setValue(SETTING_FOG_COLOR, val); + mWaterFogColor = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getWaterFogDensity() const { - return (F32)mSettings[SETTING_FOG_DENSITY].asReal(); + return mWaterFogDensity; } F32 getModifiedWaterFogDensity(bool underwater) const; void setWaterFogDensity(F32 val) { - setValue(SETTING_FOG_DENSITY, val); + mWaterFogDensity = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFogMod() const { - return (F32)mSettings[SETTING_FOG_MOD].asReal(); + return mFogMod; } void setFogMod(F32 val) { - setValue(SETTING_FOG_MOD, val); + mFogMod = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFresnelOffset() const { - return (F32)mSettings[SETTING_FRESNEL_OFFSET].asReal(); + return mFresnelOffset; } void setFresnelOffset(F32 val) { - setValue(SETTING_FRESNEL_OFFSET, val); + mFresnelOffset = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFresnelScale() const { - return (F32)mSettings[SETTING_FRESNEL_SCALE].asReal(); + return mFresnelScale; } void setFresnelScale(F32 val) { - setValue(SETTING_FRESNEL_SCALE, val); + mFresnelScale = val; + setDirtyFlag(true); + setLLSDDirty(); } LLUUID getTransparentTextureID() const { - return mSettings[SETTING_TRANSPARENT_TEXTURE].asUUID(); + return mTransparentTextureID; } void setTransparentTextureID(LLUUID val) { - setValue(SETTING_TRANSPARENT_TEXTURE, val); + mTransparentTextureID = val; + setDirtyFlag(true); + setLLSDDirty(); } LLUUID getNormalMapID() const { - return mSettings[SETTING_NORMAL_MAP].asUUID(); + return mNormalMapID; } void setNormalMapID(LLUUID val) { - setValue(SETTING_NORMAL_MAP, val); + mNormalMapID = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector3 getNormalScale() const { - return LLVector3(mSettings[SETTING_NORMAL_SCALE]); + return mNormalScale; } void setNormalScale(LLVector3 val) { - setValue(SETTING_NORMAL_SCALE, val); + mNormalScale = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getScaleAbove() const { - return (F32)mSettings[SETTING_SCALE_ABOVE].asReal(); + return mScaleAbove; } void setScaleAbove(F32 val) { - setValue(SETTING_SCALE_ABOVE, val); + mScaleAbove = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getScaleBelow() const { - return (F32)mSettings[SETTING_SCALE_BELOW].asReal(); + return mScaleBelow; } void setScaleBelow(F32 val) { - setValue(SETTING_SCALE_BELOW, val); + mScaleBelow = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector2 getWave1Dir() const { - return LLVector2(mSettings[SETTING_WAVE1_DIR]); + return mWave1Dir; } void setWave1Dir(LLVector2 val) { - setValue(SETTING_WAVE1_DIR, val); + mWave1Dir = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector2 getWave2Dir() const { - return LLVector2(mSettings[SETTING_WAVE2_DIR]); + return mWave2Dir; } void setWave2Dir(LLVector2 val) { - setValue(SETTING_WAVE2_DIR, val); + mWave2Dir = val; + setDirtyFlag(true); + setLLSDDirty(); } //------------------------------------------- @@ -218,7 +248,7 @@ public: static LLSD translateLegacySettings(LLSD legacy); - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultWaterNormalAssetId(); @@ -241,9 +271,22 @@ protected: LLSettingsWater(); + LLUUID mTransparentTextureID; + LLUUID mNormalMapID; LLUUID mNextTransparentTextureID; LLUUID mNextNormalMapID; + F32 mBlurMultiplier; + LLColor3 mWaterFogColor; + F32 mWaterFogDensity; + F32 mFogMod; + F32 mFresnelOffset; + F32 mFresnelScale; + LLVector3 mNormalScale; + F32 mScaleAbove; + F32 mScaleBelow; + LLVector2 mWave1Dir; + LLVector2 mWave2Dir; }; #endif diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 0b4630dfc3..05bd704556 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -453,11 +453,11 @@ namespace void applyInjections(LLSettingsBase::Seconds delta) { - this->mSettings = this->mSource->getSettings(); + LLSD settings = this->mSource->cloneSettings(); for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) { - this->mSettings[(*ito).first] = (*ito).second; + settings[(*ito).first] = (*ito).second; } const LLSettingsBase::stringset_t &slerps = this->getSlerpKeys(); @@ -469,7 +469,7 @@ namespace { std::string key_name = (*it)->mKeyName; - LLSD value = this->mSettings[key_name]; + LLSD value = settings[key_name]; LLSD target = (*it)->mValue; if ((*it)->mFirstTime) @@ -485,11 +485,11 @@ namespace { mOverrideValues[key_name] = target; mOverrideExps[key_name] = (*it)->mExperience; - this->mSettings[key_name] = target; + settings[key_name] = target; } else { - this->mSettings.erase(key_name); + settings.erase(key_name); } } else if (specials.find(key_name) != specials.end()) @@ -500,8 +500,8 @@ namespace { if (!(*it)->mBlendIn) mix = 1.0 - mix; - (*it)->mLastValue = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); - this->mSettings[key_name] = (*it)->mLastValue; + (*it)->mLastValue = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, skips, slerps); + settings[key_name] = (*it)->mLastValue; } } @@ -520,7 +520,7 @@ namespace { mInjections.erase(mInjections.begin(), mInjections.end()); } - + this->setSettings(settings); } bool hasInjections() const @@ -685,7 +685,8 @@ namespace if (!injection->mBlendIn) mix = 1.0 - mix; stringset_t dummy; - F64 value = this->mSettings[injection->mKeyName].asReal(); + LLSD settings = this->cloneSettings(); + F64 value = settings[injection->mKeyName].asReal(); if (this->getCloudNoiseTextureId().isNull()) { value = 0; // there was no texture so start from zero coverage @@ -695,7 +696,8 @@ namespace // with different transitions, don't ignore it F64 result = lerp((F32)value, (F32)injection->mValue.asReal(), (F32)mix); injection->mLastValue = LLSD::Real(result); - this->mSettings[injection->mKeyName] = injection->mLastValue; + settings[injection->mKeyName] = injection->mLastValue; + this->setSettings(settings); } // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. @@ -1740,90 +1742,9 @@ void LLEnvironment::updateGLVariablesForSettings(LLShaderUniforms* uniforms, con { uniforms[i].clear(); } - - LLShaderUniforms* shader = &uniforms[LLGLSLShader::SG_ANY]; - //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; - LLSettingsBase::parammapping_t params = psetting->getParameterMap(); - for (auto &it: params) - { - LLSD value; - // legacy first since it contains ambient color and we prioritize value from legacy, see getAmbientColor() - if (psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first)) - { - value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; - } - else if (psetting->mSettings.has(it.first)) - { - value = psetting->mSettings[it.first]; - } - else - { - // We need to reset shaders, use defaults - value = it.second.getDefaultValue(); - } - - LLSD::Type setting_type = value.type(); - stop_glerror(); - switch (setting_type) - { - case LLSD::TypeInteger: - shader->uniform1i(it.second.getShaderKey(), value.asInteger()); - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; - break; - case LLSD::TypeReal: - shader->uniform1f(it.second.getShaderKey(), (F32)value.asReal()); - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; - break; - - case LLSD::TypeBoolean: - shader->uniform1i(it.second.getShaderKey(), value.asBoolean() ? 1 : 0); - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; - break; - - case LLSD::TypeArray: - { - LLVector4 vect4(value); - // always identify as a radiance pass if desaturating irradiance is disabled - static LLCachedControl<bool> desaturate_irradiance(gSavedSettings, "RenderDesaturateIrradiance", true); - - if (desaturate_irradiance && gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass()) - { // maximize and remove tinting if this is an irradiance map render pass and the parameter feeds into the sky background color - auto max_vec = [](LLVector4 col) - { - LLColor3 color(col); - F32 h, s, l; - color.calcHSL(&h, &s, &l); - - col.mV[0] = col.mV[1] = col.mV[2] = l; - return col; - }; - - switch (it.second.getShaderKey()) - { - case LLShaderMgr::BLUE_HORIZON: - case LLShaderMgr::BLUE_DENSITY: - vect4 = max_vec(vect4); - break; - } - } - - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform3fv(it.second.getShaderKey(), LLVector3(vect4.mV) ); - break; - } - - // case LLSD::TypeMap: - // case LLSD::TypeString: - // case LLSD::TypeUUID: - // case LLSD::TypeURI: - // case LLSD::TypeBinary: - // case LLSD::TypeDate: - default: - break; - } - } //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + psetting->applyToUniforms(uniforms); psetting->applySpecial(uniforms); } diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6f9de57d2a..34b8535c84 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -549,7 +549,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() return skyp; } -LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() { LLSD settings = cloneSettings(); U32 flags = getFlags(); @@ -684,6 +684,67 @@ void LLSettingsVOSky::updateSettings() gSky.setMoonScale(getMoonScale()); } +void draw_color(LLShaderUniforms* shader, const LLColor3& col, S32 shader_key) +{ + // always identify as a radiance pass if desaturating irradiance is disabled + static LLCachedControl<bool> desaturate_irradiance(gSavedSettings, "RenderDesaturateIrradiance", true); + + LLVector4 vect4(col.mV[0], col.mV[1], col.mV[2]); + + if (desaturate_irradiance && gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass()) + { // maximize and remove tinting if this is an irradiance map render pass and the parameter feeds into the sky background color + auto max_vec = [](LLVector4 col) + { + LLColor3 color(col); + F32 h, s, l; + color.calcHSL(&h, &s, &l); + + col.mV[0] = col.mV[1] = col.mV[2] = l; + return col; + }; + + switch (shader_key) + { + case LLShaderMgr::BLUE_HORIZON: + case LLShaderMgr::BLUE_DENSITY: + vect4 = max_vec(vect4); + break; + } + } + + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; + shader->uniform3fv(shader_key, LLVector3(vect4.mV)); +} + +inline void draw_real(LLShaderUniforms* shader, F32 value, S32 shader_key) +{ + shader->uniform1f(shader_key, value); +} + +void LLSettingsVOSky::applyToUniforms(void* ptarget) +{ + LLShaderUniforms* shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_ANY]; + + draw_color(shader, getAmbientColor(), LLShaderMgr::AMBIENT); + draw_color(shader, getBlueDensity(), LLShaderMgr::BLUE_DENSITY); + draw_color(shader, getBlueHorizon(), LLShaderMgr::BLUE_HORIZON); + draw_real(shader, getHazeDensity(), LLShaderMgr::HAZE_DENSITY); + draw_real(shader, getHazeHorizon(), LLShaderMgr::HAZE_HORIZON); + draw_real(shader, getDensityMultiplier(), LLShaderMgr::DENSITY_MULTIPLIER); + draw_real(shader, getDistanceMultiplier(), LLShaderMgr::DISTANCE_MULTIPLIER); + draw_color(shader, getCloudPosDensity2(), LLShaderMgr::CLOUD_POS_DENSITY2); + draw_real(shader, getCloudScale(), LLShaderMgr::CLOUD_SCALE); + draw_real(shader, getCloudShadow(), LLShaderMgr::CLOUD_SHADOW); + draw_real(shader, getCloudVariance(), LLShaderMgr::CLOUD_VARIANCE); + draw_color(shader, getGlow(), LLShaderMgr::GLOW); + draw_real(shader, getMaxY(), LLShaderMgr::MAX_Y); + draw_real(shader, getMoonBrightness(), LLShaderMgr::MOON_BRIGHTNESS); + draw_real(shader, getSkyMoistureLevel(), LLShaderMgr::MOISTURE_LEVEL); + draw_real(shader, getSkyDropletRadius(), LLShaderMgr::DROPLET_RADIUS); + draw_real(shader, getSkyIceLevel(), LLShaderMgr::ICE_LEVEL); + draw_real(shader, getReflectionProbeAmbiance(), LLShaderMgr::REFLECTION_PROBE_AMBIANCE); +} + void LLSettingsVOSky::applySpecial(void *ptarget, bool force) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; @@ -702,7 +763,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, light_direction); // Legacy? SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate") - LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + LLVector4 vect_c_p_d1(mCloudPosDensity1.mV[0], mCloudPosDensity1.mV[1], mCloudPosDensity1.mV[2]); LLVector4 cloud_scroll( LLEnvironment::instance().getCloudScrollDelta() ); // SL-13084 EEP added support for custom cloud textures -- flip them horizontally to match the preview of Clouds > Cloud Scroll @@ -935,7 +996,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() return waterp; } -LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() { LLSD settings = cloneSettings(); U32 flags = getFlags(); @@ -974,6 +1035,12 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) } //------------------------------------------------------------------------- //------------------------------------------------------------------------- + +void LLSettingsVOWater::applyToUniforms(void*) +{ + +} + void LLSettingsVOWater::applySpecial(void *ptarget, bool force) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; @@ -1368,7 +1435,7 @@ void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsB } -LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); @@ -1393,10 +1460,10 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const return dayp; } -LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const +LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() { // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD - LLSD settings = llsd_clone(mSettings); + LLSD settings = llsd_clone(getSettings()); U32 flags = getFlags(); LLSettingsDay::ptr_t day_clone = std::make_shared<LLSettingsVODay>(settings); diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index c55b3f82b9..92cb8d0704 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -94,7 +94,7 @@ public: static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages); static ptr_t buildDefaultSky(); - virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() SETTINGS_OVERRIDE; static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); @@ -110,6 +110,7 @@ protected: virtual void updateSettings() override; + virtual void applyToUniforms(void*) override; virtual void applySpecial(void *, bool) override; virtual parammapping_t getParameterMap() const override; @@ -128,7 +129,7 @@ public: static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages); static ptr_t buildDefaultWater(); - virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() SETTINGS_OVERRIDE; static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); @@ -138,6 +139,7 @@ protected: LLSettingsVOWater(); virtual void updateSettings() override; + virtual void applyToUniforms(void*) override; virtual void applySpecial(void *, bool) override; virtual parammapping_t getParameterMap() const override; @@ -167,8 +169,8 @@ public: static ptr_t buildDefaultDayCycle(); static ptr_t buildFromEnvironmentMessage(LLSD settings); static void buildFromOtherSetting(LLSettingsBase::ptr_t settings, asset_built_fn cb); - virtual ptr_t buildClone() const SETTINGS_OVERRIDE; - virtual ptr_t buildDeepCloneAndUncompress() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() SETTINGS_OVERRIDE; + virtual ptr_t buildDeepCloneAndUncompress() SETTINGS_OVERRIDE; static LLSD convertToLegacy(const ptr_t &); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 1be80a5e02..0e7d82fd90 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3888,7 +3888,9 @@ void LLViewerWindow::updateKeyboardFocus() LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); if (cur_focus) { - if (!cur_focus->isInVisibleChain() || !cur_focus->isInEnabledChain()) + bool is_in_visible_chain = cur_focus->isInVisibleChain(); + bool is_in_enabled_chain = cur_focus->isInEnabledChain(); + if (!is_in_visible_chain || !is_in_enabled_chain) { // don't release focus, just reassign so that if being given // to a sibling won't call onFocusLost on all the ancestors @@ -3899,11 +3901,19 @@ void LLViewerWindow::updateKeyboardFocus() bool new_focus_found = false; while(parent) { + if (!is_in_visible_chain) + { + is_in_visible_chain = parent->isInVisibleChain(); + } + if (!is_in_enabled_chain) + { + is_in_enabled_chain = parent->isInEnabledChain(); + } if (parent->isCtrl() && (parent->hasTabStop() || parent == focus_root) && !parent->getIsChrome() - && parent->isInVisibleChain() - && parent->isInEnabledChain()) + && is_in_visible_chain + && is_in_enabled_chain) { if (!parent->focusFirstItem()) { |