diff options
Diffstat (limited to 'indra/llinventory/llsettingsbase.cpp')
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 89 |
1 files changed, 72 insertions, 17 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 4aab3dee3b..8575ac6920 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -69,25 +69,80 @@ const U32 LLSettingsBase::Validator::VALIDATION_PARTIAL(0x01 << 0); LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), mDirty(true), - mBlendedFactor(0.0) + mLLSDDirty(false), + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { + loadValuesFromLLSD(); } LLSettingsBase::LLSettingsBase(const LLSD setting) : mSettings(setting), + mLLSDDirty(false), mDirty(true), - mBlendedFactor(0.0) + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { + loadValuesFromLLSD(); +} + +//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); + saveValuesIfNeeded(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mSettings = interpolateSDMap(mSettings, other.getSettings(), other.getParameterMap(), mix, skip, slerps); setDirtyFlag(true); + loadValuesFromLLSD(); } -LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) const +LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) { LLSD newSettings; @@ -161,13 +216,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 +256,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 +285,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 +312,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 +338,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 +400,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 +417,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,6 +435,7 @@ bool LLSettingsBase::validate() mSettings[SETTING_TYPE] = getSettingsType(); } + saveValuesIfNeeded(); LLSD result = LLSettingsBase::settingValidation(mSettings, validations); if (result["errors"].size() > 0) |