From d7dd10b88bc3fda88f6528ecc5936e4889f019f3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Nov 2017 11:32:22 -0800 Subject: Split for viewer/simhost sync LLSD with simhost. --- indra/newview/llsettingsvo.cpp | 420 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 420 insertions(+) create mode 100644 indra/newview/llsettingsvo.cpp (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp new file mode 100644 index 0000000000..76a6754573 --- /dev/null +++ b/indra/newview/llsettingsvo.cpp @@ -0,0 +1,420 @@ +/** +* @file llsettingsvo.cpp +* @author Rider Linden +* @brief Subclasses for viewer specific settings behaviors. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llviewercontrol.h" +#include "llsettingsvo.h" + +#include "pipeline.h" + +#include +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +#include "llglslshader.h" +#include "llviewershadermgr.h" + +#include "llenvironment.h" +#include "llsky.h" + +//========================================================================= +LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): + LLSettingsSky(data) +{ +} + +LLSettingsVOSky::LLSettingsVOSky(): + LLSettingsSky() +{ +} + +//------------------------------------------------------------------------- +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +{ + + LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); + + newsettings[SETTING_NAME] = name; + + LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() +{ + LLSD settings = LLSettingsSky::defaults(); + settings[SETTING_NAME] = std::string("_default_"); + + + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +//------------------------------------------------------------------------- +void LLSettingsVOSky::updateSettings() +{ + LLSettingsSky::updateSettings(); + + LLVector3 sun_direction = getSunDirection(); + LLVector3 moon_direction = getMoonDirection(); + + // set direction (in CRF) and don't allow overriding + LLVector3 crf_sunDirection(sun_direction.mV[2], sun_direction.mV[0], sun_direction.mV[1]); + LLVector3 crf_moonDirection(moon_direction.mV[2], moon_direction.mV[0], moon_direction.mV[1]); + + gSky.setSunDirection(crf_sunDirection, crf_moonDirection); +} + +void LLSettingsVOSky::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); + + shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); + + { + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + } +} + +LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { + param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; + param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; + param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; + param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; + + param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; + param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; + param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; + param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; + param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; + param_map[SETTING_GLOW] = LLShaderMgr::GLOW; + param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; + param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; + param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; + param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; + } + + return param_map; +} + +//========================================================================= +const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f); + +//------------------------------------------------------------------------- +LLSettingsVOWater::LLSettingsVOWater(const LLSD &data) : + LLSettingsWater(data) +{ + +} + +LLSettingsVOWater::LLSettingsVOWater() : + LLSettingsWater() +{ + +} + +//------------------------------------------------------------------------- +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +{ + LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy)); + + newsettings[SETTING_NAME] = name; + + LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() +{ + LLSD settings = LLSettingsWater::defaults(); + settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +//------------------------------------------------------------------------- +void LLSettingsVOWater::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); + shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); +} + +void LLSettingsVOWater::updateSettings() +{ + // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); + // LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; + + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + // only do this if we're dealing with shaders + if (gPipeline.canUseVertexShaders()) + { + //transform water plane to eye space + glh::vec3f norm(0.f, 0.f, 1.f); + glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); + + F32 modelView[16]; + for (U32 i = 0; i < 16; i++) + { + modelView[i] = (F32)gGLModelView[i]; + } + + glh::matrix4f mat(modelView); + glh::matrix4f invtrans = mat.inverse().transpose(); + glh::vec3f enorm; + glh::vec3f ep; + invtrans.mult_matrix_vec(norm, enorm); + enorm.normalize(); + mat.mult_matrix_vec(p, ep); + + mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + + LLVector4 light_direction = LLEnvironment::instance().getLightDirection(); + + mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); + } +} + +LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { + param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; + param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; + } + return param_map; +} + +//========================================================================= +LLSettingsVODay::LLSettingsVODay(const LLSD &data): + LLSettingsDay(data) +{} + +LLSettingsVODay::LLSettingsVODay(): + LLSettingsDay() +{} + +//------------------------------------------------------------------------- +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +{ + LLSD newsettings(defaults()); + + newsettings[SETTING_NAME] = name; + newsettings[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); + + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, "Default")); + + LLSD skytrack = LLSD::emptyArray(); + + for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) + { + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, (*it)[1].asString()); + skytrack.append(entry); + } + + newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); + + LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); + + if (dayp->validate()) + { + dayp->initialize(); + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) +{ + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset("Region", waterdef); + LLEnvironment::namedSettingMap_t skys; + + for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) + { + std::string name = (*itm).first; + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, (*itm).second); + + skys[name] = sky; + LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; + } + + LLSettingsDay::ptr_t dayp = buildFromLegacyPreset("Region (legacy)", daycycle); + + dayp->setWaterAtKeyframe(water, 0.0f); + + for (LLSD::array_iterator ita = daycycle.beginArray(); ita != daycycle.endArray(); ++ita) + { + F32 frame = (*ita)[0].asReal(); + std::string name = (*ita)[1].asString(); + + LLEnvironment::namedSettingMap_t::iterator it = skys.find(name); + + if (it == skys.end()) + continue; + dayp->setSkyAtKeyframe(boost::static_pointer_cast((*it).second), frame, 1); + + LL_WARNS("WindlightCaps") << "Added '" << name << "' to region day cycle at " << frame << LL_ENDL; + } + + dayp->setInitialized(); + + if (dayp->validate()) + { + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() +{ + LLSD settings = LLSettingsDay::defaults(); + settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + if (dayp->validate()) + { + dayp->initialize(); + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + return dayp; +} + +LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const +{ + return LLSettingsVOSky::buildDefaultSky(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::getDefaultWater() const +{ + return LLSettingsVOWater::buildDefaultWater(); +} + +LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const +{ + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const +{ + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +LLSettingsSkyPtr_t LLSettingsVODay::getNamedSky(const std::string &name) const +{ + return LLEnvironment::instance().findSkyByName(name); +} + +LLSettingsWaterPtr_t LLSettingsVODay::getNamedWater(const std::string &name) const +{ + return LLEnvironment::instance().findWaterByName(name); +} -- cgit v1.2.3 From 8211f57205f0008d8ffb9bfcd465ca26d906e19c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 8 Jan 2018 15:10:25 -0800 Subject: MAINT-7699: Deliver new settings to viewer via cap --- indra/newview/llsettingsvo.cpp | 185 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 76a6754573..cd32aa07a8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -43,6 +43,30 @@ #include "llenvironment.h" #include "llsky.h" +#undef VERIFY_LEGACY_CONVERSION + +//========================================================================= +namespace +{ +LLSD ensureArray4(LLSD in, F32 fill) +{ + if (in.size() >= 4) + return in; + + LLSD out(LLSD::emptyArray()); + + for (S32 idx = 0; idx < in.size(); ++idx) + { + out.append(in[idx]); + } + + while (out.size() < 4) + { + out.append(LLSD::Real(fill)); + } + return out; +} +} //========================================================================= LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): LLSettingsSky(data) @@ -64,6 +88,18 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp); + + if (!llsd_equals(legacy, oldsettings)) + { + LL_WARNS("SKY") << "Conversion to/from legacy does not match!\n" + << "Old: " << legacy + << "new: " << oldsettings << LL_ENDL; + } + +#endif + if (skyp->validate()) return skyp; @@ -95,6 +131,43 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() return LLSettingsSky::ptr_t(); } +LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = psky->getSettings(); + + legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); + legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); + + legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; + legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) + (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); + + legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); + legacy[SETTING_GLOW] = ensureArray4(settings[SETTING_GLOW], 1.0); + legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + legacy[SETTING_LIGHT_NORMAL] = ensureArray4(psky->getLightDirection().getValue(), 0.0f); + legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); + legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; + legacy[SETTING_SUNLIGHT_COLOR] = ensureArray4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); + + LLSettingsSky::azimalt_t azialt = psky->getSunRotationAzAl(); + + legacy[SETTING_LEGACY_EAST_ANGLE] = azialt.first; + legacy[SETTING_LEGACY_SUN_ANGLE] = azialt.second; + + return legacy; +} + //------------------------------------------------------------------------- void LLSettingsVOSky::updateSettings() { @@ -176,6 +249,19 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); + + if (!llsd_equals(legacy, oldsettings)) + { + LL_WARNS("WATER") << "Conversion to/from legacy does not match!\n" + << "Old: " << legacy + << "new: " << oldsettings << LL_ENDL; + } + +#endif + + if (waterp->validate()) return waterp; @@ -207,6 +293,28 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() return LLSettingsWater::ptr_t(); } +LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = pwater->getSettings(); + + legacy[SETTING_LEGACY_BLUR_MULTIPILER] = settings[SETTING_BLUR_MULTIPILER]; + legacy[SETTING_LEGACY_FOG_COLOR] = ensureArray4(settings[SETTING_FOG_COLOR], 1.0f); + legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; + legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; + legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; + legacy[SETTING_LEGACY_FRESNEL_SCALE] = settings[SETTING_FRESNEL_SCALE]; + legacy[SETTING_LEGACY_NORMAL_MAP] = settings[SETTING_NORMAL_MAP]; + legacy[SETTING_LEGACY_NORMAL_SCALE] = settings[SETTING_NORMAL_SCALE]; + legacy[SETTING_LEGACY_SCALE_ABOVE] = settings[SETTING_SCALE_ABOVE]; + legacy[SETTING_LEGACY_SCALE_BELOW] = settings[SETTING_SCALE_BELOW]; + legacy[SETTING_LEGACY_WAVE1_DIR] = settings[SETTING_WAVE1_DIR]; + legacy[SETTING_LEGACY_WAVE2_DIR] = settings[SETTING_WAVE2_DIR]; + + //_WARNS("LAPRAS") << "Legacy water: " << legacy << LL_ENDL; + return legacy; +} +//------------------------------------------------------------------------- //------------------------------------------------------------------------- void LLSettingsVOWater::applySpecial(void *ptarget) { @@ -303,12 +411,26 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); +#ifdef VERIFY_LEGACY_CONVERSION + LLSD testsettings = LLSettingsVODay::convertToLegacy(dayp); + + if (!llsd_equals(oldsettings, testsettings)) + { + LL_WARNS("DAYCYCLE") << "Conversion to/from legacy does not match!\n" + << "Old: " << oldsettings + << "new: " << testsettings << LL_ENDL; + } + +#endif + if (dayp->validate()) { dayp->initialize(); return dayp; } + + return LLSettingsDay::ptr_t(); } @@ -370,6 +492,20 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() return LLSettingsDay::ptr_t(); } +LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) +{ + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + if (dayp->validate()) + { + dayp->initialize(); + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + + LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); @@ -379,6 +515,55 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() return dayp; } +LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) +{ + CycleTrack_t &trackwater = pday->getCycleTrack(TRACK_WATER); + + LLSettingsWater::ptr_t pwater; + if (!trackwater.empty()) + { + pwater = boost::static_pointer_cast((*trackwater.begin()).second); + } + + if (!pwater) + pwater = LLSettingsVOWater::buildDefaultWater(); + + LLSD llsdwater = LLSettingsVOWater::convertToLegacy(pwater); + + CycleTrack_t &tracksky = pday->getCycleTrack(1); // first sky track + std::map skys; + + LLSD llsdcycle(LLSD::emptyArray()); + + for(CycleTrack_t::iterator it = tracksky.begin(); it != tracksky.end(); ++it) + { + size_t hash = (*it).second->getHash(); + std::stringstream name; + + name << hash; + + skys[name.str()] = boost::static_pointer_cast((*it).second); + + F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; + llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); + } + //_WARNS("LAPRAS") << "Cycle created with " << llsdcycle.size() << "entries: " << llsdcycle << LL_ENDL; + + LLSD llsdskylist(LLSD::emptyMap()); + + for (std::map::iterator its = skys.begin(); its != skys.end(); ++its) + { + LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second); + llsdsky[SETTING_NAME] = (*its).first; + + llsdskylist[(*its).first] = llsdsky; + } + + //_WARNS("LAPRAS") << "Sky map with " << llsdskylist.size() << " entries created: " << llsdskylist << LL_ENDL; + + return LLSDArray(LLSD::emptyMap())(llsdcycle)(llsdskylist)(llsdwater); +} + LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const { return LLSettingsVOSky::buildDefaultSky(); -- cgit v1.2.3 From 1b8c2b5ebbe0d42f147730bc9b6528fa8c6796ce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 23 Jan 2018 08:54:34 -0800 Subject: MAINT-8052: Initial support for new EEP cap --- indra/newview/llsettingsvo.cpp | 156 +++++++++++++++++++++++++++-------------- 1 file changed, 103 insertions(+), 53 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index cd32aa07a8..7756d28879 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -86,6 +86,14 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n newsettings[SETTING_NAME] = name; + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsSky::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION @@ -100,10 +108,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n #endif - if (skyp->validate()) - return skyp; - - return LLSettingsSky::ptr_t(); + return skyp; } LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() @@ -111,24 +116,32 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() LLSD settings = LLSettingsSky::defaults(); settings[SETTING_NAME] = std::string("_default_"); + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsSky::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } LLSettingsSky::ptr_t skyp = boost::make_shared(settings); - if (skyp->validate()) - return skyp; - - return LLSettingsSky::ptr_t(); + return skyp; } LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() { LLSD settings = cloneSettings(); - LLSettingsSky::ptr_t skyp = boost::make_shared(settings); - - if (skyp->validate()) - return skyp; + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsSky::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } - return LLSettingsSky::ptr_t(); + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + return skyp; } LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) @@ -246,6 +259,13 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy)); newsettings[SETTING_NAME] = name; + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsWater::ptr_t(); + } LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); @@ -260,12 +280,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin } #endif - - - if (waterp->validate()) - return waterp; - - return LLSettingsWater::ptr_t(); + return waterp; } LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() @@ -273,24 +288,33 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() LLSD settings = LLSettingsWater::defaults(); settings[SETTING_NAME] = std::string("_default_"); - LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsWater::ptr_t(); + } - if (waterp->validate()) - return waterp; + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); - return LLSettingsWater::ptr_t(); + return waterp; } LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() { LLSD settings = cloneSettings(); + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsWater::ptr_t(); + } LLSettingsWater::ptr_t waterp = boost::make_shared(settings); - if (waterp->validate()) - return waterp; - - return LLSettingsWater::ptr_t(); + return waterp; } LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) @@ -409,6 +433,15 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION @@ -423,20 +456,21 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n #endif - if (dayp->validate()) - { - dayp->initialize(); - return dayp; - } + dayp->initialize(); - - - return LLSettingsDay::ptr_t(); + return dayp; } LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) { LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset("Region", waterdef); + + if (!water) + { + LL_WARNS("WindlightCaps") << "Water construction failed." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + LLEnvironment::namedSettingMap_t skys; for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) @@ -444,6 +478,12 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io std::string name = (*itm).first; LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, (*itm).second); + if (!sky) + { + LL_WARNS("WindlightCaps") << "Sky construction failed." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + skys[name] = sky; LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; } @@ -468,12 +508,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io dayp->setInitialized(); - if (dayp->validate()) - { - return dayp; - } - - return LLSettingsDay::ptr_t(); + return dayp; } LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() @@ -481,28 +516,34 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() LLSD settings = LLSettingsDay::defaults(); settings[SETTING_NAME] = std::string("_default_"); - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); - - if (dayp->validate()) + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) { - dayp->initialize(); - return dayp; + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); } - return LLSettingsDay::ptr_t(); + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + dayp->initialize(); + return dayp; } LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) { - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); - - if (dayp->validate()) + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) { - dayp->initialize(); - return dayp; + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); } - return LLSettingsDay::ptr_t(); + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + dayp->initialize(); + return dayp; } @@ -510,6 +551,15 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); return dayp; -- cgit v1.2.3 From 536aeb54a6130f3d1e20405c8f6cbd29201de26d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 23 Jan 2018 17:34:25 -0800 Subject: MAINT-8052: One more step towards parcel environments. --- indra/newview/llsettingsvo.cpp | 109 ++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 44 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 7756d28879..80cb8c8357 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -263,8 +263,8 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin LLSD results = LLSettingsWater::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { - LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; - LLSettingsWater::ptr_t(); + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); } LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); @@ -292,8 +292,8 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() LLSD results = LLSettingsWater::settingValidation(settings, validations); if (!results["success"].asBoolean()) { - LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; - LLSettingsWater::ptr_t(); + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); } LLSettingsWater::ptr_t waterp = boost::make_shared(settings); @@ -308,8 +308,8 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() LLSD results = LLSettingsWater::settingValidation(settings, validations); if (!results["success"].asBoolean()) { - LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; - LLSettingsWater::ptr_t(); + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); } LLSettingsWater::ptr_t waterp = boost::make_shared(settings); @@ -414,31 +414,48 @@ LLSettingsVODay::LLSettingsVODay(): LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) { LLSD newsettings(defaults()); + std::set framenames; newsettings[SETTING_NAME] = name; - newsettings[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); LLSD watertrack = LLSDArray( LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) - (SETTING_KEYNAME, "Default")); + (SETTING_KEYNAME, "water:Default")); LLSD skytrack = LLSD::emptyArray(); for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) { + std::string framename = (*it)[1].asString(); LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) - (SETTING_KEYNAME, (*it)[1].asString()); + (SETTING_KEYNAME, "sky:" + framename); + framenames.insert(framename); skytrack.append(entry); } newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); + LLSD frames(LLSD::emptyMap()); + + { + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName("Default"); + frames["water:Default"] = pwater->getSettings(); + } + + for (std::set::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) + { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(*itn); + frames["sky:" + (*itn)] = psky->getSettings(); + } + + newsettings[SETTING_FRAMES] = frames; + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); + LL_WARNS("SETTINGS") << "Day setting validation failed!: " << results << LL_ENDL; + return LLSettingsDay::ptr_t(); } @@ -463,51 +480,55 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) { - LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset("Region", waterdef); - - if (!water) - { - LL_WARNS("WindlightCaps") << "Water construction failed." << LL_ENDL; - return LLSettingsDay::ptr_t(); - } - - LLEnvironment::namedSettingMap_t skys; + LLSD frames(LLSD::emptyMap()); for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) { - std::string name = (*itm).first; - LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, (*itm).second); + LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second); + std::string newname = "sky:" + (*itm).first; - if (!sky) - { - LL_WARNS("WindlightCaps") << "Sky construction failed." << LL_ENDL; - return LLSettingsDay::ptr_t(); - } + newsettings[SETTING_NAME] = newname; + frames[newname] = newsettings; - skys[name] = sky; - LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; + LL_WARNS("SETTINGS") << "created region sky '" << newname << "'" << LL_ENDL; } - LLSettingsDay::ptr_t dayp = buildFromLegacyPreset("Region (legacy)", daycycle); + LLSD watersettings = LLSettingsWater::translateLegacySettings(waterdef); + std::string watername = "water:"+ watersettings[SETTING_NAME].asString(); + watersettings[SETTING_NAME] = watername; + frames[watername] = watersettings; - dayp->setWaterAtKeyframe(water, 0.0f); + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, watername)); - for (LLSD::array_iterator ita = daycycle.beginArray(); ita != daycycle.endArray(); ++ita) + LLSD skytrack(LLSD::emptyArray()); + for (LLSD::array_const_iterator it = daycycle.beginArray(); it != daycycle.endArray(); ++it) { - F32 frame = (*ita)[0].asReal(); - std::string name = (*ita)[1].asString(); - - LLEnvironment::namedSettingMap_t::iterator it = skys.find(name); + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, "sky:" + (*it)[1].asString()); + skytrack.append(entry); + } - if (it == skys.end()) - continue; - dayp->setSkyAtKeyframe(boost::static_pointer_cast((*it).second), frame, 1); + LLSD newsettings = LLSDMap + ( SETTING_NAME, "Region (legacy)" ) + ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) + ( SETTING_FRAMES, frames ); - LL_WARNS("WindlightCaps") << "Added '" << name << "' to region day cycle at " << frame << LL_ENDL; + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsDay::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!:" << results << LL_ENDL; + LLSettingsDay::ptr_t(); } - dayp->setInitialized(); - + LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); + + if (dayp) + { + dayp->setInitialized(); + } return dayp; } @@ -555,13 +576,13 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() LLSD results = LLSettingsDay::settingValidation(settings, validations); if (!results["success"].asBoolean()) { - LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; LLSettingsDay::ptr_t(); } - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + dayp->initialize(); return dayp; } -- cgit v1.2.3 From 2d41de9007ce485e2c7e96c487d609cfe1690c29 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 24 Jan 2018 13:36:59 -0800 Subject: MAINT-8052: Parcel environments. Set, clear and get. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 80cb8c8357..8ba6b2354a 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -520,7 +520,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io if (!results["success"].asBoolean()) { LL_WARNS("SETTINGS") << "Day setting validation failed!:" << results << LL_ENDL; - LLSettingsDay::ptr_t(); + return LLSettingsDay::ptr_t(); } LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); -- cgit v1.2.3 From fbd8a98300277bdbc1885c25eea290560fd8c6c1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 25 Jan 2018 17:21:25 -0800 Subject: Selects correct day cycle. Fix an error validating legacy daycycles. --- indra/newview/llsettingsvo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8ba6b2354a..eadc035b3b 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -515,7 +515,9 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) ( SETTING_FRAMES, frames ); - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LL_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; + + LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { @@ -527,7 +529,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io if (dayp) { - dayp->setInitialized(); + dayp->initialize(); } return dayp; } -- cgit v1.2.3 From 7838189843ff3b9c800e458b2452943edbc202ea Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 6 Feb 2018 17:27:56 -0800 Subject: boost->std & same level interp --- indra/newview/llsettingsvo.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index eadc035b3b..6b1c663357 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -94,7 +94,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n LLSettingsSky::ptr_t(); } - LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); + LLSettingsSky::ptr_t skyp = std::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp); @@ -124,7 +124,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() LLSettingsSky::ptr_t(); } - LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + LLSettingsSky::ptr_t skyp = std::make_shared(settings); return skyp; } @@ -140,7 +140,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() LLSettingsSky::ptr_t(); } - LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + LLSettingsSky::ptr_t skyp = std::make_shared(settings); return skyp; } @@ -267,7 +267,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin return LLSettingsWater::ptr_t(); } - LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); + LLSettingsWater::ptr_t waterp = std::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); @@ -296,7 +296,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() return LLSettingsWater::ptr_t(); } - LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + LLSettingsWater::ptr_t waterp = std::make_shared(settings); return waterp; } @@ -312,7 +312,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() return LLSettingsWater::ptr_t(); } - LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + LLSettingsWater::ptr_t waterp = std::make_shared(settings); return waterp; } @@ -459,7 +459,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n } - LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); + LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION LLSD testsettings = LLSettingsVODay::convertToLegacy(dayp); @@ -525,7 +525,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io return LLSettingsDay::ptr_t(); } - LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); + LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); if (dayp) { @@ -547,7 +547,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() LLSettingsDay::ptr_t(); } - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + LLSettingsDay::ptr_t dayp = std::make_shared(settings); dayp->initialize(); return dayp; @@ -563,7 +563,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) LLSettingsDay::ptr_t(); } - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + LLSettingsDay::ptr_t dayp = std::make_shared(settings); dayp->initialize(); return dayp; @@ -582,7 +582,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() LLSettingsDay::ptr_t(); } - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + LLSettingsDay::ptr_t dayp = std::make_shared(settings); dayp->initialize(); return dayp; @@ -595,7 +595,7 @@ LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) LLSettingsWater::ptr_t pwater; if (!trackwater.empty()) { - pwater = boost::static_pointer_cast((*trackwater.begin()).second); + pwater = std::static_pointer_cast((*trackwater.begin()).second); } if (!pwater) @@ -615,7 +615,7 @@ LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) name << hash; - skys[name.str()] = boost::static_pointer_cast((*it).second); + skys[name.str()] = std::static_pointer_cast((*it).second); F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); @@ -649,7 +649,7 @@ LLSettingsWaterPtr_t LLSettingsVODay::getDefaultWater() const LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const { - LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + LLSettingsSky::ptr_t skyp = std::make_shared(settings); if (skyp->validate()) return skyp; @@ -659,7 +659,7 @@ LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const { - LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + LLSettingsWater::ptr_t waterp = std::make_shared(settings); if (waterp->validate()) return waterp; -- cgit v1.2.3 From 6cc4a091b3ba4dd4842cc06e3b34af3d04dc5796 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 22 Feb 2018 00:35:24 +0000 Subject: Add settings/validations for new advanced atmo settings. --- indra/newview/llsettingsvo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6b1c663357..db68b39f75 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -117,6 +117,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() settings[SETTING_NAME] = std::string("_default_"); LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsSky::settingValidation(settings, validations); if (!results["success"].asBoolean()) { -- cgit v1.2.3 From b766466b3013e39831bcfcaef5d1089c07202afb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 26 Feb 2018 09:27:14 -0800 Subject: Added settings inventory object with subtype --- indra/newview/llsettingsvo.cpp | 307 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6b1c663357..aa3adfb8dd 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -32,6 +32,7 @@ #include "pipeline.h" #include +#include #include #include "lltrace.h" #include "llfasttimer.h" @@ -40,9 +41,21 @@ #include "llglslshader.h" #include "llviewershadermgr.h" +#include "llagent.h" +#include "llassettype.h" +#include "llnotificationsutil.h" + +#include "llviewerregion.h" +#include "llviewerassetupload.h" +#include "llviewerinventory.h" + #include "llenvironment.h" #include "llsky.h" +#include "llpermissions.h" + +#include "llinventorymodel.h" + #undef VERIFY_LEGACY_CONVERSION //========================================================================= @@ -66,7 +79,257 @@ LLSD ensureArray4(LLSD in, F32 fill) } return out; } + + +//------------------------------------------------------------------------- +class LLSettingsInventoryCB : public LLInventoryCallback +{ +public: + typedef std::function callback_t; + + LLSettingsInventoryCB(callback_t cbfn) : + mCbfn(cbfn) + { } + + void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } + +private: + callback_t mCbfn; +}; + +} + + +//========================================================================= +#if 0 +void LLSettingsVOBase::storeAsAsset(const LLSettingsBase::ptr_t &settings) +{ + LLTransactionID tid; + tid.generate(); + + LLAssetID aid(tid.makeAssetID(gAgent.getSecureSessionID())); + + const std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, aid.asString()) + ".setting"; + + if (!exportFile(settings, filename)) + { + LL_WARNS("SETTINGS") << "Unable to save settings file named '" << filename << "'." << LL_ENDL; + + LLSD args; + args["NAME"] = aid.asString() + "setting"; + LLNotificationsUtil::add("CannotSaveWearableOutOfSpace", args); + return; + } + + SettingsSaveData::ptr_t psave = std::make_shared(); + psave->mType = settings->getSettingType(); + psave->mSettings = settings; + psave->mTempFile = filename; + psave->mTransId = tid; + + gAssetStorage->storeAssetData(filename, tid, LLAssetType::AT_SETTINGS, + [psave](const LLUUID &assetId, void *, S32 status, LLExtStat extstat) { + onSaveNewAssetComplete(assetId, psave, status, extstat); + }, + nullptr); + +} + +void testingOnGotAsset(LLVFS *vfs, const LLUUID &asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status) +{ + LL_WARNS("SETTINGS") << "Got back stored setting with id '" << asset_id << "' status is " << status << ":" << ext_status << LL_ENDL; +} + + +void LLSettingsVOBase::onSaveNewAssetComplete(const LLUUID& new_asset_id, const LLSettingsVOBase::SettingsSaveData::ptr_t &savedata, + S32 status, LLExtStat ext_status) +{ + if (!status) + { + // Success + LL_INFOS("SETTINGS") << "Saved setting of type '" << savedata->mType << "' as " << new_asset_id << LL_ENDL; + } + else + { + LL_WARNS("SETTINGS") << "Unable to save '" << savedata->mType << "' to central asset store." << LL_ENDL; + LLSD args; + args["NAME"] = savedata->mType; + LLNotificationsUtil::add("CannotSaveToAssetStore", args); + } + + gAssetStorage->getAssetData(new_asset_id, LLAssetType::AT_SETTINGS, &testingOnGotAsset, nullptr); + + std::remove(savedata->mTempFile.c_str()); +} +#endif + + +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings) +{ + LLTransactionID tid; + LLUUID parentFolder = gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); + U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + + tid.generate(); + + LLPointer cb = new LLSettingsInventoryCB([settings](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings); + }); + + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parentFolder, tid, + settings->getName(), "new settings collection.", + settings->getSettingTypeValue(), nextOwnerPerm, cb); +} + +void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings) +{ + // We need to update some inventory stuff here.... maybe. + uploadSettingsAsset(settings, inventoryId); +} + + +void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id) +{ + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; + return; + } + + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + + if (agent_url.empty()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + return; + } + + std::stringstream buffer; + LLSD settingdata(settings->getSettings()); + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); + + LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), + [settings](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { + LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings); + }); + + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); +} + +void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id) +{ + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; + return; + } + + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + + if (agent_url.empty()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + return; + } + + std::stringstream buffer; + LLSD settingdata(settings->getSettings()); + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); + + LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), + [settings](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { + LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings); + }); + + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); +} + +void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings) +{ + LL_WARNS("SETTINGS") << "Upload to inventory complete!" << LL_ENDL; +} + +void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings) +{ + LL_WARNS("SETTINGS") << "Upload to task complete!" << LL_ENDL; +} + +bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format) +{ + try + { + std::ofstream file(filename, std::ios::out | std::ios::trunc); + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + + if (!file) + { + LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for writing." << LL_ENDL; + return false; + } + + LLSDSerialize::serialize(settings->getSettings(), file, format); + } + catch (const std::ios_base::failure &e) + { + LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; + return false; + } + + return true; +} + +LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) +{ + LLSD settings; + + try + { + std::ifstream file(filename, std::ios::in); + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + + if (!file) + { + LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for reading." << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + if (!LLSDSerialize::deserialize(settings, file, -1)) + { + LL_WARNS("SETTINGS") << "Unable to deserialize settings from '" << filename << "'" << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + } + catch (const std::ios_base::failure &e) + { + LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; + return false; + } + + std::string settingtype = settings[SETTING_NAME].asString(); + + LLSettingsBase::ptr_t psetting; + + if (settingtype == "water") + { + return LLSettingsVOWater::buildWater(settings); + } + else if (settingtype == "sky") + { + return LLSettingsVOSky::buildSky(settings); + } + else if (settingtype == "daycycle") + { + return LLSettingsVODay::buildDay(settings); + } + + LL_WARNS("SETTINGS") << "Unable to determine settings type for '" << filename << "'." << LL_ENDL; + return LLSettingsBase::ptr_t(); } + + //========================================================================= LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): LLSettingsSky(data) @@ -79,6 +342,20 @@ LLSettingsVOSky::LLSettingsVOSky(): } //------------------------------------------------------------------------- +LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) +{ + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsSky::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + return std::make_shared(settings); +} + + LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) { @@ -253,6 +530,19 @@ LLSettingsVOWater::LLSettingsVOWater() : } +LLSettingsWater::ptr_t LLSettingsVOWater::buildWater(LLSD settings) +{ + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsWater::ptr_t(); + } + + return std::make_shared(settings); +} + //------------------------------------------------------------------------- LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) { @@ -410,6 +700,23 @@ LLSettingsVODay::LLSettingsVODay(): LLSettingsDay() {} +LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) +{ + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t pday = std::make_shared(settings); + if (pday) + pday->initialize(); + + return pday; +} + //------------------------------------------------------------------------- LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) { -- cgit v1.2.3 From 5621fa48537100d70e8d06b00b6c2577f5c11140 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 27 Feb 2018 15:17:18 -0800 Subject: Fix the return type. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index aa3adfb8dd..14530715df 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -305,7 +305,7 @@ LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) catch (const std::ios_base::failure &e) { LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; - return false; + return LLSettingsBase::ptr_t(); } std::string settingtype = settings[SETTING_NAME].asString(); -- cgit v1.2.3 From 72270213f5eebd019b10bdd6ec15020ba3d2ecf5 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Wed, 28 Feb 2018 21:46:30 +0000 Subject: Add 3p package for adv atmospherics to autobuild. Mark legacy atmospherics code with ifdefs. Fix up legacy uplift to include new atmospherics settings. --- indra/newview/llsettingsvo.cpp | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index db68b39f75..84930ee425 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -150,25 +150,27 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) LLSD legacy(LLSD::emptyMap()); LLSD settings = psky->getSettings(); +// These will need to be inferred from new settings' density profiles +#if SUPPORT_LEGACY_ATMOSPHERICS legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); +#endif + legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); - legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); - + legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) - (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); - - legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); + legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); legacy[SETTING_GLOW] = ensureArray4(settings[SETTING_GLOW], 1.0); - legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); legacy[SETTING_LIGHT_NORMAL] = ensureArray4(psky->getLightDirection().getValue(), 0.0f); legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; @@ -218,21 +220,26 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { +#if SUPPORT_LEGACY_ATMOSPHERICS param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; - param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; + param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; + param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; + param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; + param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; +#endif + param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; - param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; - param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; - param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; - param_map[SETTING_GLOW] = LLShaderMgr::GLOW; - param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; - param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; + param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; + param_map[SETTING_GLOW] = LLShaderMgr::GLOW; param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; + +// AdvancedAtmospherics TODO +// Provide mappings for new shader params here } return param_map; -- cgit v1.2.3 From 7951001081209855178b73a0092cc18b1a192397 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Fri, 2 Mar 2018 00:58:04 +0000 Subject: Rework density profile validation, eliminate custom LLSettingsSky::settingsValidation in favor of custom validator functor for each profile type (rayleigh, mie, absorption). --- indra/newview/llsettingsvo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 861615b14b..8cb182b18b 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -345,7 +345,9 @@ LLSettingsVOSky::LLSettingsVOSky(): LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) { LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsSky::settingValidation(settings, validations); + + LLSD results = LLSettingsBase::settingValidation(settings, validations); + if (!results["success"].asBoolean()) { LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; @@ -364,7 +366,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n newsettings[SETTING_NAME] = name; LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsSky::settingValidation(newsettings, validations); + LLSD results = LLSettingsBase::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; @@ -394,7 +396,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() settings[SETTING_NAME] = std::string("_default_"); LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsSky::settingValidation(settings, validations); + LLSD results = LLSettingsBase::settingValidation(settings, validations); if (!results["success"].asBoolean()) { LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; @@ -410,7 +412,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() LLSD settings = cloneSettings(); LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsSky::settingValidation(settings, validations); + LLSD results = LLSettingsBase::settingValidation(settings, validations); if (!results["success"].asBoolean()) { LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; -- cgit v1.2.3 From acdead96cd194040f586c5a6e976beca7bb999c4 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Fri, 2 Mar 2018 23:29:28 +0000 Subject: Replace ifdefs with comments marking legacy atmo params. --- indra/newview/llsettingsvo.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8cb182b18b..f57de011f8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -429,7 +429,7 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) LLSD settings = psky->getSettings(); // These will need to be inferred from new settings' density profiles -#if SUPPORT_LEGACY_ATMOSPHERICS +// LEGACY_ATMOSPHERICS legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); @@ -437,7 +437,6 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); -#endif legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); @@ -498,7 +497,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { -#if SUPPORT_LEGACY_ATMOSPHERICS +// LEGACY_ATMOSPHERICS param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; @@ -506,7 +505,6 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; -#endif param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; -- cgit v1.2.3 From 98862a53a77cd1ce9a2cae596a743669cc32a2af Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Sat, 3 Mar 2018 00:53:39 +0000 Subject: Fix 16F enum for compat w/ SL gl headers on Mac. Make density profile/layer parsing handle when LLSD heard you liked arrays so it put an array in your array. --- indra/newview/llsettingsvo.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index f57de011f8..4c10017a57 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -331,13 +331,15 @@ LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) //========================================================================= -LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): - LLSettingsSky(data) +LLSettingsVOSky::LLSettingsVOSky(const LLSD &data, bool isAdvanced) +: LLSettingsSky(data) +, m_isAdvanced(isAdvanced) { } -LLSettingsVOSky::LLSettingsVOSky(): - LLSettingsSky() +LLSettingsVOSky::LLSettingsVOSky() +: LLSettingsSky() +, m_isAdvanced(false) { } @@ -354,7 +356,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) LLSettingsSky::ptr_t(); } - return std::make_shared(settings); + return std::make_shared(settings, true); } @@ -376,7 +378,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n LLSettingsSky::ptr_t skyp = std::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION - LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp); + LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp, isAdvanced()); if (!llsd_equals(legacy, oldsettings)) { @@ -423,7 +425,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() return skyp; } -LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) +LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) { LLSD legacy(LLSD::emptyMap()); LLSD settings = psky->getSettings(); @@ -940,7 +942,7 @@ LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) for (std::map::iterator its = skys.begin(); its != skys.end(); ++its) { - LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second); + LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second, false); llsdsky[SETTING_NAME] = (*its).first; llsdskylist[(*its).first] = llsdsky; -- cgit v1.2.3 From 6e51714419a151dcc26e04319cc554187a905279 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 6 Mar 2018 20:16:49 +0000 Subject: Isolate atmospherics LLSD conversion code. Fix translateLegacySettings to add an array where an array is expected. --- indra/newview/llsettingsvo.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 4c10017a57..61e411496a 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -425,13 +425,10 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() return skyp; } -LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) +void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) { - LLSD legacy(LLSD::emptyMap()); - LLSD settings = psky->getSettings(); - -// These will need to be inferred from new settings' density profiles // LEGACY_ATMOSPHERICS + // These will need to be inferred from new settings' density profiles legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); @@ -440,6 +437,23 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + //legacy[SETTING_AMBIENT] = LLColor4::black.getValue(); + //legacy[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 0.0).getValue(); + //legacy[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 0.0).getValue(); + //legacy[SETTING_HAZE_DENSITY] = LLSDArray(0.6999f)(0.0f)(0.0f)(1.0f); + //legacy[SETTING_HAZE_HORIZON] = LLSDArray(0.1899f)(0.0f)(0.0f)(1.0f); + //legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(0.0001f)(0.0f)(0.0f)(1.0f);LLSD::Real(0.0001); + //legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(0.8f)(0.0f)(0.0f)(1.0f); +} + +LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = psky->getSettings(); + +// LEGACY_ATMOSPHERICS + convertAtmosphericsToLegacy(legacy, settings); + legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); -- cgit v1.2.3 From cbe4cac78cf48cb9144dc2f6c194585cff87a1ce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 6 Mar 2018 14:58:39 -0800 Subject: Settings type inventory objects and upload the assests. --- indra/newview/llsettingsvo.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 14530715df..57dabca2f5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1,5 +1,5 @@ /** -* @file llsettingsvo.cpp +* @file llvo.cpp * @author Rider Linden * @brief Subclasses for viewer specific settings behaviors. * @@ -167,7 +167,7 @@ void LLSettingsVOBase::onSaveNewAssetComplete(const LLUUID& new_asset_id, const void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings) { LLTransactionID tid; - LLUUID parentFolder = gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); + LLUUID parentFolder; //= gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); tid.generate(); @@ -237,6 +237,9 @@ void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings std::stringstream buffer; LLSD settingdata(settings->getSettings()); + + LL_WARNS("LAPRAS") << "Sending '" << settingdata << "' for asset." << LL_ENDL; + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), @@ -765,7 +768,6 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n return LLSettingsDay::ptr_t(); } - LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); #ifdef VERIFY_LEGACY_CONVERSION @@ -820,7 +822,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io LLSD newsettings = LLSDMap ( SETTING_NAME, "Region (legacy)" ) ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) - ( SETTING_FRAMES, frames ); + ( SETTING_FRAMES, frames ) + ( SETTING_TYPE, "daycycle" ); LL_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; -- cgit v1.2.3 From 1687719a2523e1a6a9d8ebc8aeac52c530fa8fd0 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 6 Mar 2018 23:11:53 +0000 Subject: Undo changes to default Sky settings XML. Undo forced validation of objects built from legacy sky settings. --- indra/newview/llsettingsvo.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 61e411496a..30d6684638 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -451,7 +451,6 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA LLSD legacy(LLSD::emptyMap()); LLSD settings = psky->getSettings(); -// LEGACY_ATMOSPHERICS convertAtmosphericsToLegacy(legacy, settings); legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); -- cgit v1.2.3 From 62a0d579b5eb23ea306ade07afba76f7cba685c7 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Wed, 7 Mar 2018 18:37:09 +0000 Subject: Move legacy atmospherics code outside of llvosky (begin teasing apart). --- indra/newview/llsettingsvo.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 01d7ab3dcf..8cacd6d0f9 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -430,7 +430,6 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) { -// LEGACY_ATMOSPHERICS // These will need to be inferred from new settings' density profiles legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); @@ -439,14 +438,6 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); - - //legacy[SETTING_AMBIENT] = LLColor4::black.getValue(); - //legacy[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 0.0).getValue(); - //legacy[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 0.0).getValue(); - //legacy[SETTING_HAZE_DENSITY] = LLSDArray(0.6999f)(0.0f)(0.0f)(1.0f); - //legacy[SETTING_HAZE_HORIZON] = LLSDArray(0.1899f)(0.0f)(0.0f)(1.0f); - //legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(0.0001f)(0.0f)(0.0f)(1.0f);LLSD::Real(0.0001); - //legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(0.8f)(0.0f)(0.0f)(1.0f); } LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) @@ -515,12 +506,12 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { -// LEGACY_ATMOSPHERICS - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; + + param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; -- cgit v1.2.3 From 057dda6afe59791f4a6fcf4c5ca8387b8aeda6a8 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 13 Mar 2018 17:21:10 +0100 Subject: Fix storing legacy haze parameters in inner map by fixing parameter update to not expect them at top level of LLSD for sky settings. --- indra/newview/llsettingsvo.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8cacd6d0f9..e398b4ee46 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -431,13 +431,18 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) { // These will need to be inferred from new settings' density profiles - legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); - legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); - legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); - legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + if (settings.has(SETTING_LEGACY_HAZE)) + { + LLSD legacyhaze = settings[SETTING_LEGACY_HAZE]; + + legacy[SETTING_AMBIENT] = ensureArray4(legacyhaze[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensureArray4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensureArray4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + } } LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) -- cgit v1.2.3 From 3c18de21369260ec9b7ba39c0e360045dd65e30d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 10 May 2018 17:08:13 -0700 Subject: Settings editor available from the open context on the menu. Can edit inventory items. --- indra/newview/llsettingsvo.cpp | 163 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 83 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 01d7ab3dcf..ed3c18ef4e 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -55,6 +55,8 @@ #include "llpermissions.h" #include "llinventorymodel.h" +#include "llassetstorage.h" +#include "llvfile.h" #undef VERIFY_LEGACY_CONVERSION @@ -101,70 +103,7 @@ private: //========================================================================= -#if 0 -void LLSettingsVOBase::storeAsAsset(const LLSettingsBase::ptr_t &settings) -{ - LLTransactionID tid; - tid.generate(); - - LLAssetID aid(tid.makeAssetID(gAgent.getSecureSessionID())); - - const std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, aid.asString()) + ".setting"; - - if (!exportFile(settings, filename)) - { - LL_WARNS("SETTINGS") << "Unable to save settings file named '" << filename << "'." << LL_ENDL; - - LLSD args; - args["NAME"] = aid.asString() + "setting"; - LLNotificationsUtil::add("CannotSaveWearableOutOfSpace", args); - return; - } - - SettingsSaveData::ptr_t psave = std::make_shared(); - psave->mType = settings->getSettingType(); - psave->mSettings = settings; - psave->mTempFile = filename; - psave->mTransId = tid; - - gAssetStorage->storeAssetData(filename, tid, LLAssetType::AT_SETTINGS, - [psave](const LLUUID &assetId, void *, S32 status, LLExtStat extstat) { - onSaveNewAssetComplete(assetId, psave, status, extstat); - }, - nullptr); - -} - -void testingOnGotAsset(LLVFS *vfs, const LLUUID &asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status) -{ - LL_WARNS("SETTINGS") << "Got back stored setting with id '" << asset_id << "' status is " << status << ":" << ext_status << LL_ENDL; -} - - -void LLSettingsVOBase::onSaveNewAssetComplete(const LLUUID& new_asset_id, const LLSettingsVOBase::SettingsSaveData::ptr_t &savedata, - S32 status, LLExtStat ext_status) -{ - if (!status) - { - // Success - LL_INFOS("SETTINGS") << "Saved setting of type '" << savedata->mType << "' as " << new_asset_id << LL_ENDL; - } - else - { - LL_WARNS("SETTINGS") << "Unable to save '" << savedata->mType << "' to central asset store." << LL_ENDL; - LLSD args; - args["NAME"] = savedata->mType; - LLNotificationsUtil::add("CannotSaveToAssetStore", args); - } - - gAssetStorage->getAssetData(new_asset_id, LLAssetType::AT_SETTINGS, &testingOnGotAsset, nullptr); - - std::remove(savedata->mTempFile.c_str()); -} -#endif - - -void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings) +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, inventory_result_fn callback) { LLTransactionID tid; LLUUID parentFolder; //= gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); @@ -172,8 +111,8 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings tid.generate(); - LLPointer cb = new LLSettingsInventoryCB([settings](const LLUUID &inventoryId) { - LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings); + LLPointer cb = new LLSettingsInventoryCB([settings, callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings, callback); }); create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), @@ -182,14 +121,13 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings settings->getSettingTypeValue(), nextOwnerPerm, cb); } -void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings) +void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) { // We need to update some inventory stuff here.... maybe. - uploadSettingsAsset(settings, inventoryId); + updateInventoryItem(settings, inventoryId, callback); } - -void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id) +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback) { const LLViewerRegion* region = gAgent.getRegion(); if (!region) @@ -200,7 +138,7 @@ void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); - if (agent_url.empty()) + if (!LLEnvironment::instance().isInventoryEnabled()) { LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; return; @@ -211,14 +149,14 @@ void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), - [settings](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { - LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings); + [settings, callback](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { + LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings, callback); }); LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); } -void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id) +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id, inventory_result_fn callback) { const LLViewerRegion* region = gAgent.getRegion(); if (!region) @@ -229,7 +167,7 @@ void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); - if (agent_url.empty()) + if (!LLEnvironment::instance().isInventoryEnabled()) { LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; return; @@ -243,23 +181,71 @@ void LLSettingsVOBase::uploadSettingsAsset(const LLSettingsBase::ptr_t &settings LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), - [settings](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { - LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings); + [settings, callback](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { + LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings, callback); }); LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); } -void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings) +void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) { - LL_WARNS("SETTINGS") << "Upload to inventory complete!" << LL_ENDL; + LL_WARNS("SETTINGS") << "itemId:" << itemId << " newAssetId:" << newAssetId << " newItemId:" << newItemId << " response:" << response << LL_ENDL; + if (callback) + callback( newAssetId, itemId, LLUUID::null, response ); } -void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings) +void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) { LL_WARNS("SETTINGS") << "Upload to task complete!" << LL_ENDL; + if (callback) + callback(newAssetId, itemId, taskId, response); } + +void LLSettingsVOBase::getSettingsAsset(const LLUUID &assetId, LLSettingsVOBase::asset_download_fn callback) +{ + gAssetStorage->getAssetData(assetId, LLAssetType::AT_SETTINGS, + [callback](LLVFS *vfs, const LLUUID &asset_id, LLAssetType::EType, void *, S32 status, LLExtStat ext_status) + { onAssetDownloadComplete(vfs, asset_id, status, ext_status, callback); }, + nullptr, true); + +} + +void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_id, S32 status, LLExtStat ext_status, LLSettingsVOBase::asset_download_fn callback) +{ + LLSettingsBase::ptr_t settings; + if (!status) + { + LLVFile file(vfs, asset_id, LLAssetType::AT_SETTINGS, LLVFile::READ); + S32 size = file.getSize(); + + std::string buffer(size + 1, '\0'); + file.read((U8 *)buffer.data(), size); + + std::stringstream llsdstream(buffer); + LLSD llsdsettings; + + if (LLSDSerialize::deserialize(llsdsettings, llsdstream, -1)) + { + settings = createFromLLSD(llsdsettings); + } + + if (!settings) + { + status = 1; + LL_WARNS("SETTINGS") << "Unable to creat settings object." << LL_ENDL; + } + + } + else + { + LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << " ext_status=" << ext_status << LL_ENDL; + } + callback(asset_id, settings, status, ext_status); +} + + bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format) { try @@ -311,7 +297,18 @@ LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) return LLSettingsBase::ptr_t(); } - std::string settingtype = settings[SETTING_NAME].asString(); + return createFromLLSD(settings); +} + +LLSettingsBase::ptr_t LLSettingsVOBase::createFromLLSD(const LLSD &settings) +{ + if (!settings.has(SETTING_TYPE)) + { + LL_WARNS("SETTINGS") << "No settings type in LLSD" << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + std::string settingtype = settings[SETTING_TYPE].asString(); LLSettingsBase::ptr_t psetting; @@ -328,10 +325,10 @@ LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) return LLSettingsVODay::buildDay(settings); } - LL_WARNS("SETTINGS") << "Unable to determine settings type for '" << filename << "'." << LL_ENDL; + LL_WARNS("SETTINGS") << "Unable to determine settings type for '" << settingtype << "'." << LL_ENDL; return LLSettingsBase::ptr_t(); -} +} //========================================================================= LLSettingsVOSky::LLSettingsVOSky(const LLSD &data, bool isAdvanced) -- cgit v1.2.3 From 13536bb273b7413aa4461c8eeaf5a6a865f4234d Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 22 May 2018 21:42:54 +0100 Subject: Remove some obsolete sky funcs. Remove Matrix3/4 funcs using LLQuat 4-float init incorrectly (they are redundant to angle/axis versions anyway). Fix up tests referring to removed funcs above. --- indra/newview/llsettingsvo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 804e4671ab..68513e37ac 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -464,8 +464,10 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; legacy[SETTING_SUNLIGHT_COLOR] = ensureArray4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); +// convert to azimuth (yaw) from east and alt (pitch) from horizon +// in +x is at (north), +z up, +y right (east) LLSettingsSky::azimalt_t azialt = psky->getSunRotationAzAl(); - + legacy[SETTING_LEGACY_EAST_ANGLE] = azialt.first; legacy[SETTING_LEGACY_SUN_ANGLE] = azialt.second; @@ -480,6 +482,8 @@ void LLSettingsVOSky::updateSettings() LLVector3 sun_direction = getSunDirection(); LLVector3 moon_direction = getMoonDirection(); + // axis swap converts from +x right, +y up, +z at + // to CFR (+x at, +z up, +y right) // set direction (in CRF) and don't allow overriding LLVector3 crf_sunDirection(sun_direction.mV[2], sun_direction.mV[0], sun_direction.mV[1]); LLVector3 crf_moonDirection(moon_direction.mV[2], moon_direction.mV[0], moon_direction.mV[1]); -- cgit v1.2.3 From 2ddad24c4d5e64711cdbffd98e290d3da8e9714a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 30 May 2018 17:08:28 -0700 Subject: Timeline behavior in day cycle edit. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index ed3c18ef4e..1ac607cd1f 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -240,7 +240,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { - LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << " ext_status=" << ext_status << LL_ENDL; + LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; } callback(asset_id, settings, status, ext_status); } -- cgit v1.2.3 From 64302d3000b69b31e72eb6a3bd8a981c80cb88de Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 00:18:36 +0100 Subject: Modify use of sky settings, reduce complexity, and name funcs to indicate coord systems in use. Fix class2 softenLightF shader. --- indra/newview/llsettingsvo.cpp | 69 ++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 23 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index bd69659e7a..85cdd1e984 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -365,7 +365,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) { - LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy, &name); + LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); newsettings[SETTING_NAME] = name; @@ -476,7 +476,7 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA sunquat.getEulerAngles(&roll, &pitch, &yaw); legacy[SETTING_LEGACY_EAST_ANGLE] = yaw; - legacy[SETTING_LEGACY_SUN_ANGLE] = pitch; + legacy[SETTING_LEGACY_SUN_ANGLE] = -pitch; return legacy; } @@ -485,32 +485,51 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA void LLSettingsVOSky::updateSettings() { LLSettingsSky::updateSettings(); - LLVector3 sun_direction = getSunDirection(); LLVector3 moon_direction = getMoonDirection(); - // axis swap converts from +x right, +z up, +y at - // to CFR (+x at, +z up, +y right) - // set direction (in CRF) and don't allow overriding - //LLVector3 crf_sunDirection(sun_direction.mV[1], sun_direction.mV[0], sun_direction.mV[2]); - //LLVector3 crf_moonDirection(moon_direction.mV[1], moon_direction.mV[0], moon_direction.mV[2]); - - gSky.setSunDirection(sun_direction, moon_direction); + F32 dp = getLightDirection() * LLVector3(0.0f, 0.0f, 1.0f); + if (dp < 0) + { + dp = 0; + } + dp = llmax(dp, 0.1f); + + // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio + // between sunlight and point lights in windlight to normalize point lights. + F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); + mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + + // Axis swaps convert from +x right, +z up, +y at + // to CFR +x at, +z up, +y right coord sys + LLVector3 sun_direction_cfr(sun_direction.mV[0], -sun_direction.mV[1], sun_direction.mV[2]); + LLVector3 moon_direction_cfr(moon_direction.mV[0], -moon_direction.mV[1], moon_direction.mV[2]); + gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); } void LLSettingsVOSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); - shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); + if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + } + else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) + { + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - { LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); - } + } + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); } LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const @@ -519,12 +538,12 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { +// LEGACY_ATMOSPHERICS + param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; - - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; @@ -663,12 +682,16 @@ void LLSettingsVOWater::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); - shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + if (shader->mShaderGroup == LLGLSLShader::SG_WATER) + { + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); + shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + } } void LLSettingsVOWater::updateSettings() @@ -702,7 +725,7 @@ void LLSettingsVOWater::updateSettings() mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); - LLVector4 light_direction = LLEnvironment::instance().getLightDirection(); + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); } @@ -820,7 +843,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) { std::string newname = "sky:" + (*itm).first; - LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second, &newname); + LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second); newsettings[SETTING_NAME] = newname; frames[newname] = newsettings; -- cgit v1.2.3 From 8dd85013865cc5b426234cd71b605d7208bcfe01 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 15:50:25 +0100 Subject: Fix mis-merge of LLSettingsBase and remove optimize pragmas. --- indra/newview/llsettingsvo.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index d5bcbd1894..451a0fb326 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -58,8 +58,6 @@ #include "llassetstorage.h" #include "llvfile.h" -#pragma optimize("", off) - #undef VERIFY_LEGACY_CONVERSION //========================================================================= -- cgit v1.2.3 From 2a613d7363c4e91a7258d4f0ea3971db1569e788 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 1 Jun 2018 16:24:36 -0700 Subject: Rework preset loading and context menu from inventory. --- indra/newview/llsettingsvo.cpp | 208 ++++++++++++++++++++++++++++++----------- 1 file changed, 154 insertions(+), 54 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 1ac607cd1f..39046004b8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -58,47 +58,33 @@ #include "llassetstorage.h" #include "llvfile.h" +#include + #undef VERIFY_LEGACY_CONVERSION //========================================================================= namespace { -LLSD ensureArray4(LLSD in, F32 fill) -{ - if (in.size() >= 4) - return in; - - LLSD out(LLSD::emptyArray()); - - for (S32 idx = 0; idx < in.size(); ++idx) - { - out.append(in[idx]); - } - - while (out.size() < 4) - { - out.append(LLSD::Real(fill)); - } - return out; -} - + LLSD ensure_array_4(LLSD in, F32 fill); + LLSD read_legacy_preset_data(const std::string& path); -//------------------------------------------------------------------------- -class LLSettingsInventoryCB : public LLInventoryCallback -{ -public: - typedef std::function callback_t; + //------------------------------------------------------------------------- + class LLSettingsInventoryCB : public LLInventoryCallback + { + public: + typedef std::function callback_t; - LLSettingsInventoryCB(callback_t cbfn) : - mCbfn(cbfn) - { } + LLSettingsInventoryCB(callback_t cbfn) : + mCbfn(cbfn) + { } - void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } + void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } -private: - callback_t mCbfn; -}; + private: + callback_t mCbfn; + }; + //------------------------------------------------------------------------- } @@ -240,9 +226,10 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { - LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; + LL_WARNS("SETTINGS") << "Error retrieving asset " << asset_id << ". Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; } - callback(asset_id, settings, status, ext_status); + if (callback) + callback(asset_id, settings, status, ext_status); } @@ -392,6 +379,37 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n return skyp; } +namespace +{ + // This is a disturbing hack + std::string legacy_name_to_filename(const std::string &name) + { + std::string fixedname(LLURI::escape(name)); + + boost::algorithm::replace_all(fixedname, "-", "%2D"); + return fixedname; + } +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + std::string full_path(path); + std::string full_name(legacy_name_to_filename(name)); + full_name += ".xml"; + + gDirUtilp->append(full_path, full_name); + LLSD legacy_data = read_legacy_preset_data(full_path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data); +} + + LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() { LLSD settings = LLSettingsSky::defaults(); @@ -429,9 +447,9 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) { // LEGACY_ATMOSPHERICS // These will need to be inferred from new settings' density profiles - legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); - legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); - legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_AMBIENT] = ensure_array_4(settings[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensure_array_4(settings[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensure_array_4(settings[SETTING_BLUE_HORIZON], 1.0); legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); @@ -453,20 +471,20 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA convertAtmosphericsToLegacy(legacy, settings); - legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); - legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); - legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); + legacy[SETTING_CLOUD_COLOR] = ensure_array_4(settings[SETTING_CLOUD_COLOR], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY1] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); - legacy[SETTING_GLOW] = ensureArray4(settings[SETTING_GLOW], 1.0); - legacy[SETTING_LIGHT_NORMAL] = ensureArray4(psky->getLightDirection().getValue(), 0.0f); + legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); + legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; - legacy[SETTING_SUNLIGHT_COLOR] = ensureArray4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); + legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); LLSettingsSky::azimalt_t azialt = psky->getSunRotationAzAl(); @@ -595,6 +613,25 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin return waterp; } +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + std::string full_path(path); + std::string full_name(legacy_name_to_filename(name)); + full_name += ".xml"; + + gDirUtilp->append(full_path, full_name); + LLSD legacy_data = read_legacy_preset_data(full_path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data); +} + + LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() { LLSD settings = LLSettingsWater::defaults(); @@ -635,7 +672,7 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) LLSD settings = pwater->getSettings(); legacy[SETTING_LEGACY_BLUR_MULTIPILER] = settings[SETTING_BLUR_MULTIPILER]; - legacy[SETTING_LEGACY_FOG_COLOR] = ensureArray4(settings[SETTING_FOG_COLOR], 1.0f); + legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f); legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; @@ -740,10 +777,18 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) } //------------------------------------------------------------------------- -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings) { LLSD newsettings(defaults()); std::set framenames; + std::set notfound; + + std::string base_path(gDirUtilp->getDirName(path)); + std::string water_path(base_path); + std::string sky_path(base_path); + + gDirUtilp->append(water_path, "water"); + gDirUtilp->append(sky_path, "skies"); newsettings[SETTING_NAME] = name; @@ -767,14 +812,16 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSD frames(LLSD::emptyMap()); { - LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName("Default"); - frames["water:Default"] = pwater->getSettings(); + LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path); + if (pwater) + frames["water:Default"] = pwater->getSettings(); } for (std::set::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(*itn); - frames["sky:" + (*itn)] = psky->getSettings(); + LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path); + if (psky) + frames["sky:" + (*itn)] = psky->getSettings(); } newsettings[SETTING_FRAMES] = frames; @@ -806,6 +853,26 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n return dayp; } +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + std::string full_path(path); + std::string full_name(legacy_name_to_filename(name)); + full_name += ".xml"; + + gDirUtilp->append(full_path, full_name); + LLSD legacy_data = read_legacy_preset_data(full_path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, path, legacy_data); +} + + + LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) { LLSD frames(LLSD::emptyMap()); @@ -863,6 +930,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io return dayp; } + + LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() { LLSD settings = LLSettingsDay::defaults(); @@ -996,12 +1065,43 @@ LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const return LLSettingsWater::ptr_t(); } -LLSettingsSkyPtr_t LLSettingsVODay::getNamedSky(const std::string &name) const +//========================================================================= +namespace { - return LLEnvironment::instance().findSkyByName(name); -} + LLSD ensure_array_4(LLSD in, F32 fill) + { + if (in.size() >= 4) + return in; -LLSettingsWaterPtr_t LLSettingsVODay::getNamedWater(const std::string &name) const -{ - return LLEnvironment::instance().findWaterByName(name); + LLSD out(LLSD::emptyArray()); + + for (S32 idx = 0; idx < in.size(); ++idx) + { + out.append(in[idx]); + } + + while (out.size() < 4) + { + out.append(LLSD::Real(fill)); + } + return out; + } + + //--------------------------------------------------------------------- + LLSD read_legacy_preset_data(const std::string& path) + { + llifstream xml_file; +// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); + + xml_file.open(path.c_str()); + if (!xml_file) + return LLSD(); + + LLSD params_data; + LLPointer parser = new LLSDXMLParser(); + parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + xml_file.close(); + + return params_data; + } } -- cgit v1.2.3 From 7136956b90614bbd236be0e30231781c04346220 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 2 Jun 2018 23:28:48 +0100 Subject: Use more typedefs to simplify sync between viewer and sim env settings code. --- indra/newview/llsettingsvo.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 0e3bc87719..5991c42c97 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -449,14 +449,13 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) if (settings.has(SETTING_LEGACY_HAZE)) { LLSD legacyhaze = settings[SETTING_LEGACY_HAZE]; - - legacy[SETTING_AMBIENT] = ensureArray4(legacyhaze[SETTING_AMBIENT], 1.0f); - legacy[SETTING_BLUE_DENSITY] = ensureArray4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); - legacy[SETTING_BLUE_HORIZON] = ensureArray4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); - legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); } } -- cgit v1.2.3 From 8365945f8af6e27e7180b40aae79f210f99bb7c8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 8 Jun 2018 16:40:01 -0700 Subject: Settings inventory picker. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 5991c42c97..28d1371350 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -104,7 +104,7 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), parentFolder, tid, settings->getName(), "new settings collection.", - settings->getSettingTypeValue(), nextOwnerPerm, cb); + settings->getSettingsTypeValue(), nextOwnerPerm, cb); } void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) -- cgit v1.2.3 From a0598b12656cdcf22ba95cacd01b5ff36f8f1b26 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 11 Jun 2018 17:46:16 +0100 Subject: Fix water fog consolidation in underwater shaders. Add plumbing facilities to allow current and next moon textures to be passed to moon shader. Modify moon shader to blend between current and next moon textures by blend factor. --- indra/newview/llsettingsvo.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 5991c42c97..b5fb889669 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -520,6 +520,8 @@ void LLSettingsVOSky::updateSettings() LLVector3 sun_direction_cfr(sun_direction.mV[0], -sun_direction.mV[1], sun_direction.mV[2]); LLVector3 moon_direction_cfr(moon_direction.mV[0], -moon_direction.mV[1], moon_direction.mV[2]); gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); + gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); + gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); } void LLSettingsVOSky::applySpecial(void *ptarget) -- cgit v1.2.3 From fc8d0de673da0e02915556008a365aca67472eba Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 11 Jun 2018 22:39:57 +0100 Subject: Make cloud rendering use textures defined in sky settings and add code to shaders to lerp between current and next cloud texture. --- indra/newview/llsettingsvo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 0ec7db2ed7..95bcf127ae 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -522,6 +522,7 @@ void LLSettingsVOSky::updateSettings() gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); + gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); } void LLSettingsVOSky::applySpecial(void *ptarget) -- cgit v1.2.3 From 67ab0084f87c40bf31d7fadded55cc9ea6299ca2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 12 Jun 2018 18:42:07 +0100 Subject: Fix env panel forward action. Make env panel update environment when jumping frame to frame. Add separate funcs for sun/moon vectors in various coord systems. Make haze glow only pay attention to sun (i.e. fix sun glow when moon is near horizon in daytime). --- indra/newview/llsettingsvo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 95bcf127ae..23c77c8a25 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -529,7 +529,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + LLVector4 light_direction = LLEnvironment::instance().getClampedSunNorm(); if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { @@ -538,7 +538,6 @@ void LLSettingsVOSky::applySpecial(void *ptarget) } else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) { - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); -- cgit v1.2.3 From 2add1e7abdf536b32bfbfa4b353189782df8cb19 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 Jun 2018 12:39:59 -0700 Subject: Time threshold on timer based updates. Editor can replace frame with one from inventory. Extra check on adding a frame type. --- indra/newview/llsettingsvo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 0ec7db2ed7..fba62e1ce9 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -222,7 +222,10 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i status = 1; LL_WARNS("SETTINGS") << "Unable to creat settings object." << LL_ENDL; } - + else + { + settings->setAssetId(asset_id); + } } else { -- cgit v1.2.3 From 34865c4bb5cd12219606f44748159fe7cbeea264 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 13 Jun 2018 00:51:39 +0100 Subject: Mods to hook up water settings to water normals for rendering with support for current to next blending. Modify LLSettingsFoo::buildDefaultFoo to use a static and avoid re-validation of default sky/water/daycycle settings. Remove all references to gSun/MoonTextureId globals (they should come from sky settings now). --- indra/newview/llsettingsvo.cpp | 76 +++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 24 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 2ffb1c1bce..deaaffb1f5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -57,6 +57,7 @@ #include "llinventorymodel.h" #include "llassetstorage.h" #include "llvfile.h" +#include "lldrawpoolwater.h" #include @@ -415,18 +416,24 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::strin LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() { - LLSD settings = LLSettingsSky::defaults(); - settings[SETTING_NAME] = std::string("_default_"); + static LLSD default_settings; - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsBase::settingValidation(settings, validations); - if (!results["success"].asBoolean()) + if (!default_settings.size()) { - LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; - LLSettingsSky::ptr_t(); + default_settings = LLSettingsSky::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } } - LLSettingsSky::ptr_t skyp = std::make_shared(settings); + LLSettingsSky::ptr_t skyp = std::make_shared(default_settings); return skyp; } @@ -662,18 +669,24 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::s LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() { - LLSD settings = LLSettingsWater::defaults(); - settings[SETTING_NAME] = std::string("_default_"); + static LLSD default_settings; - LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); - LLSD results = LLSettingsWater::settingValidation(settings, validations); - if (!results["success"].asBoolean()) + if (!default_settings.size()) { - LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; - return LLSettingsWater::ptr_t(); + default_settings = LLSettingsWater::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } } - LLSettingsWater::ptr_t waterp = std::make_shared(settings); + LLSettingsWater::ptr_t waterp = std::make_shared(default_settings); return waterp; } @@ -726,6 +739,9 @@ void LLSettingsVOWater::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); + shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); @@ -768,6 +784,13 @@ void LLSettingsVOWater::updateSettings() mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); } + + LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER); + if (pwaterpool) + { + pwaterpool->setTransparentTextures(getTransparentTextureID(), getNextTransparentTextureID()); + pwaterpool->setNormalMaps(getNormalMapID(), getNextNormalMapID()); + } } LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const @@ -966,18 +989,23 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() { - LLSD settings = LLSettingsDay::defaults(); - settings[SETTING_NAME] = std::string("_default_"); + static LLSD default_settings; - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(settings, validations); - if (!results["success"].asBoolean()) + if (!default_settings.size()) { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); + default_settings = LLSettingsDay::defaults(); + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } } - LLSettingsDay::ptr_t dayp = std::make_shared(settings); + LLSettingsDay::ptr_t dayp = std::make_shared(default_settings); dayp->initialize(); return dayp; -- cgit v1.2.3 From a02b3500b9979c10336eb13674279b3c07367445 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 22 Jun 2018 00:41:19 +0100 Subject: Make LLSettingsFoo::defaults() funcs only calculate the invariant values once (use static trick ala the validations). Fix conversion of legacy settings w/ non-zero east angles to account for those values being CW radian angles. --- indra/newview/llsettingsvo.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index deaaffb1f5..44bb9fc6f5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -525,10 +525,11 @@ void LLSettingsVOSky::updateSettings() F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); - // Axis swaps convert from +x right, +z up, +y at - // to CFR +x at, +z up, +y right coord sys - LLVector3 sun_direction_cfr(sun_direction.mV[0], -sun_direction.mV[1], sun_direction.mV[2]); - LLVector3 moon_direction_cfr(moon_direction.mV[0], -moon_direction.mV[1], moon_direction.mV[2]); + // Axis swaps convert from "normal" (+x right, +z up, +y at) + // to CFR (+x at, +z up, +y right) coord sys + LLVector3 sun_direction_cfr(sun_direction.mV[1], sun_direction.mV[0], sun_direction.mV[2]); + LLVector3 moon_direction_cfr(moon_direction.mV[1], moon_direction.mV[0], moon_direction.mV[2]); + gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); -- cgit v1.2.3 From 6dc109a8d248540c6674b863e3e4655d079528d8 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Jun 2018 16:46:38 +0100 Subject: Remove unnecessary coord sys transformation to fix moon positioning. Avoid doing sky texture generation when using atmospherics shaders (which don't need that texture anyway). --- indra/newview/llsettingsvo.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 44bb9fc6f5..646b317325 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -525,12 +525,7 @@ void LLSettingsVOSky::updateSettings() F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); - // Axis swaps convert from "normal" (+x right, +z up, +y at) - // to CFR (+x at, +z up, +y right) coord sys - LLVector3 sun_direction_cfr(sun_direction.mV[1], sun_direction.mV[0], sun_direction.mV[2]); - LLVector3 moon_direction_cfr(moon_direction.mV[1], moon_direction.mV[0], moon_direction.mV[2]); - - gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); + gSky.setSunAndMoonDirectionsCFR(sun_direction, moon_direction); gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); -- cgit v1.2.3 From 19069ce25c30f6744310e015dbf767954efbd8ae Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 28 Jun 2018 17:06:49 -0700 Subject: Creating settings objects in the correct folders. Correctly check if clouds paused. --- indra/newview/llsettingsvo.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 646b317325..e2c8652f47 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -90,10 +90,9 @@ namespace //========================================================================= -void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, inventory_result_fn callback) +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, inventory_result_fn callback) { LLTransactionID tid; - LLUUID parentFolder; //= gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); tid.generate(); @@ -103,7 +102,7 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings }); create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), - parentFolder, tid, + parent_id, tid, settings->getName(), "new settings collection.", settings->getSettingsTypeValue(), nextOwnerPerm, cb); } -- cgit v1.2.3 From a4137d72ebc9f49dfd8bd124b255da0dfbc4ba92 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 3 Jul 2018 14:18:24 -0700 Subject: MAINT-8821: New "My Environments" floater. First pass. --- indra/newview/llsettingsvo.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index e2c8652f47..5ea29fb609 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -162,7 +162,6 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings std::stringstream buffer; LLSD settingdata(settings->getSettings()); - LL_WARNS("LAPRAS") << "Sending '" << settingdata << "' for asset." << LL_ENDL; LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); @@ -176,14 +175,16 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) { - LL_WARNS("SETTINGS") << "itemId:" << itemId << " newAssetId:" << newAssetId << " newItemId:" << newItemId << " response:" << response << LL_ENDL; + LL_INFOS("SETTINGS") << "itemId:" << itemId << " newAssetId:" << newAssetId << " newItemId:" << newItemId << " response:" << response << LL_ENDL; + psettings->setAssetId(newAssetId); if (callback) callback( newAssetId, itemId, LLUUID::null, response ); } void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) { - LL_WARNS("SETTINGS") << "Upload to task complete!" << LL_ENDL; + LL_INFOS("SETTINGS") << "Upload to task complete!" << LL_ENDL; + psettings->setAssetId(newAssetId); if (callback) callback(newAssetId, itemId, taskId, response); } -- cgit v1.2.3 From 21d165011b81909c8cab944755b53f908e51ad16 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 9 Jul 2018 13:26:48 -0700 Subject: Attempting to create a settings inventory item on a non-eep region will now show a visible failure message to the user. Menu items for greating settings in inventory are disabled on non eep regions. --- indra/newview/llsettingsvo.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 5ea29fb609..dba7e00b93 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -95,6 +95,13 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings LLTransactionID tid; U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + tid.generate(); LLPointer cb = new LLSettingsInventoryCB([settings, callback](const LLUUID &inventoryId) { @@ -127,6 +134,7 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings if (!LLEnvironment::instance().isInventoryEnabled()) { LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); return; } @@ -156,6 +164,7 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings if (!LLEnvironment::instance().isInventoryEnabled()) { LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); return; } -- cgit v1.2.3 From a90e61b798711306496c2ed7aa5cce6d096ea466 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 10 Jul 2018 19:08:14 +0100 Subject: Support blending current/next bloom textures in deferred star rendering. --- indra/newview/llsettingsvo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 5ea29fb609..b728cbc314 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -529,6 +529,7 @@ void LLSettingsVOSky::updateSettings() gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); + gSky.setBloomTextures(getBloomTextureId(), getNextBloomTextureId()); } void LLSettingsVOSky::applySpecial(void *ptarget) -- cgit v1.2.3 From d6ede8e81cad497a6cd8482dfb48c99bdf5c258a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 30 Jul 2018 15:54:36 -0700 Subject: MAINT-8904: Creating new setting in inventory now causes simulator to assign default asset ID to inventory item. --- indra/newview/llsettingsvo.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index a5187b7363..010b5dec36 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -90,6 +90,31 @@ namespace //========================================================================= +void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback) +{ + LLTransactionID tid; + U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + tid.generate(); + + LLPointer cb = new LLSettingsInventoryCB([callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, LLSettingsBase::ptr_t(), callback); + }); + + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, + LLSettingsType::getDefaultName(stype), "new settings collection.", + stype, nextOwnerPerm, cb); +} + + void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, inventory_result_fn callback) { LLTransactionID tid; @@ -116,6 +141,20 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) { + if (!settings) + { // The item was created as new with no settings passed in. Simulator should have given it the default for the type... check ID, + // no need to upload asset. + LLUUID asset_id; + LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); + + if (pitem) + { + asset_id = pitem->getAssetUUID(); + } + if (callback) + callback(asset_id, inventoryId, LLUUID::null, LLSD()); + return; + } // We need to update some inventory stuff here.... maybe. updateInventoryItem(settings, inventoryId, callback); } -- cgit v1.2.3 From b50d546d5ffb520228926ff1f4e6b03c69b3f857 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Aug 2018 16:13:22 -0700 Subject: MAINT-7699: More robust cap protocol, better support for delete and support for individual tracks, support for setting environment by asset id in the cap MAINT-7703: Initial flags sent in message protocol for parcels --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 010b5dec36..e464f3f8ef 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -269,7 +269,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i if (!settings) { status = 1; - LL_WARNS("SETTINGS") << "Unable to creat settings object." << LL_ENDL; + LL_WARNS("SETTINGS") << "Unable to create settings object." << LL_ENDL; } else { -- cgit v1.2.3 From 51abc168c03f80d63c85d4bb48624f440b585390 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 3 Aug 2018 21:01:43 +0300 Subject: MAINT-8902 fix encroaching 'legacy' issues --- indra/newview/llsettingsvo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index e464f3f8ef..80797ae21c 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1025,7 +1025,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io if (dayp) { - dayp->initialize(); + // true for validation - either validate here, or when cloning for floater. + dayp->initialize(true); } return dayp; } -- cgit v1.2.3 From 584fec695bc8d6bafc38ff6ed3b435f133fdca2b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 15 Aug 2018 18:31:07 +0300 Subject: MAINT-8952 EEP 'uncompress' day tracks before editing --- indra/newview/llsettingsvo.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 80797ae21c..2cdc3e79c3 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1092,6 +1092,30 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() return dayp; } +LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() +{ + // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD + LLSD settings = llsd_clone(mSettings); + + LLSettingsDay::ptr_t day_clone = std::make_shared(settings); + + for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i) + { + LLSettingsDay::CycleTrack_t track = getCycleTrack(i); + LLSettingsDay::CycleTrack_t::iterator iter = track.begin(); + while (iter != track.end()) + { + // 'Unpack', usually for editing + // - frames 'share' settings multiple times + // - settings can reuse LLSDs they were initialized from + // We do not want for edited frame to change multiple frames in same track, so do a clone + day_clone->setSettingsAtKeyframe(iter->second->buildDerivedClone(), iter->first, i); + iter++; + } + } + return day_clone; +} + LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) { CycleTrack_t &trackwater = pday->getCycleTrack(TRACK_WATER); -- cgit v1.2.3 From eadf0b910174274e7c83fe37e417f576a7350edb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 15 Aug 2018 13:35:53 -0700 Subject: MAINT-8990, MAINT-9002: First pass rework on environment panels, region/parcel --- indra/newview/llsettingsvo.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 80797ae21c..a9e801a2e1 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -273,6 +273,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { + LL_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; settings->setAssetId(asset_id); } } @@ -1074,6 +1075,44 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) } +void LLSettingsVODay::buildFromOtherSetting(LLSettingsBase::ptr_t settings, LLSettingsVODay::asset_built_fn cb) +{ + if (settings->getSettingsType() == "daycycle") + { + if (cb) + cb(std::static_pointer_cast(settings)); + } + else + { + LLSettingsVOBase::getSettingsAsset(LLSettingsDay::GetDefaultAssetId(), + [settings, cb](LLUUID, LLSettingsBase::ptr_t pday, S32, LLExtStat){ combineIntoDayCycle(std::static_pointer_cast(pday), settings, cb); }); + } +} + +void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsBase::ptr_t settings, asset_built_fn cb) +{ + if (settings->getSettingsType() == "sky") + { + pday->setName("sky: " + settings->getName()); + pday->clearCycleTrack(1); + pday->setSettingsAtKeyframe(settings, 0.0, 1); + } + else if (settings->getSettingsType() == "water") + { + pday->setName("water: " + settings->getName()); + pday->clearCycleTrack(0); + pday->setSettingsAtKeyframe(settings, 0.0, 0); + } + else + { + pday.reset(); + } + + if (cb) + cb(pday); +} + + LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); -- cgit v1.2.3 From aa03fe54cc35cac760a20b5c9e9ab6c84a7b38e5 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 16 Aug 2018 17:59:24 +0300 Subject: MAINT-8952 EEP make sure settings will be re-compressed --- indra/newview/llsettingsvo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 2cdc3e79c3..b9eb1fd5c6 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1104,9 +1104,9 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() LLSettingsDay::CycleTrack_t track = getCycleTrack(i); LLSettingsDay::CycleTrack_t::iterator iter = track.begin(); while (iter != track.end()) - { - // 'Unpack', usually for editing - // - frames 'share' settings multiple times + { + // 'Unpack', usually for editing + // - frames 'share' settings multiple times // - settings can reuse LLSDs they were initialized from // We do not want for edited frame to change multiple frames in same track, so do a clone day_clone->setSettingsAtKeyframe(iter->second->buildDerivedClone(), iter->first, i); -- cgit v1.2.3 From 5ddd9d0c977bea070008baefdb452e808077f98c Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 16 Aug 2018 21:38:49 +0100 Subject: Make settings vfuncs use SETTINGS_OVERRIDE macro (override keyword in viewer codebase) to fix OS X compilation. Mark cloning funcs and derived class overrides as const. --- indra/newview/llsettingsvo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index b9eb1fd5c6..c410f0d955 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -485,7 +485,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() return skyp; } -LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const { LLSD settings = cloneSettings(); @@ -736,7 +736,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() return waterp; } -LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const { LLSD settings = cloneSettings(); LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); @@ -1074,7 +1074,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) } -LLSettingsDay::ptr_t LLSettingsVODay::buildClone() +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const { LLSD settings = cloneSettings(); @@ -1092,7 +1092,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() return dayp; } -LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() +LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const { // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD LLSD settings = llsd_clone(mSettings); -- cgit v1.2.3 From 597d28ad343d39f0812f7403119cc817dfab3d64 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 16 Aug 2018 22:00:53 +0100 Subject: Fix constness of LLSettingsVODay::buildDeepCloneAndUncompress. --- indra/newview/llsettingsvo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index c410f0d955..ef74ecf46f 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1101,8 +1101,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i) { - LLSettingsDay::CycleTrack_t track = getCycleTrack(i); - LLSettingsDay::CycleTrack_t::iterator iter = track.begin(); + const LLSettingsDay::CycleTrack_t& track = getCycleTrackConst(i); + LLSettingsDay::CycleTrack_t::const_iterator iter = track.begin(); while (iter != track.end()) { // 'Unpack', usually for editing -- cgit v1.2.3 From f45edabe478eb2e5ed899377f541875cbd566977 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 22 Aug 2018 23:02:16 +0100 Subject: MAINT-9026 hook up sun/moon scale to settingsvo and render code --- indra/newview/llsettingsvo.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index c56b5df74d..3638cd0b44 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -579,6 +579,9 @@ void LLSettingsVOSky::updateSettings() gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); gSky.setBloomTextures(getBloomTextureId(), getNextBloomTextureId()); + + gSky.setSunScale(getSunScale()); + gSky.setMoonScale(getMoonScale()); } void LLSettingsVOSky::applySpecial(void *ptarget) -- cgit v1.2.3 From d5f2267369d2695a8aec7c1d0cfa25954ae3c706 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 24 Aug 2018 11:59:28 -0700 Subject: Remove "Commit" from fixed editor. Check isDirty() before replacing or closing fixed editor. --- indra/newview/llsettingsvo.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 3638cd0b44..719d682118 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -227,6 +227,14 @@ void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAsset psettings->setAssetId(newAssetId); if (callback) callback( newAssetId, itemId, LLUUID::null, response ); + +#if 0 + std::string exprtFile = gDirUtilp->getTempDir() + gDirUtilp->getDirDelimiter() + newAssetId.asString() + ".llsd"; + + LLSettingsVOBase::exportFile(psettings, exprtFile, LLSDSerialize::LLSD_NOTATION); + + LL_WARNS("LAPRAS") << "SETTINGS File written as: '" << exprtFile << "'" << LL_ENDL; +#endif } void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) -- cgit v1.2.3 From d452fd77eff53c031c74301dd44a35edce6da95b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 30 Aug 2018 21:37:10 +0100 Subject: MAINT-9007 fix management of water plane and fog Ks shader uniforms --- indra/newview/llsettingsvo.cpp | 46 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 719d682118..12f487398f 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -793,30 +793,6 @@ void LLSettingsVOWater::applySpecial(void *ptarget) if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); - shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); - - F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); - shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - - LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); - } -} - -void LLSettingsVOWater::updateSettings() -{ - // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); - // LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; - - // base class clears dirty flag so as to not trigger recursive update - LLSettingsBase::updateSettings(); - - // only do this if we're dealing with shaders - if (gPipeline.canUseVertexShaders()) - { //transform water plane to eye space glh::vec3f norm(0.f, 0.f, 1.f); glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); @@ -835,12 +811,30 @@ void LLSettingsVOWater::updateSettings() enorm.normalize(); mat.mult_matrix_vec(p, ep); - mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, waterPlane.mV); LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); - mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); + F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); + + shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); + + F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); + shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); } +} + +void LLSettingsVOWater::updateSettings() +{ + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER); if (pwaterpool) -- cgit v1.2.3 From fa2b53385eb27fc1c42016a48267f92f7f9567a8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 31 Aug 2018 14:25:07 -0700 Subject: Better code for finding a file when loading legacy windlights --- indra/newview/llsettingsvo.cpp | 89 ++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 38 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 12f487398f..6426e95f6c 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -67,7 +67,7 @@ namespace { LLSD ensure_array_4(LLSD in, F32 fill); - LLSD read_legacy_preset_data(const std::string& path); + LLSD read_legacy_preset_data(const std::string &name, const std::string& path); //------------------------------------------------------------------------- class LLSettingsInventoryCB : public LLInventoryCallback @@ -440,30 +440,13 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n return skyp; } -namespace -{ - // This is a disturbing hack - std::string legacy_name_to_filename(const std::string &name) - { - std::string fixedname(LLURI::escape(name)); - - boost::algorithm::replace_all(fixedname, "-", "%2D"); - return fixedname; - } -} - LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path) { - std::string full_path(path); - std::string full_name(legacy_name_to_filename(name)); - full_name += ".xml"; - - gDirUtilp->append(full_path, full_name); - LLSD legacy_data = read_legacy_preset_data(full_path); + LLSD legacy_data = read_legacy_preset_data(name, path); if (!legacy_data) { - LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } @@ -707,16 +690,11 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path) { - std::string full_path(path); - std::string full_name(legacy_name_to_filename(name)); - full_name += ".xml"; - - gDirUtilp->append(full_path, full_name); - LLSD legacy_data = read_legacy_preset_data(full_path); + LLSD legacy_data = read_legacy_preset_data(name, path); if (!legacy_data) { - LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } @@ -961,16 +939,11 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path) { - std::string full_path(path); - std::string full_name(legacy_name_to_filename(name)); - full_name += ".xml"; - - gDirUtilp->append(full_path, full_name); - LLSD legacy_data = read_legacy_preset_data(full_path); + LLSD legacy_data = read_legacy_preset_data(name, path); if (!legacy_data) { - LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } @@ -1261,15 +1234,55 @@ namespace return out; } + // This is a disturbing hack + std::string legacy_name_to_filename(const std::string &name, bool convertdash = false) + { + std::string fixedname(LLURI::escape(name)); + + if (convertdash) + boost::algorithm::replace_all(fixedname, "-", "%2D"); + + return fixedname; + } + //--------------------------------------------------------------------- - LLSD read_legacy_preset_data(const std::string& path) + LLSD read_legacy_preset_data(const std::string &name, const std::string& path) { llifstream xml_file; -// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - xml_file.open(path.c_str()); + std::string full_path(path); + std::string full_name(name); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + + xml_file.open(full_path.c_str()); if (!xml_file) - return LLSD(); + { + std::string bad_path(full_path); + full_path = path; + full_name = legacy_name_to_filename(name); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + + LL_INFOS("LEGACYSETTING") << "Could not open \"" << bad_path << "\" trying escaped \"" << full_path << "\"" << LL_ENDL; + + xml_file.open(full_path.c_str()); + if (!xml_file) + { + LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; + + full_path = path; + full_name = legacy_name_to_filename(name, true); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + xml_file.open(full_path.c_str()); + if (!xml_file) + { + LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; + return LLSD(); + } + } + } LLSD params_data; LLPointer parser = new LLSDXMLParser(); -- cgit v1.2.3 From 114e358aae80e9e3ca70de093d51e4700c46df37 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 7 Sep 2018 16:09:32 -0700 Subject: Work to make edit floaters respect no mod and no trans. Importing no-trans frame will cause day cycle to become no trans. --- indra/newview/llsettingsvo.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6426e95f6c..b16ba65c01 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -60,6 +60,8 @@ #include "lldrawpoolwater.h" #include +#include "llinventoryobserver.h" +#include "llinventorydefines.h" #undef VERIFY_LEGACY_CONVERSION @@ -177,6 +179,34 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings return; } + LLViewerInventoryItem *inv_item = gInventory.getItem(inv_item_id); + if (inv_item) + { + bool need_update(false); + LLPointer new_item = new LLViewerInventoryItem(inv_item); + + if (settings->getFlag(LLSettingsBase::FLAG_NOTRANS) && new_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) + { + LLPermissions perm(inv_item->getPermissions()); + perm.setBaseBits(LLUUID::null, FALSE, PERM_TRANSFER); + perm.setOwnerBits(LLUUID::null, FALSE, PERM_TRANSFER); + new_item->setPermissions(perm); + need_update |= true; + } + if (settings->getName() != new_item->getName()) + { + new_item->rename(settings->getName()); + settings->setName(new_item->getName()); // account for corrections + need_update |= true; + } + if (need_update) + { + new_item->updateServer(FALSE); + gInventory.updateItem(new_item); + gInventory.notifyObservers(); + } + } + std::stringstream buffer; LLSD settingdata(settings->getSettings()); LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); @@ -210,7 +240,6 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings std::stringstream buffer; LLSD settingdata(settings->getSettings()); - LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), @@ -293,6 +322,10 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i callback(asset_id, settings, status, ext_status); } +void LLSettingsVOBase::getSettingsInventory(const LLUUID &inventoryId, inventory_download_fn callback) +{ + +} bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format) { @@ -1105,6 +1138,10 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const LLSettingsDay::ptr_t dayp = std::make_shared(settings); + U32 flags = getFlags(); + if (flags) + dayp->setFlags(flags); + dayp->initialize(); return dayp; } -- cgit v1.2.3 From 862b8f72dc4d89e88b0c03992dad393aff9451a5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 18 Sep 2018 20:31:26 +0100 Subject: SL-9685 Make sure legacy opaque water texture ID is assigned so it can be bound for lowest graphics use. --- indra/newview/llsettingsvo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index b16ba65c01..583adcb024 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -851,6 +851,7 @@ void LLSettingsVOWater::updateSettings() if (pwaterpool) { pwaterpool->setTransparentTextures(getTransparentTextureID(), getNextTransparentTextureID()); + pwaterpool->setOpaqueTexture(GetDefaultOpaqueTextureAssetId()); pwaterpool->setNormalMaps(getNormalMapID(), getNextNormalMapID()); } } -- cgit v1.2.3 From 6c9e4e3cf0f7c594034025499654b920d546671a Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 21 Sep 2018 14:38:32 +0300 Subject: SL-9715 [EEP] Allow setting default creation permissions for environment settings --- indra/newview/llsettingsvo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 583adcb024..4073639a20 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -43,6 +43,7 @@ #include "llagent.h" #include "llassettype.h" +#include "llfloaterperms.h" #include "llnotificationsutil.h" #include "llviewerregion.h" @@ -95,7 +96,8 @@ namespace void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback) { LLTransactionID tid; - U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + U32 nextOwnerPerm = LLFloaterPerms::getNextOwnerPerms("Settings"); + nextOwnerPerm |= PERM_COPY; if (!LLEnvironment::instance().isInventoryEnabled()) { -- cgit v1.2.3 From 405f5c879c44f32635dcb94de2c7dfb9e4a8673a Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 26 Sep 2018 17:39:55 +0300 Subject: SL-9732 FIXED [EEP] Save As does not provide dialogue to supply new setting name --- indra/newview/llsettingsvo.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 4073639a20..26b0bcb5a3 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -119,7 +119,7 @@ void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, cons } -void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, inventory_result_fn callback) +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) { LLTransactionID tid; U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); @@ -137,9 +137,13 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings, callback); }); + if (settings_name.empty()) + { + settings_name = settings->getName(); + } create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), parent_id, tid, - settings->getName(), "new settings collection.", + settings_name, "new settings collection.", settings->getSettingsTypeValue(), nextOwnerPerm, cb); } @@ -160,10 +164,10 @@ void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSetti return; } // We need to update some inventory stuff here.... maybe. - updateInventoryItem(settings, inventoryId, callback); + updateInventoryItem(settings, inventoryId, callback, false); } -void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback) +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback, bool update_name) { const LLViewerRegion* region = gAgent.getRegion(); if (!region) @@ -195,7 +199,7 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings new_item->setPermissions(perm); need_update |= true; } - if (settings->getName() != new_item->getName()) + if (update_name && (settings->getName() != new_item->getName())) { new_item->rename(settings->getName()); settings->setName(new_item->getName()); // account for corrections -- cgit v1.2.3 From 2d5fa7a732661f97b028ddcbabdd4fb3ba825a52 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 26 Sep 2018 20:33:26 +0300 Subject: SL-1825 EEP - default description should be empty --- indra/newview/llsettingsvo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 26b0bcb5a3..8d66004ddb 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -114,7 +114,7 @@ void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, cons create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), parent_id, LLTransactionID::tnull, - LLSettingsType::getDefaultName(stype), "new settings collection.", + LLSettingsType::getDefaultName(stype), "", stype, nextOwnerPerm, cb); } @@ -143,7 +143,7 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings } create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), parent_id, tid, - settings_name, "new settings collection.", + settings_name, "", settings->getSettingsTypeValue(), nextOwnerPerm, cb); } -- cgit v1.2.3 From 5eed233618abd7020e130799be2abe0f986543f6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Oct 2018 21:32:42 +0100 Subject: SL-1925 More settings for rainbow/halo atmospheric effects, final default asset UUIDs, and shader mods. --- indra/newview/llsettingsvo.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8d66004ddb..386a5deec6 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -661,6 +661,10 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; + param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL; + param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS; + param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL; + // AdvancedAtmospherics TODO // Provide mappings for new shader params here } -- cgit v1.2.3 From f8aac192378462b5824d28808ed84833e2cbfe0f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Oct 2018 18:44:43 +0100 Subject: SL-1289 add cloud_variance control for randomized perturbance of clouds to break up tiling monotony --- indra/newview/llsettingsvo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 386a5deec6..17384a3a6b 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -657,10 +657,11 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; + param_map[SETTING_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE; param_map[SETTING_GLOW] = LLShaderMgr::GLOW; param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; - + param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS; param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL; param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS; param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL; -- cgit v1.2.3 From 79d33f9d19a0c6e5ed34ffbd01a31cb2625e1ecc Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Oct 2018 18:44:03 +0100 Subject: Fix names of WATER_BLUR_MULTIPILER. Give wave direction uniforms more meaningful names in shaders. Add comments on glow size/focus conversions for clarity. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 17384a3a6b..8e55ae395a 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -791,7 +791,7 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) LLSD legacy(LLSD::emptyMap()); LLSD settings = pwater->getSettings(); - legacy[SETTING_LEGACY_BLUR_MULTIPILER] = settings[SETTING_BLUR_MULTIPILER]; + legacy[SETTING_LEGACY_BLUR_MULTIPLIER] = settings[SETTING_BLUR_MULTIPLIER]; legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f); legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; -- cgit v1.2.3 From a639642c218161901515d74852c5b61961ce3032 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 17 Oct 2018 17:50:56 +0300 Subject: SL-9853 FIXED [EEP] Default Settings object cannot be copied by other users. --- indra/newview/llsettingsvo.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8e55ae395a..1f62b98889 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -158,6 +158,14 @@ void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSetti if (pitem) { asset_id = pitem->getAssetUUID(); + + LLPermissions perm = pitem->getPermissions(); + if (perm.getMaskEveryone() != PERM_COPY) + { + perm.setMaskEveryone(PERM_COPY); + pitem->setPermissions(perm); + pitem->updateServer(FALSE); + } } if (callback) callback(asset_id, inventoryId, LLUUID::null, LLSD()); -- cgit v1.2.3 From 6cdcc7fe2edcb6c001f2dabf48c87e00d907a4db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Oct 2018 12:16:24 -0700 Subject: SL-9889: New reconverted default assets --- indra/newview/llsettingsvo.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 1f62b98889..b33bdca512 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -270,14 +270,6 @@ void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAsset psettings->setAssetId(newAssetId); if (callback) callback( newAssetId, itemId, LLUUID::null, response ); - -#if 0 - std::string exprtFile = gDirUtilp->getTempDir() + gDirUtilp->getDirDelimiter() + newAssetId.asString() + ".llsd"; - - LLSettingsVOBase::exportFile(psettings, exprtFile, LLSDSerialize::LLSD_NOTATION); - - LL_WARNS("LAPRAS") << "SETTINGS File written as: '" << exprtFile << "'" << LL_ENDL; -#endif } void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) @@ -324,7 +316,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { - LL_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; + //_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; settings->setAssetId(asset_id); } } @@ -1043,7 +1035,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io ( SETTING_FRAMES, frames ) ( SETTING_TYPE, "daycycle" ); - LL_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; + //_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(newsettings, validations); -- cgit v1.2.3 From 3447621a15c14a6a23a9827cfbb2e244ce91e8c0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 18 Oct 2018 21:18:40 +0100 Subject: Port sim-side changes to back-conversion of new settings to legacy. Fix validating of density multiplier to clamp >= 0.0001f. Port fix to setter for ambient color in sky settings. --- indra/newview/llsettingsvo.cpp | 2724 ++++++++++++++++++++-------------------- 1 file changed, 1381 insertions(+), 1343 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8e55ae395a..f13265ae84 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -1,1343 +1,1381 @@ -/** -* @file llsettingsvo.cpp -* @author Rider Linden -* @brief Subclasses for viewer specific settings behaviors. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" -#include "llviewercontrol.h" -#include "llsettingsvo.h" - -#include "pipeline.h" - -#include -#include -#include -#include "lltrace.h" -#include "llfasttimer.h" -#include "v3colorutil.h" - -#include "llglslshader.h" -#include "llviewershadermgr.h" - -#include "llagent.h" -#include "llassettype.h" -#include "llfloaterperms.h" -#include "llnotificationsutil.h" - -#include "llviewerregion.h" -#include "llviewerassetupload.h" -#include "llviewerinventory.h" - -#include "llenvironment.h" -#include "llsky.h" - -#include "llpermissions.h" - -#include "llinventorymodel.h" -#include "llassetstorage.h" -#include "llvfile.h" -#include "lldrawpoolwater.h" - -#include -#include "llinventoryobserver.h" -#include "llinventorydefines.h" - -#undef VERIFY_LEGACY_CONVERSION - -//========================================================================= -namespace -{ - LLSD ensure_array_4(LLSD in, F32 fill); - LLSD read_legacy_preset_data(const std::string &name, const std::string& path); - - //------------------------------------------------------------------------- - class LLSettingsInventoryCB : public LLInventoryCallback - { - public: - typedef std::function callback_t; - - LLSettingsInventoryCB(callback_t cbfn) : - mCbfn(cbfn) - { } - - void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } - - private: - callback_t mCbfn; - }; - - //------------------------------------------------------------------------- -} - - -//========================================================================= -void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback) -{ - LLTransactionID tid; - U32 nextOwnerPerm = LLFloaterPerms::getNextOwnerPerms("Settings"); - nextOwnerPerm |= PERM_COPY; - - if (!LLEnvironment::instance().isInventoryEnabled()) - { - LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; - LLNotificationsUtil::add("SettingsUnsuported"); - return; - } - - tid.generate(); - - LLPointer cb = new LLSettingsInventoryCB([callback](const LLUUID &inventoryId) { - LLSettingsVOBase::onInventoryItemCreated(inventoryId, LLSettingsBase::ptr_t(), callback); - }); - - create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, - LLSettingsType::getDefaultName(stype), "", - stype, nextOwnerPerm, cb); -} - - -void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) -{ - LLTransactionID tid; - U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); - - if (!LLEnvironment::instance().isInventoryEnabled()) - { - LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; - LLNotificationsUtil::add("SettingsUnsuported"); - return; - } - - tid.generate(); - - LLPointer cb = new LLSettingsInventoryCB([settings, callback](const LLUUID &inventoryId) { - LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings, callback); - }); - - if (settings_name.empty()) - { - settings_name = settings->getName(); - } - create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), - parent_id, tid, - settings_name, "", - settings->getSettingsTypeValue(), nextOwnerPerm, cb); -} - -void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) -{ - if (!settings) - { // The item was created as new with no settings passed in. Simulator should have given it the default for the type... check ID, - // no need to upload asset. - LLUUID asset_id; - LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); - - if (pitem) - { - asset_id = pitem->getAssetUUID(); - } - if (callback) - callback(asset_id, inventoryId, LLUUID::null, LLSD()); - return; - } - // We need to update some inventory stuff here.... maybe. - updateInventoryItem(settings, inventoryId, callback, false); -} - -void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback, bool update_name) -{ - const LLViewerRegion* region = gAgent.getRegion(); - if (!region) - { - LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; - return; - } - - std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); - - if (!LLEnvironment::instance().isInventoryEnabled()) - { - LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; - LLNotificationsUtil::add("SettingsUnsuported"); - return; - } - - LLViewerInventoryItem *inv_item = gInventory.getItem(inv_item_id); - if (inv_item) - { - bool need_update(false); - LLPointer new_item = new LLViewerInventoryItem(inv_item); - - if (settings->getFlag(LLSettingsBase::FLAG_NOTRANS) && new_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) - { - LLPermissions perm(inv_item->getPermissions()); - perm.setBaseBits(LLUUID::null, FALSE, PERM_TRANSFER); - perm.setOwnerBits(LLUUID::null, FALSE, PERM_TRANSFER); - new_item->setPermissions(perm); - need_update |= true; - } - if (update_name && (settings->getName() != new_item->getName())) - { - new_item->rename(settings->getName()); - settings->setName(new_item->getName()); // account for corrections - need_update |= true; - } - if (need_update) - { - new_item->updateServer(FALSE); - gInventory.updateItem(new_item); - gInventory.notifyObservers(); - } - } - - std::stringstream buffer; - LLSD settingdata(settings->getSettings()); - LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); - - LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), - [settings, callback](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { - LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings, callback); - }); - - LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); -} - -void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id, inventory_result_fn callback) -{ - const LLViewerRegion* region = gAgent.getRegion(); - if (!region) - { - LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; - return; - } - - std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); - - if (!LLEnvironment::instance().isInventoryEnabled()) - { - LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; - LLNotificationsUtil::add("SettingsUnsuported"); - return; - } - - std::stringstream buffer; - LLSD settingdata(settings->getSettings()); - - LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); - - LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), - [settings, callback](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { - LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings, callback); - }); - - LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); -} - -void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) -{ - LL_INFOS("SETTINGS") << "itemId:" << itemId << " newAssetId:" << newAssetId << " newItemId:" << newItemId << " response:" << response << LL_ENDL; - psettings->setAssetId(newAssetId); - if (callback) - callback( newAssetId, itemId, LLUUID::null, response ); - -#if 0 - std::string exprtFile = gDirUtilp->getTempDir() + gDirUtilp->getDirDelimiter() + newAssetId.asString() + ".llsd"; - - LLSettingsVOBase::exportFile(psettings, exprtFile, LLSDSerialize::LLSD_NOTATION); - - LL_WARNS("LAPRAS") << "SETTINGS File written as: '" << exprtFile << "'" << LL_ENDL; -#endif -} - -void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) -{ - LL_INFOS("SETTINGS") << "Upload to task complete!" << LL_ENDL; - psettings->setAssetId(newAssetId); - if (callback) - callback(newAssetId, itemId, taskId, response); -} - - -void LLSettingsVOBase::getSettingsAsset(const LLUUID &assetId, LLSettingsVOBase::asset_download_fn callback) -{ - gAssetStorage->getAssetData(assetId, LLAssetType::AT_SETTINGS, - [callback](LLVFS *vfs, const LLUUID &asset_id, LLAssetType::EType, void *, S32 status, LLExtStat ext_status) - { onAssetDownloadComplete(vfs, asset_id, status, ext_status, callback); }, - nullptr, true); - -} - -void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_id, S32 status, LLExtStat ext_status, LLSettingsVOBase::asset_download_fn callback) -{ - LLSettingsBase::ptr_t settings; - if (!status) - { - LLVFile file(vfs, asset_id, LLAssetType::AT_SETTINGS, LLVFile::READ); - S32 size = file.getSize(); - - std::string buffer(size + 1, '\0'); - file.read((U8 *)buffer.data(), size); - - std::stringstream llsdstream(buffer); - LLSD llsdsettings; - - if (LLSDSerialize::deserialize(llsdsettings, llsdstream, -1)) - { - settings = createFromLLSD(llsdsettings); - } - - if (!settings) - { - status = 1; - LL_WARNS("SETTINGS") << "Unable to create settings object." << LL_ENDL; - } - else - { - LL_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; - settings->setAssetId(asset_id); - } - } - else - { - LL_WARNS("SETTINGS") << "Error retrieving asset " << asset_id << ". Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; - } - if (callback) - callback(asset_id, settings, status, ext_status); -} - -void LLSettingsVOBase::getSettingsInventory(const LLUUID &inventoryId, inventory_download_fn callback) -{ - -} - -bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format) -{ - try - { - std::ofstream file(filename, std::ios::out | std::ios::trunc); - file.exceptions(std::ios_base::failbit | std::ios_base::badbit); - - if (!file) - { - LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for writing." << LL_ENDL; - return false; - } - - LLSDSerialize::serialize(settings->getSettings(), file, format); - } - catch (const std::ios_base::failure &e) - { - LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; - return false; - } - - return true; -} - -LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) -{ - LLSD settings; - - try - { - std::ifstream file(filename, std::ios::in); - file.exceptions(std::ios_base::failbit | std::ios_base::badbit); - - if (!file) - { - LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for reading." << LL_ENDL; - return LLSettingsBase::ptr_t(); - } - - if (!LLSDSerialize::deserialize(settings, file, -1)) - { - LL_WARNS("SETTINGS") << "Unable to deserialize settings from '" << filename << "'" << LL_ENDL; - return LLSettingsBase::ptr_t(); - } - } - catch (const std::ios_base::failure &e) - { - LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; - return LLSettingsBase::ptr_t(); - } - - return createFromLLSD(settings); -} - -LLSettingsBase::ptr_t LLSettingsVOBase::createFromLLSD(const LLSD &settings) -{ - if (!settings.has(SETTING_TYPE)) - { - LL_WARNS("SETTINGS") << "No settings type in LLSD" << LL_ENDL; - return LLSettingsBase::ptr_t(); - } - - std::string settingtype = settings[SETTING_TYPE].asString(); - - LLSettingsBase::ptr_t psetting; - - if (settingtype == "water") - { - return LLSettingsVOWater::buildWater(settings); - } - else if (settingtype == "sky") - { - return LLSettingsVOSky::buildSky(settings); - } - else if (settingtype == "daycycle") - { - return LLSettingsVODay::buildDay(settings); - } - - LL_WARNS("SETTINGS") << "Unable to determine settings type for '" << settingtype << "'." << LL_ENDL; - return LLSettingsBase::ptr_t(); - -} - -//========================================================================= -LLSettingsVOSky::LLSettingsVOSky(const LLSD &data, bool isAdvanced) -: LLSettingsSky(data) -, m_isAdvanced(isAdvanced) -{ -} - -LLSettingsVOSky::LLSettingsVOSky() -: LLSettingsSky() -, m_isAdvanced(false) -{ -} - -//------------------------------------------------------------------------- -LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) -{ - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - - LLSD results = LLSettingsBase::settingValidation(settings, validations); - - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; - LLSettingsSky::ptr_t(); - } - - return std::make_shared(settings, true); -} - - -LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) -{ - - LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); - - newsettings[SETTING_NAME] = name; - - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsBase::settingValidation(newsettings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; - LLSettingsSky::ptr_t(); - } - - LLSettingsSky::ptr_t skyp = std::make_shared(newsettings); - -#ifdef VERIFY_LEGACY_CONVERSION - LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp, isAdvanced()); - - if (!llsd_equals(legacy, oldsettings)) - { - LL_WARNS("SKY") << "Conversion to/from legacy does not match!\n" - << "Old: " << legacy - << "new: " << oldsettings << LL_ENDL; - } - -#endif - - return skyp; -} - -LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path) -{ - LLSD legacy_data = read_legacy_preset_data(name, path); - - if (!legacy_data) - { - LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; - return ptr_t(); - } - - return buildFromLegacyPreset(name, legacy_data); -} - - -LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() -{ - static LLSD default_settings; - - if (!default_settings.size()) - { - default_settings = LLSettingsSky::defaults(); - - default_settings[SETTING_NAME] = std::string("_default_"); - - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsBase::settingValidation(default_settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; - LLSettingsSky::ptr_t(); - } - } - - LLSettingsSky::ptr_t skyp = std::make_shared(default_settings); - return skyp; -} - -LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const -{ - LLSD settings = cloneSettings(); - - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsBase::settingValidation(settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; - LLSettingsSky::ptr_t(); - } - - LLSettingsSky::ptr_t skyp = std::make_shared(settings); - return skyp; -} - -void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) -{ - // These will need to be inferred from new settings' density profiles - if (settings.has(SETTING_LEGACY_HAZE)) - { - LLSD legacyhaze = settings[SETTING_LEGACY_HAZE]; - legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f); - legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); - legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); - legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); - } -} - -LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) -{ - LLSD legacy(LLSD::emptyMap()); - LLSD settings = psky->getSettings(); - - convertAtmosphericsToLegacy(legacy, settings); - - legacy[SETTING_CLOUD_COLOR] = ensure_array_4(settings[SETTING_CLOUD_COLOR], 1.0); - legacy[SETTING_CLOUD_POS_DENSITY1] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); - legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); - legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); - legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; - legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) - (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); - legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); - legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); - legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); - legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); - legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; - legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); - - LLQuaternion sunquat = psky->getSunRotation(); - - F32 roll; - F32 pitch; - F32 yaw; - - // get euler angles in right-handed X right, Y up, Z at - sunquat.getEulerAngles(&roll, &pitch, &yaw); - - legacy[SETTING_LEGACY_EAST_ANGLE] = yaw; - legacy[SETTING_LEGACY_SUN_ANGLE] = -pitch; - - return legacy; -} - -//------------------------------------------------------------------------- -void LLSettingsVOSky::updateSettings() -{ - LLSettingsSky::updateSettings(); - LLVector3 sun_direction = getSunDirection(); - LLVector3 moon_direction = getMoonDirection(); - - F32 dp = getLightDirection() * LLVector3(0.0f, 0.0f, 1.0f); - if (dp < 0) - { - dp = 0; - } - dp = llmax(dp, 0.1f); - - // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio - // between sunlight and point lights in windlight to normalize point lights. - F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); - - gSky.setSunAndMoonDirectionsCFR(sun_direction, moon_direction); - gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); - gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); - gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); - gSky.setBloomTextures(getBloomTextureId(), getNextBloomTextureId()); - - gSky.setSunScale(getSunScale()); - gSky.setMoonScale(getMoonScale()); -} - -void LLSettingsVOSky::applySpecial(void *ptarget) -{ - LLGLSLShader *shader = (LLGLSLShader *)ptarget; - - LLVector4 light_direction = LLEnvironment::instance().getClampedSunNorm(); - - if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) - { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - } - else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) - { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - - LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); - vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); - shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); - } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); -} - -LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const -{ - static parammapping_t param_map; - - if (param_map.empty()) - { -// LEGACY_ATMOSPHERICS - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; - param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; - param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; - param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; - param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; - param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; - param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; - - param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; - param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; - param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; - param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; - param_map[SETTING_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE; - param_map[SETTING_GLOW] = LLShaderMgr::GLOW; - param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; - param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; - param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS; - param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL; - param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS; - param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL; - -// AdvancedAtmospherics TODO -// Provide mappings for new shader params here - } - - return param_map; -} - -//========================================================================= -const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f); - -//------------------------------------------------------------------------- -LLSettingsVOWater::LLSettingsVOWater(const LLSD &data) : - LLSettingsWater(data) -{ - -} - -LLSettingsVOWater::LLSettingsVOWater() : - LLSettingsWater() -{ - -} - -LLSettingsWater::ptr_t LLSettingsVOWater::buildWater(LLSD settings) -{ - LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); - LLSD results = LLSettingsWater::settingValidation(settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; - LLSettingsWater::ptr_t(); - } - - return std::make_shared(settings); -} - -//------------------------------------------------------------------------- -LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) -{ - LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy)); - - newsettings[SETTING_NAME] = name; - LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); - LLSD results = LLSettingsWater::settingValidation(newsettings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; - return LLSettingsWater::ptr_t(); - } - - LLSettingsWater::ptr_t waterp = std::make_shared(newsettings); - -#ifdef VERIFY_LEGACY_CONVERSION - LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); - - if (!llsd_equals(legacy, oldsettings)) - { - LL_WARNS("WATER") << "Conversion to/from legacy does not match!\n" - << "Old: " << legacy - << "new: " << oldsettings << LL_ENDL; - } - -#endif - return waterp; -} - -LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path) -{ - LLSD legacy_data = read_legacy_preset_data(name, path); - - if (!legacy_data) - { - LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; - return ptr_t(); - } - - return buildFromLegacyPreset(name, legacy_data); -} - - -LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() -{ - static LLSD default_settings; - - if (!default_settings.size()) - { - default_settings = LLSettingsWater::defaults(); - - default_settings[SETTING_NAME] = std::string("_default_"); - - LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); - LLSD results = LLSettingsWater::settingValidation(default_settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; - return LLSettingsWater::ptr_t(); - } - } - - LLSettingsWater::ptr_t waterp = std::make_shared(default_settings); - - return waterp; -} - -LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const -{ - LLSD settings = cloneSettings(); - LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); - LLSD results = LLSettingsWater::settingValidation(settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; - return LLSettingsWater::ptr_t(); - } - - LLSettingsWater::ptr_t waterp = std::make_shared(settings); - - return waterp; -} - -LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) -{ - LLSD legacy(LLSD::emptyMap()); - LLSD settings = pwater->getSettings(); - - legacy[SETTING_LEGACY_BLUR_MULTIPLIER] = settings[SETTING_BLUR_MULTIPLIER]; - legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f); - legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; - legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; - legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; - legacy[SETTING_LEGACY_FRESNEL_SCALE] = settings[SETTING_FRESNEL_SCALE]; - legacy[SETTING_LEGACY_NORMAL_MAP] = settings[SETTING_NORMAL_MAP]; - legacy[SETTING_LEGACY_NORMAL_SCALE] = settings[SETTING_NORMAL_SCALE]; - legacy[SETTING_LEGACY_SCALE_ABOVE] = settings[SETTING_SCALE_ABOVE]; - legacy[SETTING_LEGACY_SCALE_BELOW] = settings[SETTING_SCALE_BELOW]; - legacy[SETTING_LEGACY_WAVE1_DIR] = settings[SETTING_WAVE1_DIR]; - legacy[SETTING_LEGACY_WAVE2_DIR] = settings[SETTING_WAVE2_DIR]; - - //_WARNS("LAPRAS") << "Legacy water: " << legacy << LL_ENDL; - return legacy; -} -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -void LLSettingsVOWater::applySpecial(void *ptarget) -{ - LLGLSLShader *shader = (LLGLSLShader *)ptarget; - - if (shader->mShaderGroup == LLGLSLShader::SG_WATER) - { - //transform water plane to eye space - glh::vec3f norm(0.f, 0.f, 1.f); - glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); - - F32 modelView[16]; - for (U32 i = 0; i < 16; i++) - { - modelView[i] = (F32)gGLModelView[i]; - } - - glh::matrix4f mat(modelView); - glh::matrix4f invtrans = mat.inverse().transpose(); - glh::vec3f enorm; - glh::vec3f ep; - invtrans.mult_matrix_vec(norm, enorm); - enorm.normalize(); - mat.mult_matrix_vec(p, ep); - - LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); - - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, waterPlane.mV); - - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); - - F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); - - shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); - - F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); - shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - - LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); - } -} - -void LLSettingsVOWater::updateSettings() -{ - // base class clears dirty flag so as to not trigger recursive update - LLSettingsBase::updateSettings(); - - LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER); - if (pwaterpool) - { - pwaterpool->setTransparentTextures(getTransparentTextureID(), getNextTransparentTextureID()); - pwaterpool->setOpaqueTexture(GetDefaultOpaqueTextureAssetId()); - pwaterpool->setNormalMaps(getNormalMapID(), getNextNormalMapID()); - } -} - -LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const -{ - static parammapping_t param_map; - - if (param_map.empty()) - { - param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; - param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; - } - return param_map; -} - -//========================================================================= -LLSettingsVODay::LLSettingsVODay(const LLSD &data): - LLSettingsDay(data) -{} - -LLSettingsVODay::LLSettingsVODay(): - LLSettingsDay() -{} - -LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) -{ - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); - } - - LLSettingsDay::ptr_t pday = std::make_shared(settings); - if (pday) - pday->initialize(); - - return pday; -} - -//------------------------------------------------------------------------- -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings) -{ - LLSD newsettings(defaults()); - std::set framenames; - std::set notfound; - - std::string base_path(gDirUtilp->getDirName(path)); - std::string water_path(base_path); - std::string sky_path(base_path); - - gDirUtilp->append(water_path, "water"); - gDirUtilp->append(sky_path, "skies"); - - newsettings[SETTING_NAME] = name; - - LLSD watertrack = LLSDArray( - LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) - (SETTING_KEYNAME, "water:Default")); - - LLSD skytrack = LLSD::emptyArray(); - - for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) - { - std::string framename = (*it)[1].asString(); - LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) - (SETTING_KEYNAME, "sky:" + framename); - framenames.insert(framename); - skytrack.append(entry); - } - - newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); - - LLSD frames(LLSD::emptyMap()); - - { - LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path); - if (pwater) - frames["water:Default"] = pwater->getSettings(); - } - - for (std::set::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) - { - LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path); - if (psky) - frames["sky:" + (*itn)] = psky->getSettings(); - } - - newsettings[SETTING_FRAMES] = frames; - - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(newsettings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Day setting validation failed!: " << results << LL_ENDL; - return LLSettingsDay::ptr_t(); - } - - LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); - -#ifdef VERIFY_LEGACY_CONVERSION - LLSD testsettings = LLSettingsVODay::convertToLegacy(dayp); - - if (!llsd_equals(oldsettings, testsettings)) - { - LL_WARNS("DAYCYCLE") << "Conversion to/from legacy does not match!\n" - << "Old: " << oldsettings - << "new: " << testsettings << LL_ENDL; - } - -#endif - - dayp->initialize(); - - return dayp; -} - -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path) -{ - LLSD legacy_data = read_legacy_preset_data(name, path); - - if (!legacy_data) - { - LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; - return ptr_t(); - } - - return buildFromLegacyPreset(name, path, legacy_data); -} - - - -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) -{ - LLSD frames(LLSD::emptyMap()); - - for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) - { - std::string newname = "sky:" + (*itm).first; - LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second); - - newsettings[SETTING_NAME] = newname; - frames[newname] = newsettings; - - LL_WARNS("SETTINGS") << "created region sky '" << newname << "'" << LL_ENDL; - } - - LLSD watersettings = LLSettingsWater::translateLegacySettings(waterdef); - std::string watername = "water:"+ watersettings[SETTING_NAME].asString(); - watersettings[SETTING_NAME] = watername; - frames[watername] = watersettings; - - LLSD watertrack = LLSDArray( - LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) - (SETTING_KEYNAME, watername)); - - LLSD skytrack(LLSD::emptyArray()); - for (LLSD::array_const_iterator it = daycycle.beginArray(); it != daycycle.endArray(); ++it) - { - LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) - (SETTING_KEYNAME, "sky:" + (*it)[1].asString()); - skytrack.append(entry); - } - - LLSD newsettings = LLSDMap - ( SETTING_NAME, "Region (legacy)" ) - ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) - ( SETTING_FRAMES, frames ) - ( SETTING_TYPE, "daycycle" ); - - LL_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; - - LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(newsettings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Day setting validation failed!:" << results << LL_ENDL; - return LLSettingsDay::ptr_t(); - } - - LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); - - if (dayp) - { - // true for validation - either validate here, or when cloning for floater. - dayp->initialize(true); - } - return dayp; -} - - - -LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() -{ - static LLSD default_settings; - - if (!default_settings.size()) - { - default_settings = LLSettingsDay::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); - - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(default_settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); - } - } - - LLSettingsDay::ptr_t dayp = std::make_shared(default_settings); - - dayp->initialize(); - return dayp; -} - -LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) -{ - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); - } - - LLSettingsDay::ptr_t dayp = std::make_shared(settings); - - dayp->initialize(); - return dayp; -} - - -void LLSettingsVODay::buildFromOtherSetting(LLSettingsBase::ptr_t settings, LLSettingsVODay::asset_built_fn cb) -{ - if (settings->getSettingsType() == "daycycle") - { - if (cb) - cb(std::static_pointer_cast(settings)); - } - else - { - LLSettingsVOBase::getSettingsAsset(LLSettingsDay::GetDefaultAssetId(), - [settings, cb](LLUUID, LLSettingsBase::ptr_t pday, S32, LLExtStat){ combineIntoDayCycle(std::static_pointer_cast(pday), settings, cb); }); - } -} - -void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsBase::ptr_t settings, asset_built_fn cb) -{ - if (settings->getSettingsType() == "sky") - { - pday->setName("sky: " + settings->getName()); - pday->clearCycleTrack(1); - pday->setSettingsAtKeyframe(settings, 0.0, 1); - } - else if (settings->getSettingsType() == "water") - { - pday->setName("water: " + settings->getName()); - pday->clearCycleTrack(0); - pday->setSettingsAtKeyframe(settings, 0.0, 0); - } - else - { - pday.reset(); - } - - if (cb) - cb(pday); -} - - -LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const -{ - LLSD settings = cloneSettings(); - - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(settings, validations); - if (!results["success"].asBoolean()) - { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); - } - - LLSettingsDay::ptr_t dayp = std::make_shared(settings); - - U32 flags = getFlags(); - if (flags) - dayp->setFlags(flags); - - dayp->initialize(); - return dayp; -} - -LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const -{ - // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD - LLSD settings = llsd_clone(mSettings); - - LLSettingsDay::ptr_t day_clone = std::make_shared(settings); - - for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i) - { - const LLSettingsDay::CycleTrack_t& track = getCycleTrackConst(i); - LLSettingsDay::CycleTrack_t::const_iterator iter = track.begin(); - while (iter != track.end()) - { - // 'Unpack', usually for editing - // - frames 'share' settings multiple times - // - settings can reuse LLSDs they were initialized from - // We do not want for edited frame to change multiple frames in same track, so do a clone - day_clone->setSettingsAtKeyframe(iter->second->buildDerivedClone(), iter->first, i); - iter++; - } - } - return day_clone; -} - -LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) -{ - CycleTrack_t &trackwater = pday->getCycleTrack(TRACK_WATER); - - LLSettingsWater::ptr_t pwater; - if (!trackwater.empty()) - { - pwater = std::static_pointer_cast((*trackwater.begin()).second); - } - - if (!pwater) - pwater = LLSettingsVOWater::buildDefaultWater(); - - LLSD llsdwater = LLSettingsVOWater::convertToLegacy(pwater); - - CycleTrack_t &tracksky = pday->getCycleTrack(1); // first sky track - std::map skys; - - LLSD llsdcycle(LLSD::emptyArray()); - - for(CycleTrack_t::iterator it = tracksky.begin(); it != tracksky.end(); ++it) - { - size_t hash = (*it).second->getHash(); - std::stringstream name; - - name << hash; - - skys[name.str()] = std::static_pointer_cast((*it).second); - - F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; - llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); - } - //_WARNS("LAPRAS") << "Cycle created with " << llsdcycle.size() << "entries: " << llsdcycle << LL_ENDL; - - LLSD llsdskylist(LLSD::emptyMap()); - - for (std::map::iterator its = skys.begin(); its != skys.end(); ++its) - { - LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second, false); - llsdsky[SETTING_NAME] = (*its).first; - - llsdskylist[(*its).first] = llsdsky; - } - - //_WARNS("LAPRAS") << "Sky map with " << llsdskylist.size() << " entries created: " << llsdskylist << LL_ENDL; - - return LLSDArray(LLSD::emptyMap())(llsdcycle)(llsdskylist)(llsdwater); -} - -LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const -{ - return LLSettingsVOSky::buildDefaultSky(); -} - -LLSettingsWaterPtr_t LLSettingsVODay::getDefaultWater() const -{ - return LLSettingsVOWater::buildDefaultWater(); -} - -LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const -{ - LLSettingsSky::ptr_t skyp = std::make_shared(settings); - - if (skyp->validate()) - return skyp; - - return LLSettingsSky::ptr_t(); -} - -LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const -{ - LLSettingsWater::ptr_t waterp = std::make_shared(settings); - - if (waterp->validate()) - return waterp; - - return LLSettingsWater::ptr_t(); -} - -//========================================================================= -namespace -{ - LLSD ensure_array_4(LLSD in, F32 fill) - { - if (in.size() >= 4) - return in; - - LLSD out(LLSD::emptyArray()); - - for (S32 idx = 0; idx < in.size(); ++idx) - { - out.append(in[idx]); - } - - while (out.size() < 4) - { - out.append(LLSD::Real(fill)); - } - return out; - } - - // This is a disturbing hack - std::string legacy_name_to_filename(const std::string &name, bool convertdash = false) - { - std::string fixedname(LLURI::escape(name)); - - if (convertdash) - boost::algorithm::replace_all(fixedname, "-", "%2D"); - - return fixedname; - } - - //--------------------------------------------------------------------- - LLSD read_legacy_preset_data(const std::string &name, const std::string& path) - { - llifstream xml_file; - - std::string full_path(path); - std::string full_name(name); - full_name += ".xml"; - gDirUtilp->append(full_path, full_name); - - xml_file.open(full_path.c_str()); - if (!xml_file) - { - std::string bad_path(full_path); - full_path = path; - full_name = legacy_name_to_filename(name); - full_name += ".xml"; - gDirUtilp->append(full_path, full_name); - - LL_INFOS("LEGACYSETTING") << "Could not open \"" << bad_path << "\" trying escaped \"" << full_path << "\"" << LL_ENDL; - - xml_file.open(full_path.c_str()); - if (!xml_file) - { - LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; - - full_path = path; - full_name = legacy_name_to_filename(name, true); - full_name += ".xml"; - gDirUtilp->append(full_path, full_name); - xml_file.open(full_path.c_str()); - if (!xml_file) - { - LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; - return LLSD(); - } - } - } - - LLSD params_data; - LLPointer parser = new LLSDXMLParser(); - parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); - xml_file.close(); - - return params_data; - } -} +/** +* @file llsettingsvo.cpp +* @author Rider Linden +* @brief Subclasses for viewer specific settings behaviors. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llviewercontrol.h" +#include "llsettingsvo.h" + +#include "pipeline.h" + +#include +#include +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +#include "llglslshader.h" +#include "llviewershadermgr.h" + +#include "llagent.h" +#include "llassettype.h" +#include "llfloaterperms.h" +#include "llnotificationsutil.h" + +#include "llviewerregion.h" +#include "llviewerassetupload.h" +#include "llviewerinventory.h" + +#include "llenvironment.h" +#include "llsky.h" + +#include "llpermissions.h" + +#include "llinventorymodel.h" +#include "llassetstorage.h" +#include "llvfile.h" +#include "lldrawpoolwater.h" + +#include +#include "llinventoryobserver.h" +#include "llinventorydefines.h" + +#undef VERIFY_LEGACY_CONVERSION + +//========================================================================= +namespace +{ + LLSD ensure_array_4(LLSD in, F32 fill); + LLSD read_legacy_preset_data(const std::string &name, const std::string& path); + + //------------------------------------------------------------------------- + class LLSettingsInventoryCB : public LLInventoryCallback + { + public: + typedef std::function callback_t; + + LLSettingsInventoryCB(callback_t cbfn) : + mCbfn(cbfn) + { } + + void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } + + private: + callback_t mCbfn; + }; + + //------------------------------------------------------------------------- +} + + +//========================================================================= +void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback) +{ + LLTransactionID tid; + U32 nextOwnerPerm = LLFloaterPerms::getNextOwnerPerms("Settings"); + nextOwnerPerm |= PERM_COPY; + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + tid.generate(); + + LLPointer cb = new LLSettingsInventoryCB([callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, LLSettingsBase::ptr_t(), callback); + }); + + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, + LLSettingsType::getDefaultName(stype), "", + stype, nextOwnerPerm, cb); +} + + +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) +{ + LLTransactionID tid; + U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + tid.generate(); + + LLPointer cb = new LLSettingsInventoryCB([settings, callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings, callback); + }); + + if (settings_name.empty()) + { + settings_name = settings->getName(); + } + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parent_id, tid, + settings_name, "", + settings->getSettingsTypeValue(), nextOwnerPerm, cb); +} + +void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) +{ + if (!settings) + { // The item was created as new with no settings passed in. Simulator should have given it the default for the type... check ID, + // no need to upload asset. + LLUUID asset_id; + LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); + + if (pitem) + { + asset_id = pitem->getAssetUUID(); + } + if (callback) + callback(asset_id, inventoryId, LLUUID::null, LLSD()); + return; + } + // We need to update some inventory stuff here.... maybe. + updateInventoryItem(settings, inventoryId, callback, false); +} + +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback, bool update_name) +{ + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; + return; + } + + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + LLViewerInventoryItem *inv_item = gInventory.getItem(inv_item_id); + if (inv_item) + { + bool need_update(false); + LLPointer new_item = new LLViewerInventoryItem(inv_item); + + if (settings->getFlag(LLSettingsBase::FLAG_NOTRANS) && new_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) + { + LLPermissions perm(inv_item->getPermissions()); + perm.setBaseBits(LLUUID::null, FALSE, PERM_TRANSFER); + perm.setOwnerBits(LLUUID::null, FALSE, PERM_TRANSFER); + new_item->setPermissions(perm); + need_update |= true; + } + if (update_name && (settings->getName() != new_item->getName())) + { + new_item->rename(settings->getName()); + settings->setName(new_item->getName()); // account for corrections + need_update |= true; + } + if (need_update) + { + new_item->updateServer(FALSE); + gInventory.updateItem(new_item); + gInventory.notifyObservers(); + } + } + + std::stringstream buffer; + LLSD settingdata(settings->getSettings()); + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); + + LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), + [settings, callback](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { + LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings, callback); + }); + + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); +} + +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id, inventory_result_fn callback) +{ + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; + return; + } + + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + std::stringstream buffer; + LLSD settingdata(settings->getSettings()); + + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); + + LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), + [settings, callback](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { + LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings, callback); + }); + + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); +} + +void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) +{ + LL_INFOS("SETTINGS") << "itemId:" << itemId << " newAssetId:" << newAssetId << " newItemId:" << newItemId << " response:" << response << LL_ENDL; + psettings->setAssetId(newAssetId); + if (callback) + callback( newAssetId, itemId, LLUUID::null, response ); + +#if 0 + std::string exprtFile = gDirUtilp->getTempDir() + gDirUtilp->getDirDelimiter() + newAssetId.asString() + ".llsd"; + + LLSettingsVOBase::exportFile(psettings, exprtFile, LLSDSerialize::LLSD_NOTATION); + + LL_WARNS("LAPRAS") << "SETTINGS File written as: '" << exprtFile << "'" << LL_ENDL; +#endif +} + +void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) +{ + LL_INFOS("SETTINGS") << "Upload to task complete!" << LL_ENDL; + psettings->setAssetId(newAssetId); + if (callback) + callback(newAssetId, itemId, taskId, response); +} + + +void LLSettingsVOBase::getSettingsAsset(const LLUUID &assetId, LLSettingsVOBase::asset_download_fn callback) +{ + gAssetStorage->getAssetData(assetId, LLAssetType::AT_SETTINGS, + [callback](LLVFS *vfs, const LLUUID &asset_id, LLAssetType::EType, void *, S32 status, LLExtStat ext_status) + { onAssetDownloadComplete(vfs, asset_id, status, ext_status, callback); }, + nullptr, true); + +} + +void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_id, S32 status, LLExtStat ext_status, LLSettingsVOBase::asset_download_fn callback) +{ + LLSettingsBase::ptr_t settings; + if (!status) + { + LLVFile file(vfs, asset_id, LLAssetType::AT_SETTINGS, LLVFile::READ); + S32 size = file.getSize(); + + std::string buffer(size + 1, '\0'); + file.read((U8 *)buffer.data(), size); + + std::stringstream llsdstream(buffer); + LLSD llsdsettings; + + if (LLSDSerialize::deserialize(llsdsettings, llsdstream, -1)) + { + settings = createFromLLSD(llsdsettings); + } + + if (!settings) + { + status = 1; + LL_WARNS("SETTINGS") << "Unable to create settings object." << LL_ENDL; + } + else + { + LL_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; + settings->setAssetId(asset_id); + } + } + else + { + LL_WARNS("SETTINGS") << "Error retrieving asset " << asset_id << ". Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; + } + if (callback) + callback(asset_id, settings, status, ext_status); +} + +void LLSettingsVOBase::getSettingsInventory(const LLUUID &inventoryId, inventory_download_fn callback) +{ + +} + +bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format) +{ + try + { + std::ofstream file(filename, std::ios::out | std::ios::trunc); + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + + if (!file) + { + LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for writing." << LL_ENDL; + return false; + } + + LLSDSerialize::serialize(settings->getSettings(), file, format); + } + catch (const std::ios_base::failure &e) + { + LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; + return false; + } + + return true; +} + +LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) +{ + LLSD settings; + + try + { + std::ifstream file(filename, std::ios::in); + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + + if (!file) + { + LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for reading." << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + if (!LLSDSerialize::deserialize(settings, file, -1)) + { + LL_WARNS("SETTINGS") << "Unable to deserialize settings from '" << filename << "'" << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + } + catch (const std::ios_base::failure &e) + { + LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + return createFromLLSD(settings); +} + +LLSettingsBase::ptr_t LLSettingsVOBase::createFromLLSD(const LLSD &settings) +{ + if (!settings.has(SETTING_TYPE)) + { + LL_WARNS("SETTINGS") << "No settings type in LLSD" << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + std::string settingtype = settings[SETTING_TYPE].asString(); + + LLSettingsBase::ptr_t psetting; + + if (settingtype == "water") + { + return LLSettingsVOWater::buildWater(settings); + } + else if (settingtype == "sky") + { + return LLSettingsVOSky::buildSky(settings); + } + else if (settingtype == "daycycle") + { + return LLSettingsVODay::buildDay(settings); + } + + LL_WARNS("SETTINGS") << "Unable to determine settings type for '" << settingtype << "'." << LL_ENDL; + return LLSettingsBase::ptr_t(); + +} + +//========================================================================= +LLSettingsVOSky::LLSettingsVOSky(const LLSD &data, bool isAdvanced) +: LLSettingsSky(data) +, m_isAdvanced(isAdvanced) +{ +} + +LLSettingsVOSky::LLSettingsVOSky() +: LLSettingsSky() +, m_isAdvanced(false) +{ +} + +//------------------------------------------------------------------------- +LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) +{ + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + + LLSD results = LLSettingsBase::settingValidation(settings, validations); + + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + return std::make_shared(settings, true); +} + + +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +{ + + LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); + + newsettings[SETTING_NAME] = name; + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + LLSettingsSky::ptr_t skyp = std::make_shared(newsettings); + +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp, isAdvanced()); + + if (!llsd_equals(legacy, oldsettings)) + { + LL_WARNS("SKY") << "Conversion to/from legacy does not match!\n" + << "Old: " << legacy + << "new: " << oldsettings << LL_ENDL; + } + +#endif + + return skyp; +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + LLSD legacy_data = read_legacy_preset_data(name, path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data); +} + + +LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() +{ + static LLSD default_settings; + + if (!default_settings.size()) + { + default_settings = LLSettingsSky::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + } + + LLSettingsSky::ptr_t skyp = std::make_shared(default_settings); + return skyp; +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const +{ + LLSD settings = cloneSettings(); + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + LLSettingsSky::ptr_t skyp = std::make_shared(settings); + return skyp; +} + +void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) +{ + // These may need to be inferred from new settings' density profiles + // if the legacy settings values are not available. + if (settings.has(SETTING_LEGACY_HAZE)) + { + LLSD legacyhaze = settings[SETTING_LEGACY_HAZE]; + + // work-around for setter formerly putting ambient values in wrong loc... + if (legacyhaze.has(SETTING_AMBIENT)) + { + legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f); + } + else if (settings.has(SETTING_AMBIENT)) + { + legacy[SETTING_AMBIENT] = ensure_array_4(settings[SETTING_AMBIENT], 1.0f); + } + + legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); + + F32 density_multiplier = legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal(); + density_multiplier = (density_multiplier < 0.0001f) ? 0.0001f : density_multiplier; + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(density_multiplier)(0.0f)(0.0f)(1.0f); + + F32 distance_multiplier = legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal(); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(distance_multiplier)(0.0f)(0.0f)(1.0f); + + legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + } +} + +LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = psky->getSettings(); + + convertAtmosphericsToLegacy(legacy, settings); + + legacy[SETTING_CLOUD_COLOR] = ensure_array_4(settings[SETTING_CLOUD_COLOR], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY1] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); + legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); + legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; + legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) + (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); + legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); + legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); + legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); + legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); + legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; + legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); + + LLVector3 dir = psky->getLightDirection(); + + F32 phi = asin(dir.mV[2]); + F32 cos_phi = cosf(phi); + F32 theta = (cos_phi != 0) ? asin(dir.mV[1] / cos_phi) : 0.0f; + + theta = -theta; + + // get angles back into valid ranges for legacy viewer... + // + while (theta < 0) + { + theta += F_PI * 2; + } + + if (theta > 4 * F_PI) + { + theta = fmod(theta, 2 * F_PI); + } + + while (phi < -F_PI) + { + phi += 2 * F_PI; + } + + if (phi > 3 * F_PI) + { + phi = F_PI + fmod(phi - F_PI, 2 * F_PI); + } + + legacy[SETTING_LEGACY_EAST_ANGLE] = theta; + legacy[SETTING_LEGACY_SUN_ANGLE] = phi; + + return legacy; +} + +//------------------------------------------------------------------------- +void LLSettingsVOSky::updateSettings() +{ + LLSettingsSky::updateSettings(); + LLVector3 sun_direction = getSunDirection(); + LLVector3 moon_direction = getMoonDirection(); + + F32 dp = getLightDirection() * LLVector3(0.0f, 0.0f, 1.0f); + if (dp < 0) + { + dp = 0; + } + dp = llmax(dp, 0.1f); + + // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio + // between sunlight and point lights in windlight to normalize point lights. + F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); + mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + + gSky.setSunAndMoonDirectionsCFR(sun_direction, moon_direction); + gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); + gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); + gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); + gSky.setBloomTextures(getBloomTextureId(), getNextBloomTextureId()); + + gSky.setSunScale(getSunScale()); + gSky.setMoonScale(getMoonScale()); +} + +void LLSettingsVOSky::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + LLVector4 light_direction = LLEnvironment::instance().getClampedSunNorm(); + + if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + } + else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + } + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); +} + +LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { +// LEGACY_ATMOSPHERICS + param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; + param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; + param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; + param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; + param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; + param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; + param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; + + param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; + param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; + param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; + param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; + param_map[SETTING_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE; + param_map[SETTING_GLOW] = LLShaderMgr::GLOW; + param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; + param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; + param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS; + param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL; + param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS; + param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL; + +// AdvancedAtmospherics TODO +// Provide mappings for new shader params here + } + + return param_map; +} + +//========================================================================= +const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f); + +//------------------------------------------------------------------------- +LLSettingsVOWater::LLSettingsVOWater(const LLSD &data) : + LLSettingsWater(data) +{ + +} + +LLSettingsVOWater::LLSettingsVOWater() : + LLSettingsWater() +{ + +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildWater(LLSD settings) +{ + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsWater::ptr_t(); + } + + return std::make_shared(settings); +} + +//------------------------------------------------------------------------- +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +{ + LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy)); + + newsettings[SETTING_NAME] = name; + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + + LLSettingsWater::ptr_t waterp = std::make_shared(newsettings); + +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); + + if (!llsd_equals(legacy, oldsettings)) + { + LL_WARNS("WATER") << "Conversion to/from legacy does not match!\n" + << "Old: " << legacy + << "new: " << oldsettings << LL_ENDL; + } + +#endif + return waterp; +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + LLSD legacy_data = read_legacy_preset_data(name, path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data); +} + + +LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() +{ + static LLSD default_settings; + + if (!default_settings.size()) + { + default_settings = LLSettingsWater::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + } + + LLSettingsWater::ptr_t waterp = std::make_shared(default_settings); + + return waterp; +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const +{ + LLSD settings = cloneSettings(); + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + + LLSettingsWater::ptr_t waterp = std::make_shared(settings); + + return waterp; +} + +LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = pwater->getSettings(); + + legacy[SETTING_LEGACY_BLUR_MULTIPLIER] = settings[SETTING_BLUR_MULTIPLIER]; + legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f); + legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; + legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; + legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; + legacy[SETTING_LEGACY_FRESNEL_SCALE] = settings[SETTING_FRESNEL_SCALE]; + legacy[SETTING_LEGACY_NORMAL_MAP] = settings[SETTING_NORMAL_MAP]; + legacy[SETTING_LEGACY_NORMAL_SCALE] = settings[SETTING_NORMAL_SCALE]; + legacy[SETTING_LEGACY_SCALE_ABOVE] = settings[SETTING_SCALE_ABOVE]; + legacy[SETTING_LEGACY_SCALE_BELOW] = settings[SETTING_SCALE_BELOW]; + legacy[SETTING_LEGACY_WAVE1_DIR] = settings[SETTING_WAVE1_DIR]; + legacy[SETTING_LEGACY_WAVE2_DIR] = settings[SETTING_WAVE2_DIR]; + + //_WARNS("LAPRAS") << "Legacy water: " << legacy << LL_ENDL; + return legacy; +} +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- +void LLSettingsVOWater::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + if (shader->mShaderGroup == LLGLSLShader::SG_WATER) + { + //transform water plane to eye space + glh::vec3f norm(0.f, 0.f, 1.f); + glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); + + F32 modelView[16]; + for (U32 i = 0; i < 16; i++) + { + modelView[i] = (F32)gGLModelView[i]; + } + + glh::matrix4f mat(modelView); + glh::matrix4f invtrans = mat.inverse().transpose(); + glh::vec3f enorm; + glh::vec3f ep; + invtrans.mult_matrix_vec(norm, enorm); + enorm.normalize(); + mat.mult_matrix_vec(p, ep); + + LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, waterPlane.mV); + + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + + F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); + + shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); + + F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); + shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + } +} + +void LLSettingsVOWater::updateSettings() +{ + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER); + if (pwaterpool) + { + pwaterpool->setTransparentTextures(getTransparentTextureID(), getNextTransparentTextureID()); + pwaterpool->setOpaqueTexture(GetDefaultOpaqueTextureAssetId()); + pwaterpool->setNormalMaps(getNormalMapID(), getNextNormalMapID()); + } +} + +LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { + param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; + param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; + } + return param_map; +} + +//========================================================================= +LLSettingsVODay::LLSettingsVODay(const LLSD &data): + LLSettingsDay(data) +{} + +LLSettingsVODay::LLSettingsVODay(): + LLSettingsDay() +{} + +LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) +{ + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t pday = std::make_shared(settings); + if (pday) + pday->initialize(); + + return pday; +} + +//------------------------------------------------------------------------- +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings) +{ + LLSD newsettings(defaults()); + std::set framenames; + std::set notfound; + + std::string base_path(gDirUtilp->getDirName(path)); + std::string water_path(base_path); + std::string sky_path(base_path); + + gDirUtilp->append(water_path, "water"); + gDirUtilp->append(sky_path, "skies"); + + newsettings[SETTING_NAME] = name; + + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, "water:Default")); + + LLSD skytrack = LLSD::emptyArray(); + + for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) + { + std::string framename = (*it)[1].asString(); + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, "sky:" + framename); + framenames.insert(framename); + skytrack.append(entry); + } + + newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); + + LLSD frames(LLSD::emptyMap()); + + { + LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path); + if (pwater) + frames["water:Default"] = pwater->getSettings(); + } + + for (std::set::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) + { + LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path); + if (psky) + frames["sky:" + (*itn)] = psky->getSettings(); + } + + newsettings[SETTING_FRAMES] = frames; + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!: " << results << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); + +#ifdef VERIFY_LEGACY_CONVERSION + LLSD testsettings = LLSettingsVODay::convertToLegacy(dayp); + + if (!llsd_equals(oldsettings, testsettings)) + { + LL_WARNS("DAYCYCLE") << "Conversion to/from legacy does not match!\n" + << "Old: " << oldsettings + << "new: " << testsettings << LL_ENDL; + } + +#endif + + dayp->initialize(); + + return dayp; +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + LLSD legacy_data = read_legacy_preset_data(name, path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, path, legacy_data); +} + + + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) +{ + LLSD frames(LLSD::emptyMap()); + + for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) + { + std::string newname = "sky:" + (*itm).first; + LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second); + + newsettings[SETTING_NAME] = newname; + frames[newname] = newsettings; + + LL_WARNS("SETTINGS") << "created region sky '" << newname << "'" << LL_ENDL; + } + + LLSD watersettings = LLSettingsWater::translateLegacySettings(waterdef); + std::string watername = "water:"+ watersettings[SETTING_NAME].asString(); + watersettings[SETTING_NAME] = watername; + frames[watername] = watersettings; + + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, watername)); + + LLSD skytrack(LLSD::emptyArray()); + for (LLSD::array_const_iterator it = daycycle.beginArray(); it != daycycle.endArray(); ++it) + { + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, "sky:" + (*it)[1].asString()); + skytrack.append(entry); + } + + LLSD newsettings = LLSDMap + ( SETTING_NAME, "Region (legacy)" ) + ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) + ( SETTING_FRAMES, frames ) + ( SETTING_TYPE, "daycycle" ); + + LL_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; + + LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!:" << results << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared(newsettings); + + if (dayp) + { + // true for validation - either validate here, or when cloning for floater. + dayp->initialize(true); + } + return dayp; +} + + + +LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() +{ + static LLSD default_settings; + + if (!default_settings.size()) + { + default_settings = LLSettingsDay::defaults(); + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + } + + LLSettingsDay::ptr_t dayp = std::make_shared(default_settings); + + dayp->initialize(); + return dayp; +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) +{ + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared(settings); + + dayp->initialize(); + return dayp; +} + + +void LLSettingsVODay::buildFromOtherSetting(LLSettingsBase::ptr_t settings, LLSettingsVODay::asset_built_fn cb) +{ + if (settings->getSettingsType() == "daycycle") + { + if (cb) + cb(std::static_pointer_cast(settings)); + } + else + { + LLSettingsVOBase::getSettingsAsset(LLSettingsDay::GetDefaultAssetId(), + [settings, cb](LLUUID, LLSettingsBase::ptr_t pday, S32, LLExtStat){ combineIntoDayCycle(std::static_pointer_cast(pday), settings, cb); }); + } +} + +void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsBase::ptr_t settings, asset_built_fn cb) +{ + if (settings->getSettingsType() == "sky") + { + pday->setName("sky: " + settings->getName()); + pday->clearCycleTrack(1); + pday->setSettingsAtKeyframe(settings, 0.0, 1); + } + else if (settings->getSettingsType() == "water") + { + pday->setName("water: " + settings->getName()); + pday->clearCycleTrack(0); + pday->setSettingsAtKeyframe(settings, 0.0, 0); + } + else + { + pday.reset(); + } + + if (cb) + cb(pday); +} + + +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const +{ + LLSD settings = cloneSettings(); + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared(settings); + + U32 flags = getFlags(); + if (flags) + dayp->setFlags(flags); + + dayp->initialize(); + return dayp; +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const +{ + // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD + LLSD settings = llsd_clone(mSettings); + + LLSettingsDay::ptr_t day_clone = std::make_shared(settings); + + for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i) + { + const LLSettingsDay::CycleTrack_t& track = getCycleTrackConst(i); + LLSettingsDay::CycleTrack_t::const_iterator iter = track.begin(); + while (iter != track.end()) + { + // 'Unpack', usually for editing + // - frames 'share' settings multiple times + // - settings can reuse LLSDs they were initialized from + // We do not want for edited frame to change multiple frames in same track, so do a clone + day_clone->setSettingsAtKeyframe(iter->second->buildDerivedClone(), iter->first, i); + iter++; + } + } + return day_clone; +} + +LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) +{ + CycleTrack_t &trackwater = pday->getCycleTrack(TRACK_WATER); + + LLSettingsWater::ptr_t pwater; + if (!trackwater.empty()) + { + pwater = std::static_pointer_cast((*trackwater.begin()).second); + } + + if (!pwater) + pwater = LLSettingsVOWater::buildDefaultWater(); + + LLSD llsdwater = LLSettingsVOWater::convertToLegacy(pwater); + + CycleTrack_t &tracksky = pday->getCycleTrack(1); // first sky track + std::map skys; + + LLSD llsdcycle(LLSD::emptyArray()); + + for(CycleTrack_t::iterator it = tracksky.begin(); it != tracksky.end(); ++it) + { + size_t hash = (*it).second->getHash(); + std::stringstream name; + + name << hash; + + skys[name.str()] = std::static_pointer_cast((*it).second); + + F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; + llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); + } + //_WARNS("LAPRAS") << "Cycle created with " << llsdcycle.size() << "entries: " << llsdcycle << LL_ENDL; + + LLSD llsdskylist(LLSD::emptyMap()); + + for (std::map::iterator its = skys.begin(); its != skys.end(); ++its) + { + LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second, false); + llsdsky[SETTING_NAME] = (*its).first; + + llsdskylist[(*its).first] = llsdsky; + } + + //_WARNS("LAPRAS") << "Sky map with " << llsdskylist.size() << " entries created: " << llsdskylist << LL_ENDL; + + return LLSDArray(LLSD::emptyMap())(llsdcycle)(llsdskylist)(llsdwater); +} + +LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const +{ + return LLSettingsVOSky::buildDefaultSky(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::getDefaultWater() const +{ + return LLSettingsVOWater::buildDefaultWater(); +} + +LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const +{ + LLSettingsSky::ptr_t skyp = std::make_shared(settings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const +{ + LLSettingsWater::ptr_t waterp = std::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +//========================================================================= +namespace +{ + LLSD ensure_array_4(LLSD in, F32 fill) + { + if (in.size() >= 4) + return in; + + LLSD out(LLSD::emptyArray()); + + for (S32 idx = 0; idx < in.size(); ++idx) + { + out.append(in[idx]); + } + + while (out.size() < 4) + { + out.append(LLSD::Real(fill)); + } + return out; + } + + // This is a disturbing hack + std::string legacy_name_to_filename(const std::string &name, bool convertdash = false) + { + std::string fixedname(LLURI::escape(name)); + + if (convertdash) + boost::algorithm::replace_all(fixedname, "-", "%2D"); + + return fixedname; + } + + //--------------------------------------------------------------------- + LLSD read_legacy_preset_data(const std::string &name, const std::string& path) + { + llifstream xml_file; + + std::string full_path(path); + std::string full_name(name); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + + xml_file.open(full_path.c_str()); + if (!xml_file) + { + std::string bad_path(full_path); + full_path = path; + full_name = legacy_name_to_filename(name); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + + LL_INFOS("LEGACYSETTING") << "Could not open \"" << bad_path << "\" trying escaped \"" << full_path << "\"" << LL_ENDL; + + xml_file.open(full_path.c_str()); + if (!xml_file) + { + LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; + + full_path = path; + full_name = legacy_name_to_filename(name, true); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + xml_file.open(full_path.c_str()); + if (!xml_file) + { + LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; + return LLSD(); + } + } + } + + LLSD params_data; + LLPointer parser = new LLSDXMLParser(); + parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + xml_file.close(); + + return params_data; + } +} -- cgit v1.2.3 From 659d14504f6ab4ad283efe4ecd950a4483e1498f Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 29 Oct 2018 18:18:20 +0200 Subject: SL-1476 EEP Better shader resets and transitions --- indra/newview/llsettingsvo.cpp | 50 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index dad7fc9448..2696ad4df5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -683,26 +683,31 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { // LEGACY_ATMOSPHERICS - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; - param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; - param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; - param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; - param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; - param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; - param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; - - param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; - param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; - param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; - param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; - param_map[SETTING_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE; - param_map[SETTING_GLOW] = LLShaderMgr::GLOW; - param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; - param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; - param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS; - param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL; - param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS; - param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL; + + // Todo: default 'legacy' values duplicate the ones from functions like getBlueDensity() find a better home for them + // There is LLSettingsSky::defaults(), but it doesn't contain everything since it is geared towards creating new settings. + param_map[SETTING_AMBIENT] = DefaultParam(LLShaderMgr::AMBIENT, LLColor3(0.25f, 0.25f, 0.25f).getValue()); + param_map[SETTING_BLUE_DENSITY] = DefaultParam(LLShaderMgr::BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f).getValue()); + param_map[SETTING_BLUE_HORIZON] = DefaultParam(LLShaderMgr::BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f).getValue()); + param_map[SETTING_HAZE_DENSITY] = DefaultParam(LLShaderMgr::HAZE_DENSITY, LLSD(0.7f)); + param_map[SETTING_HAZE_HORIZON] = DefaultParam(LLShaderMgr::HAZE_HORIZON, LLSD(0.19f)); + param_map[SETTING_DENSITY_MULTIPLIER] = DefaultParam(LLShaderMgr::DENSITY_MULTIPLIER, LLSD(0.0001f)); + param_map[SETTING_DISTANCE_MULTIPLIER] = DefaultParam(LLShaderMgr::DISTANCE_MULTIPLIER, LLSD(0.8f)); + + // Following values are always present, so we can just zero these ones, but used values from defaults() + LLSD& sky_defaults = LLSettingsSky::defaults(); + param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]); + param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]); + param_map[SETTING_CLOUD_SHADOW] = DefaultParam(LLShaderMgr::CLOUD_SHADOW, sky_defaults[SETTING_CLOUD_SHADOW]); + param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); + param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); + param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); + param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); + param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); + param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); + param_map[SETTING_SKY_ICE_LEVEL] = DefaultParam(LLShaderMgr::ICE_LEVEL, sky_defaults[SETTING_SKY_ICE_LEVEL]); // AdvancedAtmospherics TODO // Provide mappings for new shader params here @@ -911,8 +916,9 @@ LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const if (param_map.empty()) { - param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; - param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; + LLSD &water_defaults = LLSettingsWater::defaults(); + param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); + param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); } return param_map; } -- cgit v1.2.3 From fb335cc243581925bb772a1f10112ec493db8552 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 1 Nov 2018 18:26:24 +0100 Subject: SL-10000 fix storing of ambient value when converting legacy settings --- indra/newview/llsettingsvo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 2696ad4df5..3925f37703 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -695,7 +695,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_DISTANCE_MULTIPLIER] = DefaultParam(LLShaderMgr::DISTANCE_MULTIPLIER, LLSD(0.8f)); // Following values are always present, so we can just zero these ones, but used values from defaults() - LLSD& sky_defaults = LLSettingsSky::defaults(); + LLSD sky_defaults = LLSettingsSky::defaults(); param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]); param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]); @@ -916,7 +916,7 @@ LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const if (param_map.empty()) { - LLSD &water_defaults = LLSettingsWater::defaults(); + LLSD water_defaults = LLSettingsWater::defaults(); param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); } -- cgit v1.2.3 From 25e046594464551d6d66eceee0471f10722c53ce Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 31 Oct 2018 15:57:19 +0200 Subject: SL-9924 [EEP] Environment Settings permissions can be dropped by Save As button --- indra/newview/llsettingsvo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 3925f37703..0def17b32d 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -120,9 +120,14 @@ void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, cons void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) +{ + U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + createInventoryItem(settings, nextOwnerPerm, parent_id, settings_name, callback); +} + +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, U32 next_owner_perm, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) { LLTransactionID tid; - U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); if (!LLEnvironment::instance().isInventoryEnabled()) { @@ -144,7 +149,7 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), parent_id, tid, settings_name, "", - settings->getSettingsTypeValue(), nextOwnerPerm, cb); + settings->getSettingsTypeValue(), next_owner_perm, cb); } void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) -- cgit v1.2.3 From dfe9a02a9bfe101d4aef39d2d4d156a944747bbc Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 20 Dec 2018 16:09:10 +0200 Subject: SL-10274 FIXED [EEP] Settings object created by Save As cannot be copied from an object --- indra/newview/llsettingsvo.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 0def17b32d..6b1a0a2b77 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -154,23 +154,24 @@ void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) { + LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); + if (pitem) + { + LLPermissions perm = pitem->getPermissions(); + if (perm.getMaskEveryone() != PERM_COPY) + { + perm.setMaskEveryone(PERM_COPY); + pitem->setPermissions(perm); + pitem->updateServer(FALSE); + } + } if (!settings) { // The item was created as new with no settings passed in. Simulator should have given it the default for the type... check ID, // no need to upload asset. LLUUID asset_id; - LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); - if (pitem) { asset_id = pitem->getAssetUUID(); - - LLPermissions perm = pitem->getPermissions(); - if (perm.getMaskEveryone() != PERM_COPY) - { - perm.setMaskEveryone(PERM_COPY); - pitem->setPermissions(perm); - pitem->updateServer(FALSE); - } } if (callback) callback(asset_id, inventoryId, LLUUID::null, LLSD()); -- cgit v1.2.3 From e13113ab0b5e7aea11feba3947d2bbf7c5699db1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 8 Jan 2019 13:15:00 -0800 Subject: SL-10305 fix post deferred gamma correction to address ALM mismatch with non-ALM lighting. --- indra/newview/llsettingsvo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6b1a0a2b77..e2e7aadb61 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -662,7 +662,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - LLVector4 light_direction = LLEnvironment::instance().getClampedSunNorm(); + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { @@ -678,8 +678,11 @@ void LLSettingsVOSky::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); } + F32 g = getGamma(); + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); + shader->uniform4f(LLShaderMgr::GAMMA, g, 0.0, 0.0, 1.0); + shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, g); } LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const -- cgit v1.2.3 From c7e02b0835cbb50777c677f618c4a957e69fabee Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 30 Jan 2019 14:36:46 -0800 Subject: SL-9925: Viewer now shows an error message if import from legacy windlight fails. --- indra/newview/llsettingsvo.cpp | 87 +++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 30 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index e2e7aadb61..29217b3f42 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -64,13 +64,15 @@ #include "llinventoryobserver.h" #include "llinventorydefines.h" +#include "lltrans.h" + #undef VERIFY_LEGACY_CONVERSION //========================================================================= namespace { LLSD ensure_array_4(LLSD in, F32 fill); - LLSD read_legacy_preset_data(const std::string &name, const std::string& path); + LLSD read_legacy_preset_data(const std::string &name, const std::string& path, LLSD &messages); //------------------------------------------------------------------------- class LLSettingsInventoryCB : public LLInventoryCallback @@ -453,10 +455,15 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) } -LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages) { - LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); + LLSD newsettings = LLSettingsSky::translateLegacySettings(oldsettings); + if (newsettings.isUndefined()) + { + messages["REASONS"] = LLTrans::getString("SettingTranslateError", LLSDMap("NAME", name)); + return LLSettingsSky::ptr_t(); + } newsettings[SETTING_NAME] = name; @@ -464,6 +471,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n LLSD results = LLSettingsBase::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { + messages["REASONS"] = LLTrans::getString("SettingValidationError", LLSDMap("NAME", name)); LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; LLSettingsSky::ptr_t(); } @@ -473,10 +481,10 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n #ifdef VERIFY_LEGACY_CONVERSION LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp, isAdvanced()); - if (!llsd_equals(legacy, oldsettings)) + if (!llsd_equals(oldsettings, oldsettings)) { LL_WARNS("SKY") << "Conversion to/from legacy does not match!\n" - << "Old: " << legacy + << "Old: " << oldsettings << "new: " << oldsettings << LL_ENDL; } @@ -485,17 +493,17 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n return skyp; } -LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages) { - LLSD legacy_data = read_legacy_preset_data(name, path); + LLSD legacy_data = read_legacy_preset_data(name, path, messages); if (!legacy_data) - { + { // messages filled in by read_legacy_preset_data LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } - return buildFromLegacyPreset(name, legacy_data); + return buildFromLegacyPreset(name, legacy_data, messages); } @@ -755,15 +763,21 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildWater(LLSD settings) } //------------------------------------------------------------------------- -LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages) { - LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy)); + LLSD newsettings(LLSettingsWater::translateLegacySettings(oldsettings)); + if (newsettings.isUndefined()) + { + messages["REASONS"] = LLTrans::getString("SettingTranslateError", LLSDMap("NAME", name)); + return LLSettingsWater::ptr_t(); + } newsettings[SETTING_NAME] = name; LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); LLSD results = LLSettingsWater::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { + messages["REASONS"] = LLTrans::getString("SettingValidationError", name); LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; return LLSettingsWater::ptr_t(); } @@ -773,10 +787,10 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin #ifdef VERIFY_LEGACY_CONVERSION LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); - if (!llsd_equals(legacy, oldsettings)) + if (!llsd_equals(oldsettings, oldsettings)) { LL_WARNS("WATER") << "Conversion to/from legacy does not match!\n" - << "Old: " << legacy + << "Old: " << oldsettings << "new: " << oldsettings << LL_ENDL; } @@ -784,17 +798,17 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin return waterp; } -LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages) { - LLSD legacy_data = read_legacy_preset_data(name, path); + LLSD legacy_data = read_legacy_preset_data(name, path, messages); if (!legacy_data) - { + { // messages filled in by read_legacy_preset_data LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } - return buildFromLegacyPreset(name, legacy_data); + return buildFromLegacyPreset(name, legacy_data, messages); } @@ -959,7 +973,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) } //------------------------------------------------------------------------- -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings) +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings, LLSD &messages) { LLSD newsettings(defaults()); std::set framenames; @@ -994,16 +1008,22 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSD frames(LLSD::emptyMap()); { - LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path); - if (pwater) - frames["water:Default"] = pwater->getSettings(); + LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path, messages); + if (!pwater) + { // messages filled in by buildFromLegacyPresetFile + return LLSettingsDay::ptr_t(); + } + frames["water:Default"] = pwater->getSettings(); } for (std::set::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) { - LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path); - if (psky) - frames["sky:" + (*itn)] = psky->getSettings(); + LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path, messages); + if (!psky) + { // messages filled in by buildFromLegacyPresetFile + return LLSettingsDay::ptr_t(); + } + frames["sky:" + (*itn)] = psky->getSettings(); } newsettings[SETTING_FRAMES] = frames; @@ -1012,6 +1032,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSD results = LLSettingsDay::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { + messages["REASONS"] = LLTrans::getString("SettingValidationError", LLSDMap("NAME", name)); LL_WARNS("SETTINGS") << "Day setting validation failed!: " << results << LL_ENDL; return LLSettingsDay::ptr_t(); } @@ -1035,17 +1056,17 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n return dayp; } -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages) { - LLSD legacy_data = read_legacy_preset_data(name, path); + LLSD legacy_data = read_legacy_preset_data(name, path, messages); if (!legacy_data) - { + { // messages filled in by read_legacy_preset_data LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } - return buildFromLegacyPreset(name, path, legacy_data); + return buildFromLegacyPreset(name, path, legacy_data, messages); } @@ -1348,7 +1369,7 @@ namespace } //--------------------------------------------------------------------- - LLSD read_legacy_preset_data(const std::string &name, const std::string& path) + LLSD read_legacy_preset_data(const std::string &name, const std::string& path, LLSD &messages) { llifstream xml_file; @@ -1380,6 +1401,7 @@ namespace xml_file.open(full_path.c_str()); if (!xml_file) { + messages["REASONS"] = LLTrans::getString("SettingImportFileError", LLSDMap("FILE", bad_path)); LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; return LLSD(); } @@ -1388,7 +1410,12 @@ namespace LLSD params_data; LLPointer parser = new LLSDXMLParser(); - parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + if (parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE) + { + xml_file.close(); + messages["REASONS"] = LLTrans::getString("SettingParseFileError", LLSDMap("FILE", full_path)); + return LLSD(); + } xml_file.close(); return params_data; -- cgit v1.2.3 From 65927e0a76aaf8ff4dc268acdb12007265ff3a14 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 13 Feb 2019 13:09:14 -0800 Subject: SL-10181, SL-10546 Fix distortion map rendering in deferred mode not including underwater fog effects. Fix distortion map rendering not including post-deferred content at all. Fix distortion map rendering not including anything but sky when camera is underwater. Update sun_up_factor/sunmoon_glow_factor uniforms even when sun disc isn't in use. --- indra/newview/llsettingsvo.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 29217b3f42..3ef5e46e38 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -879,11 +879,15 @@ void LLSettingsVOWater::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; + LLEnvironment& env = LLEnvironment::instance(); + if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { + F32 water_height = env.getWaterHeight(); + //transform water plane to eye space glh::vec3f norm(0.f, 0.f, 1.f); - glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); + glh::vec3f p(0.f, 0.f, water_height + 0.1f); F32 modelView[16]; for (U32 i = 0; i < 16; i++) @@ -903,13 +907,18 @@ void LLSettingsVOWater::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, waterPlane.mV); - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + LLVector4 light_direction = env.getClampedLightNorm(); F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); - F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - water_height; + + F32 waterFogDensity = env.getCurrentWater()->getModifiedWaterFogDensity(LLPipeline::sUnderWaterRender || (eyedepth <= 0.0f)); + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, waterFogDensity); + + F32 blend_factor = env.getCurrentWater()->getBlendFactor(); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); @@ -941,7 +950,9 @@ LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const { LLSD water_defaults = LLSettingsWater::defaults(); param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); - param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); + + // let this get set by LLSettingsVOWater::applySpecial so that it can properly reflect the underwater modifier + //param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); } return param_map; } -- cgit v1.2.3 From 2401712d1073e85b4b9183d20c6e9274bc874f64 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 20 Feb 2019 15:20:30 -0800 Subject: SL-9660: Next pass cleanup. Removed and downgraded a number of logs. Removed refs to LAPAS. Better sync with legacy regions. --- indra/newview/llsettingsvo.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 3ef5e46e38..10a0527fe2 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -324,7 +324,6 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { - //_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; settings->setAssetId(asset_id); } } @@ -870,7 +869,6 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) legacy[SETTING_LEGACY_WAVE1_DIR] = settings[SETTING_WAVE1_DIR]; legacy[SETTING_LEGACY_WAVE2_DIR] = settings[SETTING_WAVE2_DIR]; - //_WARNS("LAPRAS") << "Legacy water: " << legacy << LL_ENDL; return legacy; } //------------------------------------------------------------------------- @@ -1120,8 +1118,6 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io ( SETTING_FRAMES, frames ) ( SETTING_TYPE, "daycycle" ); - //_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; - LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) @@ -1299,7 +1295,6 @@ LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); } - //_WARNS("LAPRAS") << "Cycle created with " << llsdcycle.size() << "entries: " << llsdcycle << LL_ENDL; LLSD llsdskylist(LLSD::emptyMap()); @@ -1311,8 +1306,6 @@ LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) llsdskylist[(*its).first] = llsdsky; } - //_WARNS("LAPRAS") << "Sky map with " << llsdskylist.size() << " entries created: " << llsdskylist << LL_ENDL; - return LLSDArray(LLSD::emptyMap())(llsdcycle)(llsdskylist)(llsdwater); } -- cgit v1.2.3 From fe589170d3faa5ca681baca7b9a664e2d851cd6e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 15:54:21 -0700 Subject: SL-10896 Fix deferred water soften prog lightnorm getting stomped with rotated lightnorm, because it's a water shader and needs water atmo uniform values, but it's a deferred lighting shader that needs not-so-rotated lightnorms. Make sunlight_color not get auto-updated so we can get the correct value from mSunDiffuse. Remove mix to preserve bumps as it was washing out shadows. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 10a0527fe2..6556380f28 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -719,7 +719,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); - param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); -- cgit v1.2.3 From 759525040ac11a2edee541c944ad0c6e9cc04d0f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Apr 2019 13:07:44 -0700 Subject: SL-10912 Fix conversion of star brightness, density mult, and distance mult to legacy ranges. Make settings look in both legacyhaze and top-level settings for haze params. --- indra/newview/llsettingsvo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6556380f28..60f4cd3f5a 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -568,9 +568,11 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) F32 density_multiplier = legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal(); density_multiplier = (density_multiplier < 0.0001f) ? 0.0001f : density_multiplier; + density_multiplier *= 0.9f / 2.0f; // take 0 - 2.0 range to 0 - 0.9 range legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(density_multiplier)(0.0f)(0.0f)(1.0f); F32 distance_multiplier = legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal(); + distance_multiplier *= 0.1f; // take 0 - 1000 range to 0 - 100 range legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(distance_multiplier)(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); @@ -597,7 +599,7 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); - legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; + legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS].asReal() / 250.0f; // convert from 0-500 -> 0-2 ala pre-FS-compat changes legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); LLVector3 dir = psky->getLightDirection(); -- cgit v1.2.3 From a50590ec4b685e4a4f4c5d8f4bf0c14dae684fc3 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Apr 2019 10:40:49 -0700 Subject: SL-10925, SL-10926 Restore letting env auto-update sunlight_color uniform (other shaders expect it even if lighting does not). --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 60f4cd3f5a..eb92c11952 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -721,7 +721,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); - //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); -- cgit v1.2.3 From 2c568e7584ed4a5c000b2064a4d06f4b2347a34a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Apr 2019 10:11:50 -0700 Subject: SL-10925, SL-10926, SL-10896 New fix for 925/926 that doesn't cause 896 again. Also linearize moon disc tex color. --- indra/newview/llsettingsvo.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index eb92c11952..628666c3ed 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -685,6 +685,28 @@ void LLSettingsVOSky::applySpecial(void *ptarget) LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor4 sunDiffuse = psky->getSunDiffuse(); + LLColor4 moonDiffuse = psky->getMoonDiffuse(); + + F32 max_color = llmax(sunDiffuse.mV[0], sunDiffuse.mV[1], sunDiffuse.mV[2]); + if (max_color > 1.f) + { + sunDiffuse *= 1.f/max_color; + } + sunDiffuse.clamp(); + + max_color = llmax(moonDiffuse.mV[0], moonDiffuse.mV[1], moonDiffuse.mV[2]); + if (max_color > 1.f) + { + moonDiffuse *= 1.f/max_color; + } + moonDiffuse.clamp(); + + shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); } F32 g = getGamma(); @@ -721,7 +743,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); - param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); -- cgit v1.2.3 From c4032528aff8ef1938e897ec583bbf25a3e713e1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 2 May 2019 13:49:35 -0700 Subject: Roll back sRGB decode changes from contrib for now. Fix direct light matching across alpha/blended-material/deferred. Get diffuse lighting to match from Low to Ultra. --- indra/newview/llsettingsvo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 628666c3ed..4bd8fcac0c 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -707,6 +707,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); + shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, psky->getCloudColor().mV); } F32 g = getGamma(); @@ -736,14 +737,17 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const // Following values are always present, so we can just zero these ones, but used values from defaults() LLSD sky_defaults = LLSettingsSky::defaults(); - param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]); param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]); param_map[SETTING_CLOUD_SHADOW] = DefaultParam(LLShaderMgr::CLOUD_SHADOW, sky_defaults[SETTING_CLOUD_SHADOW]); param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); + //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + //param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); -- cgit v1.2.3 From 6d13430d78f2fa18577fc2a43e8d182852e826b7 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 3 May 2019 10:33:30 -0700 Subject: Make sure cloud_color has non-garbage alpha (no offense to 4.59e-41). --- indra/newview/llsettingsvo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 4bd8fcac0c..d307e1a947 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -707,7 +707,9 @@ void LLSettingsVOSky::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); - shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, psky->getCloudColor().mV); + + LLColor4 cloud_color(psky->getCloudColor(), 1.0); + shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); } F32 g = getGamma(); -- cgit v1.2.3 From 61c2f820b4f9753fc73d2e338a38f81ff11de791 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 9 May 2019 14:16:01 -0700 Subject: SL-11008: Do not adjust imported windlight density and distance multipliers. --- indra/newview/llsettingsvo.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index d307e1a947..7e0ec23a06 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -566,14 +566,8 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); - F32 density_multiplier = legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal(); - density_multiplier = (density_multiplier < 0.0001f) ? 0.0001f : density_multiplier; - density_multiplier *= 0.9f / 2.0f; // take 0 - 2.0 range to 0 - 0.9 range - legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(density_multiplier)(0.0f)(0.0f)(1.0f); - - F32 distance_multiplier = legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal(); - distance_multiplier *= 0.1f; // take 0 - 1000 range to 0 - 100 range - legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(distance_multiplier)(0.0f)(0.0f)(1.0f); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); -- cgit v1.2.3 From c8ae0c0c3f1747faf36d27a63c66755a1bfeeb3c Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 17 May 2019 14:21:52 -0700 Subject: SL-11112 Fix blend between reflected/refracted water maps (make less transparent) and fix setting of water fog color alpha on low end to better match prev behavior of setting the internal control value in that case. --- indra/newview/llsettingsvo.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 7e0ec23a06..387644fa57 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -936,10 +936,14 @@ void LLSettingsVOWater::applySpecial(void *ptarget) shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - water_height; + bool underwater = LLPipeline::sUnderWaterRender || (eyedepth <= 0.0f); - F32 waterFogDensity = env.getCurrentWater()->getModifiedWaterFogDensity(LLPipeline::sUnderWaterRender || (eyedepth <= 0.0f)); + F32 waterFogDensity = env.getCurrentWater()->getModifiedWaterFogDensity(underwater); shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, waterFogDensity); + LLColor4 fog_color(env.getCurrentWater()->getWaterFogColor(), 0.0f); + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV); + F32 blend_factor = env.getCurrentWater()->getBlendFactor(); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); @@ -970,9 +974,8 @@ LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const if (param_map.empty()) { - LLSD water_defaults = LLSettingsWater::defaults(); - param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); - + //LLSD water_defaults = LLSettingsWater::defaults(); + //param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); // let this get set by LLSettingsVOWater::applySpecial so that it can properly reflect the underwater modifier //param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); } -- cgit v1.2.3 From e9dbee00262a437e4b3f971b37ea636e92032133 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 21 May 2019 16:00:45 -0700 Subject: SL-11238 Fix ambient light inputs to the renderer. Fix 3rd sky shader w/ mistaken density mod conversion. Make ambient clamp apply to all modes. Tune ALM ambient clamp to match non-ALM. --- indra/newview/llsettingsvo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 387644fa57..11d7eb1c35 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -682,8 +682,8 @@ void LLSettingsVOSky::applySpecial(void *ptarget) LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLColor4 sunDiffuse = psky->getSunDiffuse(); - LLColor4 moonDiffuse = psky->getMoonDiffuse(); + LLColor4 sunDiffuse = psky->getSunlightColor(); + LLColor4 moonDiffuse = psky->getMoonlightColor(); F32 max_color = llmax(sunDiffuse.mV[0], sunDiffuse.mV[1], sunDiffuse.mV[2]); if (max_color > 1.f) -- cgit v1.2.3 From 6aa393f7f50ca30b65391f4ae230a3357092f3cd Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 24 May 2019 21:17:41 +0300 Subject: SL-11287 [EEP] Importing certain legacy windlights give upload error --- indra/newview/llsettingsvo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 11d7eb1c35..7f9e2f6d30 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -502,7 +502,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::strin return ptr_t(); } - return buildFromLegacyPreset(name, legacy_data, messages); + return buildFromLegacyPreset(LLURI::unescape(name), legacy_data, messages); } @@ -831,7 +831,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::s return ptr_t(); } - return buildFromLegacyPreset(name, legacy_data, messages); + return buildFromLegacyPreset(LLURI::unescape(name), legacy_data, messages); } @@ -1101,8 +1101,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::strin LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; return ptr_t(); } - - return buildFromLegacyPreset(name, path, legacy_data, messages); + // Name for LLSettingsDay only, path to get related files from filesystem + return buildFromLegacyPreset(LLURI::unescape(name), path, legacy_data, messages); } -- cgit v1.2.3 From 5d844d2646166fe112bc58362b7dfd4e24fa76ec Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 29 May 2019 08:12:49 -0700 Subject: SL-11247 Fix underwater water fog density modifier being used when not underwater. --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 11d7eb1c35..00acb78c45 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -936,7 +936,7 @@ void LLSettingsVOWater::applySpecial(void *ptarget) shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - water_height; - bool underwater = LLPipeline::sUnderWaterRender || (eyedepth <= 0.0f); + bool underwater = (eyedepth <= 0.0f); F32 waterFogDensity = env.getCurrentWater()->getModifiedWaterFogDensity(underwater); shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, waterFogDensity); -- cgit v1.2.3 From 158a0104c1d00e56b46fec31e650cd6942cac735 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 6 Jun 2019 15:55:50 -0700 Subject: SL-11367 Use rotated lightnorm directly in water shader instead of forcing all shaders marked as water (including lighting) to get that norm (where it would only affect Mid as only that graphics mode has atmospherics on but isn't using deferred rendering). --- indra/newview/llsettingsvo.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index f4cd0eef6e..cc70f651cf 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -947,10 +947,8 @@ void LLSettingsVOWater::applySpecial(void *ptarget) F32 blend_factor = env.getCurrentWater()->getBlendFactor(); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + // update to normal lightnorm, water shader itself will use rotated lightnorm as necessary + shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, light_direction.mV); } } -- cgit v1.2.3 From b507d63566e8896af702dd10f5643dc29068a8a9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2019 11:36:22 -0700 Subject: SL-11621 Remove all references to unused shader var global_gamma. Remove many unused decls for gamma from shaders. Make post-deferred gamma correction use display_gamma. Make setting display_gamma use the correct RenderDeferredDisplayGamma setting. --- indra/newview/llsettingsvo.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index cc70f651cf..5b336f0870 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -706,11 +706,15 @@ void LLSettingsVOSky::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); } - F32 g = getGamma(); + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - shader->uniform4f(LLShaderMgr::GAMMA, g, 0.0, 0.0, 1.0); - shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, g); + + F32 g = getGamma(); + F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + + shader->uniform1f(LLShaderMgr::GAMMA, g); + shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, display_gamma); } LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const -- cgit v1.2.3 From 1f656735d339fc4d83da86efbb400af1361c27db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 26 Aug 2019 11:43:45 -0700 Subject: SL-11705, SL-11706: New flags in llsettings base for tracking by simulator. --- indra/newview/llsettingsvo.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 5b336f0870..11bb732be8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -532,6 +532,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const { LLSD settings = cloneSettings(); + U32 flags = getFlags(); LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); LLSD results = LLSettingsBase::settingValidation(settings, validations); @@ -542,6 +543,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const } LLSettingsSky::ptr_t skyp = std::make_shared(settings); + skyp->setFlags(flags); return skyp; } @@ -866,6 +868,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const { LLSD settings = cloneSettings(); + U32 flags = getFlags(); LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); LLSD results = LLSettingsWater::settingValidation(settings, validations); if (!results["success"].asBoolean()) @@ -875,7 +878,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const } LLSettingsWater::ptr_t waterp = std::make_shared(settings); - + waterp->setFlags(flags); return waterp; } @@ -1273,6 +1276,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD LLSD settings = llsd_clone(mSettings); + U32 flags = getFlags(); LLSettingsDay::ptr_t day_clone = std::make_shared(settings); for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i) @@ -1289,6 +1293,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const iter++; } } + day_clone->setFlags(flags); return day_clone; } -- cgit v1.2.3 From ad26896a1086536cf47d3cb0041b0410aebf2119 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 27 Aug 2019 12:49:18 -0700 Subject: SL-11055 Remedy cloud_shadow and hack halving being done twice to ambient in some cases (i.e. artificial dimunition of necessary bullshit factor). --- indra/newview/llsettingsvo.cpp | 56 ++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 32 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 11bb732be8..bbee94287d 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -663,7 +663,7 @@ void LLSettingsVOSky::updateSettings() gSky.setMoonScale(getMoonScale()); } -void LLSettingsVOSky::applySpecial(void *ptarget) +void LLSettingsVOSky::applySpecial(void *ptarget, bool force) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; @@ -671,46 +671,38 @@ void LLSettingsVOSky::applySpecial(void *ptarget) if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); } else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); - vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); - shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLColor4 sunDiffuse = psky->getSunlightColor(); - LLColor4 moonDiffuse = psky->getMoonlightColor(); + LLColor4 sunDiffuse = psky->getSunlightColor(); + LLColor4 moonDiffuse = psky->getMoonlightColor(); - F32 max_color = llmax(sunDiffuse.mV[0], sunDiffuse.mV[1], sunDiffuse.mV[2]); - if (max_color > 1.f) - { - sunDiffuse *= 1.f/max_color; - } - sunDiffuse.clamp(); - - max_color = llmax(moonDiffuse.mV[0], moonDiffuse.mV[1], moonDiffuse.mV[2]); - if (max_color > 1.f) - { - moonDiffuse *= 1.f/max_color; - } - moonDiffuse.clamp(); + shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); - shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); - shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); - - LLColor4 cloud_color(psky->getCloudColor(), 1.0); - shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); + LLColor4 cloud_color(psky->getCloudColor(), 1.0); + shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + + LLColor4 ambient(getTotalAmbient()); + shader->uniform4fv(LLShaderMgr::AMBIENT, 1, ambient.mV); + + shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, getIsSunUp() ? 1 : 0); + shader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, getSunMoonGlowFactor()); + shader->uniform1f(LLShaderMgr::DENSITY_MULTIPLIER, getDensityMultiplier()); + shader->uniform1f(LLShaderMgr::DISTANCE_MULTIPLIER, getDistanceMultiplier()); F32 g = getGamma(); F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); @@ -904,13 +896,13 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) } //------------------------------------------------------------------------- //------------------------------------------------------------------------- -void LLSettingsVOWater::applySpecial(void *ptarget) +void LLSettingsVOWater::applySpecial(void *ptarget, bool force) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; LLEnvironment& env = LLEnvironment::instance(); - if (shader->mShaderGroup == LLGLSLShader::SG_WATER) + if (force || (shader->mShaderGroup == LLGLSLShader::SG_WATER)) { F32 water_height = env.getWaterHeight(); -- cgit v1.2.3 From b3e11083cc31abfa7cebf2c3acc6aeebfc1f4205 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 19 Dec 2019 18:04:32 -0700 Subject: SL-11606 fix to match EEP light falloff vs release --- indra/newview/llsettingsvo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index bbee94287d..32398aa609 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -641,17 +641,17 @@ void LLSettingsVOSky::updateSettings() LLVector3 sun_direction = getSunDirection(); LLVector3 moon_direction = getMoonDirection(); - F32 dp = getLightDirection() * LLVector3(0.0f, 0.0f, 1.0f); - if (dp < 0) - { - dp = 0; - } - dp = llmax(dp, 0.1f); + // Want the dot prod of sun w/ high noon vector (0,0,1), which is just the z component + F32 dp = llmax(sun_direction[2], 0.0f); // clamped to 0 when sun is down // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio // between sunlight and point lights in windlight to normalize point lights. + // + // After some A/B comparison of relesae vs EEP, tweak to allow strength to fall below 2 + // at night, for better match. (mSceneLightStrength is a divisor, so lower value means brighter + // local lights) F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + mSceneLightStrength = 2.0f * (0.65f + sun_dynamic_range * dp); gSky.setSunAndMoonDirectionsCFR(sun_direction, moon_direction); gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); -- cgit v1.2.3 From 4ec316871563ffafc39ffb69fee48b80cee9c2f5 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 20 Dec 2019 10:29:46 -0700 Subject: SL-11606 final tweak of non-ALM lights strength --- indra/newview/llsettingsvo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 32398aa609..d96f276a71 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -644,14 +644,14 @@ void LLSettingsVOSky::updateSettings() // Want the dot prod of sun w/ high noon vector (0,0,1), which is just the z component F32 dp = llmax(sun_direction[2], 0.0f); // clamped to 0 when sun is down - // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio - // between sunlight and point lights in windlight to normalize point lights. + // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio + // between sunlight and point lights in windlight to normalize point lights. // // After some A/B comparison of relesae vs EEP, tweak to allow strength to fall below 2 // at night, for better match. (mSceneLightStrength is a divisor, so lower value means brighter // local lights) F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - mSceneLightStrength = 2.0f * (0.65f + sun_dynamic_range * dp); + mSceneLightStrength = 2.0f * (0.75f + sun_dynamic_range * dp); gSky.setSunAndMoonDirectionsCFR(sun_direction, moon_direction); gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); -- cgit v1.2.3 From 6620211bff5dca7df0667cf9220da1a9e7ce079c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 27 Mar 2020 00:13:33 +0200 Subject: SL-12911 Add Debug setting EnvironmentPersistAcrossLogin --- indra/newview/llsettingsvo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsettingsvo.cpp') diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index d96f276a71..c72a0706cd 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -514,7 +514,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() { default_settings = LLSettingsSky::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); + default_settings[SETTING_NAME] = DEFAULT_SETTINGS_NAME; LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); LLSD results = LLSettingsBase::settingValidation(default_settings, validations); @@ -841,7 +841,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() { default_settings = LLSettingsWater::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); + default_settings[SETTING_NAME] = DEFAULT_SETTINGS_NAME; LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); LLSD results = LLSettingsWater::settingValidation(default_settings, validations); @@ -1169,7 +1169,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() if (!default_settings.size()) { default_settings = LLSettingsDay::defaults(); - default_settings[SETTING_NAME] = std::string("_default_"); + default_settings[SETTING_NAME] = DEFAULT_SETTINGS_NAME; LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(default_settings, validations); -- cgit v1.2.3