summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2017-11-03 11:28:08 -0700
committerRider Linden <rider@lindenlab.com>2017-11-03 11:28:08 -0700
commit61e6632a713041e8e4ccebf72874767238bf8a48 (patch)
treed1134597b1ac03812fccf0ef21171f9577bc522d /indra/newview
parent2161788711f6d89564afc933707b6a0b8c1b0562 (diff)
Initial day cycle impl.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lldaycyclemanager.cpp3
-rw-r--r--indra/newview/llenvironment.cpp469
-rw-r--r--indra/newview/llenvironment.h146
-rw-r--r--indra/newview/llenvmanager.h1
-rw-r--r--indra/newview/llfloatereditdaycycle.cpp1
-rw-r--r--indra/newview/llfloatereditsky.cpp167
-rw-r--r--indra/newview/llfloatereditsky.h2
-rw-r--r--indra/newview/llfloatereditwater.cpp164
-rw-r--r--indra/newview/llfloatereditwater.h1
-rw-r--r--indra/newview/llfloaterenvironmentsettings.cpp112
-rw-r--r--indra/newview/llfloaterenvironmentsettings.h1
-rw-r--r--indra/newview/llsettingsbase.cpp24
-rw-r--r--indra/newview/llsettingsbase.h34
-rw-r--r--indra/newview/llsettingsdaycycle.cpp179
-rw-r--r--indra/newview/llsettingsdaycycle.h28
-rw-r--r--indra/newview/llsettingssky.cpp31
-rw-r--r--indra/newview/llsettingssky.h4
-rw-r--r--indra/newview/llsettingswater.cpp9
-rw-r--r--indra/newview/llsettingswater.h3
-rw-r--r--indra/newview/llwaterparammanager.cpp4
-rw-r--r--indra/newview/llwlparammanager.cpp5
21 files changed, 875 insertions, 513 deletions
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index 803e2b2fb2..23d442f3b6 100644
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -30,6 +30,9 @@
#include "lldiriterator.h"
+#include "llenvironment.h"
+#include "llsettingsdaycycle.h"
+
void LLDayCycleManager::getPresetNames(preset_name_list_t& names) const
{
names.clear();
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index fbb713c6d8..9c654bbeb5 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -29,7 +29,6 @@
#include "llenvironment.h"
#include "llagent.h"
-#include "lldaycyclemanager.h"
#include "llviewercontrol.h" // for gSavedSettings
#include "llviewerregion.h"
#include "llwlhandlers.h"
@@ -40,6 +39,10 @@
#include "pipeline.h"
#include "llsky.h"
+#include "llviewershadermgr.h"
+
+#include "llsdserialize.h"
+#include "lldiriterator.h"
//=========================================================================
namespace
{
@@ -53,21 +56,37 @@ const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS)
//-------------------------------------------------------------------------
LLEnvironment::LLEnvironment():
- mCurrentSky(),
- mCurrentWater(),
+ mSelectedSky(),
+ mSelectedWater(),
+ mSelectedDayCycle(),
mSkysById(),
mSkysByName(),
mWaterByName(),
mWaterById(),
+ mDayCycleByName(),
+ mDayCycleById(),
mUserPrefs()
{
+}
+
+void LLEnvironment::initSingleton()
+{
LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky();
addSky(p_default_sky);
- mCurrentSky = p_default_sky;
+ mSelectedSky = p_default_sky;
LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater();
addWater(p_default_water);
- mCurrentWater = p_default_water;
+ mSelectedWater = p_default_water;
+
+ LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle();
+ addDayCycle(p_default_day);
+ mSelectedDayCycle.reset();
+
+ applyAllSelected();
+
+ // LEGACY!
+ legacyLoadAllPresets();
}
LLEnvironment::~LLEnvironment()
@@ -79,10 +98,25 @@ void LLEnvironment::loadPreferences()
mUserPrefs.load();
}
+LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb)
+{
+ return mSkyListChange.connect(cb);
+}
+
+LLEnvironment::connection_t LLEnvironment::setWaterListChange(const LLEnvironment::change_signal_t::slot_type& cb)
+{
+ return mWaterListChange.connect(cb);
+}
+
+LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnvironment::change_signal_t::slot_type& cb)
+{
+ return mDayCycleListChange.connect(cb);
+}
+
//-------------------------------------------------------------------------
F32 LLEnvironment::getCamHeight() const
{
- return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius());
+ return (mSelectedSky->getDomeOffset() * mSelectedSky->getDomeRadius());
}
F32 LLEnvironment::getWaterHeight() const
@@ -92,7 +126,7 @@ F32 LLEnvironment::getWaterHeight() const
bool LLEnvironment::getIsDayTime() const
{
- return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS;
+ return mSelectedSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS;
}
//-------------------------------------------------------------------------
@@ -102,7 +136,13 @@ void LLEnvironment::update(const LLViewerCamera * cam)
// update clouds, sun, and general
updateCloudScroll();
- mCurrentSky->update();
+ if (mSelectedDayCycle)
+ mSelectedDayCycle->update();
+
+ if (mSelectedSky)
+ mSelectedSky->update();
+ if (mSelectedWater)
+ mSelectedWater->update();
// // update only if running
// if (mAnimator.getIsRunning())
@@ -139,6 +179,11 @@ void LLEnvironment::update(const LLViewerCamera * cam)
}
}
+void advanceDay(F32 delta)
+{
+
+}
+
void LLEnvironment::updateCloudScroll()
{
// This is a function of the environment rather than the sky, since it should
@@ -147,7 +192,7 @@ void LLEnvironment::updateCloudScroll()
F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64();
- LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;
+ LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mSelectedSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;
mCloudScrollDelta += cloud_delta;
@@ -225,8 +270,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)
if (gPipeline.canUseWindLightShaders())
{
- updateGLVariablesForSettings(shader, mCurrentSky);
- updateGLVariablesForSettings(shader, mCurrentWater);
+ updateGLVariablesForSettings(shader, mSelectedSky);
+ updateGLVariablesForSettings(shader, mSelectedWater);
}
if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT)
@@ -248,6 +293,176 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)
}
//--------------------------------------------------------------------------
+void LLEnvironment::selectSky(const std::string &name)
+{
+ LLSettingsSky::ptr_t next_sky = findSkyByName(name);
+ if (!next_sky)
+ {
+ LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL;
+ return;
+ }
+
+ selectSky(next_sky);
+}
+
+void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky)
+{
+ if (!sky)
+ {
+ mSelectedSky = mCurrentSky;
+ return;
+ }
+ mSelectedSky = sky;
+ mSelectedSky->setDirtyFlag(true);
+}
+
+void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky)
+{
+ if (sky)
+ {
+ mCurrentSky = sky;
+ }
+ else
+ {
+ mCurrentSky = mSelectedSky;
+ }
+}
+
+void LLEnvironment::selectWater(const std::string &name)
+{
+ LLSettingsWater::ptr_t next_water = findWaterByName(name);
+
+ if (!next_water)
+ {
+ LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL;
+ return;
+ }
+
+ selectWater(next_water);
+}
+
+void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water)
+{
+ if (!water)
+ {
+ mSelectedWater = mCurrentWater;
+ return;
+ }
+ mSelectedWater = water;
+ mSelectedWater->setDirtyFlag(true);
+}
+
+void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water)
+{
+ if (water)
+ {
+ mCurrentWater = water;
+ }
+ else
+ {
+ mCurrentWater = mSelectedWater;
+ }
+}
+
+void LLEnvironment::selectDayCycle(const std::string &name)
+{
+ LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name);
+
+ if (!next_daycycle)
+ {
+ LL_WARNS("ENVIRONMENT") << "Unable to select daycycle with unknown name '" << name << "'" << LL_ENDL;
+ return;
+ }
+
+ mSelectedDayCycle = next_daycycle;
+ mSelectedDayCycle->setDirtyFlag(true);
+}
+
+void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle)
+{
+ if (!daycycle)
+ {
+ mSelectedDayCycle = mCurrentDayCycle;
+ return;
+ }
+
+ mSelectedDayCycle = daycycle;
+ mSelectedDayCycle->setDirtyFlag(true);
+}
+
+void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle)
+{
+ if (daycycle)
+ {
+ mCurrentDayCycle = daycycle;
+ }
+ else
+ {
+ mCurrentDayCycle = mSelectedDayCycle;
+ }
+}
+
+void LLEnvironment::clearAllSelected()
+{
+ if (mSelectedSky != mCurrentSky)
+ selectSky();
+ if (mSelectedWater != mCurrentWater)
+ selectWater();
+ if (mSelectedDayCycle != mCurrentDayCycle)
+ selectDayCycle();
+}
+
+void LLEnvironment::applyAllSelected()
+{
+ if (mSelectedSky != mCurrentSky)
+ applySky();
+ if (mSelectedWater != mCurrentWater)
+ applyWater();
+ if (mSelectedDayCycle != mCurrentDayCycle)
+ applyDayCycle();
+}
+
+LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const
+{
+ list_name_id_t list;
+
+ list.reserve(mSkysByName.size());
+
+ for (NamedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it)
+ {
+ list.push_back(std::vector<name_id_t>::value_type((*it).second->getName(), (*it).second->getId()));
+ }
+
+ return list;
+}
+
+LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const
+{
+ list_name_id_t list;
+
+ list.reserve(mWaterByName.size());
+
+ for (NamedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it)
+ {
+ list.push_back(std::vector<name_id_t>::value_type((*it).second->getName(), (*it).second->getId()));
+ }
+
+ return list;
+}
+
+LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const
+{
+ list_name_id_t list;
+
+ list.reserve(mDayCycleByName.size());
+
+ for (NamedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it)
+ {
+ list.push_back(std::vector<name_id_t>::value_type((*it).second->getName(), (*it).second->getId()));
+ }
+
+ return list;
+}
void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky)
{
@@ -260,6 +475,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky)
if (!result.second)
(*(result.first)).second = sky;
+ mSkyListChange();
}
// void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky)
@@ -278,6 +494,7 @@ void LLEnvironment::removeSky(const std::string &name)
NamedSettingMap_t::iterator it = mSkysByName.find(name);
if (it != mSkysByName.end())
mSkysByName.erase(it);
+ mSkyListChange();
}
// void LLEnvironment::removeSky(const LLUUID &id)
@@ -289,19 +506,7 @@ void LLEnvironment::clearAllSkys()
{
mSkysByName.clear();
mSkysById.clear();
-}
-
-void LLEnvironment::selectSky(const std::string &name)
-{
- LLSettingsSky::ptr_t next_sky = findSkyByName(name);
- if (!next_sky)
- {
- LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL;
- return;
- }
-
- mCurrentSky = next_sky;
- mCurrentSky->setDirtyFlag(true);
+ mSkyListChange();
}
void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water)
@@ -315,29 +520,17 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water)
if (!result.second)
(*(result.first)).second = water;
+ mWaterListChange();
}
//void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
-void LLEnvironment::selectWater(const std::string &name)
-{
- LLSettingsWater::ptr_t next_water = findWaterByName(name);
-
- if (!next_water)
- {
- LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL;
- return;
- }
-
- mCurrentWater = next_water;
- mCurrentWater->setDirtyFlag(true);
-}
-
void LLEnvironment::removeWater(const std::string &name)
{
NamedSettingMap_t::iterator it = mWaterByName.find(name);
if (it != mWaterByName.end())
mWaterByName.erase(it);
+ mWaterListChange();
}
//void LLEnvironment::removeWater(const LLUUID &id);
@@ -345,6 +538,39 @@ void LLEnvironment::clearAllWater()
{
mWaterByName.clear();
mWaterById.clear();
+ mWaterListChange();
+}
+
+void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle)
+{
+ std::string name = daycycle->getValue(LLSettingsDayCycle::SETTING_NAME).asString();
+
+ LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL;
+
+ std::pair<NamedSettingMap_t::iterator, bool> result;
+ result = mDayCycleByName.insert(NamedSettingMap_t::value_type(name, daycycle));
+
+ if (!result.second)
+ (*(result.first)).second = daycycle;
+ mDayCycleListChange();
+}
+
+//void LLEnvironment::addDayCycle(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
+
+void LLEnvironment::removeDayCycle(const std::string &name)
+{
+ NamedSettingMap_t::iterator it = mDayCycleByName.find(name);
+ if (it != mDayCycleByName.end())
+ mDayCycleByName.erase(it);
+ mDayCycleListChange();
+}
+
+//void LLEnvironment::removeDayCycle(const LLUUID &id);
+void LLEnvironment::clearAllDayCycles()
+{
+ mDayCycleByName.clear();
+ mWaterById.clear();
+ mDayCycleListChange();
}
LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const
@@ -373,6 +599,19 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const
return boost::static_pointer_cast<LLSettingsWater>((*it).second);
}
+LLSettingsDayCycle::ptr_t LLEnvironment::findDayCycleByName(std::string name) const
+{
+ NamedSettingMap_t::const_iterator it = mDayCycleByName.find(name);
+
+ if (it == mDayCycleByName.end())
+ {
+ LL_WARNS("ENVIRONMENT") << "Unable to find daycycle with unknown name '" << name << "'" << LL_ENDL;
+ return LLSettingsDayCycle::ptr_t();
+ }
+
+ return boost::static_pointer_cast<LLSettingsDayCycle>((*it).second);
+}
+
//=========================================================================
LLEnvironment::UserPrefs::UserPrefs():
mUseRegionSettings(true),
@@ -409,3 +648,157 @@ void LLEnvironment::UserPrefs::store()
gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle());
}
}
+
+
+//=========================================================================
+// Transitional Code.
+// static
+std::string LLEnvironment::getSysDir(const std::string &subdir)
+{
+ return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight\\"+subdir, "");
+}
+
+// static
+std::string LLEnvironment::getUserDir(const std::string &subdir)
+{
+ return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "windlight\\"+subdir, "");
+}
+
+LLSD LLEnvironment::legacyLoadPreset(const std::string& path)
+{
+ llifstream xml_file;
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true));
+
+ xml_file.open(path.c_str());
+ if (!xml_file)
+ {
+ return LLSD();
+ }
+
+ LLSD params_data;
+ LLPointer<LLSDParser> parser = new LLSDXMLParser();
+ parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED);
+ xml_file.close();
+
+ return params_data;
+}
+
+void LLEnvironment::legacyLoadAllPresets()
+{
+ std::string dir;
+ std::string file;
+
+ // System skies
+ {
+ dir = getSysDir("skies");
+ LLDirIterator dir_iter(dir, "*.xml");
+ while (dir_iter.next(file))
+ {
+ std::string path = gDirUtilp->add(dir, file);
+
+ LLSD data = legacyLoadPreset(path);
+ if (data)
+ {
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
+
+ LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data);
+ LLEnvironment::instance().addSky(sky);
+ }
+ }
+ }
+
+ // User skies
+ {
+ dir = getUserDir("skies");
+ LLDirIterator dir_iter(dir, "*.xml");
+ while (dir_iter.next(file))
+ {
+ std::string path = gDirUtilp->add(dir, file);
+
+ LLSD data = legacyLoadPreset(path);
+ if (data)
+ {
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
+
+ LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data);
+ LLEnvironment::instance().addSky(sky);
+ }
+ }
+ }
+
+ // System water
+ {
+ dir = getSysDir("water");
+ LLDirIterator dir_iter(dir, "*.xml");
+ while (dir_iter.next(file))
+ {
+ std::string path = gDirUtilp->add(dir, file);
+
+ LLSD data = legacyLoadPreset(path);
+ if (data)
+ {
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
+
+ LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data);
+ LLEnvironment::instance().addWater(water);
+ }
+ }
+ }
+
+ // User water
+ {
+ dir = getUserDir("water");
+ LLDirIterator dir_iter(dir, "*.xml");
+ while (dir_iter.next(file))
+ {
+ std::string path = gDirUtilp->add(dir, file);
+
+ LLSD data = legacyLoadPreset(path);
+ if (data)
+ {
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
+
+ LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data);
+ LLEnvironment::instance().addWater(water);
+ }
+ }
+ }
+
+ // System water
+ {
+ dir = getSysDir("days");
+ LLDirIterator dir_iter(dir, "*.xml");
+ while (dir_iter.next(file))
+ {
+ std::string path = gDirUtilp->add(dir, file);
+
+ LLSD data = legacyLoadPreset(path);
+ if (data)
+ {
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
+
+ LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data);
+ LLEnvironment::instance().addDayCycle(day);
+ }
+ }
+ }
+
+ // User water
+ {
+ dir = getUserDir("days");
+ LLDirIterator dir_iter(dir, "*.xml");
+ while (dir_iter.next(file))
+ {
+ std::string path = gDirUtilp->add(dir, file);
+
+ LLSD data = legacyLoadPreset(path);
+ if (data)
+ {
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true));
+
+ LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data);
+ LLEnvironment::instance().addDayCycle(day);
+ }
+ }
+ }
+}
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 493fff1769..a3fc9eef66 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -32,6 +32,7 @@
#include "llsettingssky.h"
#include "llsettingswater.h"
+#include "llsettingsdaycycle.h"
class LLViewerCamera;
class LLGLSLShader;
@@ -52,22 +53,22 @@ public:
public:
UserPrefs();
- bool getUseRegionSettings() const { return mUseRegionSettings; }
- bool getUseDayCycle() const { return mUseDayCycle; }
- bool getUseFixedSky() const { return !getUseDayCycle(); }
+ bool getUseRegionSettings() const { return mUseRegionSettings; }
+ bool getUseDayCycle() const { return mUseDayCycle; }
+ bool getUseFixedSky() const { return !getUseDayCycle(); }
- std::string getWaterPresetName() const { return mWaterPresetName; }
- std::string getSkyPresetName() const { return mSkyPresetName; }
- std::string getDayCycleName() const { return mDayCycleName; }
+ std::string getWaterPresetName() const { return mWaterPresetName; }
+ std::string getSkyPresetName() const { return mSkyPresetName; }
+ std::string getDayCycleName() const { return mDayCycleName; }
- void setUseRegionSettings(bool val);
- void setUseWaterPreset(const std::string& name);
- void setUseSkyPreset(const std::string& name);
- void setUseDayCycle(const std::string& name);
+ void setUseRegionSettings(bool val);
+ void setUseWaterPreset(const std::string& name);
+ void setUseSkyPreset(const std::string& name);
+ void setUseDayCycle(const std::string& name);
private:
- void load();
- void store();
+ void load();
+ void store();
bool mUseRegionSettings;
bool mUseDayCycle;
@@ -77,66 +78,104 @@ public:
std::string mDayCycleName;
};
+ typedef std::pair<std::string, LLUUID> name_id_t;
+ typedef std::vector<name_id_t> list_name_id_t;
+ typedef boost::signals2::signal<void()> change_signal_t;
+ typedef boost::signals2::connection connection_t;
+
virtual ~LLEnvironment();
- void loadPreferences();
- const UserPrefs & getPreferences() const { return mUserPrefs; }
+ void loadPreferences();
+ const UserPrefs & getPreferences() const { return mUserPrefs; }
+
+ LLSettingsSky::ptr_t getCurrentSky() const { return mSelectedSky; }
+ LLSettingsWater::ptr_t getCurrentWater() const { return mSelectedWater; }
- LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; }
- LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; }
+ void update(const LLViewerCamera * cam);
+ void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
+ void updateShaderUniforms(LLGLSLShader *shader);
+ void addSky(const LLSettingsSky::ptr_t &sky);
+ void addWater(const LLSettingsWater::ptr_t &sky);
+ void addDayCycle(const LLSettingsDayCycle::ptr_t &day);
- void update(const LLViewerCamera * cam);
+ void selectSky(const std::string &name);
+ void selectSky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t());
+ void applySky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t());
+ void selectWater(const std::string &name);
+ void selectWater(const LLSettingsWater::ptr_t &water = LLSettingsWater::ptr_t());
+ void applyWater(const LLSettingsWater::ptr_t water = LLSettingsWater::ptr_t());
+ void selectDayCycle(const std::string &name);
+ void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t());
+ void applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t());
+ void clearAllSelected();
+ void applyAllSelected();
- void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
- void updateShaderUniforms(LLGLSLShader *shader);
+ list_name_id_t getSkyList() const;
+ list_name_id_t getWaterList() const;
+ list_name_id_t getDayCycleList() const;
- void addSky(const LLSettingsSky::ptr_t &sky);
- void selectSky(const std::string &name);
- LLSettingsSky::ptr_t findSkyByName(std::string name) const;
- LLSettingsWater::ptr_t findWaterByName(std::string name) const;
+ LLSettingsSky::ptr_t findSkyByName(std::string name) const;
+ LLSettingsWater::ptr_t findWaterByName(std::string name) const;
+ LLSettingsDayCycle::ptr_t findDayCycleByName(std::string name) const;
- void addWater(const LLSettingsWater::ptr_t &sky);
- void selectWater(const std::string &name);
+ inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; }
- inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; }
+ F32 getCamHeight() const;
+ F32 getWaterHeight() const;
+ bool getIsDayTime() const; // "Day Time" is defined as the sun above the horizon.
+ bool getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time"
- F32 getCamHeight() const;
- F32 getWaterHeight() const;
- bool getIsDayTime() const; // "Day Time" is defined as the sun above the horizon.
- bool getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time"
+ inline F32 getSceneLightStrength() const { return mSceneLightStrength; }
+ inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; }
- inline F32 getSceneLightStrength() const { return mSceneLightStrength; }
- inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; }
+ inline LLVector4 getLightDirection() const { return LLVector4(mSelectedSky->getLightDirection(), 0.0f); }
+ inline LLVector4 getClampedLightDirection() const { return LLVector4(mSelectedSky->getClampedLightDirection(), 0.0f); }
+ inline LLVector4 getRotatedLight() const { return mRotatedLight; }
- inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); }
- inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); }
- inline LLVector4 getRotatedLight() const { return mRotatedLight; }
+ //-------------------------------------------
+ connection_t setSkyListChange(const change_signal_t::slot_type& cb);
+ connection_t setWaterListChange(const change_signal_t::slot_type& cb);
+ connection_t setDayCycleListChange(const change_signal_t::slot_type& cb);
+protected:
+ virtual void initSingleton();
private:
- static const F32 SUN_DELTA_YAW;
- static const F32 NIGHTTIME_ELEVATION_COS;
+ static const F32 SUN_DELTA_YAW;
+ static const F32 NIGHTTIME_ELEVATION_COS;
typedef std::map<std::string, LLSettingsBase::ptr_t> NamedSettingMap_t;
typedef std::map<LLUUID, LLSettingsBase::ptr_t> AssetSettingMap_t;
- LLVector2 mCloudScrollDelta; // cumulative cloud delta
+ LLVector2 mCloudScrollDelta; // cumulative cloud delta
+
+ LLSettingsSky::ptr_t mSelectedSky;
+ LLSettingsWater::ptr_t mSelectedWater;
+ LLSettingsDayCycle::ptr_t mSelectedDayCycle;
+
+ LLSettingsSky::ptr_t mCurrentSky;
+ LLSettingsWater::ptr_t mCurrentWater;
+ LLSettingsDayCycle::ptr_t mCurrentDayCycle;
+
+ NamedSettingMap_t mSkysByName;
+ AssetSettingMap_t mSkysById;
- LLSettingsSky::ptr_t mCurrentSky;
- LLSettingsWater::ptr_t mCurrentWater;
+ NamedSettingMap_t mWaterByName;
+ AssetSettingMap_t mWaterById;
- NamedSettingMap_t mSkysByName;
- AssetSettingMap_t mSkysById;
+ NamedSettingMap_t mDayCycleByName;
+ AssetSettingMap_t mDayCycleById;
- NamedSettingMap_t mWaterByName;
- AssetSettingMap_t mWaterById;
+ F32 mSceneLightStrength;
+ LLVector4 mRotatedLight;
- F32 mSceneLightStrength;
- LLVector4 mRotatedLight;
+ UserPrefs mUserPrefs;
- UserPrefs mUserPrefs;
+ change_signal_t mSkyListChange;
+ change_signal_t mWaterListChange;
+ change_signal_t mDayCycleListChange;
//void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
void removeSky(const std::string &name);
@@ -148,7 +187,20 @@ private:
//void removeWater(const LLUUID &id);
void clearAllWater();
+ //void addDayCycle(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
+ void removeDayCycle(const std::string &name);
+ //void removeDayCycle(const LLUUID &id);
+ void clearAllDayCycles();
+
+
void updateCloudScroll();
+
+ //=========================================================================
+ void legacyLoadAllPresets();
+ LLSD legacyLoadPreset(const std::string& path);
+ static std::string getSysDir(const std::string &subdir);
+ static std::string getUserDir(const std::string &subdir);
+
};
diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h
index 54bbf85e86..31a093ad5d 100644
--- a/indra/newview/llenvmanager.h
+++ b/indra/newview/llenvmanager.h
@@ -328,6 +328,7 @@ private:
void onRegionChange();
+
/// Emitted when user environment preferences change.
prefs_change_signal_t mUsePrefsChangeSignal;
diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp
index 5c0991b0b3..97d87ee13e 100644
--- a/indra/newview/llfloatereditdaycycle.cpp
+++ b/indra/newview/llfloatereditdaycycle.cpp
@@ -691,6 +691,7 @@ void LLFloaterEditDayCycle::onDayCycleNameEdited()
void LLFloaterEditDayCycle::onDayCycleSelected()
{
+
LLSD day_data;
LLWLParamKey dc_key = getSelectedDayCycle();
bool can_edit = true;
diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp
index 5fd559c060..23744e5b07 100644
--- a/indra/newview/llfloatereditsky.cpp
+++ b/indra/newview/llfloatereditsky.cpp
@@ -87,6 +87,8 @@ BOOL LLFloaterEditSky::postBuild()
mSaveButton = getChild<LLButton>("save");
mSkyAdapter = boost::make_shared<LLSkySettingsAdapter>();
+ LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this));
+
initCallbacks();
// // Create the sun position scrubber on the slider.
@@ -124,7 +126,7 @@ void LLFloaterEditSky::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
-// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment
+ LLEnvironment::instance().clearAllSelected();
}
}
@@ -216,6 +218,10 @@ void LLFloaterEditSky::syncControls()
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
mEditSettings = psky;
+ std::string name = psky->getName();
+
+ mSkyPresetNameEditor->setText(name);
+ mSkyPresetCombo->setValue(name);
// blue horizon
mSkyAdapter->mBlueHorizon.setColor3( psky->getBlueHorizon() );
@@ -557,44 +563,16 @@ bool LLFloaterEditSky::isNewPreset() const
void LLFloaterEditSky::refreshSkyPresetsList()
{
-#if 0
mSkyPresetCombo->removeall();
- LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets;
- LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets);
-
-#if 0 // Disable editing region skies until the workflow is clear enough.
- // Add region presets.
- std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown");
- for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it)
- {
- std::string item_title = *it + " (" + region_name + ")";
- mSkyPresetCombo->add(item_title, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toLLSD());
- }
- if (region_presets.size() > 0)
- {
- mSkyPresetCombo->addSeparator();
- }
-#endif
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList();
- // Add user presets.
- for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
- {
- mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD());
- }
- if (user_presets.size() > 0)
- {
- mSkyPresetCombo->addSeparator();
- }
-
- // Add system presets.
- for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it)
- {
- mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD());
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second));
+ }
mSkyPresetCombo->setLabel(getString("combo_label"));
-#endif
}
void LLFloaterEditSky::enableEditing(bool enable)
@@ -629,63 +607,51 @@ void LLFloaterEditSky::saveRegionSky()
#endif
}
-// LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset()
-// {
-// LLWLParamKey key;
-//
-// if (mSkyPresetNameEditor->getVisible())
-// {
-// key.name = mSkyPresetNameEditor->getText();
-// key.scope = LLEnvKey::SCOPE_LOCAL;
-// }
-// else
-// {
-// LLSD combo_val = mSkyPresetCombo->getValue();
-//
-// if (!combo_val.isArray()) // manually typed text
-// {
-// key.name = combo_val.asString();
-// key.scope = LLEnvKey::SCOPE_LOCAL;
-// }
-// else
-// {
-// key.fromLLSD(combo_val);
-// }
-// }
-//
-// return key;
-// }
+std::string LLFloaterEditSky::getSelectedPresetName() const
+{
+ std::string name;
+ if (mSkyPresetNameEditor->getVisible())
+ {
+ name = mSkyPresetNameEditor->getText();
+ }
+ else
+ {
+ LLSD combo_val = mSkyPresetCombo->getValue();
+ name = combo_val[0].asString();
+ }
+
+ return name;
+}
void LLFloaterEditSky::onSkyPresetNameEdited()
{
-#if 0
- // Disable saving a sky preset having empty name.
- LLWLParamKey key = getSelectedSkyPreset();
- mSaveButton->setEnabled(!key.name.empty());
-#endif
+ std::string name = mSkyPresetNameEditor->getText();
+ LLSettingsWater::ptr_t psky = LLEnvironment::instance().getCurrentWater();
+
+ psky->setName(name);
}
void LLFloaterEditSky::onSkyPresetSelected()
{
-#if 0
- LLWLParamKey key = getSelectedSkyPreset();
- LLWLParamSet sky_params;
+ std::string name;
- if (!LLWLParamManager::instance().getParamSet(key, sky_params))
- {
- // Manually entered string?
- LL_WARNS("Windlight") << "No sky preset named " << key.toString() << LL_ENDL;
- return;
- }
+ name = getSelectedPresetName();
- LLEnvManagerNew::instance().useSkyParams(sky_params.getAll());
- //syncControls();
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(name);
- bool can_edit = (key.scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings());
- enableEditing(can_edit);
+ if (!psky)
+ {
+ LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL;
+ enableEditing(false);
+ return;
+ }
+
+ psky = psky->buildClone();
+ LLEnvironment::instance().selectSky(psky);
+
+ syncControls();
+ enableEditing(true);
- mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL);
-#endif
}
bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response)
@@ -733,43 +699,11 @@ void LLFloaterEditSky::onSaveConfirmed()
void LLFloaterEditSky::onBtnSave()
{
-#if 0
- LLWLParamKey selected_sky = getSelectedSkyPreset();
- LLWLParamManager& wl_mgr = LLWLParamManager::instance();
-
- if (selected_sky.scope == LLEnvKey::SCOPE_REGION)
- {
- saveRegionSky();
- closeFloater();
- return;
- }
-
- std::string name = selected_sky.name;
- if (name.empty())
- {
- // *TODO: show an alert
- LL_WARNS() << "Empty sky preset name" << LL_ENDL;
- return;
- }
-
- // Don't allow overwriting system presets.
- if (wl_mgr.isSystemPreset(name))
- {
- LLNotificationsUtil::add("WLNoEditDefault");
- return;
- }
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
+ LLEnvironment::instance().addSky(psky);
- // Save, ask for confirmation for overwriting an existing preset.
- if (wl_mgr.hasParamSet(selected_sky))
- {
- LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditSky::onSaveAnswer, this, _1, _2));
- }
- else
- {
- // new preset, hence no confirmation needed
- onSaveConfirmed();
- }
-#endif
+ LLEnvironment::instance().applySky();
+ closeFloater();
}
void LLFloaterEditSky::onBtnCancel()
@@ -779,6 +713,7 @@ void LLFloaterEditSky::onBtnCancel()
void LLFloaterEditSky::onSkyPresetListChange()
{
+ refreshSkyPresetsList();
#if 0
LLWLParamKey key = getSelectedSkyPreset(); // preset being edited
if (!LLWLParamManager::instance().hasParamSet(key))
diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h
index 51be50a481..36438becce 100644
--- a/indra/newview/llfloatereditsky.h
+++ b/indra/newview/llfloatereditsky.h
@@ -98,7 +98,7 @@ private:
void refreshSkyPresetsList();
void enableEditing(bool enable);
void saveRegionSky();
-// LLWLParamKey getSelectedSkyPreset();
+ std::string getSelectedPresetName() const;
void onSkyPresetNameEdited();
void onSkyPresetSelected();
diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp
index b025680da1..2868a0609a 100644
--- a/indra/newview/llfloatereditwater.cpp
+++ b/indra/newview/llfloatereditwater.cpp
@@ -73,6 +73,8 @@ BOOL LLFloaterEditWater::postBuild()
mWaterAdapter = boost::make_shared<LLWatterSettingsAdapter>();
+ LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this));
+
initCallbacks();
refreshWaterPresetsList();
syncControls();
@@ -109,7 +111,7 @@ void LLFloaterEditWater::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
-// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment
+ LLEnvironment::instance().clearAllSelected();
}
}
@@ -176,6 +178,10 @@ void LLFloaterEditWater::syncControls()
LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater();
mEditSettings = pwater;
+ std::string name = pwater->getName();
+ mWaterPresetNameEditor->setText(name);
+ mWaterPresetCombo->setValue(name);
+
//getChild<LLUICtrl>("WaterGlow")->setValue(col.mV[3]);
getChild<LLColorSwatchCtrl>("WaterFogColor")->set(LLColor4(pwater->getFogColor()));
@@ -322,44 +328,16 @@ bool LLFloaterEditWater::isNewPreset() const
void LLFloaterEditWater::refreshWaterPresetsList()
{
-#if 0
mWaterPresetCombo->removeall();
-#if 0 // *TODO: enable when we have a clear workflow to edit existing region environment
- // If the region already has water params, add them to the list.
- const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings();
- if (region_settings.getWaterParams().size() != 0)
- {
- const std::string& region_name = gAgent.getRegion()->getName();
- mWaterPresetCombo->add(region_name, LLSD().with(0, region_name).with(1, LLEnvKey::SCOPE_REGION));
- mWaterPresetCombo->addSeparator();
- }
-#endif
-
- std::list<std::string> user_presets, system_presets;
- LLWaterParamManager::instance().getPresetNames(user_presets, system_presets);
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList();
- // Add local user presets first.
- for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
- {
- const std::string& name = *it;
- mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [<name>, <scope>]
- }
-
- if (user_presets.size() > 0)
- {
- mWaterPresetCombo->addSeparator();
- }
-
- // Add local system presets.
- for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it)
- {
- const std::string& name = *it;
- mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [<name>, <scope>]
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second));
+ }
mWaterPresetCombo->setLabel(getString("combo_label"));
-#endif
}
void LLFloaterEditWater::enableEditing(bool enable)
@@ -406,36 +384,28 @@ LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const
}
#endif
-#if 0
-void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const
+std::string LLFloaterEditWater::getSelectedPresetName() const
{
-
+ std::string name;
if (mWaterPresetNameEditor->getVisible())
{
name = mWaterPresetNameEditor->getText();
- scope = LLEnvKey::SCOPE_LOCAL;
}
else
{
LLSD combo_val = mWaterPresetCombo->getValue();
-
- if (!combo_val.isArray()) // manually typed text
- {
- name = combo_val.asString();
- scope = LLEnvKey::SCOPE_LOCAL;
- }
- else
- {
- name = combo_val[0].asString();
- scope = (LLEnvKey::EScope) combo_val[1].asInteger();
- }
+ name = combo_val[0].asString();
}
+ return name;
}
-#endif
void LLFloaterEditWater::onWaterPresetNameEdited()
{
+ std::string name = mWaterPresetNameEditor->getText();
+ LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater();
+
+ pwater->setName(name);
#if 0
// Disable saving a water preset having empty name.
mSaveButton->setEnabled(!getCurrentPresetName().empty());
@@ -444,35 +414,24 @@ void LLFloaterEditWater::onWaterPresetNameEdited()
void LLFloaterEditWater::onWaterPresetSelected()
{
-#if 0
- LLWaterParamSet water_params;
std::string name;
- LLEnvKey::EScope scope;
- getSelectedPreset(name, scope);
+ name = getSelectedPresetName();
- // Display selected preset.
- if (scope == LLEnvKey::SCOPE_REGION)
- {
- water_params.setAll(LLEnvManagerNew::instance().getRegionSettings().getWaterParams());
- }
- else // local preset selected
- {
- if (!LLWaterParamManager::instance().getParamSet(name, water_params))
- {
- // Manually entered string?
- LL_WARNS("Windlight") << "No water preset named " << name << LL_ENDL;
- return;
- }
- }
+ LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(name);
- LLEnvManagerNew::instance().useWaterParams(water_params.getAll());
+ if (!pwater)
+ {
+ LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL;
+ enableEditing(false);
+ return;
+ }
- bool can_edit = (scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings());
- enableEditing(can_edit);
+ pwater = pwater->buildClone();
+ LLEnvironment::instance().selectWater(pwater);
- mMakeDefaultCheckBox->setEnabled(scope == LLEnvKey::SCOPE_LOCAL);
-#endif
+ syncControls();
+ enableEditing(true);
}
bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response)
@@ -521,44 +480,11 @@ void LLFloaterEditWater::onSaveConfirmed()
void LLFloaterEditWater::onBtnSave()
{
-#if 0
- LLEnvKey::EScope scope;
- std::string name;
- getSelectedPreset(name, scope);
-
- if (scope == LLEnvKey::SCOPE_REGION)
- {
- saveRegionWater();
- closeFloater();
- return;
- }
-
- if (name.empty())
- {
- // *TODO: show an alert
- LL_WARNS() << "Empty water preset name" << LL_ENDL;
- return;
- }
-
- // Don't allow overwriting system presets.
- LLWaterParamManager& water_mgr = LLWaterParamManager::instance();
- if (water_mgr.isSystemPreset(name))
- {
- LLNotificationsUtil::add("WLNoEditDefault");
- return;
- }
+ LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater();
+ LLEnvironment::instance().addWater(pwater);
- // Save, ask for confirmation for overwriting an existing preset.
- if (water_mgr.hasParamSet(name))
- {
- LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditWater::onSaveAnswer, this, _1, _2));
- }
- else
- {
- // new preset, hence no confirmation needed
- onSaveConfirmed();
- }
-#endif
+ LLEnvironment::instance().applyWater();
+ closeFloater();
}
void LLFloaterEditWater::onBtnCancel()
@@ -568,23 +494,7 @@ void LLFloaterEditWater::onBtnCancel()
void LLFloaterEditWater::onWaterPresetListChange()
{
-#if 0
- std::string name;
- LLEnvKey::EScope scope;
- getSelectedPreset(name, scope); // preset being edited
-
- if (scope == LLEnvKey::SCOPE_LOCAL && !LLWaterParamManager::instance().hasParamSet(name))
- {
- // Preset we've been editing doesn't exist anymore. Close the floater.
- closeFloater(false);
- }
- else
- {
- // A new preset has been added.
- // Refresh the presets list, though it may not make sense as the floater is about to be closed.
- refreshWaterPresetsList();
- }
-#endif
+ refreshWaterPresetsList();
}
void LLFloaterEditWater::onRegionSettingsChange()
diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h
index 7d9e493ac2..081b939039 100644
--- a/indra/newview/llfloatereditwater.h
+++ b/indra/newview/llfloatereditwater.h
@@ -87,6 +87,7 @@ private:
void enableEditing(bool enable);
void saveRegionWater();
+ std::string getSelectedPresetName() const;
// std::string getCurrentPresetName() const;
// LLEnvKey::EScope getCurrentScope() const;
// void getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const;
diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp
index 39907b19a3..e25c5cedbf 100644
--- a/indra/newview/llfloaterenvironmentsettings.cpp
+++ b/indra/newview/llfloaterenvironmentsettings.cpp
@@ -70,10 +70,10 @@ BOOL LLFloaterEnvironmentSettings::postBuild()
setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this));
+ LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this));
+ LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this));
+ LLEnvironment::instance().setDayCycleListChange(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this));
// LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this));
-// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this));
-// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this));
-// LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this));
return TRUE;
}
@@ -84,6 +84,14 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key)
refresh();
}
+//virtual
+void LLFloaterEnvironmentSettings::onClose(bool app_quitting)
+{
+ if (!app_quitting)
+ LLEnvironment::instance().clearAllSelected();
+}
+
+
void LLFloaterEnvironmentSettings::onSwitchRegionSettings()
{
getChild<LLView>("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0);
@@ -133,6 +141,7 @@ void LLFloaterEnvironmentSettings::onBtnOK()
use_region_settings);
// *TODO: This triggers applying user preferences again, which is suboptimal.
+ LLEnvironment::instance().applyAllSelected();
closeFloater();
}
@@ -173,9 +182,9 @@ void LLFloaterEnvironmentSettings::apply()
// Update environment with the user choice.
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
- std::string water_preset = mWaterPresetCombo->getValue().asString();
- std::string sky_preset = mSkyPresetCombo->getValue().asString();
- std::string day_cycle = mDayCyclePresetCombo->getValue().asString();
+ std::string water_preset = mWaterPresetCombo->getValue()[0].asString();
+ std::string sky_preset = mSkyPresetCombo->getValue()[0].asString();
+ std::string day_cycle = mDayCyclePresetCombo->getValue()[0].asString();
LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance();
if (use_region_settings)
@@ -186,18 +195,23 @@ void LLFloaterEnvironmentSettings::apply()
{
if (use_fixed_sky)
{
- /* LAPRAS */
- //env_mgr.useSkyPreset(sky_preset);
- LLEnvironment::instance().selectSky(sky_preset);
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset);
+ if (psky)
+ LLEnvironment::instance().selectSky(psky);
}
else
{
- env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL);
+ LLSettingsDayCycle::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle);
+ if (pday)
+ LLEnvironment::instance().selectDayCycle(pday);
+
+// LLEnvironment::instance().selectDayCycle(day_cycle);
+// env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL);
}
- /* LAPRAS */
- //env_mgr.useWaterPreset(water_preset);
- LLEnvironment::instance().selectWater(water_preset);
+ LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset);
+ if (pwater)
+ LLEnvironment::instance().selectWater(pwater);
}
}
@@ -209,76 +223,36 @@ void LLFloaterEnvironmentSettings::cancel()
void LLFloaterEnvironmentSettings::populateWaterPresetsList()
{
- mWaterPresetCombo->removeall();
+ mWaterPresetCombo->removeall();
- std::list<std::string> user_presets, system_presets;
- //LLWaterParamManager::instance().getPresetNames(user_presets, system_presets);
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList();
- // Add user presets first.
- for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
- {
- mWaterPresetCombo->add(*it);
- }
-
- if (user_presets.size() > 0)
- {
- mWaterPresetCombo->addSeparator();
- }
-
- // Add system presets.
- for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it)
- {
- mWaterPresetCombo->add(*it);
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second));
+ }
}
void LLFloaterEnvironmentSettings::populateSkyPresetsList()
{
mSkyPresetCombo->removeall();
- LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here
- LLWLParamManager::preset_name_list_t user_presets, sys_presets;
- LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets);
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList();
- // Add user presets.
- for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
- {
- mSkyPresetCombo->add(*it);
- }
-
- if (!user_presets.empty())
- {
- mSkyPresetCombo->addSeparator();
- }
-
- // Add system presets.
- for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it)
- {
- mSkyPresetCombo->add(*it);
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second));
+ }
}
void LLFloaterEnvironmentSettings::populateDayCyclePresetsList()
{
mDayCyclePresetCombo->removeall();
- LLDayCycleManager::preset_name_list_t user_days, sys_days;
- LLDayCycleManager::instance().getPresetNames(user_days, sys_days);
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getDayCycleList();
- // Add user days.
- for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it)
- {
- mDayCyclePresetCombo->add(*it);
- }
-
- if (user_days.size() > 0)
- {
- mDayCyclePresetCombo->addSeparator();
- }
-
- // Add system days.
- for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it)
- {
- mDayCyclePresetCombo->add(*it);
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mDayCyclePresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second));
+ }
}
diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h
index 0ab458a0f6..2236d57ff4 100644
--- a/indra/newview/llfloaterenvironmentsettings.h
+++ b/indra/newview/llfloaterenvironmentsettings.h
@@ -40,6 +40,7 @@ public:
LLFloaterEnvironmentSettings(const LLSD &key);
/*virtual*/ BOOL postBuild();
/*virtual*/ void onOpen(const LLSD& key);
+ /*virtual*/ void onClose(bool app_quitting);
private:
void onSwitchRegionSettings();
diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp
index 1f155776bf..a2e705d1fa 100644
--- a/indra/newview/llsettingsbase.cpp
+++ b/indra/newview/llsettingsbase.cpp
@@ -33,12 +33,17 @@
#include "llsdserialize.h"
+//=========================================================================
namespace
{
const F32 BREAK_POINT = 0.5;
}
//=========================================================================
+const std::string LLSettingsBase::SETTING_ID("id");
+const std::string LLSettingsBase::SETTING_NAME("name");
+
+//=========================================================================
LLSettingsBase::LLSettingsBase():
mSettings(LLSD::emptyMap()),
mDirty(true)
@@ -242,15 +247,16 @@ LLSD LLSettingsBase::cloneSettings() const
LLSettingsBase::ptr_t LLSettingsBase::buildBlend(const ptr_t &begin, const ptr_t &end, F32 blendf)
{
- if (begin->getSettingType() != end->getSettingType())
- {
- LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " <<
- begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL;
-
- return LLSettingsBase::ptr_t();
- }
-
- return begin->blend(end, blendf);
+// if (begin->getSettingType() != end->getSettingType())
+// {
+// LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " <<
+// begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL;
+//
+// return LLSettingsBase::ptr_t();
+// }
+
+// return begin->blend(end, blendf);
+ return LLSettingsBase::ptr_t();
}
void LLSettingsBase::exportSettings(std::string name) const
diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h
index f7015fb12b..205351c401 100644
--- a/indra/newview/llsettingsbase.h
+++ b/indra/newview/llsettingsbase.h
@@ -46,6 +46,9 @@ class LLSettingsBase: private boost::noncopyable
friend class LLSettingsDayCycle;
public:
+ static const std::string SETTING_ID;
+ static const std::string SETTING_NAME;
+
typedef std::map<std::string, S32> parammapping_t;
typedef boost::shared_ptr<LLSettingsBase> ptr_t;
@@ -63,6 +66,32 @@ public:
inline bool isDirty() const { return mDirty; }
inline void setDirtyFlag(bool dirty) { mDirty = dirty; }
+ inline LLUUID getId() const
+ {
+ return getValue(SETTING_ID).asUUID();
+ }
+
+ inline std::string getName() const
+ {
+ return getValue(SETTING_NAME).asString();
+ }
+
+ inline void setName(std::string val)
+ {
+ setValue(SETTING_NAME, val);
+ }
+
+ inline void replaceSettings(LLSD settings)
+ {
+ mSettings = settings;
+ setDirtyFlag(true);
+ }
+
+ inline LLSD getSettings() const
+ {
+ return mSettings;
+ }
+
//---------------------------------------------------------------------
//
inline void setValue(const std::string &name, const LLSD &value)
@@ -71,7 +100,7 @@ public:
mDirty = true;
}
- inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD())
+ inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const
{
if (!mSettings.has(name))
return deflt;
@@ -121,13 +150,14 @@ public:
// TODO: This is temporary
virtual void exportSettings(std::string name) const;
+ virtual void blend(const ptr_t &end, F32 blendf) = 0;
+
protected:
LLSettingsBase();
LLSettingsBase(const LLSD setting);
typedef std::set<std::string> stringset_t;
- virtual ptr_t blend(const ptr_t &end, F32 blendf) const = 0;
// combining settings objects. Customize for specific setting types
virtual void lerpSettings(const LLSettingsBase &other, F32 mix);
diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp
index bda3c7c138..2d97ea865f 100644
--- a/indra/newview/llsettingsdaycycle.cpp
+++ b/indra/newview/llsettingsdaycycle.cpp
@@ -47,6 +47,8 @@
#include "llenvironment.h"
+#include "llworld.h"
+
//=========================================================================
namespace
{
@@ -55,7 +57,16 @@ namespace
inline F32 get_wrapping_distance(F32 begin, F32 end)
{
- return 1.0 - fabs((begin + 1.0) - end);
+ if (begin < end)
+ {
+ return end - begin;
+ }
+ else if (begin > end)
+ {
+ return 1.0 - (begin - end);
+ }
+
+ return 0;
}
LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDayCycle::CycleTrack_t &collection, F32 key)
@@ -81,11 +92,11 @@ namespace
LLSettingsDayCycle::CycleTrack_t::iterator it = collection.lower_bound(key);
if (it == collection.end())
- { // all offsets are lower, take the last one.
+ { // all keyframes are lower, take the last one.
--it; // we know the range is not empty
}
else if ((*it).first > key)
- { // the offset we are interested in is smaller than the found.
+ { // the keyframe we are interested in is smaller than the found.
if (it == collection.begin())
it = collection.end();
--it;
@@ -101,11 +112,13 @@ namespace
const std::string LLSettingsDayCycle::SETTING_DAYLENGTH("day_length");
const std::string LLSettingsDayCycle::SETTING_KEYID("key_id");
const std::string LLSettingsDayCycle::SETTING_KEYNAME("key_name");
-const std::string LLSettingsDayCycle::SETTING_KEYOFFSET("key_offset");
+const std::string LLSettingsDayCycle::SETTING_KEYKFRAME("key_keyframe");
const std::string LLSettingsDayCycle::SETTING_NAME("name");
const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks");
-const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours
+const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins
+
+//const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours
const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days
const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0
@@ -113,13 +126,15 @@ const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water
//=========================================================================
LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) :
- LLSettingsBase(data)
+ LLSettingsBase(data),
+ mHasParsed(false)
{
mDayTracks.resize(TRACK_MAX);
}
LLSettingsDayCycle::LLSettingsDayCycle() :
- LLSettingsBase()
+ LLSettingsBase(),
+ mHasParsed(false)
{
mDayTracks.resize(TRACK_MAX);
}
@@ -132,8 +147,8 @@ LLSD LLSettingsDayCycle::defaults()
dfltsetting[SETTING_NAME] = "_default_";
dfltsetting[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH;
dfltsetting[SETTING_TRACKS] = LLSDArray(
- LLSDArray(LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))
- (LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")));
+ LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))
+ (LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")));
return dfltsetting;
}
@@ -146,14 +161,14 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s
newsettings[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH;
LLSD watertrack = LLSDArray(
- LLSDMap ( SETTING_KEYOFFSET, LLSD::Real(0.0f) )
+ LLSDMap ( SETTING_KEYKFRAME, LLSD::Real(0.0f) )
( SETTING_KEYNAME, "Default" ));
LLSD skytrack = LLSD::emptyArray();
for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it)
{
- LLSD entry = LLSDMap(SETTING_KEYOFFSET, (*it)[0].asReal())
+ LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal())
(SETTING_KEYNAME, (*it)[1].asString());
skytrack.append(entry);
}
@@ -185,7 +200,7 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data)
LLSD curtrack = tracks[i];
for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it)
{
- F32 offset = (*it)[SETTING_KEYOFFSET].asReal();
+ F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal();
LLSettingsBase::ptr_t setting;
if ((*it).has(SETTING_KEYNAME))
@@ -201,9 +216,10 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data)
}
if (setting)
- mDayTracks[i][offset] = setting;
+ mDayTracks[i][keyframe] = setting;
}
}
+ mHasParsed = true;
}
@@ -216,31 +232,85 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone()
return dayp;
}
-LLSettingsBase::ptr_t LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) const
+void LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix)
{
LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL;
- return LLSettingsBase::ptr_t();
}
//=========================================================================
-F32 LLSettingsDayCycle::secondsToOffset(S32 seconds)
+F32 LLSettingsDayCycle::secondsToKeyframe(S32 seconds)
{
S32 daylength = getDayLength();
return static_cast<F32>(seconds % daylength) / static_cast<F32>(daylength);
}
-S32 LLSettingsDayCycle::offsetToSeconds(F32 offset)
+S32 LLSettingsDayCycle::keyframeToSeconds(F32 keyframe)
{
S32 daylength = getDayLength();
- return static_cast<S32>(offset * static_cast<F32>(daylength));
+ return static_cast<S32>(keyframe * static_cast<F32>(daylength));
}
//=========================================================================
void LLSettingsDayCycle::updateSettings()
{
+ if (!mHasParsed)
+ parseFromLLSD(mSettings);
+ //F64Seconds time_now(LLWorld::instance().getSpaceTimeUSec());
+ F64Seconds time_now(LLDate::now().secondsSinceEpoch());
+
+ // base class clears dirty flag so as to not trigger recursive update
+ LLSettingsBase::updateSettings();
+
+ if (!mBlendedWater)
+ {
+ mBlendedWater = LLEnvironment::instance().getCurrentWater()->buildClone();
+ LLEnvironment::instance().selectWater(mBlendedWater);
+ }
+
+ if (!mBlendedSky)
+ {
+ mBlendedSky = LLEnvironment::instance().getCurrentSky()->buildClone();
+ LLEnvironment::instance().selectSky(mBlendedSky);
+ }
+
+
+ if ((time_now < mLastUpdateTime) || ((time_now - mLastUpdateTime) > static_cast<F64Seconds>(0.1)))
+ {
+ F64Seconds daylength = static_cast<F64Seconds>(getDayLength());
+ F32 frame = fmod(time_now.value(), daylength.value()) / daylength.value();
+
+ CycleList_t::iterator itTrack = mDayTracks.begin();
+ TrackBound_t bounds = getBoundingEntries(*itTrack, frame);
+
+ mBlendedWater->replaceSettings((*bounds.first).second->getSettings());
+ if (bounds.first != bounds.second)
+ {
+ F32 blendf = get_wrapping_distance((*bounds.first).first, frame) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
+ mBlendedWater->blend((*bounds.second).second, blendf);
+ }
+
+ ++itTrack;
+ bounds = getBoundingEntries(*itTrack, frame);
+
+ //_WARNS("RIDER") << "Sky blending: frame=" << frame << " start=" << F64Seconds((*bounds.first).first) << " end=" << F64Seconds((*bounds.second).first) << LL_ENDL;
+
+ mBlendedSky->replaceSettings((*bounds.first).second->getSettings());
+ if (bounds.first != bounds.second)
+ {
+ F32 blendf = get_wrapping_distance((*bounds.first).first, frame) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
+ //_WARNS("RIDER") << "Distance=" << get_wrapping_distance((*bounds.first).first, frame) << "/" << get_wrapping_distance((*bounds.first).first, (*bounds.second).first) << " Blend factor=" << blendf << LL_ENDL;
+
+ mBlendedSky->blend((*bounds.second).second, blendf);
+ }
+
+ mLastUpdateTime = time_now;
+ }
+
+ // Always mark the day cycle as dirty.So that the blend check can be handled.
+ setDirtyFlag(true);
}
//=========================================================================
@@ -251,40 +321,40 @@ void LLSettingsDayCycle::setDayLength(S32 seconds)
setValue(SETTING_DAYLENGTH, seconds);
}
-LLSettingsDayCycle::OffsetList_t LLSettingsDayCycle::getTrackOffsets(S32 trackno)
+LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 trackno)
{
if ((trackno < 1) || (trackno >= TRACK_MAX))
{
LL_WARNS("DAYCYCLE") << "Attempt get track (#" << trackno << ") out of range!" << LL_ENDL;
- return OffsetList_t();
+ return KeyframeList_t();
}
- OffsetList_t offsets;
+ KeyframeList_t keyframes;
CycleTrack_t &track = mDayTracks[trackno];
- offsets.reserve(track.size());
+ keyframes.reserve(track.size());
for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it)
{
- offsets.push_back((*it).first);
+ keyframes.push_back((*it).first);
}
- return offsets;
+ return keyframes;
}
LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno)
{
- OffsetList_t offsets = getTrackOffsets(trackno);
+ KeyframeList_t keyframes = getTrackKeyframes(trackno);
- if (offsets.empty())
+ if (keyframes.empty())
return TimeList_t();
TimeList_t times;
- times.reserve(offsets.size());
- for (OffsetList_t::iterator it = offsets.begin(); it != offsets.end(); ++it)
+ times.reserve(keyframes.size());
+ for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it)
{
- times.push_back(offsetToSeconds(*it));
+ times.push_back(keyframeToSeconds(*it));
}
return times;
@@ -292,13 +362,13 @@ LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno)
void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds)
{
- F32 offset = secondsToOffset(seconds);
- setWaterAtOffset(water, offset);
+ F32 keyframe = secondsToKeyframe(seconds);
+ setWaterAtKeyframe(water, keyframe);
}
-void LLSettingsDayCycle::setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset)
+void LLSettingsDayCycle::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe)
{
- mDayTracks[TRACK_WATER][offset] = water;
+ mDayTracks[TRACK_WATER][keyframe] = water;
setDirtyFlag(true);
}
@@ -310,34 +380,33 @@ void LLSettingsDayCycle::setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seco
LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL;
return;
}
- F32 offset = secondsToOffset(seconds);
+ F32 keyframe = secondsToKeyframe(seconds);
- mDayTracks[track][offset] = sky;
+ mDayTracks[track][keyframe] = sky;
setDirtyFlag(true);
-
}
-LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 offset)
+LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 keyframe)
{
- return TrackBound_t(get_wrapping_atbefore(track, offset), get_wrapping_atafter(track, offset));
+ return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe));
}
-LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 offset)
-{
- TrackBound_t bounds = getBoundingEntries(track, offset);
-
- if (bounds.first == track.end())
- return LLSettingsBase::ptr_t(); // Track is empty nothing to blend.
-
- if (bounds.first == bounds.second)
- { // Single entry. Nothing to blend
- return (*bounds.first).second;
- }
-
- F32 blendf = get_wrapping_distance((*bounds.first).first, offset) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
-
- LLSettingsBase::ptr_t base = (*bounds.first).second;
- return base->blend((*bounds.second).second, blendf);
-}
+// LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 keyframe)
+// {
+// TrackBound_t bounds = getBoundingEntries(track, keyframe);
+//
+// if (bounds.first == track.end())
+// return LLSettingsBase::ptr_t(); // Track is empty nothing to blend.
+//
+// if (bounds.first == bounds.second)
+// { // Single entry. Nothing to blend
+// return (*bounds.first).second;
+// }
+//
+// F32 blendf = get_wrapping_distance((*bounds.first).first, keyframe) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
+//
+// LLSettingsBase::ptr_t base = (*bounds.first).second;
+// return base->blend((*bounds.second).second, blendf);
+// }
//=========================================================================
diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h
index 5eb704cdb7..f332b85dee 100644
--- a/indra/newview/llsettingsdaycycle.h
+++ b/indra/newview/llsettingsdaycycle.h
@@ -42,7 +42,7 @@ public:
static const std::string SETTING_DAYLENGTH;
static const std::string SETTING_KEYID;
static const std::string SETTING_KEYNAME;
- static const std::string SETTING_KEYOFFSET;
+ static const std::string SETTING_KEYKFRAME;
static const std::string SETTING_NAME;
static const std::string SETTING_TRACKS;
@@ -56,7 +56,7 @@ public:
typedef std::vector<CycleTrack_t> CycleList_t;
typedef boost::shared_ptr<LLSettingsDayCycle> ptr_t;
typedef std::vector<S32> TimeList_t;
- typedef std::vector<F32> OffsetList_t;
+ typedef std::vector<F32> KeyframeList_t;
typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t;
//---------------------------------------------------------------------
@@ -71,7 +71,7 @@ public:
virtual std::string getSettingType() const { return std::string("daycycle"); }
// Settings status
- virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &other, F32 mix) const;
+ virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix);
static LLSD defaults();
@@ -83,11 +83,11 @@ public:
void setDayLength(S32 seconds);
- OffsetList_t getTrackOffsets(S32 track);
+ KeyframeList_t getTrackKeyframes(S32 track);
TimeList_t getTrackTimes(S32 track);
void setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds);
- void setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset);
+ void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe);
LLSettingsSkyPtr_t getBlendedWaterAt(S32 seconds);
void setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track);
@@ -98,23 +98,27 @@ protected:
virtual void updateSettings();
+ LLSettingsSkyPtr_t mBlendedSky;
+ LLSettingsWaterPtr_t mBlendedWater;
CycleList_t mDayTracks;
- F32 secondsToOffset(S32 seconds);
- S32 offsetToSeconds(F32 offset);
+ bool mHasParsed;
- LLSettingsBase::ptr_t getBlendedEntry(CycleTrack_t &track, F32 offset);
+ F32 secondsToKeyframe(S32 seconds);
+ S32 keyframeToSeconds(F32 keyframe);
+
+ //LLSettingsBase::ptr_t getBlendedEntry(const CycleTrack_t &track, F32 keyframe);
void parseFromLLSD(LLSD &data);
// CycleList_t & getTrackRef(S32 trackno);
- static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 offset);
- static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 offset);
-
- static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 offset);
+ static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe);
+ static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe);
+ static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe);
+ F32Seconds mLastUpdateTime;
private:
};
diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp
index 782703c7f7..c420ebca1e 100644
--- a/indra/newview/llsettingssky.cpp
+++ b/indra/newview/llsettingssky.cpp
@@ -81,7 +81,6 @@ 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_NAME("name");
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");
@@ -103,14 +102,12 @@ LLSettingsSky::LLSettingsSky():
{
}
-LLSettingsBase::ptr_t LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const
+void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf)
{
LLSettingsSky::ptr_t other = boost::static_pointer_cast<LLSettingsSky>(end);
LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf);
- LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(blenddata);
-
- return skyp;
+ replaceSettings(blenddata);
}
@@ -301,18 +298,18 @@ LLSettingsSky::ptr_t LLSettingsSky::buildClone()
// Settings status
-LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const
-{
- LL_RECORD_BLOCK_TIME(FTM_BLEND_SKYVALUES);
- LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL;
-
- LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(mSettings);
- // the settings in the initial constructor are references to this' settings block.
- // They will be replaced in the following lerp
- skyp->lerpSettings(*other, mix);
-
- return skyp;
-}
+// LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const
+// {
+// LL_RECORD_BLOCK_TIME(FTM_BLEND_SKYVALUES);
+// LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL;
+//
+// LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(mSettings);
+// // the settings in the initial constructor are references to this' settings block.
+// // They will be replaced in the following lerp
+// skyp->lerpSettings(*other, mix);
+//
+// return skyp;
+// }
LLSD LLSettingsSky::defaults()
diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h
index 977ab5141e..ade5a06553 100644
--- a/indra/newview/llsettingssky.h
+++ b/indra/newview/llsettingssky.h
@@ -56,7 +56,6 @@ public:
static const std::string SETTING_MAX_Y;
static const std::string SETTING_MOON_ROTATION;
static const std::string SETTING_MOON_TEXTUREID;
- static const std::string SETTING_NAME;
static const std::string SETTING_STAR_BRIGHTNESS;
static const std::string SETTING_SUNLIGHT_COLOR;
static const std::string SETTING_SUN_ROTATION;
@@ -77,7 +76,7 @@ public:
virtual std::string getSettingType() const { return std::string("sky"); }
// Settings status
- ptr_t blend(const ptr_t &other, F32 mix) const;
+ virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf);
static LLSD defaults();
@@ -414,7 +413,6 @@ public:
protected:
LLSettingsSky();
- virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const;
virtual stringset_t getSlerpKeys() const;
diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp
index 52448bd4af..9a6dfc15fd 100644
--- a/indra/newview/llsettingswater.cpp
+++ b/indra/newview/llsettingswater.cpp
@@ -56,7 +56,6 @@ const std::string LLSettingsWater::SETTING_FOG_DENSITY("water_fog_density");
const std::string LLSettingsWater::SETTING_FOG_MOD("underwater_fog_mod");
const std::string LLSettingsWater::SETTING_FRESNEL_OFFSET("fresnel_offset");
const std::string LLSettingsWater::SETTING_FRESNEL_SCALE("fresnel_scale");
-const std::string LLSettingsWater::SETTING_NAME("name");
const std::string LLSettingsWater::SETTING_NORMAL_MAP("normal_map");
const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale");
const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above");
@@ -195,14 +194,12 @@ LLSettingsWater::ptr_t LLSettingsWater::buildClone()
return skyp;
}
-LLSettingsBase::ptr_t LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const
+void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf)
{
LLSettingsWater::ptr_t other = boost::static_pointer_cast<LLSettingsWater>(end);
LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf);
-
- LLSettingsWater::ptr_t waterp = boost::make_shared<LLSettingsWater>(blenddata);
-
- return waterp;
+
+ replaceSettings(blenddata);
}
diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h
index 6a7e692c25..1550ba4004 100644
--- a/indra/newview/llsettingswater.h
+++ b/indra/newview/llsettingswater.h
@@ -39,7 +39,6 @@ public:
static const std::string SETTING_FOG_MOD;
static const std::string SETTING_FRESNEL_OFFSET;
static const std::string SETTING_FRESNEL_SCALE;
- static const std::string SETTING_NAME;
static const std::string SETTING_NORMAL_MAP;
static const std::string SETTING_NORMAL_SCALE;
static const std::string SETTING_SCALE_ABOVE;
@@ -63,7 +62,7 @@ public:
virtual std::string getSettingType() const { return std::string("water"); }
// Settings status
- virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const;
+ virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf);
static LLSD defaults();
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index eb21f3c4b4..9e275fd108 100644
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -135,10 +135,6 @@ bool LLWaterParamManager::loadPreset(const std::string& path)
addParamSet(name, params_data);
}
- //*LAPRAS temp code testing conversion old preset to new settings.
- LLSettingsWater::ptr_t test = LLSettingsWater::buildFromLegacyPreset(name, params_data);
- LLEnvironment::instance().addWater(test);
-
return true;
}
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index a6dc2b343b..966a7840cf 100644
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -319,11 +319,6 @@ bool LLWLParamManager::loadPreset(const std::string& path)
addParamSet(key, params_data);
}
- //*LAPRAS temp code testing conversion old preset to new settings.
- LLSettingsSky::ptr_t test = LLSettingsSky::buildFromLegacyPreset(name, params_data);
- LLEnvironment::instance().addSky(test);
- //test->exportSettings(name);
-
return true;
}