From 40e93e9f4d9059a298e16009483cf531eccd7c82 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Aug 2024 14:15:07 +0200 Subject: Fix formatting and add some more constexpr --- indra/llinventory/llpermissionsflags.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llpermissionsflags.h b/indra/llinventory/llpermissionsflags.h index aaf1fd3afb..0ab4de0ab2 100644 --- a/indra/llinventory/llpermissionsflags.h +++ b/indra/llinventory/llpermissionsflags.h @@ -37,48 +37,48 @@ typedef U32 PermissionBit; // Do you have permission to transfer ownership of the object or // item. Fair use rules dictate that if you cannot copy, you can // always transfer. -const PermissionBit PERM_TRANSFER = (1 << 13); // 0x00002000 +constexpr PermissionBit PERM_TRANSFER = (1 << 13); // 0x00002000 // objects, scale or change textures // parcels, allow building on it -const PermissionBit PERM_MODIFY = (1 << 14); // 0x00004000 +constexpr PermissionBit PERM_MODIFY = (1 << 14); // 0x00004000 // objects, allow copy -const PermissionBit PERM_COPY = (1 << 15); // 0x00008000 +constexpr PermissionBit PERM_COPY = (1 << 15); // 0x00008000 // parcels, allow entry, deprecated -//const PermissionBit PERM_ENTER = (1 << 16); // 0x00010000 +//constexpr PermissionBit PERM_ENTER = (1 << 16); // 0x00010000 // parcels, allow terraform, deprecated -//const PermissionBit PERM_TERRAFORM = (1 << 17); // 0x00020000 +//constexpr PermissionBit PERM_TERRAFORM = (1 << 17); // 0x00020000 // NOTA BENE: This flag is NO LONGER USED!!! However, it is possible that some // objects in the universe have it set so DON"T USE IT going forward. -//const PermissionBit PERM_OWNER_DEBIT = (1 << 18); // 0x00040000 +//constexpr PermissionBit PERM_OWNER_DEBIT = (1 << 18); // 0x00040000 // objects, can grab/translate/rotate -const PermissionBit PERM_MOVE = (1 << 19); // 0x00080000 +constexpr PermissionBit PERM_MOVE = (1 << 19); // 0x00080000 // parcels, avatars take damage, deprecated //const PermissionBit PERM_DAMAGE = (1 << 20); // 0x00100000 // don't use bit 31 -- printf/scanf with "%x" assume signed numbers -const PermissionBit PERM_RESERVED = ((U32)1) << 31; +constexpr PermissionBit PERM_RESERVED = ((U32)1) << 31; -const PermissionMask PERM_NONE = 0x00000000; -const PermissionMask PERM_ALL = 0x7FFFFFFF; -//const PermissionMask PERM_ALL_PARCEL = PERM_MODIFY | PERM_ENTER | PERM_TERRAFORM | PERM_DAMAGE; -const PermissionMask PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER; +constexpr PermissionMask PERM_NONE = 0x00000000; +constexpr PermissionMask PERM_ALL = 0x7FFFFFFF; +//constexpr PermissionMask PERM_ALL_PARCEL = PERM_MODIFY | PERM_ENTER | PERM_TERRAFORM | PERM_DAMAGE; +constexpr PermissionMask PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER; // Useful stuff for transmission. // Which permissions field are we trying to change? -const U8 PERM_BASE = 0x01; +constexpr U8 PERM_BASE = 0x01; // TODO: Add another PERM_OWNER operation type for allowOperationBy DK 04/03/06 -const U8 PERM_OWNER = 0x02; -const U8 PERM_GROUP = 0x04; -const U8 PERM_EVERYONE = 0x08; -const U8 PERM_NEXT_OWNER = 0x10; +constexpr U8 PERM_OWNER = 0x02; +constexpr U8 PERM_GROUP = 0x04; +constexpr U8 PERM_EVERYONE = 0x08; +constexpr U8 PERM_NEXT_OWNER = 0x10; // This is just a quickie debugging key // no modify: PERM_ALL & ~PERM_MODIFY = 0x7fffbfff -- cgit v1.3 From 17fed3985f56033f6c433436935cfde32ea1e7c6 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 29 Aug 2024 15:43:01 +0200 Subject: #2360 Incorrect Day Cycle name in Edit Day Cycle floater (remove unused key CANMOD) --- indra/llinventory/llsettingsbase.cpp | 7 +- indra/newview/llenvironment.cpp | 149 ++++++++++++++++------------- indra/newview/llfloatereditextdaycycle.cpp | 19 ++-- indra/newview/llfloatereditextdaycycle.h | 1 - indra/newview/llfloaterregioninfo.cpp | 2 +- indra/newview/llpanelenvironment.cpp | 94 ++++++++++-------- indra/newview/llpanelenvironment.h | 2 +- indra/newview/llsettingspicker.cpp | 26 ++--- indra/newview/llsettingspicker.h | 1 + indra/newview/llsettingsvo.cpp | 7 +- 10 files changed, 167 insertions(+), 141 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 7b55fbc9e8..4aab3dee3b 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -355,10 +355,11 @@ LLSD LLSettingsBase::getSettings() const LLSD LLSettingsBase::cloneSettings() const { - U32 flags = getFlags(); - LLSD settings (combineSDMaps(getSettings(), LLSD())); - if (flags) + LLSD settings(combineSDMaps(getSettings(), LLSD())); + if (U32 flags = getFlags()) + { settings[SETTING_FLAGS] = LLSD::Integer(flags); + } return settings; } diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 6e31760e9e..0b4630dfc3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1051,8 +1051,8 @@ bool LLEnvironment::isExtendedEnvironmentEnabled() const bool LLEnvironment::isInventoryEnabled() const { - return (!gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty() && - !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); + return !gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty() && + !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty(); } void LLEnvironment::onRegionChange() @@ -1079,9 +1079,8 @@ void LLEnvironment::onRegionChange() void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); - LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); - if (parcel) + if (LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel()) { parcel_id = parcel->getLocalID(); } @@ -1092,7 +1091,8 @@ void LLEnvironment::onParcelChange() //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mCurrentEnvironment->getSky()->getDomeOffset() * mCurrentEnvironment->getSky()->getDomeRadius()); + auto sky = mCurrentEnvironment ? mCurrentEnvironment->getSky() : nullptr; + return sky ? sky->getDomeOffset() * sky->getDomeRadius() : 0; } F32 LLEnvironment::getWaterHeight() const @@ -1103,16 +1103,14 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsSunUp() const { - if (!mCurrentEnvironment || !mCurrentEnvironment->getSky()) - return false; - return mCurrentEnvironment->getSky()->getIsSunUp(); + auto sky = mCurrentEnvironment ? mCurrentEnvironment->getSky() : nullptr; + return sky && sky->getIsSunUp(); } bool LLEnvironment::getIsMoonUp() const { - if (!mCurrentEnvironment || !mCurrentEnvironment->getSky()) - return false; - return mCurrentEnvironment->getSky()->getIsMoonUp(); + auto sky = mCurrentEnvironment ? mCurrentEnvironment->getSky() : nullptr; + return sky && sky->getIsMoonUp(); } //------------------------------------------------------------------------- @@ -1139,13 +1137,19 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro if (create) { if (environment) + { environment = environment->clone(); + } else { if (env == ENV_PUSH) + { environment = std::make_shared(env); + } else + { environment = std::make_shared(env); + } } mEnvironments[env] = environment; } @@ -1172,7 +1176,9 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe environment->animate(); if (!mSignalEnvChanged.empty()) + { mSignalEnvChanged(env, env_version); + } } void LLEnvironment::setCurrentEnvironmentSelection(LLEnvironment::EnvSelection_t env) @@ -1282,7 +1288,9 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm } if (!mSignalEnvChanged.empty()) + { mSignalEnvChanged(env, env_version); + } } void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings, S32 env_version) @@ -1375,7 +1383,9 @@ void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) mEnvironments[env].reset(); if (!mSignalEnvChanged.empty()) + { mSignalEnvChanged(env, VERSION_CLEANUP); + } } void LLEnvironment::logEnvironment(EnvSelection_t env, const LLSettingsBase::ptr_t &settings, S32 env_version) @@ -1415,10 +1425,10 @@ LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelectio return LLSettingsDay::ptr_t(); } - DayInstance::ptr_t environment = getEnvironmentInstance(env); - - if (environment) + if (DayInstance::ptr_t environment = getEnvironmentInstance(env)) + { return environment->getDayCycle(); + } return LLSettingsDay::ptr_t(); } @@ -1431,10 +1441,10 @@ LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env return LLSettingsDay::Seconds(0); } - DayInstance::ptr_t environment = getEnvironmentInstance(env); - - if (environment) + if (DayInstance::ptr_t environment = getEnvironmentInstance(env)) + { return environment->getDayLength(); + } return LLSettingsDay::Seconds(0); } @@ -1447,9 +1457,10 @@ LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env return LLSettingsDay::Seconds(0); } - DayInstance::ptr_t environment = getEnvironmentInstance(env); - if (environment) + if (DayInstance::ptr_t environment = getEnvironmentInstance(env)) + { return environment->getDayOffset(); + } return LLSettingsDay::Seconds(0); } @@ -1479,7 +1490,9 @@ LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironme } if (!fixed.first || !fixed.second) + { LL_WARNS("ENVIRONMENT") << "Can not construct complete fixed environment. Missing Sky and/or Water." << LL_ENDL; + } return fixed; } @@ -1490,10 +1503,10 @@ LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironme return fixedEnvironment_t(); } - DayInstance::ptr_t environment = getEnvironmentInstance(env); - - if (environment) + if (DayInstance::ptr_t environment = getEnvironmentInstance(env)) + { return fixedEnvironment_t(environment->getSky(), environment->getWater()); + } return fixedEnvironment_t(); } @@ -1503,7 +1516,9 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( for (S32 idx = mSelectedEnvironment; idx < ENV_DEFAULT; ++idx) { if (mEnvironments[idx]) + { return mEnvironments[idx]; + } } return mEnvironments[ENV_DEFAULT]; @@ -1514,7 +1529,9 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSharedEnvironmentInstance() for (S32 idx = ENV_PARCEL; idx < ENV_DEFAULT; ++idx) { if (mEnvironments[idx]) + { return mEnvironments[idx]; + } } return mEnvironments[ENV_DEFAULT]; @@ -1673,21 +1690,19 @@ void LLEnvironment::update(const LLViewerCamera * cam) updateSettingsUniforms(); + LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; + end_shaders = LLViewerShaderMgr::instance()->endShaders(); + for (shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) { - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for (shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + shaders_iter->mUniformsDirty = true; + if (shaders_iter->mRiggedVariant) { - shaders_iter->mUniformsDirty = true; - if (shaders_iter->mRiggedVariant) - { - shaders_iter->mRiggedVariant->mUniformsDirty = true; - } + shaders_iter->mRiggedVariant->mUniformsDirty = true; + } - for (auto& variant : shaders_iter->mGLTFVariants) - { - variant.mUniformsDirty = true; - } + for (auto& variant : shaders_iter->mGLTFVariants) + { + variant.mUniformsDirty = true; } } } @@ -1971,7 +1986,6 @@ void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_l updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset, altitudes, cb); } - void LLEnvironment::resetRegion(environment_apply_fn cb) { resetParcel(INVALID_PARCEL_ID, cb); @@ -1996,7 +2010,10 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) LLEnvironmentRequest::initiate(cb); } else if (cb) + { cb(parcel_id, EnvironmentInfo::ptr_t()); + } + return; } @@ -2006,16 +2023,14 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) cb = [this, transition](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo, transition); }; } - std::string coroname = - LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", + LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, U32 flags, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { UpdateInfo::ptr_t updates(std::make_shared(asset_id, display_name, day_length, day_offset, altitudes, flags)); - std::string coroname = - LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); } @@ -2031,7 +2046,9 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p LLSettingsDay::ptr_t pday; if (settings->getSettingsType() == "daycycle") + { pday = std::static_pointer_cast(settings); + } else { pday = createDayCycleFromEnvironment( (parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, settings); @@ -2065,8 +2082,7 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday { UpdateInfo::ptr_t updates(std::make_shared(pday, day_length, day_offset, altitudes)); - std::string coroname = - LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); } @@ -2075,12 +2091,9 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday updateParcel(parcel_id, pday, NO_TRACK, day_length, day_offset, altitudes, cb); } - - void LLEnvironment::resetParcel(S32 parcel_id, environment_apply_fn cb) { - std::string coroname = - LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", + LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", [this, parcel_id, cb]() { coroResetEnvironment(parcel_id, NO_TRACK, cb); }); } @@ -2130,7 +2143,6 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ }); } } - } void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInfo::ptr_t updates, environment_apply_fn apply) @@ -2150,9 +2162,14 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf if (track_no == NO_TRACK) { // day length and offset are only applicable if we are addressing the entire day cycle. if (updates->mDayLength > 0) + { body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = updates->mDayLength; + } + if (updates->mDayOffset > 0) + { body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = updates->mDayOffset; + } if ((parcel_id == INVALID_PARCEL_ID) && (updates->mAltitudes.size() == 3)) { // only test for altitude changes if we are changing the region. @@ -2165,12 +2182,16 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf } if (updates->mDayp) + { body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = updates->mDayp->getSettings(); + } else if (!updates->mSettingsAsset.isNull()) { body[KEY_ENVIRONMENT][KEY_DAYASSET] = updates->mSettingsAsset; if (!updates->mDayName.empty()) + { body[KEY_ENVIRONMENT][KEY_DAYNAME] = updates->mDayName; + } } body[KEY_ENVIRONMENT][KEY_FLAGS] = LLSD::Integer(updates->mFlags); @@ -2188,22 +2209,27 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf if (track_no != NO_TRACK) query << "&"; } + if (track_no != NO_TRACK) { query << "trackno=" << track_no; } + url += query.str(); } LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); // results that come back may contain the new settings + if (LLApp::isExiting()) + return; + LLSD notify; LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if ((!status) || !result["success"].asBoolean()) + if (!status || !result["success"].asBoolean()) { LL_WARNS("ENVIRONMENT") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; @@ -2218,10 +2244,6 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf notify["FAIL_REASON"] = reason; } } - else if (LLApp::isExiting()) - { - return; - } else { LLSD environment = result[KEY_ENVIRONMENT]; @@ -2272,34 +2294,26 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environmen LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); // results that come back may contain the new settings + if (LLApp::isExiting()) + return; + LLSD notify; LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if ((!status) || !result["success"].asBoolean()) + if (!status || !result["success"].asBoolean()) { LL_WARNS("ENVIRONMENT") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; notify = LLSD::emptyMap(); std::string reason = result["message"].asString(); - if (reason.empty()) - { - notify["FAIL_REASON"] = status.toString(); - } - else - { - notify["FAIL_REASON"] = reason; - } - } - else if (LLApp::isExiting()) - { - return; + notify["FAIL_REASON"] = reason.empty() ? status.toString() : reason; } - else + else if (apply) { - LLSD environment = result[KEY_ENVIRONMENT]; - if (environment.isDefined() && apply) + LLSD environment = result[KEY_ENVIRONMENT]; + if (environment.isDefined()) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); apply(parcel_id, envinfo); @@ -2311,7 +2325,6 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environmen LLNotificationsUtil::add("WLRegionApplyFail", notify); //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); } - } diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index d6e7cd97f3..fd58cd8aaf 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -132,7 +132,6 @@ namespace { //========================================================================= const std::string LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT("edit_context"); const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length"); -const std::string LLFloaterEditExtDayCycle::KEY_CANMOD("canmod"); const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_INVENTORY("inventory"); const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL("parcel"); @@ -286,11 +285,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) mEditContext = CONTEXT_REGION; } - if (key.has(KEY_CANMOD)) - { - mCanMod = key[KEY_CANMOD].asBoolean(); - } - if (mEditContext == CONTEXT_UNKNOWN) { LL_WARNS("ENVDAYEDIT") << "Unknown editing context!" << LL_ENDL; @@ -298,6 +292,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) if (key.has(KEY_INVENTORY_ID)) { + // mCanMod is initialized inside this call loadInventoryItem(key[KEY_INVENTORY_ID].asUUID()); } else @@ -519,14 +514,20 @@ void LLFloaterEditExtDayCycle::setEditDefaultDayCycle() std::string LLFloaterEditExtDayCycle::getEditName() const { if (mEditDay) + { return mEditDay->getName(); + } + return "new"; } void LLFloaterEditExtDayCycle::setEditName(const std::string &name) { if (mEditDay) + { mEditDay->setName(name); + } + getChild(TXT_DAY_NAME)->setText(name); } @@ -548,13 +549,13 @@ bool LLFloaterEditExtDayCycle::handleKeyUp(KEY key, MASK mask, bool called_from_ keymap_t::iterator it = mSliderKeyMap.find(curslider); if (it != mSliderKeyMap.end()) { - if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos)) + if (mEditDay->moveTrackKeyframe(mCurrentTrack, it->second.mFrame, sliderpos)) { - (*it).second.mFrame = sliderpos; + it->second.mFrame = sliderpos; } else { - mFramesSlider->setCurSliderValue((*it).second.mFrame); + mFramesSlider->setCurSliderValue(it->second.mFrame); } } else diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 926a24f8a4..992b532967 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -60,7 +60,6 @@ class LLFloaterEditExtDayCycle : public LLFloaterEditEnvironmentBase public: static const std::string KEY_EDIT_CONTEXT; static const std::string KEY_DAY_LENGTH; - static const std::string KEY_CANMOD; static const std::string VALUE_CONTEXT_INVENTORY; static const std::string VALUE_CONTEXT_PARCEL; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 7869abf66d..66e88e8841 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -4291,7 +4291,7 @@ void LLPanelRegionEnvironment::refreshFromSource() } LLEnvironment::instance().requestRegion( - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); }); setControlsEnabled(false); } diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index c1d8ce50ff..423ca376d1 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -392,8 +392,10 @@ std::string LLPanelEnvironmentInfo::getNameForTrackIndex(U32 index) if (invname.empty()) { invname = getNameForTrackIndex(index - 1); - if (invname[0] != '(') + if (!invname.empty() && invname.front() != '(') + { invname = "(" + invname + ")"; + } } return invname; @@ -764,7 +766,7 @@ void LLPanelEnvironmentInfo::commitDayLenOffsetChanges(bool need_callback) (S32)mCurrentEnvironment->mDayLength.value(), (S32)mCurrentEnvironment->mDayOffset.value(), LLEnvironment::altitudes_vect_t(), - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); }); } else { @@ -852,7 +854,7 @@ void LLPanelEnvironmentInfo::onBtnDefault() if (opt == 0) { LLEnvironment::instance().resetParcel(parcel_id, - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); }); } }); } @@ -864,8 +866,7 @@ void LLPanelEnvironmentInfo::onBtnEdit() LLFloaterEditExtDayCycle *dayeditor = getEditFloater(); LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, isRegion() ? LLFloaterEditExtDayCycle::VALUE_CONTEXT_REGION : LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL) - (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS) - (LLFloaterEditExtDayCycle::KEY_CANMOD, LLSD::Boolean(true))); + (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS)); dayeditor->openFloater(params); @@ -882,13 +883,13 @@ void LLPanelEnvironmentInfo::onBtnEdit() void LLPanelEnvironmentInfo::onBtnSelect() { - LLFloaterSettingsPicker *picker = getSettingsPicker(); - if (picker) + if (LLFloaterSettingsPicker* picker = getSettingsPicker()) { LLUUID item_id; if (mCurrentEnvironment && mCurrentEnvironment->mDayCycle) { - item_id = LLFloaterSettingsPicker::findItemID(mCurrentEnvironment->mDayCycle->getAssetId(), false, false); + LLUUID asset_id = mCurrentEnvironment->mDayCycle->getAssetId(); + item_id = LLFloaterSettingsPicker::findItemID(asset_id, false); } picker->setSettingsFilter(LLSettingsType::ST_NONE); picker->setSettingsItemId(item_id); @@ -919,7 +920,7 @@ void LLPanelEnvironmentInfo::onBtnRstAltitudes() mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, alts, - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); }); } } @@ -985,32 +986,41 @@ void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, std::string sourc void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, S32 track_num) { - LLInventoryItem *itemp = gInventory.getItem(item_id); - if (itemp) + if (LLInventoryItem* itemp = gInventory.getItem(item_id)) { + LL_INFOS("ENVPANEL") << "item '" << item_id << "' : '" << itemp->getDescription() << "'" << LL_ENDL; + LLHandle that_h = getHandle(); clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); U32 flags(0); - if (itemp) + if (!itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) { - if (!itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) - flags |= LLSettingsBase::FLAG_NOMOD; - if (!itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) - flags |= LLSettingsBase::FLAG_NOTRANS; + flags |= LLSettingsBase::FLAG_NOMOD; } - LLEnvironment::instance().updateParcel(getParcelId(), - itemp->getAssetUUID(), - itemp->getName(), - track_num, - mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, - mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, - flags, - LLEnvironment::altitudes_vect_t(), - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + if (!itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) + { + flags |= LLSettingsBase::FLAG_NOTRANS; + } + + LLEnvironment::instance().updateParcel + ( + getParcelId(), + itemp->getAssetUUID(), + itemp->getName(), + track_num, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, + flags, + LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) + { + onEnvironmentReceived(that_h, parcel_id, envifo); + } + ); } } @@ -1018,17 +1028,20 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) { LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); LLEnvironment::instance().updateEnvironment(); + if (!newday) { LL_WARNS("ENVPANEL") << "Editor committed an empty day. Do nothing." << LL_ENDL; return; } + if (!mCurrentEnvironment) { // Attempting to save mid update? LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " env version: " << mCurEnvVersion << LL_ENDL; return; } + size_t newhash(newday->getHash()); size_t oldhash((mCurrentEnvironment->mDayCycle) ? mCurrentEnvironment->mDayCycle->getHash() : 0); @@ -1043,7 +1056,7 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, LLEnvironment::altitudes_vect_t(), - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); }); } } @@ -1080,8 +1093,7 @@ void LLPanelEnvironmentInfo::onEnvironmentChanged(LLEnvironment::EnvSelection_t else if ((env == LLEnvironment::ENV_PARCEL) && (getParcelId() == LLViewerParcelMgr::instance().getAgentParcelId())) { - LLParcel *parcel = getParcel(); - if (parcel) + if (LLParcel* parcel = getParcel()) { // first for parcel own settings, second is for case when parcel uses region settings if (mCurEnvVersion < new_version @@ -1143,17 +1155,21 @@ void LLPanelEnvironmentInfo::onEnvironmentReceived(S32 parcel_id, LLEnvironment: // todo: we have envifo and parcel env version, should we just setEnvironment() and parcel's property to prevent dupplicate requests? } -void LLPanelEnvironmentInfo::_onEnvironmentReceived(LLHandle that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) +// static +void LLPanelEnvironmentInfo::onEnvironmentReceived(LLHandle that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { - LLPanelEnvironmentInfo *that = (LLPanelEnvironmentInfo *)that_h.get(); - if (!that) - return; - that->onEnvironmentReceived(parcel_id, envifo); + if (LLPanelEnvironmentInfo* that = (LLPanelEnvironmentInfo*)that_h.get()) + { + that->onEnvironmentReceived(parcel_id, envifo); + } } LLSettingsDropTarget::LLSettingsDropTarget(const LLSettingsDropTarget::Params& p) - : LLView(p), mEnvironmentInfoPanel(NULL), mDndEnabled(false) -{} + : LLView(p) + , mEnvironmentInfoPanel(NULL) + , mDndEnabled(false) +{ +} bool LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type, @@ -1170,11 +1186,9 @@ bool LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, switch (cargo_type) { case DAD_SETTINGS: - { - LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; - if (inv_item && mEnvironmentInfoPanel) + if (cargo_data && mEnvironmentInfoPanel) { - LLUUID item_id = inv_item->getUUID(); + LLUUID item_id = ((LLViewerInventoryItem*)cargo_data)->getUUID(); if (gInventory.getItem(item_id)) { *accept = ACCEPT_YES_COPY_SINGLE; @@ -1190,11 +1204,11 @@ bool LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, *accept = ACCEPT_NO; } break; - } default: *accept = ACCEPT_NO; break; } } + return handled; } diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index c9b95cc348..e9a42c8962 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -137,7 +137,7 @@ protected: void onPickerAssetDownloaded(LLSettingsBase::ptr_t settings); void onEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); - static void _onEnvironmentReceived(LLHandle that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); + static void onEnvironmentReceived(LLHandle that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); virtual bool isLargeEnough() = 0; virtual void refreshFromSource() = 0; diff --git a/indra/newview/llsettingspicker.cpp b/indra/newview/llsettingspicker.cpp index 85f0678c4c..24cf543864 100644 --- a/indra/newview/llsettingspicker.cpp +++ b/indra/newview/llsettingspicker.cpp @@ -348,6 +348,11 @@ void LLFloaterSettingsPicker::onButtonCancel() } void LLFloaterSettingsPicker::onButtonSelect() +{ + applySelectedItemAndCloseFloater(); +} + +void LLFloaterSettingsPicker::applySelectedItemAndCloseFloater() { if (mCommitSignal) { @@ -378,14 +383,7 @@ bool LLFloaterSettingsPicker::handleDoubleClick(S32 x, S32 y, MASK mask) if (target_rect.pointInRect(x, y)) { // Quick-apply - if (mCommitSignal) - { - LLSD res; - res["ItemId"] = mSettingItemID; - res["Track"] = getChild(CMB_TRACK_SELECTION)->getValue(); - (*mCommitSignal)(this, res); - } - closeFloater(); + applySelectedItemAndCloseFloater(); // hit inside panel on selected item, double click should do nothing result = true; } @@ -408,14 +406,7 @@ bool LLFloaterSettingsPicker::handleKeyHere(KEY key, MASK mask) if (item_viewp && item_viewp->getIsCurSelection() && item_viewp->getVisible()) { // Quick-apply - if (mCommitSignal) - { - LLSD res; - res["ItemId"] = mSettingItemID; - res["Track"] = getChild(CMB_TRACK_SELECTION)->getValue(); - (*mCommitSignal)(this, res); - } - closeFloater(); + applySelectedItemAndCloseFloater(); return true; } } @@ -466,6 +457,9 @@ void LLFloaterSettingsPicker::setSettingsItemId(const LLUUID &settings_id, bool LLInventoryItem* LLFloaterSettingsPicker::findItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library) { + if (asset_id.isNull()) + return nullptr; + LLViewerInventoryCategory::cat_array_t cats; LLViewerInventoryItem::item_array_t items; LLAssetIDMatches asset_id_matches(asset_id); diff --git a/indra/newview/llsettingspicker.h b/indra/newview/llsettingspicker.h index 29827dfb94..e5b1e15899 100644 --- a/indra/newview/llsettingspicker.h +++ b/indra/newview/llsettingspicker.h @@ -111,6 +111,7 @@ private: bool handleKeyHere(KEY key, MASK mask) override; void onFocusLost() override; + void applySelectedItemAndCloseFloater(); LLHandle mOwnerHandle; LLUUID mSettingItemID; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 5152570786..e05b6f3736 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1387,9 +1387,12 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const LLSettingsDay::ptr_t dayp = std::make_shared(settings); - U32 flags = getFlags(); - if (flags) + dayp->setName(getName()); + + if (U32 flags = getFlags()) + { dayp->setFlags(flags); + } dayp->initialize(); return dayp; -- cgit v1.3 From 047eb16f4c8fdfb1826136db9ee2eed83cb95416 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 10 Sep 2024 23:07:07 +0300 Subject: viewer#2529 Optimize updateGLVariablesForSettings Intent is to eventually use only stored variables for everything. LLSD operations are far too expensive. --- indra/llinventory/llsettingsbase.cpp | 89 ++++-- indra/llinventory/llsettingsbase.h | 109 ++++---- indra/llinventory/llsettingsdaycycle.cpp | 45 ++-- indra/llinventory/llsettingsdaycycle.h | 12 +- indra/llinventory/llsettingssky.cpp | 447 +++++++++++++++++++++++-------- indra/llinventory/llsettingssky.h | 67 ++++- indra/llinventory/llsettingswater.cpp | 53 +++- indra/llinventory/llsettingswater.h | 87 ++++-- indra/newview/llenvironment.cpp | 105 +------- indra/newview/llsettingsvo.cpp | 80 +++++- indra/newview/llsettingsvo.h | 10 +- 11 files changed, 767 insertions(+), 337 deletions(-) (limited to 'indra/llinventory') 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) diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 9d8d746b7e..c2867f32d9 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -110,71 +110,55 @@ public: virtual bool isVeryDirty() const { return mReplaced; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; clearAssetId(); } - 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; + 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(mSettings[SETTING_FLAGS].asInteger()); - return 0; + return mSettingFlags; } inline void setFlags(U32 value) { - setLLSD(SETTING_FLAGS, LLSD::Integer(value)); + mSettingFlags = value; + 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 +167,31 @@ public: setDirtyFlag(true); mReplaced = true; mSettings = settings; + loadValuesFromLLSD(); + } + + 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; + mDirty = true; + clearAssetId(); + } //--------------------------------------------------------------------- // inline void setLLSD(const std::string &name, const LLSD &value) { + saveValuesIfNeeded(); mSettings[name] = value; mDirty = true; if (name != SETTING_ASSETID) @@ -202,8 +203,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 +261,11 @@ public: (const_cast(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 +312,20 @@ 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(); + protected: LLSettingsBase(); @@ -331,7 +336,7 @@ protected: typedef std::set 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 +344,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 +358,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(LLSettingsBase::ptr_t other) { replaceSettings(other->cloneSettings()); 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..19d1bb1907 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -124,33 +124,40 @@ 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); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); } //========================================================================= -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 in_use; @@ -174,7 +181,7 @@ LLSD LLSettingsDay::getSettings() const } tracks.append(trackout); } - settings[SETTING_TRACKS] = tracks; + mDaySettings[SETTING_TRACKS] = tracks; LLSD frames(LLSD::emptyMap()); for (std::map::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) @@ -184,9 +191,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 +405,8 @@ bool LLSettingsDay::initialize(bool validate_frames) mSettings[SETTING_ASSETID] = assetid; } + loadValuesFromLLSD(); + mInitialized = true; return true; } @@ -449,7 +464,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..272219c02d 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -443,7 +443,7 @@ void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) mNextHaloTextureId = pother->mNextHaloTextureId; } -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; llassert(getSettingsType() == end->getSettingsType()); @@ -451,24 +451,29 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast(end); if (other) { - if (other->mSettings.has(SETTING_LEGACY_HAZE)) + LLSD& settings = getSettings(); + LLSD& other_settings = other->getSettings(); + if (other_settings.has(SETTING_LEGACY_HAZE)) { - if (!mSettings.has(SETTING_LEGACY_HAZE) || !mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) + if (!settings.has(SETTING_LEGACY_HAZE) || !settings[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()); + // see getColor(), we are about to replaceSettings(), so we are free to set it + LLColor3 ambient = getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + setAmbientColor(ambient); + settings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = ambient.getValue(); } } else { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) + if (settings.has(SETTING_LEGACY_HAZE) && settings[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); + LLColor3 ambient = getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + settings[SETTING_AMBIENT] = ambient.getValue(); + settings[SETTING_LEGACY_HAZE].erase(SETTING_AMBIENT); } } @@ -480,22 +485,24 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) // 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); + cloud_shadow = lerp((F32)settings[SETTING_CLOUD_SHADOW].asReal(), 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); + cloud_shadow = lerp(0.f, (F32)other_settings[SETTING_CLOUD_SHADOW].asReal(), (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); + cloud_shadow = lerp((F32)settings[SETTING_CLOUD_SHADOW].asReal(), (F32)other_settings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); } + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); + LLSD blenddata = interpolateSDMap(settings, other_settings, other->getParameterMap(), blendf, skip, slerps); blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(cloud_shadow); replaceSettings(blenddata); mNextSunTextureId = other->getSunTextureId(); @@ -955,6 +962,180 @@ 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(); + } + 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]); + } + 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 + 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)); +} + +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]; + if (mLegacyDistanceMultiplier) + { + legacy[SETTING_DISTANCE_MULTIPLIER] = mDistanceMultiplier; + } + if (mLegacyDensityMultiplier) + { + legacy[SETTING_DENSITY_MULTIPLIER] = mDensityMultiplier; + } + if (mLegacyHazeHorizon) + { + legacy[SETTING_HAZE_HORIZON] = mHazeHorizon; + } + if (mLegacyHazeDensity) + { + legacy[SETTING_HAZE_DENSITY] = mHazeDensity; + } + if (mLegacyBlueHorizon) + { + legacy[SETTING_BLUE_HORIZON] = mBlueHorizon.getValue(); + } + if (mLegacyBlueDensity) + { + legacy[SETTING_BLUE_DENSITY] = mBlueDensity.getValue(); + } + if (mLegacyAmbientColor) + { + legacy[SETTING_AMBIENT] = mAmbientColor.getValue(); + } +} + F32 LLSettingsSky::getSunMoonGlowFactor() const { return getIsSunUp() ? 1.0f : @@ -1024,37 +1205,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,118 +1256,135 @@ 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); } void LLSettingsSky::setBlueDensity(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY] = val.getValue(); + mBlueDensity = val; + mLegacyBlueDensity = true; setDirtyFlag(true); } void LLSettingsSky::setBlueHorizon(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON] = val.getValue(); + mBlueHorizon = val; + mLegacyBlueHorizon = true; setDirtyFlag(true); } void LLSettingsSky::setDensityMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER] = val; + mDensityMultiplier = val; + mLegacyDensityMultiplier = true; setDirtyFlag(true); } void LLSettingsSky::setDistanceMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER] = val; + mDistanceMultiplier = val; + mLegacyDistanceMultiplier = true; setDirtyFlag(true); } void LLSettingsSky::setHazeDensity(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY] = val; + mHazeDensity = val; + mLegacyHazeDensity = true; setDirtyFlag(true); } void LLSettingsSky::setHazeHorizon(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON] = val; + mHazeHorizon = val; + mLegacyHazeHorizon = true; setDirtyFlag(true); } @@ -1299,7 +1500,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 +1616,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 +1641,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 +1666,169 @@ 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; - setDirtyFlag(true); + mScrollRate.mV[0] = val; + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateY(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; - setDirtyFlag(true); + mScrollRate.mV[1] = val; + 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 +1845,94 @@ 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); - setDirtyFlag(true); + mGamma = val; + 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 +1951,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 +2011,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..dc8e620f47 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -111,20 +111,23 @@ 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; void replaceWithSky(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 +309,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 +351,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 +364,63 @@ protected: LLUUID mNextRainbowTextureId; LLUUID mNextHaloTextureId; + bool mCanAutoAdjust; + F32 mReflectionProbeAmbiance; + F32 mSunScale; + LLQuaternion mSunRotation; + LLColor3 mSunlightColor; + F32 mStarBrightness; + F32 mMoonBrightness; + F32 mMoonScale; + LLQuaternion mMoonRotation; + F32 mMaxY; + LLColor3 mGlow; + F32 mGamma; + F32 mCloudVariance; + F32 mCloudShadow; + LLVector2 mScrollRate; + F32 mCloudScale; + 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 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..6127a523ae 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -109,6 +109,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,12 +227,14 @@ 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) { LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast(end); if (other) { - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + LLSD blenddata = interpolateSDMap(getSettings(), other->getSettings(), other->getParameterMap(), blendf, skip, slerps); replaceSettings(blenddata); mNextNormalMapID = other->getNormalMapID(); mNextTransparentTextureID = other->getTransparentTextureID(); diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 9e7ff61272..0f2a62bba2 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -55,151 +55,167 @@ 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); 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; + setLLSDDirty(); } LLColor3 getWaterFogColor() const { - return LLColor3(mSettings[SETTING_FOG_COLOR]); + return mWaterFogColor; } void setWaterFogColor(LLColor3 val) { - setValue(SETTING_FOG_COLOR, val); + mWaterFogColor = val; + 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; + setLLSDDirty(); } F32 getFogMod() const { - return (F32)mSettings[SETTING_FOG_MOD].asReal(); + return mFogMod; } void setFogMod(F32 val) { - setValue(SETTING_FOG_MOD, val); + mFogMod = val; + setLLSDDirty(); } F32 getFresnelOffset() const { - return (F32)mSettings[SETTING_FRESNEL_OFFSET].asReal(); + return mFresnelOffset; } void setFresnelOffset(F32 val) { - setValue(SETTING_FRESNEL_OFFSET, val); + mFresnelOffset = val; + setLLSDDirty(); } F32 getFresnelScale() const { - return (F32)mSettings[SETTING_FRESNEL_SCALE].asReal(); + return mFresnelScale; } void setFresnelScale(F32 val) { - setValue(SETTING_FRESNEL_SCALE, val); + mFresnelScale = val; + setLLSDDirty(); } LLUUID getTransparentTextureID() const { - return mSettings[SETTING_TRANSPARENT_TEXTURE].asUUID(); + return mTransparentTextureID; } void setTransparentTextureID(LLUUID val) { - setValue(SETTING_TRANSPARENT_TEXTURE, val); + mTransparentTextureID = val; + setLLSDDirty(); } LLUUID getNormalMapID() const { - return mSettings[SETTING_NORMAL_MAP].asUUID(); + return mNormalMapID; } void setNormalMapID(LLUUID val) { - setValue(SETTING_NORMAL_MAP, val); + mNormalMapID = val; + setLLSDDirty(); } LLVector3 getNormalScale() const { - return LLVector3(mSettings[SETTING_NORMAL_SCALE]); + return mNormalScale; } void setNormalScale(LLVector3 val) { - setValue(SETTING_NORMAL_SCALE, val); + mNormalScale = val; + setLLSDDirty(); } F32 getScaleAbove() const { - return (F32)mSettings[SETTING_SCALE_ABOVE].asReal(); + return mScaleAbove; } void setScaleAbove(F32 val) { - setValue(SETTING_SCALE_ABOVE, val); + mScaleAbove = val; + setLLSDDirty(); } F32 getScaleBelow() const { - return (F32)mSettings[SETTING_SCALE_BELOW].asReal(); + return mScaleBelow; } void setScaleBelow(F32 val) { - setValue(SETTING_SCALE_BELOW, val); + mScaleBelow = val; + setLLSDDirty(); } LLVector2 getWave1Dir() const { - return LLVector2(mSettings[SETTING_WAVE1_DIR]); + return mWave1Dir; } void setWave1Dir(LLVector2 val) { - setValue(SETTING_WAVE1_DIR, val); + mWave1Dir = val; + setLLSDDirty(); } LLVector2 getWave2Dir() const { - return LLVector2(mSettings[SETTING_WAVE2_DIR]); + return mWave2Dir; } void setWave2Dir(LLVector2 val) { - setValue(SETTING_WAVE2_DIR, val); + mWave2Dir = val; + setLLSDDirty(); } //------------------------------------------- @@ -218,7 +234,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 +257,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 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 e05b6f3736..be891213a7 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,68 @@ 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 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]; + LLSD &settings = getSettings(); + + 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 +764,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 +997,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 +1036,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; @@ -1373,7 +1441,7 @@ void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsB } -LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); @@ -1398,10 +1466,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(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 &); -- cgit v1.3 From 0a110ff0833216b167e032987b0d676f29ad0ee5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 11 Sep 2024 18:21:03 +0300 Subject: viewer#2529 Track interpolateSDMap's performance viewer#2529 Fix initialization --- indra/llinventory/llsettingsbase.cpp | 8 ++++---- indra/llinventory/llsettingsbase.h | 4 ++-- indra/llinventory/llsettingsdaycycle.cpp | 2 ++ indra/llinventory/llsettingssky.cpp | 24 +++++++++++++++++++++++- indra/llinventory/llsettingssky.h | 1 + indra/llinventory/llsettingswater.cpp | 3 +++ indra/llinventory/llsettingswater.h | 13 +++++++++++++ 7 files changed, 48 insertions(+), 7 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 8575ac6920..f7151403b4 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -69,23 +69,21 @@ const U32 LLSettingsBase::Validator::VALIDATION_PARTIAL(0x01 << 0); LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), mDirty(true), - mLLSDDirty(false), + mLLSDDirty(true), mReplaced(false), mBlendedFactor(0.0), mSettingFlags(0) { - loadValuesFromLLSD(); } LLSettingsBase::LLSettingsBase(const LLSD setting) : mSettings(setting), - mLLSDDirty(false), + mLLSDDirty(true), mDirty(true), mReplaced(false), mBlendedFactor(0.0), mSettingFlags(0) { - loadValuesFromLLSD(); } //virtual @@ -134,6 +132,7 @@ void LLSettingsBase::saveValuesIfNeeded() //========================================================================= void LLSettingsBase::lerpSettings(LLSettingsBase &other, F64 mix) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; saveValuesIfNeeded(); stringset_t skip = getSkipInterpolateKeys(); stringset_t slerps = getSlerpKeys(); @@ -437,6 +436,7 @@ bool LLSettingsBase::validate() saveValuesIfNeeded(); LLSD result = LLSettingsBase::settingValidation(mSettings, validations); + loadValuesFromLLSD(); if (result["errors"].size() > 0) { diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index c2867f32d9..dc2a745fa0 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -125,6 +125,7 @@ public: inline void setName(std::string val) { mSettingName = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -141,6 +142,7 @@ public: inline void setFlags(U32 value) { mSettingFlags = value; + setDirtyFlag(true); setLLSDDirty(); } @@ -183,8 +185,6 @@ public: virtual void setLLSDDirty() { mLLSDDirty = true; - mDirty = true; - clearAssetId(); } //--------------------------------------------------------------------- diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 19d1bb1907..2b189e7cca 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -128,6 +128,7 @@ LLSettingsDay::LLSettingsDay(const LLSD &data) : mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + loadValuesFromLLSD(); } LLSettingsDay::LLSettingsDay() : @@ -136,6 +137,7 @@ LLSettingsDay::LLSettingsDay() : mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + replaceSettings(defaults()); } //========================================================================= diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 272219c02d..548c1b30e1 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -407,6 +407,7 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) : mNextRainbowTextureId(), mNextHaloTextureId() { + loadValuesFromLLSD(); } LLSettingsSky::LLSettingsSky(): @@ -418,6 +419,7 @@ LLSettingsSky::LLSettingsSky(): mNextRainbowTextureId(), mNextHaloTextureId() { + replaceSettings(defaults()); } void LLSettingsSky::replaceSettings(LLSD settings) @@ -460,7 +462,6 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) // Special case since SETTING_AMBIENT is both in outer and legacy maps, we prioritize legacy one // see getColor(), we are about to replaceSettings(), so we are free to set it LLColor3 ambient = getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); - setAmbientColor(ambient); settings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = ambient.getValue(); } } @@ -974,6 +975,7 @@ F32 get_float(bool &use_legacy, LLSD& settings, std::string key, F32 default_val { return (F32)settings[key].asReal(); } + use_legacy = true; return default_value; } @@ -989,6 +991,7 @@ LLColor3 get_color(bool& use_legacy, LLSD& settings, const std::string& key, con { return LLColor3(settings[key]); } + use_legacy = true; return default_value; } @@ -1046,6 +1049,7 @@ void LLSettingsSky::loadValuesFromLLSD() 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); @@ -1053,6 +1057,14 @@ void LLSettingsSky::loadValuesFromLLSD() 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 LLSettingsSky::saveValuesToLLSD() @@ -1344,6 +1356,7 @@ void LLSettingsSky::setAmbientColor(const LLColor3 &val) mAmbientColor = val; mLegacyAmbientColor = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueDensity(const LLColor3 &val) @@ -1351,6 +1364,7 @@ void LLSettingsSky::setBlueDensity(const LLColor3 &val) mBlueDensity = val; mLegacyBlueDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueHorizon(const LLColor3 &val) @@ -1358,6 +1372,7 @@ void LLSettingsSky::setBlueHorizon(const LLColor3 &val) mBlueHorizon = val; mLegacyBlueHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDensityMultiplier(F32 val) @@ -1365,6 +1380,7 @@ void LLSettingsSky::setDensityMultiplier(F32 val) mDensityMultiplier = val; mLegacyDensityMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDistanceMultiplier(F32 val) @@ -1372,6 +1388,7 @@ void LLSettingsSky::setDistanceMultiplier(F32 val) mDistanceMultiplier = val; mLegacyDistanceMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeDensity(F32 val) @@ -1379,6 +1396,7 @@ void LLSettingsSky::setHazeDensity(F32 val) mHazeDensity = val; mLegacyHazeDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeHorizon(F32 val) @@ -1386,6 +1404,7 @@ void LLSettingsSky::setHazeHorizon(F32 val) mHazeHorizon = val; mLegacyHazeHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } // Get total from rayleigh and mie density values for normalization @@ -1800,12 +1819,14 @@ void LLSettingsSky::setCloudScrollRate(const LLVector2 &val) void LLSettingsSky::setCloudScrollRateX(F32 val) { mScrollRate.mV[0] = val; + setDirtyFlag(true); setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateY(F32 val) { mScrollRate.mV[1] = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -1851,6 +1872,7 @@ F32 LLSettingsSky::getGamma() const void LLSettingsSky::setGamma(F32 val) { mGamma = val; + setDirtyFlag(true); setLLSDDirty(); } LLColor3 LLSettingsSky::getGlow() const diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index dc8e620f47..535c4722ef 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -402,6 +402,7 @@ protected: LLColor3 mBlueDensity; LLColor3 mAmbientColor; + bool mHasLegacyHaze; bool mLegacyHazeHorizon; bool mLegacyHazeDensity; bool mLegacyDistanceMultiplier; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 6127a523ae..cad0b41d67 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -70,12 +70,14 @@ LLSettingsWater::LLSettingsWater(const LLSD &data) : LLSettingsBase(data), mNextNormalMapID() { + loadValuesFromLLSD(); } LLSettingsWater::LLSettingsWater() : LLSettingsBase(), mNextNormalMapID() { + replaceSettings(defaults()); } //========================================================================= @@ -229,6 +231,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) void LLSettingsWater::blend(LLSettingsBase::ptr_t &end, F64 blendf) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast(end); if (other) { diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 0f2a62bba2..9d229e6a0b 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -81,6 +81,7 @@ public: void setBlurMultiplier(F32 val) { mBlurMultiplier = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -92,6 +93,7 @@ public: void setWaterFogColor(LLColor3 val) { mWaterFogColor = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -105,6 +107,7 @@ public: void setWaterFogDensity(F32 val) { mWaterFogDensity = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -116,6 +119,7 @@ public: void setFogMod(F32 val) { mFogMod = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -127,6 +131,7 @@ public: void setFresnelOffset(F32 val) { mFresnelOffset = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -138,6 +143,7 @@ public: void setFresnelScale(F32 val) { mFresnelScale = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -149,6 +155,7 @@ public: void setTransparentTextureID(LLUUID val) { mTransparentTextureID = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -160,6 +167,7 @@ public: void setNormalMapID(LLUUID val) { mNormalMapID = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -171,6 +179,7 @@ public: void setNormalScale(LLVector3 val) { mNormalScale = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -182,6 +191,7 @@ public: void setScaleAbove(F32 val) { mScaleAbove = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -193,6 +203,7 @@ public: void setScaleBelow(F32 val) { mScaleBelow = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -204,6 +215,7 @@ public: void setWave1Dir(LLVector2 val) { mWave1Dir = val; + setDirtyFlag(true); setLLSDDirty(); } @@ -215,6 +227,7 @@ public: void setWave2Dir(LLVector2 val) { mWave2Dir = val; + setDirtyFlag(true); setLLSDDirty(); } -- cgit v1.3 From dfff269d83df60de49fe8e5d7fffe9d1913e8036 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 11 Sep 2024 20:05:26 +0300 Subject: viewer#2529 Optimize LLSettingsSky::blend --- indra/llinventory/llsettingsbase.h | 1 + indra/llinventory/llsettingssky.cpp | 246 ++++++++++++++++++++++++++++-------- indra/llinventory/llsettingssky.h | 10 +- 3 files changed, 202 insertions(+), 55 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index dc2a745fa0..7b59437d6e 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -109,6 +109,7 @@ 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(); // Hash will not include Name, ID or a previously stored Hash diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 548c1b30e1..e574241e9c 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -411,7 +411,7 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) : } LLSettingsSky::LLSettingsSky(): - LLSettingsBase(), + LLSettingsBase(LLSettingsSky::defaults()), mNextSunTextureId(), mNextMoonTextureId(), mNextCloudTextureId(), @@ -445,6 +445,70 @@ void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) mNextHaloTextureId = pother->mNextHaloTextureId; } +void lerp_vector2(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); +} + +void lerp_color(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); +} + +bool lerp_legacy_color(LLColor3& a, bool& a_has_legacy, const LLColor3& b, bool b_has_legacy, const LLColor3& def, F32 mix) +{ + if (b_has_legacy) + { + if (a_has_legacy) + { + lerp_color(a, b, mix); + } + else + { + a = def; + lerp_color(a, b, mix); + a_has_legacy = true; + } + } + else if (a_has_legacy) + { + lerp_color(a, def, mix); + } + else + { + lerp_color(a, b, mix); + } + return a_has_legacy; +} + +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 (a_has_legacy) + { + a = lerp(a, b, mix); + } + else + { + 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; @@ -453,59 +517,148 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast(end); if (other) { - LLSD& settings = getSettings(); - LLSD& other_settings = other->getSettings(); - if (other_settings.has(SETTING_LEGACY_HAZE)) + if (other->mHasLegacyHaze) { - if (!settings.has(SETTING_LEGACY_HAZE) || !settings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) + if (!mHasLegacyHaze || !mLegacyAmbientColor) { - // Special case since SETTING_AMBIENT is both in outer and legacy maps, we prioritize legacy one - // see getColor(), we are about to replaceSettings(), so we are free to set it - LLColor3 ambient = getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); - settings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = ambient.getValue(); + // 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 (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) + if (mLegacyAmbientColor) { // 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 - LLColor3 ambient = getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); - settings[SETTING_AMBIENT] = ambient.getValue(); - settings[SETTING_LEGACY_HAZE].erase(SETTING_AMBIENT); + mLegacyAmbientColor = false; } } 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)settings[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_settings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); + mCloudShadow = lerp(0.f, mCloudShadow, (F32)blendf); setCloudNoiseTextureId(cloud_noise_id_next); } else { - cloud_shadow = lerp((F32)settings[SETTING_CLOUD_SHADOW].asReal(), (F32)other_settings[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); + lerp_color(mSunlightColor, other->mSunlightColor, (F32)blendf); + lerp_color(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); + lerp_vector2(mScrollRate, other->mScrollRate, (F32)blendf); + lerp_color(mCloudPosDensity1, other->mCloudPosDensity1, (F32)blendf); + lerp_color(mCloudPosDensity2, other->mCloudPosDensity2, (F32)blendf); + lerp_color(mCloudColor, other->mCloudColor, (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); + + 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); + + 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); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + + /////// validation + /* LLSD blenddata = interpolateSDMap(settings, other_settings, other->getParameterMap(), blendf, skip, slerps); - blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(cloud_shadow); - replaceSettings(blenddata); + blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(mCloudShadow); + + LLSettingsSky::ptr_t sky_p = buildClone(); + sky_p->replaceSettings(blenddata); + sky_p->loadValuesFromLLSD(); + llassert(sky_p->getSettingsType() == getSettingsType()); + llassert(sky_p->getSunRotation() == getSunRotation()); + llassert(sky_p->getMoonRotation() == getMoonRotation()); + llassert(sky_p->getSunTextureId() == getSunTextureId()); + llassert(sky_p->getMoonTextureId() == getMoonTextureId()); + llassert(sky_p->getCloudNoiseTextureId() == getCloudNoiseTextureId()); + llassert(sky_p->getBloomTextureId() == getBloomTextureId()); + llassert(sky_p->getRainbowTextureId() == getRainbowTextureId()); + llassert(sky_p->getHaloTextureId() == getHaloTextureId()); + llassert(sky_p->getCloudColor() == getCloudColor()); + llassert(sky_p->getCloudPosDensity1() == getCloudPosDensity1()); + llassert(sky_p->getCloudPosDensity2() == getCloudPosDensity2()); + llassert(sky_p->getCloudScale() == getCloudScale()); + llassert(sky_p->getCloudScrollRate() == getCloudScrollRate()); + llassert(sky_p->getCloudShadow() == getCloudShadow()); + llassert(sky_p->getCloudVariance() == getCloudVariance()); + llassert(sky_p->getDomeOffset() == getDomeOffset()); + llassert(sky_p->getDomeRadius() == getDomeRadius()); + llassert(sky_p->getGamma() == getGamma()); + llassert(sky_p->getStarBrightness() == getStarBrightness()); + llassert(sky_p->getSunlightColor() == getSunlightColor()); + llassert(sky_p->getSunScale() == getSunScale()); + llassert(sky_p->getSunArcRadians() == getSunArcRadians()); + llassert(sky_p->getSunlightColor() == getSunlightColor()); + llassert(sky_p->getGlow() == getGlow()); + llassert(sky_p->getReflectionProbeAmbiance() == getReflectionProbeAmbiance()); + llassert(sky_p->getStarBrightness() == getStarBrightness()); + llassert(sky_p->getMoonBrightness() == getMoonBrightness()); + llassert(sky_p->getMoonScale() == getMoonScale()); + llassert(sky_p->getMaxY() == getMaxY()); + llassert(sky_p->getSkyTopRadius() == getSkyTopRadius()); + llassert(sky_p->getSkyBottomRadius() == getSkyBottomRadius()); + llassert(sky_p->getSkyMoistureLevel() == getSkyMoistureLevel()); + llassert(sky_p->getSkyDropletRadius() == getSkyDropletRadius()); + llassert(sky_p->getSkyIceLevel() == getSkyIceLevel()); + llassert(sky_p->getPlanetRadius() == getPlanetRadius()); + llassert(sky_p->getHazeHorizon() == getHazeHorizon()); + llassert(sky_p->getHazeDensity() == getHazeDensity()); + llassert(sky_p->getDistanceMultiplier() == getDistanceMultiplier()); + llassert(sky_p->getDensityMultiplier() == getDensityMultiplier()); + llassert(sky_p->getBlueHorizon() == getBlueHorizon()); + llassert(sky_p->getBlueDensity() == getBlueDensity());*/ + mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); mNextCloudTextureId = cloud_noise_id_next; @@ -1067,6 +1220,19 @@ void LLSettingsSky::loadValuesFromLLSD() || 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; @@ -1117,35 +1283,15 @@ void LLSettingsSky::saveValuesToLLSD() settings[SETTING_SKY_DROPLET_RADIUS] = mSkyDropletRadius; settings[SETTING_SKY_ICE_LEVEL] = mSkyIceLevel; settings[SETTING_PLANET_RADIUS] = mPlanetRadius; + LLSD& legacy = settings[SETTING_LEGACY_HAZE]; - if (mLegacyDistanceMultiplier) - { - legacy[SETTING_DISTANCE_MULTIPLIER] = mDistanceMultiplier; - } - if (mLegacyDensityMultiplier) - { - legacy[SETTING_DENSITY_MULTIPLIER] = mDensityMultiplier; - } - if (mLegacyHazeHorizon) - { - legacy[SETTING_HAZE_HORIZON] = mHazeHorizon; - } - if (mLegacyHazeDensity) - { - legacy[SETTING_HAZE_DENSITY] = mHazeDensity; - } - if (mLegacyBlueHorizon) - { - legacy[SETTING_BLUE_HORIZON] = mBlueHorizon.getValue(); - } - if (mLegacyBlueDensity) - { - legacy[SETTING_BLUE_DENSITY] = mBlueDensity.getValue(); - } - if (mLegacyAmbientColor) - { - legacy[SETTING_AMBIENT] = mAmbientColor.getValue(); - } + 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 diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 535c4722ef..b2b042e53f 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -365,21 +365,21 @@ protected: LLUUID mNextHaloTextureId; bool mCanAutoAdjust; - F32 mReflectionProbeAmbiance; - F32 mSunScale; LLQuaternion mSunRotation; + LLQuaternion mMoonRotation; LLColor3 mSunlightColor; + LLColor3 mGlow; + F32 mReflectionProbeAmbiance; + F32 mSunScale; F32 mStarBrightness; F32 mMoonBrightness; F32 mMoonScale; - LLQuaternion mMoonRotation; F32 mMaxY; - LLColor3 mGlow; F32 mGamma; F32 mCloudVariance; F32 mCloudShadow; - LLVector2 mScrollRate; F32 mCloudScale; + LLVector2 mScrollRate; LLColor3 mCloudPosDensity1; LLColor3 mCloudPosDensity2; LLColor3 mCloudColor; -- cgit v1.3 From e71215dcfdb960f64a7f10d2fba71790f8e7bcd1 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 12 Sep 2024 14:32:43 +0300 Subject: viewer#2529 Optimize LLSettingsWater::blend --- indra/llinventory/llsettingsbase.cpp | 24 +++- indra/llinventory/llsettingsbase.h | 20 +++- indra/llinventory/llsettingssky.cpp | 215 ++++++++++++++++++---------------- indra/llinventory/llsettingssky.h | 3 +- indra/llinventory/llsettingswater.cpp | 57 +++++++-- indra/llinventory/llsettingswater.h | 3 +- indra/newview/llsettingsvo.cpp | 1 - 7 files changed, 207 insertions(+), 116 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index f7151403b4..0ee71de3a1 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -141,6 +141,26 @@ void LLSettingsBase::lerpSettings(LLSettingsBase &other, F64 mix) 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); +} + +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; @@ -759,7 +779,7 @@ F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_ if (mTarget) { - mTarget->replaceSettings(mInitial->getSettings()); + mTarget->replaceSettings(mInitial); mTarget->blend(mFinal, blendf); } else @@ -774,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 7b59437d6e..816ff3e111 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -173,6 +173,18 @@ public: 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); @@ -327,6 +339,10 @@ public: 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(); @@ -370,9 +386,9 @@ protected: mBlendedFactor = blendfactor; } - virtual void replaceWith(LLSettingsBase::ptr_t other) + virtual void replaceWith(const LLSettingsBase::ptr_t other) { - replaceSettings(other->cloneSettings()); + replaceSettings(other); setBlendFactor(other->getBlendFactor()); } diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index e574241e9c..3685915ffd 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -433,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(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); @@ -445,41 +518,28 @@ void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) mNextHaloTextureId = pother->mNextHaloTextureId; } -void lerp_vector2(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); -} - -void lerp_color(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); -} - bool lerp_legacy_color(LLColor3& a, bool& a_has_legacy, const LLColor3& b, bool b_has_legacy, const LLColor3& def, F32 mix) { if (b_has_legacy) { if (a_has_legacy) { - lerp_color(a, b, mix); + LLSettingsBase::lerpColor(a, b, mix); } else { a = def; - lerp_color(a, b, mix); + LLSettingsBase::lerpColor(a, b, mix); a_has_legacy = true; } } else if (a_has_legacy) { - lerp_color(a, def, mix); + LLSettingsBase::lerpColor(a, def, mix); } else { - lerp_color(a, b, mix); + LLSettingsBase::lerpColor(a, b, mix); } return a_has_legacy; } @@ -517,26 +577,6 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast(end); if (other) { - 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; - } - } - LLUUID cloud_noise_id = getCloudNoiseTextureId(); LLUUID cloud_noise_id_next = other->getCloudNoiseTextureId(); if (!cloud_noise_id.isNull() && cloud_noise_id_next.isNull()) @@ -565,8 +605,8 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) mSunRotation = slerp((F32)blendf, mSunRotation, other->mSunRotation); mMoonRotation = slerp((F32)blendf, mMoonRotation, other->mMoonRotation); - lerp_color(mSunlightColor, other->mSunlightColor, (F32)blendf); - lerp_color(mGlow, other->mGlow, (F32)blendf); + 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); @@ -577,17 +617,10 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) mCloudVariance = lerp(mCloudVariance, other->mCloudVariance, (F32)blendf); mCloudShadow = lerp(mCloudShadow, other->mCloudShadow, (F32)blendf); mCloudScale = lerp(mCloudScale, other->mCloudScale, (F32)blendf); - lerp_vector2(mScrollRate, other->mScrollRate, (F32)blendf); - lerp_color(mCloudPosDensity1, other->mCloudPosDensity1, (F32)blendf); - lerp_color(mCloudPosDensity2, other->mCloudPosDensity2, (F32)blendf); - lerp_color(mCloudColor, other->mCloudColor, (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); + 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); @@ -597,6 +630,28 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 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; + } + } + 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); @@ -604,61 +659,17 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 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(); - /////// validation - /* - LLSD blenddata = interpolateSDMap(settings, other_settings, other->getParameterMap(), blendf, skip, slerps); - blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(mCloudShadow); - - LLSettingsSky::ptr_t sky_p = buildClone(); - sky_p->replaceSettings(blenddata); - sky_p->loadValuesFromLLSD(); - llassert(sky_p->getSettingsType() == getSettingsType()); - llassert(sky_p->getSunRotation() == getSunRotation()); - llassert(sky_p->getMoonRotation() == getMoonRotation()); - llassert(sky_p->getSunTextureId() == getSunTextureId()); - llassert(sky_p->getMoonTextureId() == getMoonTextureId()); - llassert(sky_p->getCloudNoiseTextureId() == getCloudNoiseTextureId()); - llassert(sky_p->getBloomTextureId() == getBloomTextureId()); - llassert(sky_p->getRainbowTextureId() == getRainbowTextureId()); - llassert(sky_p->getHaloTextureId() == getHaloTextureId()); - llassert(sky_p->getCloudColor() == getCloudColor()); - llassert(sky_p->getCloudPosDensity1() == getCloudPosDensity1()); - llassert(sky_p->getCloudPosDensity2() == getCloudPosDensity2()); - llassert(sky_p->getCloudScale() == getCloudScale()); - llassert(sky_p->getCloudScrollRate() == getCloudScrollRate()); - llassert(sky_p->getCloudShadow() == getCloudShadow()); - llassert(sky_p->getCloudVariance() == getCloudVariance()); - llassert(sky_p->getDomeOffset() == getDomeOffset()); - llassert(sky_p->getDomeRadius() == getDomeRadius()); - llassert(sky_p->getGamma() == getGamma()); - llassert(sky_p->getStarBrightness() == getStarBrightness()); - llassert(sky_p->getSunlightColor() == getSunlightColor()); - llassert(sky_p->getSunScale() == getSunScale()); - llassert(sky_p->getSunArcRadians() == getSunArcRadians()); - llassert(sky_p->getSunlightColor() == getSunlightColor()); - llassert(sky_p->getGlow() == getGlow()); - llassert(sky_p->getReflectionProbeAmbiance() == getReflectionProbeAmbiance()); - llassert(sky_p->getStarBrightness() == getStarBrightness()); - llassert(sky_p->getMoonBrightness() == getMoonBrightness()); - llassert(sky_p->getMoonScale() == getMoonScale()); - llassert(sky_p->getMaxY() == getMaxY()); - llassert(sky_p->getSkyTopRadius() == getSkyTopRadius()); - llassert(sky_p->getSkyBottomRadius() == getSkyBottomRadius()); - llassert(sky_p->getSkyMoistureLevel() == getSkyMoistureLevel()); - llassert(sky_p->getSkyDropletRadius() == getSkyDropletRadius()); - llassert(sky_p->getSkyIceLevel() == getSkyIceLevel()); - llassert(sky_p->getPlanetRadius() == getPlanetRadius()); - llassert(sky_p->getHazeHorizon() == getHazeHorizon()); - llassert(sky_p->getHazeDensity() == getHazeDensity()); - llassert(sky_p->getDistanceMultiplier() == getDistanceMultiplier()); - llassert(sky_p->getDensityMultiplier() == getDensityMultiplier()); - llassert(sky_p->getBlueHorizon() == getBlueHorizon()); - llassert(sky_p->getBlueDensity() == getBlueDensity());*/ - mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); mNextCloudTextureId = cloud_noise_id_next; diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index b2b042e53f..38c0368423 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -121,8 +121,9 @@ public: 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; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index cad0b41d67..08e18ea26e 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -68,14 +68,16 @@ 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()); } @@ -235,10 +237,24 @@ void LLSettingsWater::blend(LLSettingsBase::ptr_t &end, F64 blendf) LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast(end); if (other) { - stringset_t skip = getSkipInterpolateKeys(); - stringset_t slerps = getSlerpKeys(); - LLSD blenddata = interpolateSDMap(getSettings(), other->getSettings(), other->getParameterMap(), blendf, skip, slerps); - 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(); } @@ -256,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(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 9d229e6a0b..82fc37cfb3 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -65,7 +65,8 @@ public: 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); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index be891213a7..79691a5ce8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -724,7 +724,6 @@ inline void draw_real(LLShaderUniforms* shader, F32 value, S32 shader_key) void LLSettingsVOSky::applyToUniforms(void* ptarget) { LLShaderUniforms* shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_ANY]; - LLSD &settings = getSettings(); draw_color(shader, getAmbientColor(), LLShaderMgr::AMBIENT); draw_color(shader, getBlueDensity(), LLShaderMgr::BLUE_DENSITY); -- cgit v1.3 From 22675c9a054691775645134c6a326a4f93f22d35 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 23 Sep 2024 20:03:58 +0300 Subject: viewer#2627 instead of checking map for being empty got empty map --- indra/llinventory/llsettingsdaycycle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 2b189e7cca..a45ab5a09c 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -143,7 +143,7 @@ LLSettingsDay::LLSettingsDay() : //========================================================================= LLSD& LLSettingsDay::getSettings() { - if (!mDaySettings.emptyMap()) + if (mDaySettings.size() > 0) { return mDaySettings; } -- cgit v1.3