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/llinventory/llsettingssky.cpp | 561 ++++++++++++++++++++++++++++++++++++ 1 file changed, 561 insertions(+) create mode 100644 indra/llinventory/llsettingssky.cpp (limited to 'indra/llinventory/llsettingssky.cpp') diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp new file mode 100644 index 0000000000..ecc89165e8 --- /dev/null +++ b/indra/llinventory/llsettingssky.cpp @@ -0,0 +1,561 @@ +/** +* @file llsettingssky.cpp +* @author optional +* @brief A base class for asset based settings groups. +* +* $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 "llsettingssky.h" +#include "indra_constants.h" +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +//========================================================================= +namespace +{ + const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0); + const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); + const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); + + LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); + LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); + + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); + void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); +} + +const F32 LLSettingsSky::DOME_OFFSET(0.96f); +const F32 LLSettingsSky::DOME_RADIUS(15000.f); + +const F32 LLSettingsSky::NIGHTTIME_ELEVATION(-8.0f); // degrees +const F32 LLSettingsSky::NIGHTTIME_ELEVATION_COS((F32)sin(NIGHTTIME_ELEVATION*DEG_TO_RAD)); + +//========================================================================= +const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); +const std::string LLSettingsSky::SETTING_BLOOM_TEXTUREID("bloom_id"); +const std::string LLSettingsSky::SETTING_BLUE_DENSITY("blue_density"); +const std::string LLSettingsSky::SETTING_BLUE_HORIZON("blue_horizon"); +const std::string LLSettingsSky::SETTING_CLOUD_COLOR("cloud_color"); +const std::string LLSettingsSky::SETTING_CLOUD_POS_DENSITY1("cloud_pos_density1"); +const std::string LLSettingsSky::SETTING_CLOUD_POS_DENSITY2("cloud_pos_density2"); +const std::string LLSettingsSky::SETTING_CLOUD_SCALE("cloud_scale"); +const std::string LLSettingsSky::SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate"); +const std::string LLSettingsSky::SETTING_CLOUD_SHADOW("cloud_shadow"); +const std::string LLSettingsSky::SETTING_CLOUD_TEXTUREID("cloud_id"); +const std::string LLSettingsSky::SETTING_DENSITY_MULTIPLIER("density_multiplier"); +const std::string LLSettingsSky::SETTING_DISTANCE_MULTIPLIER("distance_multiplier"); +const std::string LLSettingsSky::SETTING_DOME_OFFSET("dome_offset"); +const std::string LLSettingsSky::SETTING_DOME_RADIUS("dome_radius"); +const std::string LLSettingsSky::SETTING_GAMMA("gamma"); +const std::string LLSettingsSky::SETTING_GLOW("glow"); +const std::string LLSettingsSky::SETTING_HAZE_DENSITY("haze_density"); +const std::string LLSettingsSky::SETTING_HAZE_HORIZON("haze_horizon"); +const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); +const std::string LLSettingsSky::SETTING_MAX_Y("max_y"); +const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation"); +const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id"); +const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); +const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); +const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); +const std::string LLSettingsSky::SETTING_SUN_TEXUTUREID("sun_id"); + +const std::string LLSettingsSky::SETTING_LEGACY_EAST_ANGLE("east_angle"); +const std::string LLSettingsSky::SETTING_LEGACY_ENABLE_CLOUD_SCROLL("enable_cloud_scroll"); +const std::string LLSettingsSky::SETTING_LEGACY_SUN_ANGLE("sun_angle"); + +//========================================================================= +LLSettingsSky::LLSettingsSky(const LLSD &data) : + LLSettingsBase(data) +{ +} + +LLSettingsSky::LLSettingsSky(): + LLSettingsBase() +{ +} + +void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +{ + LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + + replaceSettings(blenddata); +} + + +void LLSettingsSky::setMoonRotation(F32 azimuth, F32 altitude) +{ + setValue(SETTING_MOON_ROTATION, ::body_position_from_angles(azimuth, altitude)); +} + +LLSettingsSky::azimalt_t LLSettingsSky::getMoonRotationAzAl() const +{ + azimalt_t res; + ::angles_from_rotation(getMoonRotation(), res.first, res.second); + + return res; +} + +void LLSettingsSky::setSunRotation(F32 azimuth, F32 altitude) +{ + setValue(SETTING_SUN_ROTATION, ::body_position_from_angles(azimuth, altitude)); +} + +LLSettingsSky::azimalt_t LLSettingsSky::getSunRotationAzAl() const +{ + azimalt_t res; + ::angles_from_rotation(getSunRotation(), res.first, res.second); + + return res; +} + +LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const +{ + static stringset_t slepSet; + + if (slepSet.empty()) + { + slepSet.insert(SETTING_SUN_ROTATION); + slepSet.insert(SETTING_MOON_ROTATION); + } + + return slepSet; +} + +LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const +{ + static validation_list_t validation; + + if (validation.empty()) + { // Note the use of LLSD(LLSDArray()()()...) This is due to an issue with the + // copy constructor for LLSDArray. Directly binding the LLSDArray as + // a parameter without first wrapping it in a pure LLSD object will result + // in deeply nested arrays like this [[[[[[[[[[v1,v2,v3]]]]]]]]]] + + validation.push_back(Validator(SETTING_AMBIENT, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*"))))); + validation.push_back(Validator(SETTING_BLOOM_TEXTUREID, true, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_BLUE_DENSITY, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*"))))); + validation.push_back(Validator(SETTING_BLUE_HORIZON, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_COLOR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(1.0f)(1.0f)(1.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_POS_DENSITY1, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(1.68841f)(1.0f)(1.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_POS_DENSITY2, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(1.68841f)(1.0f)(1.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_SCALE, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.001f)(0.999f))))); + validation.push_back(Validator(SETTING_CLOUD_SCROLL_RATE, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)), + LLSD(LLSDArray(20.0f)(20.0f))))); + validation.push_back(Validator(SETTING_CLOUD_SHADOW, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_CLOUD_TEXTUREID, false, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f))))); + validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f))))); + validation.push_back(Validator(SETTING_DOME_OFFSET, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_DOME_RADIUS, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1000.0f)(2000.0f))))); + validation.push_back(Validator(SETTING_GAMMA, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(10.0f))))); + validation.push_back(Validator(SETTING_GLOW, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.2f)("*")(-2.5f)("*")), + LLSD(LLSDArray(20.0f)("*")(0.0f)("*"))))); + validation.push_back(Validator(SETTING_HAZE_DENSITY, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f))))); + validation.push_back(Validator(SETTING_HAZE_HORIZON, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_LIGHT_NORMAL, false, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorNormalized, _1, 3))); + validation.push_back(Validator(SETTING_MAX_Y, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4000.0f))))); + validation.push_back(Validator(SETTING_MOON_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); + validation.push_back(Validator(SETTING_MOON_TEXTUREID, false, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_STAR_BRIGHTNESS, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(2.0f))))); + validation.push_back(Validator(SETTING_SUNLIGHT_COLOR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*"))))); + validation.push_back(Validator(SETTING_SUN_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); + validation.push_back(Validator(SETTING_SUN_TEXUTUREID, false, LLSD::TypeUUID)); + } + + return validation; +} + + +LLSD LLSettingsSky::defaults() +{ + LLSD dfltsetting; + + + LLQuaternion sunquat; + sunquat.setEulerAngles(1.39626, 0.0, 0.0); // 80deg Azumith/0deg East + LLQuaternion moonquat = ~sunquat; + + // Magic constants copied form dfltsetting.xml + dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue(); + dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 0.0).getValue(); + dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); + dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); + dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699); + dfltsetting[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(0.0001); + dfltsetting[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(0.8000); + dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); + dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); + dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); + dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); + dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999); + dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899); + dfltsetting[SETTING_LIGHT_NORMAL] = LLVector3(0.0000, 0.9126, -0.4086).getValue(); + dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); + dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); + dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); + dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); + dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); + + dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow! + dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID; + + return dfltsetting; +} + +LLSD LLSettingsSky::translateLegacySettings(LLSD legacy) +{ + LLSD newsettings(defaults()); + + if (legacy.has(SETTING_AMBIENT)) + { + newsettings[SETTING_AMBIENT] = LLColor3(legacy[SETTING_AMBIENT]).getValue(); + } + if (legacy.has(SETTING_BLUE_DENSITY)) + { + newsettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue(); + } + if (legacy.has(SETTING_BLUE_HORIZON)) + { + newsettings[SETTING_BLUE_HORIZON] = LLColor3(legacy[SETTING_BLUE_HORIZON]).getValue(); + } + if (legacy.has(SETTING_CLOUD_COLOR)) + { + newsettings[SETTING_CLOUD_COLOR] = LLColor3(legacy[SETTING_CLOUD_COLOR]).getValue(); + } + if (legacy.has(SETTING_CLOUD_POS_DENSITY1)) + { + newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor3(legacy[SETTING_CLOUD_POS_DENSITY1]).getValue(); + } + if (legacy.has(SETTING_CLOUD_POS_DENSITY2)) + { + newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor3(legacy[SETTING_CLOUD_POS_DENSITY2]).getValue(); + } + if (legacy.has(SETTING_CLOUD_SCALE)) + { + newsettings[SETTING_CLOUD_SCALE] = LLSD::Real(legacy[SETTING_CLOUD_SCALE][0].asReal()); + } + if (legacy.has(SETTING_CLOUD_SCROLL_RATE)) + { + LLVector2 cloud_scroll(legacy[SETTING_CLOUD_SCROLL_RATE]); + + if (legacy.has(SETTING_LEGACY_ENABLE_CLOUD_SCROLL)) + { + LLSD enabled = legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL]; + if (!enabled[0].asBoolean()) + cloud_scroll.mV[0] = 0.0f; + if (!enabled[1].asBoolean()) + cloud_scroll.mV[1] = 0.0f; + } + + newsettings[SETTING_CLOUD_SCROLL_RATE] = cloud_scroll.getValue(); + } + if (legacy.has(SETTING_CLOUD_SHADOW)) + { + newsettings[SETTING_CLOUD_SHADOW] = LLSD::Real(legacy[SETTING_CLOUD_SHADOW][0].asReal()); + } + if (legacy.has(SETTING_DENSITY_MULTIPLIER)) + { + newsettings[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(legacy[SETTING_DENSITY_MULTIPLIER][0].asReal()); + } + if (legacy.has(SETTING_DISTANCE_MULTIPLIER)) + { + newsettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(legacy[SETTING_DISTANCE_MULTIPLIER][0].asReal()); + } + if (legacy.has(SETTING_GAMMA)) + { + newsettings[SETTING_GAMMA] = legacy[SETTING_GAMMA][0].asReal(); + } + if (legacy.has(SETTING_GLOW)) + { + newsettings[SETTING_GLOW] = LLColor3(legacy[SETTING_GLOW]).getValue(); + } + if (legacy.has(SETTING_HAZE_DENSITY)) + { + newsettings[SETTING_HAZE_DENSITY] = LLSD::Real(legacy[SETTING_HAZE_DENSITY][0].asReal()); + } + if (legacy.has(SETTING_HAZE_HORIZON)) + { + newsettings[SETTING_HAZE_HORIZON] = LLSD::Real(legacy[SETTING_HAZE_HORIZON][0].asReal()); + } + if (legacy.has(SETTING_LIGHT_NORMAL)) + { + newsettings[SETTING_LIGHT_NORMAL] = LLVector3(legacy[SETTING_LIGHT_NORMAL]).getValue(); + } + if (legacy.has(SETTING_MAX_Y)) + { + newsettings[SETTING_MAX_Y] = LLSD::Real(legacy[SETTING_MAX_Y][0].asReal()); + } + if (legacy.has(SETTING_STAR_BRIGHTNESS)) + { + newsettings[SETTING_STAR_BRIGHTNESS] = LLSD::Real(legacy[SETTING_STAR_BRIGHTNESS].asReal()); + } + if (legacy.has(SETTING_SUNLIGHT_COLOR)) + { + newsettings[SETTING_SUNLIGHT_COLOR] = LLColor4(legacy[SETTING_SUNLIGHT_COLOR]).getValue(); + } + + if (legacy.has(SETTING_LEGACY_EAST_ANGLE) && legacy.has(SETTING_LEGACY_SUN_ANGLE)) + { // convert the east and sun angles into a quaternion. + F32 azimuth = legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); + F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); + + LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude); + LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude); + + F32 az(0), al(0); + ::angles_from_rotation(sunquat, az, al); + + newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); + newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); + } + + return newsettings; +} + +void LLSettingsSky::updateSettings() +{ + LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); + //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; + + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + calculateHeavnlyBodyPositions(); + calculateLightSettings(); +} + +void LLSettingsSky::calculateHeavnlyBodyPositions() +{ + mSunDirection = DUE_EAST * getSunRotation(); + mSunDirection.normalize(); + mMoonDirection = DUE_EAST * getMoonRotation(); + mMoonDirection.normalize(); + + // is the normal from the sun or the moon + if (mSunDirection.mV[1] >= 0.0) + { + mLightDirection = mSunDirection; + } + else if (mSunDirection.mV[1] < 0.0 && mSunDirection.mV[1] > NIGHTTIME_ELEVATION_COS) + { + // clamp v1 to 0 so sun never points up and causes weirdness on some machines + LLVector3 vec(mSunDirection); + vec.mV[1] = 0.0; + vec.normalize(); + mLightDirection = vec; + } + else + { + mLightDirection = mMoonDirection; + } + + // calculate the clamp lightnorm for sky (to prevent ugly banding in sky + // when haze goes below the horizon + mClampedLightDirection = mLightDirection; + + if (mClampedLightDirection.mV[1] < -0.1f) + { + mClampedLightDirection.mV[1] = -0.1f; + mClampedLightDirection.normalize(); + } +} + +void LLSettingsSky::calculateLightSettings() +{ + LLColor3 vary_HazeColor; + LLColor3 vary_SunlightColor; + LLColor3 vary_AmbientColor; + { + // Initialize temp variables + LLColor3 sunlight = getSunlightColor(); + LLColor3 ambient = getAmbientColor(); + F32 gamma = getGamma(); + LLColor3 blue_density = getBlueDensity(); + LLColor3 blue_horizon = getBlueHorizon(); + F32 haze_density = getHazeDensity(); + F32 haze_horizon = getHazeHorizon(); + F32 density_multiplier = getDensityMultiplier(); + F32 max_y = getMaxY(); + F32 cloud_shadow = getCloudShadow(); + LLVector3 lightnorm = getLightDirection(); + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + LLColor3 light_atten = + (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); + + // Calculate relative weights + LLColor3 temp2(0.f, 0.f, 0.f); + LLColor3 temp1 = blue_density + smear(haze_density); + LLColor3 blue_weight = componentDiv(blue_density, temp1); + LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); + + // Compute sunlight from P & lightnorm (for long rays like sky) + /// USE only lightnorm. + // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + + // and vary_sunlight will work properly with moon light + F32 lighty = lightnorm[1]; + if (lighty < NIGHTTIME_ELEVATION_COS) + { + lighty = -lighty; + } + + temp2.mV[1] = llmax(0.f, lighty); + if(temp2.mV[1] > 0.f) + { + temp2.mV[1] = 1.f / temp2.mV[1]; + } + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Distance + temp2.mV[2] = density_multiplier; + + // Transparency (-> temp1) + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); + + // vary_AtmosAttenuation = temp1; + + //increase ambient when there are more clouds + LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; + + //haze color + vary_HazeColor = + (blue_horizon * blue_weight * (sunlight*(1.f - cloud_shadow) + tmpAmbient) + + componentMult(haze_horizon * haze_weight, sunlight*(1.f - cloud_shadow) * temp2.mV[0] + tmpAmbient) + ); + + //brightness of surface both sunlight and ambient + vary_SunlightColor = componentMult(sunlight, temp1) * 1.f; + vary_SunlightColor.clamp(); + vary_SunlightColor = smear(1.0f) - vary_SunlightColor; + vary_SunlightColor = componentPow(vary_SunlightColor, gamma); + vary_SunlightColor = smear(1.0f) - vary_SunlightColor; + vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5; + vary_AmbientColor.clamp(); + vary_AmbientColor = smear(1.0f) - vary_AmbientColor; + vary_AmbientColor = componentPow(vary_AmbientColor, gamma); + vary_AmbientColor = smear(1.0f) - vary_AmbientColor; + + componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1); + + } + + mSunDiffuse = vary_SunlightColor; + mSunAmbient = vary_AmbientColor; + mMoonDiffuse = vary_SunlightColor; + mMoonAmbient = vary_AmbientColor; + + mTotalAmbient = LLColor4(vary_AmbientColor, 1.0f); + + mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; + mFadeColor.setAlpha(0); +} + + +//========================================================================= +namespace +{ + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) + { + // Azimuth is traditionally calculated from North, we are going from East. + LLQuaternion rot_azi; + LLQuaternion rot_alt; + + rot_azi.setAngleAxis(azimuth, VECT_ZENITH); + rot_alt.setAngleAxis(-altitude, VECT_NORTHSOUTH); + + LLQuaternion body_quat = rot_alt * rot_azi; + body_quat.normalize(); + + //LLVector3 sun_vector = (DUE_EAST * body_quat); + //_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL; + return body_quat; + } + + void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude) + { + LLVector3 body_vector = (DUE_EAST * quat); + + LLVector3 body_az(body_vector[0], 0.f, body_vector[2]); + LLVector3 body_al(0.f, body_vector[1], body_vector[2]); + + if (fabs(body_az.normalize()) > 0.001) + azimuth = angle_between(DUE_EAST, body_az); + else + azimuth = 0.0f; + + if (fabs(body_al.normalize()) > 0.001) + altitude = angle_between(DUE_EAST, body_al); + else + altitude = 0.0f; + } +} + + -- cgit v1.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/llinventory/llsettingsbase.cpp | 16 +- indra/llinventory/llsettingsbase.h | 39 +++-- indra/llinventory/llsettingsdaycycle.cpp | 41 +++-- indra/llinventory/llsettingsdaycycle.h | 28 +++- indra/llinventory/llsettingssky.cpp | 2 +- indra/llinventory/llsettingssky.h | 10 +- indra/llinventory/llsettingswater.cpp | 2 +- indra/llinventory/llsettingswater.h | 23 +-- indra/newview/llenvironment.cpp | 270 ++++++++++++++++++++++++++++++- indra/newview/llenvironment.h | 20 +++ indra/newview/llsettingsvo.cpp | 185 +++++++++++++++++++++ indra/newview/llsettingsvo.h | 5 + indra/newview/llviewerregion.cpp | 1 + indra/newview/llwlhandlers.cpp | 4 +- indra/newview/llwlhandlers.h | 2 + 15 files changed, 585 insertions(+), 63 deletions(-) (limited to 'indra/llinventory/llsettingssky.cpp') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index e4291d8080..30b1d66634 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -35,7 +35,7 @@ //========================================================================= namespace { - const F32 BREAK_POINT = 0.5; + const F64 BREAK_POINT = 0.5; } //========================================================================= @@ -44,7 +44,7 @@ const std::string LLSettingsBase::SETTING_NAME("name"); const std::string LLSettingsBase::SETTING_HASH("hash"); const std::string LLSettingsBase::SETTING_TYPE("type"); -const F32Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); +const F64Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); //========================================================================= LLSettingsBase::LLSettingsBase(): @@ -60,7 +60,7 @@ LLSettingsBase::LLSettingsBase(const LLSD setting) : } //========================================================================= -void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F32 mix) +void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix) { mSettings = interpolateSDMap(mSettings, other.mSettings, mix); setDirtyFlag(true); @@ -140,7 +140,7 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons return newSettings; } -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const { LLSD newSettings; @@ -535,9 +535,9 @@ bool LLSettingsBase::Validator::verifyQuaternionNormal(LLSD &value) bool LLSettingsBase::Validator::verifyFloatRange(LLSD &value, LLSD range) { - F32 real = value.asReal(); + F64 real = value.asReal(); - F32 clampedval = llclamp(LLSD::Real(real), range[0].asReal(), range[1].asReal()); + F64 clampedval = llclamp(LLSD::Real(real), range[0].asReal(), range[1].asReal()); if (is_approx_equal(clampedval, real)) return true; @@ -561,7 +561,7 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) //========================================================================= -void LLSettingsBlender::update(F32Seconds timedelta) +void LLSettingsBlender::update(F64Seconds timedelta) { mTimeSpent += timedelta; @@ -573,7 +573,7 @@ void LLSettingsBlender::update(F32Seconds timedelta) return; } - F32 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); + F64 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); mTarget->replaceSettings(mInitial->getSettings()); mTarget->blend(mFinal, blendf); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 2b59a103ad..0a20754ffb 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -151,7 +151,7 @@ public: (const_cast(this))->updateSettings(); } - virtual void blend(const ptr_t &end, F32 blendf) = 0; + virtual void blend(const ptr_t &end, F64 blendf) = 0; virtual bool validate(); @@ -198,8 +198,8 @@ protected: typedef std::set stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, F32 mix); - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const; + virtual void lerpSettings(const LLSettingsBase &other, F64 mix); + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const; /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -240,10 +240,10 @@ public: typedef boost::signals2::signal finish_signal_t; typedef boost::signals2::connection connection_t; - static const F32Seconds DEFAULT_THRESHOLD; + static const F64Seconds DEFAULT_THRESHOLD; LLSettingsBlender(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F32Seconds seconds) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) : mTarget(target), mInitial(initsetting), mFinal(endsetting), @@ -254,23 +254,34 @@ public: mTimeSpent(0.0f) { mTarget->replaceSettings(mInitial->getSettings()); - mTimeStart = F32Seconds(LLDate::now().secondsSinceEpoch()); + mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; } ~LLSettingsBlender() {} + void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 seconds ) + { + mInitial = initsetting; + mFinal = endsetting; + mSeconds.value(seconds); + mTarget->replaceSettings(mInitial->getSettings()); + mTimeStart.value(LLDate::now().secondsSinceEpoch()); + mLastUpdate = mTimeStart; + mTimeSpent.value(0.0f); + } + connection_t setOnFinished(const finish_signal_t::slot_type &onfinished) { return mOnFinished.connect(onfinished); } - void setUpdateThreshold(F32Seconds threshold) + void setUpdateThreshold(F64Seconds threshold) { mBlendThreshold = threshold; } - F32Seconds getUpdateThreshold() const + F64Seconds getUpdateThreshold() const { return mBlendThreshold; } @@ -290,17 +301,17 @@ public: return mFinal; } - void update(F32Seconds time); + void update(F64Seconds time); private: LLSettingsBase::ptr_t mTarget; LLSettingsBase::ptr_t mInitial; LLSettingsBase::ptr_t mFinal; - F32Seconds mSeconds; + F64Seconds mSeconds; finish_signal_t mOnFinished; - F32Seconds mBlendThreshold; - F32Seconds mLastUpdate; - F32Seconds mTimeSpent; - F32Seconds mTimeStart; + F64Seconds mBlendThreshold; + F64Seconds mLastUpdate; + F64Seconds mTimeSpent; + F64Seconds mTimeStart; }; #endif diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 687210e127..180992cd29 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -104,11 +104,14 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash"); const std::string LLSettingsDay::SETTING_TRACKS("tracks"); const std::string LLSettingsDay::SETTING_FRAMES("frames"); -const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins - -//const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins +const S64 LLSettingsDay::DEFAULT_DAYLENGTH( 14400); // 4 hours const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days +const S32 LLSettingsDay::MINIMUM_DAYOFFSET( 0); +const S32 LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) +const S32 LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours + const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water const S32 LLSettingsDay::FRAME_MAX(56); @@ -116,14 +119,18 @@ const S32 LLSettingsDay::FRAME_MAX(56); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), - mInitialized(false) + mInitialized(false), + mDayLength(DEFAULT_DAYLENGTH), + mDayOffset(DEFAULT_DAYOFFSET) { mDayTracks.resize(TRACK_MAX); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false) + mInitialized(false), + mDayLength(DEFAULT_DAYLENGTH), + mDayOffset(DEFAULT_DAYOFFSET) { mDayTracks.resize(TRACK_MAX); } @@ -266,7 +273,7 @@ LLSD LLSettingsDay::defaults() return dfltsetting; } -void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F32 mix) +void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F64 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; } @@ -337,19 +344,30 @@ LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const return validation; } +LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track) +{ + static CycleTrack_t emptyTrack; + if (mDayTracks.size() <= track) + return emptyTrack; + + return mDayTracks[track]; +} + //========================================================================= F32 LLSettingsDay::secondsToKeyframe(S64Seconds seconds) { S64Seconds daylength = getDayLength(); + S64Seconds dayoffset = getDayOffset(); - return llclamp(static_cast(seconds.value() % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); + return llclamp(static_cast((seconds.value() + dayoffset.value()) % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); } F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe) { S64Seconds daylength = getDayLength(); + S64Seconds dayoffset = getDayOffset(); - return F64Seconds(static_cast(keyframe * static_cast(daylength.value()))); + return F64Seconds(static_cast(keyframe * static_cast(daylength.value())) - dayoffset.value()); } //========================================================================= @@ -424,13 +442,6 @@ void LLSettingsDay::updateSettings() } //========================================================================= -void LLSettingsDay::setDayLength(S64Seconds seconds) -{ - S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); - - setValue(SETTING_DAYLENGTH, val); -} - LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) { if ((trackno < 1) || (trackno >= TRACK_MAX)) diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 3b24ce9f97..ae47a54270 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -48,8 +48,13 @@ public: static const std::string SETTING_FRAMES; static const S64 MINIMUM_DAYLENGTH; + static const S64 DEFAULT_DAYLENGTH; static const S64 MAXIMUM_DAYLENGTH; + static const S32 MINIMUM_DAYOFFSET; + static const S32 DEFAULT_DAYOFFSET; + static const S32 MAXIMUM_DAYOFFSET; + static const S32 TRACK_WATER; static const S32 TRACK_MAX; static const S32 FRAME_MAX; @@ -74,17 +79,30 @@ public: virtual std::string getSettingType() const { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix); + virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix); static LLSD defaults(); //--------------------------------------------------------------------- S64Seconds getDayLength() const { - return S64Seconds(mSettings[SETTING_DAYLENGTH].asInteger()); + return mDayLength; + } + + void setDayLength(S64Seconds seconds) + { + mDayLength = seconds; + } + + S64Seconds getDayOffset() const + { + return mDayOffset; } - void setDayLength(S64Seconds seconds); + void setDayOffset(S64Seconds seconds) + { + mDayOffset = seconds; + } KeyframeList_t getTrackKeyframes(S32 track); TimeList_t getTrackTimes(S32 track); @@ -117,6 +135,7 @@ public: virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const = 0; void setInitialized(bool value = true) { mInitialized = value; } + CycleTrack_t & getCycleTrack(S32 track); protected: LLSettingsDay(); @@ -137,6 +156,9 @@ private: F64Seconds mLastUpdateTime; + S64Seconds mDayLength; + S64Seconds mDayOffset; + F32 secondsToKeyframe(S64Seconds seconds); F64Seconds keyframeToSeconds(F32 keyframe); diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index ecc89165e8..7fc9d83cae 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -96,7 +96,7 @@ LLSettingsSky::LLSettingsSky(): { } -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index ff4b62f86e..12ea237ef3 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -75,7 +75,7 @@ public: virtual std::string getSettingType() const { return std::string("sky"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf); static LLSD defaults(); @@ -410,6 +410,10 @@ public: } protected: + static const std::string SETTING_LEGACY_EAST_ANGLE; + static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; + static const std::string SETTING_LEGACY_SUN_ANGLE; + LLSettingsSky(); virtual stringset_t getSlerpKeys() const; @@ -421,10 +425,6 @@ protected: static LLSD translateLegacySettings(LLSD legacy); private: - static const std::string SETTING_LEGACY_EAST_ANGLE; - static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; - static const std::string SETTING_LEGACY_SUN_ANGLE; - static const F32 NIGHTTIME_ELEVATION; static const F32 NIGHTTIME_ELEVATION_COS; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 1b960746d5..00f870bbb0 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -159,7 +159,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) return newsettings; } -void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 5d6a482d56..d18caf68b1 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -60,7 +60,7 @@ public: virtual std::string getSettingType() const { return std::string("water"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf); static LLSD defaults(); @@ -199,16 +199,6 @@ public: } protected: - LLSettingsWater(); - - virtual validation_list_t getValidationList() const; - - static LLSD translateLegacySettings(LLSD legacy); - - LLVector4 mWaterPlane; - F32 mWaterFogKS; - -private: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; static const std::string SETTING_LEGACY_FOG_COLOR; static const std::string SETTING_LEGACY_FOG_DENSITY; @@ -222,6 +212,17 @@ private: static const std::string SETTING_LEGACY_WAVE1_DIR; static const std::string SETTING_LEGACY_WAVE2_DIR; + LLSettingsWater(); + + virtual validation_list_t getValidationList() const; + + static LLSD translateLegacySettings(LLSD legacy); + + LLVector4 mWaterPlane; + F32 mWaterFogKS; + +private: + }; #endif diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e8c9db045c..e14265d950 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -45,8 +45,11 @@ #include "lldiriterator.h" #include "llsettingsvo.h" +#include "llnotificationsutil.h" #include + +#define EXPORT_PRESETS 1 //========================================================================= namespace { @@ -75,7 +78,9 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(ENV_LOCAL) + mSelectedEnvironment(ENV_LOCAL), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET) { mSetSkys.resize(ENV_END); mSetWater.resize(ENV_END); @@ -146,7 +151,8 @@ void LLEnvironment::onRegionChange() void LLEnvironment::requestRegionEnvironment() { - LLEnvironmentRequest::initiate(); +// LLEnvironmentRequest::initiate(); + requestRegion(); } void LLEnvironment::onLegacyRegionSettings(LLSD data) @@ -182,6 +188,20 @@ bool LLEnvironment::getIsDayTime() const return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } +void LLEnvironment::setDayLength(S64Seconds seconds) +{ + mDayLength = seconds; + if (mCurrentDay) + mCurrentDay->setDayLength(mDayLength); +} + +void LLEnvironment::setDayOffset(S64Seconds seconds) +{ + mDayOffset = seconds; + if (mCurrentDay) + mCurrentDay->setDayOffset(seconds); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -455,6 +475,8 @@ void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seco } mCurrentDay = daycycle; + mCurrentDay->setDayLength(mDayLength); + mCurrentDay->setDayOffset(mDayOffset); daycycle->startDayCycle(); selectWater(daycycle->getCurrentWater(), transition); @@ -740,6 +762,238 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const return boost::static_pointer_cast((*it).second); } + +void LLEnvironment::applyEnvironment(LLSD environment) +{ + LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + + S32 daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + S32 dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + + if (environment.has("day_length")) + daylength = environment["day_length"].asInteger(); + if (environment.has("day_offset")) + dayoffset = environment["day_cycle"].asInteger(); + + setDayLength(S64Seconds(daylength)); + setDayOffset(S64Seconds(dayoffset)); + + if (environment.has("day_cycle")) + { + LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(environment["day_cycle"]); + + if (pday) + selectDayCycle(pday); + } + + /*TODO: track_altitudes*/ +} + +//========================================================================= +void LLEnvironment::requestRegion() +{ + if (gAgent.getRegionCapability("ExtEnvironment").empty()) + { + LLEnvironmentRequest::initiate(); + return; + } + + requestParcel(LLUUID::null); +} + +void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +{ + if (gAgent.getRegionCapability("ExtEnvironment").empty()) + { + LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); + return; + } + + updateParcel(LLUUID::null, pday, day_length, day_offset); +} + +void LLEnvironment::resetRegion() +{ + resetParcel(LLUUID::null); +} + +void LLEnvironment::requestParcel(const LLUUID &parcel_id) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id)); + +} + +void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, pday, day_length, day_offset)); + +} + +void LLEnvironment::resetParcel(const LLUUID &parcel_id) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id)); + +} + +void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + LLSD body(LLSD::emptyMap()); + body["environment"] = LLSD::emptyMap(); + + if (day_length >= 0) + body["environment"]["day_length"] = day_length; + if (day_offset >= 0) + body["environment"]["day_offset"] = day_offset; + if (pday) + body["environment"]["day_cycle"] = pday->getSettings(); + + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } + +} + + //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): mUseRegionSettings(true), @@ -906,6 +1160,18 @@ void LLEnvironment::legacyLoadAllPresets() LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); + +#ifdef EXPORT_PRESETS + std::string exportfile = LLURI::escape(name) + "(new).xml"; + std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); + + LLSD settings = day->getSettings(); + + std::ofstream daycyclefile(exportpath); + LLPointer formatter = new LLSDXMLFormatter(); + formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); + daycyclefile.close(); +#endif } } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 4d3d1f6a57..9e9c05b194 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -181,6 +181,10 @@ public: inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } inline LLVector4 getRotatedLight() const { return mRotatedLight; } + inline S64Seconds getDayLength() const { return mDayLength; } + void setDayLength(S64Seconds seconds); + inline S64Seconds getDayOffset() const { return mDayOffset; } + void setDayOffset(S64Seconds seconds); //------------------------------------------- connection_t setSkyListChange(const change_signal_t::slot_type& cb); connection_t setWaterListChange(const change_signal_t::slot_type& cb); @@ -190,6 +194,13 @@ public: void onLegacyRegionSettings(LLSD data); + void requestRegion(); + void updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void resetRegion(); + void requestParcel(const LLUUID &parcel_id); + void updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void resetParcel(const LLUUID &parcel_id); + protected: virtual void initSingleton(); @@ -254,6 +265,9 @@ private: change_signal_t mWaterListChange; change_signal_t mDayCycleListChange; + S64Seconds mDayLength; + S64Seconds mDayOffset; + void onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender); void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); @@ -278,6 +292,12 @@ private: void onRegionChange(); + void coroRequestEnvironment(LLUUID parcel_id); + void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset); + void coroResetEnvironment(LLUUID parcel_id); + + void applyEnvironment(LLSD environment); + //========================================================================= void legacyLoadAllPresets(); LLSD legacyLoadPreset(const std::string& path); 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(); diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 6ef7290ba4..ba96a19d3e 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -42,6 +42,7 @@ public: static ptr_t buildDefaultSky(); virtual ptr_t buildClone(); + static LLSD convertToLegacy(const ptr_t &); protected: LLSettingsVOSky(); @@ -63,6 +64,7 @@ public: static ptr_t buildDefaultWater(); virtual ptr_t buildClone(); + static LLSD convertToLegacy(const ptr_t &); protected: LLSettingsVOWater(); @@ -86,8 +88,11 @@ public: static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); static ptr_t buildDefaultDayCycle(); + static ptr_t buildFromEnvironmentMessage(LLSD settings); virtual ptr_t buildClone(); + static LLSD convertToLegacy(const ptr_t &); + virtual LLSettingsSkyPtr_t getDefaultSky() const; virtual LLSettingsWaterPtr_t getDefaultWater() const; virtual LLSettingsSkyPtr_t buildSky(LLSD) const; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 5b61eab5f7..81be645c6a 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2823,6 +2823,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("EnvironmentSettings"); capabilityNames.append("EstateChangeInfo"); capabilityNames.append("EventQueueGet"); + capabilityNames.append("ExtEnvironment"); capabilityNames.append("FacebookConnect"); capabilityNames.append("FlickrConnect"); capabilityNames.append("TwitterConnect"); diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 0e4017a1c0..cd3310d5cb 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -164,7 +164,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) sLastUpdate = current; // Send update request. - std::string url = gAgent.getRegionCapability("EnvironmentSettings"); + std::string url = gAgent.getRegionCapability("ExtEnvironment"); if (url.empty()) { LL_WARNS("WindlightCaps") << "Applying windlight settings not supported" << LL_ENDL; @@ -244,13 +244,11 @@ void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) } LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << result["regionID"].asUUID() << LL_ENDL; - //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); } while (false); if (!notify.isUndefined()) { LLNotificationsUtil::add("WLRegionApplyFail", notify); - //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); } } diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index eb2bbf9553..857ffa9bd3 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -60,4 +60,6 @@ private: static void environmentApplyCoro(std::string url, LLSD content); }; + + #endif // LL_LLWLHANDLERS_H -- cgit v1.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/llinventory/llparcel.h | 4 +- indra/llinventory/llsettingsbase.cpp | 89 +++++---- indra/llinventory/llsettingsbase.h | 6 +- indra/llinventory/llsettingsdaycycle.cpp | 120 +++++++++++- indra/llinventory/llsettingsdaycycle.h | 9 +- indra/llinventory/llsettingssky.cpp | 5 + indra/llinventory/llsettingssky.h | 5 +- indra/llinventory/llsettingswater.cpp | 5 + indra/llinventory/llsettingswater.h | 5 +- indra/newview/llenvironment.cpp | 205 ++++++++++++++++----- indra/newview/llenvironment.h | 35 +++- indra/newview/llfloaterland.cpp | 80 ++++++-- indra/newview/llfloaterland.h | 5 +- indra/newview/llfloaterregioninfo.cpp | 84 +++++++-- indra/newview/llsettingsvo.cpp | 156 ++++++++++------ .../default/xui/en/panel_region_environment.xml | 32 ++-- 16 files changed, 636 insertions(+), 209 deletions(-) (limited to 'indra/llinventory/llsettingssky.cpp') diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index dada2cf6d8..7b4647cc5f 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -595,8 +595,8 @@ public: void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; } S64Seconds getDayOffset() const { return mDayOffset; } void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; } - bool getIsDefaultDayCycle() const { return mIsDefaultDayCycle; } - void setIsDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } + bool getUsesDefaultDayCycle() const { return mIsDefaultDayCycle; } + void setUsesDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } LLSettingsDay::ptr_t getParcelDayCycle() const { return mDayCycle; } void setParcelDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; } diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 30b1d66634..fb9d8de053 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -315,49 +315,65 @@ namespace bool LLSettingsBase::validate() { - static Validator validateName(SETTING_NAME, false, LLSD::TypeString); - static Validator validateId(SETTING_ID, false, LLSD::TypeUUID); - static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger); - static Validator validateType(SETTING_TYPE, false, LLSD::TypeString); validation_list_t validations = getValidationList(); - stringset_t validated; - stringset_t strip; if (!mSettings.has(SETTING_TYPE)) { mSettings[SETTING_TYPE] = getSettingType(); } + LLSD result = LLSettingsBase::settingValidation(mSettings, validations); + + if (result["errors"].size() > 0) + { + LL_WARNS("SETTINGS") << "Validation errors: " << result["errors"] << LL_ENDL; + } + if (result["warnings"].size() > 0) + { + LL_WARNS("SETTINGS") << "Validation warnings: " << result["errors"] << LL_ENDL; + } + + return result["success"].asBoolean(); +} + +LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &validations) +{ + static Validator validateName(SETTING_NAME, false, LLSD::TypeString); + static Validator validateId(SETTING_ID, false, LLSD::TypeUUID); + static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger); + static Validator validateType(SETTING_TYPE, false, LLSD::TypeString); + stringset_t validated; + stringset_t strip; + bool isValid(true); + LLSD errors(LLSD::emptyArray()); + LLSD warnings(LLSD::emptyArray()); + // Fields common to all settings. - if (!validateName.verify(mSettings)) + if (!validateName.verify(settings)) { - LL_WARNS("SETTINGS") << "Unable to validate Name." << LL_ENDL; - mIsValid = false; - return false; + errors.append( LLSD::String("Unable to validate 'name'.") ); + isValid = false; } validated.insert(validateName.getName()); - if (!validateId.verify(mSettings)) + if (!validateId.verify(settings)) { - LL_WARNS("SETTINGS") << "Unable to validate Id." << LL_ENDL; - mIsValid = false; - return false; + errors.append( LLSD::String("Unable to validate 'id'.") ); + isValid = false; } validated.insert(validateId.getName()); - if (!validateHash.verify(mSettings)) + if (!validateHash.verify(settings)) { - LL_WARNS("SETTINGS") << "Unable to validate Hash." << LL_ENDL; - mIsValid = false; - return false; + errors.append( LLSD::String("Unable to validate 'hash'.") ); + isValid = false; } validated.insert(validateHash.getName()); - if (!validateType.verify(mSettings)) + if (!validateType.verify(settings)) { - LL_WARNS("SETTINGS") << "Unable to validate Type." << LL_ENDL; - mIsValid = false; - return false; + errors.append( LLSD::String("Unable to validate 'type'.") ); + isValid = false; } validated.insert(validateType.getName()); @@ -366,47 +382,54 @@ bool LLSettingsBase::validate() { #ifdef VALIDATION_DEBUG LLSD oldvalue; - if (mSettings.has((*itv).getName())) + if (settings.has((*itv).getName())) { oldvalue = llsd_clone(mSettings[(*itv).getName()]); } #endif - if (!(*itv).verify(mSettings)) + if (!(*itv).verify(settings)) { - LL_WARNS("SETTINGS") << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!" << LL_ENDL; - mIsValid = false; - return false; + std::stringstream errtext; + + errtext << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!"; + errors.append( errtext.str() ); + isValid = false; } validated.insert((*itv).getName()); #ifdef VALIDATION_DEBUG if (!oldvalue.isUndefined()) { - if (!compare_llsd(mSettings[(*itv).getName()], oldvalue)) + if (!compare_llsd(settings[(*itv).getName()], oldvalue)) { - LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << mSettings[(*itv).getName()] << LL_ENDL; + LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << settings[(*itv).getName()] << LL_ENDL; } } #endif } // strip extra entries - for (LLSD::map_iterator itm = mSettings.beginMap(); itm != mSettings.endMap(); ++itm) + for (LLSD::map_const_iterator itm = settings.beginMap(); itm != settings.endMap(); ++itm) { if (validated.find((*itm).first) == validated.end()) { - LL_WARNS("SETTINGS") << "Stripping setting '" << (*itm).first << "'" << LL_ENDL; + std::stringstream warntext; + + warntext << "Stripping setting '" << (*itm).first << "'"; + warnings.append( warntext.str() ); strip.insert((*itm).first); } } for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its) { - mSettings.erase(*its); + settings.erase(*its); } - return true; + return LLSDMap("success", LLSD::Boolean(isValid)) + ("errors", errors) + ("warnings", warnings); } //========================================================================= diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 0a20754ffb..fa5fb7a763 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -155,7 +155,6 @@ public: virtual bool validate(); -protected: class Validator { public: @@ -192,9 +191,14 @@ protected: }; typedef std::vector validation_list_t; + static LLSD settingValidation(LLSD &settings, validation_list_t &validations); +protected: + LLSettingsBase(); LLSettingsBase(const LLSD setting); + static LLSD settingValidation(LLSD settings); + typedef std::set stringset_t; // combining settings objects. Customize for specific setting types diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 4207df0924..c7d5c35c60 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -183,7 +183,7 @@ LLSD LLSettingsDay::getSettings() const return settings; } -void LLSettingsDay::initialize() +bool LLSettingsDay::initialize() { LLSD tracks = mSettings[SETTING_TRACKS]; LLSD frames = mSettings[SETTING_FRAMES]; @@ -194,21 +194,32 @@ void LLSettingsDay::initialize() { std::string name = (*itFrame).first; LLSD data = (*itFrame).second; + LLSettingsBase::ptr_t keyframe; if (data[SETTING_TYPE].asString() == "sky") { - used[name] = buildSky(data); + keyframe = buildSky(data); } else if (data[SETTING_TYPE].asString() == "water") { - used[name] = buildWater(data); + keyframe = buildWater(data); } else { LL_WARNS("DAYCYCLE") << "Unknown child setting type '" << data[SETTING_TYPE].asString() << "' named '" << name << "'" << LL_ENDL; } + if (!keyframe) + { + LL_WARNS("DAYCYCLE") << "Invalid frame data" << LL_ENDL; + continue; + } + + used[name] = keyframe; } + bool haswater(false); + bool hassky(false); + for (S32 i = 0; (i < tracks.size()) && (i < TRACK_MAX); ++i) { mDayTracks[i].clear(); @@ -246,15 +257,27 @@ void LLSettingsDay::initialize() } if (setting) + { + if (i == TRACK_WATER) + haswater |= true; + else + hassky |= true; mDayTracks[i][keyframe] = setting; + } } } + if (!haswater || !hassky) + { + LL_WARNS("DAYCYCLE") << "Must have at least one water and one sky frame!" << LL_ENDL; + return false; + } // these are no longer needed and just take up space now. mSettings.erase(SETTING_TRACKS); mSettings.erase(SETTING_FRAMES); mInitialized = true; + return true; } @@ -288,11 +311,14 @@ namespace value.erase(value.size() - 1); } + S32 framecount(0); + for (LLSD::array_iterator track = value.beginArray(); track != value.endArray(); ++track) { S32 index = 0; while (index < (*track).size()) { + ++framecount; if (index >= LLSettingsDay::FRAME_MAX) { (*track).erase(index); @@ -323,22 +349,100 @@ namespace } } + + framecount -= value[0].size(); + + if (value[0].size() < 1) + { + LL_WARNS("SETTINGS") << "Missing water track" << LL_ENDL; + return false; + } + + if (framecount < 1) + { + LL_WARNS("SETTINGS") << "Missing sky tracks" << LL_ENDL; + return false; + } + return true; + } + + bool validateDayCycleFrames(LLSD &value) + { + bool hasSky(false); + bool hasWater(false); + + for (LLSD::map_iterator itf = value.beginMap(); itf != value.endMap(); ++itf) + { + LLSD frame = (*itf).second; + + std::string ftype = frame[LLSettingsBase::SETTING_TYPE]; + if (ftype == "sky") + { + LLSettingsSky::validation_list_t valid_sky = LLSettingsSky::validationList(); + LLSD res_sky = LLSettingsSky::settingValidation(frame, valid_sky); + LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_sky << LL_ENDL; + //_WARNS("SETTINGS") << "success=" << res_sky["success"].asBoolean() << "(" << res_sky["success"].asInteger() << ") res=" << res_sky << LL_ENDL; + + if (res_sky["success"].asInteger() == 0) + { + LL_WARNS("SETTINGS") << "Sky setting named '" << (*itf).first << "' validation failed!: " << res_sky << LL_ENDL; + LL_WARNS("SETTINGS") << "Sky: " << frame << LL_ENDL; + continue; + } + hasSky |= true; + } + else if (ftype == "water") + { + LLSettingsWater::validation_list_t valid_h2o = LLSettingsWater::validationList(); + LLSD res_h2o = LLSettingsWater::settingValidation(frame, valid_h2o); + LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_h2o << LL_ENDL; + //_WARNS("SETTINGS") << "success=" << res_h2o["success"].asBoolean() << LL_ENDL; + if (res_h2o["success"].asInteger() == 0) + { + LL_WARNS("SETTINGS") << "Water setting named '" << (*itf).first << "' validation failed!: " << res_h2o << LL_ENDL; + LL_WARNS("SETTINGS") << "Water: " << frame << LL_ENDL; + continue; + } + hasWater |= true; + } + else + { + LL_WARNS("SETTINGS") << "Unknown settings block of type '" << ftype << "' named '" << (*itf).first << "'" << LL_ENDL; + return false; + } + } + + if (!hasSky) + { + LL_WARNS("SETTINGS") << "No skies defined." << LL_ENDL; + return false; + } + + if (!hasWater) + { + LL_WARNS("SETTINGS") << "No waters defined." << LL_ENDL; + return false; + } + return true; } } LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const +{ + return LLSettingsDay::validationList(); +} + +LLSettingsDay::validation_list_t LLSettingsDay::validationList() { static validation_list_t validation; if (validation.empty()) { - validation.push_back(Validator(SETTING_TRACKS, false, LLSD::TypeArray, + validation.push_back(Validator(SETTING_TRACKS, true, LLSD::TypeArray, &validateDayCycleTrack)); - validation.push_back(Validator(SETTING_FRAMES, false, LLSD::TypeMap)); - validation.push_back(Validator(SETTING_DAYLENGTH, false, LLSD::TypeInteger, - boost::bind(&Validator::verifyIntegerRange, _1, - LLSD(LLSDArray(LLSD::Integer(MINIMUM_DAYLENGTH))(LLSD::Integer(MAXIMUM_DAYLENGTH)))))); + validation.push_back(Validator(SETTING_FRAMES, true, LLSD::TypeMap, + &validateDayCycleFrames)); } return validation; diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index ae47a54270..b3cf53869f 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -61,7 +61,7 @@ public: typedef std::map CycleTrack_t; typedef std::vector CycleList_t; - typedef boost::shared_ptr ptr_t; + typedef boost::shared_ptr ptr_t; typedef std::vector TimeList_t; typedef std::vector KeyframeList_t; typedef std::pair TrackBound_t; @@ -70,7 +70,7 @@ public: LLSettingsDay(const LLSD &data); virtual ~LLSettingsDay() { }; - void initialize(); + bool initialize(); virtual ptr_t buildClone() = 0; virtual LLSD getSettings() const; @@ -136,13 +136,14 @@ public: void setInitialized(bool value = true) { mInitialized = value; } CycleTrack_t & getCycleTrack(S32 track); + + virtual validation_list_t getValidationList() const; + static validation_list_t validationList(); protected: LLSettingsDay(); virtual void updateSettings(); - virtual validation_list_t getValidationList() const; - bool mInitialized; private: diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 7fc9d83cae..14024cf4f7 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -145,6 +145,11 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const } LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const +{ + return LLSettingsSky::validationList(); +} + +LLSettingsSky::validation_list_t LLSettingsSky::validationList() { static validation_list_t validation; diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 12ea237ef3..d36de571f6 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -409,6 +409,9 @@ public: return mTotalAmbient; } + virtual validation_list_t getValidationList() const; + static validation_list_t validationList(); + protected: static const std::string SETTING_LEGACY_EAST_ANGLE; static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; @@ -418,8 +421,6 @@ protected: virtual stringset_t getSlerpKeys() const; - virtual validation_list_t getValidationList() const; - virtual void updateSettings(); static LLSD translateLegacySettings(LLSD legacy); diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 00f870bbb0..67a9cd39cb 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -168,6 +168,11 @@ void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) } LLSettingsWater::validation_list_t LLSettingsWater::getValidationList() const +{ + return LLSettingsWater::validationList(); +} + +LLSettingsWater::validation_list_t LLSettingsWater::validationList() { static validation_list_t validation; diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index d18caf68b1..94e5583fd7 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -198,6 +198,9 @@ public: return mWaterFogKS; } + virtual validation_list_t getValidationList() const; + static validation_list_t validationList(); + protected: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; static const std::string SETTING_LEGACY_FOG_COLOR; @@ -214,8 +217,6 @@ protected: LLSettingsWater(); - virtual validation_list_t getValidationList() const; - static LLSD translateLegacySettings(LLSD legacy); LLVector4 mWaterPlane; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b05c9ee871..3451b0efef 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -52,7 +52,7 @@ #include -#define EXPORT_PRESETS 1 +//define EXPORT_PRESETS 1 //========================================================================= namespace { @@ -154,12 +154,12 @@ void LLEnvironment::onRegionChange() void LLEnvironment::onParcelChange() { - LLUUID parcel_id; + S32 parcel_id(INVALID_PARCEL_ID); LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); if (parcel) { - parcel_id = parcel->getID(); + parcel_id = parcel->getLocalID(); } requestParcel(parcel_id); @@ -167,7 +167,6 @@ void LLEnvironment::onParcelChange() void LLEnvironment::requestRegionEnvironment() { -// LLEnvironmentRequest::initiate(); requestRegion(); } @@ -243,7 +242,6 @@ void LLEnvironment::update(const LLViewerCamera * cam) if (mCurrentWater) mCurrentWater->update(); - F32 camYaw = cam->getYaw(); stop_glerror(); @@ -485,7 +483,7 @@ void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transitio void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition) { - if (!daycycle) + if (!daycycle || (daycycle == mCurrentDay)) { return; } @@ -779,30 +777,81 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const } -void LLEnvironment::applyEnvironment(LLSD environment) +void LLEnvironment::selectAgentEnvironment() { - LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + S64Seconds day_length(LLSettingsDay::DEFAULT_DAYLENGTH); + S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET); + LLSettingsDay::ptr_t pday; - S32 daylength(LLSettingsDay::DEFAULT_DAYLENGTH); - S32 dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + // TODO: First test if agent has local environment set. - if (environment.has("day_length")) - daylength = environment["day_length"].asInteger(); - if (environment.has("day_offset")) - dayoffset = environment["day_cycle"].asInteger(); + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); + LLViewerRegion *pRegion = gAgent.getRegion(); - setDayLength(S64Seconds(daylength)); - setDayOffset(S64Seconds(dayoffset)); + if (!parcel || parcel->getUsesDefaultDayCycle() || !parcel->getParcelDayCycle()) + { + day_length = pRegion->getDayLength(); + day_offset = pRegion->getDayOffset(); + pday = pRegion->getRegionDayCycle(); + } + else + { + day_length = parcel->getDayLength(); + day_offset = parcel->getDayOffset(); + pday = parcel->getParcelDayCycle(); + } - if (environment.has("day_cycle")) + if (getDayLength() != day_length) + setDayLength(day_length); + + if (getDayOffset() != day_offset) + setDayOffset(day_offset); + + if (pday) + selectDayCycle(pday); + +} + +void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) +{ + LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + + if (parcel_id == INVALID_PARCEL_ID) { - LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(environment["day_cycle"]); + LLViewerRegion *pRegion = gAgent.getRegion(); + + if (pRegion) + { + pRegion->setDayLength(envinfo->mDayLength); + pRegion->setDayOffset(envinfo->mDayOffset); + pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); + pRegion->setRegionDayCycle(LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData)); + + /*TODO: track_altitudes*/ + } + } + else + { + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (parcel->getLocalID() == parcel_id) + { + parcel->setDayLength(envinfo->mDayLength); + parcel->setDayOffset(envinfo->mDayOffset); + parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); + + LLSettingsDay::ptr_t pday; + if (!envinfo->mIsDefault) + { + pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); + } + parcel->setParcelDayCycle(pday); - if (pday) - selectDayCycle(pday); + // select parcel day + } } - /*TODO: track_altitudes*/ + selectAgentEnvironment(); } //========================================================================= @@ -814,7 +863,7 @@ void LLEnvironment::requestRegion() return; } - requestParcel(LLUUID::null); + requestParcel(INVALID_PARCEL_ID); } void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) @@ -825,42 +874,45 @@ void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 return; } - updateParcel(LLUUID::null, pday, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset); } void LLEnvironment::resetRegion() { - resetParcel(LLUUID::null); + resetParcel(INVALID_PARCEL_ID); } -void LLEnvironment::requestParcel(const LLUUID &parcel_id) +void LLEnvironment::requestParcel(S32 parcel_id) { + environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, - boost::bind(&LLEnvironment::applyEnvironment, this, _1))); + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, apply)); } -void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { + environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, - pday, day_length, day_offset, - boost::bind(&LLEnvironment::applyEnvironment, this, _1))); + pday, day_length, day_offset, apply)); } -void LLEnvironment::resetParcel(const LLUUID &parcel_id) +void LLEnvironment::resetParcel(S32 parcel_id) { + environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, - boost::bind(&LLEnvironment::applyEnvironment, this, _1))); + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, apply)); } -void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply) +void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -871,8 +923,17 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f if (url.empty()) return; - if (!parcel_id.isNull()) - url += "?parcelid=" + parcel_id.asString(); + LL_WARNS("LAPRAS") << "Requesting for parcel_id=" << parcel_id << LL_ENDL; + + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; LLSD result = httpAdapter->getAndSuspend(httpRequest, url); // results that come back may contain the new settings @@ -883,7 +944,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; std::stringstream msg; msg << status.toString() << " (Code " << status.toTerseString() << ")"; @@ -896,7 +957,8 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f LLSD environment = result["environment"]; if (environment.isDefined() && !apply.empty()) { - apply(environment); + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); } } @@ -907,7 +969,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f } } -void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply) +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -928,9 +990,17 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t if (pday) body["environment"]["day_cycle"] = pday->getSettings(); + LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL; - if (!parcel_id.isNull()) - url += "?parcelid=" + parcel_id.asString(); + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); // results that come back may contain the new settings @@ -941,7 +1011,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; std::stringstream msg; msg << status.toString() << " (Code " << status.toTerseString() << ")"; @@ -953,7 +1023,8 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t LLSD environment = result["environment"]; if (environment.isDefined() && !apply.empty()) { - apply(environment); + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); } } @@ -964,7 +1035,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t } } -void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply) +void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -975,8 +1046,15 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn if (url.empty()) return; - if (!parcel_id.isNull()) - url += "?parcelid=" + parcel_id.asString(); + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); // results that come back may contain the new settings @@ -987,7 +1065,7 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; std::stringstream msg; msg << status.toString() << " (Code " << status.toTerseString() << ")"; @@ -1000,7 +1078,8 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn LLSD environment = result["environment"]; if (environment.isDefined() && !apply.empty()) { - apply(environment); + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); } } @@ -1050,6 +1129,36 @@ void LLEnvironment::UserPrefs::store() } } +LLEnvironment::EnvironmentInfo::EnvironmentInfo(): + mParcelId(), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mDaycycleData(), + mAltitudes(), + mIsDefault(false) +{ +} + +LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LLSD environment) +{ + ptr_t pinfo = boost::make_shared(); + + if (environment.has("parcel_id")) + pinfo->mParcelId = environment["parcel_id"].asUUID(); + if (environment.has("day_length")) + pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger()); + if (environment.has("day_offset")) + pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger()); + if (environment.has("day_cycle")) + pinfo->mDaycycleData = environment["day_cycle"]; + if (environment.has("is_default")) + pinfo->mIsDefault = environment["is_default"].asBoolean(); + if (environment.has("track_altitudes")) + pinfo->mAltitudes = environment["track_altitudes"]; + + return pinfo; +} + //========================================================================= // Transitional Code. // static diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 4f8850683e..f5bd9be870 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -54,6 +54,23 @@ public: static const F32Seconds TRANSITION_DEFAULT; static const F32Seconds TRANSITION_SLOW; + struct EnvironmentInfo + { + EnvironmentInfo(); + + typedef boost::shared_ptr ptr_t; + + LLUUID mParcelId; + S64Seconds mDayLength; + S64Seconds mDayOffset; + LLSD mDaycycleData; + LLSD mAltitudes; + bool mIsDefault; + + static ptr_t extract(LLSD); + + }; + enum EnvSelection_t { ENV_LOCAL, @@ -99,7 +116,7 @@ public: typedef std::pair name_id_t; typedef std::vector list_name_id_t; typedef boost::signals2::signal change_signal_t; - typedef boost::function environment_apply_fn; + typedef boost::function environment_apply_fn; virtual ~LLEnvironment(); @@ -198,9 +215,11 @@ public: void requestRegion(); void updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); void resetRegion(); - void requestParcel(const LLUUID &parcel_id); - void updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); - void resetParcel(const LLUUID &parcel_id); + void requestParcel(S32 parcel_id); + void updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void resetParcel(S32 parcel_id); + + void selectAgentEnvironment(); protected: virtual void initSingleton(); @@ -280,11 +299,11 @@ private: void onRegionChange(); void onParcelChange(); - void coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply); - void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply); - void coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply); + void coroRequestEnvironment(S32 parcel_id, environment_apply_fn apply); + void coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply); + void coroResetEnvironment(S32 parcel_id, environment_apply_fn apply); - void applyEnvironment(LLSD environment); + void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment); //========================================================================= void legacyLoadAllPresets(); diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index fc4ab0a7a7..5d6e8885de 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -139,31 +139,21 @@ protected: LLPanelExperienceListEditor* mBlocked; }; -#if 0 + class LLPanelLandEnvironment - : public LLPanel + : public LLPanelEnvironmentInfo { public: LLPanelLandEnvironment(LLSafeHandle& parcelp); - // TODO: LAPRAS -#if 0 + virtual BOOL postBuild(); void refresh(); - void experienceAdded(const LLUUID& id, U32 xp_type, U32 access_type); - void experienceRemoved(const LLUUID& id, U32 access_type); protected: - LLPanelExperienceListEditor* setupList(const char* control_name, U32 xp_type, U32 access_type); - void refreshPanel(LLPanelExperienceListEditor* panel, U32 xp_type); LLSafeHandle& mParcel; - - LLPanelExperienceListEditor* mAllowed; - LLPanelExperienceListEditor* mBlocked; -#endif }; -#endif // inserts maturity info(icon and text) into target textbox // names_floater - pointer to floater which contains strings with maturity icons filenames @@ -346,6 +336,7 @@ void LLFloaterLand::refresh() mPanelAccess->refresh(); mPanelCovenant->refresh(); mPanelExperiences->refresh(); + mPanelEnvironment->refresh(); } @@ -418,7 +409,7 @@ void* LLFloaterLand::createPanelLandExperiences(void* data) void* LLFloaterLand::createPanelLandEnvironment(void* data) { LLFloaterLand* self = (LLFloaterLand*)data; - self->mPanelEnvironment = new LLPanelEnvironmentInfo(/*self->mParcel*/); + self->mPanelEnvironment = new LLPanelLandEnvironment(self->mParcel); return self->mPanelEnvironment; } @@ -3247,3 +3238,64 @@ void LLPanelLandExperiences::refresh() refreshPanel(mAllowed, EXPERIENCE_KEY_TYPE_ALLOWED); refreshPanel(mBlocked, EXPERIENCE_KEY_TYPE_BLOCKED); } + +//========================================================================= + +LLPanelLandEnvironment::LLPanelLandEnvironment(LLSafeHandle& parcelp): + LLPanelEnvironmentInfo(), + mParcel(parcelp) +{ +} + +BOOL LLPanelLandEnvironment::postBuild() +{ + if (!LLPanelEnvironmentInfo::postBuild()) + return FALSE; + + mAllowOverRide->setVisible(FALSE); + return TRUE; +} + +void LLPanelLandEnvironment::refresh() +{ + LLParcel* parcel = mParcel->getParcel(); + if (!parcel) + { + mRegionSettingsRadioGroup->setEnabled(FALSE); + mDayLengthSlider->setEnabled(FALSE); + mDayOffsetSlider->setEnabled(FALSE); + mAllowOverRide->setEnabled(FALSE); + + return; + } + + //BOOL owner_or_god = gAgent.isGodlike() || (parcel owner or group) + BOOL owner_or_god = true; + //BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); + + F64Hours daylength; + F64Hours dayoffset; + + daylength = parcel->getDayLength(); + dayoffset = parcel->getDayOffset(); + + if (dayoffset.value() > 12.0) + dayoffset = dayoffset - F32Hours(24.0f); + + mDayLengthSlider->setValue(daylength.value()); + mDayOffsetSlider->setValue(dayoffset.value()); + + mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1); + + setControlsEnabled(owner_or_god); + + if (!parcel->getUsesDefaultDayCycle()) + mEditingDayCycle = parcel->getParcelDayCycle()->buildClone(); + else + { + LLViewerRegion* regionp = LLViewerParcelMgr::getInstance()->getSelectionRegion(); + if (regionp) + mEditingDayCycle = regionp->getRegionDayCycle()->buildClone(); + } + +} diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index e5837b5a08..0eea46bc5a 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -67,8 +67,7 @@ class LLPanelLandRenters; class LLPanelLandCovenant; class LLParcel; class LLPanelLandExperiences; -//class LLPanelLandEnvironment; -class LLPanelEnvironmentInfo; +class LLPanelLandEnvironment; class LLFloaterLand : public LLFloater @@ -122,7 +121,7 @@ protected: LLPanelLandAccess* mPanelAccess; LLPanelLandCovenant* mPanelCovenant; LLPanelLandExperiences* mPanelExperiences; - LLPanelEnvironmentInfo *mPanelEnvironment; + LLPanelLandEnvironment *mPanelEnvironment; LLSafeHandle mParcel; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 5ce682fe8c..578c85470e 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -95,6 +95,7 @@ #include "llexperiencecache.h" #include "llpanelexperiences.h" #include "llcorehttputil.h" +#include "llenvironment.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -175,6 +176,24 @@ void unpack_request_params( } */ +class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo +{ +public: + LLPanelRegionEnvironment(); + + void refresh(); + + bool refreshFromRegion(LLViewerRegion* region); + + virtual BOOL postBuild(); + +protected: + virtual void doApply(); + +private: + LLViewerRegion * mLastRegion; +}; + bool estate_dispatch_initialized = false; @@ -3345,25 +3364,22 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id ) } //========================================================================= -class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo -{ -public: - LLPanelRegionEnvironment(); - - void refresh(); - - bool refreshFromRegion(LLViewerRegion* region); - -private: - LLViewerRegion * mLastRegion; -}; - LLPanelRegionEnvironment::LLPanelRegionEnvironment(): LLPanelEnvironmentInfo(), mLastRegion(NULL) { } + +BOOL LLPanelRegionEnvironment::postBuild() +{ + if (!LLPanelEnvironmentInfo::postBuild()) + return FALSE; + + return TRUE; +} + + void LLPanelRegionEnvironment::refresh() { refreshFromRegion(mLastRegion); @@ -3374,12 +3390,50 @@ bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region) BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - mDayLengthSlider->setValue(region->getDayLength().value()); - mDayOffsetSlider->setValue(region->getDayOffset().value()); + F64Hours daylength; + F64Hours dayoffset; + daylength = region->getDayLength(); + dayoffset = region->getDayOffset(); + + if (dayoffset.value() > 12.0) + dayoffset = dayoffset - F32Hours(24.0f); + + mDayLengthSlider->setValue(daylength.value()); + mDayOffsetSlider->setValue(dayoffset.value()); + mRegionSettingsRadioGroup->setSelectedIndex(region->getIsDefaultDayCycle() ? 0 : 1); setControlsEnabled(owner_or_god_or_manager); mLastRegion = region; + + if (region->getRegionDayCycle()) + mEditingDayCycle = region->getRegionDayCycle()->buildClone(); + return true; } + +void LLPanelRegionEnvironment::doApply() +{ + if (mRegionSettingsRadioGroup->getSelectedIndex() == 0) + { + LLEnvironment::instance().resetRegion(); + } + else + { + S64Seconds daylength; + F32Hours dayoffset_h; + + daylength = F32Hours(mDayLengthSlider->getValueF32()); + dayoffset_h = F32Hours(mDayOffsetSlider->getValueF32()); + + if (dayoffset_h.value() < 0) + { + dayoffset_h = F32Hours(24.0f) + dayoffset_h; + } + + S64Seconds dayoffset_s = dayoffset_h; + + LLEnvironment::instance().updateRegion(mEditingDayCycle, daylength.value(), dayoffset_s.value()); + } +} 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; diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml index a11b9b2d8b..21518338ff 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -10,8 +10,8 @@ name="panel_env_info" width="530">