From e045d212d35354d679c2d2e05c6d4689f9f8ac95 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Mon, 27 Sep 2010 22:56:08 -0400 Subject: STORM-1126 WIP Windlight Estate Settings port from 1.23: first pass at merging in windlight estate settings to viewer-dev codebase. not built, not tested. Probably needs a bunch of fixes to be able to be integrated. (resubmitted by Vadim ProductEngine) --- indra/newview/llwlparammanager.cpp | 441 ++++++++++++++++++++++++------------- 1 file changed, 282 insertions(+), 159 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 9b6047395a..493d066942 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -2,25 +2,31 @@ * @file llwlparammanager.cpp * @brief Implementation for the LLWLParamManager class. * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, 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. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * 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. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * 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 + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -31,28 +37,34 @@ #include "pipeline.h" #include "llsky.h" -#include "llfloaterreg.h" #include "llsliderctrl.h" #include "llspinctrl.h" #include "llcheckboxctrl.h" #include "lluictrlfactory.h" +#include "llviewercamera.h" #include "llcombobox.h" #include "lllineeditor.h" #include "llsdserialize.h" #include "v4math.h" +#include "llviewerdisplay.h" #include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "lldrawpoolwater.h" +#include "llagent.h" +#include "llviewerregion.h" +#include "llenvmanager.h" #include "llwlparamset.h" #include "llpostprocess.h" #include "llfloaterwindlight.h" #include "llfloaterdaycycle.h" #include "llfloaterenvsettings.h" +#include "llviewershadermgr.h" +#include "llglslshader.h" #include "curl/curl.h" - -LLWLParamManager * LLWLParamManager::sInstance = NULL; -static LLFastTimer::DeclareTimer FTM_UPDATE_WLPARAM("Update Windlight Params"); +#include "llstreamtools.h" LLWLParamManager::LLWLParamManager() : @@ -95,19 +107,150 @@ LLWLParamManager::~LLWLParamManager() { } +void LLWLParamManager::clearParamSetsOfScope(LLWLParamKey::EScope scope) +{ + if (LLWLParamKey::SCOPE_LOCAL == scope) + { + LL_WARNS("Windlight") << "Tried to clear windlight sky presets from local system! This shouldn't be called..." << LL_ENDL; + return; + } + + std::set to_remove; + for(std::map::iterator iter = mParamList.begin(); iter != mParamList.end(); ++iter) + { + if(iter->first.scope == scope) + { + to_remove.insert(iter->first); + } + } + + for(std::set::iterator iter = to_remove.begin(); iter != to_remove.end(); ++iter) + { + mParamList.erase(*iter); + } +} + +// returns all skies referenced by the day cycle, with their final names +// side effect: applies changes to all internal structures! +std::map LLWLParamManager::finalizeFromDayCycle(LLWLParamKey::EScope scope) +{ + std::map final_references; + + // Move all referenced to desired scope, renaming if necessary + // First, save skies referenced + std::map current_references; // all skies referenced by the day cycle, with their current names + // guard against skies with same name and different scopes + std::set inserted_names; + std::map conflicted_names; // integer later used as a count, for uniquely renaming conflicts + + LLWLDayCycle& cycle = mDay; + for(std::map::iterator iter = cycle.mTimeMap.begin(); + iter != cycle.mTimeMap.end(); + ++iter) + { + LLWLParamKey& key = iter->second; + std::string desired_name = key.name; + replace_newlines_with_whitespace(desired_name); // already shouldn't have newlines, but just in case + if(inserted_names.find(desired_name) == inserted_names.end()) + { + inserted_names.insert(desired_name); + } + else + { + // make exist in map + conflicted_names[desired_name] = 0; + } + current_references[key] = mParamList[key]; + } + + // forget all old skies in target scope, and rebuild, renaming as needed + clearParamSetsOfScope(scope); + for(std::map::iterator iter = current_references.begin(); iter != current_references.end(); ++iter) + { + const LLWLParamKey& old_key = iter->first; + + std::string desired_name(old_key.name); + replace_newlines_with_whitespace(desired_name); + + LLWLParamKey new_key(desired_name, scope); // name will be replaced later if necessary + + // if this sky is one with a non-unique name, rename via appending a number + // an existing preset of the target scope gets to keep its name + if (scope != old_key.scope && conflicted_names.find(desired_name) != conflicted_names.end()) + { + std::string& new_name = new_key.name; + + do + { + // if this executes more than once, this is an absurdly pathological case + // (e.g. "x" repeated twice, but "x 1" already exists, so need to use "x 2") + std::stringstream temp; + temp << desired_name << " " << (++conflicted_names[desired_name]); + new_name = temp.str(); + } while (inserted_names.find(new_name) != inserted_names.end()); + + // yay, found one that works + inserted_names.insert(new_name); // track names we consume here; shouldn't be necessary due to ++int? but just in case + + // *TODO factor out below into a rename()? + + LL_INFOS("Windlight") << "Renamed " << old_key.name << " (scope" << old_key.scope << ") to " + << new_key.name << " (scope " << new_key.scope << ")" << LL_ENDL; + + // update name in sky + iter->second.mName = new_name; + + // update keys in day cycle + for(std::map::iterator frame = cycle.mTimeMap.begin(); frame != cycle.mTimeMap.end(); ++frame) + { + if (frame->second == old_key) + { + frame->second = new_key; + } + } + + // add to master sky map + mParamList[new_key] = iter->second; + } + + final_references[new_key] = iter->second; + } + + return final_references; +} + +LLSD LLWLParamManager::createSkyMap(std::map refs) +{ + LLSD skies = LLSD::emptyMap(); + for(std::map::iterator iter = refs.begin(); iter != refs.end(); ++iter) + { + skies.insert(iter->first.name, iter->second.getAll()); + } + return skies; +} + +void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& sky_presets) +{ + for(LLSD::map_const_iterator iter = sky_presets.beginMap(); iter != sky_presets.endMap(); ++iter) + { + LLWLParamSet set; + set.setAll(iter->second); + mParamList[LLWLParamKey(iter->first, scope)] = set; + } +} + void LLWLParamManager::loadPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); - LL_DEBUGS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL; - - bool found = true; + LL_INFOS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL; + + bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); if(found) { - name=name.erase(name.length()-4); // bugfix for SL-46920: preventing filenames that break stuff. @@ -117,16 +260,16 @@ void LLWLParamManager::loadPresets(const std::string& file_name) curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - loadPreset(unescaped_name,FALSE); + loadPreset(LLWLParamKey(unescaped_name, LLWLParamKey::SCOPE_LOCAL),FALSE); } } // And repeat for user presets, note the user presets will modify any system presets already loaded std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); - LL_DEBUGS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL; - - found = true; + LL_INFOS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL; + + found = true; while(found) { std::string name; @@ -142,12 +285,14 @@ void LLWLParamManager::loadPresets(const std::string& file_name) curl_str = NULL; LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - loadPreset(unescaped_name,FALSE); + loadPreset(LLWLParamKey(unescaped_name,LLWLParamKey::SCOPE_LOCAL),FALSE); } } } +// untested and unmaintained! sanity-check me before using +/* void LLWLParamManager::savePresets(const std::string & fileName) { //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder @@ -157,11 +302,11 @@ void LLWLParamManager::savePresets(const std::string & fileName) std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", fileName)); - for(std::map::iterator mIt = mParamList.begin(); + for(std::map::iterator mIt = mParamList.begin(); mIt != mParamList.end(); ++mIt) { - paramsData[mIt->first] = mIt->second.getAll(); + paramsData[mIt->first.name] = mIt->second.getAll(); } llofstream presetsXML(pathName); @@ -172,70 +317,78 @@ void LLWLParamManager::savePresets(const std::string & fileName) presetsXML.close(); } +*/ -void LLWLParamManager::loadPreset(const std::string & name,bool propagate) +void LLWLParamManager::loadPreset(const LLWLParamKey key, bool propagate) { - - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_escape(name.c_str(), name.size()); - std::string escaped_filename(curl_str); - curl_free(curl_str); - curl_str = NULL; - - escaped_filename += ".xml"; - - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading WindLight sky setting from " << pathName << LL_ENDL; - - llifstream presetsXML; - presetsXML.open(pathName.c_str()); - - // That failed, try loading from the users area instead. - if(!presetsXML) + if(mParamList.find(key) == mParamList.end()) // key does not already exist in mapping { - pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename); - LL_DEBUGS2("AppInit", "Shaders") << "Loading User WindLight sky setting from " << pathName << LL_ENDL; - presetsXML.clear(); - presetsXML.open(pathName.c_str()); - } + if(key.scope == LLWLParamKey::SCOPE_LOCAL) // local scope, so try to load from file + { + // bugfix for SL-46920: preventing filenames that break stuff. + char * curl_str = curl_escape(key.name.c_str(), key.name.size()); + std::string escaped_filename(curl_str); + curl_free(curl_str); + curl_str = NULL; - if (presetsXML) - { - LLSD paramsData(LLSD::emptyMap()); + escaped_filename += ".xml"; - LLPointer parser = new LLSDXMLParser(); + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); + llinfos << "Loading WindLight sky setting from " << pathName << llendl; - parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); + llifstream presetsXML; + presetsXML.open(pathName.c_str()); - std::map::iterator mIt = mParamList.find(name); - if(mIt == mParamList.end()) - { - addParamSet(name, paramsData); + // That failed, try loading from the users area instead. + if(!presetsXML) + { + pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename); + llinfos << "Loading User WindLight sky setting from " << pathName << llendl; + presetsXML.open(pathName.c_str()); + } + + if (presetsXML) + { + loadPresetFromXML(key, presetsXML); + presetsXML.close(); + } + else + { + llwarns << "Could not load local WindLight sky setting " << key.toString() << llendl; + return; + } } - else + else { - setParamSet(name, paramsData); - } - presetsXML.close(); - } - else - { - llwarns << "Can't find " << name << llendl; - return; + llwarns << "Attempted to load non-local WindLight sky settings " << key.toString() << "; not found in parameter mapping." << llendl; + return; + } } - if(propagate) { - getParamSet(name, mCurParams); + getParamSet(key, mCurParams); propagateParameters(); } -} +} -void LLWLParamManager::savePreset(const std::string & name) +void LLWLParamManager::loadPresetFromXML(LLWLParamKey key, std::istream & presetsXML) +{ + LLSD paramsData(LLSD::emptyMap()); + LLPointer parser = new LLSDXMLParser(); + + parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); + + std::map::iterator mIt = mParamList.find(key); + + if(mIt == mParamList.end()) addParamSet(key, paramsData); + else setParamSet(key, paramsData); +} + +void LLWLParamManager::savePreset(LLWLParamKey key) { // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_escape(name.c_str(), name.size()); + char * curl_str = curl_escape(key.name.c_str(), key.name.size()); std::string escaped_filename(curl_str); curl_free(curl_str); curl_str = NULL; @@ -247,7 +400,7 @@ void LLWLParamManager::savePreset(const std::string & name) std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename)); // fill it with LLSD windlight params - paramsData = mParamList[name].getAll(); + paramsData = mParamList[key].getAll(); // write to file llofstream presetsXML(pathName); @@ -282,7 +435,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) void LLWLParamManager::propagateParameters(void) { - LLFastTimer ftm(FTM_UPDATE_WLPARAM); + LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); LLVector4 sunDir; LLVector4 moonDir; @@ -306,7 +459,7 @@ void LLWLParamManager::propagateParameters(void) { mLightDir = sunDir; } - else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) + else if(sunDir.mV[1] < 0 && sunDir.mV[1] > NIGHTTIME_ELEVATION_COS) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); @@ -353,13 +506,13 @@ void LLWLParamManager::propagateParameters(void) void LLWLParamManager::update(LLViewerCamera * cam) { - LLFastTimer ftm(FTM_UPDATE_WLPARAM); + LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); // update clouds, sun, and general mCurParams.updateCloudScrolling(); // update only if running - if(mAnimator.mIsRunning) + if(mAnimator.getIsRunning()) { mAnimator.update(mCurParams); } @@ -368,30 +521,29 @@ void LLWLParamManager::update(LLViewerCamera * cam) propagateParameters(); // sync menus if they exist - LLFloaterWindLight* wlfloater = LLFloaterReg::findTypedInstance("env_windlight"); - if (wlfloater) + if(LLFloaterWindLight::isOpen()) { - wlfloater->syncMenu(); + LLFloaterWindLight::instance()->syncMenu(); } - LLFloaterDayCycle* dlfloater = LLFloaterReg::findTypedInstance("env_day_cycle"); - if (dlfloater) + if(LLFloaterDayCycle::isOpen()) { - dlfloater->syncMenu(); + LLFloaterDayCycle::instance()->syncMenu(); } - LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("env_settings"); - if (envfloater) + if(LLFloaterEnvSettings::isOpen()) { - envfloater->syncMenu(); + LLFloaterEnvSettings::instance()->syncMenu(); } F32 camYaw = cam->getYaw(); + stop_glerror(); + // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; - LLVector3 lightNorm3(mLightDir); + LLVector3 lightNorm3(mLightDir); lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); mRotatedLightDir = LLVector4(lightNorm3, 0.f); @@ -409,19 +561,6 @@ void LLWLParamManager::update(LLViewerCamera * cam) } } -// static -void LLWLParamManager::initClass(void) -{ - instance(); -} - -// static -void LLWLParamManager::cleanupClass() -{ - delete sInstance; - sInstance = NULL; -} - void LLWLParamManager::resetAnimator(F32 curTime, bool run) { mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, @@ -429,26 +568,27 @@ void LLWLParamManager::resetAnimator(F32 curTime, bool run) return; } -bool LLWLParamManager::addParamSet(const std::string& name, LLWLParamSet& param) + +bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) { // add a new one if not one there already - std::map::iterator mIt = mParamList.find(name); + std::map::iterator mIt = mParamList.find(key); if(mIt == mParamList.end()) { - mParamList[name] = param; + mParamList[key] = param; return true; } return false; } -BOOL LLWLParamManager::addParamSet(const std::string& name, LLSD const & param) +BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) { // add a new one if not one there already - std::map::const_iterator finder = mParamList.find(name); + std::map::const_iterator finder = mParamList.find(key); if(finder == mParamList.end()) { - mParamList[name].setAll(param); + mParamList[key].setAll(param); return TRUE; } else @@ -457,105 +597,88 @@ BOOL LLWLParamManager::addParamSet(const std::string& name, LLSD const & param) } } -bool LLWLParamManager::getParamSet(const std::string& name, LLWLParamSet& param) +bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) { // find it and set it - std::map::iterator mIt = mParamList.find(name); + std::map::iterator mIt = mParamList.find(key); if(mIt != mParamList.end()) { - param = mParamList[name]; - param.mName = name; + param = mParamList[key]; + param.mName = key.name; return true; } return false; } -bool LLWLParamManager::setParamSet(const std::string& name, LLWLParamSet& param) +bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) { - mParamList[name] = param; + mParamList[key] = param; return true; } -bool LLWLParamManager::setParamSet(const std::string& name, const LLSD & param) +bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) { // quick, non robust (we won't be working with files, but assets) check + // this might not actually be true anymore.... if(!param.isMap()) { return false; } - mParamList[name].setAll(param); + mParamList[key].setAll(param); return true; } -bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_disk) +void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) { // remove from param list - std::map::iterator mIt = mParamList.find(name); + std::map::iterator mIt = mParamList.find(key); if(mIt != mParamList.end()) { mParamList.erase(mIt); } - - F32 key; - - // remove all references - bool stat = true; - do + else { - // get it - stat = mDay.getKey(name, key); - if(stat == false) - { - break; - } + LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << "; not found." << LL_ENDL; + } - // and remove - stat = mDay.removeKey(key); + mDay.removeReferencesTo(key); - } while(stat == true); - - if(delete_from_disk) + if(delete_from_disk && key.scope == LLWLParamKey::SCOPE_LOCAL) { std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); // use full curl escaped name - char * curl_str = curl_escape(name.c_str(), name.size()); + char * curl_str = curl_escape(key.name.c_str(), key.name.size()); std::string escaped_name(curl_str); curl_free(curl_str); curl_str = NULL; - gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); + if(gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml") < 1) + { + LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << " from disk; not found." << LL_ENDL; + } } - - return true; } -// static -LLWLParamManager * LLWLParamManager::instance() +// virtual static +void LLWLParamManager::initSingleton() { - if(NULL == sInstance) - { - sInstance = new LLWLParamManager(); + loadPresets(LLStringUtil::null); - sInstance->loadPresets(LLStringUtil::null); + // load the day + mDay.loadDayCycleFromFile(std::string("Default.xml")); - // load the day - sInstance->mDay.loadDayCycle(std::string("Default.xml")); + // *HACK - sets cloud scrolling to what we want... fix this better in the future + getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); - // *HACK - sets cloud scrolling to what we want... fix this better in the future - sInstance->getParamSet("Default", sInstance->mCurParams); - - // set it to noon - sInstance->resetAnimator(0.5, true); - - // but use linden time sets it to what the estate is - sInstance->mAnimator.mUseLindenTime = true; - } + // set it to noon + resetAnimator(0.5, true); - return sInstance; + // but use linden time sets it to what the estate is + mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); } -- cgit v1.2.3 From 2fb337bc12984f9abecfbc7f3918c372a7b5ac6c Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Thu, 30 Sep 2010 23:21:23 -0400 Subject: STORM-1126 WIP Windlight Estate Settings port from 1.23: second pass at getting windlight ported to V2. Lots of cleanup in the floater classes. Not sure every decision was correct but it compiles now. Doesn't link yet. (resubmitted by Vadim ProductEngine) --- indra/newview/llwlparammanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 493d066942..3070fed81f 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -433,9 +433,11 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) } +static LLFastTimer::DeclareTimer FTM_UPDATE_WLPARAM("Update Windlight Params"); + void LLWLParamManager::propagateParameters(void) { - LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); + LLFastTimer ftm(FTM_UPDATE_WLPARAM); LLVector4 sunDir; LLVector4 moonDir; @@ -459,7 +461,7 @@ void LLWLParamManager::propagateParameters(void) { mLightDir = sunDir; } - else if(sunDir.mV[1] < 0 && sunDir.mV[1] > NIGHTTIME_ELEVATION_COS) + else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); @@ -506,7 +508,7 @@ void LLWLParamManager::propagateParameters(void) void LLWLParamManager::update(LLViewerCamera * cam) { - LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); + LLFastTimer ftm(FTM_UPDATE_WLPARAM); // update clouds, sun, and general mCurParams.updateCloudScrolling(); -- cgit v1.2.3 From 758fdbfe125d75bd2253a69337eab7fec7406ecf Mon Sep 17 00:00:00 2001 From: "tiggs@lindenlab.com" Date: Wed, 23 Feb 2011 17:44:18 -0500 Subject: STORM-1126 WIP Windlight Estate Settings port from 1.23: baseline: read only windlight works (resubmitted by Vadim ProductEngine) --- indra/newview/llwlparammanager.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 3070fed81f..2adf9f4a77 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -37,6 +37,7 @@ #include "pipeline.h" #include "llsky.h" +#include "llfloaterreg.h" #include "llsliderctrl.h" #include "llspinctrl.h" #include "llcheckboxctrl.h" @@ -57,6 +58,7 @@ #include "llenvmanager.h" #include "llwlparamset.h" #include "llpostprocess.h" + #include "llfloaterwindlight.h" #include "llfloaterdaycycle.h" #include "llfloaterenvsettings.h" @@ -523,17 +525,20 @@ void LLWLParamManager::update(LLViewerCamera * cam) propagateParameters(); // sync menus if they exist - if(LLFloaterWindLight::isOpen()) + LLFloaterWindLight* wlfloater = LLFloaterReg::findTypedInstance("env_windlight"); + if (wlfloater) { - LLFloaterWindLight::instance()->syncMenu(); + wlfloater->syncMenu(); } - if(LLFloaterDayCycle::isOpen()) + LLFloaterDayCycle* dlfloater = LLFloaterReg::findTypedInstance("env_day_cycle"); + if (dlfloater) { - LLFloaterDayCycle::instance()->syncMenu(); + dlfloater->syncMenu(); } - if(LLFloaterEnvSettings::isOpen()) + LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("env_settings"); + if (envfloater) { - LLFloaterEnvSettings::instance()->syncMenu(); + envfloater->syncMenu(); } F32 camYaw = cam->getYaw(); -- cgit v1.2.3 From 79fb8e2ec26dc2c5a42ef1ee48ebaaa39183c67b Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 31 Mar 2011 18:24:01 +0300 Subject: STORM-1126 WIP Windlight Estate Settings integration: pass 4 Changes: * Fixed incorrect way to pass parameters to notifications. * Fixed crashes in the Advanced Sky floater and the Region Terrain panel. * Fixed initialization and multiple instantiation of the Day Cycle floater (that might lead to incorrect behavior). * Fixed and re-enabled committing env. settings changes to region. * Fixed day cycle and sky settings being sent as empty arrays and therefore not passing validation on server. It is now possible to change region environment settings. * Added debug messages. --- indra/newview/llwlparammanager.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 2adf9f4a77..470c4dcbec 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -136,6 +136,15 @@ void LLWLParamManager::clearParamSetsOfScope(LLWLParamKey::EScope scope) // side effect: applies changes to all internal structures! std::map LLWLParamManager::finalizeFromDayCycle(LLWLParamKey::EScope scope) { + lldebugs << "mDay before finalizing:" << llendl; + { + for (std::map::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter) + { + LLWLParamKey& key = iter->second; + lldebugs << iter->first << "->" << key.name << llendl; + } + } + std::map final_references; // Move all referenced to desired scope, renaming if necessary @@ -218,6 +227,15 @@ std::map LLWLParamManager::finalizeFromDayCycle(LLWL final_references[new_key] = iter->second; } + lldebugs << "mDay after finalizing:" << llendl; + { + for (std::map::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter) + { + LLWLParamKey& key = iter->second; + lldebugs << iter->first << "->" << key.name << llendl; + } + } + return final_references; } -- cgit v1.2.3 From 48309dcb3f5609ae72ca81a161a6efae3b2e91a1 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 31 Mar 2011 18:24:01 +0300 Subject: STORM-1126 WIP Windlight Estate Settings integration: pass 8 Eliminated more merge artifacts (superflous copyright changes). --- indra/newview/llwlparammanager.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 470c4dcbec..7d5c81109f 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -2,31 +2,25 @@ * @file llwlparammanager.cpp * @brief Implementation for the LLWLParamManager class. * - * $LicenseInfo:firstyear=2007&license=viewergpl$ - * - * Copyright (c) 2007-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -- cgit v1.2.3 From cccca566bd2365c88cca819729c5432af9dfa52f Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 16 May 2011 17:17:01 +0300 Subject: STORM-1245 WIP Reimplementing management of local presets according to the new spec. User environment preferences are now persistent. TODO: Implement applying region env. settings. --- indra/newview/llwlparammanager.cpp | 52 +++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 1da70b9557..43f0cdae93 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -580,6 +580,49 @@ void LLWLParamManager::update(LLViewerCamera * cam) } } +void LLWLParamManager::applyUserPrefs() +{ + LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL; + + if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings + { + llwarns << "Using region settings has not been implemented" << llendl; + } + else // apply user-specified settings + { + bool use_day_cycle = LLEnvManagerNew::instance().getUseDayCycle(); + + if (use_day_cycle) + { + LL_DEBUGS("Windlight") << "Loading day cycle " << LLEnvManagerNew::instance().getDayCycleName() << LL_ENDL; + mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); + } + else + { + // *HACK - sets cloud scrolling to what we want... fix this better in the future + std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); + LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; + getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); + } + + // Animator should be running if we're using a day cycle + // and be stopped if we want fixed sky. + if (use_day_cycle != mAnimator.getIsRunning()) + { + if (use_day_cycle) + { + LL_DEBUGS("Windlight") << "Activating animator" << LL_ENDL; + mAnimator.activate(mAnimator.getTimeType()); + } + else + { + LL_DEBUGS("Windlight") << "Deactivating animator" << LL_ENDL; + mAnimator.deactivate(); + } + } + } +} + void LLWLParamManager::resetAnimator(F32 curTime, bool run) { mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, @@ -687,16 +730,19 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ // virtual static void LLWLParamManager::initSingleton() { + LL_DEBUGS("Windlight") << "Initializing sky" << LL_ENDL; + loadPresets(LLStringUtil::null); // load the day - mDay.loadDayCycleFromFile(std::string("Default.xml")); + mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); // *HACK - sets cloud scrolling to what we want... fix this better in the future - getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); + std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); + getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); // set it to noon - resetAnimator(0.5, true); + resetAnimator(0.5, LLEnvManagerNew::instance().getUseDayCycle()); // but use linden time sets it to what the estate is mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); -- cgit v1.2.3 From 912f021bb11ef48f352ea85cca27c2bca6ca06b1 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 16 May 2011 17:17:22 +0300 Subject: STORM-1245 WIP Implement loading and applying region environment settings. --- indra/newview/llwlparammanager.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 43f0cdae93..4431b3f5c0 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -583,23 +583,33 @@ void LLWLParamManager::update(LLViewerCamera * cam) void LLWLParamManager::applyUserPrefs() { LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL; + clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings { - llwarns << "Using region settings has not been implemented" << llendl; + // *TODO: Support fixed sky from region. + LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; + + const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); + + if (0) // *TODO: interpolate? + { + mAnimator.startInterpolation(region_settings.getWaterParams()); + } + + addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); + mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); + resetAnimator(region_settings.getDayTime(), true); } else // apply user-specified settings { - bool use_day_cycle = LLEnvManagerNew::instance().getUseDayCycle(); + // Load day cycle anyway so that we can switch to it from a fixed sky. + LL_DEBUGS("Windlight") << "Loading day cycle " << LLEnvManagerNew::instance().getDayCycleName() << LL_ENDL; + mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); - if (use_day_cycle) - { - LL_DEBUGS("Windlight") << "Loading day cycle " << LLEnvManagerNew::instance().getDayCycleName() << LL_ENDL; - mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); - } - else + bool use_day_cycle = LLEnvManagerNew::instance().getUseDayCycle(); + if (!use_day_cycle) // if we should use fixed sky { - // *HACK - sets cloud scrolling to what we want... fix this better in the future std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); -- cgit v1.2.3 From 348218e40f362d386a0175d4b010b639282764b2 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 17 May 2011 16:26:55 +0300 Subject: STORM-1245 WIP Restored environment settings interpolation on region crossing. Also got rid of duplicated region environment settings requests. --- indra/newview/llwlparammanager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 4431b3f5c0..0913c4dec2 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -580,7 +580,7 @@ void LLWLParamManager::update(LLViewerCamera * cam) } } -void LLWLParamManager::applyUserPrefs() +void LLWLParamManager::applyUserPrefs(bool interpolate) { LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL; clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); @@ -592,13 +592,10 @@ void LLWLParamManager::applyUserPrefs() const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (0) // *TODO: interpolate? - { - mAnimator.startInterpolation(region_settings.getWaterParams()); - } - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); + LL_DEBUGS("Windlight") << "Applying region time: " << region_settings.getDayTime() + << " = " << region_settings.getDayTime() * 24.0f << " h" << LL_ENDL; resetAnimator(region_settings.getDayTime(), true); } else // apply user-specified settings -- cgit v1.2.3 From ec749bb1c1fa143c6019791d6713d85f05510e53 Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Tue, 17 May 2011 17:09:15 +0300 Subject: STORM-1244 FIXED Environment Settings floater implementation. --- indra/newview/llwlparammanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 0913c4dec2..7af17a8d0b 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -547,7 +547,7 @@ void LLWLParamManager::update(LLViewerCamera * cam) { dlfloater->syncMenu(); } - LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("env_settings"); + LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("old_env_settings"); if (envfloater) { envfloater->syncMenu(); -- cgit v1.2.3 From 242f45d167a615d091580eda12701b34a86b663d Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 17 May 2011 17:33:08 +0300 Subject: STORM-1245 WIP Fixed switching to day cycle. --- indra/newview/llwlparammanager.cpp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 7af17a8d0b..e5fb88afa2 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -600,33 +600,20 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) } else // apply user-specified settings { - // Load day cycle anyway so that we can switch to it from a fixed sky. - LL_DEBUGS("Windlight") << "Loading day cycle " << LLEnvManagerNew::instance().getDayCycleName() << LL_ENDL; - mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); - - bool use_day_cycle = LLEnvManagerNew::instance().getUseDayCycle(); - if (!use_day_cycle) // if we should use fixed sky + if (LLEnvManagerNew::instance().getUseDayCycle()) + { + std::string day_cycle = LLEnvManagerNew::instance().getDayCycleName(); + LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; + mDay.loadDayCycleFromFile(day_cycle + ".xml"); + resetAnimator(0.5, true); // set to noon and start animator + } + else { + mAnimator.deactivate(); std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); } - - // Animator should be running if we're using a day cycle - // and be stopped if we want fixed sky. - if (use_day_cycle != mAnimator.getIsRunning()) - { - if (use_day_cycle) - { - LL_DEBUGS("Windlight") << "Activating animator" << LL_ENDL; - mAnimator.activate(mAnimator.getTimeType()); - } - else - { - LL_DEBUGS("Windlight") << "Deactivating animator" << LL_ENDL; - mAnimator.deactivate(); - } - } } } -- cgit v1.2.3 From 0c358f78ab618de8727892a50cd3a3055dbdf956 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 19 May 2011 21:10:34 +0300 Subject: STORM-1269 FIXED Teleport to a region that has no env. settings now resets environment to defaults. --- indra/newview/llwlparammanager.cpp | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 562e6c9018..d64e2420e4 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -585,30 +585,35 @@ void LLWLParamManager::update(LLViewerCamera * cam) void LLWLParamManager::applyUserPrefs(bool interpolate) { - LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL; + // Remove all region sky presets because they may belong to a previously visited region. clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings { - // *TODO: Support fixed sky from region. - LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); - mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); - LL_DEBUGS("Windlight") << "Applying region time: " << region_settings.getDayTime() - << " = " << region_settings.getDayTime() * 24.0f << " h" << LL_ENDL; - resetAnimator(region_settings.getDayTime(), true); + if (region_settings.getSkyMap().size() == 0) + { + applyDefaults(); + } + else + { + // *TODO: Support fixed sky from region. + LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; + + // Add all sky presets belonging to the current region. + addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); + + // Apply region day cycle. + mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); + resetAnimator(region_settings.getDayTime(), true); + } } else // apply user-specified settings { if (LLEnvManagerNew::instance().getUseDayCycle()) { - std::string day_cycle = LLEnvManagerNew::instance().getDayCycleName(); - LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - mDay.loadDayCycleFromFile(day_cycle + ".xml"); - resetAnimator(0.5, true); // set to noon and start animator + applyDayCycle(LLEnvManagerNew::instance().getDayCycleName()); } else { @@ -620,6 +625,18 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) } } +void LLWLParamManager::applyDefaults() +{ + applyDayCycle("Default"); +} + +void LLWLParamManager::applyDayCycle(const std::string& day_cycle) +{ + LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; + mDay.loadDayCycleFromFile(day_cycle + ".xml"); + resetAnimator(0.5, true); // set to noon and start animator +} + void LLWLParamManager::resetAnimator(F32 curTime, bool run) { mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, -- cgit v1.2.3 From b60c63bf075a92084ba94459a840decba846a916 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 23 May 2011 19:26:17 +0300 Subject: STORM-1256 WIP Implemented editing region environment settings via the Region/Estate floater. --- indra/newview/llwlparammanager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index d64e2420e4..16abe2b174 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -234,6 +234,7 @@ std::map LLWLParamManager::finalizeFromDayCycle(LLWL return final_references; } +// static LLSD LLWLParamManager::createSkyMap(std::map refs) { LLSD skies = LLSD::emptyMap(); -- cgit v1.2.3 From 047f69bf618fa525410dc512977e384cbbdb4d11 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 24 May 2011 19:05:41 +0300 Subject: STORM-1256 WIP Fixed resetting the Environment tab if a server env. update comes while your preference is using personal env. settings. The fix is to re-add server skies to our WL param mgr regardless of user preferences. --- indra/newview/llwlparammanager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 16abe2b174..ec7889cb93 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -589,10 +589,12 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) // Remove all region sky presets because they may belong to a previously visited region. clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + // Add all sky presets belonging to the current region. + const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); + addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); + if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings { - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getSkyMap().size() == 0) { applyDefaults(); @@ -602,9 +604,6 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) // *TODO: Support fixed sky from region. LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - // Add all sky presets belonging to the current region. - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); - // Apply region day cycle. mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); resetAnimator(region_settings.getDayTime(), true); -- cgit v1.2.3 From c32b19f31d4d5d0b32fcf64cce1cebd7d79b9b05 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 15:11:01 +0300 Subject: STORM-1253 WIP Implemented switching between multiple day cycles (locally and region-wide). --- indra/newview/llwlparammanager.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index ec7889cb93..396c61b4b6 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -50,6 +50,7 @@ #include "llagent.h" #include "llviewerregion.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llwlparamset.h" #include "llpostprocess.h" @@ -613,7 +614,11 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) { if (LLEnvManagerNew::instance().getUseDayCycle()) { - applyDayCycle(LLEnvManagerNew::instance().getDayCycleName()); + if (!applyDayCycle(LLEnvManagerNew::instance().getDayCycleName())) + { + // *TODO: fix user prefs + applyDefaults(); + } } else { @@ -627,14 +632,21 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) void LLWLParamManager::applyDefaults() { - applyDayCycle("Default"); + llassert(applyDayCycle("Default") == true); } -void LLWLParamManager::applyDayCycle(const std::string& day_cycle) +bool LLWLParamManager::applyDayCycle(const std::string& day_cycle) { LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - mDay.loadDayCycleFromFile(day_cycle + ".xml"); + + if (!LLDayCycleManager::instance().getPreset(day_cycle, mDay)) + { + llwarns << "No day cycle named " << day_cycle << llendl; + return false; + } + resetAnimator(0.5, true); // set to noon and start animator + return true; } void LLWLParamManager::resetAnimator(F32 curTime, bool run) -- cgit v1.2.3 From c0037909d576fc4922b92dfcc83d865d61ac43cb Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 19:32:20 +0300 Subject: STORM-1284 FIXED Changes to region environment are now visible immediately. Pressing "Apply" sends the settings update to server. Pressing "Cancel" reverts to current region settings. --- indra/newview/llwlparammanager.cpp | 68 +++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 396c61b4b6..3dad7b2f4e 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -256,6 +256,15 @@ void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& } } +void LLWLParamManager::refreshRegionPresets() +{ + // Remove all region sky presets because they may belong to a previously visited region. + clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + + // Add all sky presets belonging to the current region. + addAllSkies(LLEnvKey::SCOPE_REGION, LLEnvManagerNew::instance().getRegionSettings().getSkyMap()); +} + void LLWLParamManager::loadPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); @@ -587,16 +596,11 @@ void LLWLParamManager::update(LLViewerCamera * cam) void LLWLParamManager::applyUserPrefs(bool interpolate) { - // Remove all region sky presets because they may belong to a previously visited region. - clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - // Add all sky presets belonging to the current region. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); - - if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings + if (env_mgr.getUseRegionSettings()) // apply region-wide settings { - if (region_settings.getSkyMap().size() == 0) + if (env_mgr.getRegionSettings().getSkyMap().size() == 0) { applyDefaults(); } @@ -606,15 +610,18 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; // Apply region day cycle. - mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); - resetAnimator(region_settings.getDayTime(), true); + const LLEnvironmentSettings& region_settings = env_mgr.getRegionSettings(); + applyDayCycleParams( + region_settings.getWLDayCycle(), + LLEnvKey::SCOPE_REGION, + region_settings.getDayTime()); } } else // apply user-specified settings { - if (LLEnvManagerNew::instance().getUseDayCycle()) + if (env_mgr.getUseDayCycle()) { - if (!applyDayCycle(LLEnvManagerNew::instance().getDayCycleName())) + if (!env_mgr.useDayCycle(env_mgr.getDayCycleName(), LLEnvKey::SCOPE_LOCAL)); { // *TODO: fix user prefs applyDefaults(); @@ -622,30 +629,39 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) } else { - mAnimator.deactivate(); - std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); - LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; - getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); + LLWLParamSet param_set; + std::string sky = env_mgr.getSkyPresetName(); + + if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), param_set)) + { + llwarns << "No sky named " << sky << llendl; + } + else + { + LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; + applySkyParams(param_set.getAll()); + } } } } void LLWLParamManager::applyDefaults() { - llassert(applyDayCycle("Default") == true); + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + llassert(env_mgr.useDayCycle("Default", LLEnvKey::SCOPE_LOCAL) == true); } -bool LLWLParamManager::applyDayCycle(const std::string& day_cycle) +bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) { - LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - - if (!LLDayCycleManager::instance().getPreset(day_cycle, mDay)) - { - llwarns << "No day cycle named " << day_cycle << llendl; - return false; - } + mDay.loadDayCycle(params, scope); + resetAnimator(time, true); // set to specified time and start animator + return true; +} - resetAnimator(0.5, true); // set to noon and start animator +bool LLWLParamManager::applySkyParams(const LLSD& params) +{ + mAnimator.deactivate(); + mCurParams.setAll(params); return true; } -- cgit v1.2.3 From 4f8098344e45aac1c177ba258e866c32d5287565 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 20:52:10 +0300 Subject: STORM-1284 ADDITIONAL_FIX Fixing build errors. --- indra/newview/llwlparammanager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 3dad7b2f4e..db81c3ead7 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -621,7 +621,7 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) { if (env_mgr.getUseDayCycle()) { - if (!env_mgr.useDayCycle(env_mgr.getDayCycleName(), LLEnvKey::SCOPE_LOCAL)); + if (!env_mgr.useDayCycle(env_mgr.getDayCycleName(), LLEnvKey::SCOPE_LOCAL)) { // *TODO: fix user prefs applyDefaults(); @@ -647,8 +647,7 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) void LLWLParamManager::applyDefaults() { - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - llassert(env_mgr.useDayCycle("Default", LLEnvKey::SCOPE_LOCAL) == true); + LLEnvManagerNew::instance().useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); } bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) -- cgit v1.2.3 From 48fe54012993c095e095ed73503922275574e595 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 22:34:56 +0300 Subject: STORM-1253 WIP Fixed loading user day cycle on start-up; improved error handling. --- indra/newview/llwlparammanager.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index db81c3ead7..eb49f2b018 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -776,11 +776,25 @@ void LLWLParamManager::initSingleton() loadPresets(LLStringUtil::null); // load the day - mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); + std::string preferred_day = LLEnvManagerNew::instance().getDayCycleName(); + if (!LLDayCycleManager::instance().getPreset(preferred_day, mDay)) + { + // Fall back to default. + llwarns << "No day cycle named " << preferred_day << ", falling back to defaults" << llendl; + mDay.loadDayCycleFromFile("Default.xml"); + + // *TODO: Fix user preferences accordingly. + } // *HACK - sets cloud scrolling to what we want... fix this better in the future std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); - getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); + if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams)) + { + llwarns << "No sky preset named " << sky << ", falling back to defaults" << llendl; + getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); + + // *TODO: Fix user preferences accordingly. + } // set it to noon resetAnimator(0.5, LLEnvManagerNew::instance().getUseDayCycle()); -- cgit v1.2.3 From 04f680a5c3fec056fb9bf3b5d531e85a60dfbd8a Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 22:57:24 +0300 Subject: STORM-1245 WIP Fixed sky initialization to apply user preferences correctly. --- indra/newview/llwlparammanager.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index eb49f2b018..83d9ef6fde 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -801,4 +801,6 @@ void LLWLParamManager::initSingleton() // but use linden time sets it to what the estate is mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); + + applyUserPrefs(false); } -- cgit v1.2.3 From dda7df4ac94d1e269aa0ce9eff6c6078f756cbd9 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 2 Jun 2011 18:35:23 +0300 Subject: STORM-1253 WIP Debugging stuff. --- indra/newview/llwlparammanager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 83d9ef6fde..5980410e64 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -678,6 +678,8 @@ bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) std::map::iterator mIt = mParamList.find(key); if(mIt == mParamList.end()) { + llassert(!key.name.empty()); + // *TODO: validate params mParamList[key] = param; return true; } @@ -691,6 +693,8 @@ BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) std::map::const_iterator finder = mParamList.find(key); if(finder == mParamList.end()) { + llassert(!key.name.empty()); + // *TODO: validate params mParamList[key].setAll(param); return TRUE; } @@ -716,6 +720,8 @@ bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) { + llassert(!key.name.empty()); + // *TODO: validate params mParamList[key] = param; return true; @@ -723,6 +729,9 @@ bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) { + llassert(!key.name.empty()); + // *TODO: validate params + // quick, non robust (we won't be working with files, but assets) check // this might not actually be true anymore.... if(!param.isMap()) -- cgit v1.2.3 From 4e05ea6ebda88f3e2af4b585f629b11f3729096e Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 00:17:21 +0300 Subject: STORM-1255 WIP Implemented creating, editing and removing local sky presets. --- indra/newview/llwlparammanager.cpp | 230 ++++++++++++++----------------------- 1 file changed, 88 insertions(+), 142 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 5980410e64..01aed7c0f1 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -265,167 +265,74 @@ void LLWLParamManager::refreshRegionPresets() addAllSkies(LLEnvKey::SCOPE_REGION, LLEnvManagerNew::instance().getRegionSettings().getSkyMap()); } -void LLWLParamManager::loadPresets(const std::string& file_name) +void LLWLParamManager::loadAllPresets() { - std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); - LL_INFOS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL; - - bool found = true; - LLDirIterator app_settings_iter(path_name, "*.xml"); - while(found) - { - std::string name; - found = app_settings_iter.next(name); - if(found) - { - name=name.erase(name.length()-4); + // First, load system (coming out of the box) sky presets. + loadPresetsFromDir(getSysDir()); - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_unescape(name.c_str(), name.size()); - std::string unescaped_name(curl_str); - curl_free(curl_str); - curl_str = NULL; - - LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - loadPreset(LLWLParamKey(unescaped_name, LLWLParamKey::SCOPE_LOCAL),FALSE); - } - } + // Then load user presets. Note that user day presets will modify any system ones already loaded. + loadPresetsFromDir(getUserDir()); +} - // And repeat for user presets, note the user presets will modify any system presets already loaded +void LLWLParamManager::loadPresetsFromDir(const std::string& dir) +{ + LL_INFOS2("AppInit", "Shaders") << "Loading sky presets from " << dir << LL_ENDL; - std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); - LL_INFOS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL; - - found = true; - LLDirIterator user_settings_iter(path_name2, "*.xml"); - while(found) + LLDirIterator dir_iter(dir, "*.xml"); + while (1) { - std::string name; - found = user_settings_iter.next(name); - if(found) + std::string file; + if (!dir_iter.next(file)) { - name=name.erase(name.length()-4); - - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_unescape(name.c_str(), name.size()); - std::string unescaped_name(curl_str); - curl_free(curl_str); - curl_str = NULL; + break; // no more files + } - LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - loadPreset(LLWLParamKey(unescaped_name,LLWLParamKey::SCOPE_LOCAL),FALSE); + std::string path = dir + file; + if (!loadPreset(path)) + { + llwarns << "Error loading sky preset from " << path << llendl; } } - } -// untested and unmaintained! sanity-check me before using -/* -void LLWLParamManager::savePresets(const std::string & fileName) +bool LLWLParamManager::loadPreset(const std::string& path) { - //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder - //and not over the RO system wide version. - - LLSD paramsData(LLSD::emptyMap()); - - std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", fileName)); + llifstream xml_file; + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - for(std::map::iterator mIt = mParamList.begin(); - mIt != mParamList.end(); - ++mIt) + xml_file.open(path.c_str()); + if (!xml_file) { - paramsData[mIt->first.name] = mIt->second.getAll(); + return false; } - llofstream presetsXML(pathName); - - LLPointer formatter = new LLSDXMLFormatter(); - - formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); + LL_DEBUGS2("AppInit", "Shaders") << "Loading sky " << name << LL_ENDL; - presetsXML.close(); -} -*/ + LLSD params_data; + LLPointer parser = new LLSDXMLParser(); + parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + xml_file.close(); -void LLWLParamManager::loadPreset(const LLWLParamKey key, bool propagate) -{ - if(mParamList.find(key) == mParamList.end()) // key does not already exist in mapping + LLWLParamKey key(name, LLEnvKey::SCOPE_LOCAL); + if (hasParamSet(key)) { - if(key.scope == LLWLParamKey::SCOPE_LOCAL) // local scope, so try to load from file - { - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_escape(key.name.c_str(), key.name.size()); - std::string escaped_filename(curl_str); - curl_free(curl_str); - curl_str = NULL; - - escaped_filename += ".xml"; - - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); - llinfos << "Loading WindLight sky setting from " << pathName << llendl; - - llifstream presetsXML; - presetsXML.open(pathName.c_str()); - - // That failed, try loading from the users area instead. - if(!presetsXML) - { - pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename); - llinfos << "Loading User WindLight sky setting from " << pathName << llendl; - presetsXML.open(pathName.c_str()); - } - - if (presetsXML) - { - loadPresetFromXML(key, presetsXML); - presetsXML.close(); - } - else - { - llwarns << "Could not load local WindLight sky setting " << key.toString() << llendl; - return; - } - } - else - { - llwarns << "Attempted to load non-local WindLight sky settings " << key.toString() << "; not found in parameter mapping." << llendl; - return; - } + setParamSet(key, params_data); } - - if(propagate) + else { - getParamSet(key, mCurParams); - propagateParameters(); + addParamSet(key, params_data); } -} - -void LLWLParamManager::loadPresetFromXML(LLWLParamKey key, std::istream & presetsXML) -{ - LLSD paramsData(LLSD::emptyMap()); - LLPointer parser = new LLSDXMLParser(); - - parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); - - std::map::iterator mIt = mParamList.find(key); - if(mIt == mParamList.end()) addParamSet(key, paramsData); - else setParamSet(key, paramsData); + return true; } void LLWLParamManager::savePreset(LLWLParamKey key) { - // bugfix for SL-46920: preventing filenames that break stuff. - char * curl_str = curl_escape(key.name.c_str(), key.name.size()); - std::string escaped_filename(curl_str); - curl_free(curl_str); - curl_str = NULL; - - escaped_filename += ".xml"; + llassert(key.scope == LLEnvKey::SCOPE_LOCAL && !key.name.empty()); // make an empty llsd LLSD paramsData(LLSD::emptyMap()); - std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename)); + std::string pathName(getUserDir() + escapeString(key.name) + ".xml"); // fill it with LLSD windlight params paramsData = mParamList[key].getAll(); @@ -718,6 +625,12 @@ bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) return false; } +bool LLWLParamManager::hasParamSet(const LLWLParamKey& key) +{ + LLWLParamSet dummy; + return getParamSet(key, dummy); +} + bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) { llassert(!key.name.empty()); @@ -746,6 +659,15 @@ bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) { + // *TODO: notify interested parties that a sky preset has been removed. + + if (key.scope == LLEnvKey::SCOPE_REGION) + { + llwarns << "Removing region skies not supported" << llendl; + llassert(key.scope == LLEnvKey::SCOPE_LOCAL); + return; + } + // remove from param list std::map::iterator mIt = mParamList.find(key); if(mIt != mParamList.end()) @@ -759,30 +681,30 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ mDay.removeReferencesTo(key); - if(delete_from_disk && key.scope == LLWLParamKey::SCOPE_LOCAL) + if (delete_from_disk) { - std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); - - // use full curl escaped name - char * curl_str = curl_escape(key.name.c_str(), key.name.size()); - std::string escaped_name(curl_str); - curl_free(curl_str); - curl_str = NULL; - + std::string path_name(getUserDir()); + std::string escaped_name = escapeString(key.name); + if(gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml") < 1) { - LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << " from disk; not found." << LL_ENDL; + LL_WARNS("WindLight") << "Error removing sky preset " << key.name << " from disk" << LL_ENDL; } } } +bool LLWLParamManager::isSystemPreset(const std::string& preset_name) +{ + // *TODO: file system access is excessive here. + return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); +} // virtual static void LLWLParamManager::initSingleton() { LL_DEBUGS("Windlight") << "Initializing sky" << LL_ENDL; - loadPresets(LLStringUtil::null); + loadAllPresets(); // load the day std::string preferred_day = LLEnvManagerNew::instance().getDayCycleName(); @@ -813,3 +735,27 @@ void LLWLParamManager::initSingleton() applyUserPrefs(false); } + +// static +std::string LLWLParamManager::getSysDir() +{ + return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""); +} + +// static +std::string LLWLParamManager::getUserDir() +{ + return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/skies", ""); +} + +// static +std::string LLWLParamManager::escapeString(const std::string& str) +{ + // Don't use LLURI::escape() because it doesn't encode '-' characters + // which may break handling of some system presets like "A-12AM". + char* curl_str = curl_escape(str.c_str(), str.size()); + std::string escaped_str(curl_str); + curl_free(curl_str); + + return escaped_str; +} -- cgit v1.2.3 From 7151a4e6b02f02155387fc595034a42aebd7ec9c Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 17:41:26 +0300 Subject: STORM-1255 WIP Consistency pass on sky presets removal. * Update all related floaters when a sky preset gets removed. * Don't allow removing skies referenced by (local) day cycles. * Other minor fixes. --- indra/newview/llwlparammanager.cpp | 46 ++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 01aed7c0f1..df52f3328f 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -588,6 +588,7 @@ bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) llassert(!key.name.empty()); // *TODO: validate params mParamList[key] = param; + mPresetListChangeSignal(); return true; } @@ -596,19 +597,9 @@ bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) { - // add a new one if not one there already - std::map::const_iterator finder = mParamList.find(key); - if(finder == mParamList.end()) - { - llassert(!key.name.empty()); - // *TODO: validate params - mParamList[key].setAll(param); - return TRUE; - } - else - { - return FALSE; - } + LLWLParamSet param_set; + param_set.setAll(param); + return addParamSet(key, param_set); } bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) @@ -652,14 +643,14 @@ bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) return false; } - mParamList[key].setAll(param); - - return true; + LLWLParamSet param_set; + param_set.setAll(param); + return setParamSet(key, param_set); } void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) { - // *TODO: notify interested parties that a sky preset has been removed. + // *NOTE: Removing a sky preset invalidates day cycles that refer to it. if (key.scope == LLEnvKey::SCOPE_REGION) { @@ -669,18 +660,17 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ } // remove from param list - std::map::iterator mIt = mParamList.find(key); - if(mIt != mParamList.end()) - { - mParamList.erase(mIt); - } - else + std::map::iterator it = mParamList.find(key); + if (it == mParamList.end()) { - LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << "; not found." << LL_ENDL; + LL_WARNS("WindLight") << "No sky preset named " << key.name << LL_ENDL; + return; } + mParamList.erase(it); mDay.removeReferencesTo(key); + // remove from file system if requested if (delete_from_disk) { std::string path_name(getUserDir()); @@ -691,6 +681,9 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ LL_WARNS("WindLight") << "Error removing sky preset " << key.name << " from disk" << LL_ENDL; } } + + // signal interested parties + mPresetListChangeSignal(); } bool LLWLParamManager::isSystemPreset(const std::string& preset_name) @@ -699,6 +692,11 @@ bool LLWLParamManager::isSystemPreset(const std::string& preset_name) return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); } +boost::signals2::connection LLWLParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) +{ + return mPresetListChangeSignal.connect(cb); +} + // virtual static void LLWLParamManager::initSingleton() { -- cgit v1.2.3 From 0d1cc56eb128755ce9e63d8cdf852b0e3b6f4fb1 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 18:21:32 +0300 Subject: STORM-1279 FIXED Changing sky preset with a keyboard shortcut now updates the Environment Settings floater. Changes: * Subscribed the floater to the "settings changed" signal of the environment manager. * Rewrote the floater to not modify settings only when the Save button is pressed. * Refactoring to eliminate code duplication. --- indra/newview/llwlparammanager.cpp | 58 +------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index df52f3328f..944773de17 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -501,62 +501,6 @@ void LLWLParamManager::update(LLViewerCamera * cam) } } -void LLWLParamManager::applyUserPrefs(bool interpolate) -{ - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - - if (env_mgr.getUseRegionSettings()) // apply region-wide settings - { - if (env_mgr.getRegionSettings().getSkyMap().size() == 0) - { - applyDefaults(); - } - else - { - // *TODO: Support fixed sky from region. - LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - - // Apply region day cycle. - const LLEnvironmentSettings& region_settings = env_mgr.getRegionSettings(); - applyDayCycleParams( - region_settings.getWLDayCycle(), - LLEnvKey::SCOPE_REGION, - region_settings.getDayTime()); - } - } - else // apply user-specified settings - { - if (env_mgr.getUseDayCycle()) - { - if (!env_mgr.useDayCycle(env_mgr.getDayCycleName(), LLEnvKey::SCOPE_LOCAL)) - { - // *TODO: fix user prefs - applyDefaults(); - } - } - else - { - LLWLParamSet param_set; - std::string sky = env_mgr.getSkyPresetName(); - - if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), param_set)) - { - llwarns << "No sky named " << sky << llendl; - } - else - { - LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; - applySkyParams(param_set.getAll()); - } - } - } -} - -void LLWLParamManager::applyDefaults() -{ - LLEnvManagerNew::instance().useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); -} - bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) { mDay.loadDayCycle(params, scope); @@ -731,7 +675,7 @@ void LLWLParamManager::initSingleton() // but use linden time sets it to what the estate is mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); - applyUserPrefs(false); + LLEnvManagerNew::instance().usePrefs(); } // static -- cgit v1.2.3 From 4fd946fa3e5217b8f64e0fcd91d268c7eaf1bbf5 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 23:44:13 +0300 Subject: STORM-1305 WIP User sky presets now go first in all lists. --- indra/newview/llwlparammanager.cpp | 47 +++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 944773de17..f475b3da01 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -630,12 +630,57 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ mPresetListChangeSignal(); } -bool LLWLParamManager::isSystemPreset(const std::string& preset_name) +bool LLWLParamManager::isSystemPreset(const std::string& preset_name) const { // *TODO: file system access is excessive here. return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); } +void LLWLParamManager::getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const +{ + region.clear(); + user.clear(); + sys.clear(); + + for (std::map::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) + { + const LLWLParamKey& key = it->first; + const std::string& name = key.name; + + if (key.scope == LLEnvKey::SCOPE_REGION) + { + region.push_back(name); + } + else + { + if (isSystemPreset(name)) + { + sys.push_back(name); + } + else + { + user.push_back(name); + } + } + } +} + +void LLWLParamManager::getUserPresetNames(preset_name_list_t& user) const +{ + preset_name_list_t region, sys; // unused + getPresetNames(region, user, sys); +} + +void LLWLParamManager::getPresetKeys(preset_key_list_t& keys) const +{ + keys.clear(); + + for (std::map::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) + { + keys.push_back(it->first); + } +} + boost::signals2::connection LLWLParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) { return mPresetListChangeSignal.connect(cb); -- cgit v1.2.3 From 31c1cff64fe6e963722e580c8779d69cef4b14ba Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 6 Jul 2011 00:42:28 +0300 Subject: STORM-1262 FIXED Removed the original Windlight Region Settings implementation. --- indra/newview/llwlparammanager.cpp | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'indra/newview/llwlparammanager.cpp') diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index f475b3da01..55608a059f 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -55,9 +55,6 @@ #include "llwlparamset.h" #include "llpostprocess.h" -#include "llfloaterwindlight.h" -#include "llfloaterdaycycle.h" -#include "llfloaterenvsettings.h" #include "llviewershadermgr.h" #include "llglslshader.h" @@ -457,23 +454,6 @@ void LLWLParamManager::update(LLViewerCamera * cam) // update the shaders and the menu propagateParameters(); - // sync menus if they exist - LLFloaterWindLight* wlfloater = LLFloaterReg::findTypedInstance("env_windlight"); - if (wlfloater) - { - wlfloater->syncMenu(); - } - LLFloaterDayCycle* dlfloater = LLFloaterReg::findTypedInstance("env_day_cycle"); - if (dlfloater) - { - dlfloater->syncMenu(); - } - LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("old_env_settings"); - if (envfloater) - { - envfloater->syncMenu(); - } - F32 camYaw = cam->getYaw(); stop_glerror(); -- cgit v1.2.3