diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-09-04 13:51:31 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-09-04 13:51:31 +0300 |
commit | e5bcd6f50a8247dde1121210150835d968dc214d (patch) | |
tree | 27f2d17c397bbebc1a1071248b63dc6d33a43cb7 /indra/newview/llenvironment.cpp | |
parent | e25d23aaac77f3793207aa0baf59ae64ea5eba41 (diff) | |
parent | 2fc8d5ff3cfa1b9ad00b310cd4a6cdb557b9415c (diff) |
Merge branch 'develop' into marchcat/b-develop
# Conflicts:
# indra/llcommon/llerror.h
Diffstat (limited to 'indra/newview/llenvironment.cpp')
-rw-r--r-- | indra/newview/llenvironment.cpp | 149 |
1 files changed, 81 insertions, 68 deletions
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<DayInjection>(env); + } else + { environment = std::make_shared<DayInstance>(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<UpdateInfo>(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<LLSettingsDay>(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<UpdateInfo>(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); } - } |