From c04ceedbc3e462098eceaa233cd26f6bed79b773 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 19 Sep 2017 15:50:30 -0700 Subject: Baseline for settings changes --- indra/llinventory/llfoldertype.cpp | 2 +- indra/llinventory/llinventorydefines.h | 4 ++++ indra/llinventory/llinventorytype.cpp | 10 ++++++++++ indra/llinventory/llinventorytype.h | 6 +++++- 4 files changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llfoldertype.cpp b/indra/llinventory/llfoldertype.cpp index b0daf639fa..2c8c82a62b 100644 --- a/indra/llinventory/llfoldertype.cpp +++ b/indra/llinventory/llfoldertype.cpp @@ -147,7 +147,7 @@ bool LLFolderType::lookupIsEnsembleType(EType folder_type) // static LLAssetType::EType LLFolderType::folderTypeToAssetType(LLFolderType::EType folder_type) { - if (LLAssetType::lookup(LLAssetType::EType(folder_type)) == LLAssetType::badLookup()) + if (LLAssetType::lookup(LLAssetType::EType(folder_type)) == LLAssetType::BADLOOKUP) { LL_WARNS() << "Converting to unknown asset type " << folder_type << LL_ENDL; } diff --git a/indra/llinventory/llinventorydefines.h b/indra/llinventory/llinventorydefines.h index 3881fb1fd7..b420e98ecb 100644 --- a/indra/llinventory/llinventorydefines.h +++ b/indra/llinventory/llinventorydefines.h @@ -84,6 +84,10 @@ public: II_FLAGS_WEARABLES_MASK = 0xff, // Wearables use the low order byte of flags to store the // LLWearableType::EType enumeration found in newview/llwearable.h + // + II_FLAGS_SETTINGS_MASK = 0x0000ff, + // Settings (like wearables) use the low order byte of flags to store + // the settings type II_FLAGS_PERM_OVERWRITE_MASK = (II_FLAGS_OBJECT_SLAM_PERM | II_FLAGS_OBJECT_SLAM_SALE | diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp index d1e6807f52..20c0a12d9e 100644 --- a/indra/llinventory/llinventorytype.cpp +++ b/indra/llinventory/llinventorytype.cpp @@ -85,6 +85,7 @@ LLInventoryDictionary::LLInventoryDictionary() addEntry(LLInventoryType::IT_MESH, new InventoryEntry("mesh", "mesh", 1, LLAssetType::AT_MESH)); addEntry(LLInventoryType::IT_WIDGET, new InventoryEntry("widget", "widget", 1, LLAssetType::AT_WIDGET)); addEntry(LLInventoryType::IT_PERSON, new InventoryEntry("person", "person", 1, LLAssetType::AT_PERSON)); + addEntry(LLInventoryType::IT_SETTINGS, new InventoryEntry("settings", "settings", 1, LLAssetType::AT_SETTINGS)); } @@ -145,6 +146,14 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] = LLInventoryType::IT_NONE, // 47 AT_NONE LLInventoryType::IT_NONE, // 48 AT_NONE LLInventoryType::IT_MESH, // 49 AT_MESH + + LLInventoryType::IT_NONE, // 50 AT_RESERVED_1 + LLInventoryType::IT_NONE, // 51 AT_RESERVED_2 + LLInventoryType::IT_NONE, // 52 AT_RESERVED_3 + LLInventoryType::IT_NONE, // 53 AT_RESERVED_4 + LLInventoryType::IT_NONE, // 54 AT_RESERVED_5 + + LLInventoryType::IT_SETTINGS, // 55 AT_SETTINGS }; // static @@ -194,6 +203,7 @@ bool LLInventoryType::cannotRestrictPermissions(LLInventoryType::EType type) { case IT_CALLINGCARD: case IT_LANDMARK: + case IT_SETTINGS: return true; default: return false; diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h index fc3c78cf50..a45bcc364e 100644 --- a/indra/llinventory/llinventorytype.h +++ b/indra/llinventory/llinventorytype.h @@ -64,7 +64,8 @@ public: IT_MESH = 22, IT_WIDGET = 23, IT_PERSON = 24, - IT_COUNT = 25, + IT_SETTINGS = 25, + IT_COUNT = 26, IT_NONE = -1 }; @@ -110,6 +111,9 @@ public: ICONNAME_LINKFOLDER, ICONNAME_MESH, + ICONNAME_SETTINGS_SKY, + ICONNAME_SETTINGS_WATER, + ICONNAME_INVALID, ICONNAME_COUNT, ICONNAME_NONE = -1 -- cgit v1.3 From d7dd10b88bc3fda88f6528ecc5936e4889f019f3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Nov 2017 11:32:22 -0800 Subject: Split for viewer/simhost sync LLSD with simhost. --- indra/llcommon/llsd.cpp | 26 +- indra/llcommon/llsd.h | 5 +- indra/llcommon/llsdutil.cpp | 275 +++++++++++++ indra/llcommon/llsdutil.h | 30 ++ indra/llinventory/CMakeLists.txt | 8 + indra/llinventory/llsettingsbase.cpp | 581 +++++++++++++++++++++++++++ indra/llinventory/llsettingsbase.h | 306 +++++++++++++++ indra/llinventory/llsettingsdaycycle.cpp | 545 +++++++++++++++++++++++++ indra/llinventory/llsettingsdaycycle.h | 156 ++++++++ indra/llinventory/llsettingssky.cpp | 561 ++++++++++++++++++++++++++ indra/llinventory/llsettingssky.h | 455 +++++++++++++++++++++ indra/llinventory/llsettingswater.cpp | 215 ++++++++++ indra/llinventory/llsettingswater.h | 227 +++++++++++ indra/newview/CMakeLists.txt | 10 +- indra/newview/llenvironment.cpp | 22 +- indra/newview/llenvironment.h | 3 + indra/newview/llsettingsbase.cpp | 617 ----------------------------- indra/newview/llsettingsbase.h | 312 --------------- indra/newview/llsettingsdaycycle.cpp | 613 ----------------------------- indra/newview/llsettingsdaycycle.h | 143 ------- indra/newview/llsettingssky.cpp | 655 ------------------------------- indra/newview/llsettingssky.h | 463 ---------------------- indra/newview/llsettingsvo.cpp | 420 ++++++++++++++++++++ indra/newview/llsettingsvo.h | 103 +++++ indra/newview/llsettingswater.cpp | 340 ---------------- indra/newview/llsettingswater.h | 243 ------------ 26 files changed, 3923 insertions(+), 3411 deletions(-) create mode 100644 indra/llinventory/llsettingsbase.cpp create mode 100644 indra/llinventory/llsettingsbase.h create mode 100644 indra/llinventory/llsettingsdaycycle.cpp create mode 100644 indra/llinventory/llsettingsdaycycle.h create mode 100644 indra/llinventory/llsettingssky.cpp create mode 100644 indra/llinventory/llsettingssky.h create mode 100644 indra/llinventory/llsettingswater.cpp create mode 100644 indra/llinventory/llsettingswater.h delete mode 100644 indra/newview/llsettingsbase.cpp delete mode 100644 indra/newview/llsettingsbase.h delete mode 100644 indra/newview/llsettingsdaycycle.cpp delete mode 100644 indra/newview/llsettingsdaycycle.h delete mode 100644 indra/newview/llsettingssky.cpp delete mode 100644 indra/newview/llsettingssky.h create mode 100644 indra/newview/llsettingsvo.cpp create mode 100644 indra/newview/llsettingsvo.h delete mode 100644 indra/newview/llsettingswater.cpp delete mode 100644 indra/newview/llsettingswater.h (limited to 'indra/llinventory') diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 57aa7d9c07..57b746889d 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -132,6 +132,7 @@ public: virtual bool has(const String&) const { return false; } virtual LLSD get(const String&) const { return LLSD(); } + virtual LLSD getKeys() const { return LLSD::emptyArray(); } virtual void erase(const String&) { } virtual const LLSD& ref(const String&) const{ return undef(); } @@ -380,7 +381,8 @@ namespace using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer) using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer) virtual LLSD get(const LLSD::String&) const; - void insert(const LLSD::String& k, const LLSD& v); + virtual LLSD getKeys() const; + void insert(const LLSD::String& k, const LLSD& v); virtual void erase(const LLSD::String&); LLSD& ref(const LLSD::String&); virtual const LLSD& ref(const LLSD::String&) const; @@ -421,7 +423,19 @@ namespace DataMap::const_iterator i = mData.find(k); return (i != mData.end()) ? i->second : LLSD(); } - + + LLSD ImplMap::getKeys() const + { + LLSD keys = LLSD::emptyArray(); + DataMap::const_iterator iter = mData.begin(); + while (iter != mData.end()) + { + keys.append((*iter).first); + iter++; + } + return keys; + } + void ImplMap::insert(const LLSD::String& k, const LLSD& v) { mData.insert(DataMap::value_type(k, v)); @@ -502,7 +516,7 @@ namespace virtual LLSD get(LLSD::Integer) const; void set(LLSD::Integer, const LLSD&); void insert(LLSD::Integer, const LLSD&); - void append(const LLSD&); + LLSD& append(const LLSD&); virtual void erase(LLSD::Integer); LLSD& ref(LLSD::Integer); virtual const LLSD& ref(LLSD::Integer) const; @@ -570,9 +584,10 @@ namespace mData.insert(mData.begin() + index, v); } - void ImplArray::append(const LLSD& v) + LLSD& ImplArray::append(const LLSD& v) { mData.push_back(v); + return mData.back(); } void ImplArray::erase(LLSD::Integer i) @@ -862,6 +877,7 @@ LLSD LLSD::emptyMap() bool LLSD::has(const String& k) const { return safe(impl).has(k); } LLSD LLSD::get(const String& k) const { return safe(impl).get(k); } +LLSD LLSD::getKeys() const { return safe(impl).getKeys(); } void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); } LLSD& LLSD::with(const String& k, const LLSD& v) @@ -895,7 +911,7 @@ LLSD& LLSD::with(Integer i, const LLSD& v) makeArray(impl).insert(i, v); return *this; } -void LLSD::append(const LLSD& v) { makeArray(impl).append(v); } +LLSD& LLSD::append(const LLSD& v) { return makeArray(impl).append(v); } void LLSD::erase(Integer i) { makeArray(impl).erase(i); } LLSD& LLSD::operator[](Integer i) diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 7b9b1285f5..5b6d5545af 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -79,7 +79,7 @@ an LLSD array). An array is a sequence of zero or more LLSD values. - + Thread Safety In general, these LLSD classes offer *less* safety than STL container @@ -284,6 +284,7 @@ public: bool has(const String&) const; LLSD get(const String&) const; + LLSD getKeys() const; // Return an LLSD array with keys as strings void insert(const String&, const LLSD&); void erase(const String&); LLSD& with(const String&, const LLSD&); @@ -301,7 +302,7 @@ public: LLSD get(Integer) const; void set(Integer, const LLSD&); void insert(Integer, const LLSD&); - void append(const LLSD&); + LLSD& append(const LLSD&); void erase(Integer); LLSD& with(Integer, const LLSD&); diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index 6ad4a97149..0171f2880e 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -314,6 +314,180 @@ BOOL compare_llsd_with_template( return TRUE; } +// filter_llsd_with_template() is a direct clone (copy-n-paste) of +// compare_llsd_with_template with the following differences: +// (1) bool vs BOOL return types +// (2) A map with the key value "*" is a special value and maps any key in the +// test llsd that doesn't have an explicitly matching key in the template. +// (3) The element of an array with exactly one element is taken as a template +// for *all* the elements of the test array. If the template array is of +// different size, compare_llsd_with_template() semantics apply. +bool filter_llsd_with_template( + const LLSD & llsd_to_test, + const LLSD & template_llsd, + LLSD & resultant_llsd) +{ + if (llsd_to_test.isUndefined() && template_llsd.isDefined()) + { + resultant_llsd = template_llsd; + return true; + } + else if (llsd_to_test.type() != template_llsd.type()) + { + resultant_llsd = LLSD(); + return false; + } + + if (llsd_to_test.isArray()) + { + //they are both arrays + //we loop over all the items in the template + //verifying that the to_test has a subset (in the same order) + //any shortcoming in the testing_llsd are just taken + //to be the rest of the template + LLSD data; + LLSD::array_const_iterator test_iter; + LLSD::array_const_iterator template_iter; + + resultant_llsd = LLSD::emptyArray(); + test_iter = llsd_to_test.beginArray(); + + if (1 == template_llsd.size()) + { + // If the template has a single item, treat it as + // the template for *all* items in the test LLSD. + template_iter = template_llsd.beginArray(); + + for (; test_iter != llsd_to_test.endArray(); ++test_iter) + { + if (! filter_llsd_with_template(*test_iter, *template_iter, data)) + { + resultant_llsd = LLSD(); + return false; + } + else + { + resultant_llsd.append(data); + } + } + } + else + { + // Traditional compare_llsd_with_template matching + + for (template_iter = template_llsd.beginArray(); + template_iter != template_llsd.endArray() && + test_iter != llsd_to_test.endArray(); + ++template_iter, ++test_iter) + { + if (! filter_llsd_with_template(*test_iter, *template_iter, data)) + { + resultant_llsd = LLSD(); + return false; + } + else + { + resultant_llsd.append(data); + } + } + + //so either the test or the template ended + //we do another loop now to the end of the template + //grabbing the default values + for (; + template_iter != template_llsd.endArray(); + ++template_iter) + { + resultant_llsd.append(*template_iter); + } + } + } + else if (llsd_to_test.isMap()) + { + resultant_llsd = LLSD::emptyMap(); + + //now we loop over the keys of the two maps + //any excess is taken from the template + //excess is ignored in the test + + // Special tag for wildcarded LLSD map key templates + const LLSD::String wildcard_tag("*"); + + const bool template_has_wildcard = template_llsd.has(wildcard_tag); + LLSD wildcard_value; + LLSD value; + + const LLSD::map_const_iterator template_iter_end(template_llsd.endMap()); + for (LLSD::map_const_iterator template_iter(template_llsd.beginMap()); + template_iter_end != template_iter; + ++template_iter) + { + if (wildcard_tag == template_iter->first) + { + wildcard_value = template_iter->second; + } + else if (llsd_to_test.has(template_iter->first)) + { + //the test LLSD has the same key + if (! filter_llsd_with_template(llsd_to_test[template_iter->first], + template_iter->second, + value)) + { + resultant_llsd = LLSD(); + return false; + } + else + { + resultant_llsd[template_iter->first] = value; + } + } + else if (! template_has_wildcard) + { + // test llsd doesn't have it...take the + // template as default value + resultant_llsd[template_iter->first] = template_iter->second; + } + } + if (template_has_wildcard) + { + LLSD sub_value; + LLSD::map_const_iterator test_iter; + + for (test_iter = llsd_to_test.beginMap(); + test_iter != llsd_to_test.endMap(); + ++test_iter) + { + if (resultant_llsd.has(test_iter->first)) + { + // Final value has test key, assume more specific + // template matched and we shouldn't modify it again. + continue; + } + else if (! filter_llsd_with_template(test_iter->second, + wildcard_value, + sub_value)) + { + // Test value doesn't match wildcarded template + resultant_llsd = LLSD(); + return false; + } + else + { + // Test value matches template, add the actuals. + resultant_llsd[test_iter->first] = sub_value; + } + } + } + } + else + { + //of same type...take the test llsd's value + resultant_llsd = llsd_to_test; + } + + return true; +} + /***************************************************************************** * Helpers for llsd_matches() *****************************************************************************/ @@ -673,3 +847,104 @@ bool llsd_equals(const LLSD& lhs, const LLSD& rhs, int bits) return false; // pacify the compiler } } + +// Construct a deep partial clone of of an LLSD object. primitive types share +// references, however maps, arrays and binary objects are duplicated. An optional +// filter may be include to exclude/include keys in a map. +LLSD llsd_clone(LLSD value, LLSD filter) +{ + LLSD clone; + bool has_filter(filter.isMap()); + + switch (value.type()) + { + case LLSD::TypeMap: + clone = LLSD::emptyMap(); + for (LLSD::map_const_iterator itm = value.beginMap(); itm != value.endMap(); ++itm) + { + if (has_filter) + { + if (filter.has((*itm).first)) + { + if (!filter[(*itm).first].asBoolean()) + continue; + } + else if (filter.has("*")) + { + if (!filter["*"].asBoolean()) + continue; + } + else + { + continue; + } + } + clone[(*itm).first] = llsd_clone((*itm).second, filter); + } + break; + case LLSD::TypeArray: + clone = LLSD::emptyArray(); + for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + { + clone.append(llsd_clone(*ita, filter)); + } + break; + + case LLSD::TypeBinary: + { + LLSD::Binary bin(value.asBinary().begin(), value.asBinary().end()); + clone = LLSD::Binary(bin); + break; + } + default: + clone = value; + } + + return clone; +} + +LLSD llsd_shallow(LLSD value, LLSD filter) +{ + LLSD shallow; + bool has_filter(filter.isMap()); + + if (value.isMap()) + { + shallow = LLSD::emptyMap(); + for (LLSD::map_const_iterator itm = value.beginMap(); itm != value.endMap(); ++itm) + { + if (has_filter) + { + if (filter.has((*itm).first)) + { + if (!filter[(*itm).first].asBoolean()) + continue; + } + else if (filter.has("*")) + { + if (!filter["*"].asBoolean()) + continue; + } + else + { + continue; + } + } + shallow[(*itm).first] = (*itm).second; + } + } + else if (value.isArray()) + { + shallow = LLSD::emptyArray(); + for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + { + shallow.append(*ita); + } + } + else + { + return value; + } + + return shallow; +} diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h index c100454e15..33befef85b 100644 --- a/indra/llcommon/llsdutil.h +++ b/indra/llcommon/llsdutil.h @@ -69,6 +69,19 @@ LL_COMMON_API BOOL compare_llsd_with_template( const LLSD& template_llsd, LLSD& resultant_llsd); +// filter_llsd_with_template() is a direct clone (copy-n-paste) of +// compare_llsd_with_template with the following differences: +// (1) bool vs BOOL return types +// (2) A map with the key value "*" is a special value and maps any key in the +// test llsd that doesn't have an explicitly matching key in the template. +// (3) The element of an array with exactly one element is taken as a template +// for *all* the elements of the test array. If the template array is of +// different size, compare_llsd_with_template() semantics apply. +bool filter_llsd_with_template( + const LLSD & llsd_to_test, + const LLSD & template_llsd, + LLSD & resultant_llsd); + /** * Recursively determine whether a given LLSD data block "matches" another * LLSD prototype. The returned string is empty() on success, non-empty() on @@ -421,6 +434,23 @@ private: } // namespace llsd +// Creates a deep clone of an LLSD object. Maps, Arrays and binary objects +// are duplicated, atomic primitives (Boolean, Integer, Real, etc) simply +// use a shared reference. +// Optionally a filter may be specified to control what is duplicated. The +// map takes the form "keyname/boolean". +// If the value is true the value will be duplicated otherwise it will be skipped +// when encountered in a map. A key name of "*" can be specified as a wild card +// and will specify the default behavior. If no wild card is given and the clone +// encounters a name not in the filter, that value will be skipped. +LLSD llsd_clone(LLSD value, LLSD filter = LLSD()); + +// Creates a shallow copy of a map or array. If passed any other type of LLSD +// object it simply returns that value. See llsd_clone for a description of +// the filter parameter. +LLSD llsd_shallow(LLSD value, LLSD filter = LLSD()); + + // Specialization for generating a hash value from an LLSD block. template <> struct boost::hash diff --git a/indra/llinventory/CMakeLists.txt b/indra/llinventory/CMakeLists.txt index 68dd00d880..3eba746614 100644 --- a/indra/llinventory/CMakeLists.txt +++ b/indra/llinventory/CMakeLists.txt @@ -29,6 +29,10 @@ set(llinventory_SOURCE_FILES llparcel.cpp llpermissions.cpp llsaleinfo.cpp + llsettingsbase.cpp + llsettingsdaycycle.cpp + llsettingssky.cpp + llsettingswater.cpp lltransactionflags.cpp lluserrelations.cpp ) @@ -49,6 +53,10 @@ set(llinventory_HEADER_FILES llpermissions.h llpermissionsflags.h llsaleinfo.h + llsettingsbase.h + llsettingsdaycycle.h + llsettingssky.h + llsettingswater.h lltransactionflags.h lltransactiontypes.h lluserrelations.h diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp new file mode 100644 index 0000000000..e4291d8080 --- /dev/null +++ b/indra/llinventory/llsettingsbase.cpp @@ -0,0 +1,581 @@ +/** +* @file llsettingsbase.cpp +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llsettingsbase.h" + +#include "llmath.h" +#include + +#include "llsdserialize.h" + +//========================================================================= +namespace +{ + const F32 BREAK_POINT = 0.5; +} + +//========================================================================= +const std::string LLSettingsBase::SETTING_ID("id"); +const std::string LLSettingsBase::SETTING_NAME("name"); +const std::string LLSettingsBase::SETTING_HASH("hash"); +const std::string LLSettingsBase::SETTING_TYPE("type"); + +const F32Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); + +//========================================================================= +LLSettingsBase::LLSettingsBase(): + mSettings(LLSD::emptyMap()), + mDirty(true) +{ +} + +LLSettingsBase::LLSettingsBase(const LLSD setting) : + mSettings(setting), + mDirty(true) +{ +} + +//========================================================================= +void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F32 mix) +{ + mSettings = interpolateSDMap(mSettings, other.mSettings, mix); + setDirtyFlag(true); +} + +LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) const +{ + LLSD newSettings; + + for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) + { + std::string key_name = (*it).first; + LLSD value = (*it).second; + + LLSD::Type setting_type = value.type(); + switch (setting_type) + { + case LLSD::TypeMap: + newSettings[key_name] = combineSDMaps(value, LLSD()); + break; + case LLSD::TypeArray: + newSettings[key_name] = LLSD::emptyArray(); + for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + { + newSettings[key_name].append(*ita); + } + break; + //case LLSD::TypeInteger: + //case LLSD::TypeReal: + //case LLSD::TypeBoolean: + //case LLSD::TypeString: + //case LLSD::TypeUUID: + //case LLSD::TypeURI: + //case LLSD::TypeDate: + //case LLSD::TypeBinary: + default: + newSettings[key_name] = value; + break; + } + } + + if (!other.isUndefined()) + { + for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it) + { + std::string key_name = (*it).first; + LLSD value = (*it).second; + + LLSD::Type setting_type = value.type(); + switch (setting_type) + { + case LLSD::TypeMap: + newSettings[key_name] = combineSDMaps(value, LLSD()); + break; + case LLSD::TypeArray: + newSettings[key_name] = LLSD::emptyArray(); + for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + { + newSettings[key_name].append(*ita); + } + break; + //case LLSD::TypeInteger: + //case LLSD::TypeReal: + //case LLSD::TypeBoolean: + //case LLSD::TypeString: + //case LLSD::TypeUUID: + //case LLSD::TypeURI: + //case LLSD::TypeDate: + //case LLSD::TypeBinary: + default: + newSettings[key_name] = value; + break; + } + } + } + + return newSettings; +} + +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const +{ + LLSD newSettings; + + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + + for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) + { + std::string key_name = (*it).first; + LLSD value = (*it).second; + + if (skip.find(key_name) != skip.end()) + continue; + + if (!other.has(key_name)) + { // The other does not contain this setting, keep the original value + // TODO: Should I blend this out instead? + newSettings[key_name] = value; + continue; + } + LLSD::Type setting_type = value.type(); + LLSD other_value = other[key_name]; + + if (other_value.type() != setting_type) + { + // The data type mismatched between this and other. Hard switch when we pass the break point + // but issue a warning. + LL_WARNS("SETTINGS") << "Setting lerp between mismatched types for '" << key_name << "'." << LL_ENDL; + newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; + continue; + } + + switch (setting_type) + { + case LLSD::TypeInteger: + // lerp between the two values rounding the result to the nearest integer. + newSettings[key_name] = LLSD::Integer(llroundf(lerp(value.asReal(), other_value.asReal(), mix))); + break; + case LLSD::TypeReal: + // lerp between the two values. + newSettings[key_name] = LLSD::Real(lerp(value.asReal(), other_value.asReal(), mix)); + break; + case LLSD::TypeMap: + // deep copy. + newSettings[key_name] = interpolateSDMap(value, other_value, mix); + break; + + case LLSD::TypeArray: + { + LLSD newvalue(LLSD::emptyArray()); + + if (slerps.find(key_name) != slerps.end()) + { + LLQuaternion q = slerp(mix, LLQuaternion(value), LLQuaternion(other_value)); + newvalue = q.getValue(); + } + else + { // TODO: We could expand this to inspect the type and do a deep lerp based on type. + // for now assume a heterogeneous array of reals. + size_t len = std::max(value.size(), other_value.size()); + + for (size_t i = 0; i < len; ++i) + { + + newvalue[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix); + } + } + + newSettings[key_name] = newvalue; + } + + break; + +// case LLSD::TypeBoolean: +// case LLSD::TypeString: +// case LLSD::TypeUUID: +// case LLSD::TypeURI: +// case LLSD::TypeBinary: +// case LLSD::TypeDate: + default: + /* TODO: If the UUID points to an image ID, blend the images. */ + // atomic or unknown data types. Lerping between them does not make sense so switch at the break. + newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; + break; + } + } + + // Now add anything that is in other but not in the settings + for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it) + { + // TODO: Should I blend this in instead? + if (skip.find((*it).first) == skip.end()) + continue; + + if (!settings.has((*it).first)) + continue; + + newSettings[(*it).first] = (*it).second; + } + + return newSettings; +} + +LLSD LLSettingsBase::getSettings() const +{ + return mSettings; +} + +LLSD LLSettingsBase::cloneSettings() const +{ + return combineSDMaps(mSettings, LLSD()); +} + +size_t LLSettingsBase::getHash() const +{ // get a shallow copy of the LLSD filtering out values to not include in the hash + LLSD hash_settings = llsd_shallow(getSettings(), + LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true)); + + return boost::hash{}(hash_settings); +} + +#ifdef VALIDATION_DEBUG +namespace +{ + bool compare_llsd(LLSD valA, LLSD valB) + { + if (valA.type() != valB.type()) + return false; + + switch (valA.type()) + { + // case LLSD::TypeMap: + // newSettings[key_name] = combineSDMaps(value, LLSD()); + // break; + case LLSD::TypeArray: + if (valA.size() != valB.size()) + return false; + + for (S32 idx = 0; idx < valA.size(); ++idx) + { + if (!compare_llsd(valA[idx], valB[idx])) + return false; + } + return true; + + case LLSD::TypeInteger: + return valA.asInteger() == valB.asInteger(); + + case LLSD::TypeReal: + return is_approx_equal(valA.asReal(), valB.asReal()); + + case LLSD::TypeBoolean: + return valA.asBoolean() == valB.asBoolean(); + + case LLSD::TypeString: + return valA.asString() == valB.asString(); + + case LLSD::TypeUUID: + return valA.asUUID() == valB.asUUID(); + + case LLSD::TypeURI: + return valA.asString() == valB.asString(); + + case LLSD::TypeDate: + return valA.asDate() == valB.asDate(); + } + + return true; + } +} +#endif + +bool LLSettingsBase::validate() +{ + static Validator validateName(SETTING_NAME, false, LLSD::TypeString); + static Validator validateId(SETTING_ID, false, LLSD::TypeUUID); + static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger); + static Validator validateType(SETTING_TYPE, false, LLSD::TypeString); + validation_list_t validations = getValidationList(); + stringset_t validated; + stringset_t strip; + + if (!mSettings.has(SETTING_TYPE)) + { + mSettings[SETTING_TYPE] = getSettingType(); + } + + // Fields common to all settings. + if (!validateName.verify(mSettings)) + { + LL_WARNS("SETTINGS") << "Unable to validate Name." << LL_ENDL; + mIsValid = false; + return false; + } + validated.insert(validateName.getName()); + + if (!validateId.verify(mSettings)) + { + LL_WARNS("SETTINGS") << "Unable to validate Id." << LL_ENDL; + mIsValid = false; + return false; + } + validated.insert(validateId.getName()); + + if (!validateHash.verify(mSettings)) + { + LL_WARNS("SETTINGS") << "Unable to validate Hash." << LL_ENDL; + mIsValid = false; + return false; + } + validated.insert(validateHash.getName()); + + if (!validateType.verify(mSettings)) + { + LL_WARNS("SETTINGS") << "Unable to validate Type." << LL_ENDL; + mIsValid = false; + return false; + } + validated.insert(validateType.getName()); + + // Fields for specific settings. + for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv) + { +#ifdef VALIDATION_DEBUG + LLSD oldvalue; + if (mSettings.has((*itv).getName())) + { + oldvalue = llsd_clone(mSettings[(*itv).getName()]); + } +#endif + + if (!(*itv).verify(mSettings)) + { + LL_WARNS("SETTINGS") << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!" << LL_ENDL; + mIsValid = false; + return false; + } + validated.insert((*itv).getName()); + +#ifdef VALIDATION_DEBUG + if (!oldvalue.isUndefined()) + { + if (!compare_llsd(mSettings[(*itv).getName()], oldvalue)) + { + LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << mSettings[(*itv).getName()] << LL_ENDL; + } + } +#endif + } + + // strip extra entries + for (LLSD::map_iterator itm = mSettings.beginMap(); itm != mSettings.endMap(); ++itm) + { + if (validated.find((*itm).first) == validated.end()) + { + LL_WARNS("SETTINGS") << "Stripping setting '" << (*itm).first << "'" << LL_ENDL; + strip.insert((*itm).first); + } + } + + for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its) + { + mSettings.erase(*its); + } + + return true; +} + +//========================================================================= +bool LLSettingsBase::Validator::verify(LLSD &data) +{ + if (!data.has(mName) || (data.has(mName) && data[mName].isUndefined())) + { + if (mRequired) + LL_WARNS("SETTINGS") << "Missing required setting '" << mName << "'" << LL_ENDL; + return !mRequired; + } + + if (data[mName].type() != mType) + { + LL_WARNS("SETTINGS") << "Setting '" << mName << "' is incorrect type." << LL_ENDL; + return false; + } + + if (!mVerify.empty() && !mVerify(data[mName])) + { + LL_WARNS("SETTINGS") << "Setting '" << mName << "' fails validation." << LL_ENDL; + return false; + } + + return true; +} + +bool LLSettingsBase::Validator::verifyColor(LLSD &value) +{ + return (value.size() == 3 || value.size() == 4); +} + +bool LLSettingsBase::Validator::verifyVector(LLSD &value, S32 length) +{ + return (value.size() == length); +} + +bool LLSettingsBase::Validator::verifyVectorNormalized(LLSD &value, S32 length) +{ + if (value.size() != length) + return false; + + LLSD newvector; + + switch (length) + { + case 2: + { + LLVector2 vect(value); + + if (is_approx_equal(vect.normalize(), 1.0f)) + return true; + newvector = vect.getValue(); + break; + } + case 3: + { + LLVector3 vect(value); + + if (is_approx_equal(vect.normalize(), 1.0f)) + return true; + newvector = vect.getValue(); + break; + } + case 4: + { + LLVector4 vect(value); + + if (is_approx_equal(vect.normalize(), 1.0f)) + return true; + newvector = vect.getValue(); + break; + } + default: + return false; + } + + return true; +} + +bool LLSettingsBase::Validator::verifyVectorMinMax(LLSD &value, LLSD minvals, LLSD maxvals) +{ + for (S32 index = 0; index < value.size(); ++index) + { + if (minvals[index].asString() != "*") + { + if (minvals[index].asReal() > value[index].asReal()) + { + value[index] = minvals[index].asReal(); + } + } + if (maxvals[index].asString() != "*") + { + if (maxvals[index].asReal() < value[index].asReal()) + { + value[index] = maxvals[index].asReal(); + } + } + } + + return true; +} + +bool LLSettingsBase::Validator::verifyQuaternion(LLSD &value) +{ + return (value.size() == 4); +} + +bool LLSettingsBase::Validator::verifyQuaternionNormal(LLSD &value) +{ + if (value.size() != 4) + return false; + + LLQuaternion quat(value); + + if (is_approx_equal(quat.normalize(), 1.0f)) + return true; + + LLSD newquat = quat.getValue(); + for (S32 index = 0; index < 4; ++index) + { + value[index] = newquat[index]; + } + return true; +} + +bool LLSettingsBase::Validator::verifyFloatRange(LLSD &value, LLSD range) +{ + F32 real = value.asReal(); + + F32 clampedval = llclamp(LLSD::Real(real), range[0].asReal(), range[1].asReal()); + + if (is_approx_equal(clampedval, real)) + return true; + + value = LLSD::Real(clampedval); + return true; +} + +bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) +{ + S32 ival = value.asInteger(); + + S32 clampedval = llclamp(LLSD::Integer(ival), range[0].asInteger(), range[1].asInteger()); + + if (clampedval == ival) + return true; + + value = LLSD::Integer(clampedval); + return true; +} + +//========================================================================= + +void LLSettingsBlender::update(F32Seconds timedelta) +{ + mTimeSpent += timedelta; + + if (mTimeSpent >= mSeconds) + { + LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon + mOnFinished(shared_from_this()); + mOnFinished.disconnect_all_slots(); // prevent from firing more than once. + return; + } + + F32 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); + + mTarget->replaceSettings(mInitial->getSettings()); + mTarget->blend(mFinal, blendf); +} + diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h new file mode 100644 index 0000000000..2b59a103ad --- /dev/null +++ b/indra/llinventory/llsettingsbase.h @@ -0,0 +1,306 @@ +/** +* @file llsettingsbase.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_BASE_H +#define LL_SETTINGS_BASE_H + +#include +#include +#include +#include +#include + +#include "llsd.h" +#include "llsdutil.h" +#include "v2math.h" +#include "v3math.h" +#include "v4math.h" +#include "llquaternion.h" +#include "v4color.h" +#include "v3color.h" + +class LLSettingsBase : + public boost::enable_shared_from_this, + private boost::noncopyable +{ + friend class LLEnvironment; + friend class LLSettingsDay; + +public: + static const std::string SETTING_ID; + static const std::string SETTING_NAME; + static const std::string SETTING_HASH; + static const std::string SETTING_TYPE; + + typedef std::map parammapping_t; + + typedef boost::shared_ptr ptr_t; + + virtual ~LLSettingsBase() { }; + + //--------------------------------------------------------------------- + virtual std::string getSettingType() const = 0; + + //--------------------------------------------------------------------- + // Settings status + inline bool hasSetting(const std::string ¶m) const { return mSettings.has(param); } + inline bool isDirty() const { return mDirty; } + inline void setDirtyFlag(bool dirty) { mDirty = dirty; } + + size_t getHash() const; // Hash will not include Name, ID or a previously stored Hash + + 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); + } + + virtual LLSD getSettings() const; + + //--------------------------------------------------------------------- + // + inline void setValue(const std::string &name, const LLSD &value) + { + mSettings[name] = value; + mDirty = true; + } + + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const + { + if (!mSettings.has(name)) + return deflt; + return mSettings[name]; + } + + inline void setValue(const std::string &name, const LLVector2 &value) + { + setValue(name, value.getValue()); + } + + inline void setValue(const std::string &name, const LLVector3 &value) + { + setValue(name, value.getValue()); + } + + inline void setValue(const std::string &name, const LLVector4 &value) + { + setValue(name, value.getValue()); + } + + inline void setValue(const std::string &name, const LLQuaternion &value) + { + setValue(name, value.getValue()); + } + + inline void setValue(const std::string &name, const LLColor3 &value) + { + setValue(name, value.getValue()); + } + + inline void setValue(const std::string &name, const LLColor4 &value) + { + setValue(name, value.getValue()); + } + + // Note this method is marked const but may modify the settings object. + // (note the internal const cast). This is so that it may be called without + // special consideration from getters. + inline void update() const + { + if (!mDirty) + return; + (const_cast(this))->updateSettings(); + } + + virtual void blend(const ptr_t &end, F32 blendf) = 0; + + virtual bool validate(); + +protected: + class Validator + { + public: + typedef boost::function verify_pr; + + Validator(std::string name, bool required, LLSD::Type type, verify_pr verify = verify_pr()) : + mName(name), + mRequired(required), + mType(type), + mVerify(verify) + { } + + std::string getName() const { return mName; } + bool isRequired() const { return mRequired; } + LLSD::Type getType() const { return mType; } + + bool verify(LLSD &data); + + // Some basic verifications + static bool verifyColor(LLSD &value); + static bool verifyVector(LLSD &value, S32 length); + static bool verifyVectorMinMax(LLSD &value, LLSD minvals, LLSD maxvals); + static bool verifyVectorNormalized(LLSD &value, S32 length); + static bool verifyQuaternion(LLSD &value); + static bool verifyQuaternionNormal(LLSD &value); + static bool verifyFloatRange(LLSD &value, LLSD range); + static bool verifyIntegerRange(LLSD &value, LLSD range); + + private: + std::string mName; + bool mRequired; + LLSD::Type mType; + verify_pr mVerify; + }; + typedef std::vector validation_list_t; + + LLSettingsBase(); + LLSettingsBase(const LLSD setting); + + typedef std::set stringset_t; + + // combining settings objects. Customize for specific setting types + virtual void lerpSettings(const LLSettingsBase &other, F32 mix); + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const; + + /// when lerping between settings, some may require special handling. + /// Get a list of these key to be skipped by the default settings lerp. + /// (handling should be performed in the override of lerpSettings. + virtual stringset_t getSkipInterpolateKeys() const { return stringset_t(); } + + // A list of settings that represent quaternions and should be slerped + // rather than lerped. + virtual stringset_t getSlerpKeys() const { return stringset_t(); } + + // Calculate any custom settings that may need to be cached. + virtual void updateSettings() { mDirty = false; }; + + virtual validation_list_t getValidationList() const = 0; + + // Apply any settings that need special handling. + virtual void applySpecial(void *) { }; + + virtual parammapping_t getParameterMap() const { return parammapping_t(); } + + LLSD mSettings; + bool mIsValid; + + LLSD cloneSettings() const; + +private: + bool mDirty; + + LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; + +}; + + +class LLSettingsBlender : public boost::enable_shared_from_this +{ +public: + typedef boost::shared_ptr ptr_t; + typedef boost::signals2::signal finish_signal_t; + typedef boost::signals2::connection connection_t; + + static const F32Seconds DEFAULT_THRESHOLD; + + LLSettingsBlender(const LLSettingsBase::ptr_t &target, + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F32Seconds seconds) : + mTarget(target), + mInitial(initsetting), + mFinal(endsetting), + mSeconds(seconds), + mOnFinished(), + mBlendThreshold(DEFAULT_THRESHOLD), + mLastUpdate(0.0f), + mTimeSpent(0.0f) + { + mTarget->replaceSettings(mInitial->getSettings()); + mTimeStart = F32Seconds(LLDate::now().secondsSinceEpoch()); + mLastUpdate = mTimeStart; + } + + ~LLSettingsBlender() {} + + connection_t setOnFinished(const finish_signal_t::slot_type &onfinished) + { + return mOnFinished.connect(onfinished); + } + + void setUpdateThreshold(F32Seconds threshold) + { + mBlendThreshold = threshold; + } + + F32Seconds getUpdateThreshold() const + { + return mBlendThreshold; + } + + LLSettingsBase::ptr_t getTarget() const + { + return mTarget; + } + + LLSettingsBase::ptr_t getInitial() const + { + return mInitial; + } + + LLSettingsBase::ptr_t getFinal() const + { + return mFinal; + } + + void update(F32Seconds time); +private: + LLSettingsBase::ptr_t mTarget; + LLSettingsBase::ptr_t mInitial; + LLSettingsBase::ptr_t mFinal; + F32Seconds mSeconds; + finish_signal_t mOnFinished; + F32Seconds mBlendThreshold; + F32Seconds mLastUpdate; + F32Seconds mTimeSpent; + F32Seconds mTimeStart; +}; + +#endif diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp new file mode 100644 index 0000000000..687210e127 --- /dev/null +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -0,0 +1,545 @@ +/** +* @file llsettingsdaycycle.cpp +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llsettingsdaycycle.h" +#include +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +#include "llsettingssky.h" +#include "llsettingswater.h" + +#include "llframetimer.h" +//========================================================================= +namespace +{ + LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); + LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); + + inline F32 get_wrapping_distance(F32 begin, F32 end) + { + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); + + if (it == collection.end()) + { // wrap around + it = collection.begin(); + } + + return it; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); + + if (it == collection.end()) + { // all keyframes are lower, take the last one. + --it; // we know the range is not empty + } + else if ((*it).first > key) + { // the keyframe we are interested in is smaller than the found. + if (it == collection.begin()) + it = collection.end(); + --it; + } + + return it; + } + + +} + +//========================================================================= +const std::string LLSettingsDay::SETTING_DAYLENGTH("day_length"); +const std::string LLSettingsDay::SETTING_KEYID("key_id"); +const std::string LLSettingsDay::SETTING_KEYNAME("key_name"); +const std::string LLSettingsDay::SETTING_KEYKFRAME("key_keyframe"); +const std::string LLSettingsDay::SETTING_KEYHASH("key_hash"); +const std::string LLSettingsDay::SETTING_TRACKS("tracks"); +const std::string LLSettingsDay::SETTING_FRAMES("frames"); + +const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins + +//const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days + +const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 +const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water +const S32 LLSettingsDay::FRAME_MAX(56); + +//========================================================================= +LLSettingsDay::LLSettingsDay(const LLSD &data) : + LLSettingsBase(data), + mInitialized(false) +{ + mDayTracks.resize(TRACK_MAX); +} + +LLSettingsDay::LLSettingsDay() : + LLSettingsBase(), + mInitialized(false) +{ + mDayTracks.resize(TRACK_MAX); +} + +//========================================================================= +LLSD LLSettingsDay::getSettings() const +{ + LLSD settings(LLSD::emptyMap()); + + if (mSettings.has(SETTING_NAME)) + settings[SETTING_NAME] = mSettings[SETTING_NAME]; + + if (mSettings.has(SETTING_ID)) + settings[SETTING_ID] = mSettings[SETTING_ID]; + + std::map in_use; + + LLSD tracks(LLSD::emptyArray()); + + for (CycleList_t::const_iterator itTrack = mDayTracks.begin(); itTrack != mDayTracks.end(); ++itTrack) + { + LLSD trackout(LLSD::emptyArray()); + + for (CycleTrack_t::const_iterator itFrame = (*itTrack).begin(); itFrame != (*itTrack).end(); ++itFrame) + { + F32 frame = (*itFrame).first; + LLSettingsBase::ptr_t data = (*itFrame).second; + size_t datahash = data->getHash(); + + std::stringstream keyname; + keyname << datahash; + + trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame))(SETTING_KEYNAME, keyname.str()))); + in_use[keyname.str()] = data; + } + tracks.append(trackout); + } + settings[SETTING_TRACKS] = tracks; + + LLSD frames(LLSD::emptyMap()); + for (std::map::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) + { + LLSD framesettings = llsd_clone((*itFrame).second->getSettings(), + LLSDMap("*", true)(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)); + + frames[(*itFrame).first] = framesettings; + } + settings[SETTING_FRAMES] = frames; + + return settings; +} + +void LLSettingsDay::initialize() +{ + LLSD tracks = mSettings[SETTING_TRACKS]; + LLSD frames = mSettings[SETTING_FRAMES]; + + std::map used; + + for (LLSD::map_const_iterator itFrame = frames.beginMap(); itFrame != frames.endMap(); ++itFrame) + { + std::string name = (*itFrame).first; + LLSD data = (*itFrame).second; + + if (data[SETTING_TYPE].asString() == "sky") + { + used[name] = buildSky(data); + } + else if (data[SETTING_TYPE].asString() == "water") + { + used[name] = buildWater(data); + } + else + { + LL_WARNS("DAYCYCLE") << "Unknown child setting type '" << data[SETTING_TYPE].asString() << "' named '" << name << "'" << LL_ENDL; + } + } + + for (S32 i = 0; (i < tracks.size()) && (i < TRACK_MAX); ++i) + { + mDayTracks[i].clear(); + LLSD curtrack = tracks[i]; + for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) + { + F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); + keyframe = llclamp(keyframe, 0.0f, 1.0f); + LLSettingsBase::ptr_t setting; + + if ((*it).has(SETTING_KEYNAME)) + { + if (i == TRACK_WATER) + { + setting = used[(*it)[SETTING_KEYNAME]]; + if (!setting) + setting = getNamedWater((*it)[SETTING_KEYNAME]); + if (setting && setting->getSettingType() != "water") + { + LL_WARNS("DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + setting.reset(); + } + } + else + { + setting = used[(*it)[SETTING_KEYNAME]]; + if (!setting) + setting = getNamedSky((*it)[SETTING_KEYNAME]); + if (setting && setting->getSettingType() != "sky") + { + LL_WARNS("DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + setting.reset(); + } + } + } + + if (setting) + mDayTracks[i][keyframe] = setting; + } + } + + // these are no longer needed and just take up space now. + mSettings.erase(SETTING_TRACKS); + mSettings.erase(SETTING_FRAMES); + + mInitialized = true; +} + + +//========================================================================= +LLSD LLSettingsDay::defaults() +{ + LLSD dfltsetting; + + dfltsetting[SETTING_NAME] = "_default_"; + dfltsetting[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); + dfltsetting[SETTING_TRACKS] = LLSDArray( + LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) + (LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); + dfltsetting[SETTING_FRAMES] = LLSD::emptyMap(); + + return dfltsetting; +} + +void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F32 mix) +{ + LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; +} + +namespace +{ + bool validateDayCycleTrack(LLSD &value) + { + // Trim extra tracks. + while (value.size() > LLSettingsDay::TRACK_MAX) + { + value.erase(value.size() - 1); + } + + for (LLSD::array_iterator track = value.beginArray(); track != value.endArray(); ++track) + { + S32 index = 0; + while (index < (*track).size()) + { + if (index >= LLSettingsDay::FRAME_MAX) + { + (*track).erase(index); + continue; + } + + if (!(*track)[index].has(LLSettingsDay::SETTING_KEYKFRAME) || + !(*track)[index][LLSettingsDay::SETTING_KEYKFRAME].isReal()) + { + (*track).erase(index); + continue; + } + + if (!(*track)[index].has(LLSettingsDay::SETTING_KEYNAME) && + !(*track)[index].has(LLSettingsDay::SETTING_KEYID)) + { + (*track).erase(index); + continue; + } + + F32 frame = (*track)[index][LLSettingsDay::SETTING_KEYKFRAME].asReal(); + if ((frame < 0.0) || (frame > 1.0)) + { + frame = llclamp(frame, 0.0f, 1.0f); + (*track)[index][LLSettingsDay::SETTING_KEYKFRAME] = frame; + } + ++index; + } + + } + return true; + } +} + +LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const +{ + static validation_list_t validation; + + if (validation.empty()) + { + validation.push_back(Validator(SETTING_TRACKS, false, LLSD::TypeArray, + &validateDayCycleTrack)); + validation.push_back(Validator(SETTING_FRAMES, false, LLSD::TypeMap)); + validation.push_back(Validator(SETTING_DAYLENGTH, false, LLSD::TypeInteger, + boost::bind(&Validator::verifyIntegerRange, _1, + LLSD(LLSDArray(LLSD::Integer(MINIMUM_DAYLENGTH))(LLSD::Integer(MAXIMUM_DAYLENGTH)))))); + } + + return validation; +} + +//========================================================================= +F32 LLSettingsDay::secondsToKeyframe(S64Seconds seconds) +{ + S64Seconds daylength = getDayLength(); + + return llclamp(static_cast(seconds.value() % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); +} + +F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe) +{ + S64Seconds daylength = getDayLength(); + + return F64Seconds(static_cast(keyframe * static_cast(daylength.value()))); +} + +//========================================================================= +void LLSettingsDay::startDayCycle() +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + + if (!mInitialized) + { + LL_WARNS("DAYCYCLE") << "Attempt to start day cycle on uninitialized object." << LL_ENDL; + return; + } + + // water + if (mDayTracks[0].empty()) + { + mBlendedWater.reset(); + mWaterBlender.reset(); + } + else if (mDayTracks[0].size() == 1) + { + mBlendedWater = boost::static_pointer_cast((*(mDayTracks[0].begin())).second); + mWaterBlender.reset(); + } + else + { + TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); + + F64Seconds timespan = F64Seconds( getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); + + mBlendedWater = getDefaultWater(); + mWaterBlender = boost::make_shared(mBlendedWater, + (*bounds.first).second, (*bounds.second).second, timespan); + mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); + } + + // sky + if (mDayTracks[1].empty()) + { + mBlendedSky.reset(); + mSkyBlender.reset(); + } + else if (mDayTracks[1].size() == 1) + { + mBlendedSky = boost::static_pointer_cast( (*(mDayTracks[1].begin())).second); + mSkyBlender.reset(); + } + else + { + TrackBound_t bounds = getBoundingEntries(mDayTracks[1], now); + F64Seconds timespan = F64Seconds(getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); + + mBlendedSky = getDefaultSky(); + mSkyBlender = boost::make_shared(mBlendedSky, + (*bounds.first).second, (*bounds.second).second, timespan); + mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, 1, _1)); + } +} + + +void LLSettingsDay::updateSettings() +{ + static LLFrameTimer timer; + + + F64Seconds delta(timer.getElapsedTimeAndResetF32()); + + if (mSkyBlender) + mSkyBlender->update(delta); + if (mWaterBlender) + mWaterBlender->update(delta); +} + +//========================================================================= +void LLSettingsDay::setDayLength(S64Seconds seconds) +{ + S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); + + setValue(SETTING_DAYLENGTH, val); +} + +LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) +{ + if ((trackno < 1) || (trackno >= TRACK_MAX)) + { + LL_WARNS("DAYCYCLE") << "Attempt get track (#" << trackno << ") out of range!" << LL_ENDL; + return KeyframeList_t(); + } + + KeyframeList_t keyframes; + CycleTrack_t &track = mDayTracks[trackno]; + + keyframes.reserve(track.size()); + + for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) + { + keyframes.push_back((*it).first); + } + + return keyframes; +} + +LLSettingsDay::TimeList_t LLSettingsDay::getTrackTimes(S32 trackno) +{ + KeyframeList_t keyframes = getTrackKeyframes(trackno); + + if (keyframes.empty()) + return TimeList_t(); + + TimeList_t times; + + times.reserve(keyframes.size()); + for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it) + { + times.push_back(keyframeToSeconds(*it)); + } + + return times; +} + +void LLSettingsDay::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) +{ + F32 keyframe = secondsToKeyframe(seconds); + setWaterAtKeyframe(water, keyframe); +} + +void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) +{ + mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; + setDirtyFlag(true); +} + + +void LLSettingsDay::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) +{ + F32 keyframe = secondsToKeyframe(seconds); + setSkyAtKeyframe(sky, keyframe, track); +} + +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) +{ + if ((track < 1) || (track >= TRACK_MAX)) + { + LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; + return; + } + + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = sky; + setDirtyFlag(true); +} + +LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) +{ + return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); +} + +LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F64Seconds time) +{ + F32 frame = secondsToKeyframe(time); + + return getBoundingEntries(track, frame); +} + +//========================================================================= +void LLSettingsDay::onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender) +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + TrackBound_t bounds = getBoundingEntries(mDayTracks[track], now); + + F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + F64Seconds timespan = F64Seconds(distance * getDayLength()); + + LL_DEBUGS("DAYCYCLE") << "New sky blender. now=" << now << + " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << + " span=" << timespan << LL_ENDL; + + mSkyBlender = boost::make_shared(mBlendedSky, + (*bounds.first).second, (*bounds.second).second, timespan); + mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, track, _1)); +} + +void LLSettingsDay::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); + + F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + F64Seconds timespan = F64Seconds(distance * getDayLength()); + + mWaterBlender = boost::make_shared(mBlendedWater, + (*bounds.first).second, (*bounds.second).second, timespan); + mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); +} diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h new file mode 100644 index 0000000000..3b24ce9f97 --- /dev/null +++ b/indra/llinventory/llsettingsdaycycle.h @@ -0,0 +1,156 @@ +/** +* @file llsettingsdaycycle.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_DAYCYCLE_H +#define LL_SETTINGS_DAYCYCLE_H + +#include "llsettingsbase.h" + +class LLSettingsWater; +class LLSettingsSky; + +typedef boost::shared_ptr LLSettingsWaterPtr_t; +typedef boost::shared_ptr LLSettingsSkyPtr_t; + +class LLSettingsDay : public LLSettingsBase +{ +public: + static const std::string SETTING_DAYLENGTH; + static const std::string SETTING_KEYID; + static const std::string SETTING_KEYNAME; + static const std::string SETTING_KEYKFRAME; + static const std::string SETTING_KEYHASH; + static const std::string SETTING_TRACKS; + static const std::string SETTING_FRAMES; + + static const S64 MINIMUM_DAYLENGTH; + static const S64 MAXIMUM_DAYLENGTH; + + static const S32 TRACK_WATER; + static const S32 TRACK_MAX; + static const S32 FRAME_MAX; + + typedef std::map CycleTrack_t; + typedef std::vector CycleList_t; + typedef boost::shared_ptr ptr_t; + typedef std::vector TimeList_t; + typedef std::vector KeyframeList_t; + typedef std::pair TrackBound_t; + + //--------------------------------------------------------------------- + LLSettingsDay(const LLSD &data); + virtual ~LLSettingsDay() { }; + + void initialize(); + + virtual ptr_t buildClone() = 0; + virtual LLSD getSettings() const; + + //--------------------------------------------------------------------- + virtual std::string getSettingType() const { return std::string("daycycle"); } + + // Settings status + virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix); + + static LLSD defaults(); + + //--------------------------------------------------------------------- + S64Seconds getDayLength() const + { + return S64Seconds(mSettings[SETTING_DAYLENGTH].asInteger()); + } + + void setDayLength(S64Seconds seconds); + + KeyframeList_t getTrackKeyframes(S32 track); + TimeList_t getTrackTimes(S32 track); + + void setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds); + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); + + void setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track); + void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track); + //--------------------------------------------------------------------- + void startDayCycle(); + + LLSettingsSkyPtr_t getCurrentSky() const + { + return mBlendedSky; + } + + LLSettingsWaterPtr_t getCurrentWater() const + { + return mBlendedWater; + } + + virtual LLSettingsSkyPtr_t getDefaultSky() const = 0; + virtual LLSettingsWaterPtr_t getDefaultWater() const = 0; + + virtual LLSettingsSkyPtr_t buildSky(LLSD) const = 0; + virtual LLSettingsWaterPtr_t buildWater(LLSD) const = 0; + + virtual LLSettingsSkyPtr_t getNamedSky(const std::string &) const = 0; + virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const = 0; + + void setInitialized(bool value = true) { mInitialized = value; } +protected: + LLSettingsDay(); + + virtual void updateSettings(); + + virtual validation_list_t getValidationList() const; + + bool mInitialized; + +private: + LLSettingsBlender::ptr_t mSkyBlender; // convert to [] for altitudes + LLSettingsBlender::ptr_t mWaterBlender; + + LLSettingsSkyPtr_t mBlendedSky; + LLSettingsWaterPtr_t mBlendedWater; + + CycleList_t mDayTracks; + + F64Seconds mLastUpdateTime; + + F32 secondsToKeyframe(S64Seconds seconds); + F64Seconds keyframeToSeconds(F32 keyframe); + + void parseFromLLSD(LLSD &data); + + static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); + static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); + + TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + TrackBound_t getBoundingEntries(CycleTrack_t &track, F64Seconds time); + + void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender); + void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); + +}; + +#endif diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp new file mode 100644 index 0000000000..ecc89165e8 --- /dev/null +++ b/indra/llinventory/llsettingssky.cpp @@ -0,0 +1,561 @@ +/** +* @file llsettingssky.cpp +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llsettingssky.h" +#include "indra_constants.h" +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +//========================================================================= +namespace +{ + const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0); + const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); + const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); + + LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); + LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); + + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); + void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); +} + +const F32 LLSettingsSky::DOME_OFFSET(0.96f); +const F32 LLSettingsSky::DOME_RADIUS(15000.f); + +const F32 LLSettingsSky::NIGHTTIME_ELEVATION(-8.0f); // degrees +const F32 LLSettingsSky::NIGHTTIME_ELEVATION_COS((F32)sin(NIGHTTIME_ELEVATION*DEG_TO_RAD)); + +//========================================================================= +const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); +const std::string LLSettingsSky::SETTING_BLOOM_TEXTUREID("bloom_id"); +const std::string LLSettingsSky::SETTING_BLUE_DENSITY("blue_density"); +const std::string LLSettingsSky::SETTING_BLUE_HORIZON("blue_horizon"); +const std::string LLSettingsSky::SETTING_CLOUD_COLOR("cloud_color"); +const std::string LLSettingsSky::SETTING_CLOUD_POS_DENSITY1("cloud_pos_density1"); +const std::string LLSettingsSky::SETTING_CLOUD_POS_DENSITY2("cloud_pos_density2"); +const std::string LLSettingsSky::SETTING_CLOUD_SCALE("cloud_scale"); +const std::string LLSettingsSky::SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate"); +const std::string LLSettingsSky::SETTING_CLOUD_SHADOW("cloud_shadow"); +const std::string LLSettingsSky::SETTING_CLOUD_TEXTUREID("cloud_id"); +const std::string LLSettingsSky::SETTING_DENSITY_MULTIPLIER("density_multiplier"); +const std::string LLSettingsSky::SETTING_DISTANCE_MULTIPLIER("distance_multiplier"); +const std::string LLSettingsSky::SETTING_DOME_OFFSET("dome_offset"); +const std::string LLSettingsSky::SETTING_DOME_RADIUS("dome_radius"); +const std::string LLSettingsSky::SETTING_GAMMA("gamma"); +const std::string LLSettingsSky::SETTING_GLOW("glow"); +const std::string LLSettingsSky::SETTING_HAZE_DENSITY("haze_density"); +const std::string LLSettingsSky::SETTING_HAZE_HORIZON("haze_horizon"); +const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); +const std::string LLSettingsSky::SETTING_MAX_Y("max_y"); +const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation"); +const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id"); +const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); +const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); +const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); +const std::string LLSettingsSky::SETTING_SUN_TEXUTUREID("sun_id"); + +const std::string LLSettingsSky::SETTING_LEGACY_EAST_ANGLE("east_angle"); +const std::string LLSettingsSky::SETTING_LEGACY_ENABLE_CLOUD_SCROLL("enable_cloud_scroll"); +const std::string LLSettingsSky::SETTING_LEGACY_SUN_ANGLE("sun_angle"); + +//========================================================================= +LLSettingsSky::LLSettingsSky(const LLSD &data) : + LLSettingsBase(data) +{ +} + +LLSettingsSky::LLSettingsSky(): + LLSettingsBase() +{ +} + +void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +{ + LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + + replaceSettings(blenddata); +} + + +void LLSettingsSky::setMoonRotation(F32 azimuth, F32 altitude) +{ + setValue(SETTING_MOON_ROTATION, ::body_position_from_angles(azimuth, altitude)); +} + +LLSettingsSky::azimalt_t LLSettingsSky::getMoonRotationAzAl() const +{ + azimalt_t res; + ::angles_from_rotation(getMoonRotation(), res.first, res.second); + + return res; +} + +void LLSettingsSky::setSunRotation(F32 azimuth, F32 altitude) +{ + setValue(SETTING_SUN_ROTATION, ::body_position_from_angles(azimuth, altitude)); +} + +LLSettingsSky::azimalt_t LLSettingsSky::getSunRotationAzAl() const +{ + azimalt_t res; + ::angles_from_rotation(getSunRotation(), res.first, res.second); + + return res; +} + +LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const +{ + static stringset_t slepSet; + + if (slepSet.empty()) + { + slepSet.insert(SETTING_SUN_ROTATION); + slepSet.insert(SETTING_MOON_ROTATION); + } + + return slepSet; +} + +LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const +{ + static validation_list_t validation; + + if (validation.empty()) + { // Note the use of LLSD(LLSDArray()()()...) This is due to an issue with the + // copy constructor for LLSDArray. Directly binding the LLSDArray as + // a parameter without first wrapping it in a pure LLSD object will result + // in deeply nested arrays like this [[[[[[[[[[v1,v2,v3]]]]]]]]]] + + validation.push_back(Validator(SETTING_AMBIENT, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*"))))); + validation.push_back(Validator(SETTING_BLOOM_TEXTUREID, true, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_BLUE_DENSITY, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*"))))); + validation.push_back(Validator(SETTING_BLUE_HORIZON, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_COLOR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(1.0f)(1.0f)(1.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_POS_DENSITY1, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(1.68841f)(1.0f)(1.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_POS_DENSITY2, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(1.68841f)(1.0f)(1.0f)("*"))))); + validation.push_back(Validator(SETTING_CLOUD_SCALE, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.001f)(0.999f))))); + validation.push_back(Validator(SETTING_CLOUD_SCROLL_RATE, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)), + LLSD(LLSDArray(20.0f)(20.0f))))); + validation.push_back(Validator(SETTING_CLOUD_SHADOW, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_CLOUD_TEXTUREID, false, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f))))); + validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f))))); + validation.push_back(Validator(SETTING_DOME_OFFSET, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_DOME_RADIUS, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1000.0f)(2000.0f))))); + validation.push_back(Validator(SETTING_GAMMA, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(10.0f))))); + validation.push_back(Validator(SETTING_GLOW, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.2f)("*")(-2.5f)("*")), + LLSD(LLSDArray(20.0f)("*")(0.0f)("*"))))); + validation.push_back(Validator(SETTING_HAZE_DENSITY, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f))))); + validation.push_back(Validator(SETTING_HAZE_HORIZON, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_LIGHT_NORMAL, false, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorNormalized, _1, 3))); + validation.push_back(Validator(SETTING_MAX_Y, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4000.0f))))); + validation.push_back(Validator(SETTING_MOON_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); + validation.push_back(Validator(SETTING_MOON_TEXTUREID, false, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_STAR_BRIGHTNESS, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(2.0f))))); + validation.push_back(Validator(SETTING_SUNLIGHT_COLOR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), + LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*"))))); + validation.push_back(Validator(SETTING_SUN_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); + validation.push_back(Validator(SETTING_SUN_TEXUTUREID, false, LLSD::TypeUUID)); + } + + return validation; +} + + +LLSD LLSettingsSky::defaults() +{ + LLSD dfltsetting; + + + LLQuaternion sunquat; + sunquat.setEulerAngles(1.39626, 0.0, 0.0); // 80deg Azumith/0deg East + LLQuaternion moonquat = ~sunquat; + + // Magic constants copied form dfltsetting.xml + dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue(); + dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 0.0).getValue(); + dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); + dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); + dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699); + dfltsetting[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(0.0001); + dfltsetting[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(0.8000); + dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); + dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); + dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); + dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); + dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999); + dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899); + dfltsetting[SETTING_LIGHT_NORMAL] = LLVector3(0.0000, 0.9126, -0.4086).getValue(); + dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); + dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); + dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); + dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); + dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); + + dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow! + dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID; + + return dfltsetting; +} + +LLSD LLSettingsSky::translateLegacySettings(LLSD legacy) +{ + LLSD newsettings(defaults()); + + if (legacy.has(SETTING_AMBIENT)) + { + newsettings[SETTING_AMBIENT] = LLColor3(legacy[SETTING_AMBIENT]).getValue(); + } + if (legacy.has(SETTING_BLUE_DENSITY)) + { + newsettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue(); + } + if (legacy.has(SETTING_BLUE_HORIZON)) + { + newsettings[SETTING_BLUE_HORIZON] = LLColor3(legacy[SETTING_BLUE_HORIZON]).getValue(); + } + if (legacy.has(SETTING_CLOUD_COLOR)) + { + newsettings[SETTING_CLOUD_COLOR] = LLColor3(legacy[SETTING_CLOUD_COLOR]).getValue(); + } + if (legacy.has(SETTING_CLOUD_POS_DENSITY1)) + { + newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor3(legacy[SETTING_CLOUD_POS_DENSITY1]).getValue(); + } + if (legacy.has(SETTING_CLOUD_POS_DENSITY2)) + { + newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor3(legacy[SETTING_CLOUD_POS_DENSITY2]).getValue(); + } + if (legacy.has(SETTING_CLOUD_SCALE)) + { + newsettings[SETTING_CLOUD_SCALE] = LLSD::Real(legacy[SETTING_CLOUD_SCALE][0].asReal()); + } + if (legacy.has(SETTING_CLOUD_SCROLL_RATE)) + { + LLVector2 cloud_scroll(legacy[SETTING_CLOUD_SCROLL_RATE]); + + if (legacy.has(SETTING_LEGACY_ENABLE_CLOUD_SCROLL)) + { + LLSD enabled = legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL]; + if (!enabled[0].asBoolean()) + cloud_scroll.mV[0] = 0.0f; + if (!enabled[1].asBoolean()) + cloud_scroll.mV[1] = 0.0f; + } + + newsettings[SETTING_CLOUD_SCROLL_RATE] = cloud_scroll.getValue(); + } + if (legacy.has(SETTING_CLOUD_SHADOW)) + { + newsettings[SETTING_CLOUD_SHADOW] = LLSD::Real(legacy[SETTING_CLOUD_SHADOW][0].asReal()); + } + if (legacy.has(SETTING_DENSITY_MULTIPLIER)) + { + newsettings[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(legacy[SETTING_DENSITY_MULTIPLIER][0].asReal()); + } + if (legacy.has(SETTING_DISTANCE_MULTIPLIER)) + { + newsettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(legacy[SETTING_DISTANCE_MULTIPLIER][0].asReal()); + } + if (legacy.has(SETTING_GAMMA)) + { + newsettings[SETTING_GAMMA] = legacy[SETTING_GAMMA][0].asReal(); + } + if (legacy.has(SETTING_GLOW)) + { + newsettings[SETTING_GLOW] = LLColor3(legacy[SETTING_GLOW]).getValue(); + } + if (legacy.has(SETTING_HAZE_DENSITY)) + { + newsettings[SETTING_HAZE_DENSITY] = LLSD::Real(legacy[SETTING_HAZE_DENSITY][0].asReal()); + } + if (legacy.has(SETTING_HAZE_HORIZON)) + { + newsettings[SETTING_HAZE_HORIZON] = LLSD::Real(legacy[SETTING_HAZE_HORIZON][0].asReal()); + } + if (legacy.has(SETTING_LIGHT_NORMAL)) + { + newsettings[SETTING_LIGHT_NORMAL] = LLVector3(legacy[SETTING_LIGHT_NORMAL]).getValue(); + } + if (legacy.has(SETTING_MAX_Y)) + { + newsettings[SETTING_MAX_Y] = LLSD::Real(legacy[SETTING_MAX_Y][0].asReal()); + } + if (legacy.has(SETTING_STAR_BRIGHTNESS)) + { + newsettings[SETTING_STAR_BRIGHTNESS] = LLSD::Real(legacy[SETTING_STAR_BRIGHTNESS].asReal()); + } + if (legacy.has(SETTING_SUNLIGHT_COLOR)) + { + newsettings[SETTING_SUNLIGHT_COLOR] = LLColor4(legacy[SETTING_SUNLIGHT_COLOR]).getValue(); + } + + if (legacy.has(SETTING_LEGACY_EAST_ANGLE) && legacy.has(SETTING_LEGACY_SUN_ANGLE)) + { // convert the east and sun angles into a quaternion. + F32 azimuth = legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); + F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); + + LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude); + LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude); + + F32 az(0), al(0); + ::angles_from_rotation(sunquat, az, al); + + newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); + newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); + } + + return newsettings; +} + +void LLSettingsSky::updateSettings() +{ + LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); + //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; + + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + calculateHeavnlyBodyPositions(); + calculateLightSettings(); +} + +void LLSettingsSky::calculateHeavnlyBodyPositions() +{ + mSunDirection = DUE_EAST * getSunRotation(); + mSunDirection.normalize(); + mMoonDirection = DUE_EAST * getMoonRotation(); + mMoonDirection.normalize(); + + // is the normal from the sun or the moon + if (mSunDirection.mV[1] >= 0.0) + { + mLightDirection = mSunDirection; + } + else if (mSunDirection.mV[1] < 0.0 && mSunDirection.mV[1] > NIGHTTIME_ELEVATION_COS) + { + // clamp v1 to 0 so sun never points up and causes weirdness on some machines + LLVector3 vec(mSunDirection); + vec.mV[1] = 0.0; + vec.normalize(); + mLightDirection = vec; + } + else + { + mLightDirection = mMoonDirection; + } + + // calculate the clamp lightnorm for sky (to prevent ugly banding in sky + // when haze goes below the horizon + mClampedLightDirection = mLightDirection; + + if (mClampedLightDirection.mV[1] < -0.1f) + { + mClampedLightDirection.mV[1] = -0.1f; + mClampedLightDirection.normalize(); + } +} + +void LLSettingsSky::calculateLightSettings() +{ + LLColor3 vary_HazeColor; + LLColor3 vary_SunlightColor; + LLColor3 vary_AmbientColor; + { + // Initialize temp variables + LLColor3 sunlight = getSunlightColor(); + LLColor3 ambient = getAmbientColor(); + F32 gamma = getGamma(); + LLColor3 blue_density = getBlueDensity(); + LLColor3 blue_horizon = getBlueHorizon(); + F32 haze_density = getHazeDensity(); + F32 haze_horizon = getHazeHorizon(); + F32 density_multiplier = getDensityMultiplier(); + F32 max_y = getMaxY(); + F32 cloud_shadow = getCloudShadow(); + LLVector3 lightnorm = getLightDirection(); + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + LLColor3 light_atten = + (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); + + // Calculate relative weights + LLColor3 temp2(0.f, 0.f, 0.f); + LLColor3 temp1 = blue_density + smear(haze_density); + LLColor3 blue_weight = componentDiv(blue_density, temp1); + LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); + + // Compute sunlight from P & lightnorm (for long rays like sky) + /// USE only lightnorm. + // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + + // and vary_sunlight will work properly with moon light + F32 lighty = lightnorm[1]; + if (lighty < NIGHTTIME_ELEVATION_COS) + { + lighty = -lighty; + } + + temp2.mV[1] = llmax(0.f, lighty); + if(temp2.mV[1] > 0.f) + { + temp2.mV[1] = 1.f / temp2.mV[1]; + } + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Distance + temp2.mV[2] = density_multiplier; + + // Transparency (-> temp1) + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); + + // vary_AtmosAttenuation = temp1; + + //increase ambient when there are more clouds + LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; + + //haze color + vary_HazeColor = + (blue_horizon * blue_weight * (sunlight*(1.f - cloud_shadow) + tmpAmbient) + + componentMult(haze_horizon * haze_weight, sunlight*(1.f - cloud_shadow) * temp2.mV[0] + tmpAmbient) + ); + + //brightness of surface both sunlight and ambient + vary_SunlightColor = componentMult(sunlight, temp1) * 1.f; + vary_SunlightColor.clamp(); + vary_SunlightColor = smear(1.0f) - vary_SunlightColor; + vary_SunlightColor = componentPow(vary_SunlightColor, gamma); + vary_SunlightColor = smear(1.0f) - vary_SunlightColor; + vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5; + vary_AmbientColor.clamp(); + vary_AmbientColor = smear(1.0f) - vary_AmbientColor; + vary_AmbientColor = componentPow(vary_AmbientColor, gamma); + vary_AmbientColor = smear(1.0f) - vary_AmbientColor; + + componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1); + + } + + mSunDiffuse = vary_SunlightColor; + mSunAmbient = vary_AmbientColor; + mMoonDiffuse = vary_SunlightColor; + mMoonAmbient = vary_AmbientColor; + + mTotalAmbient = LLColor4(vary_AmbientColor, 1.0f); + + mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; + mFadeColor.setAlpha(0); +} + + +//========================================================================= +namespace +{ + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) + { + // Azimuth is traditionally calculated from North, we are going from East. + LLQuaternion rot_azi; + LLQuaternion rot_alt; + + rot_azi.setAngleAxis(azimuth, VECT_ZENITH); + rot_alt.setAngleAxis(-altitude, VECT_NORTHSOUTH); + + LLQuaternion body_quat = rot_alt * rot_azi; + body_quat.normalize(); + + //LLVector3 sun_vector = (DUE_EAST * body_quat); + //_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL; + return body_quat; + } + + void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude) + { + LLVector3 body_vector = (DUE_EAST * quat); + + LLVector3 body_az(body_vector[0], 0.f, body_vector[2]); + LLVector3 body_al(0.f, body_vector[1], body_vector[2]); + + if (fabs(body_az.normalize()) > 0.001) + azimuth = angle_between(DUE_EAST, body_az); + else + azimuth = 0.0f; + + if (fabs(body_al.normalize()) > 0.001) + altitude = angle_between(DUE_EAST, body_al); + else + altitude = 0.0f; + } +} + + diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h new file mode 100644 index 0000000000..ff4b62f86e --- /dev/null +++ b/indra/llinventory/llsettingssky.h @@ -0,0 +1,455 @@ +/** +* @file llsettingssky.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_SKY_H +#define LL_SETTINGS_SKY_H + +#include "llsettingsbase.h" +#include "v4coloru.h" + +class LLSettingsSky: public LLSettingsBase +{ +public: + static const std::string SETTING_AMBIENT; + static const std::string SETTING_BLOOM_TEXTUREID; + static const std::string SETTING_BLUE_DENSITY; + static const std::string SETTING_BLUE_HORIZON; + static const std::string SETTING_CLOUD_COLOR; + static const std::string SETTING_CLOUD_POS_DENSITY1; + static const std::string SETTING_CLOUD_POS_DENSITY2; + static const std::string SETTING_CLOUD_SCALE; + static const std::string SETTING_CLOUD_SCROLL_RATE; + static const std::string SETTING_CLOUD_SHADOW; + static const std::string SETTING_CLOUD_TEXTUREID; + static const std::string SETTING_DENSITY_MULTIPLIER; + static const std::string SETTING_DISTANCE_MULTIPLIER; + static const std::string SETTING_DOME_OFFSET; + static const std::string SETTING_DOME_RADIUS; + static const std::string SETTING_GAMMA; + static const std::string SETTING_GLOW; + static const std::string SETTING_HAZE_DENSITY; + static const std::string SETTING_HAZE_HORIZON; + static const std::string SETTING_LIGHT_NORMAL; + 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_STAR_BRIGHTNESS; + static const std::string SETTING_SUNLIGHT_COLOR; + static const std::string SETTING_SUN_ROTATION; + static const std::string SETTING_SUN_TEXUTUREID; + + typedef boost::shared_ptr ptr_t; + typedef std::pair azimalt_t; + + //--------------------------------------------------------------------- + LLSettingsSky(const LLSD &data); + virtual ~LLSettingsSky() { }; + + virtual ptr_t buildClone() = 0; + + //--------------------------------------------------------------------- + virtual std::string getSettingType() const { return std::string("sky"); } + + // Settings status + virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); + + static LLSD defaults(); + + //--------------------------------------------------------------------- + LLColor3 getAmbientColor() const + { + return LLColor3(mSettings[SETTING_AMBIENT]); + } + + void setAmbientColor(const LLColor3 &val) + { + setValue(SETTING_AMBIENT, val); + } + + LLUUID getBloomTextureId() const + { + return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); + } + + LLColor3 getBlueDensity() const + { + return LLColor3(mSettings[SETTING_BLUE_DENSITY]); + } + + void setBlueDensity(const LLColor3 &val) + { + setValue(SETTING_BLUE_DENSITY, val); + } + + LLColor3 getBlueHorizon() const + { + return LLColor3(mSettings[SETTING_BLUE_HORIZON]); + } + + void setBlueHorizon(const LLColor3 &val) + { + setValue(SETTING_BLUE_HORIZON, val); + } + + LLColor3 getCloudColor() const + { + return LLColor3(mSettings[SETTING_CLOUD_COLOR]); + } + + void setCloudColor(const LLColor3 &val) + { + setValue(SETTING_CLOUD_COLOR, val); + } + + LLUUID getCloudNoiseTextureId() const + { + return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); + } + + LLColor3 getCloudPosDensity1() const + { + return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); + } + + void setCloudPosDensity1(const LLColor3 &val) + { + setValue(SETTING_CLOUD_POS_DENSITY1, val); + } + + LLColor3 getCloudPosDensity2() const + { + return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); + } + + void setCloudPosDensity2(const LLColor3 &val) + { + setValue(SETTING_CLOUD_POS_DENSITY2, val); + } + + F32 getCloudScale() const + { + return mSettings[SETTING_CLOUD_SCALE].asReal(); + } + + void setCloudScale(F32 val) + { + setValue(SETTING_CLOUD_SCALE, val); + } + + LLVector2 getCloudScrollRate() const + { + return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); + } + + void setCloudScrollRate(const LLVector2 &val) + { + setValue(SETTING_CLOUD_SCROLL_RATE, val); + } + + void setCloudScrollRateX(F32 val) + { + mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; + setDirtyFlag(true); + } + + void setCloudScrollRateY(F32 val) + { + mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; + setDirtyFlag(true); + } + + F32 getCloudShadow() const + { + return mSettings[SETTING_CLOUD_SHADOW].asReal(); + } + + void setCloudShadow(F32 val) + { + setValue(SETTING_CLOUD_SHADOW, val); + } + + F32 getDensityMultiplier() const + { + return mSettings[SETTING_DENSITY_MULTIPLIER].asReal(); + } + + void setDensityMultiplier(F32 val) + { + setValue(SETTING_DENSITY_MULTIPLIER, val); + } + + F32 getDistanceMultiplier() const + { + return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal(); + } + + void setDistanceMultiplier(F32 val) + { + setValue(SETTING_DISTANCE_MULTIPLIER, val); + } + + F32 getDomeOffset() const + { + return DOME_OFFSET; + //return mSettings[SETTING_DOME_OFFSET].asReal(); + } + + F32 getDomeRadius() const + { + return DOME_RADIUS; + //return mSettings[SETTING_DOME_RADIUS].asReal(); + } + + F32 getGamma() const + { + return mSettings[SETTING_GAMMA].asReal(); + } + + void setGamma(F32 val) + { + mSettings[SETTING_GAMMA] = LLSD::Real(val); + setDirtyFlag(true); + } + + LLColor3 getGlow() const + { + return LLColor3(mSettings[SETTING_GLOW]); + } + + void setGlow(const LLColor3 &val) + { + setValue(SETTING_GLOW, val); + } + + F32 getHazeDensity() const + { + return mSettings[SETTING_HAZE_DENSITY].asReal(); + } + + void setHazeDensity(F32 val) + { + setValue(SETTING_HAZE_DENSITY, val); + } + + F32 getHazeHorizon() const + { + return mSettings[SETTING_HAZE_HORIZON].asReal(); + } + + void setHazeHorizon(F32 val) + { + setValue(SETTING_HAZE_HORIZON, val); + } + + LLVector3 getLightNormal() const + { + return LLVector3(mSettings[SETTING_LIGHT_NORMAL]); + } + + void setLightNormal(const LLVector3 &val) + { + setValue(SETTING_LIGHT_NORMAL, val); + } + + F32 getMaxY() const + { + return mSettings[SETTING_MAX_Y].asReal(); + } + + LLQuaternion getMoonRotation() const + { + return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); + } + + void setMoonRotation(const LLQuaternion &val) + { + setValue(SETTING_MOON_ROTATION, val); + } + + azimalt_t getMoonRotationAzAl() const; + + void setMoonRotation(F32 azimuth, F32 altitude); + + void setMoonRotation(const azimalt_t &azialt) + { + setMoonRotation(azialt.first, azialt.second); + } + + LLUUID getMoonTextureId() const + { + return mSettings[SETTING_MOON_TEXTUREID].asUUID(); + } + + F32 getStarBrightness() const + { + return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); + } + + void setStarBrightness(F32 val) + { + setValue(SETTING_STAR_BRIGHTNESS, val); + } + + LLColor3 getSunlightColor() const + { + return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); + } + + void setSunlightColor(const LLColor3 &val) + { + setValue(SETTING_SUNLIGHT_COLOR, val); + } + + LLQuaternion getSunRotation() const + { + return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); + } + + azimalt_t getSunRotationAzAl() const; + + void setSunRotation(const LLQuaternion &val) + { + setValue(SETTING_SUN_ROTATION, val); + } + + void setSunRotation(F32 azimuth, F32 altitude); + + void setSunRotation(const azimalt_t & azimalt) + { + setSunRotation(azimalt.first, azimalt.second); + } + + LLUUID getSunTextureId() const + { + return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); + } + + // Internal/calculated settings + LLVector3 getLightDirection() const + { + update(); + return mLightDirection; + }; + + LLVector3 getClampedLightDirection() const + { + update(); + return mClampedLightDirection; + }; + + LLVector3 getSunDirection() const + { + update(); + return mSunDirection; + } + + LLVector3 getMoonDirection() const + { + update(); + return mMoonDirection; + } + + LLColor4U getFadeColor() const + { + update(); + return mFadeColor; + } + + LLColor4 getMoonAmbient() const + { + update(); + return mMoonAmbient; + } + + LLColor3 getMoonDiffuse() const + { + update(); + return mMoonDiffuse; + } + + LLColor4 getSunAmbient() const + { + update(); + return mSunAmbient; + } + + LLColor3 getSunDiffuse() const + { + update(); + return mSunDiffuse; + } + + LLColor4 getTotalAmbient() const + { + update(); + return mTotalAmbient; + } + +protected: + LLSettingsSky(); + + virtual stringset_t getSlerpKeys() const; + + virtual validation_list_t getValidationList() const; + + virtual void updateSettings(); + + static LLSD translateLegacySettings(LLSD legacy); + +private: + static const std::string SETTING_LEGACY_EAST_ANGLE; + static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; + static const std::string SETTING_LEGACY_SUN_ANGLE; + + static const F32 NIGHTTIME_ELEVATION; + static const F32 NIGHTTIME_ELEVATION_COS; + + void calculateHeavnlyBodyPositions(); + void calculateLightSettings(); + + LLVector3 mSunDirection; + LLVector3 mMoonDirection; + LLVector3 mLightDirection; + LLVector3 mClampedLightDirection; + + static const F32 DOME_RADIUS; + static const F32 DOME_OFFSET; + + LLColor4U mFadeColor; + LLColor4 mMoonAmbient; + LLColor3 mMoonDiffuse; + LLColor4 mSunAmbient; + LLColor3 mSunDiffuse; + + LLColor4 mTotalAmbient; + + typedef std::map mapNameToUniformId_t; + + static mapNameToUniformId_t sNameToUniformMapping; +}; + +#endif diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp new file mode 100644 index 0000000000..1b960746d5 --- /dev/null +++ b/indra/llinventory/llsettingswater.cpp @@ -0,0 +1,215 @@ +/** +* @file llsettingswater.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llsettingswater.h" +#include +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" +#include "indra_constants.h" + +//========================================================================= +namespace +{ + LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); + LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); +} + +//========================================================================= +const std::string LLSettingsWater::SETTING_BLUR_MULTIPILER("blur_multiplier"); +const std::string LLSettingsWater::SETTING_FOG_COLOR("water_fog_color"); +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_NORMAL_MAP("normal_map"); +const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale"); +const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above"); +const std::string LLSettingsWater::SETTING_SCALE_BELOW("scale_below"); +const std::string LLSettingsWater::SETTING_WAVE1_DIR("wave1_direction"); +const std::string LLSettingsWater::SETTING_WAVE2_DIR("wave2_direction"); + +const std::string LLSettingsWater::SETTING_LEGACY_BLUR_MULTIPILER("blurMultiplier"); +const std::string LLSettingsWater::SETTING_LEGACY_FOG_COLOR("waterFogColor"); +const std::string LLSettingsWater::SETTING_LEGACY_FOG_DENSITY("waterFogDensity"); +const std::string LLSettingsWater::SETTING_LEGACY_FOG_MOD("underWaterFogMod"); +const std::string LLSettingsWater::SETTING_LEGACY_FRESNEL_OFFSET("fresnelOffset"); +const std::string LLSettingsWater::SETTING_LEGACY_FRESNEL_SCALE("fresnelScale"); +const std::string LLSettingsWater::SETTING_LEGACY_NORMAL_MAP("normalMap"); +const std::string LLSettingsWater::SETTING_LEGACY_NORMAL_SCALE("normScale"); +const std::string LLSettingsWater::SETTING_LEGACY_SCALE_ABOVE("scaleAbove"); +const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow"); +const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir"); +const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); + +const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL); + + +//========================================================================= +LLSettingsWater::LLSettingsWater(const LLSD &data) : + LLSettingsBase(data) +{ +} + +LLSettingsWater::LLSettingsWater() : + LLSettingsBase() +{ +} + +//========================================================================= +LLSD LLSettingsWater::defaults() +{ + LLSD dfltsetting; + + // Magic constants copied form defaults.xml + dfltsetting[SETTING_BLUR_MULTIPILER] = LLSD::Real(0.04000f); + dfltsetting[SETTING_FOG_COLOR] = LLColor3(0.0156f, 0.1490f, 0.2509f).getValue(); + dfltsetting[SETTING_FOG_DENSITY] = LLSD::Real(2.0f); + dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); + dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); + dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); + dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL_ID); + dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue(); + dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); + dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); + dfltsetting[SETTING_WAVE1_DIR] = LLVector2(1.04999f, -0.42000f).getValue(); + dfltsetting[SETTING_WAVE2_DIR] = LLVector2(1.10999f, -1.16000f).getValue(); + + return dfltsetting; +} + +LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) +{ + LLSD newsettings(defaults()); + + if (legacy.has(SETTING_LEGACY_BLUR_MULTIPILER)) + { + newsettings[SETTING_BLUR_MULTIPILER] = LLSD::Real(legacy[SETTING_LEGACY_BLUR_MULTIPILER].asReal()); + } + if (legacy.has(SETTING_LEGACY_FOG_COLOR)) + { + newsettings[SETTING_FOG_COLOR] = LLColor3(legacy[SETTING_LEGACY_FOG_COLOR]).getValue(); + } + if (legacy.has(SETTING_LEGACY_FOG_DENSITY)) + { + newsettings[SETTING_FOG_DENSITY] = LLSD::Real(legacy[SETTING_LEGACY_FOG_DENSITY]); + } + if (legacy.has(SETTING_LEGACY_FOG_MOD)) + { + newsettings[SETTING_FOG_MOD] = LLSD::Real(legacy[SETTING_LEGACY_FOG_MOD].asReal()); + } + if (legacy.has(SETTING_LEGACY_FRESNEL_OFFSET)) + { + newsettings[SETTING_FRESNEL_OFFSET] = LLSD::Real(legacy[SETTING_LEGACY_FRESNEL_OFFSET].asReal()); + } + if (legacy.has(SETTING_LEGACY_FRESNEL_SCALE)) + { + newsettings[SETTING_FRESNEL_SCALE] = LLSD::Real(legacy[SETTING_LEGACY_FRESNEL_SCALE].asReal()); + } + if (legacy.has(SETTING_LEGACY_NORMAL_MAP)) + { + newsettings[SETTING_NORMAL_MAP] = LLSD::UUID(legacy[SETTING_LEGACY_NORMAL_MAP].asUUID()); + } + if (legacy.has(SETTING_LEGACY_NORMAL_SCALE)) + { + newsettings[SETTING_NORMAL_SCALE] = LLVector3(legacy[SETTING_LEGACY_NORMAL_SCALE]).getValue(); + } + if (legacy.has(SETTING_LEGACY_SCALE_ABOVE)) + { + newsettings[SETTING_SCALE_ABOVE] = LLSD::Real(legacy[SETTING_LEGACY_SCALE_ABOVE].asReal()); + } + if (legacy.has(SETTING_LEGACY_SCALE_BELOW)) + { + newsettings[SETTING_SCALE_BELOW] = LLSD::Real(legacy[SETTING_LEGACY_SCALE_BELOW].asReal()); + } + if (legacy.has(SETTING_LEGACY_WAVE1_DIR)) + { + newsettings[SETTING_WAVE1_DIR] = LLVector2(legacy[SETTING_LEGACY_WAVE1_DIR]).getValue(); + } + if (legacy.has(SETTING_LEGACY_WAVE2_DIR)) + { + newsettings[SETTING_WAVE2_DIR] = LLVector2(legacy[SETTING_LEGACY_WAVE2_DIR]).getValue(); + } + + return newsettings; +} + +void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +{ + LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + + replaceSettings(blenddata); +} + +LLSettingsWater::validation_list_t LLSettingsWater::getValidationList() const +{ + static validation_list_t validation; + + if (validation.empty()) + { // Note the use of LLSD(LLSDArray()()()...) This is due to an issue with the + // copy constructor for LLSDArray. Directly binding the LLSDArray as + // a parameter without first wrapping it in a pure LLSD object will result + // in deeply nested arrays like this [[[[[[[[[[v1,v2,v3]]]]]]]]]] + + validation.push_back(Validator(SETTING_BLUR_MULTIPILER, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.16f))))); + validation.push_back(Validator(SETTING_FOG_COLOR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)(1.0f)), + LLSD(LLSDArray(1.0f)(1.0f)(1.0f)(1.0f))))); + validation.push_back(Validator(SETTING_FOG_DENSITY, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1.0f)(1024.0f))))); + validation.push_back(Validator(SETTING_FOG_MOD, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1.0f)(1024.0f))))); + validation.push_back(Validator(SETTING_FRESNEL_OFFSET, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_FRESNEL_SCALE, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_NORMAL_MAP, true, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_NORMAL_SCALE, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(0.0f)(0.0f)(0.0f)), + LLSD(LLSDArray(10.0f)(10.0f)(10.0f))))); + validation.push_back(Validator(SETTING_SCALE_ABOVE, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_SCALE_BELOW, true, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_WAVE1_DIR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(-4.0f)(-4.0f)), + LLSD(LLSDArray(4.0f)(4.0f))))); + validation.push_back(Validator(SETTING_WAVE2_DIR, true, LLSD::TypeArray, + boost::bind(&Validator::verifyVectorMinMax, _1, + LLSD(LLSDArray(-4.0f)(-4.0f)), + LLSD(LLSDArray(4.0f)(4.0f))))); + } + + return validation; +} + diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h new file mode 100644 index 0000000000..5d6a482d56 --- /dev/null +++ b/indra/llinventory/llsettingswater.h @@ -0,0 +1,227 @@ +/** +* @file llsettingssky.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_WATER_H +#define LL_SETTINGS_WATER_H + +#include "llsettingsbase.h" + +class LLSettingsWater : public LLSettingsBase +{ +public: + static const std::string SETTING_BLUR_MULTIPILER; + static const std::string SETTING_FOG_COLOR; + static const std::string SETTING_FOG_DENSITY; + 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_NORMAL_MAP; + static const std::string SETTING_NORMAL_SCALE; + static const std::string SETTING_SCALE_ABOVE; + static const std::string SETTING_SCALE_BELOW; + static const std::string SETTING_WAVE1_DIR; + static const std::string SETTING_WAVE2_DIR; + + static const LLUUID DEFAULT_WATER_NORMAL_ID; + + typedef boost::shared_ptr ptr_t; + + //--------------------------------------------------------------------- + LLSettingsWater(const LLSD &data); + virtual ~LLSettingsWater() { }; + + virtual ptr_t buildClone() = 0; + + //--------------------------------------------------------------------- + virtual std::string getSettingType() const { return std::string("water"); } + + // Settings status + virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); + + static LLSD defaults(); + + //--------------------------------------------------------------------- + F32 getBlurMultiplier() const + { + return mSettings[SETTING_BLUR_MULTIPILER].asReal(); + } + + void setBlurMultiplier(F32 val) + { + setValue(SETTING_BLUR_MULTIPILER, val); + } + + LLColor3 getFogColor() const + { + return LLColor3(mSettings[SETTING_FOG_COLOR]); + } + + void setFogColor(LLColor3 val) + { + setValue(SETTING_FOG_COLOR, val); + } + + F32 getFogDensity() const + { + return mSettings[SETTING_FOG_DENSITY].asReal(); + } + + void setFogDensity(F32 val) + { + setValue(SETTING_FOG_DENSITY, val); + } + + F32 getFogMod() const + { + return mSettings[SETTING_FOG_MOD].asReal(); + } + + void setFogMod(F32 val) + { + setValue(SETTING_FOG_MOD, val); + } + + F32 getFresnelOffset() const + { + return mSettings[SETTING_FRESNEL_OFFSET].asReal(); + } + + void setFresnelOffset(F32 val) + { + setValue(SETTING_FRESNEL_OFFSET, val); + } + + F32 getFresnelScale() const + { + return mSettings[SETTING_FRESNEL_SCALE].asReal(); + } + + void setFresnelScale(F32 val) + { + setValue(SETTING_FRESNEL_SCALE, val); + } + + LLUUID getNormalMapID() const + { + return mSettings[SETTING_NORMAL_MAP].asUUID(); + } + + void setNormalMapID(LLUUID val) + { + setValue(SETTING_NORMAL_MAP, val); + } + + LLVector3 getNormalScale() const + { + return LLVector3(mSettings[SETTING_NORMAL_SCALE]); + } + + void setNormalScale(LLVector3 val) + { + setValue(SETTING_NORMAL_SCALE, val); + } + + F32 getScaleAbove() const + { + return mSettings[SETTING_SCALE_ABOVE].asReal(); + } + + void setScaleAbove(F32 val) + { + setValue(SETTING_SCALE_ABOVE, val); + } + + F32 getScaleBelow() const + { + return mSettings[SETTING_SCALE_BELOW].asReal(); + } + + void setScaleBelow(F32 val) + { + setValue(SETTING_SCALE_BELOW, val); + } + + LLVector2 getWave1Dir() const + { + return LLVector2(mSettings[SETTING_WAVE1_DIR]); + } + + void setWave1Dir(LLVector2 val) + { + setValue(SETTING_WAVE1_DIR, val); + } + + LLVector2 getWave2Dir() const + { + return LLVector2(mSettings[SETTING_WAVE2_DIR]); + } + + void setWave2Dir(LLVector2 val) + { + setValue(SETTING_WAVE2_DIR, val); + } + + //------------------------------------------- + LLVector4 getWaterPlane() const + { + update(); + return mWaterPlane; + } + + F32 getWaterFogKS() const + { + update(); + return mWaterFogKS; + } + +protected: + LLSettingsWater(); + + virtual validation_list_t getValidationList() const; + + static LLSD translateLegacySettings(LLSD legacy); + + LLVector4 mWaterPlane; + F32 mWaterFogKS; + +private: + static const std::string SETTING_LEGACY_BLUR_MULTIPILER; + static const std::string SETTING_LEGACY_FOG_COLOR; + static const std::string SETTING_LEGACY_FOG_DENSITY; + static const std::string SETTING_LEGACY_FOG_MOD; + static const std::string SETTING_LEGACY_FRESNEL_OFFSET; + static const std::string SETTING_LEGACY_FRESNEL_SCALE; + static const std::string SETTING_LEGACY_NORMAL_MAP; + static const std::string SETTING_LEGACY_NORMAL_SCALE; + static const std::string SETTING_LEGACY_SCALE_ABOVE; + static const std::string SETTING_LEGACY_SCALE_BELOW; + static const std::string SETTING_LEGACY_WAVE1_DIR; + static const std::string SETTING_LEGACY_WAVE2_DIR; + +}; + +#endif diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index bbe32866f6..4579ef14e2 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -532,10 +532,7 @@ set(viewer_SOURCE_FILES llsecapi.cpp llsechandler_basic.cpp llselectmgr.cpp - llsettingsbase.cpp - llsettingsdaycycle.cpp - llsettingssky.cpp - llsettingswater.cpp + llsettingsvo.cpp llshareavatarhandler.cpp llsidepanelappearance.cpp llsidepanelinventory.cpp @@ -1141,10 +1138,7 @@ set(viewer_HEADER_FILES llsecapi.h llsechandler_basic.h llselectmgr.h - llsettingsbase.h - llsettingsdaycycle.h - llsettingssky.h - llsettingswater.h + llsettingsvo.h llsidepanelappearance.h llsidepanelinventory.h llsidepanelinventorysubpanel.h diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8b879710da..e8c9db045c 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -44,6 +44,8 @@ #include "llsdserialize.h" #include "lldiriterator.h" +#include "llsettingsvo.h" + #include //========================================================================= namespace @@ -82,15 +84,15 @@ LLEnvironment::LLEnvironment(): void LLEnvironment::initSingleton() { - LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); + LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); addSky(p_default_sky); mCurrentSky = p_default_sky; - LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); + LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); addWater(p_default_water); mCurrentWater = p_default_water; - LLSettingsDay::ptr_t p_default_day = LLSettingsDay::buildDefaultDayCycle(); + LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle(); addDayCycle(p_default_day); mCurrentDay.reset(); @@ -155,7 +157,7 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) if (data[1].isUndefined()) regionday = LLEnvironment::findDayCycleByName("Default"); else - regionday = LLSettingsDay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); + regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); setSkyFor(ENV_REGION, LLSettingsSky::ptr_t()); setWaterFor(ENV_REGION, LLSettingsWater::ptr_t()); @@ -826,7 +828,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); LLEnvironment::instance().addSky(sky); } } @@ -845,7 +847,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); LLEnvironment::instance().addSky(sky); } } @@ -864,7 +866,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); LLEnvironment::instance().addWater(water); } } @@ -883,7 +885,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); LLEnvironment::instance().addWater(water); } } @@ -902,7 +904,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } @@ -921,7 +923,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index ce8c08f692..4d3d1f6a57 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -27,6 +27,7 @@ #ifndef LL_ENVIRONMENT_H #define LL_ENVIRONMENT_H +#include "llsingleton.h" #include "llmemory.h" #include "llsd.h" @@ -35,6 +36,8 @@ #include "llsettingswater.h" #include "llsettingsdaycycle.h" +#include + //------------------------------------------------------------------------- class LLViewerCamera; class LLGLSLShader; diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp deleted file mode 100644 index e36c6d4a84..0000000000 --- a/indra/newview/llsettingsbase.cpp +++ /dev/null @@ -1,617 +0,0 @@ -/** -* @file llsettingsbase.cpp -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" -#include "llsettingsbase.h" - -#include "llmath.h" -#include - -#include "llsdserialize.h" - -//========================================================================= -namespace -{ - const F32 BREAK_POINT = 0.5; -} - -//========================================================================= -const std::string LLSettingsBase::SETTING_ID("id"); -const std::string LLSettingsBase::SETTING_NAME("name"); - -const F32Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); - -//========================================================================= -LLSettingsBase::LLSettingsBase(): - mSettings(LLSD::emptyMap()), - mDirty(true), - mHashValue(0) -{ -} - -LLSettingsBase::LLSettingsBase(const LLSD setting) : - mSettings(setting), - mDirty(true), - mHashValue(0) -{ -} - -//========================================================================= -void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F32 mix) -{ - mSettings = interpolateSDMap(mSettings, other.mSettings, mix); - setDirtyFlag(true); -} - -LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) const -{ - LLSD newSettings; - - for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) - { - std::string key_name = (*it).first; - LLSD value = (*it).second; - - LLSD::Type setting_type = value.type(); - switch (setting_type) - { - case LLSD::TypeMap: - newSettings[key_name] = combineSDMaps(value, LLSD()); - break; - case LLSD::TypeArray: - newSettings[key_name] = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) - { - newSettings[key_name].append(*ita); - } - break; - //case LLSD::TypeInteger: - //case LLSD::TypeReal: - //case LLSD::TypeBoolean: - //case LLSD::TypeString: - //case LLSD::TypeUUID: - //case LLSD::TypeURI: - //case LLSD::TypeDate: - //case LLSD::TypeBinary: - default: - newSettings[key_name] = value; - break; - } - } - - if (!other.isUndefined()) - { - for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it) - { - std::string key_name = (*it).first; - LLSD value = (*it).second; - - LLSD::Type setting_type = value.type(); - switch (setting_type) - { - case LLSD::TypeMap: - newSettings[key_name] = combineSDMaps(value, LLSD()); - break; - case LLSD::TypeArray: - newSettings[key_name] = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) - { - newSettings[key_name].append(*ita); - } - break; - //case LLSD::TypeInteger: - //case LLSD::TypeReal: - //case LLSD::TypeBoolean: - //case LLSD::TypeString: - //case LLSD::TypeUUID: - //case LLSD::TypeURI: - //case LLSD::TypeDate: - //case LLSD::TypeBinary: - default: - newSettings[key_name] = value; - break; - } - } - } - - return newSettings; -} - -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const -{ - LLSD newSettings; - - stringset_t skip = getSkipInterpolateKeys(); - stringset_t slerps = getSlerpKeys(); - - for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) - { - std::string key_name = (*it).first; - LLSD value = (*it).second; - - if (skip.find(key_name) != skip.end()) - continue; - - if (!other.has(key_name)) - { // The other does not contain this setting, keep the original value - // TODO: Should I blend this out instead? - newSettings[key_name] = value; - continue; - } - LLSD::Type setting_type = value.type(); - LLSD other_value = other[key_name]; - - if (other_value.type() != setting_type) - { - // The data type mismatched between this and other. Hard switch when we pass the break point - // but issue a warning. - LL_WARNS("SETTINGS") << "Setting lerp between mismatched types for '" << key_name << "'." << LL_ENDL; - newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; - continue; - } - - switch (setting_type) - { - case LLSD::TypeInteger: - // lerp between the two values rounding the result to the nearest integer. - newSettings[key_name] = LLSD::Integer(llroundf(lerp(value.asReal(), other_value.asReal(), mix))); - break; - case LLSD::TypeReal: - // lerp between the two values. - newSettings[key_name] = LLSD::Real(lerp(value.asReal(), other_value.asReal(), mix)); - break; - case LLSD::TypeMap: - // deep copy. - newSettings[key_name] = interpolateSDMap(value, other_value, mix); - break; - - case LLSD::TypeArray: - { - LLSD newvalue(LLSD::emptyArray()); - - if (slerps.find(key_name) != slerps.end()) - { - LLQuaternion q = slerp(mix, LLQuaternion(value), LLQuaternion(other_value)); - newvalue = q.getValue(); - } - else - { // TODO: We could expand this to inspect the type and do a deep lerp based on type. - // for now assume a heterogeneous array of reals. - size_t len = std::max(value.size(), other_value.size()); - - for (size_t i = 0; i < len; ++i) - { - - newvalue[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix); - } - } - - newSettings[key_name] = newvalue; - } - - break; - -// case LLSD::TypeBoolean: -// case LLSD::TypeString: -// case LLSD::TypeUUID: -// case LLSD::TypeURI: -// case LLSD::TypeBinary: -// case LLSD::TypeDate: - default: - /* TODO: If the UUID points to an image ID, blend the images. */ - // atomic or unknown data types. Lerping between them does not make sense so switch at the break. - newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; - break; - } - } - - // Now add anything that is in other but not in the settings - for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it) - { - // TODO: Should I blend this in instead? - if (skip.find((*it).first) == skip.end()) - continue; - - if (!settings.has((*it).first)) - continue; - - newSettings[(*it).first] = (*it).second; - } - - return newSettings; -} - -LLSD LLSettingsBase::cloneSettings() const -{ - return combineSDMaps(mSettings, LLSD()); -} - -void LLSettingsBase::exportSettings(std::string name) const -{ - LLSD exprt = LLSDMap("type", LLSD::String(getSettingType())) - ("name", LLSD::String(name)) - ("settings", mSettings); - - std::string path_name = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, name + ".settings"); - - // write to file - llofstream presetsXML(path_name.c_str()); - if (presetsXML.is_open()) - { - LLPointer formatter = new LLSDXMLFormatter(); - formatter->format(exprt, presetsXML, LLSDFormatter::OPTIONS_PRETTY); - presetsXML.close(); - - LL_DEBUGS() << "saved preset '" << name << "'; " << mSettings.size() << " settings" << LL_ENDL; - } - else - { - LL_WARNS("Presets") << "Cannot open for output preset file " << path_name << LL_ENDL; - } -} - -#ifdef VALIDATION_DEBUG -namespace -{ - LLSD clone_llsd(LLSD value) - { - LLSD clone; - - switch (value.type()) - { -// case LLSD::TypeMap: -// newSettings[key_name] = combineSDMaps(value, LLSD()); -// break; - case LLSD::TypeArray: - clone = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) - { - clone.append( clone_llsd(*ita) ); - } - break; - case LLSD::TypeInteger: - clone = LLSD::Integer(value.asInteger()); - break; - case LLSD::TypeReal: - clone = LLSD::Real(value.asReal()); - break; - case LLSD::TypeBoolean: - clone = LLSD::Boolean(value.asBoolean()); - break; - case LLSD::TypeString: - clone = LLSD::String(value.asString()); - break; - case LLSD::TypeUUID: - clone = LLSD::UUID(value.asUUID()); - break; - case LLSD::TypeURI: - clone = LLSD::URI(value.asURI()); - break; - case LLSD::TypeDate: - clone = LLSD::Date(value.asDate()); - break; - //case LLSD::TypeBinary: - // break; - //default: - // newSettings[key_name] = value; - // break; - } - - return clone; - } - - bool compare_llsd(LLSD valA, LLSD valB) - { - if (valA.type() != valB.type()) - return false; - - switch (valA.type()) - { - // case LLSD::TypeMap: - // newSettings[key_name] = combineSDMaps(value, LLSD()); - // break; - case LLSD::TypeArray: - if (valA.size() != valB.size()) - return false; - - for (S32 idx = 0; idx < valA.size(); ++idx) - { - if (!compare_llsd(valA[idx], valB[idx])) - return false; - } - return true; - - case LLSD::TypeInteger: - return valA.asInteger() == valB.asInteger(); - - case LLSD::TypeReal: - return is_approx_equal(valA.asReal(), valB.asReal()); - - case LLSD::TypeBoolean: - return valA.asBoolean() == valB.asBoolean(); - - case LLSD::TypeString: - return valA.asString() == valB.asString(); - - case LLSD::TypeUUID: - return valA.asUUID() == valB.asUUID(); - - case LLSD::TypeURI: - return valA.asString() == valB.asString(); - - case LLSD::TypeDate: - return valA.asDate() == valB.asDate(); - } - - return true; - } -} -#endif - -bool LLSettingsBase::validate() -{ - static Validator validateName(SETTING_NAME, false, LLSD::TypeString); - static Validator validateId(SETTING_ID, false, LLSD::TypeUUID); - validation_list_t validations = getValidationList(); - stringset_t validated; - stringset_t strip; - - // Fields common to all settings. - if (!validateName.verify(mSettings)) - { - LL_WARNS("SETTINGS") << "Unable to validate name." << LL_ENDL; - mIsValid = false; - return false; - } - validated.insert(validateName.getName()); - - if (!validateId.verify(mSettings)) - { - LL_WARNS("SETTINGS") << "Unable to validate Id." << LL_ENDL; - mIsValid = false; - return false; - } - validated.insert(validateId.getName()); - - // Fields for specific settings. - for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv) - { -#ifdef VALIDATION_DEBUG - LLSD oldvalue; - if (mSettings.has((*itv).getName())) - { - oldvalue = clone_llsd(mSettings[(*itv).getName()]); - } -#endif - - if (!(*itv).verify(mSettings)) - { - LL_WARNS("SETTINGS") << "Settings LLSD fails validation and could not be corrected!" << LL_ENDL; - mIsValid = false; - return false; - } - validated.insert((*itv).getName()); - -#ifdef VALIDATION_DEBUG - if (!oldvalue.isUndefined()) - { - if (!compare_llsd(mSettings[(*itv).getName()], oldvalue)) - { - LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << mSettings[(*itv).getName()] << LL_ENDL; - } - } -#endif - } - - // strip extra entries - for (LLSD::map_iterator itm = mSettings.beginMap(); itm != mSettings.endMap(); ++itm) - { - if (validated.find((*itm).first) == validated.end()) - { - LL_WARNS("SETTINGS") << "Stripping setting '" << (*itm).first << "'" << LL_ENDL; - strip.insert((*itm).first); - } - } - - for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its) - { - mSettings.erase(*its); - } - - return true; -} - -//========================================================================= -bool LLSettingsBase::Validator::verify(LLSD &data) -{ - if (!data.has(mName)) - { - if (mRequired) - LL_WARNS("SETTINGS") << "Missing required setting '" << mName << "'" << LL_ENDL; - return !mRequired; - } - - if (data[mName].type() != mType) - { - LL_WARNS("SETTINGS") << "Setting '" << mName << "' is incorrect type." << LL_ENDL; - return false; - } - - if (!mVerify.empty() && !mVerify(data[mName])) - { - LL_WARNS("SETTINGS") << "Setting '" << mName << "' fails validation." << LL_ENDL; - return false; - } - - return true; -} - -bool LLSettingsBase::Validator::verifyColor(LLSD &value) -{ - return (value.size() == 3 || value.size() == 4); -} - -bool LLSettingsBase::Validator::verifyVector(LLSD &value, S32 length) -{ - return (value.size() == length); -} - -bool LLSettingsBase::Validator::verifyVectorNormalized(LLSD &value, S32 length) -{ - if (value.size() != length) - return false; - - LLSD newvector; - - switch (length) - { - case 2: - { - LLVector2 vect(value); - - if (is_approx_equal(vect.normalize(), 1.0f)) - return true; - newvector = vect.getValue(); - break; - } - case 3: - { - LLVector3 vect(value); - - if (is_approx_equal(vect.normalize(), 1.0f)) - return true; - newvector = vect.getValue(); - break; - } - case 4: - { - LLVector4 vect(value); - - if (is_approx_equal(vect.normalize(), 1.0f)) - return true; - newvector = vect.getValue(); - break; - } - default: - return false; - } - - return true; -} - -bool LLSettingsBase::Validator::verifyVectorMinMax(LLSD &value, LLSD minvals, LLSD maxvals) -{ - for (S32 index = 0; index < value.size(); ++index) - { - if (minvals[index].asString() != "*") - { - if (minvals[index].asReal() > value[index].asReal()) - { - value[index] = minvals[index].asReal(); - } - } - if (maxvals[index].asString() != "*") - { - if (maxvals[index].asReal() < value[index].asReal()) - { - value[index] = maxvals[index].asReal(); - } - } - } - - return true; -} - -bool LLSettingsBase::Validator::verifyQuaternion(LLSD &value) -{ - return (value.size() == 4); -} - -bool LLSettingsBase::Validator::verifyQuaternionNormal(LLSD &value) -{ - if (value.size() != 4) - return false; - - LLQuaternion quat(value); - - if (is_approx_equal(quat.normalize(), 1.0f)) - return true; - - LLSD newquat = quat.getValue(); - for (S32 index = 0; index < 4; ++index) - { - value[index] = newquat[index]; - } - return true; -} - -bool LLSettingsBase::Validator::verifyFloatRange(LLSD &value, LLSD range) -{ - F32 real = value.asReal(); - - F32 clampedval = llclamp(LLSD::Real(real), range[0].asReal(), range[1].asReal()); - - if (is_approx_equal(clampedval, real)) - return true; - - value = LLSD::Real(clampedval); - return true; -} - -bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) -{ - S32 ival = value.asInteger(); - - S32 clampedval = llclamp(LLSD::Integer(ival), range[0].asInteger(), range[1].asInteger()); - - if (clampedval == ival) - return true; - - value = LLSD::Integer(clampedval); - return true; -} - -//========================================================================= - -void LLSettingsBlender::update(F32Seconds timedelta) -{ - mTimeSpent += timedelta; - - if (mTimeSpent >= mSeconds) - { - LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon - mOnFinished(shared_from_this()); - mOnFinished.disconnect_all_slots(); // prevent from firing more than once. - return; - } - - F32 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); - - mTarget->replaceSettings(mInitial->getSettings()); - mTarget->blend(mFinal, blendf); -} - diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h deleted file mode 100644 index d304b8702a..0000000000 --- a/indra/newview/llsettingsbase.h +++ /dev/null @@ -1,312 +0,0 @@ -/** -* @file llsettingsbase.h -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#ifndef LL_SETTINGS_BASE_H -#define LL_SETTINGS_BASE_H - -#include -#include -#include -#include - -#include "llsd.h" -#include "llsdutil.h" -#include "v2math.h" -#include "v3math.h" -#include "v4math.h" -#include "llquaternion.h" -#include "v4color.h" - -class LLSettingsBase : - public boost::enable_shared_from_this, - private boost::noncopyable -{ - friend class LLEnvironment; - friend class LLSettingsDay; - -public: - static const std::string SETTING_ID; - static const std::string SETTING_NAME; - - typedef std::map parammapping_t; - - typedef boost::shared_ptr ptr_t; - - virtual ~LLSettingsBase() { }; - - //--------------------------------------------------------------------- - virtual std::string getSettingType() const = 0; - - //--------------------------------------------------------------------- - // Settings status - inline bool hasSetting(const std::string ¶m) const { return mSettings.has(param); } - inline bool isDirty() const { return mDirty; } - inline void setDirtyFlag(bool dirty) { mDirty = dirty; } - - inline size_t getHash() const - { - return boost::hash{}(mSettings); - } - - 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) - { - mSettings[name] = value; - mDirty = true; - } - - inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const - { - if (!mSettings.has(name)) - return deflt; - return mSettings[name]; - } - - inline void setValue(const std::string &name, const LLVector2 &value) - { - setValue(name, value.getValue()); - } - - inline void setValue(const std::string &name, const LLVector3 &value) - { - setValue(name, value.getValue()); - } - - inline void setValue(const std::string &name, const LLVector4 &value) - { - setValue(name, value.getValue()); - } - - inline void setValue(const std::string &name, const LLQuaternion &value) - { - setValue(name, value.getValue()); - } - - inline void setValue(const std::string &name, const LLColor3 &value) - { - setValue(name, value.getValue()); - } - - inline void setValue(const std::string &name, const LLColor4 &value) - { - setValue(name, value.getValue()); - } - - // Note this method is marked const but may modify the settings object. - // (note the internal const cast). This is so that it may be called without - // special consideration from getters. - inline void update() const - { - if (!mDirty) - return; - (const_cast(this))->updateSettings(); - } - - // TODO: This is temporary - virtual void exportSettings(std::string name) const; - - virtual void blend(const ptr_t &end, F32 blendf) = 0; - - virtual bool validate(); - -protected: - class Validator - { - public: - typedef boost::function verify_pr; - - Validator(std::string name, bool required, LLSD::Type type, verify_pr verify = verify_pr()) : - mName(name), - mRequired(required), - mType(type), - mVerify(verify) - { } - - std::string getName() const { return mName; } - bool isRequired() const { return mRequired; } - LLSD::Type getType() const { return mType; } - - bool verify(LLSD &data); - - // Some basic verifications - static bool verifyColor(LLSD &value); - static bool verifyVector(LLSD &value, S32 length); - static bool verifyVectorMinMax(LLSD &value, LLSD minvals, LLSD maxvals); - static bool verifyVectorNormalized(LLSD &value, S32 length); - static bool verifyQuaternion(LLSD &value); - static bool verifyQuaternionNormal(LLSD &value); - static bool verifyFloatRange(LLSD &value, LLSD range); - static bool verifyIntegerRange(LLSD &value, LLSD range); - - private: - std::string mName; - bool mRequired; - LLSD::Type mType; - verify_pr mVerify; - }; - typedef std::vector validation_list_t; - - LLSettingsBase(); - LLSettingsBase(const LLSD setting); - - typedef std::set stringset_t; - - // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, F32 mix); - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const; - - /// when lerping between settings, some may require special handling. - /// Get a list of these key to be skipped by the default settings lerp. - /// (handling should be performed in the override of lerpSettings. - virtual stringset_t getSkipInterpolateKeys() const { return stringset_t(); } - - // A list of settings that represent quaternions and should be slerped - // rather than lerped. - virtual stringset_t getSlerpKeys() const { return stringset_t(); } - - // Calculate any custom settings that may need to be cached. - virtual void updateSettings() { mDirty = false; }; - - virtual validation_list_t getValidationList() const = 0; - - // Apply any settings that need special handling. - virtual void applySpecial(void *) { }; - - virtual parammapping_t getParameterMap() const { return parammapping_t(); } - - LLSD mSettings; - bool mIsValid; - - LLSD cloneSettings() const; - -private: - bool mDirty; - size_t mHashValue; - - LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; - -}; - - -class LLSettingsBlender : public boost::enable_shared_from_this -{ -public: - typedef boost::shared_ptr ptr_t; - typedef boost::signals2::signal finish_signal_t; - typedef boost::signals2::connection connection_t; - - static const F32Seconds DEFAULT_THRESHOLD; - - LLSettingsBlender(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F32Seconds seconds) : - mTarget(target), - mInitial(initsetting), - mFinal(endsetting), - mSeconds(seconds), - mOnFinished(), - mBlendThreshold(DEFAULT_THRESHOLD), - mLastUpdate(0.0f), - mTimeSpent(0.0f) - { - mTarget->replaceSettings(mInitial->getSettings()); - mTimeStart = F32Seconds(LLDate::now().secondsSinceEpoch()); - mLastUpdate = mTimeStart; - } - - ~LLSettingsBlender() {} - - connection_t setOnFinished(const finish_signal_t::slot_type &onfinished) - { - return mOnFinished.connect(onfinished); - } - - void setUpdateThreshold(F32Seconds threshold) - { - mBlendThreshold = threshold; - } - - F32Seconds getUpdateThreshold() const - { - return mBlendThreshold; - } - - LLSettingsBase::ptr_t getTarget() const - { - return mTarget; - } - - LLSettingsBase::ptr_t getInitial() const - { - return mInitial; - } - - LLSettingsBase::ptr_t getFinal() const - { - return mFinal; - } - - void update(F32Seconds time); -private: - LLSettingsBase::ptr_t mTarget; - LLSettingsBase::ptr_t mInitial; - LLSettingsBase::ptr_t mFinal; - F32Seconds mSeconds; - finish_signal_t mOnFinished; - F32Seconds mBlendThreshold; - F32Seconds mLastUpdate; - F32Seconds mTimeSpent; - F32Seconds mTimeStart; -}; - -#endif diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp deleted file mode 100644 index a579f99182..0000000000 --- a/indra/newview/llsettingsdaycycle.cpp +++ /dev/null @@ -1,613 +0,0 @@ -/** -* @file llsettingsdaycycle.cpp -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" -#include "llviewercontrol.h" -#include "llsettingsdaycycle.h" -#include -#include -#include "lltrace.h" -#include "llfasttimer.h" -#include "v3colorutil.h" - -#include "llglslshader.h" -#include "llviewershadermgr.h" - -#include "llenvironment.h" - -#include "llagent.h" -#include "pipeline.h" - -#include "llsettingssky.h" -#include "llsettingswater.h" - -#include "llenvironment.h" - -#include "llworld.h" - -//========================================================================= -namespace -{ - LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); - LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); - - inline F32 get_wrapping_distance(F32 begin, F32 end) - { - if (begin < end) - { - return end - begin; - } - else if (begin > end) - { - return 1.0 - (begin - end); - } - - return 0; - } - - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) - { - if (collection.empty()) - return collection.end(); - - LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); - - if (it == collection.end()) - { // wrap around - it = collection.begin(); - } - - return it; - } - - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) - { - if (collection.empty()) - return collection.end(); - - LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); - - if (it == collection.end()) - { // all keyframes are lower, take the last one. - --it; // we know the range is not empty - } - else if ((*it).first > key) - { // the keyframe we are interested in is smaller than the found. - if (it == collection.begin()) - it = collection.end(); - --it; - } - - return it; - } - - -} - -//========================================================================= -const std::string LLSettingsDay::SETTING_DAYLENGTH("day_length"); -const std::string LLSettingsDay::SETTING_KEYID("key_id"); -const std::string LLSettingsDay::SETTING_KEYNAME("key_name"); -const std::string LLSettingsDay::SETTING_KEYKFRAME("key_keyframe"); -const std::string LLSettingsDay::SETTING_TRACKS("tracks"); - -const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins - -//const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours -const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days - -const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 -const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water -const S32 LLSettingsDay::FRAME_MAX(56); - -//========================================================================= -LLSettingsDay::LLSettingsDay(const LLSD &data) : - LLSettingsBase(data), - mHasParsed(false) -{ - mDayTracks.resize(TRACK_MAX); -} - -LLSettingsDay::LLSettingsDay() : - LLSettingsBase(), - mHasParsed(false) -{ - mDayTracks.resize(TRACK_MAX); -} - -//========================================================================= -LLSD LLSettingsDay::defaults() -{ - LLSD dfltsetting; - - dfltsetting[SETTING_NAME] = "_default_"; - dfltsetting[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); - dfltsetting[SETTING_TRACKS] = LLSDArray( - LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) - (LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); - - return dfltsetting; -} - -LLSettingsDay::ptr_t LLSettingsDay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) -{ - LLSD newsettings(defaults()); - - newsettings[SETTING_NAME] = name; - newsettings[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); - - LLSD watertrack = LLSDArray( - LLSDMap ( SETTING_KEYKFRAME, LLSD::Real(0.0f) ) - ( SETTING_KEYNAME, "Default" )); - - LLSD skytrack = LLSD::emptyArray(); - - for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) - { - LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) - (SETTING_KEYNAME, (*it)[1].asString()); - skytrack.append(entry); - } - - newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); - - LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); - dayp->parseFromLLSD(dayp->mSettings); - - if (dayp->validate()) - return dayp; - - return LLSettingsDay::ptr_t(); -} - -LLSettingsDay::ptr_t LLSettingsDay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) -{ - LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset("Region", waterdef); - LLEnvironment::namedSettingMap_t skys; - - for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) - { - std::string name = (*itm).first; - LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, (*itm).second); - - skys[name] = sky; - LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; - } - - LLSettingsDay::ptr_t dayp = buildFromLegacyPreset("Region (legacy)", daycycle); - - dayp->setWaterAtKeyframe(water, 0.0f); - - for (LLSD::array_iterator ita = daycycle.beginArray(); ita != daycycle.endArray(); ++ita) - { - F32 frame = (*ita)[0].asReal(); - std::string name = (*ita)[1].asString(); - - LLEnvironment::namedSettingMap_t::iterator it = skys.find(name); - - if (it == skys.end()) - continue; - dayp->setSkyAtKeyframe(boost::static_pointer_cast((*it).second), frame, 1); - - LL_WARNS("WindlightCaps") << "Added '" << name << "' to region day cycle at " << frame << LL_ENDL; - } - - dayp->mHasParsed = true; - - if (dayp->validate()) - return dayp; - - return LLSettingsDay::ptr_t(); -} - -LLSettingsDay::ptr_t LLSettingsDay::buildDefaultDayCycle() -{ - LLSD settings = LLSettingsDay::defaults(); - - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); - dayp->parseFromLLSD(dayp->mSettings); - - if (dayp->validate()) - return dayp; - - return LLSettingsDay::ptr_t(); -} - -void LLSettingsDay::parseFromLLSD(LLSD &data) -{ - LLEnvironment &environment(LLEnvironment::instance()); - LLSD tracks = data[SETTING_TRACKS]; - - for (S32 i = 0; (i < tracks.size()) && (i < TRACK_MAX); ++i) - { - mDayTracks[i].clear(); - LLSD curtrack = tracks[i]; - for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) - { - F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); - keyframe = llclamp(keyframe, 0.0f, 1.0f); - LLSettingsBase::ptr_t setting; - - if ((*it).has(SETTING_KEYNAME)) - { - if (i == TRACK_WATER) - setting = environment.findWaterByName((*it)[SETTING_KEYNAME]); - else - setting = environment.findSkyByName((*it)[SETTING_KEYNAME]); - } - else if ((*it).has(SETTING_KEYID)) - { - - } - - if (setting) - mDayTracks[i][keyframe] = setting; - } - } - mHasParsed = true; -} - - -LLSettingsDay::ptr_t LLSettingsDay::buildClone() -{ - LLSD settings = cloneSettings(); - - LLSettingsDay::ptr_t dayp = boost::make_shared(settings); - - return dayp; -} - -void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F32 mix) -{ - LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; -} - -namespace -{ - bool validateDayCycleTrack(LLSD &value) - { - // Trim extra tracks. - while (value.size() > LLSettingsDay::TRACK_MAX) - { - value.erase(value.size() - 1); - } - - for (LLSD::array_iterator track = value.beginArray(); track != value.endArray(); ++track) - { - S32 index = 0; - while (index < (*track).size()) - { - if (index >= LLSettingsDay::FRAME_MAX) - { - (*track).erase(index); - continue; - } - - if (!(*track)[index].has(LLSettingsDay::SETTING_KEYKFRAME) || - !(*track)[index][LLSettingsDay::SETTING_KEYKFRAME].isReal()) - { - (*track).erase(index); - continue; - } - - if (!(*track)[index].has(LLSettingsDay::SETTING_KEYNAME) && - !(*track)[index].has(LLSettingsDay::SETTING_KEYID)) - { - (*track).erase(index); - continue; - } - - F32 frame = (*track)[index][LLSettingsDay::SETTING_KEYKFRAME].asReal(); - if ((frame < 0.0) || (frame > 1.0)) - { - frame = llclamp(frame, 0.0f, 1.0f); - (*track)[index][LLSettingsDay::SETTING_KEYKFRAME] = frame; - } - ++index; - } - - } - return true; - } -} - -LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const -{ - static validation_list_t validation; - - if (validation.empty()) - { - validation.push_back(Validator(SETTING_TRACKS, true, LLSD::TypeArray, - &validateDayCycleTrack)); - validation.push_back(Validator(SETTING_DAYLENGTH, false, LLSD::TypeInteger, - boost::bind(&Validator::verifyIntegerRange, _1, - LLSD(LLSDArray(LLSD::Integer(MINIMUM_DAYLENGTH))(LLSD::Integer(MAXIMUM_DAYLENGTH)))))); - } - - return validation; -} - -//========================================================================= -F32 LLSettingsDay::secondsToKeyframe(S64Seconds seconds) -{ - S64Seconds daylength = getDayLength(); - - return llclamp(static_cast(seconds.value() % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); -} - -F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe) -{ - S64Seconds daylength = getDayLength(); - - return F64Seconds(static_cast(keyframe * static_cast(daylength.value()))); -} - -//========================================================================= -void LLSettingsDay::startDayCycle() -{ - F64Seconds now(LLDate::now().secondsSinceEpoch()); - - if (!mHasParsed) - parseFromLLSD(mSettings); - - // water - if (mDayTracks[0].empty()) - { - mBlendedWater.reset(); - mWaterBlender.reset(); - } - else if (mDayTracks[0].size() == 1) - { - mBlendedWater = boost::static_pointer_cast((*(mDayTracks[0].begin())).second); - mWaterBlender.reset(); - } - else - { - TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); - - F64Seconds timespan = F64Seconds( getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); - - mBlendedWater = LLSettingsWater::buildDefaultWater(); - mWaterBlender = boost::make_shared(mBlendedWater, - (*bounds.first).second, (*bounds.second).second, timespan); - mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); - } - - // sky - if (mDayTracks[1].empty()) - { - mBlendedSky.reset(); - mSkyBlender.reset(); - } - else if (mDayTracks[1].size() == 1) - { - mBlendedSky = boost::static_pointer_cast( (*(mDayTracks[1].begin())).second); - mSkyBlender.reset(); - } - else - { - TrackBound_t bounds = getBoundingEntries(mDayTracks[1], now); - F64Seconds timespan = F64Seconds(getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); - - mBlendedSky = LLSettingsSky::buildDefaultSky(); - mSkyBlender = boost::make_shared(mBlendedSky, - (*bounds.first).second, (*bounds.second).second, timespan); - mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, 1, _1)); - } -} - - -void LLSettingsDay::updateSettings() -{ - static LLFrameTimer timer; - - - F64Seconds delta(timer.getElapsedTimeAndResetF32()); - - if (mSkyBlender) - mSkyBlender->update(delta); - if (mWaterBlender) - mWaterBlender->update(delta); - -#if 0 - //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(0.1))) - { - F64Seconds daylength = static_cast(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); -#endif -} - -//========================================================================= -void LLSettingsDay::setDayLength(S64Seconds seconds) -{ - S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); - - setValue(SETTING_DAYLENGTH, val); -} - -LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) -{ - if ((trackno < 1) || (trackno >= TRACK_MAX)) - { - LL_WARNS("DAYCYCLE") << "Attempt get track (#" << trackno << ") out of range!" << LL_ENDL; - return KeyframeList_t(); - } - - KeyframeList_t keyframes; - CycleTrack_t &track = mDayTracks[trackno]; - - keyframes.reserve(track.size()); - - for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) - { - keyframes.push_back((*it).first); - } - - return keyframes; -} - -LLSettingsDay::TimeList_t LLSettingsDay::getTrackTimes(S32 trackno) -{ - KeyframeList_t keyframes = getTrackKeyframes(trackno); - - if (keyframes.empty()) - return TimeList_t(); - - TimeList_t times; - - times.reserve(keyframes.size()); - for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it) - { - times.push_back(keyframeToSeconds(*it)); - } - - return times; -} - -void LLSettingsDay::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) -{ - F32 keyframe = secondsToKeyframe(seconds); - setWaterAtKeyframe(water, keyframe); -} - -void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) -{ - mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; - setDirtyFlag(true); -} - - -void LLSettingsDay::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) -{ - F32 keyframe = secondsToKeyframe(seconds); - setSkyAtKeyframe(sky, keyframe, track); -} - -void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) -{ - if ((track < 1) || (track >= TRACK_MAX)) - { - LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; - return; - } - - mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = sky; - setDirtyFlag(true); -} - -LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) -{ - return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); -} - -LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F64Seconds time) -{ - F32 frame = secondsToKeyframe(time); - - return getBoundingEntries(track, frame); -} - -//========================================================================= -void LLSettingsDay::onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender) -{ - F64Seconds now(LLDate::now().secondsSinceEpoch()); - TrackBound_t bounds = getBoundingEntries(mDayTracks[track], now); - - F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - F64Seconds timespan = F64Seconds(distance * getDayLength()); - - LL_WARNS("RIDER") << "New sky blender. now=" << now << - " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << - " span=" << timespan << LL_ENDL; - - mSkyBlender = boost::make_shared(mBlendedSky, - (*bounds.first).second, (*bounds.second).second, timespan); - mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, track, _1)); -} - -void LLSettingsDay::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) -{ - F64Seconds now(LLDate::now().secondsSinceEpoch()); - TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); - - F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - F64Seconds timespan = F64Seconds(distance * getDayLength()); - - mWaterBlender = boost::make_shared(mBlendedWater, - (*bounds.first).second, (*bounds.second).second, timespan); - mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); -} diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h deleted file mode 100644 index 804d7aee26..0000000000 --- a/indra/newview/llsettingsdaycycle.h +++ /dev/null @@ -1,143 +0,0 @@ -/** -* @file llsettingsdaycycle.h -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#ifndef LL_SETTINGS_DAYCYCLE_H -#define LL_SETTINGS_DAYCYCLE_H - -#include "llsettingsbase.h" - -class LLSettingsWater; -class LLSettingsSky; - -typedef boost::shared_ptr LLSettingsWaterPtr_t; -typedef boost::shared_ptr LLSettingsSkyPtr_t; - -class LLSettingsDay : public LLSettingsBase -{ -public: - static const std::string SETTING_DAYLENGTH; - static const std::string SETTING_KEYID; - static const std::string SETTING_KEYNAME; - static const std::string SETTING_KEYKFRAME; - static const std::string SETTING_TRACKS; - - static const S64 MINIMUM_DAYLENGTH; - static const S64 MAXIMUM_DAYLENGTH; - - static const S32 TRACK_WATER; - static const S32 TRACK_MAX; - static const S32 FRAME_MAX; - - typedef std::map CycleTrack_t; - typedef std::vector CycleList_t; - typedef boost::shared_ptr ptr_t; - typedef std::vector TimeList_t; - typedef std::vector KeyframeList_t; - typedef std::pair TrackBound_t; - - //--------------------------------------------------------------------- - LLSettingsDay(const LLSD &data); - virtual ~LLSettingsDay() { }; - - static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); - static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); - static ptr_t buildDefaultDayCycle(); - ptr_t buildClone(); - - //--------------------------------------------------------------------- - virtual std::string getSettingType() const { return std::string("daycycle"); } - - // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix); - - static LLSD defaults(); - - //--------------------------------------------------------------------- - S64Seconds getDayLength() const - { - return S64Seconds(mSettings[SETTING_DAYLENGTH].asInteger()); - } - - void setDayLength(S64Seconds seconds); - - KeyframeList_t getTrackKeyframes(S32 track); - TimeList_t getTrackTimes(S32 track); - - void setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds); - void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - - void setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track); - void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track); - //--------------------------------------------------------------------- - void startDayCycle(); - - LLSettingsSkyPtr_t getCurrentSky() const - { - return mBlendedSky; - } - - LLSettingsWaterPtr_t getCurrentWater() const - { - return mBlendedWater; - } - -protected: - LLSettingsDay(); - - virtual void updateSettings(); - - virtual validation_list_t getValidationList() const; - -private: - LLSettingsBlender::ptr_t mSkyBlender; // convert to [] for altitudes - LLSettingsBlender::ptr_t mWaterBlender; - - LLSettingsSkyPtr_t mBlendedSky; - LLSettingsWaterPtr_t mBlendedWater; - - CycleList_t mDayTracks; - - bool mHasParsed; - F64Seconds mLastUpdateTime; - - F32 secondsToKeyframe(S64Seconds seconds); - F64Seconds keyframeToSeconds(F32 keyframe); - - void parseFromLLSD(LLSD &data); - - static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); - static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); - - TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); - TrackBound_t getBoundingEntries(CycleTrack_t &track, F64Seconds time); - - void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender); - void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); - -}; - -#endif diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp deleted file mode 100644 index f1825792d9..0000000000 --- a/indra/newview/llsettingssky.cpp +++ /dev/null @@ -1,655 +0,0 @@ -/** -* @file llsettingssky.cpp -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" -#include "llviewercontrol.h" -#include "llsettingssky.h" -#include -#include -#include "lltrace.h" -#include "llfasttimer.h" -#include "v3colorutil.h" - -#include "llglslshader.h" -#include "llviewershadermgr.h" - -#include "llenvironment.h" -#include "llsky.h" - -//========================================================================= -namespace -{ - const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0); - const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); - const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); - - LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); - LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); - - LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); - void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); -} - -const F32 LLSettingsSky::DOME_OFFSET(0.96f); -const F32 LLSettingsSky::DOME_RADIUS(15000.f); - -//========================================================================= -const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); -const std::string LLSettingsSky::SETTING_BLOOM_TEXTUREID("bloom_id"); -const std::string LLSettingsSky::SETTING_BLUE_DENSITY("blue_density"); -const std::string LLSettingsSky::SETTING_BLUE_HORIZON("blue_horizon"); -const std::string LLSettingsSky::SETTING_CLOUD_COLOR("cloud_color"); -const std::string LLSettingsSky::SETTING_CLOUD_POS_DENSITY1("cloud_pos_density1"); -const std::string LLSettingsSky::SETTING_CLOUD_POS_DENSITY2("cloud_pos_density2"); -const std::string LLSettingsSky::SETTING_CLOUD_SCALE("cloud_scale"); -const std::string LLSettingsSky::SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate"); -const std::string LLSettingsSky::SETTING_CLOUD_SHADOW("cloud_shadow"); -const std::string LLSettingsSky::SETTING_CLOUD_TEXTUREID("cloud_id"); -const std::string LLSettingsSky::SETTING_DENSITY_MULTIPLIER("density_multiplier"); -const std::string LLSettingsSky::SETTING_DISTANCE_MULTIPLIER("distance_multiplier"); -const std::string LLSettingsSky::SETTING_DOME_OFFSET("dome_offset"); -const std::string LLSettingsSky::SETTING_DOME_RADIUS("dome_radius"); -const std::string LLSettingsSky::SETTING_GAMMA("gamma"); -const std::string LLSettingsSky::SETTING_GLOW("glow"); -const std::string LLSettingsSky::SETTING_HAZE_DENSITY("haze_density"); -const std::string LLSettingsSky::SETTING_HAZE_HORIZON("haze_horizon"); -const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); -const std::string LLSettingsSky::SETTING_MAX_Y("max_y"); -const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation"); -const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id"); -const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); -const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); -const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); -const std::string LLSettingsSky::SETTING_SUN_TEXUTUREID("sun_id"); - -const std::string LLSettingsSky::SETTING_LEGACY_EAST_ANGLE("east_angle"); -const std::string LLSettingsSky::SETTING_LEGACY_ENABLE_CLOUD_SCROLL("enable_cloud_scroll"); -const std::string LLSettingsSky::SETTING_LEGACY_SUN_ANGLE("sun_angle"); - -//========================================================================= -LLSettingsSky::LLSettingsSky(const LLSD &data) : - LLSettingsBase(data) -{ -} - -LLSettingsSky::LLSettingsSky(): - LLSettingsBase() -{ -} - -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) -{ - LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); - - replaceSettings(blenddata); -} - - -void LLSettingsSky::setMoonRotation(F32 azimuth, F32 altitude) -{ - setValue(SETTING_MOON_ROTATION, ::body_position_from_angles(azimuth, altitude)); -} - -LLSettingsSky::azimalt_t LLSettingsSky::getMoonRotationAzAl() const -{ - azimalt_t res; - ::angles_from_rotation(getMoonRotation(), res.first, res.second); - - return res; -} - -void LLSettingsSky::setSunRotation(F32 azimuth, F32 altitude) -{ - setValue(SETTING_SUN_ROTATION, ::body_position_from_angles(azimuth, altitude)); -} - -LLSettingsSky::azimalt_t LLSettingsSky::getSunRotationAzAl() const -{ - azimalt_t res; - ::angles_from_rotation(getSunRotation(), res.first, res.second); - - return res; -} - -LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const -{ - static stringset_t slepSet; - - if (slepSet.empty()) - { - slepSet.insert(SETTING_SUN_ROTATION); - slepSet.insert(SETTING_MOON_ROTATION); - } - - return slepSet; -} - -LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const -{ - static validation_list_t validation; - - if (validation.empty()) - { // Note the use of LLSD(LLSDArray()()()...) This is due to an issue with the - // copy constructor for LLSDArray. Directly binding the LLSDArray as - // a parameter without first wrapping it in a pure LLSD object will result - // in deeply nested arrays like this [[[[[[[[[[v1,v2,v3]]]]]]]]]] - - validation.push_back(Validator(SETTING_AMBIENT, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*"))))); - validation.push_back(Validator(SETTING_BLOOM_TEXTUREID, true, LLSD::TypeUUID)); - validation.push_back(Validator(SETTING_BLUE_DENSITY, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*"))))); - validation.push_back(Validator(SETTING_BLUE_HORIZON, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*"))))); - validation.push_back(Validator(SETTING_CLOUD_COLOR, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(1.0f)(1.0f)(1.0f)("*"))))); - validation.push_back(Validator(SETTING_CLOUD_POS_DENSITY1, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(1.68841f)(1.0f)(1.0f)("*"))))); - validation.push_back(Validator(SETTING_CLOUD_POS_DENSITY2, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(1.68841f)(1.0f)(1.0f)("*"))))); - validation.push_back(Validator(SETTING_CLOUD_SCALE, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.001f)(0.999f))))); - validation.push_back(Validator(SETTING_CLOUD_SCROLL_RATE, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)), - LLSD(LLSDArray(20.0f)(20.0f))))); - validation.push_back(Validator(SETTING_CLOUD_SHADOW, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_CLOUD_TEXTUREID, false, LLSD::TypeUUID)); - validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f))))); - validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f))))); - validation.push_back(Validator(SETTING_DOME_OFFSET, false, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_DOME_RADIUS, false, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1000.0f)(2000.0f))))); - validation.push_back(Validator(SETTING_GAMMA, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(10.0f))))); - validation.push_back(Validator(SETTING_GLOW, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.2f)("*")(-2.5f)("*")), - LLSD(LLSDArray(20.0f)("*")(0.0f)("*"))))); - validation.push_back(Validator(SETTING_HAZE_DENSITY, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f))))); - validation.push_back(Validator(SETTING_HAZE_HORIZON, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_LIGHT_NORMAL, false, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorNormalized, _1, 3))); - validation.push_back(Validator(SETTING_MAX_Y, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4000.0f))))); - validation.push_back(Validator(SETTING_MOON_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); - validation.push_back(Validator(SETTING_MOON_TEXTUREID, false, LLSD::TypeUUID)); - validation.push_back(Validator(SETTING_STAR_BRIGHTNESS, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(2.0f))))); - validation.push_back(Validator(SETTING_SUNLIGHT_COLOR, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")), - LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*"))))); - validation.push_back(Validator(SETTING_SUN_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); - validation.push_back(Validator(SETTING_SUN_TEXUTUREID, false, LLSD::TypeUUID)); - } - - return validation; -} - -LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) -{ - LLSD newsettings(defaults()); - - newsettings[SETTING_NAME] = name; - - - if (oldsettings.has(SETTING_AMBIENT)) - { - newsettings[SETTING_AMBIENT] = LLColor3(oldsettings[SETTING_AMBIENT]).getValue(); - } - if (oldsettings.has(SETTING_BLUE_DENSITY)) - { - newsettings[SETTING_BLUE_DENSITY] = LLColor3(oldsettings[SETTING_BLUE_DENSITY]).getValue(); - } - if (oldsettings.has(SETTING_BLUE_HORIZON)) - { - newsettings[SETTING_BLUE_HORIZON] = LLColor3(oldsettings[SETTING_BLUE_HORIZON]).getValue(); - } - if (oldsettings.has(SETTING_CLOUD_COLOR)) - { - newsettings[SETTING_CLOUD_COLOR] = LLColor3(oldsettings[SETTING_CLOUD_COLOR]).getValue(); - } - if (oldsettings.has(SETTING_CLOUD_POS_DENSITY1)) - { - newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor3(oldsettings[SETTING_CLOUD_POS_DENSITY1]).getValue(); - } - if (oldsettings.has(SETTING_CLOUD_POS_DENSITY2)) - { - newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor3(oldsettings[SETTING_CLOUD_POS_DENSITY2]).getValue(); - } - if (oldsettings.has(SETTING_CLOUD_SCALE)) - { - newsettings[SETTING_CLOUD_SCALE] = LLSD::Real(oldsettings[SETTING_CLOUD_SCALE][0].asReal()); - } - if (oldsettings.has(SETTING_CLOUD_SCROLL_RATE)) - { - LLVector2 cloud_scroll(oldsettings[SETTING_CLOUD_SCROLL_RATE]); - - if (oldsettings.has(SETTING_LEGACY_ENABLE_CLOUD_SCROLL)) - { - LLSD enabled = oldsettings[SETTING_LEGACY_ENABLE_CLOUD_SCROLL]; - if (!enabled[0].asBoolean()) - cloud_scroll.mV[0] = 0.0f; - if (!enabled[1].asBoolean()) - cloud_scroll.mV[1] = 0.0f; - } - - newsettings[SETTING_CLOUD_SCROLL_RATE] = cloud_scroll.getValue(); - } - if (oldsettings.has(SETTING_CLOUD_SHADOW)) - { - newsettings[SETTING_CLOUD_SHADOW] = LLSD::Real(oldsettings[SETTING_CLOUD_SHADOW][0].asReal()); - } - if (oldsettings.has(SETTING_DENSITY_MULTIPLIER)) - { - newsettings[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(oldsettings[SETTING_DENSITY_MULTIPLIER][0].asReal()); - } - if (oldsettings.has(SETTING_DISTANCE_MULTIPLIER)) - { - newsettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(oldsettings[SETTING_DISTANCE_MULTIPLIER][0].asReal()); - } - if (oldsettings.has(SETTING_GAMMA)) - { - newsettings[SETTING_GAMMA] = oldsettings[SETTING_GAMMA][0].asReal(); - } - if (oldsettings.has(SETTING_GLOW)) - { - newsettings[SETTING_GLOW] = LLColor3(oldsettings[SETTING_GLOW]).getValue(); - } - if (oldsettings.has(SETTING_HAZE_DENSITY)) - { - newsettings[SETTING_HAZE_DENSITY] = LLSD::Real(oldsettings[SETTING_HAZE_DENSITY][0].asReal()); - } - if (oldsettings.has(SETTING_HAZE_HORIZON)) - { - newsettings[SETTING_HAZE_HORIZON] = LLSD::Real(oldsettings[SETTING_HAZE_HORIZON][0].asReal()); - } - if (oldsettings.has(SETTING_LIGHT_NORMAL)) - { - newsettings[SETTING_LIGHT_NORMAL] = LLVector3(oldsettings[SETTING_LIGHT_NORMAL]).getValue(); - } - if (oldsettings.has(SETTING_MAX_Y)) - { - newsettings[SETTING_MAX_Y] = LLSD::Real(oldsettings[SETTING_MAX_Y][0].asReal()); - } - if (oldsettings.has(SETTING_STAR_BRIGHTNESS)) - { - newsettings[SETTING_STAR_BRIGHTNESS] = LLSD::Real(oldsettings[SETTING_STAR_BRIGHTNESS].asReal()); - } - if (oldsettings.has(SETTING_SUNLIGHT_COLOR)) - { - newsettings[SETTING_SUNLIGHT_COLOR] = LLColor4(oldsettings[SETTING_SUNLIGHT_COLOR]).getValue(); - } - - if (oldsettings.has(SETTING_LEGACY_EAST_ANGLE) && oldsettings.has(SETTING_LEGACY_SUN_ANGLE)) - { // convert the east and sun angles into a quaternion. - F32 azimuth = oldsettings[SETTING_LEGACY_EAST_ANGLE].asReal(); - F32 altitude = oldsettings[SETTING_LEGACY_SUN_ANGLE].asReal(); - - LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude); - LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude); - - F32 az(0), al(0); - ::angles_from_rotation(sunquat, az, al); - - newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); - newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); - } - - LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); - - if (skyp->validate()) - return skyp; - - return LLSettingsSky::ptr_t(); -} - -LLSettingsSky::ptr_t LLSettingsSky::buildDefaultSky() -{ - LLSD settings = LLSettingsSky::defaults(); - - LLSettingsSky::ptr_t skyp = boost::make_shared(settings); - if (skyp->validate()) - return skyp; - - return LLSettingsSky::ptr_t(); -} - -LLSettingsSky::ptr_t LLSettingsSky::buildClone() -{ - LLSD settings = cloneSettings(); - - LLSettingsSky::ptr_t skyp = boost::make_shared(settings); - - if (skyp->validate()) - return skyp; - - return LLSettingsSky::ptr_t(); -} - - -LLSD LLSettingsSky::defaults() -{ - LLSD dfltsetting; - - - LLQuaternion sunquat; - sunquat.setEulerAngles(1.39626, 0.0, 0.0); // 80deg Azumith/0deg East - LLQuaternion moonquat = ~sunquat; - - // Magic constants copied form dfltsetting.xml - dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue(); - dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 0.0).getValue(); - dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); - dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); - dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699); - dfltsetting[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(0.0001); - dfltsetting[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(0.8000); - dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); - dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); - dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); - dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); - dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999); - dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899); - dfltsetting[SETTING_LIGHT_NORMAL] = LLVector3(0.0000, 0.9126, -0.4086).getValue(); - dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); - dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); - dfltsetting[SETTING_NAME] = std::string("_default_"); - dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); - dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); - dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); - - dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; - dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; - dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow! - dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID; - - return dfltsetting; -} - -void LLSettingsSky::updateSettings() -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); - //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; - - // base class clears dirty flag so as to not trigger recursive update - LLSettingsBase::updateSettings(); - - calculateHeavnlyBodyPositions(); - calculateLightSettings(); -} - -void LLSettingsSky::calculateHeavnlyBodyPositions() -{ - mSunDirection = DUE_EAST * getSunRotation(); - mSunDirection.normalize(); - mMoonDirection = DUE_EAST * getMoonRotation(); - mMoonDirection.normalize(); - - { // set direction (in CRF) and don't allow overriding - LLVector3 crf_sunDirection(mSunDirection.mV[2], mSunDirection.mV[0], mSunDirection.mV[1]); - LLVector3 crf_moonDirection(mMoonDirection.mV[2], mMoonDirection.mV[0], mMoonDirection.mV[1]); - - gSky.setSunDirection(crf_sunDirection, crf_moonDirection); - } - - // is the normal from the sun or the moon - if (mSunDirection.mV[1] >= 0.0) - { - mLightDirection = mSunDirection; - } - else if (mSunDirection.mV[1] < 0.0 && mSunDirection.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) - { - // clamp v1 to 0 so sun never points up and causes weirdness on some machines - LLVector3 vec(mSunDirection); - vec.mV[1] = 0.0; - vec.normalize(); - mLightDirection = vec; - } - else - { - mLightDirection = mMoonDirection; - } - - // calculate the clamp lightnorm for sky (to prevent ugly banding in sky - // when haze goes below the horizon - mClampedLightDirection = mLightDirection; - - if (mClampedLightDirection.mV[1] < -0.1f) - { - mClampedLightDirection.mV[1] = -0.1f; - mClampedLightDirection.normalize(); - } -} - -void LLSettingsSky::calculateLightSettings() -{ - LLColor3 vary_HazeColor; - LLColor3 vary_SunlightColor; - LLColor3 vary_AmbientColor; - { - // Initialize temp variables - LLColor3 sunlight = getSunlightColor(); - LLColor3 ambient = getAmbientColor(); - F32 gamma = getGamma(); - LLColor3 blue_density = getBlueDensity(); - LLColor3 blue_horizon = getBlueHorizon(); - F32 haze_density = getHazeDensity(); - F32 haze_horizon = getHazeHorizon(); - F32 density_multiplier = getDensityMultiplier(); - F32 max_y = getMaxY(); - F32 cloud_shadow = getCloudShadow(); - LLVector3 lightnorm = getLightDirection(); - - // Sunlight attenuation effect (hue and brightness) due to atmosphere - // this is used later for sunlight modulation at various altitudes - LLColor3 light_atten = - (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); - - // Calculate relative weights - LLColor3 temp2(0.f, 0.f, 0.f); - LLColor3 temp1 = blue_density + smear(haze_density); - LLColor3 blue_weight = componentDiv(blue_density, temp1); - LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); - - // Compute sunlight from P & lightnorm (for long rays like sky) - /// USE only lightnorm. - // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); - - // and vary_sunlight will work properly with moon light - F32 lighty = lightnorm[1]; - if (lighty < LLSky::NIGHTTIME_ELEVATION_COS) - { - lighty = -lighty; - } - - temp2.mV[1] = llmax(0.f, lighty); - if(temp2.mV[1] > 0.f) - { - temp2.mV[1] = 1.f / temp2.mV[1]; - } - componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); - - // Distance - temp2.mV[2] = density_multiplier; - - // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); - - // vary_AtmosAttenuation = temp1; - - //increase ambient when there are more clouds - LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; - - //haze color - vary_HazeColor = - (blue_horizon * blue_weight * (sunlight*(1.f - cloud_shadow) + tmpAmbient) - + componentMult(haze_horizon * haze_weight, sunlight*(1.f - cloud_shadow) * temp2.mV[0] + tmpAmbient) - ); - - //brightness of surface both sunlight and ambient - vary_SunlightColor = componentMult(sunlight, temp1) * 1.f; - vary_SunlightColor.clamp(); - vary_SunlightColor = smear(1.0f) - vary_SunlightColor; - vary_SunlightColor = componentPow(vary_SunlightColor, gamma); - vary_SunlightColor = smear(1.0f) - vary_SunlightColor; - vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5; - vary_AmbientColor.clamp(); - vary_AmbientColor = smear(1.0f) - vary_AmbientColor; - vary_AmbientColor = componentPow(vary_AmbientColor, gamma); - vary_AmbientColor = smear(1.0f) - vary_AmbientColor; - - componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1); - - } - - mSunDiffuse = vary_SunlightColor; - mSunAmbient = vary_AmbientColor; - mMoonDiffuse = vary_SunlightColor; - mMoonAmbient = vary_AmbientColor; - - mTotalAmbient = LLColor4(vary_AmbientColor, 1.0f); - - mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); -} - -LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const -{ - static parammapping_t param_map; - - if (param_map.empty()) - { - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; - param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; - param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; - param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; - - param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; - param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; - param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; - param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; - param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; - param_map[SETTING_GLOW] = LLShaderMgr::GLOW; - param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; - param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; - param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; - param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; - } - - return param_map; -} - -//========================================================================= -namespace -{ - LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) - { - // Azimuth is traditionally calculated from North, we are going from East. - LLQuaternion rot_azi; - LLQuaternion rot_alt; - - rot_azi.setAngleAxis(azimuth, VECT_ZENITH); - rot_alt.setAngleAxis(-altitude, VECT_NORTHSOUTH); - - LLQuaternion body_quat = rot_alt * rot_azi; - body_quat.normalize(); - - //LLVector3 sun_vector = (DUE_EAST * body_quat); - //_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL; - return body_quat; - } - - void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude) - { - LLVector3 body_vector = (DUE_EAST * quat); - - LLVector3 body_az(body_vector[0], 0.f, body_vector[2]); - LLVector3 body_al(0.f, body_vector[1], body_vector[2]); - - if (fabs(body_az.normalize()) > 0.001) - azimuth = angle_between(DUE_EAST, body_az); - else - azimuth = 0.0f; - - if (fabs(body_al.normalize()) > 0.001) - altitude = angle_between(DUE_EAST, body_al); - else - altitude = 0.0f; - } -} - -//========================================================================= -LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): - LLSettingsSky(data) -{ -} - -LLSettingsVOSky::LLSettingsVOSky(): - LLSettingsSky() -{ -} - -void LLSettingsVOSky::applySpecial(void *ptarget) -{ - LLGLSLShader *shader = (LLGLSLShader *)ptarget; - - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); - - shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); - - { - LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); - vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); - shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); - } -} - diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h deleted file mode 100644 index 3f564d2605..0000000000 --- a/indra/newview/llsettingssky.h +++ /dev/null @@ -1,463 +0,0 @@ -/** -* @file llsettingssky.h -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#ifndef LL_SETTINGS_SKY_H -#define LL_SETTINGS_SKY_H - -#include "llsettingsbase.h" - -class LLSettingsSky: public LLSettingsBase -{ -public: - static const std::string SETTING_AMBIENT; - static const std::string SETTING_BLOOM_TEXTUREID; - static const std::string SETTING_BLUE_DENSITY; - static const std::string SETTING_BLUE_HORIZON; - static const std::string SETTING_CLOUD_COLOR; - static const std::string SETTING_CLOUD_POS_DENSITY1; - static const std::string SETTING_CLOUD_POS_DENSITY2; - static const std::string SETTING_CLOUD_SCALE; - static const std::string SETTING_CLOUD_SCROLL_RATE; - static const std::string SETTING_CLOUD_SHADOW; - static const std::string SETTING_CLOUD_TEXTUREID; - static const std::string SETTING_DENSITY_MULTIPLIER; - static const std::string SETTING_DISTANCE_MULTIPLIER; - static const std::string SETTING_DOME_OFFSET; - static const std::string SETTING_DOME_RADIUS; - static const std::string SETTING_GAMMA; - static const std::string SETTING_GLOW; - static const std::string SETTING_HAZE_DENSITY; - static const std::string SETTING_HAZE_HORIZON; - static const std::string SETTING_LIGHT_NORMAL; - 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_STAR_BRIGHTNESS; - static const std::string SETTING_SUNLIGHT_COLOR; - static const std::string SETTING_SUN_ROTATION; - static const std::string SETTING_SUN_TEXUTUREID; - - typedef boost::shared_ptr ptr_t; - typedef std::pair azimalt_t; - - //--------------------------------------------------------------------- - LLSettingsSky(const LLSD &data); - virtual ~LLSettingsSky() { }; - - static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); - static ptr_t buildDefaultSky(); - ptr_t buildClone(); - - //--------------------------------------------------------------------- - virtual std::string getSettingType() const { return std::string("sky"); } - - // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); - - static LLSD defaults(); - - //--------------------------------------------------------------------- - LLColor3 getAmbientColor() const - { - return LLColor3(mSettings[SETTING_AMBIENT]); - } - - void setAmbientColor(const LLColor3 &val) - { - setValue(SETTING_AMBIENT, val); - } - - LLUUID getBloomTextureId() const - { - return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); - } - - LLColor3 getBlueDensity() const - { - return LLColor3(mSettings[SETTING_BLUE_DENSITY]); - } - - void setBlueDensity(const LLColor3 &val) - { - setValue(SETTING_BLUE_DENSITY, val); - } - - LLColor3 getBlueHorizon() const - { - return LLColor3(mSettings[SETTING_BLUE_HORIZON]); - } - - void setBlueHorizon(const LLColor3 &val) - { - setValue(SETTING_BLUE_HORIZON, val); - } - - LLColor3 getCloudColor() const - { - return LLColor3(mSettings[SETTING_CLOUD_COLOR]); - } - - void setCloudColor(const LLColor3 &val) - { - setValue(SETTING_CLOUD_COLOR, val); - } - - LLUUID getCloudNoiseTextureId() const - { - return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); - } - - LLColor3 getCloudPosDensity1() const - { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); - } - - void setCloudPosDensity1(const LLColor3 &val) - { - setValue(SETTING_CLOUD_POS_DENSITY1, val); - } - - LLColor3 getCloudPosDensity2() const - { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); - } - - void setCloudPosDensity2(const LLColor3 &val) - { - setValue(SETTING_CLOUD_POS_DENSITY2, val); - } - - F32 getCloudScale() const - { - return mSettings[SETTING_CLOUD_SCALE].asReal(); - } - - void setCloudScale(F32 val) - { - setValue(SETTING_CLOUD_SCALE, val); - } - - LLVector2 getCloudScrollRate() const - { - return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); - } - - void setCloudScrollRate(const LLVector2 &val) - { - setValue(SETTING_CLOUD_SCROLL_RATE, val); - } - - void setCloudScrollRateX(F32 val) - { - mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; - setDirtyFlag(true); - } - - void setCloudScrollRateY(F32 val) - { - mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; - setDirtyFlag(true); - } - - F32 getCloudShadow() const - { - return mSettings[SETTING_CLOUD_SHADOW].asReal(); - } - - void setCloudShadow(F32 val) - { - setValue(SETTING_CLOUD_SHADOW, val); - } - - F32 getDensityMultiplier() const - { - return mSettings[SETTING_DENSITY_MULTIPLIER].asReal(); - } - - void setDensityMultiplier(F32 val) - { - setValue(SETTING_DENSITY_MULTIPLIER, val); - } - - F32 getDistanceMultiplier() const - { - return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal(); - } - - void setDistanceMultiplier(F32 val) - { - setValue(SETTING_DISTANCE_MULTIPLIER, val); - } - - F32 getDomeOffset() const - { - return DOME_OFFSET; - //return mSettings[SETTING_DOME_OFFSET].asReal(); - } - - F32 getDomeRadius() const - { - return DOME_RADIUS; - //return mSettings[SETTING_DOME_RADIUS].asReal(); - } - - F32 getGamma() const - { - return mSettings[SETTING_GAMMA].asReal(); - } - - void setGamma(F32 val) - { - mSettings[SETTING_GAMMA] = LLSD::Real(val); - setDirtyFlag(true); - } - - LLColor3 getGlow() const - { - return LLColor3(mSettings[SETTING_GLOW]); - } - - void setGlow(const LLColor3 &val) - { - setValue(SETTING_GLOW, val); - } - - F32 getHazeDensity() const - { - return mSettings[SETTING_HAZE_DENSITY].asReal(); - } - - void setHazeDensity(F32 val) - { - setValue(SETTING_HAZE_DENSITY, val); - } - - F32 getHazeHorizon() const - { - return mSettings[SETTING_HAZE_HORIZON].asReal(); - } - - void setHazeHorizon(F32 val) - { - setValue(SETTING_HAZE_HORIZON, val); - } - - LLVector3 getLightNormal() const - { - return LLVector3(mSettings[SETTING_LIGHT_NORMAL]); - } - - void setLightNormal(const LLVector3 &val) - { - setValue(SETTING_LIGHT_NORMAL, val); - } - - F32 getMaxY() const - { - return mSettings[SETTING_MAX_Y].asReal(); - } - - LLQuaternion getMoonRotation() const - { - return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); - } - - void setMoonRotation(const LLQuaternion &val) - { - setValue(SETTING_MOON_ROTATION, val); - } - - azimalt_t getMoonRotationAzAl() const; - - void setMoonRotation(F32 azimuth, F32 altitude); - - void setMoonRotation(const azimalt_t &azialt) - { - setMoonRotation(azialt.first, azialt.second); - } - - LLUUID getMoonTextureId() const - { - return mSettings[SETTING_MOON_TEXTUREID].asUUID(); - } - - F32 getStarBrightness() const - { - return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); - } - - void setStarBrightness(F32 val) - { - setValue(SETTING_STAR_BRIGHTNESS, val); - } - - LLColor3 getSunlightColor() const - { - return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); - } - - void setSunlightColor(const LLColor3 &val) - { - setValue(SETTING_SUNLIGHT_COLOR, val); - } - - LLQuaternion getSunRotation() const - { - return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); - } - - azimalt_t getSunRotationAzAl() const; - - void setSunRotation(const LLQuaternion &val) - { - setValue(SETTING_SUN_ROTATION, val); - } - - void setSunRotation(F32 azimuth, F32 altitude); - - void setSunRotation(const azimalt_t & azimalt) - { - setSunRotation(azimalt.first, azimalt.second); - } - - LLUUID getSunTextureId() const - { - return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); - } - - // Internal/calculated settings - LLVector3 getLightDirection() const - { - update(); - return mLightDirection; - }; - - LLVector3 getClampedLightDirection() const - { - update(); - return mClampedLightDirection; - }; - - LLVector3 getSunDirection() const - { - update(); - return mSunDirection; - } - - LLVector3 getMoonDirection() const - { - update(); - return mMoonDirection; - } - - LLColor4U getFadeColor() const - { - update(); - return mFadeColor; - } - - LLColor4 getMoonAmbient() const - { - update(); - return mMoonAmbient; - } - - LLColor3 getMoonDiffuse() const - { - update(); - return mMoonDiffuse; - } - - LLColor4 getSunAmbient() const - { - update(); - return mSunAmbient; - } - - LLColor3 getSunDiffuse() const - { - update(); - return mSunDiffuse; - } - - LLColor4 getTotalAmbient() const - { - update(); - return mTotalAmbient; - } - -protected: - LLSettingsSky(); - - virtual stringset_t getSlerpKeys() const; - - virtual validation_list_t getValidationList() const; - - virtual void updateSettings(); - - virtual parammapping_t getParameterMap() const; - -private: - static const std::string SETTING_LEGACY_EAST_ANGLE; - static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; - static const std::string SETTING_LEGACY_SUN_ANGLE; - - void calculateHeavnlyBodyPositions(); - void calculateLightSettings(); - - LLVector3 mSunDirection; - LLVector3 mMoonDirection; - LLVector3 mLightDirection; - LLVector3 mClampedLightDirection; - - static const F32 DOME_RADIUS; - static const F32 DOME_OFFSET; - - LLColor4U mFadeColor; - LLColor4 mMoonAmbient; - LLColor3 mMoonDiffuse; - LLColor4 mSunAmbient; - LLColor3 mSunDiffuse; - - LLColor4 mTotalAmbient; - - typedef std::map mapNameToUniformId_t; - - static mapNameToUniformId_t sNameToUniformMapping; -}; - -class LLSettingsVOSky : public LLSettingsSky -{ -public: - LLSettingsVOSky(const LLSD &data); -protected: - LLSettingsVOSky(); - - virtual void applySpecial(void *); -}; - -#endif diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp new file mode 100644 index 0000000000..76a6754573 --- /dev/null +++ b/indra/newview/llsettingsvo.cpp @@ -0,0 +1,420 @@ +/** +* @file llsettingsvo.cpp +* @author Rider Linden +* @brief Subclasses for viewer specific settings behaviors. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llviewercontrol.h" +#include "llsettingsvo.h" + +#include "pipeline.h" + +#include +#include +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +#include "llglslshader.h" +#include "llviewershadermgr.h" + +#include "llenvironment.h" +#include "llsky.h" + +//========================================================================= +LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): + LLSettingsSky(data) +{ +} + +LLSettingsVOSky::LLSettingsVOSky(): + LLSettingsSky() +{ +} + +//------------------------------------------------------------------------- +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +{ + + LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); + + newsettings[SETTING_NAME] = name; + + LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() +{ + LLSD settings = LLSettingsSky::defaults(); + settings[SETTING_NAME] = std::string("_default_"); + + + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +//------------------------------------------------------------------------- +void LLSettingsVOSky::updateSettings() +{ + LLSettingsSky::updateSettings(); + + LLVector3 sun_direction = getSunDirection(); + LLVector3 moon_direction = getMoonDirection(); + + // set direction (in CRF) and don't allow overriding + LLVector3 crf_sunDirection(sun_direction.mV[2], sun_direction.mV[0], sun_direction.mV[1]); + LLVector3 crf_moonDirection(moon_direction.mV[2], moon_direction.mV[0], moon_direction.mV[1]); + + gSky.setSunDirection(crf_sunDirection, crf_moonDirection); +} + +void LLSettingsVOSky::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); + + shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); + + { + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + } +} + +LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { + param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; + param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; + param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; + param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; + + param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; + param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; + param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; + param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; + param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; + param_map[SETTING_GLOW] = LLShaderMgr::GLOW; + param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; + param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; + param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; + param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; + } + + return param_map; +} + +//========================================================================= +const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f); + +//------------------------------------------------------------------------- +LLSettingsVOWater::LLSettingsVOWater(const LLSD &data) : + LLSettingsWater(data) +{ + +} + +LLSettingsVOWater::LLSettingsVOWater() : + LLSettingsWater() +{ + +} + +//------------------------------------------------------------------------- +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) +{ + LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy)); + + newsettings[SETTING_NAME] = name; + + LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() +{ + LLSD settings = LLSettingsWater::defaults(); + settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +//------------------------------------------------------------------------- +void LLSettingsVOWater::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); + shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); +} + +void LLSettingsVOWater::updateSettings() +{ + // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); + // LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; + + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + // only do this if we're dealing with shaders + if (gPipeline.canUseVertexShaders()) + { + //transform water plane to eye space + glh::vec3f norm(0.f, 0.f, 1.f); + glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); + + F32 modelView[16]; + for (U32 i = 0; i < 16; i++) + { + modelView[i] = (F32)gGLModelView[i]; + } + + glh::matrix4f mat(modelView); + glh::matrix4f invtrans = mat.inverse().transpose(); + glh::vec3f enorm; + glh::vec3f ep; + invtrans.mult_matrix_vec(norm, enorm); + enorm.normalize(); + mat.mult_matrix_vec(p, ep); + + mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + + LLVector4 light_direction = LLEnvironment::instance().getLightDirection(); + + mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); + } +} + +LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { + param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; + param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; + } + return param_map; +} + +//========================================================================= +LLSettingsVODay::LLSettingsVODay(const LLSD &data): + LLSettingsDay(data) +{} + +LLSettingsVODay::LLSettingsVODay(): + LLSettingsDay() +{} + +//------------------------------------------------------------------------- +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +{ + LLSD newsettings(defaults()); + + newsettings[SETTING_NAME] = name; + newsettings[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); + + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, "Default")); + + LLSD skytrack = LLSD::emptyArray(); + + for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) + { + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, (*it)[1].asString()); + skytrack.append(entry); + } + + newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); + + LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); + + if (dayp->validate()) + { + dayp->initialize(); + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) +{ + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset("Region", waterdef); + LLEnvironment::namedSettingMap_t skys; + + for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) + { + std::string name = (*itm).first; + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, (*itm).second); + + skys[name] = sky; + LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; + } + + LLSettingsDay::ptr_t dayp = buildFromLegacyPreset("Region (legacy)", daycycle); + + dayp->setWaterAtKeyframe(water, 0.0f); + + for (LLSD::array_iterator ita = daycycle.beginArray(); ita != daycycle.endArray(); ++ita) + { + F32 frame = (*ita)[0].asReal(); + std::string name = (*ita)[1].asString(); + + LLEnvironment::namedSettingMap_t::iterator it = skys.find(name); + + if (it == skys.end()) + continue; + dayp->setSkyAtKeyframe(boost::static_pointer_cast((*it).second), frame, 1); + + LL_WARNS("WindlightCaps") << "Added '" << name << "' to region day cycle at " << frame << LL_ENDL; + } + + dayp->setInitialized(); + + if (dayp->validate()) + { + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() +{ + LLSD settings = LLSettingsDay::defaults(); + settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + if (dayp->validate()) + { + dayp->initialize(); + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + return dayp; +} + +LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const +{ + return LLSettingsVOSky::buildDefaultSky(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::getDefaultWater() const +{ + return LLSettingsVOWater::buildDefaultWater(); +} + +LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const +{ + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const +{ + LLSettingsWater::ptr_t waterp = boost::make_shared(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +LLSettingsSkyPtr_t LLSettingsVODay::getNamedSky(const std::string &name) const +{ + return LLEnvironment::instance().findSkyByName(name); +} + +LLSettingsWaterPtr_t LLSettingsVODay::getNamedWater(const std::string &name) const +{ + return LLEnvironment::instance().findWaterByName(name); +} diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h new file mode 100644 index 0000000000..6ef7290ba4 --- /dev/null +++ b/indra/newview/llsettingsvo.h @@ -0,0 +1,103 @@ +/** +* @file llsettingsvo.h +* @author Rider Linden +* @brief Subclasses for viewer specific settings behaviors. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_VO_H +#define LL_SETTINGS_VO_H + +#include "llsettingsbase.h" +#include "llsettingssky.h" +#include "llsettingswater.h" +#include "llsettingsdaycycle.h" + +class LLSettingsVOSky : public LLSettingsSky +{ +public: + LLSettingsVOSky(const LLSD &data); + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildDefaultSky(); + virtual ptr_t buildClone(); + +protected: + LLSettingsVOSky(); + + virtual void updateSettings(); + + virtual void applySpecial(void *); + + virtual parammapping_t getParameterMap() const; + +}; + +//========================================================================= +class LLSettingsVOWater : public LLSettingsWater +{ +public: + LLSettingsVOWater(const LLSD &data); + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildDefaultWater(); + virtual ptr_t buildClone(); + +protected: + LLSettingsVOWater(); + + virtual void updateSettings(); + virtual void applySpecial(void *); + + virtual parammapping_t getParameterMap() const; + + +private: + static const F32 WATER_FOG_LIGHT_CLAMP; + +}; + +//========================================================================= +class LLSettingsVODay : public LLSettingsDay +{ +public: + LLSettingsVODay(const LLSD &data); + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); + static ptr_t buildDefaultDayCycle(); + virtual ptr_t buildClone(); + + virtual LLSettingsSkyPtr_t getDefaultSky() const; + virtual LLSettingsWaterPtr_t getDefaultWater() const; + virtual LLSettingsSkyPtr_t buildSky(LLSD) const; + virtual LLSettingsWaterPtr_t buildWater(LLSD) const; + virtual LLSettingsSkyPtr_t getNamedSky(const std::string &) const; + virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const; + +protected: + LLSettingsVODay(); +}; + + +#endif diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp deleted file mode 100644 index caf7a4b7cc..0000000000 --- a/indra/newview/llsettingswater.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/** -* @file llsettingswater.h -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" -#include "llviewercontrol.h" -#include "llsettingswater.h" -#include -#include -#include "lltrace.h" -#include "llfasttimer.h" -#include "v3colorutil.h" - -#include "llglslshader.h" -#include "llviewershadermgr.h" - -#include "llenvironment.h" - -#include "llagent.h" -#include "pipeline.h" - -//========================================================================= -namespace -{ - LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); - LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); -} - -//========================================================================= -const std::string LLSettingsWater::SETTING_BLUR_MULTIPILER("blur_multiplier"); -const std::string LLSettingsWater::SETTING_FOG_COLOR("water_fog_color"); -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_NORMAL_MAP("normal_map"); -const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale"); -const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above"); -const std::string LLSettingsWater::SETTING_SCALE_BELOW("scale_below"); -const std::string LLSettingsWater::SETTING_WAVE1_DIR("wave1_direction"); -const std::string LLSettingsWater::SETTING_WAVE2_DIR("wave2_direction"); - -const std::string LLSettingsWater::SETTING_LEGACY_BLUR_MULTIPILER("blurMultiplier"); -const std::string LLSettingsWater::SETTING_LEGACY_FOG_COLOR("waterFogColor"); -const std::string LLSettingsWater::SETTING_LEGACY_FOG_DENSITY("waterFogDensity"); -const std::string LLSettingsWater::SETTING_LEGACY_FOG_MOD("underWaterFogMod"); -const std::string LLSettingsWater::SETTING_LEGACY_FRESNEL_OFFSET("fresnelOffset"); -const std::string LLSettingsWater::SETTING_LEGACY_FRESNEL_SCALE("fresnelScale"); -const std::string LLSettingsWater::SETTING_LEGACY_NORMAL_MAP("normalMap"); -const std::string LLSettingsWater::SETTING_LEGACY_NORMAL_SCALE("normScale"); -const std::string LLSettingsWater::SETTING_LEGACY_SCALE_ABOVE("scaleAbove"); -const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow"); -const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir"); -const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); - -const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL); - - -//========================================================================= -LLSettingsWater::LLSettingsWater(const LLSD &data) : - LLSettingsBase(data) -{ -} - -LLSettingsWater::LLSettingsWater() : - LLSettingsBase() -{ -} - -//========================================================================= -LLSD LLSettingsWater::defaults() -{ - LLSD dfltsetting; - - // Magic constants copied form defaults.xml - dfltsetting[SETTING_BLUR_MULTIPILER] = LLSD::Real(0.04000f); - dfltsetting[SETTING_FOG_COLOR] = LLColor3(0.0156f, 0.1490f, 0.2509f).getValue(); - dfltsetting[SETTING_FOG_DENSITY] = LLSD::Real(2.0f); - dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); - dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); - dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); - dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL_ID); - dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue(); - dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); - dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); - dfltsetting[SETTING_WAVE1_DIR] = LLVector2(1.04999f, -0.42000f).getValue(); - dfltsetting[SETTING_WAVE2_DIR] = LLVector2(1.10999f, -1.16000f).getValue(); - - return dfltsetting; -} - -LLSettingsWater::ptr_t LLSettingsWater::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) -{ - LLSD newsettings(defaults()); - - newsettings[SETTING_NAME] = name; - - - if (oldsettings.has(SETTING_LEGACY_BLUR_MULTIPILER)) - { - newsettings[SETTING_BLUR_MULTIPILER] = LLSD::Real(oldsettings[SETTING_LEGACY_BLUR_MULTIPILER].asReal()); - } - if (oldsettings.has(SETTING_LEGACY_FOG_COLOR)) - { - newsettings[SETTING_FOG_COLOR] = LLColor3(oldsettings[SETTING_LEGACY_FOG_COLOR]).getValue(); - } - if (oldsettings.has(SETTING_LEGACY_FOG_DENSITY)) - { - newsettings[SETTING_FOG_DENSITY] = LLSD::Real(oldsettings[SETTING_LEGACY_FOG_DENSITY]); - } - if (oldsettings.has(SETTING_LEGACY_FOG_MOD)) - { - newsettings[SETTING_FOG_MOD] = LLSD::Real(oldsettings[SETTING_LEGACY_FOG_MOD].asReal()); - } - if (oldsettings.has(SETTING_LEGACY_FRESNEL_OFFSET)) - { - newsettings[SETTING_FRESNEL_OFFSET] = LLSD::Real(oldsettings[SETTING_LEGACY_FRESNEL_OFFSET].asReal()); - } - if (oldsettings.has(SETTING_LEGACY_FRESNEL_SCALE)) - { - newsettings[SETTING_FRESNEL_SCALE] = LLSD::Real(oldsettings[SETTING_LEGACY_FRESNEL_SCALE].asReal()); - } - if (oldsettings.has(SETTING_LEGACY_NORMAL_MAP)) - { - newsettings[SETTING_NORMAL_MAP] = LLSD::UUID(oldsettings[SETTING_LEGACY_NORMAL_MAP].asUUID()); - } - if (oldsettings.has(SETTING_LEGACY_NORMAL_SCALE)) - { - newsettings[SETTING_NORMAL_SCALE] = LLVector3(oldsettings[SETTING_LEGACY_NORMAL_SCALE]).getValue(); - } - if (oldsettings.has(SETTING_LEGACY_SCALE_ABOVE)) - { - newsettings[SETTING_SCALE_ABOVE] = LLSD::Real(oldsettings[SETTING_LEGACY_SCALE_ABOVE].asReal()); - } - if (oldsettings.has(SETTING_LEGACY_SCALE_BELOW)) - { - newsettings[SETTING_SCALE_BELOW] = LLSD::Real(oldsettings[SETTING_LEGACY_SCALE_BELOW].asReal()); - } - if (oldsettings.has(SETTING_LEGACY_WAVE1_DIR)) - { - newsettings[SETTING_WAVE1_DIR] = LLVector2(oldsettings[SETTING_LEGACY_WAVE1_DIR]).getValue(); - } - if (oldsettings.has(SETTING_LEGACY_WAVE2_DIR)) - { - newsettings[SETTING_WAVE2_DIR] = LLVector2(oldsettings[SETTING_LEGACY_WAVE2_DIR]).getValue(); - } - - LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); - - if (waterp->validate()) - return waterp; - - return LLSettingsWater::ptr_t(); -} - -LLSettingsWater::ptr_t LLSettingsWater::buildDefaultWater() -{ - LLSD settings = LLSettingsWater::defaults(); - - LLSettingsWater::ptr_t waterp = boost::make_shared(settings); - - if (waterp->validate()) - return waterp; - - return LLSettingsWater::ptr_t(); -} - -LLSettingsWater::ptr_t LLSettingsWater::buildClone() -{ - LLSD settings = cloneSettings(); - - LLSettingsWater::ptr_t waterp = boost::make_shared(settings); - - if (waterp->validate()) - return waterp; - - return LLSettingsWater::ptr_t(); -} - -void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) -{ - LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); - - replaceSettings(blenddata); -} - -LLSettingsWater::validation_list_t LLSettingsWater::getValidationList() const -{ - static validation_list_t validation; - - if (validation.empty()) - { // Note the use of LLSD(LLSDArray()()()...) This is due to an issue with the - // copy constructor for LLSDArray. Directly binding the LLSDArray as - // a parameter without first wrapping it in a pure LLSD object will result - // in deeply nested arrays like this [[[[[[[[[[v1,v2,v3]]]]]]]]]] - - validation.push_back(Validator(SETTING_BLUR_MULTIPILER, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.16f))))); - validation.push_back(Validator(SETTING_FOG_COLOR, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)(1.0f)), - LLSD(LLSDArray(1.0f)(1.0f)(1.0f)(1.0f))))); - validation.push_back(Validator(SETTING_FOG_DENSITY, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1.0f)(1024.0f))))); - validation.push_back(Validator(SETTING_FOG_MOD, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1.0f)(1024.0f))))); - validation.push_back(Validator(SETTING_FRESNEL_OFFSET, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_FRESNEL_SCALE, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_NORMAL_MAP, true, LLSD::TypeUUID)); - validation.push_back(Validator(SETTING_NORMAL_SCALE, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(0.0f)(0.0f)(0.0f)), - LLSD(LLSDArray(10.0f)(10.0f)(10.0f))))); - validation.push_back(Validator(SETTING_SCALE_ABOVE, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_SCALE_BELOW, true, LLSD::TypeReal, - boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); - validation.push_back(Validator(SETTING_WAVE1_DIR, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(-4.0f)(-4.0f)), - LLSD(LLSDArray(4.0f)(4.0f))))); - validation.push_back(Validator(SETTING_WAVE2_DIR, true, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorMinMax, _1, - LLSD(LLSDArray(-4.0f)(-4.0f)), - LLSD(LLSDArray(4.0f)(4.0f))))); - } - - return validation; -} - -//========================================================================= - -LLSettingsWater::parammapping_t LLSettingsWater::getParameterMap() const -{ - static parammapping_t param_map; - - if (param_map.empty()) - { - param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; - param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; - - - } - return param_map; -} - -//========================================================================= -const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f); - -//========================================================================= -LLSettingsVOWater::LLSettingsVOWater(const LLSD &data): - LLSettingsWater(data) -{ - -} - -LLSettingsVOWater::LLSettingsVOWater() : - LLSettingsWater() -{ - -} - -void LLSettingsVOWater::applySpecial(void *ptarget) -{ - LLGLSLShader *shader = (LLGLSLShader *)ptarget; - - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); - shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); - - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); - - -} - -void LLSettingsVOWater::updateSettings() -{ - // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); - // LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; - - // base class clears dirty flag so as to not trigger recursive update - LLSettingsBase::updateSettings(); - - // only do this if we're dealing with shaders - if (gPipeline.canUseVertexShaders()) - { - //transform water plane to eye space - glh::vec3f norm(0.f, 0.f, 1.f); - glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); - - F32 modelView[16]; - for (U32 i = 0; i < 16; i++) - { - modelView[i] = (F32)gGLModelView[i]; - } - - glh::matrix4f mat(modelView); - glh::matrix4f invtrans = mat.inverse().transpose(); - glh::vec3f enorm; - glh::vec3f ep; - invtrans.mult_matrix_vec(norm, enorm); - enorm.normalize(); - mat.mult_matrix_vec(p, ep); - - mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); - - LLVector4 light_direction = LLEnvironment::instance().getLightDirection(); - - mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); - } - -} - diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h deleted file mode 100644 index aa60861bd4..0000000000 --- a/indra/newview/llsettingswater.h +++ /dev/null @@ -1,243 +0,0 @@ -/** -* @file llsettingssky.h -* @author optional -* @brief A base class for asset based settings groups. -* -* $LicenseInfo:2011&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2017, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#ifndef LL_SETTINGS_WATER_H -#define LL_SETTINGS_WATER_H - -#include "llsettingsbase.h" - -class LLSettingsWater : public LLSettingsBase -{ -public: - static const std::string SETTING_BLUR_MULTIPILER; - static const std::string SETTING_FOG_COLOR; - static const std::string SETTING_FOG_DENSITY; - 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_NORMAL_MAP; - static const std::string SETTING_NORMAL_SCALE; - static const std::string SETTING_SCALE_ABOVE; - static const std::string SETTING_SCALE_BELOW; - static const std::string SETTING_WAVE1_DIR; - static const std::string SETTING_WAVE2_DIR; - - static const LLUUID DEFAULT_WATER_NORMAL_ID; - - typedef boost::shared_ptr ptr_t; - - //--------------------------------------------------------------------- - LLSettingsWater(const LLSD &data); - virtual ~LLSettingsWater() { }; - - static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); - static ptr_t buildDefaultWater(); - ptr_t buildClone(); - - //--------------------------------------------------------------------- - virtual std::string getSettingType() const { return std::string("water"); } - - // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); - - static LLSD defaults(); - - //--------------------------------------------------------------------- - F32 getBlurMultiplier() const - { - return mSettings[SETTING_BLUR_MULTIPILER].asReal(); - } - - void setBlurMultiplier(F32 val) - { - setValue(SETTING_BLUR_MULTIPILER, val); - } - - LLColor3 getFogColor() const - { - return LLColor3(mSettings[SETTING_FOG_COLOR]); - } - - void setFogColor(LLColor3 val) - { - setValue(SETTING_FOG_COLOR, val); - } - - F32 getFogDensity() const - { - return mSettings[SETTING_FOG_DENSITY].asReal(); - } - - void setFogDensity(F32 val) - { - setValue(SETTING_FOG_DENSITY, val); - } - - F32 getFogMod() const - { - return mSettings[SETTING_FOG_MOD].asReal(); - } - - void setFogMod(F32 val) - { - setValue(SETTING_FOG_MOD, val); - } - - F32 getFresnelOffset() const - { - return mSettings[SETTING_FRESNEL_OFFSET].asReal(); - } - - void setFresnelOffset(F32 val) - { - setValue(SETTING_FRESNEL_OFFSET, val); - } - - F32 getFresnelScale() const - { - return mSettings[SETTING_FRESNEL_SCALE].asReal(); - } - - void setFresnelScale(F32 val) - { - setValue(SETTING_FRESNEL_SCALE, val); - } - - LLUUID getNormalMapID() const - { - return mSettings[SETTING_NORMAL_MAP].asUUID(); - } - - void setNormalMapID(LLUUID val) - { - setValue(SETTING_NORMAL_MAP, val); - } - - LLVector3 getNormalScale() const - { - return LLVector3(mSettings[SETTING_NORMAL_SCALE]); - } - - void setNormalScale(LLVector3 val) - { - setValue(SETTING_NORMAL_SCALE, val); - } - - F32 getScaleAbove() const - { - return mSettings[SETTING_SCALE_ABOVE].asReal(); - } - - void setScaleAbove(F32 val) - { - setValue(SETTING_SCALE_ABOVE, val); - } - - F32 getScaleBelow() const - { - return mSettings[SETTING_SCALE_BELOW].asReal(); - } - - void setScaleBelow(F32 val) - { - setValue(SETTING_SCALE_BELOW, val); - } - - LLVector2 getWave1Dir() const - { - return LLVector2(mSettings[SETTING_WAVE1_DIR]); - } - - void setWave1Dir(LLVector2 val) - { - setValue(SETTING_WAVE1_DIR, val); - } - - LLVector2 getWave2Dir() const - { - return LLVector2(mSettings[SETTING_WAVE2_DIR]); - } - - void setWave2Dir(LLVector2 val) - { - setValue(SETTING_WAVE2_DIR, val); - } - - //------------------------------------------- - LLVector4 getWaterPlane() const - { - update(); - return mWaterPlane; - } - - F32 getWaterFogKS() const - { - update(); - return mWaterFogKS; - } - -protected: - LLSettingsWater(); - - virtual parammapping_t getParameterMap() const; - - virtual validation_list_t getValidationList() const; - - LLVector4 mWaterPlane; - F32 mWaterFogKS; -private: - static const std::string SETTING_LEGACY_BLUR_MULTIPILER; - static const std::string SETTING_LEGACY_FOG_COLOR; - static const std::string SETTING_LEGACY_FOG_DENSITY; - static const std::string SETTING_LEGACY_FOG_MOD; - static const std::string SETTING_LEGACY_FRESNEL_OFFSET; - static const std::string SETTING_LEGACY_FRESNEL_SCALE; - static const std::string SETTING_LEGACY_NORMAL_MAP; - static const std::string SETTING_LEGACY_NORMAL_SCALE; - static const std::string SETTING_LEGACY_SCALE_ABOVE; - static const std::string SETTING_LEGACY_SCALE_BELOW; - static const std::string SETTING_LEGACY_WAVE1_DIR; - static const std::string SETTING_LEGACY_WAVE2_DIR; -}; - -class LLSettingsVOWater : public LLSettingsWater -{ -public: - LLSettingsVOWater(const LLSD &data); - -protected: - LLSettingsVOWater(); - - virtual void updateSettings(); - virtual void applySpecial(void *); - -private: - static const F32 WATER_FOG_LIGHT_CLAMP; - -}; - -#endif -- cgit v1.3 From 8211f57205f0008d8ffb9bfcd465ca26d906e19c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 8 Jan 2018 15:10:25 -0800 Subject: MAINT-7699: Deliver new settings to viewer via cap --- indra/llinventory/llsettingsbase.cpp | 16 +- indra/llinventory/llsettingsbase.h | 39 +++-- indra/llinventory/llsettingsdaycycle.cpp | 41 +++-- indra/llinventory/llsettingsdaycycle.h | 28 +++- indra/llinventory/llsettingssky.cpp | 2 +- indra/llinventory/llsettingssky.h | 10 +- indra/llinventory/llsettingswater.cpp | 2 +- indra/llinventory/llsettingswater.h | 23 +-- indra/newview/llenvironment.cpp | 270 ++++++++++++++++++++++++++++++- indra/newview/llenvironment.h | 20 +++ indra/newview/llsettingsvo.cpp | 185 +++++++++++++++++++++ indra/newview/llsettingsvo.h | 5 + indra/newview/llviewerregion.cpp | 1 + indra/newview/llwlhandlers.cpp | 4 +- indra/newview/llwlhandlers.h | 2 + 15 files changed, 585 insertions(+), 63 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index e4291d8080..30b1d66634 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -35,7 +35,7 @@ //========================================================================= namespace { - const F32 BREAK_POINT = 0.5; + const F64 BREAK_POINT = 0.5; } //========================================================================= @@ -44,7 +44,7 @@ const std::string LLSettingsBase::SETTING_NAME("name"); const std::string LLSettingsBase::SETTING_HASH("hash"); const std::string LLSettingsBase::SETTING_TYPE("type"); -const F32Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); +const F64Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); //========================================================================= LLSettingsBase::LLSettingsBase(): @@ -60,7 +60,7 @@ LLSettingsBase::LLSettingsBase(const LLSD setting) : } //========================================================================= -void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F32 mix) +void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix) { mSettings = interpolateSDMap(mSettings, other.mSettings, mix); setDirtyFlag(true); @@ -140,7 +140,7 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons return newSettings; } -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const { LLSD newSettings; @@ -535,9 +535,9 @@ bool LLSettingsBase::Validator::verifyQuaternionNormal(LLSD &value) bool LLSettingsBase::Validator::verifyFloatRange(LLSD &value, LLSD range) { - F32 real = value.asReal(); + F64 real = value.asReal(); - F32 clampedval = llclamp(LLSD::Real(real), range[0].asReal(), range[1].asReal()); + F64 clampedval = llclamp(LLSD::Real(real), range[0].asReal(), range[1].asReal()); if (is_approx_equal(clampedval, real)) return true; @@ -561,7 +561,7 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) //========================================================================= -void LLSettingsBlender::update(F32Seconds timedelta) +void LLSettingsBlender::update(F64Seconds timedelta) { mTimeSpent += timedelta; @@ -573,7 +573,7 @@ void LLSettingsBlender::update(F32Seconds timedelta) return; } - F32 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); + F64 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); mTarget->replaceSettings(mInitial->getSettings()); mTarget->blend(mFinal, blendf); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 2b59a103ad..0a20754ffb 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -151,7 +151,7 @@ public: (const_cast(this))->updateSettings(); } - virtual void blend(const ptr_t &end, F32 blendf) = 0; + virtual void blend(const ptr_t &end, F64 blendf) = 0; virtual bool validate(); @@ -198,8 +198,8 @@ protected: typedef std::set stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, F32 mix); - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const; + virtual void lerpSettings(const LLSettingsBase &other, F64 mix); + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const; /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -240,10 +240,10 @@ public: typedef boost::signals2::signal finish_signal_t; typedef boost::signals2::connection connection_t; - static const F32Seconds DEFAULT_THRESHOLD; + static const F64Seconds DEFAULT_THRESHOLD; LLSettingsBlender(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F32Seconds seconds) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) : mTarget(target), mInitial(initsetting), mFinal(endsetting), @@ -254,23 +254,34 @@ public: mTimeSpent(0.0f) { mTarget->replaceSettings(mInitial->getSettings()); - mTimeStart = F32Seconds(LLDate::now().secondsSinceEpoch()); + mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; } ~LLSettingsBlender() {} + void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 seconds ) + { + mInitial = initsetting; + mFinal = endsetting; + mSeconds.value(seconds); + mTarget->replaceSettings(mInitial->getSettings()); + mTimeStart.value(LLDate::now().secondsSinceEpoch()); + mLastUpdate = mTimeStart; + mTimeSpent.value(0.0f); + } + connection_t setOnFinished(const finish_signal_t::slot_type &onfinished) { return mOnFinished.connect(onfinished); } - void setUpdateThreshold(F32Seconds threshold) + void setUpdateThreshold(F64Seconds threshold) { mBlendThreshold = threshold; } - F32Seconds getUpdateThreshold() const + F64Seconds getUpdateThreshold() const { return mBlendThreshold; } @@ -290,17 +301,17 @@ public: return mFinal; } - void update(F32Seconds time); + void update(F64Seconds time); private: LLSettingsBase::ptr_t mTarget; LLSettingsBase::ptr_t mInitial; LLSettingsBase::ptr_t mFinal; - F32Seconds mSeconds; + F64Seconds mSeconds; finish_signal_t mOnFinished; - F32Seconds mBlendThreshold; - F32Seconds mLastUpdate; - F32Seconds mTimeSpent; - F32Seconds mTimeStart; + F64Seconds mBlendThreshold; + F64Seconds mLastUpdate; + F64Seconds mTimeSpent; + F64Seconds mTimeStart; }; #endif diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 687210e127..180992cd29 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -104,11 +104,14 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash"); const std::string LLSettingsDay::SETTING_TRACKS("tracks"); const std::string LLSettingsDay::SETTING_FRAMES("frames"); -const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins - -//const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins +const S64 LLSettingsDay::DEFAULT_DAYLENGTH( 14400); // 4 hours const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days +const S32 LLSettingsDay::MINIMUM_DAYOFFSET( 0); +const S32 LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) +const S32 LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours + const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water const S32 LLSettingsDay::FRAME_MAX(56); @@ -116,14 +119,18 @@ const S32 LLSettingsDay::FRAME_MAX(56); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), - mInitialized(false) + mInitialized(false), + mDayLength(DEFAULT_DAYLENGTH), + mDayOffset(DEFAULT_DAYOFFSET) { mDayTracks.resize(TRACK_MAX); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false) + mInitialized(false), + mDayLength(DEFAULT_DAYLENGTH), + mDayOffset(DEFAULT_DAYOFFSET) { mDayTracks.resize(TRACK_MAX); } @@ -266,7 +273,7 @@ LLSD LLSettingsDay::defaults() return dfltsetting; } -void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F32 mix) +void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F64 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; } @@ -337,19 +344,30 @@ LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const return validation; } +LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track) +{ + static CycleTrack_t emptyTrack; + if (mDayTracks.size() <= track) + return emptyTrack; + + return mDayTracks[track]; +} + //========================================================================= F32 LLSettingsDay::secondsToKeyframe(S64Seconds seconds) { S64Seconds daylength = getDayLength(); + S64Seconds dayoffset = getDayOffset(); - return llclamp(static_cast(seconds.value() % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); + return llclamp(static_cast((seconds.value() + dayoffset.value()) % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); } F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe) { S64Seconds daylength = getDayLength(); + S64Seconds dayoffset = getDayOffset(); - return F64Seconds(static_cast(keyframe * static_cast(daylength.value()))); + return F64Seconds(static_cast(keyframe * static_cast(daylength.value())) - dayoffset.value()); } //========================================================================= @@ -424,13 +442,6 @@ void LLSettingsDay::updateSettings() } //========================================================================= -void LLSettingsDay::setDayLength(S64Seconds seconds) -{ - S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); - - setValue(SETTING_DAYLENGTH, val); -} - LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) { if ((trackno < 1) || (trackno >= TRACK_MAX)) diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 3b24ce9f97..ae47a54270 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -48,8 +48,13 @@ public: static const std::string SETTING_FRAMES; static const S64 MINIMUM_DAYLENGTH; + static const S64 DEFAULT_DAYLENGTH; static const S64 MAXIMUM_DAYLENGTH; + static const S32 MINIMUM_DAYOFFSET; + static const S32 DEFAULT_DAYOFFSET; + static const S32 MAXIMUM_DAYOFFSET; + static const S32 TRACK_WATER; static const S32 TRACK_MAX; static const S32 FRAME_MAX; @@ -74,17 +79,30 @@ public: virtual std::string getSettingType() const { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix); + virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix); static LLSD defaults(); //--------------------------------------------------------------------- S64Seconds getDayLength() const { - return S64Seconds(mSettings[SETTING_DAYLENGTH].asInteger()); + return mDayLength; + } + + void setDayLength(S64Seconds seconds) + { + mDayLength = seconds; + } + + S64Seconds getDayOffset() const + { + return mDayOffset; } - void setDayLength(S64Seconds seconds); + void setDayOffset(S64Seconds seconds) + { + mDayOffset = seconds; + } KeyframeList_t getTrackKeyframes(S32 track); TimeList_t getTrackTimes(S32 track); @@ -117,6 +135,7 @@ public: virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const = 0; void setInitialized(bool value = true) { mInitialized = value; } + CycleTrack_t & getCycleTrack(S32 track); protected: LLSettingsDay(); @@ -137,6 +156,9 @@ private: F64Seconds mLastUpdateTime; + S64Seconds mDayLength; + S64Seconds mDayOffset; + F32 secondsToKeyframe(S64Seconds seconds); F64Seconds keyframeToSeconds(F32 keyframe); diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index ecc89165e8..7fc9d83cae 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -96,7 +96,7 @@ LLSettingsSky::LLSettingsSky(): { } -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index ff4b62f86e..12ea237ef3 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -75,7 +75,7 @@ public: virtual std::string getSettingType() const { return std::string("sky"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf); static LLSD defaults(); @@ -410,6 +410,10 @@ public: } protected: + static const std::string SETTING_LEGACY_EAST_ANGLE; + static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; + static const std::string SETTING_LEGACY_SUN_ANGLE; + LLSettingsSky(); virtual stringset_t getSlerpKeys() const; @@ -421,10 +425,6 @@ protected: static LLSD translateLegacySettings(LLSD legacy); private: - static const std::string SETTING_LEGACY_EAST_ANGLE; - static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; - static const std::string SETTING_LEGACY_SUN_ANGLE; - static const F32 NIGHTTIME_ELEVATION; static const F32 NIGHTTIME_ELEVATION_COS; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 1b960746d5..00f870bbb0 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -159,7 +159,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) return newsettings; } -void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) +void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 5d6a482d56..d18caf68b1 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -60,7 +60,7 @@ public: virtual std::string getSettingType() const { return std::string("water"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf); static LLSD defaults(); @@ -199,16 +199,6 @@ public: } protected: - LLSettingsWater(); - - virtual validation_list_t getValidationList() const; - - static LLSD translateLegacySettings(LLSD legacy); - - LLVector4 mWaterPlane; - F32 mWaterFogKS; - -private: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; static const std::string SETTING_LEGACY_FOG_COLOR; static const std::string SETTING_LEGACY_FOG_DENSITY; @@ -222,6 +212,17 @@ private: static const std::string SETTING_LEGACY_WAVE1_DIR; static const std::string SETTING_LEGACY_WAVE2_DIR; + LLSettingsWater(); + + virtual validation_list_t getValidationList() const; + + static LLSD translateLegacySettings(LLSD legacy); + + LLVector4 mWaterPlane; + F32 mWaterFogKS; + +private: + }; #endif diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e8c9db045c..e14265d950 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -45,8 +45,11 @@ #include "lldiriterator.h" #include "llsettingsvo.h" +#include "llnotificationsutil.h" #include + +#define EXPORT_PRESETS 1 //========================================================================= namespace { @@ -75,7 +78,9 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(ENV_LOCAL) + mSelectedEnvironment(ENV_LOCAL), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET) { mSetSkys.resize(ENV_END); mSetWater.resize(ENV_END); @@ -146,7 +151,8 @@ void LLEnvironment::onRegionChange() void LLEnvironment::requestRegionEnvironment() { - LLEnvironmentRequest::initiate(); +// LLEnvironmentRequest::initiate(); + requestRegion(); } void LLEnvironment::onLegacyRegionSettings(LLSD data) @@ -182,6 +188,20 @@ bool LLEnvironment::getIsDayTime() const return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } +void LLEnvironment::setDayLength(S64Seconds seconds) +{ + mDayLength = seconds; + if (mCurrentDay) + mCurrentDay->setDayLength(mDayLength); +} + +void LLEnvironment::setDayOffset(S64Seconds seconds) +{ + mDayOffset = seconds; + if (mCurrentDay) + mCurrentDay->setDayOffset(seconds); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -455,6 +475,8 @@ void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seco } mCurrentDay = daycycle; + mCurrentDay->setDayLength(mDayLength); + mCurrentDay->setDayOffset(mDayOffset); daycycle->startDayCycle(); selectWater(daycycle->getCurrentWater(), transition); @@ -740,6 +762,238 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const return boost::static_pointer_cast((*it).second); } + +void LLEnvironment::applyEnvironment(LLSD environment) +{ + LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + + S32 daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + S32 dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + + if (environment.has("day_length")) + daylength = environment["day_length"].asInteger(); + if (environment.has("day_offset")) + dayoffset = environment["day_cycle"].asInteger(); + + setDayLength(S64Seconds(daylength)); + setDayOffset(S64Seconds(dayoffset)); + + if (environment.has("day_cycle")) + { + LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(environment["day_cycle"]); + + if (pday) + selectDayCycle(pday); + } + + /*TODO: track_altitudes*/ +} + +//========================================================================= +void LLEnvironment::requestRegion() +{ + if (gAgent.getRegionCapability("ExtEnvironment").empty()) + { + LLEnvironmentRequest::initiate(); + return; + } + + requestParcel(LLUUID::null); +} + +void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +{ + if (gAgent.getRegionCapability("ExtEnvironment").empty()) + { + LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); + return; + } + + updateParcel(LLUUID::null, pday, day_length, day_offset); +} + +void LLEnvironment::resetRegion() +{ + resetParcel(LLUUID::null); +} + +void LLEnvironment::requestParcel(const LLUUID &parcel_id) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id)); + +} + +void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, pday, day_length, day_offset)); + +} + +void LLEnvironment::resetParcel(const LLUUID &parcel_id) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id)); + +} + +void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + LLSD body(LLSD::emptyMap()); + body["environment"] = LLSD::emptyMap(); + + if (day_length >= 0) + body["environment"]["day_length"] = day_length; + if (day_offset >= 0) + body["environment"]["day_offset"] = day_offset; + if (pday) + body["environment"]["day_cycle"] = pday->getSettings(); + + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } + +} + + //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): mUseRegionSettings(true), @@ -906,6 +1160,18 @@ void LLEnvironment::legacyLoadAllPresets() LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); + +#ifdef EXPORT_PRESETS + std::string exportfile = LLURI::escape(name) + "(new).xml"; + std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); + + LLSD settings = day->getSettings(); + + std::ofstream daycyclefile(exportpath); + LLPointer formatter = new LLSDXMLFormatter(); + formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); + daycyclefile.close(); +#endif } } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 4d3d1f6a57..9e9c05b194 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -181,6 +181,10 @@ public: inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } inline LLVector4 getRotatedLight() const { return mRotatedLight; } + inline S64Seconds getDayLength() const { return mDayLength; } + void setDayLength(S64Seconds seconds); + inline S64Seconds getDayOffset() const { return mDayOffset; } + void setDayOffset(S64Seconds seconds); //------------------------------------------- connection_t setSkyListChange(const change_signal_t::slot_type& cb); connection_t setWaterListChange(const change_signal_t::slot_type& cb); @@ -190,6 +194,13 @@ public: void onLegacyRegionSettings(LLSD data); + void requestRegion(); + void updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void resetRegion(); + void requestParcel(const LLUUID &parcel_id); + void updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void resetParcel(const LLUUID &parcel_id); + protected: virtual void initSingleton(); @@ -254,6 +265,9 @@ private: change_signal_t mWaterListChange; change_signal_t mDayCycleListChange; + S64Seconds mDayLength; + S64Seconds mDayOffset; + void onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender); void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); @@ -278,6 +292,12 @@ private: void onRegionChange(); + void coroRequestEnvironment(LLUUID parcel_id); + void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset); + void coroResetEnvironment(LLUUID parcel_id); + + void applyEnvironment(LLSD environment); + //========================================================================= void legacyLoadAllPresets(); LLSD legacyLoadPreset(const std::string& path); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 76a6754573..cd32aa07a8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -43,6 +43,30 @@ #include "llenvironment.h" #include "llsky.h" +#undef VERIFY_LEGACY_CONVERSION + +//========================================================================= +namespace +{ +LLSD ensureArray4(LLSD in, F32 fill) +{ + if (in.size() >= 4) + return in; + + LLSD out(LLSD::emptyArray()); + + for (S32 idx = 0; idx < in.size(); ++idx) + { + out.append(in[idx]); + } + + while (out.size() < 4) + { + out.append(LLSD::Real(fill)); + } + return out; +} +} //========================================================================= LLSettingsVOSky::LLSettingsVOSky(const LLSD &data): LLSettingsSky(data) @@ -64,6 +88,18 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp); + + if (!llsd_equals(legacy, oldsettings)) + { + LL_WARNS("SKY") << "Conversion to/from legacy does not match!\n" + << "Old: " << legacy + << "new: " << oldsettings << LL_ENDL; + } + +#endif + if (skyp->validate()) return skyp; @@ -95,6 +131,43 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() return LLSettingsSky::ptr_t(); } +LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = psky->getSettings(); + + legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); + legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); + + legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; + legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) + (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); + + legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); + legacy[SETTING_GLOW] = ensureArray4(settings[SETTING_GLOW], 1.0); + legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(settings[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + legacy[SETTING_LIGHT_NORMAL] = ensureArray4(psky->getLightDirection().getValue(), 0.0f); + legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); + legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; + legacy[SETTING_SUNLIGHT_COLOR] = ensureArray4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); + + LLSettingsSky::azimalt_t azialt = psky->getSunRotationAzAl(); + + legacy[SETTING_LEGACY_EAST_ANGLE] = azialt.first; + legacy[SETTING_LEGACY_SUN_ANGLE] = azialt.second; + + return legacy; +} + //------------------------------------------------------------------------- void LLSettingsVOSky::updateSettings() { @@ -176,6 +249,19 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin LLSettingsWater::ptr_t waterp = boost::make_shared(newsettings); +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); + + if (!llsd_equals(legacy, oldsettings)) + { + LL_WARNS("WATER") << "Conversion to/from legacy does not match!\n" + << "Old: " << legacy + << "new: " << oldsettings << LL_ENDL; + } + +#endif + + if (waterp->validate()) return waterp; @@ -207,6 +293,28 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() return LLSettingsWater::ptr_t(); } +LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = pwater->getSettings(); + + legacy[SETTING_LEGACY_BLUR_MULTIPILER] = settings[SETTING_BLUR_MULTIPILER]; + legacy[SETTING_LEGACY_FOG_COLOR] = ensureArray4(settings[SETTING_FOG_COLOR], 1.0f); + legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; + legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; + legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; + legacy[SETTING_LEGACY_FRESNEL_SCALE] = settings[SETTING_FRESNEL_SCALE]; + legacy[SETTING_LEGACY_NORMAL_MAP] = settings[SETTING_NORMAL_MAP]; + legacy[SETTING_LEGACY_NORMAL_SCALE] = settings[SETTING_NORMAL_SCALE]; + legacy[SETTING_LEGACY_SCALE_ABOVE] = settings[SETTING_SCALE_ABOVE]; + legacy[SETTING_LEGACY_SCALE_BELOW] = settings[SETTING_SCALE_BELOW]; + legacy[SETTING_LEGACY_WAVE1_DIR] = settings[SETTING_WAVE1_DIR]; + legacy[SETTING_LEGACY_WAVE2_DIR] = settings[SETTING_WAVE2_DIR]; + + //_WARNS("LAPRAS") << "Legacy water: " << legacy << LL_ENDL; + return legacy; +} +//------------------------------------------------------------------------- //------------------------------------------------------------------------- void LLSettingsVOWater::applySpecial(void *ptarget) { @@ -303,12 +411,26 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); +#ifdef VERIFY_LEGACY_CONVERSION + LLSD testsettings = LLSettingsVODay::convertToLegacy(dayp); + + if (!llsd_equals(oldsettings, testsettings)) + { + LL_WARNS("DAYCYCLE") << "Conversion to/from legacy does not match!\n" + << "Old: " << oldsettings + << "new: " << testsettings << LL_ENDL; + } + +#endif + if (dayp->validate()) { dayp->initialize(); return dayp; } + + return LLSettingsDay::ptr_t(); } @@ -370,6 +492,20 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() return LLSettingsDay::ptr_t(); } +LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) +{ + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); + + if (dayp->validate()) + { + dayp->initialize(); + return dayp; + } + + return LLSettingsDay::ptr_t(); +} + + LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); @@ -379,6 +515,55 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() return dayp; } +LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) +{ + CycleTrack_t &trackwater = pday->getCycleTrack(TRACK_WATER); + + LLSettingsWater::ptr_t pwater; + if (!trackwater.empty()) + { + pwater = boost::static_pointer_cast((*trackwater.begin()).second); + } + + if (!pwater) + pwater = LLSettingsVOWater::buildDefaultWater(); + + LLSD llsdwater = LLSettingsVOWater::convertToLegacy(pwater); + + CycleTrack_t &tracksky = pday->getCycleTrack(1); // first sky track + std::map skys; + + LLSD llsdcycle(LLSD::emptyArray()); + + for(CycleTrack_t::iterator it = tracksky.begin(); it != tracksky.end(); ++it) + { + size_t hash = (*it).second->getHash(); + std::stringstream name; + + name << hash; + + skys[name.str()] = boost::static_pointer_cast((*it).second); + + F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; + llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); + } + //_WARNS("LAPRAS") << "Cycle created with " << llsdcycle.size() << "entries: " << llsdcycle << LL_ENDL; + + LLSD llsdskylist(LLSD::emptyMap()); + + for (std::map::iterator its = skys.begin(); its != skys.end(); ++its) + { + LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second); + llsdsky[SETTING_NAME] = (*its).first; + + llsdskylist[(*its).first] = llsdsky; + } + + //_WARNS("LAPRAS") << "Sky map with " << llsdskylist.size() << " entries created: " << llsdskylist << LL_ENDL; + + return LLSDArray(LLSD::emptyMap())(llsdcycle)(llsdskylist)(llsdwater); +} + LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const { return LLSettingsVOSky::buildDefaultSky(); diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 6ef7290ba4..ba96a19d3e 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -42,6 +42,7 @@ public: static ptr_t buildDefaultSky(); virtual ptr_t buildClone(); + static LLSD convertToLegacy(const ptr_t &); protected: LLSettingsVOSky(); @@ -63,6 +64,7 @@ public: static ptr_t buildDefaultWater(); virtual ptr_t buildClone(); + static LLSD convertToLegacy(const ptr_t &); protected: LLSettingsVOWater(); @@ -86,8 +88,11 @@ public: static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); static ptr_t buildDefaultDayCycle(); + static ptr_t buildFromEnvironmentMessage(LLSD settings); virtual ptr_t buildClone(); + static LLSD convertToLegacy(const ptr_t &); + virtual LLSettingsSkyPtr_t getDefaultSky() const; virtual LLSettingsWaterPtr_t getDefaultWater() const; virtual LLSettingsSkyPtr_t buildSky(LLSD) const; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 5b61eab5f7..81be645c6a 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2823,6 +2823,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("EnvironmentSettings"); capabilityNames.append("EstateChangeInfo"); capabilityNames.append("EventQueueGet"); + capabilityNames.append("ExtEnvironment"); capabilityNames.append("FacebookConnect"); capabilityNames.append("FlickrConnect"); capabilityNames.append("TwitterConnect"); diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 0e4017a1c0..cd3310d5cb 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -164,7 +164,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) sLastUpdate = current; // Send update request. - std::string url = gAgent.getRegionCapability("EnvironmentSettings"); + std::string url = gAgent.getRegionCapability("ExtEnvironment"); if (url.empty()) { LL_WARNS("WindlightCaps") << "Applying windlight settings not supported" << LL_ENDL; @@ -244,13 +244,11 @@ void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) } LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << result["regionID"].asUUID() << LL_ENDL; - //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); } while (false); if (!notify.isUndefined()) { LLNotificationsUtil::add("WLRegionApplyFail", notify); - //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); } } diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index eb2bbf9553..857ffa9bd3 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -60,4 +60,6 @@ private: static void environmentApplyCoro(std::string url, LLSD content); }; + + #endif // LL_LLWLHANDLERS_H -- cgit v1.3 From a0c228d84240a80437b63e0a2cd1cee24e8004a0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 16 Jan 2018 11:03:26 -0800 Subject: MAINT-8052: Report if the returned environment is the default. --- indra/llinventory/llparcel.cpp | 5 + indra/llinventory/llparcel.h | 17 +- indra/llinventory/llsettingsdaycycle.cpp | 1 - indra/newview/CMakeLists.txt | 2 + indra/newview/llenvironment.cpp | 49 +- indra/newview/llenvironment.h | 22 +- indra/newview/llfloaterland.cpp | 36 ++ indra/newview/llfloaterland.h | 6 +- indra/newview/llfloaterregioninfo.cpp | 678 ++------------------- indra/newview/llfloaterregioninfo.h | 7 +- indra/newview/llviewerregion.cpp | 5 +- indra/newview/llviewerregion.h | 558 +++++++++-------- .../skins/default/xui/en/floater_about_land.xml | 12 + .../default/xui/en/floater_test_layout_stacks.xml | 401 ++++++------ .../default/xui/en/panel_region_environment.xml | 317 +++++----- 15 files changed, 812 insertions(+), 1304 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 0908613c10..f53ef5e0ff 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -231,6 +231,11 @@ void LLParcel::init(const LLUUID &owner_id, setAllowGroupAVSounds(TRUE); setAllowAnyAVSounds(TRUE); setHaveNewParcelLimitData(FALSE); + + mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH); + mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET); + mIsDefaultDayCycle = true; + mDayCycle.reset(); } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 135d0ca7b9..dada2cf6d8 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -34,6 +34,7 @@ #include "llpermissions.h" #include "lltimer.h" #include "v3math.h" +#include "llsettingsdaycycle.h" // Grid out of which parcels taken is stepped every 4 meters. const F32 PARCEL_GRID_STEP_METERS = 4.f; @@ -590,7 +591,15 @@ public: BOOL getPreviouslyGroupOwned() const { return mPreviouslyGroupOwned; } BOOL getSellWithObjects() const { return (mParcelFlags & PF_SELL_PARCEL_OBJECTS) ? TRUE : FALSE; } - + S64Seconds getDayLength() const { return mDayLength; } + void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; } + S64Seconds getDayOffset() const { return mDayOffset; } + void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; } + bool getIsDefaultDayCycle() const { return mIsDefaultDayCycle; } + void setIsDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } + LLSettingsDay::ptr_t getParcelDayCycle() const { return mDayCycle; } + void setParcelDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; } + protected: LLUUID mID; LLUUID mOwnerID; @@ -665,7 +674,11 @@ protected: BOOL mAllowGroupAVSounds; BOOL mAllowAnyAVSounds; - + S64Seconds mDayLength; + S64Seconds mDayOffset; + bool mIsDefaultDayCycle; + LLSettingsDay::ptr_t mDayCycle; + public: // HACK, make private S32 mLocalID; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 180992cd29..4207df0924 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -432,7 +432,6 @@ void LLSettingsDay::updateSettings() { static LLFrameTimer timer; - F64Seconds delta(timer.getElapsedTimeAndResetF32()); if (mSkyBlender) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4579ef14e2..673f251da2 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -419,6 +419,7 @@ set(viewer_SOURCE_FILES llpanelclassified.cpp llpanelcontents.cpp llpaneleditwearable.cpp + llpanelenvironment.cpp llpanelexperiencelisteditor.cpp llpanelexperiencelog.cpp llpanelexperiencepicker.cpp @@ -1026,6 +1027,7 @@ set(viewer_HEADER_FILES llpanelclassified.h llpanelcontents.h llpaneleditwearable.h + llpanelenvironment.h llpanelexperiencelisteditor.h llpanelexperiencelog.h llpanelexperiencepicker.h diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e14265d950..b05c9ee871 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -41,6 +41,9 @@ #include "llviewershadermgr.h" +#include "llparcel.h" +#include "llviewerparcelmgr.h" + #include "llsdserialize.h" #include "lldiriterator.h" @@ -106,6 +109,7 @@ void LLEnvironment::initSingleton() requestRegionEnvironment(); gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); + gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this)); } LLEnvironment::~LLEnvironment() @@ -143,12 +147,24 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron return mDayCycleListChange.connect(cb); } - void LLEnvironment::onRegionChange() { requestRegionEnvironment(); } +void LLEnvironment::onParcelChange() +{ + LLUUID parcel_id; + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (parcel) + { + parcel_id = parcel->getID(); + } + + requestParcel(parcel_id); +} + void LLEnvironment::requestRegionEnvironment() { // LLEnvironmentRequest::initiate(); @@ -821,7 +837,8 @@ void LLEnvironment::requestParcel(const LLUUID &parcel_id) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id)); + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, + boost::bind(&LLEnvironment::applyEnvironment, this, _1))); } @@ -829,7 +846,9 @@ void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t & { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, pday, day_length, day_offset)); + boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, + pday, day_length, day_offset, + boost::bind(&LLEnvironment::applyEnvironment, this, _1))); } @@ -837,11 +856,11 @@ void LLEnvironment::resetParcel(const LLUUID &parcel_id) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id)); - + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, + boost::bind(&LLEnvironment::applyEnvironment, this, _1))); } -void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) +void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -875,9 +894,9 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) else { LLSD environment = result["environment"]; - if (environment.isDefined()) + if (environment.isDefined() && !apply.empty()) { - applyEnvironment(environment); + apply(environment); } } @@ -888,7 +907,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) } } -void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset) +void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -932,9 +951,9 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t else { LLSD environment = result["environment"]; - if (environment.isDefined()) + if (environment.isDefined() && !apply.empty()) { - applyEnvironment(environment); + apply(environment); } } @@ -945,7 +964,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t } } -void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) +void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -979,10 +998,10 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) else { LLSD environment = result["environment"]; - if (environment.isDefined()) + if (environment.isDefined() && !apply.empty()) { - applyEnvironment(environment); - } + apply(environment); + } } if (!notify.isUndefined()) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 9e9c05b194..4f8850683e 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -99,6 +99,7 @@ public: typedef std::pair name_id_t; typedef std::vector list_name_id_t; typedef boost::signals2::signal change_signal_t; + typedef boost::function environment_apply_fn; virtual ~LLEnvironment(); @@ -233,20 +234,6 @@ private: WaterList_t mSetWater; DayList_t mSetDays; -#if 0 - LLSettingsSky::ptr_t mRegionFixedSky; - LLSettingsWater::ptr_t mRegionFixedWater; - LLSettingsDay::ptr_t mRegionDay; - - LLSettingsSky::ptr_t mParcelFixedSky; - LLSettingsWater::ptr_t mParcelFixedWater; - LLSettingsDay::ptr_t mParcelDay; - - LLSettingsSky::ptr_t mUserSky; - LLSettingsWater::ptr_t mUserWater; - LLSettingsDay::ptr_t mUserDay; -#endif - namedSettingMap_t mSkysByName; AssetSettingMap_t mSkysById; @@ -291,10 +278,11 @@ private: void updateCloudScroll(); void onRegionChange(); + void onParcelChange(); - void coroRequestEnvironment(LLUUID parcel_id); - void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset); - void coroResetEnvironment(LLUUID parcel_id); + void coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply); + void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply); + void coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply); void applyEnvironment(LLSD environment); diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 88b3fb7b96..fc4ab0a7a7 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -78,6 +78,7 @@ #include "lltrans.h" #include "llpanelexperiencelisteditor.h" #include "llpanelexperiencepicker.h" +#include "llpanelenvironment.h" #include "llexperiencecache.h" #include "llgroupactions.h" @@ -138,6 +139,32 @@ protected: LLPanelExperienceListEditor* mBlocked; }; +#if 0 +class LLPanelLandEnvironment + : public LLPanel +{ +public: + LLPanelLandEnvironment(LLSafeHandle& parcelp); + // TODO: LAPRAS +#if 0 + virtual BOOL postBuild(); + void refresh(); + + void experienceAdded(const LLUUID& id, U32 xp_type, U32 access_type); + void experienceRemoved(const LLUUID& id, U32 access_type); +protected: + LLPanelExperienceListEditor* setupList(const char* control_name, U32 xp_type, U32 access_type); + void refreshPanel(LLPanelExperienceListEditor* panel, U32 xp_type); + + LLSafeHandle& mParcel; + + + LLPanelExperienceListEditor* mAllowed; + LLPanelExperienceListEditor* mBlocked; +#endif +}; +#endif + // inserts maturity info(icon and text) into target textbox // names_floater - pointer to floater which contains strings with maturity icons filenames // str_to_parse is string in format "txt1[MATURITY]txt2" where maturity icon and text will be inserted instead of [MATURITY] @@ -277,6 +304,7 @@ LLFloaterLand::LLFloaterLand(const LLSD& seed) mFactoryMap["land_media_panel"] = LLCallbackMap(createPanelLandMedia, this); mFactoryMap["land_access_panel"] = LLCallbackMap(createPanelLandAccess, this); mFactoryMap["land_experiences_panel"] = LLCallbackMap(createPanelLandExperiences, this); + mFactoryMap["land_environment_panel"] = LLCallbackMap(createPanelLandEnvironment, this); sObserver = new LLParcelSelectionObserver(); LLViewerParcelMgr::getInstance()->addObserver( sObserver ); @@ -386,6 +414,14 @@ void* LLFloaterLand::createPanelLandExperiences(void* data) return self->mPanelExperiences; } +//static +void* LLFloaterLand::createPanelLandEnvironment(void* data) +{ + LLFloaterLand* self = (LLFloaterLand*)data; + self->mPanelEnvironment = new LLPanelEnvironmentInfo(/*self->mParcel*/); + return self->mPanelEnvironment; +} + //--------------------------------------------------------------------------- // LLPanelLandGeneral diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 0540ddb880..e5837b5a08 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -67,6 +67,8 @@ class LLPanelLandRenters; class LLPanelLandCovenant; class LLParcel; class LLPanelLandExperiences; +//class LLPanelLandEnvironment; +class LLPanelEnvironmentInfo; class LLFloaterLand : public LLFloater @@ -103,7 +105,8 @@ protected: static void* createPanelLandMedia(void* data); static void* createPanelLandAccess(void* data); static void* createPanelLandExperiences(void* data); - static void* createPanelLandBan(void* data); + static void* createPanelLandEnvironment(void* data); + static void* createPanelLandBan(void* data); protected: @@ -119,6 +122,7 @@ protected: LLPanelLandAccess* mPanelAccess; LLPanelLandCovenant* mPanelCovenant; LLPanelLandExperiences* mPanelExperiences; + LLPanelEnvironmentInfo *mPanelEnvironment; LLSafeHandle mParcel; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index e0a56b9412..5ce682fe8c 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -189,7 +189,8 @@ LLUUID LLFloaterRegionInfo::sRequestInvoice; LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) - : LLFloater(seed) + : LLFloater(seed), + mEnvironmentPanel(NULL) {} BOOL LLFloaterRegionInfo::postBuild() @@ -220,10 +221,9 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_terrain.xml"); mTab->addTabPanel(panel); - panel = new LLPanelEnvironmentInfo; - mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_environment.xml"); - mTab->addTabPanel(panel); + mEnvironmentPanel = new LLPanelRegionEnvironment; + mEnvironmentPanel->buildFromFile("panel_region_environment.xml"); + mTab->addTabPanel(mEnvironmentPanel); panel = new LLPanelRegionDebugInfo; mInfoPanels.push_back(panel); @@ -242,7 +242,7 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_experiences.xml"); mTab->addTabPanel(panel); } - + gMessageSystem->setHandlerFunc( "EstateOwnerMessage", &processEstateOwnerRequest); @@ -540,6 +540,7 @@ void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) std::mem_fun(&LLPanelRegionInfo::refreshFromRegion), #endif region)); + mEnvironmentPanel->refreshFromRegion(region); } // public @@ -550,6 +551,7 @@ void LLFloaterRegionInfo::refresh() { (*iter)->refresh(); } + mEnvironmentPanel->refresh(); } void LLFloaterRegionInfo::enableTopButtons() @@ -3083,630 +3085,6 @@ bool LLDispatchSetEstateExperience::operator()( } - -LLPanelEnvironmentInfo::LLPanelEnvironmentInfo() -: mEnableEditing(false), - mRegionSettingsRadioGroup(NULL), - mDayCycleSettingsRadioGroup(NULL), - mWaterPresetCombo(NULL), - mSkyPresetCombo(NULL), - mDayCyclePresetCombo(NULL) -{ -} - -// virtual -BOOL LLPanelEnvironmentInfo::postBuild() -{ - mRegionSettingsRadioGroup = getChild("region_settings_radio_group"); - mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchRegionSettings, this)); - - mDayCycleSettingsRadioGroup = getChild("sky_dayc_settings_radio_group"); - mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); - - mWaterPresetCombo = getChild("water_settings_preset_combo"); - mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); - - mSkyPresetCombo = getChild("sky_settings_preset_combo"); - mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); - - mDayCyclePresetCombo = getChild("dayc_settings_preset_combo"); - mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - - childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); -// getChild("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); - childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); -// getChild("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); - -// LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); -// LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); - -// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); -// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); -// LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this)); - - return TRUE; -} - -// virtual -void LLPanelEnvironmentInfo::onOpen(const LLSD& key) -{ - LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; - refresh(); -} - -// virtual -void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) -{ - // If hiding (user switched to another tab or closed the floater), - // display user's preferred environment. - if (!new_visibility) - { -// LLEnvManagerNew::instance().usePrefs(); - } -} - -// virtual -bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) -{ - LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; - BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); - BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - // Don't refresh from region settings to avoid flicker after applying new region settings. - mEnableEditing = owner_or_god_or_manager; - setControlsEnabled(mEnableEditing); - - return LLPanelRegionInfo::refreshFromRegion(region); -} - -void LLPanelEnvironmentInfo::refresh() -{ -#if 0 - if(gDisconnected) - { - return; - } - - populateWaterPresetsList(); - populateSkyPresetsList(); - populateDayCyclesList(); - - // Init radio groups. - const LLEnvironmentSettings& settings = LLEnvManagerNew::instance().getRegionSettings(); - const LLSD& dc = settings.getWLDayCycle(); - LLSD::Real first_frame_time = dc.size() > 0 ? dc[0][0].asReal() : 0.0f; - const bool use_fixed_sky = dc.size() == 1 && first_frame_time < 0; - mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); - mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); - - setControlsEnabled(mEnableEditing); - - setDirty(false); -#endif -} - -void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) -{ - mRegionSettingsRadioGroup->setEnabled(enabled); - mDayCycleSettingsRadioGroup->setEnabled(enabled); - - mWaterPresetCombo->setEnabled(false); - mSkyPresetCombo->setEnabled(false); - mDayCyclePresetCombo->setEnabled(false); - - getChildView("apply_btn")->setEnabled(enabled); - getChildView("cancel_btn")->setEnabled(enabled); - - if (enabled) - { - // Enable/disable some controls based on currently selected radio buttons. - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild("user_environment_settings")->setEnabled(!use_defaults); - - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - } -} - -void LLPanelEnvironmentInfo::setApplyProgress(bool started) -{ - LLLoadingIndicator* indicator = getChild("progress_indicator"); - - indicator->setVisible(started); - - if (started) - { - indicator->start(); - } - else - { - indicator->stop(); - } -} - -void LLPanelEnvironmentInfo::setDirty(bool dirty) -{ - getChildView("apply_btn")->setEnabled(dirty); - getChildView("cancel_btn")->setEnabled(dirty); -} - -void LLPanelEnvironmentInfo::sendRegionSunUpdate() -{ -#if 0 - LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); - - // If the region is being switched to fixed sky, - // change the region's sun hour according to the (fixed) sun position. - // This is needed for llGetSunDirection() LSL function to work properly (STORM-1330). - const LLSD& sky_map = mNewRegionSettings.getSkyMap(); - bool region_use_fixed_sky = sky_map.size() == 1; - if (region_use_fixed_sky) - { - LLWLParamSet param_set; - llassert(sky_map.isMap()); - param_set.setAll(sky_map.beginMap()->second); - F32 sun_angle = param_set.getSunAngle(); - - LL_DEBUGS("Windlight Sync") << "Old sun hour: " << region_info.mSunHour << LL_ENDL; - // convert value range from 0..2pi to 6..30 - region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f; - } - - region_info.setUseFixedSun(region_use_fixed_sky); - region_info.mUseEstateSun = !region_use_fixed_sky; - LL_DEBUGS("Windlight Sync") << "Sun hour: " << region_info.mSunHour << LL_ENDL; - - region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); -#endif -} - -void LLPanelEnvironmentInfo::fixEstateSun() -{ - // We don't support fixed sun estates anymore and need to fix - // such estates for region day cycle to take effect. - // *NOTE: Assuming that current estate settings have arrived already. - LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); - if (estate_info.getUseFixedSun()) - { - LL_INFOS() << "Switching estate to global sun" << LL_ENDL; - estate_info.setUseFixedSun(false); - estate_info.sendEstateInfo(); - } -} - -void LLPanelEnvironmentInfo::populateWaterPresetsList() -{ -#if 0 - mWaterPresetCombo->removeall(); - - // 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, LLWLParamKey(region_name, LLEnvKey::SCOPE_REGION).toLLSD()); - mWaterPresetCombo->addSeparator(); - } - - std::list user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); - - // Add local user presets first. - for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add local system presets. - for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - // There's no way to select current preset because its name is not stored on server. -#endif -} - -void LLPanelEnvironmentInfo::populateSkyPresetsList() -{ -#if 0 - mSkyPresetCombo->removeall(); - - LLWLParamManager::preset_name_list_t region_presets; - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - - // 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 preset_name = *it; - std::string item_title = preset_name + " (" + region_name + ")"; - mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); - } - - if (!region_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // 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).toStringVal()); - } - - 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, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // Select current preset. - LLSD sky_map = LLEnvManagerNew::instance().getRegionSettings().getSkyMap(); - if (sky_map.size() == 1) // if the region is set to fixed sky - { - std::string preset_name = sky_map.beginMap()->first; - mSkyPresetCombo->selectByValue(LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); - } -#endif -} - -void LLPanelEnvironmentInfo::populateDayCyclesList() -{ -#if 0 - mDayCyclePresetCombo->removeall(); - - // If the region already has env. settings, add its day cycle to the list. - const LLSD& cur_region_dc = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); - if (cur_region_dc.size() != 0) - { - LLViewerRegion* region = gAgent.getRegion(); - llassert(region != NULL); - - LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); - mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); - mDayCyclePresetCombo->addSeparator(); - } - - // Add local user day cycles. - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - if (user_days.size() > 0) - { - mDayCyclePresetCombo->addSeparator(); - } - - // Add local system day cycles. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // Current day cycle is already selected. -#endif -} - -bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) -{ -#if 0 - LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); - - if (water_key.scope == LLEnvKey::SCOPE_REGION) - { - water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); - } - else - { - LLWaterParamSet param_set; - if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) - { - LL_WARNS() << "Error getting water preset: " << water_key.name << LL_ENDL; - return false; - } - - water_params = param_set.getAll(); - } - - return true; -#endif - return false; -} - -bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) -{ -#if 0 - std::string preset_key(mSkyPresetCombo->getValue().asString()); - LLWLParamKey preset(preset_key); - - // Get the preset sky params. - LLWLParamSet param_set; - if (!LLWLParamManager::instance().getParamSet(preset, param_set)) - { - LL_WARNS() << "Error getting sky params: " << preset.toLLSD() << LL_ENDL; - return false; - } - - sky_params = param_set.getAll(); - preset_name = preset.name; - return true; -#endif - return false; -} - -bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) -{ -#if 0 - std::string preset_key(mDayCyclePresetCombo->getValue().asString()); - LLWLParamKey dc(preset_key); - LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; - - if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle - { - const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); - day_cycle = cur_region_settings.getWLDayCycle(); - sky_map = cur_region_settings.getSkyMap(); - } - else // a local day cycle - { - if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) - { - LL_WARNS() << "Error getting day cycle " << dc.name << LL_ENDL; - return false; - } - - // Create sky map from the day cycle. - { - LLWLDayCycle tmp_day; - tmp_day.loadDayCycle(day_cycle, dc.scope); - tmp_day.getSkyMap(sky_map); - } - } - - scope = dc.scope; - - return true; -#endif - return false; -} -void LLPanelEnvironmentInfo::onSwitchRegionSettings() -{ - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild("user_environment_settings")->setEnabled(!use_defaults); - - if (use_defaults) - { -// LLEnvManagerNew::instance().useDefaults(); - } - else - { - onSelectWaterPreset(); - onSwitchDayCycle(); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSwitchDayCycle() -{ - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - - if (is_fixed_sky) - { - onSelectSkyPreset(); - } - else - { - onSelectDayCycle(); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectWaterPreset() -{ - LLSD water_params; - - if (getSelectedWaterParams(water_params)) - { -// LLEnvManagerNew::instance().useWaterParams(water_params); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectSkyPreset() -{ - LLSD params; - std::string dummy; - - if (getSelectedSkyParams(params, dummy)) - { -// LLEnvManagerNew::instance().useSkyParams(params); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectDayCycle() -{ - LLSD day_cycle; - LLSD sky_map; // unused - short scope; - - if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) - { -// LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onBtnApply() -{ - const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - LLSD day_cycle; - LLSD sky_map; - LLSD water_params; - - if (use_defaults) - { - // settings will be empty - LL_DEBUGS("Windlight") << "Defaults" << LL_ENDL; - } - else // use custom region settings - { - if (use_fixed_sky) - { - LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; - -#if 0 - // Get selected sky params. - LLSD params; - std::string preset_name; - if (!getSelectedSkyParams(params, preset_name)) - { - return; - } - - // Create a day cycle consisting of a single sky preset. - LLSD key(LLSD::emptyArray()); - key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle - key.append(preset_name); - day_cycle.append(key); - - // Create a sky map consisting of only the sky preset. - std::map refs; - LLWLParamSet param_set; - param_set.setAll(params); - refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here - sky_map = LLWLParamManager::createSkyMap(refs); -#endif - } - else // use day cycle - { - LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; - - short scope; // unused - if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) - { - return; - } - - // If it's a special single-preset day cycle meaning using a fixed sky, - // reset the frame time to a non-negative value, - // so that the region setting is displayed in the floater as - // a day cycle, not a preset. (STORM-1289) - if (day_cycle.size() == 1 && day_cycle[0][0].asReal() < 0.0f) - { - LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL; - day_cycle[0][0] = 0.0f; - } - } - - // Get water params. - if (!getSelectedWaterParams(water_params)) - { - // *TODO: show a notification? - return; - } - } - -#if 0 - // Send settings apply request. - LLEnvironmentSettings new_region_settings; - new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f); - if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) - { - LL_WARNS() << "Error applying region environment settings" << LL_ENDL; - return; - } - - // When the settings get applied, we'll also send the region sun position update. - // To determine the sun angle we're going to need the new settings. - mNewRegionSettings = new_region_settings; -#endif - - // Start spinning the progress indicator. - setApplyProgress(true); -} - -void LLPanelEnvironmentInfo::onBtnCancel() -{ - // Reload last saved region settings. - refresh(); - -#if 0 - LLEnvironment::instance().applyChosenEnvironment(); - // Apply them. - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); - const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); - const LLSD& region_water = cur_settings.getWaterParams(); - env_mgr.useWaterParams(region_water); - env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); -#endif -} - -void LLPanelEnvironmentInfo::onRegionSettingschange() -{ - LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; - refresh(); - - // Stop applying progress indicator (it may be running if it's us who initiated settings update). - setApplyProgress(false); -} - -void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) -{ - // If applying new settings has failed, stop the indicator right away. - // Otherwise it will be stopped when we receive the updated settings from server. - if (ok) - { - // Set the region sun phase/flags according to the chosen new preferences. - // - // If we do this earlier we may get jerky transition from fixed sky to a day cycle (STORM-1481). - // That is caused by the simulator re-sending the region info, which in turn makes us - // re-request and display old region environment settings while the new ones haven't been applied yet. - sendRegionSunUpdate(); - - // Switch estate to not using fixed sun for the region day cycle to work properly (STORM-1506). - fixEstateSun(); - } - else - { - setApplyProgress(false); - - // We need to re-request environment setting here, - // otherwise our subsequent attempts to change region settings will fail with the following error: - // "Unable to update environment settings because the last update your viewer saw was not the same - // as the last update sent from the simulator. Try sending your update again, and if this - // does not work, try leaving and returning to the region." -// LLEnvManagerNew::instance().requestRegionSettings(); - } -} - BOOL LLPanelRegionExperiences::postBuild() { mAllowed = setupList("panel_allowed", ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE); @@ -3965,3 +3343,43 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id ) onChangeAnything(); } + +//========================================================================= +class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo +{ +public: + LLPanelRegionEnvironment(); + + void refresh(); + + bool refreshFromRegion(LLViewerRegion* region); + +private: + LLViewerRegion * mLastRegion; +}; + +LLPanelRegionEnvironment::LLPanelRegionEnvironment(): + LLPanelEnvironmentInfo(), + mLastRegion(NULL) +{ +} + +void LLPanelRegionEnvironment::refresh() +{ + refreshFromRegion(mLastRegion); +} + +bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region) +{ + BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); + BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); + + mDayLengthSlider->setValue(region->getDayLength().value()); + mDayOffsetSlider->setValue(region->getDayOffset().value()); + + + + setControlsEnabled(owner_or_god_or_manager); + mLastRegion = region; + return true; +} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index bbdff84bf6..61bf33af2f 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -34,6 +34,7 @@ #include "llhost.h" #include "llpanel.h" #include "llextendedstatus.h" +#include "llpanelenvironment.h" #include "lleventcoro.h" @@ -63,6 +64,7 @@ class LLPanelEstateCovenant; class LLPanelExperienceListEditor; class LLPanelExperiences; class LLPanelRegionExperiences; +class LLPanelRegionEnvironment; class LLEventTimer; @@ -115,6 +117,7 @@ protected: LLTabContainer* mTab; typedef std::vector info_panels_t; info_panels_t mInfoPanels; + LLPanelRegionEnvironment *mEnvironmentPanel; //static S32 sRequestSerial; // serial # of last EstateOwnerRequest static LLUUID sRequestInvoice; }; @@ -409,6 +412,7 @@ protected: ///////////////////////////////////////////////////////////////////////////// +#if 0 class LLPanelEnvironmentInfo : public LLPanelRegionInfo { LOG_CLASS(LLPanelEnvironmentInfo); @@ -468,10 +472,11 @@ private: LLComboBox* mSkyPresetCombo; LLComboBox* mDayCyclePresetCombo; }; +#endif class LLPanelRegionExperiences : public LLPanelRegionInfo { - LOG_CLASS(LLPanelEnvironmentInfo); + LOG_CLASS(LLPanelRegionExperiences); public: LLPanelRegionExperiences(){} diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 81be645c6a..1dda516ca4 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -78,6 +78,7 @@ #include "llcoros.h" #include "lleventcoro.h" #include "llcorehttputil.h" +#include "llsettingsdaycycle.h" #ifdef LL_WINDOWS #pragma warning(disable:4355) @@ -534,7 +535,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mInvisibilityCheckHistory(-1), mPaused(FALSE), mRegionCacheHitCount(0), - mRegionCacheMissCount(0) + mRegionCacheMissCount(0), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET) { mWidth = region_width_meters; mImpl->mOriginGlobal = from_region_handle(handle); diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 69fb9c4d4e..fef78e29a9 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -42,6 +42,8 @@ #include "m4math.h" // LLMatrix4 #include "llframetimer.h" +#include "llsettingsdaycycle.h" + // Surface id's #define LAND 1 #define WATER 2 @@ -71,320 +73,331 @@ class LLViewerRegionImpl; class LLViewerOctreeGroup; class LLVOCachePartition; -class LLViewerRegion: public LLCapabilityProvider // implements this interface +class LLViewerRegion : public LLCapabilityProvider // implements this interface { public: - //MUST MATCH THE ORDER OF DECLARATION IN CONSTRUCTOR - typedef enum - { - PARTITION_HUD=0, - PARTITION_TERRAIN, - PARTITION_VOIDWATER, - PARTITION_WATER, - PARTITION_TREE, - PARTITION_PARTICLE, - PARTITION_GRASS, - PARTITION_VOLUME, - PARTITION_BRIDGE, - PARTITION_HUD_PARTICLE, - PARTITION_VO_CACHE, - PARTITION_NONE, - NUM_PARTITIONS - } eObjectPartitions; - - typedef boost::signals2::signal caps_received_signal_t; - - LLViewerRegion(const U64 &handle, - const LLHost &host, - const U32 surface_grid_width, - const U32 patch_grid_width, - const F32 region_width_meters); - ~LLViewerRegion(); - - // Call this after you have the region name and handle. - void loadObjectCache(); - void saveObjectCache(); - - void sendMessage(); // Send the current message to this region's simulator - void sendReliableMessage(); // Send the current message to this region's simulator - - void setOriginGlobal(const LLVector3d &origin); - //void setAgentOffset(const LLVector3d &offset); - void updateRenderMatrix(); - - void setAllowDamage(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DAMAGE, b); } - void setAllowLandmark(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_LANDMARK, b); } - void setAllowSetHome(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_SET_HOME, b); } - void setResetHomeOnTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_RESET_HOME_ON_TELEPORT, b); } - void setSunFixed(BOOL b) { setRegionFlag(REGION_FLAGS_SUN_FIXED, b); } - //void setBlockFly(BOOL b) { setRegionFlag(REGION_FLAGS_BLOCK_FLY, b); } Never used - void setAllowDirectTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, b); } - - - inline BOOL getAllowDamage() const; - inline BOOL getAllowLandmark() const; - inline BOOL getAllowSetHome() const; - inline BOOL getResetHomeOnTeleport() const; - inline BOOL getSunFixed() const; - inline BOOL getBlockFly() const; - inline BOOL getAllowDirectTeleport() const; - inline BOOL isPrelude() const; - inline BOOL getAllowTerraform() const; - inline BOOL getRestrictPushObject() const; - inline BOOL getReleaseNotesRequested() const; - - bool isAlive(); // can become false if circuit disconnects - - void setWaterHeight(F32 water_level); - F32 getWaterHeight() const; - - BOOL isVoiceEnabled() const; - - void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; } - F32 getBillableFactor() const { return mBillableFactor; } - - // Maximum number of primitives allowed, regardless of object - // bonus factor. - U32 getMaxTasks() const { return mMaxTasks; } - void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; } - - // Draw lines in the dirt showing ownership. Return number of - // vertices drawn. - S32 renderPropertyLines(); - - // Call this whenever you change the height data in the region. - // (Automatically called by LLSurfacePatch's update routine) - void dirtyHeights(); - - LLViewerParcelOverlay *getParcelOverlay() const - { return mParcelOverlay; } - - inline void setRegionFlag(U64 flag, BOOL on); - inline BOOL getRegionFlag(U64 flag) const; - void setRegionFlags(U64 flags); - U64 getRegionFlags() const { return mRegionFlags; } - - inline void setRegionProtocol(U64 protocol, BOOL on); - BOOL getRegionProtocol(U64 protocol) const; - void setRegionProtocols(U64 protocols) { mRegionProtocols = protocols; } - U64 getRegionProtocols() const { return mRegionProtocols; } - - void setTimeDilation(F32 time_dilation); - F32 getTimeDilation() const { return mTimeDilation; } - - // Origin height is at zero. - const LLVector3d &getOriginGlobal() const; - LLVector3 getOriginAgent() const; - - // Center is at the height of the water table. - const LLVector3d &getCenterGlobal() const; - LLVector3 getCenterAgent() const; - - void setRegionNameAndZone(const std::string& name_and_zone); - const std::string& getName() const { return mName; } - const std::string& getZoning() const { return mZoning; } - - void setOwner(const LLUUID& owner_id); - const LLUUID& getOwner() const; - - // Is the current agent on the estate manager list for this region? - void setIsEstateManager(BOOL b) { mIsEstateManager = b; } - BOOL isEstateManager() const { return mIsEstateManager; } - BOOL canManageEstate() const; - - void setSimAccess(U8 sim_access) { mSimAccess = sim_access; } - U8 getSimAccess() const { return mSimAccess; } - const std::string getSimAccessString() const; - - // Homestead-related getters; there are no setters as nobody should be - // setting them other than the individual message handler which is a member - S32 getSimClassID() const { return mClassID; } - S32 getSimCPURatio() const { return mCPURatio; } - const std::string& getSimColoName() const { return mColoName; } - const std::string& getSimProductSKU() const { return mProductSKU; } - std::string getLocalizedSimProductName() const; - - // Returns "Sandbox", "Expensive", etc. - static std::string regionFlagsToString(U64 flags); - - // Returns translated version of "Mature", "PG", "Adult", etc. - static std::string accessToString(U8 sim_access); - - // Returns "M", "PG", "A" etc. - static std::string accessToShortString(U8 sim_access); - static U8 shortStringToAccess(const std::string &sim_access); - - // Return access icon name - static std::string getAccessIcon(U8 sim_access); - - // helper function which just makes sure all interested parties - // can process the message. - static void processRegionInfo(LLMessageSystem* msg, void**); + //MUST MATCH THE ORDER OF DECLARATION IN CONSTRUCTOR + typedef enum + { + PARTITION_HUD = 0, + PARTITION_TERRAIN, + PARTITION_VOIDWATER, + PARTITION_WATER, + PARTITION_TREE, + PARTITION_PARTICLE, + PARTITION_GRASS, + PARTITION_VOLUME, + PARTITION_BRIDGE, + PARTITION_HUD_PARTICLE, + PARTITION_VO_CACHE, + PARTITION_NONE, + NUM_PARTITIONS + } eObjectPartitions; + + typedef boost::signals2::signal caps_received_signal_t; + + LLViewerRegion(const U64 &handle, + const LLHost &host, + const U32 surface_grid_width, + const U32 patch_grid_width, + const F32 region_width_meters); + ~LLViewerRegion(); + + // Call this after you have the region name and handle. + void loadObjectCache(); + void saveObjectCache(); + + void sendMessage(); // Send the current message to this region's simulator + void sendReliableMessage(); // Send the current message to this region's simulator + + void setOriginGlobal(const LLVector3d &origin); + //void setAgentOffset(const LLVector3d &offset); + void updateRenderMatrix(); + + void setAllowDamage(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DAMAGE, b); } + void setAllowLandmark(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_LANDMARK, b); } + void setAllowSetHome(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_SET_HOME, b); } + void setResetHomeOnTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_RESET_HOME_ON_TELEPORT, b); } + void setSunFixed(BOOL b) { setRegionFlag(REGION_FLAGS_SUN_FIXED, b); } + //void setBlockFly(BOOL b) { setRegionFlag(REGION_FLAGS_BLOCK_FLY, b); } Never used + void setAllowDirectTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, b); } + + + inline BOOL getAllowDamage() const; + inline BOOL getAllowLandmark() const; + inline BOOL getAllowSetHome() const; + inline BOOL getResetHomeOnTeleport() const; + inline BOOL getSunFixed() const; + inline BOOL getBlockFly() const; + inline BOOL getAllowDirectTeleport() const; + inline BOOL isPrelude() const; + inline BOOL getAllowTerraform() const; + inline BOOL getRestrictPushObject() const; + inline BOOL getReleaseNotesRequested() const; + + bool isAlive(); // can become false if circuit disconnects + + void setWaterHeight(F32 water_level); + F32 getWaterHeight() const; + + BOOL isVoiceEnabled() const; + + void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; } + F32 getBillableFactor() const { return mBillableFactor; } + + // Maximum number of primitives allowed, regardless of object + // bonus factor. + U32 getMaxTasks() const { return mMaxTasks; } + void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; } + + // Draw lines in the dirt showing ownership. Return number of + // vertices drawn. + S32 renderPropertyLines(); + + // Call this whenever you change the height data in the region. + // (Automatically called by LLSurfacePatch's update routine) + void dirtyHeights(); + + LLViewerParcelOverlay *getParcelOverlay() const + { + return mParcelOverlay; + } + + inline void setRegionFlag(U64 flag, BOOL on); + inline BOOL getRegionFlag(U64 flag) const; + void setRegionFlags(U64 flags); + U64 getRegionFlags() const { return mRegionFlags; } + + inline void setRegionProtocol(U64 protocol, BOOL on); + BOOL getRegionProtocol(U64 protocol) const; + void setRegionProtocols(U64 protocols) { mRegionProtocols = protocols; } + U64 getRegionProtocols() const { return mRegionProtocols; } + + void setTimeDilation(F32 time_dilation); + F32 getTimeDilation() const { return mTimeDilation; } + + // Origin height is at zero. + const LLVector3d &getOriginGlobal() const; + LLVector3 getOriginAgent() const; + + // Center is at the height of the water table. + const LLVector3d &getCenterGlobal() const; + LLVector3 getCenterAgent() const; + + void setRegionNameAndZone(const std::string& name_and_zone); + const std::string& getName() const { return mName; } + const std::string& getZoning() const { return mZoning; } + + void setOwner(const LLUUID& owner_id); + const LLUUID& getOwner() const; + + // Is the current agent on the estate manager list for this region? + void setIsEstateManager(BOOL b) { mIsEstateManager = b; } + BOOL isEstateManager() const { return mIsEstateManager; } + BOOL canManageEstate() const; + + void setSimAccess(U8 sim_access) { mSimAccess = sim_access; } + U8 getSimAccess() const { return mSimAccess; } + const std::string getSimAccessString() const; + + // Homestead-related getters; there are no setters as nobody should be + // setting them other than the individual message handler which is a member + S32 getSimClassID() const { return mClassID; } + S32 getSimCPURatio() const { return mCPURatio; } + const std::string& getSimColoName() const { return mColoName; } + const std::string& getSimProductSKU() const { return mProductSKU; } + std::string getLocalizedSimProductName() const; + + // Returns "Sandbox", "Expensive", etc. + static std::string regionFlagsToString(U64 flags); + + // Returns translated version of "Mature", "PG", "Adult", etc. + static std::string accessToString(U8 sim_access); + + // Returns "M", "PG", "A" etc. + static std::string accessToShortString(U8 sim_access); + static U8 shortStringToAccess(const std::string &sim_access); + + // Return access icon name + static std::string getAccessIcon(U8 sim_access); - //check if the viewer camera is static - static BOOL isViewerCameraStatic(); - static void calcNewObjectCreationThrottle(); + // helper function which just makes sure all interested parties + // can process the message. + static void processRegionInfo(LLMessageSystem* msg, void**); + + //check if the viewer camera is static + static BOOL isViewerCameraStatic(); + static void calcNewObjectCreationThrottle(); - void setCacheID(const LLUUID& id); + void setCacheID(const LLUUID& id); - F32 getWidth() const { return mWidth; } + F32 getWidth() const { return mWidth; } - void idleUpdate(F32 max_update_time); - void lightIdleUpdate(); - bool addVisibleGroup(LLViewerOctreeGroup* group); - void addVisibleChildCacheEntry(LLVOCacheEntry* parent, LLVOCacheEntry* child); - void addActiveCacheEntry(LLVOCacheEntry* entry); - void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep); - void killCacheEntry(U32 local_id); //physically delete the cache entry + void idleUpdate(F32 max_update_time); + void lightIdleUpdate(); + bool addVisibleGroup(LLViewerOctreeGroup* group); + void addVisibleChildCacheEntry(LLVOCacheEntry* parent, LLVOCacheEntry* child); + void addActiveCacheEntry(LLVOCacheEntry* entry); + void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep); + void killCacheEntry(U32 local_id); //physically delete the cache entry - // Like idleUpdate, but forces everything to complete regardless of - // how long it takes. - void forceUpdate(); + // Like idleUpdate, but forces everything to complete regardless of + // how long it takes. + void forceUpdate(); - void connectNeighbor(LLViewerRegion *neighborp, U32 direction); + void connectNeighbor(LLViewerRegion *neighborp, U32 direction); - void updateNetStats(); + void updateNetStats(); - U32 getPacketsLost() const; + U32 getPacketsLost() const; - S32 getHttpResponderID() const; + S32 getHttpResponderID() const; - // Get/set named capability URLs for this region. - void setSeedCapability(const std::string& url); - S32 getNumSeedCapRetries(); - void setCapability(const std::string& name, const std::string& url); - void setCapabilityDebug(const std::string& name, const std::string& url); - bool isCapabilityAvailable(const std::string& name) const; - // implements LLCapabilityProvider + // Get/set named capability URLs for this region. + void setSeedCapability(const std::string& url); + S32 getNumSeedCapRetries(); + void setCapability(const std::string& name, const std::string& url); + void setCapabilityDebug(const std::string& name, const std::string& url); + bool isCapabilityAvailable(const std::string& name) const; + // implements LLCapabilityProvider virtual std::string getCapability(const std::string& name) const; std::string getCapabilityDebug(const std::string& name) const; - // has region received its final (not seed) capability list? - bool capabilitiesReceived() const; - void setCapabilitiesReceived(bool received); - boost::signals2::connection setCapabilitiesReceivedCallback(const caps_received_signal_t::slot_type& cb); + // has region received its final (not seed) capability list? + bool capabilitiesReceived() const; + void setCapabilitiesReceived(bool received); + boost::signals2::connection setCapabilitiesReceivedCallback(const caps_received_signal_t::slot_type& cb); - static bool isSpecialCapabilityName(const std::string &name); - void logActiveCapabilities() const; + static bool isSpecialCapabilityName(const std::string &name); + void logActiveCapabilities() const; /// implements LLCapabilityProvider - /*virtual*/ const LLHost& getHost() const; - const U64 &getHandle() const { return mHandle; } + /*virtual*/ const LLHost& getHost() const; + const U64 &getHandle() const { return mHandle; } - LLSurface &getLand() const; + LLSurface &getLand() const; - // set and get the region id - const LLUUID& getRegionID() const; - void setRegionID(const LLUUID& region_id); + // set and get the region id + const LLUUID& getRegionID() const; + void setRegionID(const LLUUID& region_id); - BOOL pointInRegionGlobal(const LLVector3d &point_global) const; - LLVector3 getPosRegionFromGlobal(const LLVector3d &point_global) const; - LLVector3 getPosRegionFromAgent(const LLVector3 &agent_pos) const; - LLVector3 getPosAgentFromRegion(const LLVector3 ®ion_pos) const; - LLVector3d getPosGlobalFromRegion(const LLVector3 &offset) const; + BOOL pointInRegionGlobal(const LLVector3d &point_global) const; + LLVector3 getPosRegionFromGlobal(const LLVector3d &point_global) const; + LLVector3 getPosRegionFromAgent(const LLVector3 &agent_pos) const; + LLVector3 getPosAgentFromRegion(const LLVector3 ®ion_pos) const; + LLVector3d getPosGlobalFromRegion(const LLVector3 &offset) const; - LLVLComposition *getComposition() const; - F32 getCompositionXY(const S32 x, const S32 y) const; + LLVLComposition *getComposition() const; + F32 getCompositionXY(const S32 x, const S32 y) const; - BOOL isOwnedSelf(const LLVector3& pos); + BOOL isOwnedSelf(const LLVector3& pos); - // Owned by a group you belong to? (officer OR member) - BOOL isOwnedGroup(const LLVector3& pos); + // Owned by a group you belong to? (officer OR member) + BOOL isOwnedGroup(const LLVector3& pos); - // deal with map object updates in the world. - void updateCoarseLocations(LLMessageSystem* msg); + // deal with map object updates in the world. + void updateCoarseLocations(LLMessageSystem* msg); - F32 getLandHeightRegion(const LLVector3& region_pos); + F32 getLandHeightRegion(const LLVector3& region_pos); - U8 getCentralBakeVersion() { return mCentralBakeVersion; } + U8 getCentralBakeVersion() { return mCentralBakeVersion; } - void getInfo(LLSD& info); - - bool meshRezEnabled() const; - bool meshUploadEnabled() const; + void getInfo(LLSD& info); - // has region received its simulator features list? Requires an additional query after caps received. - void setSimulatorFeaturesReceived(bool); - bool simulatorFeaturesReceived() const; - boost::signals2::connection setSimulatorFeaturesReceivedCallback(const caps_received_signal_t::slot_type& cb); - - void getSimulatorFeatures(LLSD& info) const; - void setSimulatorFeatures(const LLSD& info); + bool meshRezEnabled() const; + bool meshUploadEnabled() const; - - bool dynamicPathfindingEnabled() const; + // has region received its simulator features list? Requires an additional query after caps received. + void setSimulatorFeaturesReceived(bool); + bool simulatorFeaturesReceived() const; + boost::signals2::connection setSimulatorFeaturesReceivedCallback(const caps_received_signal_t::slot_type& cb); - bool avatarHoverHeightEnabled() const; + void getSimulatorFeatures(LLSD& info) const; + void setSimulatorFeatures(const LLSD& info); - typedef enum - { - CACHE_MISS_TYPE_FULL = 0, - CACHE_MISS_TYPE_CRC, - CACHE_MISS_TYPE_NONE - } eCacheMissType; - typedef enum - { - CACHE_UPDATE_DUPE = 0, - CACHE_UPDATE_CHANGED, - CACHE_UPDATE_ADDED, - CACHE_UPDATE_REPLACED - } eCacheUpdateResult; - - // handle a full update message - eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags); - eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags); - LLVOCacheEntry* getCacheEntryForOctree(U32 local_id); - LLVOCacheEntry* getCacheEntry(U32 local_id, bool valid = true); - bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type); - U64 getRegionCacheHitCount() { return mRegionCacheHitCount; } - U64 getRegionCacheMissCount() { return mRegionCacheMissCount; } - void requestCacheMisses(); - void addCacheMissFull(const U32 local_id); - //update object cache if the object receives a full-update or terse update - LLViewerObject* updateCacheEntry(U32 local_id, LLViewerObject* objectp, U32 update_type); - void findOrphans(U32 parent_id); - void clearCachedVisibleObjects(); - void dumpCache(); - - void unpackRegionHandshake(); - - void calculateCenterGlobal(); - void calculateCameraDistance(); - - friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion); + bool dynamicPathfindingEnabled() const; + + bool avatarHoverHeightEnabled() const; + + typedef enum + { + CACHE_MISS_TYPE_FULL = 0, + CACHE_MISS_TYPE_CRC, + CACHE_MISS_TYPE_NONE + } eCacheMissType; + + typedef enum + { + CACHE_UPDATE_DUPE = 0, + CACHE_UPDATE_CHANGED, + CACHE_UPDATE_ADDED, + CACHE_UPDATE_REPLACED + } eCacheUpdateResult; + + // handle a full update message + eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags); + eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags); + LLVOCacheEntry* getCacheEntryForOctree(U32 local_id); + LLVOCacheEntry* getCacheEntry(U32 local_id, bool valid = true); + bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type); + U64 getRegionCacheHitCount() { return mRegionCacheHitCount; } + U64 getRegionCacheMissCount() { return mRegionCacheMissCount; } + void requestCacheMisses(); + void addCacheMissFull(const U32 local_id); + //update object cache if the object receives a full-update or terse update + LLViewerObject* updateCacheEntry(U32 local_id, LLViewerObject* objectp, U32 update_type); + void findOrphans(U32 parent_id); + void clearCachedVisibleObjects(); + void dumpCache(); + + void unpackRegionHandshake(); + + void calculateCenterGlobal(); + void calculateCameraDistance(); + + friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion); /// implements LLCapabilityProvider virtual std::string getDescription() const; std::string getViewerAssetUrl() const { return mViewerAssetUrl; } - U32 getNumOfVisibleGroups() const; - U32 getNumOfActiveCachedObjects() const; - LLSpatialPartition* getSpatialPartition(U32 type); - LLVOCachePartition* getVOCachePartition(); + U32 getNumOfVisibleGroups() const; + U32 getNumOfActiveCachedObjects() const; + LLSpatialPartition* getSpatialPartition(U32 type); + LLVOCachePartition* getVOCachePartition(); - bool objectIsReturnable(const LLVector3& pos, const std::vector& boxes) const; - bool childrenObjectReturnable( const std::vector& boxes ) const; - bool objectsCrossParcel(const std::vector& boxes) const; + bool objectIsReturnable(const LLVector3& pos, const std::vector& boxes) const; + bool childrenObjectReturnable(const std::vector& boxes) const; + bool objectsCrossParcel(const std::vector& boxes) const; - void getNeighboringRegions( std::vector& uniqueRegions ); - void getNeighboringRegionsStatus( std::vector& regions ); - const LLViewerRegionImpl * getRegionImpl() const { return mImpl; } - LLViewerRegionImpl * getRegionImplNC() { return mImpl; } + void getNeighboringRegions(std::vector& uniqueRegions); + void getNeighboringRegionsStatus(std::vector& regions); + const LLViewerRegionImpl * getRegionImpl() const { return mImpl; } + LLViewerRegionImpl * getRegionImplNC() { return mImpl; } - // implements the materials capability throttle - bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); } - void resetMaterialsCapThrottle(); - - U32 getMaxMaterialsPerTransaction() const; + // implements the materials capability throttle + bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); } + void resetMaterialsCapThrottle(); + + U32 getMaxMaterialsPerTransaction() const; - void removeFromCreatedList(U32 local_id); - void addToCreatedList(U32 local_id); + void removeFromCreatedList(U32 local_id); + void addToCreatedList(U32 local_id); - BOOL isPaused() const {return mPaused;} - S32 getLastUpdate() const {return mLastUpdate;} + BOOL isPaused() const { return mPaused; } + S32 getLastUpdate() const { return mLastUpdate; } - static BOOL isNewObjectCreationThrottleDisabled() {return sNewObjectCreationThrottle < 0;} + static BOOL isNewObjectCreationThrottleDisabled() { return sNewObjectCreationThrottle < 0; } + + S64Seconds getDayLength() const { return mDayLength; } + void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; } + S64Seconds getDayOffset() const { return mDayOffset; } + void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; } + bool getIsDefaultDayCycle() const { return mIsDefaultDayCycle; } + void setIsDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } + LLSettingsDay::ptr_t getRegionDayCycle() const { return mDayCycle; } + void setRegionDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; } private: void addToVOCacheTree(LLVOCacheEntry* entry); @@ -525,6 +538,11 @@ private: typedef std::map > orphan_list_t; orphan_list_t mOrphanMap; + S64Seconds mDayLength; + S64Seconds mDayOffset; + bool mIsDefaultDayCycle; + LLSettingsDay::ptr_t mDayCycle; + class CacheMissItem { public: diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 535af317d9..334de8e3db 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -2109,5 +2109,17 @@ Only large parcels can be listed in search. class="land_experiences_panel" filename="panel_region_experiences.xml"> + + diff --git a/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml b/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml index a04050e7eb..82ad031959 100644 --- a/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml +++ b/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml @@ -1,226 +1,181 @@ - - - flex - - - flex - - - flex - - - flex - - - - - flex - - - flex - - - fixed - - - fixed - - - flex - - - flex - - - flex - - - flex - - - - - flex - - - fixed - - - flex - - - - - fixed - - - fixed - - - fixed - - - flex - - - flex - - - flex - - + can_resize="true" + can_close="true" + bevel_style="in" + height="300" + layout="topleft" + min_height="40" + min_width="420" + name="Test Floater" + title="LAYOUTSTACK TESTS" + width="420"> + + + + + Environment Source + + + + + + + + + + + + + + + + + - Time Line Goes here - + left="10" + max_sliders="20" + max_val="24" + name="WLTimeSlider" + show_text="false" + top_pad="0" + use_triangle="true" + width="525" + min_width="525"/> + + + + + + + + + + top="0"> + + + top="0"> + + + name="skip_forward" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25"> @@ -505,15 +512,6 @@ name="cancel_btn" width="100" /> - - -- cgit v1.3 From fa4ac065cb332c8c90fb59eeff0b983a1fd56691 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 24 May 2018 13:11:33 -0700 Subject: Enable sky changes with altitude. --- indra/llinventory/llsettingsbase.cpp | 13 +++- indra/llinventory/llsettingsbase.h | 22 +++++- indra/llinventory/llsettingsdaycycle.h | 2 + indra/llinventory/llsettingssky.h | 2 + indra/llinventory/llsettingswater.h | 2 + indra/newview/llagent.cpp | 14 ++++ indra/newview/llagent.h | 10 ++- indra/newview/llenvironment.cpp | 126 ++++++++++++++++++++++++++------- indra/newview/llenvironment.h | 9 ++- 9 files changed, 168 insertions(+), 32 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index f870ec8904..411eaff8e3 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -547,8 +547,11 @@ F64 LLSettingsBlender::setPosition(F64 blendf) } blendf = llclamp(blendf, 0.0, 1.0); - //_WARNS("LAPRAS") << "blending at " << (blendf * 100.0f) << "%" << LL_ENDL; mTarget->replaceSettings(mInitial->getSettings()); + if (mIsTrivial || (blendf == 0.0)) + { // this is a trivial blend. Results will be identical to the initial. + return blendf; + } mTarget->blend(mFinal, blendf); return blendf; @@ -562,6 +565,11 @@ void LLSettingsBlender::triggerComplete() } //------------------------------------------------------------------------- +F64 LLSettingsBlenderTimeDelta::calculateBlend(F64 spanpos, F64 spanlen) const +{ + return fmod(spanpos, spanlen) / spanlen; +} + void LLSettingsBlenderTimeDelta::update(F64 timedelta) { mTimeSpent += F64Seconds(timedelta); @@ -572,8 +580,7 @@ void LLSettingsBlenderTimeDelta::update(F64 timedelta) return; } - F64 blendf = fmod(mTimeSpent.value(), mBlendSpan.value()) / mBlendSpan.value(); - + F64 blendf = calculateBlend(mTimeSpent.value(), mBlendSpan.value()); // Note no clamp here. setPosition(blendf); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index d00e340b4b..71358d6a49 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -166,6 +166,8 @@ public: virtual bool validate(); + virtual ptr_t buildDerivedClone() = 0; + class Validator { public: @@ -269,10 +271,15 @@ public: mOnFinished(), mTarget(target), mInitial(initsetting), - mFinal(endsetting) + mFinal(endsetting), + mIsTrivial(false) { if (mInitial) mTarget->replaceSettings(mInitial->getSettings()); + + if (!mFinal) + mFinal = mInitial; + mIsTrivial = (mFinal == mInitial); } virtual ~LLSettingsBlender() {} @@ -280,8 +287,16 @@ public: virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 /*span*/ = 1.0) { // note: the 'span' reset parameter is unused by the base class. + if (!mInitial) + LL_WARNS("BLENDER") << "Reseting blender with empty initial setting. Expect badness in the future." << LL_ENDL; + mInitial = initsetting; mFinal = endsetting; + + if (!mFinal) + mFinal = mInitial; + mIsTrivial = (mFinal == mInitial); + mTarget->replaceSettings(mInitial->getSettings()); } @@ -308,6 +323,8 @@ public: virtual void update(F64 blendf); virtual F64 setPosition(F64 blendf); + virtual void switchTrack(S32 trackno, F64 position = -1.0) { /*NoOp*/ } + protected: void triggerComplete(); @@ -316,6 +333,7 @@ protected: LLSettingsBase::ptr_t mTarget; LLSettingsBase::ptr_t mInitial; LLSettingsBase::ptr_t mFinal; + bool mIsTrivial; }; class LLSettingsBlenderTimeDelta : public LLSettingsBlender @@ -349,6 +367,8 @@ public: virtual void update(F64 timedelta) override; protected: + F64 calculateBlend(F64 spanpos, F64 spanlen) const; + F64Seconds mBlendSpan; F64Seconds mLastUpdate; F64Seconds mTimeSpent; diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 9a89031aed..336a00f386 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -114,6 +114,8 @@ public: virtual validation_list_t getValidationList() const override; static validation_list_t validationList(); + virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + protected: LLSettingsDay(); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 59a9dc9a43..9379cd37c3 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -479,6 +479,8 @@ public: return mNextCloudTextureId; } + virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + protected: static const std::string SETTING_LEGACY_EAST_ANGLE; static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 64de4486ca..acae903e92 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -211,6 +211,8 @@ public: static LLSD translateLegacySettings(LLSD legacy); + virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + protected: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; static const std::string SETTING_LEGACY_FOG_COLOR; diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 80e5647ace..b413c21033 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -381,6 +381,7 @@ LLAgent::LLAgent() : mAgentOriginGlobal(), mPositionGlobal(), + mLastTestGlobal(), mDistanceTraveled(0.F), mLastPositionGlobal(LLVector3d::zero), @@ -1070,6 +1071,13 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) pos_agent_d.setVec(pos_agent); mPositionGlobal = pos_agent_d + mAgentOriginGlobal; } + + if (((mLastTestGlobal - mPositionGlobal).lengthSquared() > 1.0) && !mOnPositionChanged.empty()) + { // If the position has changed my more than 1 meter since the last time we triggered. + // filters out some noise. + mLastTestGlobal = mPositionGlobal; + mOnPositionChanged(mFrameAgent.getOrigin(), mPositionGlobal); + } } //----------------------------------------------------------------------------- @@ -1110,6 +1118,12 @@ const LLVector3 &LLAgent::getPositionAgent() return mFrameAgent.getOrigin(); } +boost::signals2::connection LLAgent::whenPositionChanged(position_signal_t::slot_type fn) +{ + return mOnPositionChanged.connect(fn); +} + + //----------------------------------------------------------------------------- // getRegionsVisited() //----------------------------------------------------------------------------- diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 4bb4d317e8..477ec88be4 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -189,6 +189,8 @@ private: // Position //-------------------------------------------------------------------- public: + typedef boost::signals2::signal position_signal_t; + LLVector3 getPosAgentFromGlobal(const LLVector3d &pos_global) const; LLVector3d getPosGlobalFromAgent(const LLVector3 &pos_agent) const; const LLVector3d &getPositionGlobal() const; @@ -196,10 +198,16 @@ public: // Call once per frame to update position, angles (radians). void updateAgentPosition(const F32 dt, const F32 yaw, const S32 mouse_x, const S32 mouse_y); void setPositionAgent(const LLVector3 ¢er); + + boost::signals2::connection whenPositionChanged(position_signal_t::slot_type fn); + protected: void propagate(const F32 dt); // ! BUG ! Should roll into updateAgentPosition private: - mutable LLVector3d mPositionGlobal; + mutable LLVector3d mPositionGlobal; + + position_signal_t mOnPositionChanged; + LLVector3d mLastTestGlobal; //-------------------------------------------------------------------- // Velocity diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 9bc3f65c79..11347917c3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -124,7 +124,7 @@ namespace LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, F64Seconds cyclelength, F64Seconds cycleoffset) : LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), F64Seconds(1.0)), mDay(day), - mTrackNo(trackno), + mTrackNo(0), mCycleLength(cyclelength), mCycleOffset(cycleoffset) { @@ -134,10 +134,57 @@ namespace mFinal = (*initial.second).second; mBlendSpan = getSpanTime(initial); + mTrackNo = selectTrackNumber(trackno); + setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } + + void switchTrack(S32 trackno, F64) override + { + S32 use_trackno = selectTrackNumber(trackno); + + if (use_trackno == mTrackNo) + { // results in no change + return; + } + + mTrackTransitionStart = mTarget->buildDerivedClone(); + mTrackNo = use_trackno; + + F64Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; + LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); + + LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); + F64 targetpos = convertTimeToPosition(now) - (*bounds.first).first; + F64 targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + F64 blendf = calculateBlend(targetpos, targetspan); + pendsetting->blend((*bounds.second).second, blendf); + + reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE.value()); + } + + protected: + S32 selectTrackNumber(S32 trackno) + { + if (trackno == 0) + { // We are dealing with the water track. There is only ever one. + return 0; + } + + for (S32 test = trackno; test == 0; --test) + { // Find the track below the requested one with data. + LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(mTrackNo); + + if (!track.empty()) + return test; + } + + return 1; + } + LLSettingsDay::TrackBound_t getBoundingEntries(F64Seconds time) { LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); @@ -170,6 +217,7 @@ namespace S32 mTrackNo; F64Seconds mCycleLength; F64Seconds mCycleOffset; + LLSettingsBase::ptr_t mTrackTransitionStart; void onFinishedSpan() { @@ -186,6 +234,7 @@ const F32Seconds LLEnvironment::TRANSITION_INSTANT(0.0f); const F32Seconds LLEnvironment::TRANSITION_FAST(1.0f); const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); +const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); @@ -202,7 +251,8 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(LLEnvironment::ENV_LOCAL) + mSelectedEnvironment(LLEnvironment::ENV_LOCAL), + mCurrentTrack(1) { } @@ -228,11 +278,13 @@ void LLEnvironment::initSingleton() requestRegionEnvironment(); - LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLEnvironment::onParcelChange, this)); - gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this)); + LLRegionInfoModel::instance().setUpdateCallback([this]() { onParcelChange(); }); + gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. - gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::requestRegionEnvironment, this)); + gAgent.addRegionChangedCallback([this]() { requestRegionEnvironment(); }); + + gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); } LLEnvironment::~LLEnvironment() @@ -374,6 +426,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe environment->clear(); environment->setDay(pday, daylength, dayoffset); + environment->setSkyTrack(mCurrentTrack); environment->animate(); /*TODO: readjust environment*/ } @@ -1435,6 +1488,29 @@ void LLEnvironment::legacyLoadAllPresets() } } +void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) +{ + S32 trackno = calculateSkyTrackForAltitude(localpos.mV[VZ]); + if (trackno == mCurrentTrack) + return; + + LL_WARNS("LAPRAS") << "Wants to switch to track #" << trackno << LL_ENDL; + + mCurrentTrack = trackno; + for (S32 env = ENV_LOCAL; env < ENV_DEFAULT; ++env) + { + if (mEnvironments[env]) + mEnvironments[env]->setSkyTrack(mCurrentTrack); + } +} + +S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) +{ + //*LAPRAS* temp base on region's response. + return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); +} + + //========================================================================= LLEnvironment::DayInstance::DayInstance() : mDayCycle(), @@ -1533,13 +1609,11 @@ void LLEnvironment::DayInstance::clear() void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) { - /*TODO*/ -// if (trackno != mSkyTrack) -// { -// mSkyTrack = trackno; -// -// // *TODO*: Pick the sky track based on the skytrack. -// } + mSkyTrack = trackno; + if (mBlenderSky) + { + mBlenderSky->switchTrack(trackno); + } } @@ -1572,35 +1646,35 @@ void LLEnvironment::DayInstance::animate() mWater.reset(); mBlenderWater.reset(); } - else if (wtrack.size() == 1) - { - mWater = std::static_pointer_cast((*(wtrack.begin())).second); - mBlenderWater.reset(); - } +// else if (wtrack.size() == 1) +// { +// mWater = std::static_pointer_cast((*(wtrack.begin())).second); +// mBlenderWater.reset(); +// } else { mWater = LLSettingsVOWater::buildDefaultWater(); mBlenderWater = std::make_shared(mWater, mDayCycle, 0, mDayLength, mDayOffset); } - // Day track 1 only for the moment - // sky - LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(mSkyTrack); + // sky, initalize to track 1 + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); if (track.empty()) { mSky.reset(); mBlenderSky.reset(); } - else if (track.size() == 1) - { - mSky = std::static_pointer_cast((*(track.begin())).second); - mBlenderSky.reset(); - } +// else if (track.size() == 1) +// { +// mSky = std::static_pointer_cast((*(track.begin())).second); +// mBlenderSky.reset(); +// } else { mSky = LLSettingsVOSky::buildDefaultSky(); - mBlenderSky = std::make_shared(mSky, mDayCycle, mSkyTrack, mDayLength, mDayOffset); + mBlenderSky = std::make_shared(mSky, mDayCycle, 1, mDayLength, mDayOffset); + mBlenderSky->switchTrack(mSkyTrack); } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index e8e5a74196..cdfac34d90 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -53,6 +53,7 @@ public: static const F32Seconds TRANSITION_FAST; static const F32Seconds TRANSITION_DEFAULT; static const F32Seconds TRANSITION_SLOW; + static const F32Seconds TRANSITION_ALTITUDE; struct EnvironmentInfo { @@ -214,6 +215,8 @@ public: void selectAgentEnvironment(); + S32 calculateSkyTrackForAltitude(F64 altitude); + protected: virtual void initSingleton(); @@ -267,6 +270,7 @@ private: S64Seconds mDayLength; S64Seconds mDayOffset; + S32 mLastTrackAltitude; LLSettingsBlender::ptr_t mBlenderSky; LLSettingsBlender::ptr_t mBlenderWater; @@ -333,6 +337,8 @@ private: change_signal_t mWaterListChange; change_signal_t mDayCycleListChange; + S32 mCurrentTrack; + DayInstance::ptr_t getEnvironmentInstance(EnvSelection_t env, bool create = false); DayInstance::ptr_t getSelectedEnvironmentInstance(); @@ -364,6 +370,7 @@ private: void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment); + void onAgentPositionHasChanged(const LLVector3 &localpos); //========================================================================= void legacyLoadAllPresets(); static LLSD legacyLoadPreset(const std::string& path); @@ -378,7 +385,7 @@ public: LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno); F64 setPosition(F64 position) override; - void switchTrack(S32 trackno, F64 position = -1.0); + virtual void switchTrack(S32 trackno, F64 position) override; S32 getTrack() const { return mTrackNo; } typedef std::shared_ptr ptr_t; -- cgit v1.3 From acaf57100eade61262d73cf5b318c4545e921bd5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 24 May 2018 17:09:01 -0700 Subject: switch track based on altitudes sent from region. --- indra/llinventory/llsettingsbase.cpp | 2 +- indra/llinventory/llsettingsbase.h | 6 +----- indra/newview/llenvironment.cpp | 30 ++++++++++++++++++++++++++---- indra/newview/llenvironment.h | 21 +++++++++++---------- indra/newview/llfloatereditextdaycycle.cpp | 11 +++++------ indra/newview/llfloatereditextdaycycle.h | 2 +- 6 files changed, 45 insertions(+), 27 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 411eaff8e3..d8e337e231 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -548,7 +548,7 @@ F64 LLSettingsBlender::setPosition(F64 blendf) blendf = llclamp(blendf, 0.0, 1.0); mTarget->replaceSettings(mInitial->getSettings()); - if (mIsTrivial || (blendf == 0.0)) + if (!mFinal || (mInitial == mFinal) || (blendf == 0.0)) { // this is a trivial blend. Results will be identical to the initial. return blendf; } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 71358d6a49..1ef7df79ad 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -271,15 +271,13 @@ public: mOnFinished(), mTarget(target), mInitial(initsetting), - mFinal(endsetting), - mIsTrivial(false) + mFinal(endsetting) { if (mInitial) mTarget->replaceSettings(mInitial->getSettings()); if (!mFinal) mFinal = mInitial; - mIsTrivial = (mFinal == mInitial); } virtual ~LLSettingsBlender() {} @@ -295,7 +293,6 @@ public: if (!mFinal) mFinal = mInitial; - mIsTrivial = (mFinal == mInitial); mTarget->replaceSettings(mInitial->getSettings()); } @@ -333,7 +330,6 @@ protected: LLSettingsBase::ptr_t mTarget; LLSettingsBase::ptr_t mInitial; LLSettingsBase::ptr_t mFinal; - bool mIsTrivial; }; class LLSettingsBlenderTimeDelta : public LLSettingsBlender diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 11347917c3..e0cfbbf79e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -961,6 +961,10 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; clearEnvironment(ENV_PARCEL); } + + mTrackAltitudes = envinfo->mAltitudes; + + LL_WARNS("LAPRAS") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; } else { @@ -1250,7 +1254,7 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mDayOffset(0), mDayHash(0), mDaycycleData(), - mAltitudes(), + mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), mIsDefault(false), mIsRegion(false) { @@ -1275,7 +1279,16 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL if (environment.has("is_default")) pinfo->mIsDefault = environment["is_default"].asBoolean(); if (environment.has("track_altitudes")) - pinfo->mAltitudes = environment["track_altitudes"]; + { + LL_WARNS("LAPRAS") << "track_altitudes=" << environment["track_altitudes"] << LL_ENDL; + + /*LAPRAS: TODO: Fix the simulator message. Shouldn't be 5, just 4*/ + int idx = 1; + for (F32 &altitude : pinfo->mAltitudes) + { + altitude = environment["track_altitudes"][idx++].asReal(); + } + } return pinfo; } @@ -1506,8 +1519,17 @@ void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) { - //*LAPRAS* temp base on region's response. - return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); +// //*LAPRAS* temp base on region's response. +// return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); + + auto it = std::find_if_not(mTrackAltitudes.begin(), mTrackAltitudes.end(), [altitude](F32 test) { return altitude > test; }); + + if (it == mTrackAltitudes.begin()) + return 1; + else if (it == mTrackAltitudes.end()) + return 4; + + return std::min(std::distance(mTrackAltitudes.begin(), it), 4LL); } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index cdfac34d90..398c97ebe9 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -61,18 +61,18 @@ public: typedef std::shared_ptr ptr_t; - S32 mParcelId; - LLUUID mRegionId; - S64Seconds mDayLength; - S64Seconds mDayOffset; - size_t mDayHash; - LLSD mDaycycleData; - LLSD mAltitudes; - bool mIsDefault; - bool mIsRegion; + S32 mParcelId; + LLUUID mRegionId; + S64Seconds mDayLength; + S64Seconds mDayOffset; + size_t mDayHash; + LLSD mDaycycleData; + std::array mAltitudes; + bool mIsDefault; + bool mIsRegion; - static ptr_t extract(LLSD); + static ptr_t extract(LLSD); }; @@ -338,6 +338,7 @@ private: change_signal_t mDayCycleListChange; S32 mCurrentTrack; + std::array mTrackAltitudes; DayInstance::ptr_t getEnvironmentInstance(EnvSelection_t env, bool create = false); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 277f2fab52..f4de71426e 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -852,6 +852,7 @@ void LLFloaterEditExtDayCycle::syncronizeTabs() panel->setSettings(psettingWater); panel->setEnabled(canedit); panel->setAllChildrenEnabled(canedit); + panel->refresh(); } } @@ -883,6 +884,7 @@ void LLFloaterEditExtDayCycle::syncronizeTabs() panel->setSettings(psettingSky); panel->setEnabled(canedit); panel->setAllChildrenEnabled(canedit); + panel->refresh(); } } @@ -1041,13 +1043,10 @@ void LLFloaterEditExtDayCycle::onIdlePlay(void* user_data) F32 new_frame = fmod(self->mPlayStartFrame + prcnt_played, 1.f); self->mTimeSlider->setCurSliderValue(new_frame); // will do the rounding - self->selectFrame(self->mTimeSlider->getCurSliderValue()); + self->mSkyBlender->setPosition(new_frame); + self->mWaterBlender->setPosition(new_frame); + self->syncronizeTabs(); - if (self->mPlayTimer.getElapsedTimeF32() > DAY_CYCLE_PLAY_TIME_SECONDS) - { - // Nothing to do anymore. - self->stopPlay(); - } } diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index c68e189cae..f2462ee1cc 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -132,7 +132,7 @@ private: // play functions void startPlay(); void stopPlay(); - static void onIdlePlay(void* user_data); + static void onIdlePlay(void *); LLSettingsDay::ptr_t mEditDay; // edited copy S64Seconds mDayLength; -- cgit v1.3 From 64302d3000b69b31e72eb6a3bd8a981c80cb88de Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 00:18:36 +0100 Subject: Modify use of sky settings, reduce complexity, and name funcs to indicate coord systems in use. Fix class2 softenLightF shader. --- indra/llinventory/llsettingsbase.h | 2 +- indra/llinventory/llsettingssky.cpp | 177 +++++---- indra/llinventory/llsettingssky.h | 113 ++---- indra/llmath/llquaternion.cpp | 2 - indra/llmath/m3math.cpp | 2 - indra/llrender/llrender.h | 5 + indra/llrender/llshadermgr.cpp | 6 +- indra/newview/app_settings/settings.xml | 2 +- .../shaders/class2/deferred/softenLightF.glsl | 8 +- indra/newview/lldrawpoolwater.cpp | 19 +- indra/newview/lldrawpoolwlsky.cpp | 21 +- indra/newview/llenvironment.cpp | 80 ++-- indra/newview/llenvironment.h | 27 +- indra/newview/llface.cpp | 6 +- indra/newview/lllegacyatmospherics.cpp | 6 +- indra/newview/lllegacyatmospherics.h | 2 +- indra/newview/llsettingsvo.cpp | 69 ++-- indra/newview/llsettingsvo.h | 1 + indra/newview/llsky.cpp | 157 +------- indra/newview/llsky.h | 19 +- indra/newview/llstartup.cpp | 3 +- indra/newview/lltoolgun.cpp | 2 +- indra/newview/llviewermessage.cpp | 11 +- indra/newview/llviewershadermgr.cpp | 2 + indra/newview/llvosky.cpp | 417 ++++++++++++--------- indra/newview/llvosky.h | 109 ++---- indra/newview/llvowlsky.cpp | 5 - indra/newview/llvowlsky.h | 3 - indra/newview/pipeline.cpp | 61 ++- indra/newview/pipeline.h | 6 +- 30 files changed, 637 insertions(+), 706 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 5b44dc4666..264c6c6c49 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -251,7 +251,7 @@ protected: void markDirty() { mDirty = true; } private: - bool mDirty; + bool mDirty = true; LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index e06cd7ca72..b8623c3ed3 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -42,13 +42,14 @@ namespace { LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); + static const LLVector3 DUE_EAST = LLVector3::x_axis; } -static LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) +static LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude) { - LLQuaternion body_quat; - body_quat.setEulerAngles(0.0f, -altitude, azimuth); - return body_quat; + LLQuaternion quat; + quat.setEulerAngles(0.0f, -altitude, azimuth); + return quat; } const F32 LLSettingsSky::DOME_OFFSET(0.96f); @@ -487,8 +488,6 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() LLSD(LLSDArray(0.2f)("*")(-2.5f)("*")), LLSD(LLSDArray(20.0f)("*")(0.0f)("*"))))); - validation.push_back(Validator(SETTING_LIGHT_NORMAL, false, LLSD::TypeArray, - boost::bind(&Validator::verifyVectorNormalized, _1, 3))); validation.push_back(Validator(SETTING_MAX_Y, true, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4000.0f))))); validation.push_back(Validator(SETTING_MOON_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal)); @@ -579,8 +578,8 @@ LLSD LLSettingsSky::defaults() LLQuaternion sunquat; LLQuaternion moonquat; - sunquat.setEulerAngles(0.0f, -1.39626, 0.0f); // 80 deg pitch / 0 deg azimuth from East - moonquat.setEulerAngles(0.0f, -1.39626, F_PI); // 80 deg pitch / 180 deg azimuth from East + sunquat = convert_azimuth_and_altitude_to_quat(0.0f, 80.0f * DEG_TO_RAD); + moonquat = convert_azimuth_and_altitude_to_quat(F_PI, 80.0f * DEG_TO_RAD); // Magic constants copied form dfltsetting.xml dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue(); @@ -595,7 +594,6 @@ LLSD LLSettingsSky::defaults() dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); - dfltsetting[SETTING_LIGHT_NORMAL] = LLVector3(0.0000, 0.9126, -0.4086).getValue(); dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); @@ -657,7 +655,7 @@ LLSD LLSettingsSky::translateLegacyHazeSettings(const LLSD& legacy) return legacyhazesettings; } -LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy, const std::string* name) +LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) { LLSD newsettings(defaults()); @@ -719,11 +717,7 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy, const std::strin { newsettings[SETTING_GLOW] = LLColor3(legacy[SETTING_GLOW]).getValue(); } - - if (legacy.has(SETTING_LIGHT_NORMAL)) - { - newsettings[SETTING_LIGHT_NORMAL] = LLVector3(legacy[SETTING_LIGHT_NORMAL]).getValue(); - } + if (legacy.has(SETTING_MAX_Y)) { newsettings[SETTING_MAX_Y] = LLSD::Real(legacy[SETTING_MAX_Y][0].asReal()); @@ -762,16 +756,11 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy, const std::strin F32 azimuth = legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); - F32 pi_over_2 = F_PI * 0.5f; - LLQuaternion sunquat = body_position_from_angles(azimuth - pi_over_2, altitude); - LLQuaternion moonquat = body_position_from_angles(azimuth + pi_over_2, altitude); + LLQuaternion sunquat = convert_azimuth_and_altitude_to_quat(azimuth, altitude); + LLQuaternion moonquat = convert_azimuth_and_altitude_to_quat(azimuth + F_PI, altitude); - if (name) - { - LLVector3 sundir = LLVector3::x_axis * sunquat; - LLVector3 moondir = LLVector3::x_axis * moonquat; - LL_INFOS() << *name << " sun: " << sundir << " moon: " << moondir << LL_ENDL; - } + //LLVector3 sundir = DUE_EAST * sunquat; + //LLVector3 moondir = DUE_EAST * moonquat; newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); @@ -785,11 +774,11 @@ void LLSettingsSky::updateSettings() LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; + mPositionsDirty = isDirty(); + mLightingDirty = isDirty(); + // base class clears dirty flag so as to not trigger recursive update LLSettingsBase::updateSettings(); - - calculateHeavnlyBodyPositions(); - calculateLightSettings(); } bool LLSettingsSky::getIsSunUp() const @@ -804,44 +793,42 @@ bool LLSettingsSky::getIsMoonUp() const return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN; } -void LLSettingsSky::calculateHeavnlyBodyPositions() +void LLSettingsSky::calculateHeavnlyBodyPositions() const { + if (!mPositionsDirty) + { + return; + } + + mPositionsDirty = false; + LLQuaternion sunq = getSunRotation(); LLQuaternion moonq = getMoonRotation(); - mSunDirection = LLVector3::x_axis * sunq; - mSunDirection.normalize(); + mSunDirection = DUE_EAST * sunq; + mMoonDirection = DUE_EAST * moonq; - mMoonDirection = LLVector3::x_axis * moonq; + mSunDirection.normalize(); mMoonDirection.normalize(); +} + +LLVector3 LLSettingsSky::getLightDirection() const +{ + calculateHeavnlyBodyPositions(); // is the normal from the sun or the moon if (getIsSunUp()) { - mLightDirection = mSunDirection; + llassert(mSunDirection.length() > 0.01f); + return mSunDirection; } else if (getIsMoonUp()) { - mLightDirection = mMoonDirection; + llassert(mMoonDirection.length() > 0.01f); + return mMoonDirection; } - else - { - mLightDirection = LLVector3::z_axis; - } - - // calculate the clamp lightnorm for sky (to prevent ugly banding in sky - // when haze goes below the horizon - mClampedLightDirection = mLightDirection; - if (mClampedLightDirection.mV[1] < -0.1f) - { - mClampedLightDirection.mV[1] = -0.1f; - mClampedLightDirection.normalize(); - } - - //LL_INFOS() << "Sun: " << mSunDirection << LL_ENDL; - //LL_INFOS() << "Moon: " << mMoonDirection << LL_ENDL; - //LL_INFOS() << "Light: " << mLightDirection << LL_ENDL; + return LLVector3::z_axis; } LLColor3 LLSettingsSky::getBlueDensity() const @@ -969,42 +956,91 @@ LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const return v; } -void LLSettingsSky::calculateLightSettings() +LLVector3 LLSettingsSky::getSunDirection() const +{ + calculateHeavnlyBodyPositions(); + return mSunDirection; +} + +LLVector3 LLSettingsSky::getMoonDirection() const +{ + calculateHeavnlyBodyPositions(); + return mMoonDirection; +} + +LLColor4U LLSettingsSky::getFadeColor() const +{ + calculateLightSettings(); + return mFadeColor; +} + +LLColor4 LLSettingsSky::getMoonAmbient() const +{ + calculateLightSettings(); + return mMoonAmbient; +} + +LLColor3 LLSettingsSky::getMoonDiffuse() const +{ + calculateLightSettings(); + return mMoonDiffuse; +} + +LLColor4 LLSettingsSky::getSunAmbient() const +{ + calculateLightSettings(); + return mSunAmbient; +} + +LLColor3 LLSettingsSky::getSunDiffuse() const +{ + calculateLightSettings(); + return mSunDiffuse; +} + +LLColor4 LLSettingsSky::getTotalAmbient() const { + calculateLightSettings(); + return mTotalAmbient; +} + +void LLSettingsSky::calculateLightSettings() const +{ + if (!mLightingDirty) + { + return; + } + + calculateHeavnlyBodyPositions(); + + mLightingDirty = false; + // Initialize temp variables LLColor3 sunlight = getSunlightColor(); LLColor3 ambient = getAmbientColor(); - F32 cloud_shadow = getCloudShadow(); - LLVector3 lightnorm = getLightDirection(); + F32 cloud_shadow = getCloudShadow(); + LLVector3 lightnorm = getLightDirection(); - // Sunlight attenuation effect (hue and brightness) due to atmosphere - // this is used later for sunlight modulation at various altitudes + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes F32 max_y = getMaxY(); LLColor3 light_atten = getLightAttenuation(max_y); LLColor3 light_transmittance = getLightTransmittance(); - - // Compute sunlight from P & lightnorm (for long rays like sky) - /// USE only lightnorm. - // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); - // and vary_sunlight will work properly with moon light - F32 lighty = lightnorm[1]; - if (lighty < NIGHTTIME_ELEVATION_SIN) - { - lighty = -lighty; - } + // and vary_sunlight will work properly with moon light + F32 lighty = lightnorm[1]; lighty = llmax(0.f, lighty); if(lighty > 0.f) - { + { lighty = 1.f / lighty; - } + } componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty)); - //increase ambient when there are more clouds - LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; + //increase ambient when there are more clouds + LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; - //brightness of surface both sunlight and ambient + //brightness of surface both sunlight and ambient mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance)); mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5); @@ -1015,4 +1051,3 @@ void LLSettingsSky::calculateLightSettings() mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; mFadeColor.setAlpha(0); } - diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 4c8a5e4016..3084cadd57 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -281,16 +281,6 @@ public: setValue(SETTING_GLOW, val); } - LLVector3 getLightNormal() const - { - return LLVector3(mSettings[SETTING_LIGHT_NORMAL]); - } - - void setLightNormal(const LLVector3 &val) - { - setValue(SETTING_LIGHT_NORMAL, val); - } - F32 getMaxY() const { return mSettings[SETTING_MAX_Y].asReal(); @@ -361,68 +351,7 @@ public: setValue(SETTING_SUN_TEXTUREID, id); } - // Internal/calculated settings - LLVector3 getLightDirection() const - { - update(); - return mLightDirection; - }; - - LLVector3 getClampedLightDirection() const - { - update(); - return mClampedLightDirection; - }; - - LLVector3 getSunDirection() const - { - update(); - return mSunDirection; - } - - LLVector3 getMoonDirection() const - { - update(); - return mMoonDirection; - } - - LLColor4U getFadeColor() const - { - update(); - return mFadeColor; - } - - LLColor4 getMoonAmbient() const - { - update(); - return mMoonAmbient; - } - - LLColor3 getMoonDiffuse() const - { - update(); - return mMoonDiffuse; - } - - LLColor4 getSunAmbient() const - { - update(); - return mSunAmbient; - } - - LLColor3 getSunDiffuse() const - { - update(); - return mSunDiffuse; - } - - LLColor4 getTotalAmbient() const - { - update(); - return mTotalAmbient; - } - -//===================================================================== + //===================================================================== // transient properties used in animations. LLUUID getNextSunTextureId() const { @@ -446,7 +375,7 @@ public: virtual validation_list_t getValidationList() const override; static validation_list_t validationList(); - static LLSD translateLegacySettings(const LLSD& legacy, const std::string* name = nullptr); + static LLSD translateLegacySettings(const LLSD& legacy); static LLSD translateLegacyHazeSettings(const LLSD& legacy); LLColor3 getLightAttenuation(F32 distance) const; @@ -468,9 +397,20 @@ public: void setHazeDensity(F32 val); void setHazeHorizon(F32 val); +// Internal/calculated settings bool getIsSunUp() const; bool getIsMoonUp() const; + LLVector3 getLightDirection() const; + LLVector3 getSunDirection() const; + LLVector3 getMoonDirection() const; + LLColor4U getFadeColor() const; + LLColor4 getMoonAmbient() const; + LLColor3 getMoonDiffuse() const; + LLColor4 getSunAmbient() const; + LLColor3 getSunDiffuse() const; + LLColor4 getTotalAmbient() const; + protected: static const std::string SETTING_LEGACY_EAST_ANGLE; static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; @@ -484,28 +424,29 @@ protected: virtual void updateSettings() override; private: + mutable bool mPositionsDirty = true; + mutable bool mLightingDirty = true; + static LLSD rayleighConfigDefault(); static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); - void calculateHeavnlyBodyPositions(); - void calculateLightSettings(); + void calculateHeavnlyBodyPositions() const; + void calculateLightSettings() const; - LLVector3 mSunDirection; - LLVector3 mMoonDirection; - LLVector3 mLightDirection; - LLVector3 mClampedLightDirection; + mutable LLVector3 mSunDirection; + mutable LLVector3 mMoonDirection; + mutable LLVector3 mLightDirection; static const F32 DOME_RADIUS; static const F32 DOME_OFFSET; - LLColor4U mFadeColor; - LLColor4 mMoonAmbient; - LLColor3 mMoonDiffuse; - LLColor4 mSunAmbient; - LLColor3 mSunDiffuse; - - LLColor4 mTotalAmbient; + mutable LLColor4U mFadeColor; + mutable LLColor4 mMoonAmbient; + mutable LLColor3 mMoonDiffuse; + mutable LLColor4 mSunAmbient; + mutable LLColor3 mSunDiffuse; + mutable LLColor4 mTotalAmbient; LLUUID mNextSunTextureId; LLUUID mNextMoonTextureId; diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp index a7ff707bb8..a8d9eba2a0 100644 --- a/indra/llmath/llquaternion.cpp +++ b/indra/llmath/llquaternion.cpp @@ -38,8 +38,6 @@ #include "m3math.h" #include "llquantize.h" -#pragma optimize("", off) - // WARNING: Don't use this for global const definitions! using this // at the top of a *.cpp file might not give you what you think. const LLQuaternion LLQuaternion::DEFAULT; diff --git a/indra/llmath/m3math.cpp b/indra/llmath/m3math.cpp index 7e59e10bab..65eb3348de 100644 --- a/indra/llmath/m3math.cpp +++ b/indra/llmath/m3math.cpp @@ -34,8 +34,6 @@ #include "m3math.h" #include "llquaternion.h" -#pragma optimize("", off) - // LLMatrix3 // ji diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 113909c1c6..ceebc7000b 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -503,6 +503,11 @@ const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X 0.f, 1.f, 0.f, 0.f, // Y becomes Z 0.f, 0.f, 0.f, 1.f }; +const F32 XYZ_TO_OGL_ROTATION[16] = { 1.f, 0.f, 0.f, 0.f, // X stays X + 0.f, 0.f, -1.f, 0.f, // Z becomes -Y + 0.f, 1.f, 0.f, 0.f, // Y becomes Z + 0.f, 0.f, 0.f, 1.f }; + glh::matrix4f copy_matrix(F32* src); glh::matrix4f get_current_modelview(); glh::matrix4f get_current_projection(); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 4d0e0f2249..aa54a5f040 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -35,6 +35,8 @@ #include "OpenGL/OpenGL.h" #endif +#pragma optimize("", off) + #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") #else @@ -552,8 +554,8 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns, const std::string& if (log.length() > 0) { - LL_INFOS() << "Shader loading from " << fname << ":\n" << LL_ENDL; - LL_INFOS() << log << LL_ENDL; + LL_INFOS("ShaderErrors") << "Shader loading from " << fname << ":\n" << LL_ENDL; + LL_INFOS("ShaderErrors") << log << LL_ENDL; } } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c9e0f7c2f4..0793784878 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8645,7 +8645,7 @@ Type Boolean Value - 0 + 1 RenderLocalLights diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index c20092bfe0..371b32406c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -82,6 +82,8 @@ vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleFragSoftClip(vec3 l); vec3 atmosFragAffectDirectionalLight(float intensity, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); +vec3 fullbrightFragAtmosTransport(vec3 l, vec3 additive, vec3 atten); +vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 atten); vec4 getPosition_d(vec2 pos_screen, float depth) { @@ -147,7 +149,7 @@ void main() calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); - col = atmosAmbient(vec3(0)); + col = atmosFragAmbient(vec3(0), amblit); float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; @@ -167,7 +169,7 @@ void main() // float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); + vec3 dumbshiny = sunlit*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; @@ -192,7 +194,7 @@ void main() if (norm.w < 0.5) { col = mix(atmosFragLighting(col, additive, atten), fullbrightFragAtmosTransport(col, atten, additive), diffuse.a); - col = mix(scaleFragSoftClip(col), fullbrightFragScaleSoftClip(col), diffuse.a); + col = mix(scaleFragSoftClip(col), fullbrightScaleSoftClipFrag(col, atten), diffuse.a); } #ifdef WATER_FOG diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index bcc0023089..9cd59c61ec 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -488,26 +488,29 @@ void LLDrawPoolWater::shade() LLVector3 light_dir; LLColor3 light_color; - LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsWater::ptr_t pwater = environment.getCurrentWater(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); - light_dir = voskyp->getLightDirection(); + light_dir = environment.getLightDirection(); light_dir.normalize(); - bool sun_up = LLEnvironment::instance().getIsSunUp(); - bool moon_up = LLEnvironment::instance().getIsSunUp(); + bool sun_up = environment.getIsSunUp(); + bool moon_up = environment.getIsMoonUp(); if (sun_up) { - light_color = light_color + voskyp->getSunAmbientColor(); - light_diffuse += voskyp->getSunDiffuseColor(); + light_color = light_color + psky->getSunAmbient(); + light_diffuse += psky->getSunDiffuse(); } light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); if (moon_up) { - light_color += voskyp->getMoonDiffuseColor(); - light_diffuse += voskyp->getMoonDiffuseColor() * 0.5f; + LLColor3 moon_diffuse_color = psky->getMoonDiffuse(); + light_color += moon_diffuse_color; + light_diffuse += moon_diffuse_color * 0.5f; if (!sun_up) { diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 277f1f3d6c..def81e46fc 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -179,22 +179,12 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering()); sky_shader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); - static float sunSize = (float)cos(0.0005); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLVector4 light_dir = LLEnvironment::instance().getClampedLightNorm(); + F32 sunSize = (float)cosf(psky->getSunArcRadians()); sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); - - static LLVector3 solDir(-0.935f, 0.23f, 0.27f); - - static bool fooA = false; - static bool fooB = false; - - //neither of these appear to track with the env settings, would the real sun please stand up. - if (fooA) solDir = gPipeline.mTransformedSunDir; - if (fooB) solDir = gSky.mVOSkyp->getSun().getDirection(); - - solDir.normalize(); - - sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV); + sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, light_dir.mV); // clouds are rendered along with sky in adv atmo if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull()) @@ -295,7 +285,7 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh cloud_shader->bind(); /// Render the skydome - renderDome(camPosLocal, camHeightLocal, cloud_shader); +//renderDome(camPosLocal, camHeightLocal, cloud_shader); cloud_shader->unbind(); } @@ -339,6 +329,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (gPipeline.canUseVertexShaders()) { gHighlightProgram.bind(); + gHighlightProgram.uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); } LLFacePool::LLOverrideFaceColor color_override(this, color); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a6f0f2cb62..0177f88b6d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -56,6 +56,8 @@ #include "llatmosphere.h" +#pragma optimize("", off) + //define EXPORT_PRESETS 1 //========================================================================= namespace @@ -630,6 +632,52 @@ void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) } } +LLVector3 LLEnvironment::getLightDirection() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, 1); + } + return psky->getLightDirection(); +} + +LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +{ + LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); + return vec_cfr; +} + +LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +{ + LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); + return vec_ogl; +} + +LLVector4 LLEnvironment::getLightDirectionCFR() const +{ + LLVector3 light_direction = getLightDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getClampedLightNorm() const +{ + LLVector3 light_direction = getLightDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getRotatedLightNorm() const +{ + LLVector3 light_direction = getLightDirection(); + light_direction *= LLQuaternion(-mLastCamYaw, LLVector3(0.f, 1.f, 0.f)); + return toLightNorm(light_direction); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -644,18 +692,14 @@ void LLEnvironment::update(const LLViewerCamera * cam) // update clouds, sun, and general updateCloudScroll(); - F32 camYaw = cam->getYaw(); + // cache this for use in rotating the rotated light vec for shader param updates later... + mLastCamYaw = cam->getYaw() + SUN_DELTA_YAW; stop_glerror(); // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { - LLVector3 lightNorm3( getLightDirection() ); - - lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f)); - mRotatedLight = LLVector4(lightNorm3, 0.f); - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; end_shaders = LLViewerShaderMgr::instance()->endShaders(); for (shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) @@ -767,26 +811,10 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) { if (gPipeline.canUseWindLightShaders()) - { - updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + { updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); - } - - if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) - { - stop_glerror(); - shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLight.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - stop_glerror(); - } - else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) - { - stop_glerror(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); - stop_glerror(); - } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + } } LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const @@ -1552,6 +1580,7 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mInitialized = false; mSky = psky; + mSky->update(); mBlenderSky.reset(); if (gAtmosphere) @@ -1570,6 +1599,7 @@ void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) mInitialized = false; mWater = pwater; + mWater->update(); mBlenderWater.reset(); } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 615318a4e6..27bb6e7fc2 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -188,15 +188,23 @@ public: bool getIsSunUp() const; bool getIsMoonUp() const; - inline F32 getSceneLightStrength() const { return mSceneLightStrength; } - inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } + // Returns either sun or moon direction (depending on which is up and stronger) + // Light direction in +x right, +z up, +y at internal coord sys + LLVector3 getLightDirection() const; - inline LLVector4 getLightDirection() const { return ((mCurrentEnvironment->getSky()) ? LLVector4(mCurrentEnvironment->getSky()->getLightDirection(), 0.0f) : LLVector4(0, 0, 1, 0)); } - inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentEnvironment->getSky()->getClampedLightDirection(), 0.0f); } - inline LLVector4 getRotatedLight() const { return mRotatedLight; } + // Returns light direction converted to CFR coord system + LLVector4 getLightDirectionCFR() const; + + // Returns light direction converted to OGL coord system + // and clamped above -0.1f in Y to avoid render artifacts in sky shaders + LLVector4 getClampedLightNorm() const; + + // Returns light direction converted to OGL coord system + // and rotated by last cam yaw needed by water rendering shaders + LLVector4 getRotatedLightNorm() const; static LLSettingsWater::ptr_t createWaterFromLegacyPreset(const std::string filename); - static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename); + static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename); //------------------------------------------- connection_t setSkyListChange(const change_signal_t::slot_type& cb); @@ -220,6 +228,9 @@ protected: virtual void initSingleton(); private: + LLVector4 toCFR(const LLVector3 vec) const; + LLVector4 toLightNorm(const LLVector3 vec) const; + class DayInstance { public: @@ -295,6 +306,7 @@ private: }; static const F32 SUN_DELTA_YAW; + F32 mLastCamYaw = 0.0f; typedef std::map AssetSettingMap_t; @@ -325,9 +337,6 @@ private: namedSettingMap_t mDayCycleByName; AssetSettingMap_t mDayCycleById; - F32 mSceneLightStrength; - LLVector4 mRotatedLight; - UserPrefs mUserPrefs; change_signal_t mSkyListChange; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 5af4cd89c4..a880cfa2a2 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -42,7 +42,6 @@ #include "llrender.h" #include "lllightconstants.h" #include "llsky.h" -#include "llenvironment.h" #include "llviewercamera.h" #include "llviewertexturelist.h" #include "llvopartgroup.h" @@ -1626,14 +1625,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { tep->getScale( &s_scale, &t_scale ); } - - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - // Use the nudged south when coming from above sun angle, such // that emboss mapping always shows up on the upward faces of cubes when // it's noon (since a lot of builders build with the sun forced to noon). LLVector3 sun_ray = gSky.mVOSkyp->mBumpSunDir; - LLVector3 moon_ray = psky->getMoonDirection(); + LLVector3 moon_ray = gSky.mVOSkyp->getMoon().getDirection(); LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray; bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV); diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index ff09e62f76..59cfab61fd 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -267,7 +267,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) F32 density_multiplier = psky->getDensityMultiplier(); F32 max_y = psky->getMaxY(); - LLVector3 lightnorm = psky->getLightNormal(); + LLVector3 lightnorm = LLVector3(LLEnvironment::instance().getClampedLightNorm()); // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); @@ -444,8 +444,10 @@ LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& va return res; } -void LLAtmospherics::updateFog(const F32 distance, LLVector3& tosun) +void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) { + LLVector3 tosun = tosun_in; + if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG)) { if (!LLGLSLShader::sNoFixedFunction) diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index 83250ee50b..ded7e1f554 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -207,7 +207,7 @@ public: ~LLAtmospherics(); void init(); - void updateFog(const F32 distance, LLVector3& tosun); + void updateFog(const F32 distance, const LLVector3& tosun); const LLHaze& getHaze() const { return mHaze; } LLHaze& getHaze() { return mHaze; } diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index bd69659e7a..85cdd1e984 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -365,7 +365,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &legacy) { - LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy, &name); + LLSD newsettings = LLSettingsSky::translateLegacySettings(legacy); newsettings[SETTING_NAME] = name; @@ -476,7 +476,7 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA sunquat.getEulerAngles(&roll, &pitch, &yaw); legacy[SETTING_LEGACY_EAST_ANGLE] = yaw; - legacy[SETTING_LEGACY_SUN_ANGLE] = pitch; + legacy[SETTING_LEGACY_SUN_ANGLE] = -pitch; return legacy; } @@ -485,32 +485,51 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA void LLSettingsVOSky::updateSettings() { LLSettingsSky::updateSettings(); - LLVector3 sun_direction = getSunDirection(); LLVector3 moon_direction = getMoonDirection(); - // axis swap converts from +x right, +z up, +y at - // to CFR (+x at, +z up, +y right) - // set direction (in CRF) and don't allow overriding - //LLVector3 crf_sunDirection(sun_direction.mV[1], sun_direction.mV[0], sun_direction.mV[2]); - //LLVector3 crf_moonDirection(moon_direction.mV[1], moon_direction.mV[0], moon_direction.mV[2]); - - gSky.setSunDirection(sun_direction, moon_direction); + F32 dp = getLightDirection() * LLVector3(0.0f, 0.0f, 1.0f); + if (dp < 0) + { + dp = 0; + } + dp = llmax(dp, 0.1f); + + // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio + // between sunlight and point lights in windlight to normalize point lights. + F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); + mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + + // Axis swaps convert from +x right, +z up, +y at + // to CFR +x at, +z up, +y right coord sys + LLVector3 sun_direction_cfr(sun_direction.mV[0], -sun_direction.mV[1], sun_direction.mV[2]); + LLVector3 moon_direction_cfr(moon_direction.mV[0], -moon_direction.mV[1], moon_direction.mV[2]); + gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); } void LLSettingsVOSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); - shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); + if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + } + else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) + { + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - { LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); - } + } + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); } LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const @@ -519,12 +538,12 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { +// LEGACY_ATMOSPHERICS + param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; - - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; @@ -663,12 +682,16 @@ void LLSettingsVOWater::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); - shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + if (shader->mShaderGroup == LLGLSLShader::SG_WATER) + { + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); + shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + } } void LLSettingsVOWater::updateSettings() @@ -702,7 +725,7 @@ void LLSettingsVOWater::updateSettings() mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); - LLVector4 light_direction = LLEnvironment::instance().getLightDirection(); + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); } @@ -820,7 +843,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) { std::string newname = "sky:" + (*itm).first; - LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second, &newname); + LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second); newsettings[SETTING_NAME] = newname; frames[newname] = newsettings; diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 3339aaf037..2f91117858 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -107,6 +107,7 @@ protected: virtual parammapping_t getParameterMap() const override; bool m_isAdvanced = false; + F32 mSceneLightStrength = 3.0f; }; //========================================================================= diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp index f7ccf7c7ff..41fe206ada 100644 --- a/indra/newview/llsky.cpp +++ b/indra/newview/llsky.cpp @@ -129,170 +129,31 @@ void LLSky::resetVertexBuffers() } } -void LLSky::setSunDirection(const LLVector3 &sun_direction, const LLVector3 &moon_direction) +void LLSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_direction, const LLVector3 &moon_direction) { - if(mVOSkyp.notNull()) { - mVOSkyp->setSunDirection(sun_direction, moon_direction); + if(mVOSkyp.notNull()) { + mVOSkyp->setSunAndMoonDirectionsCFR(sun_direction, moon_direction); } } -/*LLVector3 LLSky::getSunDirection() const -{ - if (mVOSkyp) - { - return mVOSkyp->getToSun(); - } - else - { - return LLVector3::z_axis; - } -} - - -LLVector3 LLSky::getMoonDirection() const -{ - if (mVOSkyp) - { - return mVOSkyp->getToMoon(); - } - else - { - return LLVector3::z_axis; - } -}*/ - - -LLColor4 LLSky::getSunDiffuseColor() const -{ - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getSunDiffuseColor()); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); - } -} - -LLColor4 LLSky::getSunAmbientColor() const -{ - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getSunAmbientColor()); - } - else - { - return LLColor4(0.f, 0.f, 0.f, 1.f); - } -} - - -LLColor4 LLSky::getMoonDiffuseColor() const -{ - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getMoonDiffuseColor()); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); - } -} - -LLColor4 LLSky::getMoonAmbientColor() const -{ - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getMoonAmbientColor()); - } - else - { - return LLColor4(0.f, 0.f, 0.f, 0.f); - } -} - - -LLColor4 LLSky::getTotalAmbientColor() const -{ - if (mVOSkyp) - { - return mVOSkyp->getTotalAmbientColor(); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); - } -} - - -/*BOOL LLSky::sunUp() const -{ - if (mVOSkyp) - { - return mVOSkyp->isSunUp(); - } - else - { - return TRUE; - } -}*/ - - -LLColor4U LLSky::getFadeColor() const -{ - if (mVOSkyp) - { - return mVOSkyp->getFadeColor(); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); - } -} - - ////////////////////////////////////////////////////////////////////// // Public Methods ////////////////////////////////////////////////////////////////////// -void LLSky::init(const LLVector3 &sun_direction) +void LLSky::init() { - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - mVOWLSkyp = static_cast(gObjectList.createObjectViewer(LLViewerObject::LL_VO_WL_SKY, NULL)); - mVOWLSkyp->initSunDirection(sun_direction, LLVector3::zero); + mVOWLSkyp->init(); gPipeline.createObject(mVOWLSkyp.get()); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - mVOSkyp = (LLVOSky *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_SKY, NULL); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - mVOSkyp->initSunDirection(sun_direction, LLVector3()); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - gPipeline.createObject((LLViewerObject *)mVOSkyp); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); + mVOSkyp->init(); + gPipeline.createObject(mVOSkyp.get()); mVOGroundp = (LLVOGround*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_GROUND, NULL); - LLVOGround *groundp = mVOGroundp; - gPipeline.createObject((LLViewerObject *)groundp); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - gSky.setFogRatio(gSavedSettings.getF32("RenderFogRatio")); + gPipeline.createObject(mVOGroundp.get()); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); + gSky.setFogRatio(gSavedSettings.getF32("RenderFogRatio")); mUpdatedThisFrame = TRUE; } diff --git a/indra/newview/llsky.h b/indra/newview/llsky.h index 626076fea4..8e86853481 100644 --- a/indra/newview/llsky.h +++ b/indra/newview/llsky.h @@ -48,11 +48,11 @@ public: LLSky(); ~LLSky(); - void init(const LLVector3 &sun_direction); - + void init(); void cleanup(); - void setSunDirection(const LLVector3 &sun_direction, const LLVector3 &moon_direction); + // These directions should be in CFR coord sys (+x at, +z up, +y right) + void setSunAndMoonDirectionsCFR(const LLVector3 &sun_direction, const LLVector3 &moon_direction); LLColor4 getSkyFogColor() const; @@ -70,19 +70,6 @@ public: F32 getFogRatio() const; LLColor4U getFadeColor() const; - //LLVector3 getSunDirection() const; - //LLVector3 getMoonDirection() const; - - LLColor4 getSunDiffuseColor() const; - LLColor4 getMoonDiffuseColor() const; - LLColor4 getSunAmbientColor() const; - LLColor4 getMoonAmbientColor() const; - LLColor4 getTotalAmbientColor() const; - //BOOL sunUp() const; - - // Legacy - void setSunPhase(const F32) { } - void destroyGL(); void restoreGL(); void resetVertexBuffers(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index deebd91198..e7a149ac0c 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -332,7 +332,6 @@ bool idle_startup() static std::string auth_desc; static std::string auth_message; - static LLVector3 initial_sun_direction(1.f, 0.f, 0.f); static LLVector3 agent_start_position_region(10.f, 10.f, 10.f); // default for when no space server // last location by default @@ -1467,7 +1466,7 @@ bool idle_startup() LLGLState::checkTextureChannels(); LLEnvironment::instance().loadPreferences(); - gSky.init(initial_sun_direction); + gSky.init(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp index 6903e69d46..fb96804bfa 100644 --- a/indra/newview/lltoolgun.cpp +++ b/indra/newview/lltoolgun.cpp @@ -108,7 +108,7 @@ BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask) if (gSavedSettings.getBOOL("MouseSun")) { LLVector3 sunpos = LLViewerCamera::getInstance()->getAtAxis(); - gSky.setSunDirection(sunpos, -sunpos); + gSky.setSunAndMoonDirectionsCFR(sunpos, -sunpos); gSavedSettings.setVector3("SkySunDefaultPosition", LLViewerCamera::getInstance()->getAtAxis()); } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index e4c71c1648..e88afdc465 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3395,6 +3395,7 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data) void process_time_synch(LLMessageSystem *mesgsys, void **user_data) { LLVector3 sun_direction; + LLVector3 moon_direction; LLVector3 sun_ang_velocity; F32 phase; U64 space_time_usec; @@ -3416,11 +3417,11 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) LL_DEBUGS("Windlight Sync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; - gSky.setSunPhase(phase); - if ( !gSavedSettings.getBOOL("SkyOverrideSimSunPosition") ) - { - gSky.setSunDirection(sun_direction, -sun_direction); - } + + /* LAPRAS + We decode these parts of the message but ignore them + as the real values are provided elsewhere. */ + (void)sun_direction, (void)moon_direction, (void)phase; } void process_sound_trigger(LLMessageSystem *msg, void **) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 5aa29f920e..40cf4c82e6 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -46,6 +46,8 @@ #include "llenvironment.h" #include "llatmosphere.h" +#pragma optimize("", off) + #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") #else diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index dc4f4a92d4..a2ea3181ca 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -53,6 +53,8 @@ #include "llsettingssky.h" #include "llenvironment.h" +#pragma optimize("", off) + #undef min #undef max @@ -71,6 +73,9 @@ static const LLVector2 TEX01 = LLVector2(0.f, 1.f); static const LLVector2 TEX10 = LLVector2(1.f, 0.f); static const LLVector2 TEX11 = LLVector2(1.f, 1.f); +static const F32 LIGHT_DIRECTION_THRESHOLD = (F32) cosf(DEG_TO_RAD * 1.f); +static const F32 COLOR_CHANGE_THRESHOLD = 0.01f; + // Exported globals LLUUID gSunTextureID = IMG_SUN; LLUUID gMoonTextureID = IMG_MOON; @@ -185,11 +190,165 @@ void LLSkyTex::bindTexture(BOOL curr) } /*************************************** - Sky + LLHeavenBody ***************************************/ F32 LLHeavenBody::sInterpVal = 0; +LLHeavenBody::LLHeavenBody(const F32 rad) +: mDirectionCached(LLVector3(0,0,0)), + mDirection(LLVector3(0,0,0)), + mIntensity(0.f), + mDiskRadius(rad), + mDraw(FALSE), + mHorizonVisibility(1.f), + mVisibility(1.f), + mVisible(FALSE) +{ + mColor.setToBlack(); + mColorCached.setToBlack(); +} + +const LLVector3& LLHeavenBody::getDirection() const +{ + return mDirection; +} + +void LLHeavenBody::setDirection(const LLVector3 &direction) +{ + mDirection = direction; +} + +void LLHeavenBody::setAngularVelocity(const LLVector3 &ang_vel) +{ + mAngularVelocity = ang_vel; +} + +const LLVector3& LLHeavenBody::getAngularVelocity() const +{ + return mAngularVelocity; +} + +const LLVector3& LLHeavenBody::getDirectionCached() const +{ + return mDirectionCached; +} + +void LLHeavenBody::renewDirection() +{ + mDirectionCached = mDirection; +} + +const LLColor3& LLHeavenBody::getColorCached() const +{ + return mColorCached; +} + +void LLHeavenBody::setColorCached(const LLColor3& c) +{ + mColorCached = c; +} + +const LLColor3& LLHeavenBody::getColor() const +{ + return mColor; +} + +void LLHeavenBody::setColor(const LLColor3& c) +{ + mColor = c; +} + +void LLHeavenBody::renewColor() +{ + mColorCached = mColor; +} + +F32 LLHeavenBody::interpVal() +{ + return sInterpVal; +} + +void LLHeavenBody::setInterpVal(const F32 v) +{ + sInterpVal = v; +} + +LLColor3 LLHeavenBody::getInterpColor() const +{ + return sInterpVal * mColor + (1 - sInterpVal) * mColorCached; +} + +const F32& LLHeavenBody::getVisibility() const +{ + return mVisibility; +} + +void LLHeavenBody::setVisibility(const F32 c) +{ + mVisibility = c; +} + +bool LLHeavenBody::isVisible() const +{ + return mVisible; +} + +void LLHeavenBody::setVisible(const bool v) +{ + mVisible = v; +} + +const F32& LLHeavenBody::getIntensity() const +{ + return mIntensity; +} + +void LLHeavenBody::setIntensity(const F32 c) +{ + mIntensity = c; +} + +void LLHeavenBody::setDiskRadius(const F32 radius) +{ + mDiskRadius = radius; +} + +F32 LLHeavenBody::getDiskRadius() const +{ + return mDiskRadius; +} + +void LLHeavenBody::setDraw(const bool draw) +{ + mDraw = draw; +} + +bool LLHeavenBody::getDraw() const +{ + return mDraw; +} + +const LLVector3& LLHeavenBody::corner(const S32 n) const +{ + return mQuadCorner[n]; +} + +LLVector3& LLHeavenBody::corner(const S32 n) +{ + return mQuadCorner[n]; +} + +const LLVector3* LLHeavenBody::corners() const +{ + return mQuadCorner; +} + +/*************************************** + Sky +***************************************/ + + S32 LLVOSky::sResolution = LLSkyTex::getResolution(); S32 LLVOSky::sTileResX = sResolution/NUM_TILES_X; S32 LLVOSky::sTileResY = sResolution/NUM_TILES_Y; @@ -227,16 +386,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mAtmHeight = ATM_HEIGHT; mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); - // *LAPRAS - mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getSunDirection(); - - if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) - { - - initSunDirection(LLVector3(mSunDefaultPosition.mV[2], mSunDefaultPosition.mV[0], mSunDefaultPosition.mV[1]), LLVector3(0, 0, 0)); - } - - mSun.setIntensity(SUN_INTENSITY); mMoon.setIntensity(0.1f * SUN_INTENSITY); @@ -265,6 +414,11 @@ LLVOSky::~LLVOSky() void LLVOSky::init() { + llassert(!mInitialized); + + // Update sky at least once to get correct initial sun/moon directions and lighting calcs performed + LLEnvironment::instance().getCurrentSky()->update(); + updateDirections(); // Initialize the cached normalized direction vectors @@ -353,10 +507,11 @@ void LLVOSky::restoreGL() if(cube_map) { cube_map->init(images); - mForceUpdate = TRUE; } } + mForceUpdate = TRUE; + if (mDrawable) { gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); @@ -426,24 +581,13 @@ void LLVOSky::updateDirections(void) mSun.renewColor(); mMoon.renewDirection(); mMoon.renewColor(); - - float dp = psky->getSunDirection() * LLVector3::y_axis; - if (dp < 0) - { - dp = 0; - } - - // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio - // between sunlight and point lights in windlight to normalize point lights. - F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - LLEnvironment::instance().setSceneLightStrength(2.0f * (1.0f + sun_dynamic_range * dp)); } void LLVOSky::idleUpdate(LLAgent &agent, const F64 &time) { } -BOOL LLVOSky::updateSky() +bool LLVOSky::updateSky() { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); @@ -473,6 +617,8 @@ BOOL LLVOSky::updateSky() mUpdateTimer.reset(); const S32 frame = next_frame; + mForceUpdate = mForceUpdate || (total_no_tiles == frame); + ++next_frame; next_frame = next_frame % cycle_frame_no; @@ -482,26 +628,27 @@ BOOL LLVOSky::updateSky() LLHeavenBody::setInterpVal( mInterpVal ); updateDirections(); - if (mForceUpdate || total_no_tiles == frame) + LLVector3 direction = mSun.getDirection(); + direction.normalize(); + const F32 dot_lighting = direction * mLastLightingDirection; + + LLColor3 delta_color; + delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0], + mLastTotalAmbient.mV[1] - total_ambient.mV[1], + mLastTotalAmbient.mV[2] - total_ambient.mV[2]); + + bool light_direction_changed = (dot_lighting >= LIGHT_DIRECTION_THRESHOLD); + bool color_changed = (delta_color.length() >= COLOR_CHANGE_THRESHOLD); + + mForceUpdate = mForceUpdate || light_direction_changed; + mForceUpdate = mForceUpdate || color_changed; + mForceUpdate = mForceUpdate || !mInitialized; + + if (mForceUpdate) { - LLSkyTex::stepCurrent(); - - const static F32 LIGHT_DIRECTION_THRESHOLD = (F32) cos(DEG_TO_RAD * 1.f); - const static F32 COLOR_CHANGE_THRESHOLD = 0.01f; - - LLVector3 direction = mSun.getDirection(); - direction.normalize(); - const F32 dot_lighting = direction * mLastLightingDirection; - - LLColor3 delta_color; - delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0], - mLastTotalAmbient.mV[1] - total_ambient.mV[1], - mLastTotalAmbient.mV[2] - total_ambient.mV[2]); - - bool light_direction_changed = (dot_lighting >= LIGHT_DIRECTION_THRESHOLD); - bool color_changed = (delta_color.length() >= COLOR_CHANGE_THRESHOLD); - bool do_update = !mInitialized || mForceUpdate || light_direction_changed || color_changed; - if ( do_update && !direction.isExactlyZero()) + LLSkyTex::stepCurrent(); + + if (!direction.isExactlyZero()) { mLastLightingDirection = direction; mLastTotalAmbient = total_ambient; @@ -509,52 +656,49 @@ BOOL LLVOSky::updateSky() if (mCubeMap) { - if (mForceUpdate) - { - updateFog(LLViewerCamera::getInstance()->getFar()); + updateFog(LLViewerCamera::getInstance()->getFar()); - for (int side = 0; side < 6; side++) + for (int side = 0; side < 6; side++) + { + for (int tile = 0; tile < NUM_TILES; tile++) { - for (int tile = 0; tile < NUM_TILES; tile++) - { - createSkyTexture(side, tile); - } + createSkyTexture(side, tile); } + } - for (int side = 0; side < 6; side++) - { - LLImageRaw* raw1 = mSkyTex[side].getImageRaw(TRUE); - LLImageRaw* raw2 = mSkyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE)); - - raw1 = mShinyTex[side].getImageRaw(TRUE); - raw2 = mShinyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mShinyTex[side].createGLImage(mShinyTex[side].getWhich(FALSE)); - } - next_frame = 0; - - // update the sky texture - for (S32 i = 0; i < 6; ++i) - { - mSkyTex[i].create(1.0f); - mShinyTex[i].create(1.0f); - } - - // update the environment map - if (mCubeMap) - { - std::vector > images; - images.reserve(6); - for (S32 side = 0; side < 6; side++) - { - images.push_back(mShinyTex[side].getImageRaw(TRUE)); - } - mCubeMap->init(images); - gGL.getTexUnit(0)->disable(); - } + for (int side = 0; side < 6; side++) + { + LLImageRaw* raw1 = mSkyTex[side].getImageRaw(TRUE); + LLImageRaw* raw2 = mSkyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE)); + + raw1 = mShinyTex[side].getImageRaw(TRUE); + raw2 = mShinyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mShinyTex[side].createGLImage(mShinyTex[side].getWhich(FALSE)); } + next_frame = 0; + + // update the sky texture + for (S32 i = 0; i < 6; ++i) + { + mSkyTex[i].create(1.0f); + mShinyTex[i].create(1.0f); + } + + // update the environment map + if (mCubeMap) + { + std::vector > images; + images.reserve(6); + for (S32 side = 0; side < 6; side++) + { + images.push_back(mShinyTex[side].getImageRaw(TRUE)); + } + mCubeMap->init(images); + gGL.getTexUnit(0)->disable(); + } } } @@ -706,7 +850,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) const F32 camera_height = mCameraPosAgent.mV[2]; const F32 height_above_water = camera_height - water_height; - BOOL sun_flag = FALSE; + bool sun_flag = FALSE; if (mSun.isVisible()) { @@ -722,7 +866,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) if (height_above_water > 0) { - BOOL render_ref = gPipeline.getPool(LLDrawPool::POOL_WATER)->getVertexShaderLevel() == 0; + bool render_ref = gPipeline.getPool(LLDrawPool::POOL_WATER)->getVertexShaderLevel() == 0; if (sun_flag) { @@ -750,7 +894,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) return TRUE; } -BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, LLHeavenBody& hb, const LLVector3 &up, const LLVector3 &right) +bool LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, LLHeavenBody& hb, const LLVector3 &up, const LLVector3 &right) { mHeavenlyBodyUpdated = TRUE ; @@ -1180,96 +1324,35 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, void LLVOSky::updateFog(const F32 distance) { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - m_legacyAtmospherics.updateFog(distance, psky->getSunDirection()); + LLEnvironment& environment = LLEnvironment::instance(); + LLVector3 light_dir = LLVector3(environment.getClampedLightNorm()); + m_legacyAtmospherics.updateFog(distance, light_dir); } -void LLVOSky::initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity) +void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLVector3 &moon_dir_cfr) { - LLVector3 sun_direction = (sun_dir.length() == 0) ? LLVector3::x_axis : sun_dir; - sun_direction.normalize(); - mSun.setDirection(sun_direction); - mSun.renewDirection(); - mSun.setAngularVelocity(sun_ang_velocity); - mMoon.setDirection(-mSun.getDirection()); - mMoon.renewDirection(); - mLastLightingDirection = mSun.getDirection(); - - updateDirections(); + mSun.setDirection(sun_dir_cfr); + mMoon.setDirection(moon_dir_cfr); - if ( !mInitialized ) - { - init(); - LLSkyTex::stepCurrent(); - } -} - -void LLVOSky::setSunDirection(const LLVector3 &sun_dir, const LLVector3 &moon_dir) -{ - LLVector3 sun_direction = (sun_dir.length() == 0) ? LLVector3::x_axis : sun_dir; - LLVector3 moon_direction = (moon_dir.length() == 0) ? LLVector3::x_axis : moon_dir; - - sun_direction.normalize(); - moon_direction.normalize(); + mLastLightingDirection = mSun.getDirection(); // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping // on the upward facing faces of cubes. - LLVector3 newDir = sun_direction; - - // Same as dot product with the up direction + clamp. - F32 sunDot = llmax(0.f, newDir.mV[2]); - sunDot *= sunDot; - - // Create normalized vector that has the sunDir pushed south about an hour and change. - LLVector3 adjustedDir = (newDir + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; + { + // Same as dot product with the up direction + clamp. + F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); + sunDot *= sunDot; - // Blend between normal sun dir and adjusted sun dir based on how close we are - // to having the sun overhead. - mBumpSunDir = adjustedDir * sunDot + newDir * (1.0f - sunDot); - mBumpSunDir.normalize(); + // Create normalized vector that has the sunDir pushed south about an hour and change. + LLVector3 adjustedDir = (sun_dir_cfr + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; - F32 dp = mLastLightingDirection * sun_direction; - mSun.setDirection(sun_direction); + // Blend between normal sun dir and adjusted sun dir based on how close we are + // to having the sun overhead. + mBumpSunDir = adjustedDir * sunDot + sun_dir_cfr * (1.0f - sunDot); + mBumpSunDir.normalize(); + } - mMoon.setDirection(moon_direction); updateDirections(); - if (dp < 0.995f) { //the sun jumped a great deal, update immediately - mForceUpdate = TRUE; - } -} - -LLVector3 LLVOSky::getLightDirection() const -{ - return LLEnvironment::instance().getCurrentSky()->getLightDirection(); -} - -LLColor4U LLVOSky::getFadeColor() const -{ - return LLEnvironment::instance().getCurrentSky()->getFadeColor(); -} - -LLColor3 LLVOSky::getSunDiffuseColor() const -{ - return LLEnvironment::instance().getCurrentSky()->getSunDiffuse(); -} - -LLColor3 LLVOSky::getMoonDiffuseColor() const -{ - return LLEnvironment::instance().getCurrentSky()->getMoonDiffuse(); -} - -LLColor4 LLVOSky::getSunAmbientColor() const -{ - return LLEnvironment::instance().getCurrentSky()->getSunAmbient(); -} - -LLColor4 LLVOSky::getMoonAmbientColor() const -{ - return LLEnvironment::instance().getCurrentSky()->getMoonAmbient(); -} - -LLColor4 LLVOSky::getTotalAmbientColor() const -{ - return LLEnvironment::instance().getCurrentSky()->getTotalAmbient(); + LLSkyTex::stepCurrent(); } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 96fe12e21c..4de3d12068 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -141,69 +141,56 @@ protected: LLVector3 mAngularVelocity; // velocity of the local heavenly body F32 mDiskRadius; - BOOL mDraw; // FALSE - do not draw. + bool mDraw; // FALSE - do not draw. F32 mHorizonVisibility; // number [0, 1] due to how horizon F32 mVisibility; // same but due to other objects being in throng. - BOOL mVisible; + bool mVisible; static F32 sInterpVal; LLVector3 mQuadCorner[4]; LLVector3 mO; public: - LLHeavenBody(const F32 rad) : - mDirectionCached(LLVector3(0,0,0)), - mDirection(LLVector3(0,0,0)), - mIntensity(0.f), - mDiskRadius(rad), mDraw(FALSE), - mHorizonVisibility(1.f), mVisibility(1.f), - mVisible(FALSE) - { - mColor.setToBlack(); - mColorCached.setToBlack(); - } + LLHeavenBody(const F32 rad); ~LLHeavenBody() {} - const LLVector3& getDirection() const { return mDirection; } - void setDirection(const LLVector3 &direction) { mDirection = direction; } - void setAngularVelocity(const LLVector3 &ang_vel) { mAngularVelocity = ang_vel; } - const LLVector3& getAngularVelocity() const { return mAngularVelocity; } + const LLVector3& getDirection() const; + void setDirection(const LLVector3 &direction); + void setAngularVelocity(const LLVector3 &ang_vel); + const LLVector3& getAngularVelocity() const; - const LLVector3& getDirectionCached() const { return mDirectionCached; } - void renewDirection() { mDirectionCached = mDirection; } + const LLVector3& getDirectionCached() const; + void renewDirection(); - const LLColor3& getColorCached() const { return mColorCached; } - void setColorCached(const LLColor3& c) { mColorCached = c; } - const LLColor3& getColor() const { return mColor; } - void setColor(const LLColor3& c) { mColor = c; } + const LLColor3& getColorCached() const; + void setColorCached(const LLColor3& c); + const LLColor3& getColor() const; + void setColor(const LLColor3& c); - void renewColor() { mColorCached = mColor; } + void renewColor(); - static F32 interpVal() { return sInterpVal; } - static void setInterpVal(const F32 v) { sInterpVal = v; } + static F32 interpVal(); + static void setInterpVal(const F32 v); - LLColor3 getInterpColor() const - { - return sInterpVal * mColor + (1 - sInterpVal) * mColorCached; - } + LLColor3 getInterpColor() const; - const F32& getVisibility() const { return mVisibility; } - void setVisibility(const F32 c = 1) { mVisibility = c; } + const F32& getVisibility() const; + void setVisibility(const F32 c = 1); - BOOL isVisible() const { return mVisible; } - void setVisible(const BOOL v) { mVisible = v; } + bool isVisible() const; + void setVisible(const bool v); - const F32& getIntensity() const { return mIntensity; } - void setIntensity(const F32 c) { mIntensity = c; } + const F32& getIntensity() const; + void setIntensity(const F32 c); - void setDiskRadius(const F32 radius) { mDiskRadius = radius; } - F32 getDiskRadius() const { return mDiskRadius; } + void setDiskRadius(const F32 radius); + F32 getDiskRadius() const; - void setDraw(const BOOL draw) { mDraw = draw; } - BOOL getDraw() const { return mDraw; } + void setDraw(const bool draw); + bool getDraw() const; - const LLVector3& corner(const S32 n) const { return mQuadCorner[n]; } - LLVector3& corner(const S32 n) { return mQuadCorner[n]; } - const LLVector3* corners() const { return mQuadCorner; } + const LLVector3& corner(const S32 n) const; + LLVector3& corner(const S32 n); + const LLVector3* corners() const; }; class LLCubeMap; @@ -237,7 +224,7 @@ public: void restoreGL(); /*virtual*/ void idleUpdate(LLAgent &agent, const F64 &time); - BOOL updateSky(); + bool updateSky(); // Graphical stuff for objects - maybe broken out into render class // later? @@ -245,29 +232,15 @@ public: /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); - const LLHeavenBody& getSun() const { return mSun; } + const LLHeavenBody& getSun() const { return mSun; } const LLHeavenBody& getMoon() const { return mMoon; } - //const LLVector3& getToSunLast() const { return mSun.getDirectionCached(); } - //const LLVector3& getToSun() const { return mSun.getDirection(); } - //const LLVector3& getToMoon() const { return mMoon.getDirection(); } - //const LLVector3& getToMoonLast() const { return mMoon.getDirectionCached(); } - //BOOL isSunUp() const { return mSun.getDirectionCached().mV[2] > -0.05f; } - - LLVector3 getLightDirection() const; - LLColor3 getSunDiffuseColor() const; - LLColor3 getMoonDiffuseColor() const; - LLColor4 getSunAmbientColor() const; - LLColor4 getMoonAmbientColor() const; - LLColor4 getTotalAmbientColor() const; - - BOOL isSameFace(S32 idx, const LLFace* face) const { return mFace[idx] == face; } - - void initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity); + bool isSameFace(S32 idx, const LLFace* face) const { return mFace[idx] == face; } - void setSunDirection(const LLVector3 &sun_dir, const LLVector3 &moon_dir); + // directions provided should already be in CFR coord sys (+x at, +z up, +y right) + void setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir, const LLVector3 &moon_dir); - BOOL updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 side, LLHeavenBody& hb, const LLVector3 &up, const LLVector3 &right); + bool updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 side, LLHeavenBody& hb, const LLVector3 &up, const LLVector3 &right); void updateReflectionGeometry(LLDrawable *drawable, F32 H, const LLHeavenBody& HB); F32 getWorldScale() const { return mWorldScale; } @@ -291,7 +264,7 @@ public: LLCubeMap *getCubeMap() const { return mCubeMap; } S32 getDrawRefl() const { return mDrawRefl; } void setDrawRefl(const S32 r) { mDrawRefl = r; } - BOOL isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; } + bool isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; } LLFace* getReflFace() const { return mFace[FACE_REFLECTION]; } LLViewerTexture* getSunTex() const { return mSunTexturep; } @@ -333,12 +306,12 @@ protected: LLColor3 mBrightestPointNew; F32 mBrightnessScaleGuess; LLColor3 mBrightestPointGuess; - BOOL mWeatherChange; + bool mWeatherChange; F32 mCloudDensity; F32 mWind; - BOOL mInitialized; - BOOL mForceUpdate; //flag to force instantaneous update of cubemap + bool mInitialized; + bool mForceUpdate; //flag to force instantaneous update of cubemap LLVector3 mLastLightingDirection; LLColor3 mLastTotalAmbient; F32 mAmbientScale; @@ -351,7 +324,7 @@ protected: LLFrameTimer mUpdateTimer; - BOOL mHeavenlyBodyUpdated ; + bool mHeavenlyBodyUpdated ; LLAtmospherics m_legacyAtmospherics; }; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 3ab149fef0..bdef2ed9fb 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -87,11 +87,6 @@ LLVOWLSky::LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regi initStars(); } -void LLVOWLSky::initSunDirection(LLVector3 const & sun_direction, - LLVector3 const & sun_angular_velocity) -{ -} - void LLVOWLSky::idleUpdate(LLAgent &agent, const F64 &time) { diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h index 8bc6afba1b..3c801d5d57 100644 --- a/indra/newview/llvowlsky.h +++ b/indra/newview/llvowlsky.h @@ -50,9 +50,6 @@ private: public: LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); - void initSunDirection(LLVector3 const & sun_direction, - LLVector3 const & sun_angular_velocity); - /*virtual*/ void idleUpdate(LLAgent &agent, const F64 &time); /*virtual*/ BOOL isActive(void) const; /*virtual*/ LLDrawable * createDrawable(LLPipeline *pipeline); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 625f811789..f3e4291092 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -116,6 +116,8 @@ #include "llenvironment.h" +#pragma optimize("", off) + #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 //#define DEBUG_INDICES @@ -2145,7 +2147,7 @@ void check_references(LLSpatialGroup* group, LLFace* face) void LLPipeline::checkReferences(LLFace* face) { -#if 0 +#if CHECK_PIPELINE_REFERENCES if (sCull) { for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) @@ -2177,7 +2179,7 @@ void LLPipeline::checkReferences(LLFace* face) void LLPipeline::checkReferences(LLDrawable* drawable) { -#if 0 +#if CHECK_PIPELINE_REFERENCES if (sCull) { for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) @@ -2228,7 +2230,7 @@ void check_references(LLSpatialGroup* group, LLDrawInfo* draw_info) void LLPipeline::checkReferences(LLDrawInfo* draw_info) { -#if 0 +#if CHECK_PIPELINE_REFERENCES if (sCull) { for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) @@ -2254,7 +2256,7 @@ void LLPipeline::checkReferences(LLDrawInfo* draw_info) void LLPipeline::checkReferences(LLSpatialGroup* group) { -#if 0 +#if CHECK_PIPELINE_REFERENCES if (sCull) { for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) @@ -6018,8 +6020,9 @@ void LLPipeline::setupAvatarLights(bool for_edit) } else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini) { - LLVector3 opposite_pos = -1.f * mSunDir; - LLVector3 orthog_light_pos = mSunDir % LLVector3::z_axis; + LLVector3 sun_dir = LLVector3(mSunDir); + LLVector3 opposite_pos = -sun_dir; + LLVector3 orthog_light_pos = sun_dir % LLVector3::z_axis; LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f); backlight_pos.normalize(); @@ -6243,27 +6246,29 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) { assertInitialized(); + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); + // Ambient if (!LLGLSLShader::sNoFixedFunction) { gGL.syncMatrices(); - LLColor4 ambient = gSky.getTotalAmbientColor(); + LLColor4 ambient = psky->getTotalAmbient(); gGL.setAmbientLightColor(ambient); } // Light 0 = Sun or Moon (All objects) { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLVector4 light_dir = environment.getLightDirectionCFR(); + mSunDir.setVec(light_dir); - if (LLEnvironment::instance().getIsSunUp()) - { - mSunDir.setVec(psky->getSunDirection()); - mSunDiffuse.setVec(gSky.getSunDiffuseColor()); + if (environment.getIsSunUp()) + { + mSunDiffuse.setVec(psky->getSunDiffuse()); } else { - mSunDir.setVec(psky->getMoonDirection()); - mSunDiffuse.setVec(gSky.getMoonDiffuseColor()); + mSunDiffuse.setVec(psky->getMoonDiffuse()); } F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); @@ -6273,20 +6278,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) } mSunDiffuse.clamp(); - LLVector4 light_pos(mSunDir, 0.0f); LLColor4 light_diffuse = mSunDiffuse; - if (LLPipeline::sRenderDeferred) - { - /*light_diffuse.mV[0] = powf(light_diffuse.mV[0], 2.2f); - light_diffuse.mV[1] = powf(light_diffuse.mV[1], 2.2f); - light_diffuse.mV[2] = powf(light_diffuse.mV[2], 2.2f);*/ - } - mHWLightColors[0] = light_diffuse; LLLightState* light = gGL.getLight(0); - light->setPosition(light_pos); + light->setPosition(mSunDir); light->setDiffuse(light_diffuse); light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); @@ -6505,7 +6502,7 @@ void LLPipeline::enableLights(U32 mask) mLightMask = mask; stop_glerror(); - LLColor4 ambient = gSky.getTotalAmbientColor(); + LLColor4 ambient = LLEnvironment::instance().getCurrentSky()->getTotalAmbient(); gGL.setAmbientLightColor(ambient); } } @@ -8470,8 +8467,7 @@ void LLPipeline::renderDeferredLighting() { setupHWLights(NULL); //to set mSunDir; - LLVector4 dir(mSunDir, 0.f); - glh::vec4f tc(dir.mV); + glh::vec4f tc(mSunDir.mV); mat.mult_matrix_vec(tc); mTransformedSunDir.set(tc.v); } @@ -9084,8 +9080,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) { setupHWLights(NULL); //to set mSunDir; - LLVector4 dir(mSunDir, 0.f); - glh::vec4f tc(dir.mV); + glh::vec4f tc(mSunDir.mV); mat.mult_matrix_vec(tc); mTransformedSunDir.set(tc.v); } @@ -10654,15 +10649,17 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; + LLVector3 sun_dir(mSunDir); + //put together a universal "near clip" plane for shadow frusta LLPlane shadow_near_clip; - { + { LLVector3 p = gAgent.getPositionAgent(); - p += mSunDir * RenderFarClip*2.f; - shadow_near_clip.setVec(p, mSunDir); + p += sun_dir * RenderFarClip*2.f; + shadow_near_clip.setVec(p, sun_dir); } - LLVector3 lightDir = -mSunDir; + LLVector3 lightDir = -sun_dir; lightDir.normVec(); glh::vec3f light_dir(lightDir.mV); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 75fed7dd39..d3fe5b4fdd 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -655,9 +655,9 @@ public: U32 mTrueNoiseMap; U32 mLightFunc; - LLColor4 mSunDiffuse; - LLVector3 mSunDir; - LLVector3 mTransformedSunDir; + LLColor4 mSunDiffuse; + LLVector4 mSunDir; + LLVector4 mTransformedSunDir; bool mInitialized; bool mVertexShadersEnabled; -- cgit v1.3 From 8dd85013865cc5b426234cd71b605d7208bcfe01 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 15:50:25 +0100 Subject: Fix mis-merge of LLSettingsBase and remove optimize pragmas. --- indra/llinventory/llsettingsbase.h | 2 ++ indra/llinventory/llsettingssky.cpp | 7 ++----- indra/llinventory/llsettingssky.h | 4 +++- indra/llrender/llshadermgr.cpp | 2 -- indra/newview/llenvironment.cpp | 2 -- indra/newview/llsettingsvo.cpp | 2 -- indra/newview/llviewershadermgr.cpp | 2 -- indra/newview/llvosky.cpp | 2 -- indra/newview/pipeline.cpp | 2 -- 9 files changed, 7 insertions(+), 18 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 29ed50419a..0b99166a86 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -166,6 +166,8 @@ public: virtual bool validate(); + virtual ptr_t buildDerivedClone() = 0; + class Validator { public: diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index b8623c3ed3..6c5ed8f12b 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -32,17 +32,14 @@ #include "llfasttimer.h" #include "v3colorutil.h" -#pragma optimize("", off) - static const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees static const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD); - +static const LLVector3 DUE_EAST = LLVector3::x_axis; //========================================================================= namespace { LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); - LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); - static const LLVector3 DUE_EAST = LLVector3::x_axis; + LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); } static LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude) diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 9b50f5a4b6..ee201f4122 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -376,13 +376,15 @@ public: static validation_list_t validationList(); static LLSD translateLegacySettings(const LLSD& legacy); + +// LEGACY_ATMOSPHERICS static LLSD translateLegacyHazeSettings(const LLSD& legacy); LLColor3 getLightAttenuation(F32 distance) const; LLColor3 getLightTransmittance() const; LLColor3 gammaCorrect(const LLColor3& in) const; -// LEGACY_ATMOSPHERICS + LLColor3 getBlueDensity() const; LLColor3 getBlueHorizon() const; F32 getHazeDensity() const; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index aa54a5f040..544a4f00aa 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -35,8 +35,6 @@ #include "OpenGL/OpenGL.h" #endif -#pragma optimize("", off) - #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") #else diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e9c27a7794..2650f69a2f 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -58,8 +58,6 @@ #include "llatmosphere.h" -#pragma optimize("", off) - //define EXPORT_PRESETS 1 //========================================================================= namespace diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index d5bcbd1894..451a0fb326 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -58,8 +58,6 @@ #include "llassetstorage.h" #include "llvfile.h" -#pragma optimize("", off) - #undef VERIFY_LEGACY_CONVERSION //========================================================================= diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 6837c6a815..820e18290f 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -46,8 +46,6 @@ #include "llenvironment.h" #include "llatmosphere.h" -#pragma optimize("", off) - #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") #else diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index a2ea3181ca..fc83218b1a 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -53,8 +53,6 @@ #include "llsettingssky.h" #include "llenvironment.h" -#pragma optimize("", off) - #undef min #undef max diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e80b5cc9ef..27db6778eb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -116,8 +116,6 @@ #include "llenvironment.h" -#pragma optimize("", off) - #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 //#define DEBUG_INDICES -- cgit v1.3 From 8cfdc07e790a557e881fadaa1b6258e5b16751f4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 23:32:30 +0100 Subject: Code cleanup and move to using typedefs of S64Seconds/F64Seconds for ease in sync w/ sim side which has not llunits types. --- indra/llinventory/llsettingsbase.cpp | 2 +- indra/llinventory/llsettingsbase.h | 13 +- indra/llinventory/llsettingsdaycycle.cpp | 14 +- indra/llinventory/llsettingsdaycycle.h | 21 +- indra/llinventory/llsettingssky.cpp | 10 +- indra/llinventory/llsettingssky.h | 4 +- indra/llinventory/llsettingswater.h | 8 +- indra/llrender/llglslshader.cpp | 332 ++++++++++++++++++----------- indra/llrender/llglslshader.h | 33 +-- indra/llrender/llrender.cpp | 2 +- indra/llrender/llrender.h | 7 +- indra/llrender/llshadermgr.cpp | 4 +- indra/llrender/llshadermgr.h | 5 - indra/llrender/llvertexbuffer.cpp | 2 +- indra/newview/llenvironment.cpp | 60 +++--- indra/newview/llenvironment.h | 48 ++--- indra/newview/llfloatereditextdaycycle.cpp | 4 +- indra/newview/llfloatereditextdaycycle.h | 2 +- indra/newview/llfloaterland.cpp | 4 +- indra/newview/llfloaterregioninfo.cpp | 4 +- 20 files changed, 317 insertions(+), 262 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index d8e337e231..a661d52b7f 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -572,7 +572,7 @@ F64 LLSettingsBlenderTimeDelta::calculateBlend(F64 spanpos, F64 spanlen) const void LLSettingsBlenderTimeDelta::update(F64 timedelta) { - mTimeSpent += F64Seconds(timedelta); + mTimeSpent += LLSettingsBase::Seconds(timedelta); if (mTimeSpent > mBlendSpan) { diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 0b99166a86..6f072a4e50 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -41,6 +41,7 @@ #include "llquaternion.h" #include "v4color.h" #include "v3color.h" +#include "llunits.h" #include "llinventorysettings.h" @@ -54,6 +55,8 @@ class LLSettingsBase : friend std::ostream &operator <<(std::ostream& os, LLSettingsBase &settings); public: + typedef F64Seconds Seconds; + static const std::string SETTING_ID; static const std::string SETTING_NAME; static const std::string SETTING_HASH; @@ -344,7 +347,7 @@ public: mLastUpdate(0.0f), mTimeSpent(0.0f) { - mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch()); + mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; } @@ -367,10 +370,10 @@ public: protected: F64 calculateBlend(F64 spanpos, F64 spanlen) const; - F64Seconds mBlendSpan; - F64Seconds mLastUpdate; - F64Seconds mTimeSpent; - F64Seconds mTimeStart; + LLSettingsBase::Seconds mBlendSpan; + LLSettingsBase::Seconds mLastUpdate; + LLSettingsBase::Seconds mTimeSpent; + LLSettingsBase::Seconds mTimeStart; }; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 577b12b031..6f4e70e98f 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -89,13 +89,13 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash"); const std::string LLSettingsDay::SETTING_TRACKS("tracks"); const std::string LLSettingsDay::SETTING_FRAMES("frames"); -const S64Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins -const S64Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours -const S64Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days +const LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins +const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours +const LLSettingsDay::Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days -const S64Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0); -const S64Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) -const S64Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours +const LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0); +const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) +const LLSettingsDay::Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water @@ -465,7 +465,7 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track) //========================================================================= void LLSettingsDay::startDayCycle() { - F64Seconds now(LLDate::now().secondsSinceEpoch()); + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); if (!mInitialized) { diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 5e6fc7f21d..0929cff87c 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -48,13 +48,16 @@ public: static const std::string SETTING_TRACKS; static const std::string SETTING_FRAMES; - static const S64Seconds MINIMUM_DAYLENGTH; - static const S64Seconds DEFAULT_DAYLENGTH; - static const S64Seconds MAXIMUM_DAYLENGTH; + // 32-bit as LLSD only supports that width at present + typedef S32Seconds Seconds; - static const S64Seconds MINIMUM_DAYOFFSET; - static const S64Seconds DEFAULT_DAYOFFSET; - static const S64Seconds MAXIMUM_DAYOFFSET; + static const Seconds MINIMUM_DAYLENGTH; + static const Seconds DEFAULT_DAYLENGTH; + static const Seconds MAXIMUM_DAYLENGTH; + + static const Seconds MINIMUM_DAYOFFSET; + static const Seconds DEFAULT_DAYOFFSET; + static const Seconds MAXIMUM_DAYOFFSET; static const S32 TRACK_WATER; static const S32 TRACK_MAX; @@ -129,7 +132,7 @@ protected: private: CycleList_t mDayTracks; - F64Seconds mLastUpdateTime; + LLSettingsBase::Seconds mLastUpdateTime; void parseFromLLSD(LLSD &data); @@ -137,10 +140,6 @@ private: static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); - -// void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender); -// void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); - }; #endif diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 6c5ed8f12b..b6320e0942 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -790,7 +790,7 @@ bool LLSettingsSky::getIsMoonUp() const return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN; } -void LLSettingsSky::calculateHeavnlyBodyPositions() const +void LLSettingsSky::calculateHeavenlyBodyPositions() const { if (!mPositionsDirty) { @@ -811,7 +811,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() const LLVector3 LLSettingsSky::getLightDirection() const { - calculateHeavnlyBodyPositions(); + calculateHeavenlyBodyPositions(); // is the normal from the sun or the moon if (getIsSunUp()) @@ -955,13 +955,13 @@ LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const LLVector3 LLSettingsSky::getSunDirection() const { - calculateHeavnlyBodyPositions(); + calculateHeavenlyBodyPositions(); return mSunDirection; } LLVector3 LLSettingsSky::getMoonDirection() const { - calculateHeavnlyBodyPositions(); + calculateHeavenlyBodyPositions(); return mMoonDirection; } @@ -1008,7 +1008,7 @@ void LLSettingsSky::calculateLightSettings() const return; } - calculateHeavnlyBodyPositions(); + calculateHeavenlyBodyPositions(); mLightingDirty = false; diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index ee201f4122..6e532eba55 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -423,7 +423,7 @@ protected: LLSettingsSky(); virtual stringset_t getSlerpKeys() const override; - + virtual stringset_t getSkipInterpolateKeys() const; virtual void updateSettings() override; private: @@ -434,7 +434,7 @@ private: static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); - void calculateHeavnlyBodyPositions() const; + void calculateHeavenlyBodyPositions() const; void calculateLightSettings() const; mutable LLVector3 mSunDirection; diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index acae903e92..35e5b7bcf6 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -76,22 +76,22 @@ public: setValue(SETTING_BLUR_MULTIPILER, val); } - LLColor3 getFogColor() const + LLColor3 getWaterFogColor() const { return LLColor3(mSettings[SETTING_FOG_COLOR]); } - void setFogColor(LLColor3 val) + void setWaterFogColor(LLColor3 val) { setValue(SETTING_FOG_COLOR, val); } - F32 getFogDensity() const + F32 getWaterFogDensity() const { return mSettings[SETTING_FOG_DENSITY].asReal(); } - void setFogDensity(F32 val) + void setWaterFogDensity(F32 val) { setValue(SETTING_FOG_DENSITY, val); } diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index b027a24017..37bcf0c163 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -157,7 +157,8 @@ void LLGLSLShader::clearStats() mSamplesDrawn = 0; mDrawCalls = 0; mTextureStateFetched = false; - mTextureMagMinFilter.clear(); + mTextureMagFilter.clear(); + mTextureMinFilter.clear(); } void LLGLSLShader::dumpStats() @@ -170,16 +171,14 @@ void LLGLSLShader::dumpStats() { LL_INFOS() << mShaderFiles[i].first << LL_ENDL; } - for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it) + for (U32 i = 0; i < mTexture.size(); ++i) { - S32 i = (*it).first; - GLint idx = (*it).second; + GLint idx = mTexture[i]; if (idx >= 0) { GLint uniform_idx = getUniformLocation(i); - magmin_filter_t::iterator it = mTextureMagMinFilter.find(i); - LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << (*it).second.second << "/" << (*it).second.first << std::dec << LL_ENDL; + LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << LL_ENDL; } } LL_INFOS() << "=============================================" << LL_ENDL; @@ -236,13 +235,14 @@ void LLGLSLShader::placeProfileQuery() if (!mTextureStateFetched) { mTextureStateFetched = true; + mTextureMagFilter.resize(mTexture.size()); + mTextureMinFilter.resize(mTexture.size()); U32 cur_active = gGL.getCurrentTexUnitIndex(); - for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it) + for (U32 i = 0; i < mTexture.size(); ++i) { - S32 i = (*it).first; - GLint idx = (*it).second; + GLint idx = mTexture[i]; if (idx >= 0) { @@ -256,7 +256,8 @@ void LLGLSLShader::placeProfileQuery() glGetTexParameteriv(type, GL_TEXTURE_MAG_FILTER, (GLint*) &mag); glGetTexParameteriv(type, GL_TEXTURE_MIN_FILTER, (GLint*) &min); - mTextureMagMinFilter[i] = magmin_values_t(mag, min); + mTextureMagFilter[i] = mag; + mTextureMinFilter[i] = min; } } @@ -414,7 +415,7 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, for ( ; fileIter != mShaderFiles.end(); fileIter++ ) { GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels); - LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << " shaderhandle=" << shaderhandle << LL_ENDL; + LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL; if (shaderhandle) { attachObject(shaderhandle); @@ -477,14 +478,13 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, } S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten - for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it) + for (U32 i = 0; i < mTexture.size(); i++) { - int i = (*it).first; - if (((*it).second >= 0) && ((*it).second < channel_count)) + if (mTexture[i] > -1 && mTexture[i] < channel_count) { llassert(cur_tex < gGLManager.mNumTextureImageUnits); uniform1i(i, cur_tex); - (*it).second = cur_tex++; + mTexture[i] = cur_tex++; } } unbind(); @@ -545,7 +545,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector * attri mAttribute.clear(); U32 numAttributes = (attributes == NULL) ? 0 : attributes->size(); +#if LL_RELEASE_WITH_DEBUG_INFO + mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, { -1, NULL }); +#else mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1); +#endif if (res) { //read back channel locations @@ -559,7 +563,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector * attri S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name); if (index != -1) { +#if LL_RELEASE_WITH_DEBUG_INFO + mAttribute[i] = { index, name }; +#else mAttribute[i] = index; +#endif mAttributeMask |= 1 << i; LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL; } @@ -659,20 +667,17 @@ void LLGLSLShader::mapUniform(GLint index, const vector * mUniformMap[hashedName] = location; LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL; - + //find the index of this uniform for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++) { - if (LLShaderMgr::instance()->mReservedUniforms[i] == name) + if ( (mUniform[i] == -1) + && (LLShaderMgr::instance()->mReservedUniforms[i] == name)) { - std::pair result; - - result = mUniform.insert(uniforms_index_t::value_type(i, location)); - if (result.second) - { - mTexture[i] = mapUniformTextureChannel(location, type); - return; - } + //found it + mUniform[i] = location; + mTexture[i] = mapUniformTextureChannel(location, type); + return; } } @@ -680,17 +685,13 @@ void LLGLSLShader::mapUniform(GLint index, const vector * { for (U32 i = 0; i < uniforms->size(); i++) { - std::pair result; - S32 index = i + LLShaderMgr::instance()->mReservedUniforms.size(); - - if ((*uniforms)[i] == hashedName) + if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1) + && ((*uniforms)[i].String() == name)) { - result = mUniform.insert(uniforms_index_t::value_type(index, location)); - if (result.second) - { - mTexture[index] = mapUniformTextureChannel(location, type); - return; - } + //found it + mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location; + mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type); + return; } } } @@ -730,6 +731,10 @@ BOOL LLGLSLShader::mapUniforms(const vector * uniforms) mUniformNameMap.clear(); mTexture.clear(); mValue.clear(); + //initialize arrays + U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size(); + mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); + mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); bind(); @@ -929,14 +934,20 @@ S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LL S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode) { - GLint channel = getTexChannelForIndex(uniform); + if (uniform < 0 || uniform >= (S32)mTexture.size()) + { + UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + return -1; + } - if (channel > -1) + uniform = mTexture[uniform]; + + if (uniform > -1) { - gGL.getTexUnit(channel)->bind(texture, mode); + gGL.getTexUnit(uniform)->bind(texture, mode); } - return channel; + return uniform; } S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode) @@ -949,64 +960,82 @@ S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureT S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode) { - GLint channel = getTexChannelForIndex(uniform); - - if (channel > -1) + if (uniform < 0 || uniform >= (S32)mTexture.size()) { - gGL.getTexUnit(channel)->unbind(mode); + UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + return -1; + } + + uniform = mTexture[uniform]; + + if (uniform > -1) + { + gGL.getTexUnit(uniform)->unbind(mode); } - return channel; + return uniform; } S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode) { - GLint channel = getTexChannelForIndex(uniform); - - if (channel != -1) + if (uniform < 0 || uniform >= (S32)mTexture.size()) + { + UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + return -1; + } + S32 index = mTexture[uniform]; + if (index != -1) { - gGL.getTexUnit(channel)->activate(); - gGL.getTexUnit(channel)->enable(mode); + gGL.getTexUnit(index)->activate(); + gGL.getTexUnit(index)->enable(mode); } - return channel; + return index; } S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) { - GLint channel = getTexChannelForIndex(uniform); - - if (channel != -1 && gGL.getTexUnit(channel)->getCurrType() != LLTexUnit::TT_NONE) + if (uniform < 0 || uniform >= (S32)mTexture.size()) + { + UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + return -1; + } + S32 index = mTexture[uniform]; + if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE) { - if (gDebugGL && gGL.getTexUnit(channel)->getCurrType() != mode) + if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode) { if (gDebugSession) { - gFailLog << "Texture channel " << channel << " texture type corrupted." << std::endl; + gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl; ll_fail("LLGLSLShader::disableTexture failed"); } else { - LL_ERRS() << "Texture channel " << channel << " texture type corrupted." << LL_ENDL; + LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL; } } - gGL.getTexUnit(channel)->disable(); + gGL.getTexUnit(index)->disable(); } - return channel; + return index; } void LLGLSLShader::uniform1i(U32 index, GLint x) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); if (iter == mValue.end() || iter->second.mV[0] != x) { - glUniform1iARB(location, x); - mValue[location] = LLVector4(x,0.f,0.f,0.f); + glUniform1iARB(mUniform[index], x); + mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f); } } } @@ -1016,15 +1045,19 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); if (iter == mValue.end() || iter->second.mV[0] != x) { - glUniform1fARB(location, x); - mValue[location] = LLVector4(x,0.f,0.f,0.f); + glUniform1fARB(mUniform[index], x); + mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f); } } } @@ -1034,16 +1067,20 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(x,y,0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec)) { - glUniform2fARB(location, x, y); - mValue[location] = vec; + glUniform2fARB(mUniform[index], x, y); + mValue[mUniform[index]] = vec; } } } @@ -1053,16 +1090,20 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(x,y,z,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec)) { - glUniform3fARB(location, x, y, z); - mValue[location] = vec; + glUniform3fARB(mUniform[index], x, y, z); + mValue[mUniform[index]] = vec; } } } @@ -1072,16 +1113,20 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(x,y,z,w); if (iter == mValue.end() || shouldChange(iter->second,vec)) { - glUniform4fARB(location, x, y, z, w); - mValue[location] = vec; + glUniform4fARB(mUniform[index], x, y, z, w); + mValue[mUniform[index]] = vec; } } } @@ -1091,16 +1136,20 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(v[0],0.f,0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform1ivARB(location, count, v); - mValue[location] = vec; + glUniform1ivARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; } } } @@ -1110,16 +1159,20 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(v[0],0.f,0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform1fvARB(location, count, v); - mValue[location] = vec; + glUniform1fvARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; } } } @@ -1129,16 +1182,20 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(v[0],v[1],0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform2fvARB(location, count, v); - mValue[location] = vec; + glUniform2fvARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; } } } @@ -1148,16 +1205,20 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(v[0],v[1],v[2],0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform3fvARB(location, count, v); - mValue[location] = vec; + glUniform3fvARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; } } } @@ -1167,16 +1228,20 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - std::map::iterator iter = mValue.find(location); + std::map::iterator iter = mValue.find(mUniform[index]); LLVector4 vec(v[0],v[1],v[2],v[3]); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform4fvARB(location, count, v); - mValue[location] = vec; + glUniform4fvARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; } } } @@ -1186,11 +1251,15 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - glUniformMatrix2fvARB(location, count, transpose, v); + glUniformMatrix2fvARB(mUniform[index], count, transpose, v); } } } @@ -1199,11 +1268,15 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - glUniformMatrix3fvARB(location, count, transpose, v); + glUniformMatrix3fvARB(mUniform[index], count, transpose, v); } } } @@ -1212,11 +1285,15 @@ void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, { if (mProgramObject) { - GLint location = getLocationForIndex(index); + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } - if (location >= 0) + if (mUniform[index] >= 0) { - glUniformMatrix3x4fv(location, count, transpose, v); + glUniformMatrix3x4fv(mUniform[index], count, transpose, v); } } } @@ -1225,10 +1302,15 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c { if (mProgramObject) { - GLint location = getLocationForIndex(index); - if (location >= 0) + if (mUniform.size() <= index) + { + UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + return; + } + + if (mUniform[index] >= 0) { - glUniformMatrix4fvARB(location, count, transpose, v); + glUniformMatrix4fvARB(mUniform[index], count, transpose, v); } } } @@ -1259,8 +1341,14 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) GLint LLGLSLShader::getUniformLocation(U32 index) { - /*TODO: flatten this... change calls to gUL(U32) */ - return getLocationForIndex(index); + GLint ret = -1; + if (mProgramObject) + { + llassert(index < mUniform.size()); + return mUniform[index]; + } + + return ret; } GLint LLGLSLShader::getAttribLocation(U32 attrib) diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 59edd7b36f..0934ceba30 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -169,11 +169,6 @@ public: U32 mMatHash[LLRender::NUM_MATRIX_MODES]; U32 mLightHash; - typedef std::map uniforms_index_t; - typedef std::pair magmin_values_t; - - typedef std::map < S32, magmin_values_t> magmin_filter_t; - GLhandleARB mProgramObject; #if LL_RELEASE_WITH_DEBUG_INFO struct attr_name @@ -188,12 +183,11 @@ public: std::vector mAttribute; //lookup table of attribute enum to attribute channel #endif U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask()) - uniforms_index_t mUniform; - uniforms_index_t mTexture; - + std::vector mUniform; //lookup table of uniform enum to uniform location LLStaticStringTable mUniformMap; //lookup map of uniform name to uniform location std::map mUniformNameMap; //lookup map of uniform location to uniform name std::map mValue; //lookup map of uniform location to last known value + std::vector mTexture; S32 mTotalUniformSize; S32 mActiveTextureChannels; S32 mShaderLevel; @@ -217,32 +211,13 @@ public: static U32 sTotalDrawCalls; bool mTextureStateFetched; - magmin_filter_t mTextureMagMinFilter; + std::vector mTextureMagFilter; + std::vector mTextureMinFilter; GLhandleARB mExtraLinkObject = 0; private: void unloadInternal(); - - inline GLint getLocationForIndex(S32 index) - { - if (!mProgramObject) - return -1; - uniforms_index_t::iterator it = mUniform.find(index); - if (it == mUniform.end()) - return -1; - return (*it).second; - } - - inline GLint getTexChannelForIndex(S32 index) - { - if (!mProgramObject) - return -1; - uniforms_index_t::iterator it = mTexture.find(index); - if (it == mTexture.end()) - return -1; - return (*it).second; - } }; //UI shader (declared here so llui_libtest will link properly) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 9067a17baf..5e16aded30 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1267,7 +1267,7 @@ void LLRender::syncMatrices() } shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m); - } + } } i = MM_PROJECTION; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index ceebc7000b..1bc5e89eac 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -446,7 +446,7 @@ public: static U32 sUICalls; static U32 sUIVerts; static bool sGLCoreProfile; - static bool sNsightDebugSupport; + static bool sNsightDebugSupport; private: friend class LLLightState; @@ -503,11 +503,6 @@ const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X 0.f, 1.f, 0.f, 0.f, // Y becomes Z 0.f, 0.f, 0.f, 1.f }; -const F32 XYZ_TO_OGL_ROTATION[16] = { 1.f, 0.f, 0.f, 0.f, // X stays X - 0.f, 0.f, -1.f, 0.f, // Z becomes -Y - 0.f, 1.f, 0.f, 0.f, // Y becomes Z - 0.f, 0.f, 0.f, 1.f }; - glh::matrix4f copy_matrix(F32* src); glh::matrix4f get_current_modelview(); glh::matrix4f get_current_projection(); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 544a4f00aa..1eb1cb56a8 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -985,7 +985,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade // Add shader file to map mShaderObjects[filename] = ret; shader_level = try_gpu_class; - } + } else { if (shader_level > 1) @@ -1150,7 +1150,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("fullbright"); mReservedUniforms.push_back("lightnorm"); - mReservedUniforms.push_back("sunlight_color"); + mReservedUniforms.push_back("sunlight_color_copy"); mReservedUniforms.push_back("ambient"); mReservedUniforms.push_back("blue_horizon"); mReservedUniforms.push_back("blue_density"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index fa2a9f03be..9919dbe31a 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -30,11 +30,6 @@ #include "llgl.h" #include "llglslshader.h" -/*RIDER: TODO: - * This should use the LL Singleton<> template... but not a quick conversion. - * (llviewershadermgr derives from this) - */ - class LLShaderMgr { public: diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index a33f84518f..e3e605d040 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -198,7 +198,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) } else { //always use a true hint of static draw when allocating non-client-backed buffers - glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB); + glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB); } glBindBufferARB(mType, 0); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 2650f69a2f..b7aff6bca9 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -125,8 +125,8 @@ namespace class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { public: - LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, F64Seconds cyclelength, F64Seconds cycleoffset) : - LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), F64Seconds(1.0)), + LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset) : + LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), LLSettingsBase::Seconds(1.0)), mDay(day), mTrackNo(0), mCycleLength(cyclelength), @@ -156,7 +156,7 @@ namespace mTrackTransitionStart = mTarget->buildDerivedClone(); mTrackNo = use_trackno; - F64Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; + LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); @@ -189,7 +189,7 @@ namespace return 1; } - LLSettingsDay::TrackBound_t getBoundingEntries(F64Seconds time) + LLSettingsDay::TrackBound_t getBoundingEntries(LLSettingsBase::Seconds time) { LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); F64 position = convertTimeToPosition(time); @@ -198,19 +198,19 @@ namespace return bounds; } - F64Seconds getAdjustedNow() const + LLSettingsBase::Seconds getAdjustedNow() const { - F64Seconds now(LLDate::now().secondsSinceEpoch()); + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); return (now + mCycleOffset); } - F64Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const + LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const { return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } - F64 convertTimeToPosition(F64Seconds time) + F64 convertTimeToPosition(LLSettingsBase::Seconds time) { F64 position = static_cast(fmod(time.value(), mCycleLength.value())) / static_cast(mCycleLength.value()); return llclamp(position, 0.0, 1.0); @@ -219,14 +219,14 @@ namespace private: LLSettingsDay::ptr_t mDay; S32 mTrackNo; - F64Seconds mCycleLength; - F64Seconds mCycleOffset; + LLSettingsBase::Seconds mCycleLength; + LLSettingsBase::Seconds mCycleOffset; LLSettingsBase::ptr_t mTrackTransitionStart; void onFinishedSpan() { LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow()); - F64Seconds nextspan = getSpanTime(next); + LLSettingsBase::Seconds nextspan = getSpanTime(next); reset((*next.first).second, (*next.second).second, nextspan.value()); } }; @@ -442,7 +442,7 @@ bool LLEnvironment::getIsMoonUp() const } //------------------------------------------------------------------------- -void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition, bool forced) +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, LLSettingsBase::Seconds transition, bool forced) { mSelectedEnvironment = env; updateEnvironment(transition, forced); @@ -472,7 +472,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro } -void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) { @@ -525,8 +525,8 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe if (settings->getSettingType() == "daycycle") { - S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); - S64Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + LLSettingsDay::Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + LLSettingsDay::Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); if (environment) { daylength = environment->getDayLength(); @@ -583,12 +583,12 @@ LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelectio return LLSettingsDay::ptr_t(); } -S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) +LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) { if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) { LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } DayInstance::ptr_t environment = getEnvironmentInstance(env); @@ -596,22 +596,22 @@ S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) if (environment) return environment->getDayLength(); - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } -S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) +LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) { if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) { LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } DayInstance::ptr_t environment = getEnvironmentInstance(env); if (environment) return environment->getDayOffset(); - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } @@ -670,7 +670,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( } -void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) +void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool forced) { DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); @@ -1365,9 +1365,9 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL if (environment.has("region_id")) pinfo->mRegionId = environment["region_id"].asUUID(); if (environment.has("day_length")) - pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger()); + pinfo->mDayLength = LLSettingsDay::Seconds(environment["day_length"].asInteger()); if (environment.has("day_offset")) - pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger()); + pinfo->mDayOffset = LLSettingsDay::Seconds(environment["day_offset"].asInteger()); if (environment.has("day_hash")) pinfo->mDayHash = environment["day_hash"].asInteger(); if (environment.has("day_cycle")) @@ -1643,7 +1643,7 @@ LLEnvironment::DayInstance::DayInstance() : mSkyTrack(1) { } -void LLEnvironment::DayInstance::update(F64Seconds delta) +void LLEnvironment::DayInstance::update(LLSettingsBase::Seconds delta) { if (!mInitialized) initialize(); @@ -1659,7 +1659,7 @@ void LLEnvironment::DayInstance::update(F64Seconds delta) // mWater->update(); } -void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { if (mType == TYPE_FIXED) LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL; @@ -1750,7 +1750,7 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky mBlenderWater = waterblend; } -F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds) +F64 LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { F64 frame = static_cast(seconds.value() % mDayLength.value()) / static_cast(mDayLength.value()); @@ -1759,7 +1759,7 @@ F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds) void LLEnvironment::DayInstance::animate() { - F64Seconds now(LLDate::now().secondsSinceEpoch()); + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); now += mDayOffset; @@ -1807,7 +1807,7 @@ void LLEnvironment::DayInstance::animate() //------------------------------------------------------------------------- LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart, - const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, S64Seconds time) : + const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, LLSettingsDay::Seconds time) : DayInstance(), mStartSky(skystart), mStartWater(waterstart), @@ -1817,7 +1817,7 @@ LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart } -void LLEnvironment::DayTransition::update(F64Seconds delta) +void LLEnvironment::DayTransition::update(LLSettingsBase::Seconds delta) { mNextInstance->update(delta); DayInstance::update(delta); diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 0fbc49bc7d..52f22ac8f1 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -62,15 +62,15 @@ public: typedef std::shared_ptr ptr_t; - S32 mParcelId; - LLUUID mRegionId; - S64Seconds mDayLength; - S64Seconds mDayOffset; - size_t mDayHash; - LLSD mDaycycleData; - std::array mAltitudes; - bool mIsDefault; - bool mIsRegion; + S32 mParcelId; + LLUUID mRegionId; + LLSettingsDay::Seconds mDayLength; + LLSettingsDay::Seconds mDayOffset; + size_t mDayHash; + LLSD mDaycycleData; + std::array mAltitudes; + bool mIsDefault; + bool mIsRegion; static ptr_t extract(LLSD); @@ -152,11 +152,11 @@ public: void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); void updateShaderUniforms(LLGLSLShader *shader); - void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT, bool forced = false); + void setSelectedEnvironment(EnvSelection_t env, LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false); EnvSelection_t getSelectedEnvironment() const { return mSelectedEnvironment; } bool hasEnvironment(EnvSelection_t env); - void setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset); + void setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset); void setEnvironment(EnvSelection_t env, fixedEnvironment_t fixed); void setEnvironment(EnvSelection_t env, const LLSettingsBase::ptr_t &fixed); void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); } @@ -164,13 +164,13 @@ public: void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw)); } void clearEnvironment(EnvSelection_t env); LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env); - S64Seconds getEnvironmentDayLength(EnvSelection_t env); - S64Seconds getEnvironmentDayOffset(EnvSelection_t env); + LLSettingsDay::Seconds getEnvironmentDayLength(EnvSelection_t env); + LLSettingsDay::Seconds getEnvironmentDayOffset(EnvSelection_t env); fixedEnvironment_t getEnvironmentFixed(EnvSelection_t env); LLSettingsSky::ptr_t getEnvironmentFixedSky(EnvSelection_t env) { return getEnvironmentFixed(env).first; }; LLSettingsWater::ptr_t getEnvironmentFixedWater(EnvSelection_t env) { return getEnvironmentFixed(env).second; }; - void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT, bool forced = false); + void updateEnvironment(LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false); void addSky(const LLSettingsSky::ptr_t &sky); void addWater(const LLSettingsWater::ptr_t &sky); @@ -253,9 +253,9 @@ private: DayInstance(); virtual ~DayInstance() { }; - virtual void update(F64Seconds); + virtual void update(LLSettingsBase::Seconds); - void setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset); + void setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset); void setSky(const LLSettingsSky::ptr_t &psky); void setWater(const LLSettingsWater::ptr_t &pwater); @@ -269,8 +269,8 @@ private: LLSettingsDay::ptr_t getDayCycle() const { return mDayCycle; } LLSettingsSky::ptr_t getSky() const { return mSky; } LLSettingsWater::ptr_t getWater() const { return mWater; } - S64Seconds getDayLength() const { return mDayLength; } - S64Seconds getDayOffset() const { return mDayOffset; } + LLSettingsDay::Seconds getDayLength() const { return mDayLength; } + LLSettingsDay::Seconds getDayOffset() const { return mDayOffset; } S32 getSkyTrack() const { return mSkyTrack; } virtual void animate(); @@ -286,14 +286,14 @@ private: InstanceType_t mType; bool mInitialized; - S64Seconds mDayLength; - S64Seconds mDayOffset; + LLSettingsDay::Seconds mDayLength; + LLSettingsDay::Seconds mDayOffset; S32 mLastTrackAltitude; LLSettingsBlender::ptr_t mBlenderSky; LLSettingsBlender::ptr_t mBlenderWater; - F64 secondsToKeyframe(S64Seconds seconds); + F64 secondsToKeyframe(LLSettingsDay::Seconds seconds); }; typedef std::array InstanceArray_t; @@ -301,17 +301,17 @@ private: class DayTransition : public DayInstance { public: - DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, S64Seconds time); + DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, LLSettingsDay::Seconds time); virtual ~DayTransition() { }; - virtual void update(F64Seconds); + virtual void update(LLSettingsBase::Seconds); virtual void animate(); protected: LLSettingsSky::ptr_t mStartSky; LLSettingsWater::ptr_t mStartWater; DayInstance::ptr_t mNextInstance; - S64Seconds mTransitionTime; + LLSettingsDay::Seconds mTransitionTime; }; static const F32 SUN_DELTA_YAW; diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 706dd99fc9..543f6e5671 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -192,7 +192,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) { S32Hours hrs; S32Minutes minutes; - S64Seconds total; + LLSettingsDay::Seconds total; LLUIString formatted_label = getString("time_label"); for (int i = 0; i < max_elm; i++) { @@ -700,7 +700,7 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel() { LLUIString formatted_label = getString("time_label"); - S64Seconds total = (mDayLength * time); + LLSettingsDay::Seconds total = (mDayLength * time); S32Hours hrs = total; S32Minutes minutes = total - hrs; diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index bee5e17b95..fc0b4f5106 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -138,7 +138,7 @@ private: static void onIdlePlay(void *); LLSettingsDay::ptr_t mEditDay; // edited copy - S64Seconds mDayLength; + LLSettingsDay::Seconds mDayLength; U32 mCurrentTrack; std::string mLastFrameSlider; diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 39dada1984..ac47253444 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -3325,7 +3325,7 @@ void LLPanelLandEnvironment::doApply() } else { - S64Seconds daylength; + LLSettingsDay::Seconds daylength; F32Hours dayoffset_h; daylength = F32Hours(mDayLengthSlider->getValueF32()); @@ -3336,7 +3336,7 @@ void LLPanelLandEnvironment::doApply() dayoffset_h = F32Hours(24.0f) + dayoffset_h; } - S64Seconds dayoffset_s = dayoffset_h; + LLSettingsDay::Seconds dayoffset_s = dayoffset_h; LLEnvironment::instance().updateParcel(parcel_id, mEditingDayCycle, daylength.value(), dayoffset_s.value()); } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 272ac8a1bb..6719e6ed3b 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3426,7 +3426,7 @@ void LLPanelRegionEnvironment::doApply() } else { - S64Seconds daylength; + LLSettingsDay::Seconds daylength; F32Hours dayoffset_h; daylength = F32Hours(mDayLengthSlider->getValueF32()); @@ -3437,7 +3437,7 @@ void LLPanelRegionEnvironment::doApply() dayoffset_h = F32Hours(24.0f) + dayoffset_h; } - S64Seconds dayoffset_s = dayoffset_h; + LLSettingsDay::Seconds dayoffset_s = dayoffset_h; LLEnvironment::instance().updateRegion(mEditingDayCycle, daylength.value(), dayoffset_s.value()); } -- cgit v1.3 From f87cf83a2bcca87f33c3f94cd09438fb7b65529c Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 23:54:01 +0100 Subject: Mark LLSettingsSky::skipInterpolateKeys as override to silence Clang fail. --- indra/llinventory/llsettingssky.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 6e532eba55..93da1e6dd0 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -423,7 +423,7 @@ protected: LLSettingsSky(); virtual stringset_t getSlerpKeys() const override; - virtual stringset_t getSkipInterpolateKeys() const; + virtual stringset_t getSkipInterpolateKeys() const override; virtual void updateSettings() override; private: -- cgit v1.3 From 2a613d7363c4e91a7258d4f0ea3971db1569e788 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 1 Jun 2018 16:24:36 -0700 Subject: Rework preset loading and context menu from inventory. --- indra/llinventory/llsettingsdaycycle.cpp | 15 +- indra/llinventory/llsettingsdaycycle.h | 7 +- indra/llinventory/llsettingssky.cpp | 7 +- indra/llinventory/llsettingssky.h | 2 + indra/llinventory/llsettingswater.cpp | 3 + indra/llinventory/llsettingswater.h | 2 + indra/newview/llenvironment.cpp | 344 +++++++++++---------- indra/newview/llenvironment.h | 15 +- indra/newview/llfloatereditextdaycycle.cpp | 8 + indra/newview/llfloaterenvironmentsettings.cpp | 2 +- indra/newview/llfloaterfixedenvironment.cpp | 9 + indra/newview/llinventorybridge.cpp | 82 ++++- indra/newview/llsettingsvo.cpp | 208 +++++++++---- indra/newview/llsettingsvo.h | 9 +- indra/newview/llviewermenu.cpp | 12 +- .../skins/default/xui/en/menu_inventory.xml | 27 ++ .../skins/default/xui/en/menu_save_settings.xml | 4 +- .../newview/skins/default/xui/en/notifications.xml | 9 + 18 files changed, 510 insertions(+), 255 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 577b12b031..e67da95a6c 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -101,6 +101,9 @@ const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water const S32 LLSettingsDay::FRAME_MAX(56); +// *LAPRAS* Change when Agni +const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb"); + //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), @@ -218,22 +221,18 @@ bool LLSettingsDay::initialize() if (i == TRACK_WATER) { setting = used[(*it)[SETTING_KEYNAME]]; - if (!setting) - setting = getNamedWater((*it)[SETTING_KEYNAME]); if (setting && setting->getSettingType() != "water") { - LL_WARNS("DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + LL_WARNS("SETTINGS", "DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; setting.reset(); } } else { setting = used[(*it)[SETTING_KEYNAME]]; - if (!setting) - setting = getNamedSky((*it)[SETTING_KEYNAME]); if (setting && setting->getSettingType() != "sky") { - LL_WARNS("DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + LL_WARNS("SETTINGS", "DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; setting.reset(); } } @@ -247,6 +246,10 @@ bool LLSettingsDay::initialize() hassky |= true; mDayTracks[i][keyframe] = setting; } + else + { + LL_WARNS("SETTINGS", "DAYCYCLE") << "Skipping frame on track #" << i << " at time index " << keyframe << LL_ENDL; + } } } diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 5e6fc7f21d..101cacc3a2 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -60,6 +60,8 @@ public: static const S32 TRACK_MAX; static const S32 FRAME_MAX; + static const LLUUID DEFAULT_ASSET_ID; + typedef std::map CycleTrack_t; typedef std::vector CycleList_t; typedef std::shared_ptr ptr_t; @@ -105,10 +107,7 @@ public: virtual LLSettingsSkyPtr_t buildSky(LLSD) const = 0; virtual LLSettingsWaterPtr_t buildWater(LLSD) const = 0; - virtual LLSettingsSkyPtr_t getNamedSky(const std::string &) const = 0; - virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const = 0; - - void setInitialized(bool value = true) { mInitialized = value; } + void setInitialized(bool value = true) { mInitialized = value; } CycleTrack_t & getCycleTrack(S32 track); virtual validation_list_t getValidationList() const override; diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 45c1ca1d7f..f578660095 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -110,6 +110,9 @@ const LLUUID LLSettingsSky::DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271 const LLUUID LLSettingsSky::DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver const LLUUID LLSettingsSky::DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); +// *LAPRAS* Change when Agni! +const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749"); + namespace { @@ -572,8 +575,8 @@ LLSD LLSettingsSky::defaults() dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1; dfltsetting[SETTING_CLOUD_TEXTUREID] = DEFAULT_CLOUD_ID; - dfltsetting[SETTING_MOON_TEXTUREID] = DEFAULT_MOON_ID; // gMoonTextureID; // These two are returned by the login... wow! - dfltsetting[SETTING_SUN_TEXTUREID] = DEFAULT_SUN_ID; // gSunTextureID; + dfltsetting[SETTING_MOON_TEXTUREID] = DEFAULT_MOON_ID; + dfltsetting[SETTING_SUN_TEXTUREID] = LLUUID::null; // DEFAULT_SUN_ID; dfltsetting[SETTING_TYPE] = "sky"; diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 9379cd37c3..82c2d6a804 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -83,6 +83,8 @@ public: static const LLUUID DEFAULT_MOON_ID; static const LLUUID DEFAULT_CLOUD_ID; + static const LLUUID DEFAULT_ASSET_ID; + typedef std::shared_ptr ptr_t; typedef std::pair azimalt_t; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index c6798945a3..aa1f0f1935 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -69,6 +69,9 @@ const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL); +// *LAPRAS* Change when Agni +const LLUUID LLSettingsWater::DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661"); + //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index acae903e92..ca32a46430 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -48,6 +48,8 @@ public: static const LLUUID DEFAULT_WATER_NORMAL_ID; + static const LLUUID DEFAULT_ASSET_ID; + typedef std::shared_ptr ptr_t; //--------------------------------------------------------------------- diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 21ecf7741b..228a396c0d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -238,6 +238,16 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); +//*TODO* Change these when available on Agni (these are Damballah asset IDs). +const LLUUID LLEnvironment::KNOWN_SKY_DEFAULT(LLSettingsSky::DEFAULT_ASSET_ID); +const LLUUID LLEnvironment::KNOWN_WATER_DEFAULT(LLSettingsWater::DEFAULT_ASSET_ID); +const LLUUID LLEnvironment::KNOWN_DAY_DEFAULT(LLSettingsDay::DEFAULT_ASSET_ID); + +const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("645d7475-19d6-d05c-6eb2-29eeacf76e06"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("68f5a7ec-2785-d9d8-be7c-cca93976759a"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("06420773-757b-4b7c-a1f9-85fceb2f7bd4"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("c13658f3-91b8-d559-3a12-b11ce3940c4c"); + const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); @@ -498,6 +508,25 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe } } +void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId) +{ + LLSettingsVOBase::getSettingsAsset(assetId, + [this, env](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, status); }); + +} + +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +{ + if (!settings || status) + { + LLSD args; + args["DESC"] = asset_id.asString(); + LLNotificationsUtil::add("FailedToFindSettings", args); + return; + } + + setEnvironment(env, settings); +} void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) { @@ -1311,196 +1340,172 @@ std::string LLEnvironment::getUserDir(const std::string &subdir) LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) { - LLSD data = legacyLoadPreset(filename); - if (!data) - return LLSettingsWater::ptr_t(); - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); - LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); + std::string path(gDirUtilp->getDirName(filename)); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path); return water; } LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename) { - LLSD data = legacyLoadPreset(filename); - if (!data) - return LLSettingsSky::ptr_t(); - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); - LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); + std::string path(gDirUtilp->getDirName(filename)); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path); return sky; + } LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename) { - // for the moment just look it up from the preloaded. std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string path(gDirUtilp->getDirName(filename)); - LLSettingsDay::ptr_t day = instance().findDayCycleByName(name); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path); return day; } -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 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 = LLSettingsVOSky::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 = LLSettingsVOSky::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 = LLSettingsVOWater::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 = LLSettingsVOWater::buildFromLegacyPreset(name, data); - LLEnvironment::instance().addWater(water); - } - } - } - - // System Days - { - 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)); - - LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); - /*if (day->validate()) - { - LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; - LLEnvironment::instance().addDayCycle(day); - } - else - { - LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; - }*/ - LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; - LLEnvironment::instance().addDayCycle(day); -#ifdef EXPORT_PRESETS - std::string exportfile = LLURI::escape(name) + "(new).xml"; - std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); - - LLSD settings = day->getSettings(); - - std::ofstream daycyclefile(exportpath); - LLPointer formatter = new LLSDXMLFormatter(); - formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); - daycyclefile.close(); -#endif - } - } - } - - // User Days - { - 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)); - - LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); - LLEnvironment::instance().addDayCycle(day); - } - } - } +// 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 = LLSettingsVOSky::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 = LLSettingsVOSky::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 = LLSettingsVOWater::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 = LLSettingsVOWater::buildFromLegacyPreset(name, data); +// LLEnvironment::instance().addWater(water); +// } +// } +// } +// +// // System Days +// { +// 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)); +// +// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); +// /*if (day->validate()) +// { +// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; +// LLEnvironment::instance().addDayCycle(day); +// } +// else +// { +// LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; +// }*/ +// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; +// LLEnvironment::instance().addDayCycle(day); +// #ifdef EXPORT_PRESETS +// std::string exportfile = LLURI::escape(name) + "(new).xml"; +// std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); +// +// LLSD settings = day->getSettings(); +// +// std::ofstream daycyclefile(exportpath); +// LLPointer formatter = new LLSDXMLFormatter(); +// formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); +// daycyclefile.close(); +// #endif +// } +// } +// } +// +// // User Days +// { +// 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)); +// +// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); +// LLEnvironment::instance().addDayCycle(day); +// } +// } +// } } void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) @@ -1521,9 +1526,6 @@ void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) { -// //*LAPRAS* temp base on region's response. -// return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); - auto it = std::find_if_not(mTrackAltitudes.begin(), mTrackAltitudes.end(), [altitude](F32 test) { return altitude > test; }); if (it == mTrackAltitudes.begin()) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 32ce99ccc9..7c8304a7ed 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -55,6 +55,14 @@ public: static const F32Seconds TRANSITION_SLOW; static const F32Seconds TRANSITION_ALTITUDE; + static const LLUUID KNOWN_SKY_DEFAULT; + static const LLUUID KNOWN_WATER_DEFAULT; + static const LLUUID KNOWN_DAY_DEFAULT; + static const LLUUID KNOWN_SKY_SUNRISE; + static const LLUUID KNOWN_SKY_MIDDAY; + static const LLUUID KNOWN_SKY_SUNSET; + static const LLUUID KNOWN_SKY_MIDNIGHT; + struct EnvironmentInfo { EnvironmentInfo(); @@ -159,6 +167,8 @@ public: void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); } void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); } void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw)); } + void setEnvironment(EnvSelection_t env, const LLUUID &assetId); + void clearEnvironment(EnvSelection_t env); LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env); S64Seconds getEnvironmentDayLength(EnvSelection_t env); @@ -177,9 +187,11 @@ public: list_name_id_t getWaterList() const; list_name_id_t getDayCycleList() const; + // *LAPRAS* TODO : Remove these vvv LLSettingsSky::ptr_t findSkyByName(std::string name) const; LLSettingsWater::ptr_t findWaterByName(std::string name) const; LLSettingsDay::ptr_t findDayCycleByName(std::string name) const; + // *LAPRAS* TODO : Remove these ^^^ inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } @@ -376,9 +388,10 @@ private: void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment); void onAgentPositionHasChanged(const LLVector3 &localpos); + + void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); //========================================================================= void legacyLoadAllPresets(); - static 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/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 706dd99fc9..4703a1ec16 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -795,6 +795,14 @@ void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId) void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) { + if (!settings || status) + { + LLSD args; + args["DESC"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; + LLNotificationsUtil::add("FailedToFindSettings", args); + closeFloater(); + return; + } mEditDay = std::dynamic_pointer_cast(settings); updateEditEnvironment(); syncronizeTabs(); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index b7bf6918fe..1b96db6611 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -122,6 +122,7 @@ void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() void LLFloaterEnvironmentSettings::onBtnOK() { +#if 0 bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); @@ -157,7 +158,6 @@ void LLFloaterEnvironmentSettings::onBtnOK() LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } -#if 0 // Save and apply new user preferences. bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index d5fc34a04b..6c1080294d 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -212,6 +212,15 @@ void LLFloaterFixedEnvironment::loadInventoryItem(const LLUUID &inventoryId) void LLFloaterFixedEnvironment::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) { + if (!settings || status) + { + LLSD args; + args["DESC"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; + LLNotificationsUtil::add("FailedToFindSettings", args); + closeFloater(); + return; + } + mSettings = settings; updateEditEnvironment(); syncronizeTabs(); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 2b74116f8b..fe7d302992 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -6903,7 +6903,44 @@ LLUIImagePtr LLSettingsBridge::getIcon() const void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action) { - LLItemBridge::performAction(model, action); + if ("apply_settings_local" == action) + { + // Single item only + LLViewerInventoryItem* item = static_cast(getItem()); + if (!item) + return; + LLUUID asset_id = item->getProtectedAssetUUID(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, asset_id); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } + else if ("apply_settings_parcel" == action) + { + // Single item only + LLViewerInventoryItem* item = static_cast(getItem()); + if (!item) + return; + LLUUID asset_id = item->getProtectedAssetUUID(); + // *LAPRAS* TODO update on simulator. + LL_WARNS("LAPRAS") << "Only updating locally!!! NOT REALLY PARCEL UPDATE" << LL_ENDL; + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_PARCEL, asset_id); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } + else if ("apply_settings_region" == action) + { + // Single item only + LLViewerInventoryItem* item = static_cast(getItem()); + if (!item) + return; + LLUUID asset_id = item->getProtectedAssetUUID(); + // *LAPRAS* TODO update on simulator. + LL_WARNS("LAPRAS") << "Only updating locally!!! NOT REALLY REGION UPDATE" << LL_ENDL; + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, asset_id); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } + else + LLItemBridge::performAction(model, action); } void LLSettingsBridge::openItem() @@ -6917,9 +6954,48 @@ void LLSettingsBridge::openItem() void LLSettingsBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - LLItemBridge::buildContextMenu(menu, flags); -} + LL_DEBUGS() << "LLSettingsBridge::buildContextMenu()" << LL_ENDL; + menuentry_vec_t items; + menuentry_vec_t disabled_items; + if (isMarketplaceListingsFolder()) + { + menuentry_vec_t items; + menuentry_vec_t disabled_items; + addMarketplaceContextMenuOptions(flags, items, disabled_items); + items.push_back(std::string("Properties")); + getClipboardEntries(false, items, disabled_items, flags); + hide_context_entries(menu, items, disabled_items); + } + else if (isItemInTrash()) + { + addTrashContextMenuOptions(items, disabled_items); + } + else + { + items.push_back(std::string("Share")); + if (!canShare()) + { + disabled_items.push_back(std::string("Share")); + } + + addOpenRightClickMenuOption(items); + items.push_back(std::string("Properties")); + + getClipboardEntries(true, items, disabled_items, flags); + + items.push_back("Settings Separator"); + items.push_back("Settings Apply Local"); + + items.push_back("Settings Apply Parcel"); + // *LAPRAS* TODO: test for permission + + items.push_back("Settings Apply Region"); + // *LAPRAS* TODO: test for permission + } + addLinkReplaceMenuOption(items, disabled_items); + hide_context_entries(menu, items, disabled_items); +} std::string LLSettingsBridge::getLabelSuffix() const { return LLItemBridge::getLabelSuffix(); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 1ac607cd1f..39046004b8 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -58,47 +58,33 @@ #include "llassetstorage.h" #include "llvfile.h" +#include + #undef VERIFY_LEGACY_CONVERSION //========================================================================= namespace { -LLSD ensureArray4(LLSD in, F32 fill) -{ - if (in.size() >= 4) - return in; - - LLSD out(LLSD::emptyArray()); - - for (S32 idx = 0; idx < in.size(); ++idx) - { - out.append(in[idx]); - } - - while (out.size() < 4) - { - out.append(LLSD::Real(fill)); - } - return out; -} - + LLSD ensure_array_4(LLSD in, F32 fill); + LLSD read_legacy_preset_data(const std::string& path); -//------------------------------------------------------------------------- -class LLSettingsInventoryCB : public LLInventoryCallback -{ -public: - typedef std::function callback_t; + //------------------------------------------------------------------------- + class LLSettingsInventoryCB : public LLInventoryCallback + { + public: + typedef std::function callback_t; - LLSettingsInventoryCB(callback_t cbfn) : - mCbfn(cbfn) - { } + LLSettingsInventoryCB(callback_t cbfn) : + mCbfn(cbfn) + { } - void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } + void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } -private: - callback_t mCbfn; -}; + private: + callback_t mCbfn; + }; + //------------------------------------------------------------------------- } @@ -240,9 +226,10 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { - LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; + LL_WARNS("SETTINGS") << "Error retrieving asset " << asset_id << ". Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; } - callback(asset_id, settings, status, ext_status); + if (callback) + callback(asset_id, settings, status, ext_status); } @@ -392,6 +379,37 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n return skyp; } +namespace +{ + // This is a disturbing hack + std::string legacy_name_to_filename(const std::string &name) + { + std::string fixedname(LLURI::escape(name)); + + boost::algorithm::replace_all(fixedname, "-", "%2D"); + return fixedname; + } +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + std::string full_path(path); + std::string full_name(legacy_name_to_filename(name)); + full_name += ".xml"; + + gDirUtilp->append(full_path, full_name); + LLSD legacy_data = read_legacy_preset_data(full_path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data); +} + + LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() { LLSD settings = LLSettingsSky::defaults(); @@ -429,9 +447,9 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) { // LEGACY_ATMOSPHERICS // These will need to be inferred from new settings' density profiles - legacy[SETTING_AMBIENT] = ensureArray4(settings[SETTING_AMBIENT], 1.0f); - legacy[SETTING_BLUE_DENSITY] = ensureArray4(settings[SETTING_BLUE_DENSITY], 1.0); - legacy[SETTING_BLUE_HORIZON] = ensureArray4(settings[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_AMBIENT] = ensure_array_4(settings[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensure_array_4(settings[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensure_array_4(settings[SETTING_BLUE_HORIZON], 1.0); legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(settings[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(settings[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(settings[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); @@ -453,20 +471,20 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA convertAtmosphericsToLegacy(legacy, settings); - legacy[SETTING_CLOUD_COLOR] = ensureArray4(settings[SETTING_CLOUD_COLOR], 1.0); - legacy[SETTING_CLOUD_POS_DENSITY1] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); - legacy[SETTING_CLOUD_POS_DENSITY2] = ensureArray4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); + legacy[SETTING_CLOUD_COLOR] = ensure_array_4(settings[SETTING_CLOUD_COLOR], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY1] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); - legacy[SETTING_GLOW] = ensureArray4(settings[SETTING_GLOW], 1.0); - legacy[SETTING_LIGHT_NORMAL] = ensureArray4(psky->getLightDirection().getValue(), 0.0f); + legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); + legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; - legacy[SETTING_SUNLIGHT_COLOR] = ensureArray4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); + legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); LLSettingsSky::azimalt_t azialt = psky->getSunRotationAzAl(); @@ -595,6 +613,25 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin return waterp; } +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + std::string full_path(path); + std::string full_name(legacy_name_to_filename(name)); + full_name += ".xml"; + + gDirUtilp->append(full_path, full_name); + LLSD legacy_data = read_legacy_preset_data(full_path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data); +} + + LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() { LLSD settings = LLSettingsWater::defaults(); @@ -635,7 +672,7 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) LLSD settings = pwater->getSettings(); legacy[SETTING_LEGACY_BLUR_MULTIPILER] = settings[SETTING_BLUR_MULTIPILER]; - legacy[SETTING_LEGACY_FOG_COLOR] = ensureArray4(settings[SETTING_FOG_COLOR], 1.0f); + legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f); legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; @@ -740,10 +777,18 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) } //------------------------------------------------------------------------- -LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings) { LLSD newsettings(defaults()); std::set framenames; + std::set notfound; + + std::string base_path(gDirUtilp->getDirName(path)); + std::string water_path(base_path); + std::string sky_path(base_path); + + gDirUtilp->append(water_path, "water"); + gDirUtilp->append(sky_path, "skies"); newsettings[SETTING_NAME] = name; @@ -767,14 +812,16 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n LLSD frames(LLSD::emptyMap()); { - LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName("Default"); - frames["water:Default"] = pwater->getSettings(); + LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path); + if (pwater) + frames["water:Default"] = pwater->getSettings(); } for (std::set::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(*itn); - frames["sky:" + (*itn)] = psky->getSettings(); + LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path); + if (psky) + frames["sky:" + (*itn)] = psky->getSettings(); } newsettings[SETTING_FRAMES] = frames; @@ -806,6 +853,26 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n return dayp; } +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path) +{ + std::string full_path(path); + std::string full_name(legacy_name_to_filename(name)); + full_name += ".xml"; + + gDirUtilp->append(full_path, full_name); + LLSD legacy_data = read_legacy_preset_data(full_path); + + if (!legacy_data) + { + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << full_path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, path, legacy_data); +} + + + LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) { LLSD frames(LLSD::emptyMap()); @@ -863,6 +930,8 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io return dayp; } + + LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() { LLSD settings = LLSettingsDay::defaults(); @@ -996,12 +1065,43 @@ LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const return LLSettingsWater::ptr_t(); } -LLSettingsSkyPtr_t LLSettingsVODay::getNamedSky(const std::string &name) const +//========================================================================= +namespace { - return LLEnvironment::instance().findSkyByName(name); -} + LLSD ensure_array_4(LLSD in, F32 fill) + { + if (in.size() >= 4) + return in; -LLSettingsWaterPtr_t LLSettingsVODay::getNamedWater(const std::string &name) const -{ - return LLEnvironment::instance().findWaterByName(name); + LLSD out(LLSD::emptyArray()); + + for (S32 idx = 0; idx < in.size(); ++idx) + { + out.append(in[idx]); + } + + while (out.size() < 4) + { + out.append(LLSD::Real(fill)); + } + return out; + } + + //--------------------------------------------------------------------- + LLSD read_legacy_preset_data(const std::string& path) + { + llifstream xml_file; +// std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); + + xml_file.open(path.c_str()); + if (!xml_file) + return LLSD(); + + LLSD params_data; + LLPointer parser = new LLSDXMLParser(); + parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + xml_file.close(); + + return params_data; + } } diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 3339aaf037..8f6f96a758 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -90,6 +90,8 @@ public: static ptr_t buildDefaultSky(); virtual ptr_t buildClone() override; + static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path); + static LLSD convertToLegacy(const ptr_t &, bool isAdvanced); bool isAdvanced() const { return m_isAdvanced; } @@ -121,6 +123,8 @@ public: static ptr_t buildDefaultWater(); virtual ptr_t buildClone() override; + static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path); + static LLSD convertToLegacy(const ptr_t &); protected: LLSettingsVOWater(); @@ -144,7 +148,8 @@ public: static ptr_t buildDay(LLSD settings); - static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings); + static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path); static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); static ptr_t buildDefaultDayCycle(); static ptr_t buildFromEnvironmentMessage(LLSD settings); @@ -156,8 +161,6 @@ public: virtual LLSettingsWaterPtr_t getDefaultWater() const override; virtual LLSettingsSkyPtr_t buildSky(LLSD) const override; virtual LLSettingsWaterPtr_t buildWater(LLSD) const override; - virtual LLSettingsSkyPtr_t getNamedSky(const std::string &) const override; - virtual LLSettingsWaterPtr_t getNamedWater(const std::string &) const override; protected: LLSettingsVODay(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ce1e740425..8153e41b45 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8391,26 +8391,22 @@ class LLWorldEnvSettings : public view_listener_t if (tod == "sunrise") { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunrise"); - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNRISE); LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } else if (tod == "noon") { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midday"); - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDDAY); LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } else if (tod == "sunset") { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunset"); - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNSET); LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } else if (tod == "midnight") { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midnight"); - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDNIGHT); LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } else diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index 29915788f1..edd1f42d92 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -862,6 +862,33 @@ + + + + + + + + + + + label="Apply To Parcel"> + label="Apply To Region"> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 6aa6653f42..d7193c511f 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11104,4 +11104,13 @@ Cannot create large prims that intersect other players. Please re-try when othe yestext="OK"/> + +Failed to find the settisgs named [DESC] in database. + fail + + -- cgit v1.3 From 7136956b90614bbd236be0e30231781c04346220 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 2 Jun 2018 23:28:48 +0100 Subject: Use more typedefs to simplify sync between viewer and sim env settings code. --- indra/llcommon/llmemory.cpp | 6 +- indra/llcommon/llunittype.h | 37 +++++++----- indra/llinventory/llsettingsbase.cpp | 51 +++++++++++----- indra/llinventory/llsettingsbase.h | 64 ++++++++++++-------- indra/llinventory/llsettingsdaycycle.cpp | 93 +++++++++++++++++++----------- indra/llinventory/llsettingsdaycycle.h | 65 +++++++++++---------- indra/llinventory/llsettingssky.cpp | 40 ++++++------- indra/llinventory/llsettingssky.h | 30 +++++----- indra/llinventory/llsettingswater.cpp | 19 ++++-- indra/llinventory/llsettingswater.h | 25 ++++---- indra/llmessage/llcircuit.cpp | 6 +- indra/newview/llenvironment.cpp | 45 +++++++-------- indra/newview/llenvironment.h | 7 +-- indra/newview/llfloatereditextdaycycle.cpp | 17 +++--- indra/newview/llpaneleditwater.cpp | 2 +- indra/newview/llsettingsvo.cpp | 13 ++--- 16 files changed, 294 insertions(+), 226 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index b3debf3550..1884d6f04f 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -77,7 +77,7 @@ void ll_assert_aligned_func(uintptr_t ptr,U32 alignment) //static void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure) { - sMaxHeapSizeInKB = max_heap_size; + sMaxHeapSizeInKB = U32Kilobytes::convert(max_heap_size); sEnableMemoryFailurePrevention = prevent_heap_failure ; } @@ -93,9 +93,9 @@ void LLMemory::updateMemoryInfo() return ; } - sAllocatedMemInKB = U64Bytes(counters.WorkingSetSize) ; + sAllocatedMemInKB = U32Kilobytes::convert(U64Bytes(counters.WorkingSetSize)); sample(sAllocatedMem, sAllocatedMemInKB); - sAllocatedPageSizeInKB = U64Bytes(counters.PagefileUsage) ; + sAllocatedPageSizeInKB = U32Kilobytes::convert(U64Bytes(counters.PagefileUsage)); sample(sVirtualMem, sAllocatedPageSizeInKB); U32Kilobytes avail_phys, avail_virtual; diff --git a/indra/llcommon/llunittype.h b/indra/llcommon/llunittype.h index ac8504ca61..81f244e422 100644 --- a/indra/llcommon/llunittype.h +++ b/indra/llcommon/llunittype.h @@ -132,23 +132,34 @@ struct LLUnit return mValue; } - LL_FORCE_INLINE void value(storage_t value) + LL_FORCE_INLINE void value(const storage_t& value) { mValue = value; } template - storage_t valueInUnits() + storage_t valueInUnits() const { return LLUnit(*this).value(); } template - void valueInUnits(storage_t value) + void valueInUnits(const storage_t& value) const { *this = LLUnit(value); } + LL_FORCE_INLINE operator storage_t() const + { + return value(); + } + + /*LL_FORCE_INLINE self_t& operator= (storage_t v) + { + value(v); + return *this; + }*/ + LL_FORCE_INLINE void operator += (self_t other) { mValue += convert(other).mValue; @@ -159,60 +170,60 @@ struct LLUnit mValue -= convert(other).mValue; } - LL_FORCE_INLINE void operator *= (storage_t multiplicand) + LL_FORCE_INLINE void operator *= (const storage_t& multiplicand) { mValue *= multiplicand; } - LL_FORCE_INLINE void operator *= (self_t multiplicand) + LL_FORCE_INLINE void operator *= (const self_t& multiplicand) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE, "Multiplication of unit types not supported."); } - LL_FORCE_INLINE void operator /= (storage_t divisor) + LL_FORCE_INLINE void operator /= (const storage_t& divisor) { mValue /= divisor; } - void operator /= (self_t divisor) + void operator /= (const self_t& divisor) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE, "Illegal in-place division of unit types."); } template - LL_FORCE_INLINE bool operator == (LLUnit other) const + LL_FORCE_INLINE bool operator == (const LLUnit& other) const { return mValue == convert(other).value(); } template - LL_FORCE_INLINE bool operator != (LLUnit other) const + LL_FORCE_INLINE bool operator != (const LLUnit& other) const { return mValue != convert(other).value(); } template - LL_FORCE_INLINE bool operator < (LLUnit other) const + LL_FORCE_INLINE bool operator < (const LLUnit& other) const { return mValue < convert(other).value(); } template - LL_FORCE_INLINE bool operator <= (LLUnit other) const + LL_FORCE_INLINE bool operator <= (const LLUnit& other) const { return mValue <= convert(other).value(); } template - LL_FORCE_INLINE bool operator > (LLUnit other) const + LL_FORCE_INLINE bool operator > (const LLUnit& other) const { return mValue > convert(other).value(); } template - LL_FORCE_INLINE bool operator >= (LLUnit other) const + LL_FORCE_INLINE bool operator >= (const LLUnit& other) const { return mValue >= convert(other).value(); } diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index a661d52b7f..23afbdfa3a 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -35,7 +35,7 @@ //========================================================================= namespace { - const F64 BREAK_POINT = 0.5; + const LLSettingsBase::BlendFactor BREAK_POINT = 0.5; } //========================================================================= @@ -272,7 +272,8 @@ size_t LLSettingsBase::getHash() const LLSD hash_settings = llsd_shallow(getSettings(), LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true)); - return boost::hash{}(hash_settings); + boost::hash hasher; + return hasher(hash_settings); } bool LLSettingsBase::validate() @@ -340,17 +341,35 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida validated.insert(validateType.getName()); // Fields for specific settings. - for (auto &test: validations) + for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv) { - if (!test.verify(settings)) +#ifdef VALIDATION_DEBUG + LLSD oldvalue; + if (settings.has((*itv).getName())) + { + oldvalue = llsd_clone(mSettings[(*itv).getName()]); + } +#endif + + if (!(*itv).verify(settings)) { std::stringstream errtext; - errtext << "Settings LLSD fails validation and could not be corrected for '" << test.getName() << "'!\n"; + errtext << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!\n"; errors.append( errtext.str() ); isValid = false; } - validated.insert(test.getName()); + validated.insert((*itv).getName()); + +#ifdef VALIDATION_DEBUG + if (!oldvalue.isUndefined()) + { + if (!compare_llsd(settings[(*itv).getName()], oldvalue)) + { + LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << settings[(*itv).getName()] << LL_ENDL; + } + } +#endif } // strip extra entries @@ -366,9 +385,9 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida } } - for (const std::string &its: strip) + for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its) { - settings.erase(its); + settings.erase(*its); } return LLSDMap("success", LLSD::Boolean(isValid)) @@ -533,13 +552,14 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) } //========================================================================= -void LLSettingsBlender::update(F64 blendf) +void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) { setPosition(blendf); } -F64 LLSettingsBlender::setPosition(F64 blendf) +F64 LLSettingsBlender::setPosition(const LLSettingsBase::TrackPosition& blendf_in) { + LLSettingsBase::TrackPosition blendf = blendf_in; if (blendf >= 1.0) { triggerComplete(); @@ -565,14 +585,14 @@ void LLSettingsBlender::triggerComplete() } //------------------------------------------------------------------------- -F64 LLSettingsBlenderTimeDelta::calculateBlend(F64 spanpos, F64 spanlen) const +LLSettingsBase::BlendFactor LLSettingsBlenderTimeDelta::calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const { - return fmod(spanpos, spanlen) / spanlen; + return LLSettingsBase::BlendFactor(fmod((F64)spanpos, (F64)spanlen) / (F64)spanlen); } -void LLSettingsBlenderTimeDelta::update(F64 timedelta) +void LLSettingsBlenderTimeDelta::advance(const LLSettingsBase::Seconds& timedelta) { - mTimeSpent += LLSettingsBase::Seconds(timedelta); + mTimeSpent += timedelta; if (mTimeSpent > mBlendSpan) { @@ -580,8 +600,7 @@ void LLSettingsBlenderTimeDelta::update(F64 timedelta) return; } - F64 blendf = calculateBlend(mTimeSpent.value(), mBlendSpan.value()); - // Note no clamp here. + LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); setPosition(blendf); } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 6f072a4e50..a8e1cc5eea 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -45,8 +45,14 @@ #include "llinventorysettings.h" +#define PTR_NAMESPACE std +#define SETTINGS_OVERRIDE override + +//#define PTR_NAMESPACE boost +//#define SETTINGS_OVERRIDE + class LLSettingsBase : - public std::enable_shared_from_this, + public PTR_NAMESPACE::enable_shared_from_this, private boost::noncopyable { friend class LLEnvironment; @@ -56,6 +62,8 @@ class LLSettingsBase : public: typedef F64Seconds Seconds; + typedef F64 BlendFactor; + typedef F64 TrackPosition; static const std::string SETTING_ID; static const std::string SETTING_NAME; @@ -64,7 +72,7 @@ public: typedef std::map parammapping_t; - typedef std::shared_ptr ptr_t; + typedef PTR_NAMESPACE::shared_ptr ptr_t; virtual ~LLSettingsBase() { }; @@ -107,12 +115,17 @@ public: //--------------------------------------------------------------------- // - inline void setValue(const std::string &name, const LLSD &value) + inline void setLLSD(const std::string &name, const LLSD &value) { mSettings[name] = value; mDirty = true; } + inline void setValue(const std::string &name, const LLSD &value) + { + setLLSD(name, value); + } + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const { if (!mSettings.has(name)) @@ -120,6 +133,11 @@ public: return mSettings[name]; } + inline void setValue(const std::string &name, F32 v) + { + setLLSD(name, LLSD::Real(v)); + } + inline void setValue(const std::string &name, const LLVector2 &value) { setValue(name, value.getValue()); @@ -150,7 +168,7 @@ public: setValue(name, value.getValue()); } - inline F64 getBlendFactor() const + inline BlendFactor getBlendFactor() const { return mBlendedFactor; } @@ -165,7 +183,7 @@ public: (const_cast(this))->updateSettings(); } - virtual void blend(const ptr_t &end, F64 blendf) = 0; + virtual void blend(const ptr_t &end, BlendFactor blendf) = 0; virtual bool validate(); @@ -220,8 +238,8 @@ protected: typedef std::set stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, F64 mix); - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const; + virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix); + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, BlendFactor mix) const; /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -248,7 +266,7 @@ protected: LLSD cloneSettings() const; - inline void setBlendFactor(F64 blendfactor) + inline void setBlendFactor(BlendFactor blendfactor) { mBlendedFactor = blendfactor; } @@ -256,18 +274,18 @@ protected: void markDirty() { mDirty = true; } private: - bool mDirty = true; + bool mDirty; LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; - F64 mBlendedFactor; + BlendFactor mBlendedFactor; }; -class LLSettingsBlender : public std::enable_shared_from_this +class LLSettingsBlender : public PTR_NAMESPACE::enable_shared_from_this { public: - typedef std::shared_ptr ptr_t; + typedef PTR_NAMESPACE::shared_ptr ptr_t; typedef boost::signals2::signal finish_signal_t; typedef boost::signals2::connection connection_t; @@ -287,7 +305,7 @@ public: virtual ~LLSettingsBlender() {} - virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 /*span*/ = 1.0) + virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) { // note: the 'span' reset parameter is unused by the base class. if (!mInitial) @@ -322,10 +340,10 @@ public: return mOnFinished.connect(onfinished); } - virtual void update(F64 blendf); - virtual F64 setPosition(F64 blendf); + virtual void update(const LLSettingsBase::BlendFactor& blendf); + virtual F64 setPosition(const LLSettingsBase::TrackPosition& position); - virtual void switchTrack(S32 trackno, F64 position = -1.0) { /*NoOp*/ } + virtual void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor& position) { /*NoOp*/ } protected: void triggerComplete(); @@ -341,7 +359,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender { public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds seconds) : LLSettingsBlender(target, initsetting, endsetting), mBlendSpan(seconds), mLastUpdate(0.0f), @@ -355,20 +373,20 @@ public: { } - virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) override + virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) SETTINGS_OVERRIDE { LLSettingsBlender::reset(initsetting, endsetting, span); - mBlendSpan.value(span); - mTimeStart.value(LLDate::now().secondsSinceEpoch()); + mBlendSpan = span; + mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; - mTimeSpent.value(0.0f); + mTimeSpent = LLSettingsBase::Seconds(0.0); } - virtual void update(F64 timedelta) override; + virtual void advance(const LLSettingsBase::Seconds& timedelta); protected: - F64 calculateBlend(F64 spanpos, F64 spanlen) const; + LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const; LLSettingsBase::Seconds mBlendSpan; LLSettingsBase::Seconds mLastUpdate; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 3f2238bf7a..cd2102a527 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -42,7 +42,22 @@ namespace LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + template + inline T get_wrapping_distance(T begin, T end) + { + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -57,7 +72,7 @@ namespace return it; } - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -102,7 +117,7 @@ const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water const S32 LLSettingsDay::FRAME_MAX(56); // *LAPRAS* Change when Agni -const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb"); +static const LLUUID DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb"); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : @@ -136,20 +151,20 @@ LLSD LLSettingsDay::getSettings() const LLSD tracks(LLSD::emptyArray()); - for (auto &track: mDayTracks) + for (CycleList_t::const_iterator itTrack = mDayTracks.begin(); itTrack != mDayTracks.end(); ++itTrack) { LLSD trackout(LLSD::emptyArray()); - for (auto &frame: track) + for (CycleTrack_t::const_iterator itFrame = (*itTrack).begin(); itFrame != (*itTrack).end(); ++itFrame) { - F32 frame_time = frame.first; - LLSettingsBase::ptr_t data = frame.second; + F32 frame = (*itFrame).first; + LLSettingsBase::ptr_t data = (*itFrame).second; size_t datahash = data->getHash(); std::stringstream keyname; keyname << datahash; - trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame_time))(SETTING_KEYNAME, keyname.str()))); + trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame))(SETTING_KEYNAME, keyname.str()))); in_use[keyname.str()] = data; } tracks.append(trackout); @@ -157,12 +172,12 @@ LLSD LLSettingsDay::getSettings() const settings[SETTING_TRACKS] = tracks; LLSD frames(LLSD::emptyMap()); - for (auto &used_frame: in_use) + for (std::map::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) { - LLSD framesettings = llsd_clone(used_frame.second->getSettings(), + LLSD framesettings = llsd_clone((*itFrame).second->getSettings(), LLSDMap("*", true)(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)); - frames[used_frame.first] = framesettings; + frames[(*itFrame).first] = framesettings; } settings[SETTING_FRAMES] = frames; @@ -212,8 +227,9 @@ bool LLSettingsDay::initialize() LLSD curtrack = tracks[i]; for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { - F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); - keyframe = llclamp(keyframe, 0.0f, 1.0f); + LLSettingsBase::Seconds keyframe = LLSettingsBase::Seconds((*it)[SETTING_KEYKFRAME].asReal()); + // is this supposed to be a blend factor or a time value? + //keyframe = llclamp((F32)keyframe, 0.0f, 1.0f); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -223,7 +239,7 @@ bool LLSettingsDay::initialize() setting = used[(*it)[SETTING_KEYNAME]]; if (setting && setting->getSettingType() != "water") { - LL_WARNS("SETTINGS", "DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + LL_WARNS("DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; setting.reset(); } } @@ -232,7 +248,7 @@ bool LLSettingsDay::initialize() setting = used[(*it)[SETTING_KEYNAME]]; if (setting && setting->getSettingType() != "sky") { - LL_WARNS("SETTINGS", "DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + LL_WARNS("DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; setting.reset(); } } @@ -296,7 +312,6 @@ LLSD LLSettingsDay::defaults() dfltsetting[SETTING_FRAMES] = frames; dfltsetting[SETTING_TYPE] = "daycycle"; - return dfltsetting; } @@ -475,7 +490,6 @@ void LLSettingsDay::startDayCycle() LL_WARNS("DAYCYCLE") << "Attempt to start day cycle on uninitialized object." << LL_ENDL; return; } - } @@ -497,15 +511,15 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) keyframes.reserve(track.size()); - for (auto &frame: track) + for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) { - keyframes.push_back(frame.first); + keyframes.push_back((*it).first); } return keyframes; } -bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame) +bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -524,7 +538,9 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame) { LLSettingsBase::ptr_t base = iter->second; track.erase(iter); - track[llclamp(new_frame, 0.0f, 1.0f)] = base; + // why are we clamping a time value as if its a blend factor + //track[llclamp(new_frame, 0.0f, 1.0f)] = base; + track[new_frame] = base; return true; } @@ -532,7 +548,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame) } -bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame) +bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -552,17 +568,18 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame) return false; } -void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) +void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe) { setSettingsAtKeyframe(water, keyframe, TRACK_WATER); } -LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe) const +LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const { - return std::dynamic_pointer_cast(getSettingsAtKeyframe(keyframe, TRACK_WATER)); + LLSettingsBase* p = getSettingsAtKeyframe(keyframe, TRACK_WATER).get(); + return LLSettingsWater::ptr_t((LLSettingsWater*)p); } -void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyframe, S32 track) +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { @@ -573,18 +590,18 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyfra setSettingsAtKeyframe(sky, keyframe, track); } -LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) const +LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const { if ((track < 1) || (track >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; return LLSettingsSky::ptr_t(); } - - return std::dynamic_pointer_cast(getSettingsAtKeyframe(keyframe, track)); + LLSettingsBase* p = getSettingsAtKeyframe(keyframe, track).get(); + return LLSettingsSky::ptr_t((LLSettingsSky*)p); } -void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track) +void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track) { if ((track < 0) || (track >= TRACK_MAX)) { @@ -592,11 +609,12 @@ void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, return; } - mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; + //mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; + mDayTracks[track][keyframe] = settings; setDirtyFlag(true); } -LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track) const +LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const { if ((track < 0) || (track >= TRACK_MAX)) { @@ -614,19 +632,24 @@ LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 tra return LLSettingsBase::ptr_t(); } -F32 LLSettingsDay::getUpperBoundFrame(S32 track, F32 keyframe) +LLSettingsBase::TrackPosition LLSettingsDay::getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe) { return get_wrapping_atafter(mDayTracks[track], keyframe)->first; } -F32 LLSettingsDay::getLowerBoundFrame(S32 track, F32 keyframe) +LLSettingsBase::TrackPosition LLSettingsDay::getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe) { return get_wrapping_atbefore(mDayTracks[track], keyframe)->first; } -LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) +LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe) { return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } +LLUUID LLSettingsDay::GetDefaultAssetId() +{ + return DEFAULT_ASSET_ID; +} + //========================================================================= diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index f7e5710dc1..b9038506d1 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -35,12 +35,15 @@ class LLSettingsSky; // These are alias for LLSettingsWater::ptr_t and LLSettingsSky::ptr_t respectively. // Here for definitions only. -typedef std::shared_ptr LLSettingsWaterPtr_t; -typedef std::shared_ptr LLSettingsSkyPtr_t; +typedef PTR_NAMESPACE::shared_ptr LLSettingsWaterPtr_t; +typedef PTR_NAMESPACE::shared_ptr LLSettingsSkyPtr_t; class LLSettingsDay : public LLSettingsBase { public: + // 32-bit as LLSD only supports that width at present + typedef S32Seconds Seconds; + static const std::string SETTING_KEYID; static const std::string SETTING_KEYNAME; static const std::string SETTING_KEYKFRAME; @@ -63,13 +66,12 @@ public: static const S32 TRACK_MAX; static const S32 FRAME_MAX; - static const LLUUID DEFAULT_ASSET_ID; - - typedef std::map CycleTrack_t; - typedef std::vector CycleList_t; - typedef std::shared_ptr ptr_t; - typedef std::vector KeyframeList_t; - typedef std::pair TrackBound_t; + typedef std::map CycleTrack_t; + typedef std::vector CycleList_t; + typedef PTR_NAMESPACE::shared_ptr ptr_t; + typedef PTR_NAMESPACE::weak_ptr wptr_t; + typedef std::vector KeyframeList_t; + typedef std::pair TrackBound_t; //--------------------------------------------------------------------- LLSettingsDay(const LLSD &data); @@ -78,29 +80,29 @@ public: bool initialize(); virtual ptr_t buildClone() = 0; - virtual LLSD getSettings() const override; - virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_DAYCYCLE; } + virtual LLSD getSettings() const SETTINGS_OVERRIDE; + virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_DAYCYCLE; } //--------------------------------------------------------------------- - virtual std::string getSettingType() const override { return std::string("daycycle"); } + virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) override; + virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; static LLSD defaults(); //--------------------------------------------------------------------- KeyframeList_t getTrackKeyframes(S32 track); - bool moveTrackKeyframe(S32 track, F32 old_frame, F32 new_frame); - bool removeTrackKeyframe(S32 track, F32 frame); - - void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe) const; - void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track); - LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track) const; - void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track); - LLSettingsBase::ptr_t getSettingsAtKeyframe(F32 keyframe, S32 track) const; + bool moveTrackKeyframe(S32 track, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame); + bool removeTrackKeyframe(S32 track, const LLSettingsBase::Seconds& frame); + + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe); + LLSettingsWaterPtr_t getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const; + void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track); + LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const; + void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track); + LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const; //--------------------------------------------------------------------- void startDayCycle(); @@ -113,18 +115,20 @@ public: void setInitialized(bool value = true) { mInitialized = value; } CycleTrack_t & getCycleTrack(S32 track); - virtual validation_list_t getValidationList() const override; + virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); - virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } - F32 getUpperBoundFrame(S32 track, F32 keyframe); - F32 getLowerBoundFrame(S32 track, F32 keyframe); + LLSettingsBase::TrackPosition getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); + LLSettingsBase::TrackPosition getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); + + static LLUUID GetDefaultAssetId(); protected: LLSettingsDay(); - virtual void updateSettings() override; + virtual void updateSettings() SETTINGS_OVERRIDE; bool mInitialized; @@ -135,10 +139,9 @@ private: void parseFromLLSD(LLSD &data); - static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); - static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); - - TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); + static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); + TrackBound_t getBoundingEntries(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); }; #endif diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index cdd5b156d2..95502f47c3 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -106,12 +106,11 @@ const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR("exp_s const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM("linear_term"); const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM("constant_term"); -const LLUUID LLSettingsSky::DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271"); // dataserver -const LLUUID LLSettingsSky::DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver -const LLUUID LLSettingsSky::DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); - // *LAPRAS* Change when Agni! -const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749"); +static const LLUUID DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271"); // dataserver +static const LLUUID DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver +static const LLUUID DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); +static const LLUUID DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749"); const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze"); @@ -218,7 +217,7 @@ LLSettingsSky::validation_list_t mieValidationList() bool validateLegacyHaze(LLSD &value) { LLSettingsSky::validation_list_t legacyHazeValidations = legacyHazeValidationList(); - llassert(value.type() == LLSD::Type::TypeMap); + llassert(value.type() == LLSD::TypeMap); LLSD result = LLSettingsBase::settingValidation(value, legacyHazeValidations); if (result["errors"].size() > 0) { @@ -242,14 +241,14 @@ bool validateRayleighLayers(LLSD &value) for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf) { LLSD& layerConfig = (*itf); - if (layerConfig.type() == LLSD::Type::TypeMap) + if (layerConfig.type() == LLSD::TypeMap) { if (!validateRayleighLayers(layerConfig)) { allGood = false; } } - else if (layerConfig.type() == LLSD::Type::TypeArray) + else if (layerConfig.type() == LLSD::TypeArray) { return validateRayleighLayers(layerConfig); } @@ -260,7 +259,7 @@ bool validateRayleighLayers(LLSD &value) } return allGood; } - llassert(value.type() == LLSD::Type::TypeMap); + llassert(value.type() == LLSD::TypeMap); LLSD result = LLSettingsBase::settingValidation(value, rayleighValidations); if (result["errors"].size() > 0) { @@ -284,14 +283,14 @@ bool validateAbsorptionLayers(LLSD &value) for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf) { LLSD& layerConfig = (*itf); - if (layerConfig.type() == LLSD::Type::TypeMap) + if (layerConfig.type() == LLSD::TypeMap) { if (!validateAbsorptionLayers(layerConfig)) { allGood = false; } } - else if (layerConfig.type() == LLSD::Type::TypeArray) + else if (layerConfig.type() == LLSD::TypeArray) { return validateAbsorptionLayers(layerConfig); } @@ -302,7 +301,7 @@ bool validateAbsorptionLayers(LLSD &value) } return allGood; } - llassert(value.type() == LLSD::Type::TypeMap); + llassert(value.type() == LLSD::TypeMap); LLSD result = LLSettingsBase::settingValidation(value, absorptionValidations); if (result["errors"].size() > 0) { @@ -326,14 +325,14 @@ bool validateMieLayers(LLSD &value) for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf) { LLSD& layerConfig = (*itf); - if (layerConfig.type() == LLSD::Type::TypeMap) + if (layerConfig.type() == LLSD::TypeMap) { if (!validateMieLayers(layerConfig)) { allGood = false; } } - else if (layerConfig.type() == LLSD::Type::TypeArray) + else if (layerConfig.type() == LLSD::TypeArray) { return validateMieLayers(layerConfig); } @@ -379,7 +378,7 @@ LLSettingsSky::LLSettingsSky(): void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsSky::ptr_t other = std::static_pointer_cast(end); + LLSettingsSky::ptr_t other((LLSettingsSky*)end.get()); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); @@ -416,8 +415,6 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const return slepSet; } - - LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const { return LLSettingsSky::validationList(); @@ -512,7 +509,6 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() validation.push_back(Validator(SETTING_SUN_ARC_RADIANS, true, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.1f))))); - validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers)); validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers)); @@ -771,9 +767,6 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) void LLSettingsSky::updateSettings() { - LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); - //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; - mPositionsDirty = isDirty(); mLightingDirty = isDirty(); @@ -1051,3 +1044,8 @@ void LLSettingsSky::calculateLightSettings() const mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; mFadeColor.setAlpha(0); } + +LLUUID LLSettingsSky::GetDefaultAssetId() +{ + return DEFAULT_ASSET_ID; +} \ No newline at end of file diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 839de033b3..fd613e4299 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -88,13 +88,7 @@ public: static const std::string SETTING_LEGACY_HAZE; - static const LLUUID DEFAULT_SUN_ID; - static const LLUUID DEFAULT_MOON_ID; - static const LLUUID DEFAULT_CLOUD_ID; - - static const LLUUID DEFAULT_ASSET_ID; - - typedef std::shared_ptr ptr_t; + typedef PTR_NAMESPACE::shared_ptr ptr_t; //--------------------------------------------------------------------- LLSettingsSky(const LLSD &data); @@ -103,11 +97,11 @@ public: virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- - virtual std::string getSettingType() const override { return std::string("sky"); } - virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_SKY; } + virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("sky"); } + virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_SKY; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override; + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -374,7 +368,7 @@ public: virtual void loadTextures() { }; //===================================================================== - virtual validation_list_t getValidationList() const override; + virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); static LLSD translateLegacySettings(const LLSD& legacy); @@ -415,7 +409,9 @@ public: LLColor3 getSunDiffuse() const; LLColor4 getTotalAmbient() const; - virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } + + static LLUUID GetDefaultAssetId(); protected: static const std::string SETTING_LEGACY_EAST_ANGLE; @@ -424,13 +420,13 @@ protected: LLSettingsSky(); - virtual stringset_t getSlerpKeys() const override; - virtual stringset_t getSkipInterpolateKeys() const override; - virtual void updateSettings() override; + virtual stringset_t getSlerpKeys() const SETTINGS_OVERRIDE; + virtual stringset_t getSkipInterpolateKeys() const SETTINGS_OVERRIDE; + virtual void updateSettings() SETTINGS_OVERRIDE; private: - mutable bool mPositionsDirty = true; - mutable bool mLightingDirty = true; + mutable bool mPositionsDirty; + mutable bool mLightingDirty; static LLSD rayleighConfigDefault(); static LLSD absorptionConfigDefault(); diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index aa1f0f1935..03e174b454 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -67,11 +67,8 @@ const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow"); const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir"); const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); -const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL); - // *LAPRAS* Change when Agni -const LLUUID LLSettingsWater::DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661"); - +static const LLUUID DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661"); //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : @@ -98,7 +95,7 @@ LLSD LLSettingsWater::defaults() dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); - dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL_ID); + dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL); dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue(); dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); @@ -168,7 +165,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsWater::ptr_t other = std::static_pointer_cast(end); + LLSettingsWater::ptr_t other((LLSettingsWater*)end.get()); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); @@ -227,3 +224,13 @@ LLSettingsWater::validation_list_t LLSettingsWater::validationList() return validation; } +LLUUID LLSettingsWater::GetDefaultAssetId() +{ + return DEFAULT_ASSET_ID; +} + +LLUUID LLSettingsWater::GetDefaultWaterNormalAssetId() +{ + return DEFAULT_WATER_NORMAL; +} + diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index a85a471bc5..92e9869e45 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -46,11 +46,7 @@ public: static const std::string SETTING_WAVE1_DIR; static const std::string SETTING_WAVE2_DIR; - static const LLUUID DEFAULT_WATER_NORMAL_ID; - - static const LLUUID DEFAULT_ASSET_ID; - - typedef std::shared_ptr ptr_t; + typedef PTR_NAMESPACE::shared_ptr ptr_t; //--------------------------------------------------------------------- LLSettingsWater(const LLSD &data); @@ -59,11 +55,11 @@ public: virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- - virtual std::string getSettingType() const override { return std::string("water"); } - virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_WATER; } + virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("water"); } + virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_WATER; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override; + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -208,12 +204,15 @@ public: } - virtual validation_list_t getValidationList() const override; + virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); static LLSD translateLegacySettings(LLSD legacy); - virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } + + static LLUUID GetDefaultAssetId(); + static LLUUID GetDefaultWaterNormalAssetId(); protected: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; @@ -231,11 +230,11 @@ protected: LLSettingsWater(); - LLVector4 mWaterPlane; - F32 mWaterFogKS; + LLVector4 mWaterPlane; + F32 mWaterFogKS; private: - LLUUID mNextNormalMapID; + LLUUID mNextNormalMapID; }; #endif diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index 8dbe2f8411..8baa2e328b 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -543,7 +543,7 @@ void LLCircuitData::checkPeriodTime() mBytesOutLastPeriod = mBytesOutThisPeriod; mBytesInThisPeriod = S32Bytes(0); mBytesOutThisPeriod = S32Bytes(0); - mLastPeriodLength = period_length; + mLastPeriodLength = F32Seconds::convert(period_length); mPeriodTime = mt_sec; } @@ -1378,8 +1378,8 @@ F32Milliseconds LLCircuitData::getPingInTransitTime() if (mPingsInTransit) { - time_since_ping_was_sent = ((mPingsInTransit*mHeartbeatInterval - F32Seconds(1)) - + (LLMessageSystem::getMessageTimeSeconds() - mPingTime)); + time_since_ping_was_sent = F32Milliseconds::convert(((mPingsInTransit*mHeartbeatInterval - F32Seconds(1)) + + (LLMessageSystem::getMessageTimeSeconds() - mPingTime))); } return time_since_ping_was_sent; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3b0bc4cd55..3f6241fa0b 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -66,7 +66,7 @@ namespace LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); //--------------------------------------------------------------------- - inline F32 get_wrapping_distance(F32 begin, F32 end) + inline LLSettingsBase::TrackPosition get_wrapping_distance(LLSettingsBase::TrackPosition begin, LLSettingsBase::TrackPosition end) { if (begin < end) { @@ -74,13 +74,13 @@ namespace } else if (begin > end) { - return 1.0 - (begin - end); + return LLSettingsBase::TrackPosition(1.0) - (begin - end); } return 0; } - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -95,7 +95,7 @@ namespace return it; } - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -116,7 +116,7 @@ namespace return it; } - LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) + LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe) { return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } @@ -144,7 +144,7 @@ namespace } - void switchTrack(S32 trackno, F64) override + void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor&) override { S32 use_trackno = selectTrackNumber(trackno); @@ -159,17 +159,16 @@ namespace LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); - LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); - F64 targetpos = convertTimeToPosition(now) - (*bounds.first).first; - F64 targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); + LLSettingsBase::TrackPosition targetpos = convertTimeToPosition(now) - (*bounds.first).first; + LLSettingsBase::TrackPosition targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - F64 blendf = calculateBlend(targetpos, targetspan); + LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); - reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE.value()); + reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); } - protected: S32 selectTrackNumber(S32 trackno) { @@ -210,9 +209,9 @@ namespace return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } - F64 convertTimeToPosition(LLSettingsBase::Seconds time) + LLSettingsBase::TrackPosition convertTimeToPosition(const LLSettingsBase::Seconds& time) { - F64 position = static_cast(fmod(time.value(), mCycleLength.value())) / static_cast(mCycleLength.value()); + F64 position = fmod((F64)time, (F64)mCycleLength) / (F64)mCycleLength; return llclamp(position, 0.0, 1.0); } @@ -223,11 +222,11 @@ namespace LLSettingsBase::Seconds mCycleOffset; LLSettingsBase::ptr_t mTrackTransitionStart; - void onFinishedSpan() + void onFinishedSpan() { LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow()); LLSettingsBase::Seconds nextspan = getSpanTime(next); - reset((*next.first).second, (*next.second).second, nextspan.value()); + reset((*next.first).second, (*next.second).second, nextspan); } }; @@ -241,10 +240,6 @@ const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); //*TODO* Change these when available on Agni (these are Damballah asset IDs). -const LLUUID LLEnvironment::KNOWN_SKY_DEFAULT(LLSettingsSky::DEFAULT_ASSET_ID); -const LLUUID LLEnvironment::KNOWN_WATER_DEFAULT(LLSettingsWater::DEFAULT_ASSET_ID); -const LLUUID LLEnvironment::KNOWN_DAY_DEFAULT(LLSettingsDay::DEFAULT_ASSET_ID); - const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("645d7475-19d6-d05c-6eb2-29eeacf76e06"); const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("68f5a7ec-2785-d9d8-be7c-cca93976759a"); const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("06420773-757b-4b7c-a1f9-85fceb2f7bd4"); @@ -1741,7 +1736,7 @@ void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) mSkyTrack = trackno; if (mBlenderSky) { - mBlenderSky->switchTrack(trackno); + mBlenderSky->switchTrack(trackno, 0.0); } } @@ -1803,7 +1798,7 @@ void LLEnvironment::DayInstance::animate() { mSky = LLSettingsVOSky::buildDefaultSky(); mBlenderSky = std::make_shared(mSky, mDayCycle, 1, mDayLength, mDayOffset); - mBlenderSky->switchTrack(mSkyTrack); + mBlenderSky->switchTrack(mSkyTrack, 0.0); } } @@ -1869,7 +1864,7 @@ LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::p } } -F64 LLTrackBlenderLoopingManual::setPosition(F64 position) +LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSettingsBase::TrackPosition& position) { mPosition = llclamp(position, 0.0, 1.0); @@ -1891,11 +1886,11 @@ F64 LLTrackBlenderLoopingManual::setPosition(F64 position) return LLSettingsBlender::setPosition(blendf); } -void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, F64 position) +void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) { mTrackNo = trackno; - F64 useposition = (position < 0.0) ? mPosition : position; + LLSettingsBase::TrackPosition useposition = (position < 0.0) ? mPosition : position; setPosition(useposition); } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 56be88f371..1be846b710 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -56,9 +56,6 @@ public: static const F32Seconds TRANSITION_SLOW; static const F32Seconds TRANSITION_ALTITUDE; - static const LLUUID KNOWN_SKY_DEFAULT; - static const LLUUID KNOWN_WATER_DEFAULT; - static const LLUUID KNOWN_DAY_DEFAULT; static const LLUUID KNOWN_SKY_SUNRISE; static const LLUUID KNOWN_SKY_MIDDAY; static const LLUUID KNOWN_SKY_SUNSET; @@ -413,8 +410,8 @@ class LLTrackBlenderLoopingManual : public LLSettingsBlender public: LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno); - F64 setPosition(F64 position) override; - virtual void switchTrack(S32 trackno, F64 position) override; + F64 setPosition(const LLSettingsBase::TrackPosition& position) override; + virtual void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) override; S32 getTrack() const { return mTrackNo; } typedef std::shared_ptr ptr_t; diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index cac9154c98..788f58d480 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -311,9 +311,9 @@ void LLFloaterEditExtDayCycle::onAddTrack() { // todo: 2.5% safety zone std::string sldr_key = mFramesSlider->getCurSlider(); - F32 frame = mTimeSlider->getCurSliderValue(); + LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); LLSettingsBase::ptr_t setting; - if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack).get() != NULL) + if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack) != nullptr) { return; } @@ -322,13 +322,15 @@ void LLFloaterEditExtDayCycle::onAddTrack() { // scratch water should always have the current water settings. setting = mScratchWater->buildClone(); - mEditDay->setWaterAtKeyframe(std::dynamic_pointer_cast(setting), frame); + LLSettingsWater::ptr_t water((LLSettingsWater*)setting.get()); + mEditDay->setWaterAtKeyframe(water, frame); } else { // scratch sky should always have the current sky settings. setting = mScratchSky->buildClone(); - mEditDay->setSkyAtKeyframe(std::dynamic_pointer_cast(setting), frame, mCurrentTrack); + LLSettingsSky::ptr_t sky((LLSettingsSky*)setting.get()); + mEditDay->setSkyAtKeyframe(sky, frame, mCurrentTrack); } addSliderFrame(frame, setting); @@ -657,7 +659,7 @@ void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) void LLFloaterEditExtDayCycle::updateButtons() { - F32 frame = mTimeSlider->getCurSliderValue(); + LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); LLSettingsBase::ptr_t settings = mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack); bool can_add = settings.get() == NULL; mAddFrameButton->setEnabled(can_add); @@ -744,7 +746,8 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() { LL_DEBUGS() << "Removing frame from " << iter->second.mFrame << LL_ENDL; mSliderKeyMap.erase(iter); - mEditDay->removeTrackKeyframe(mCurrentTrack, iter->second.mFrame); + LLSettingsBase::Seconds seconds(iter->second.mFrame); + mEditDay->removeTrackKeyframe(mCurrentTrack, seconds); } mLastFrameSlider = mFramesSlider->getCurSlider(); @@ -852,7 +855,7 @@ void LLFloaterEditExtDayCycle::syncronizeTabs() { // This should probably get moved into "updateTabs" - F32 frame = mTimeSlider->getCurSliderValue(); + LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); bool canedit(false); LLSettingsWater::ptr_t psettingWater; diff --git a/indra/newview/llpaneleditwater.cpp b/indra/newview/llpaneleditwater.cpp index 940b171dfe..b0a300abe3 100644 --- a/indra/newview/llpaneleditwater.cpp +++ b/indra/newview/llpaneleditwater.cpp @@ -87,7 +87,7 @@ BOOL LLPanelSettingsWaterMainTab::postBuild() // getChild(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(getChild(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); }); getChild(FIELD_WATER_UNDERWATER_MOD)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogUnderWaterChanged(); }); - mTxtNormalMap->setDefaultImageAssetID(LLSettingsWater::DEFAULT_WATER_NORMAL_ID); + mTxtNormalMap->setDefaultImageAssetID(LLSettingsWater::GetDefaultWaterNormalAssetId()); mTxtNormalMap->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalMapChanged(); }); getChild(FIELD_WATER_WAVE1_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLargeWaveChanged(); }); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 0e3bc87719..5991c42c97 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -449,14 +449,13 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) if (settings.has(SETTING_LEGACY_HAZE)) { LLSD legacyhaze = settings[SETTING_LEGACY_HAZE]; - - legacy[SETTING_AMBIENT] = ensureArray4(legacyhaze[SETTING_AMBIENT], 1.0f); - legacy[SETTING_BLUE_DENSITY] = ensureArray4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); - legacy[SETTING_BLUE_HORIZON] = ensureArray4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); - legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f); + legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); - legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); } } -- cgit v1.3 From 38271e9980f2ccb6b80b27cd063933748247a7be Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 3 Jun 2018 00:35:17 +0100 Subject: Remove redundant typedef hosing OSX build. --- indra/llinventory/llsettingsdaycycle.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index b9038506d1..6f54833c74 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -51,9 +51,6 @@ public: static const std::string SETTING_TRACKS; static const std::string SETTING_FRAMES; - // 32-bit as LLSD only supports that width at present - typedef S32Seconds Seconds; - static const Seconds MINIMUM_DAYLENGTH; static const Seconds DEFAULT_DAYLENGTH; static const Seconds MAXIMUM_DAYLENGTH; -- cgit v1.3 From cd8f0da2d187df69a99a665ea11faaa4e13b7a12 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 4 Jun 2018 23:12:21 +0100 Subject: Fix use of new typedefs in inventory settings code in llenvironment. --- indra/llinventory/llsettingsbase.cpp | 12 ++++---- indra/llinventory/llsettingsbase.h | 31 +++++++++++--------- indra/llinventory/llsettingsdaycycle.cpp | 42 +++++++++++---------------- indra/llinventory/llsettingsdaycycle.h | 24 +++++++-------- indra/llinventory/llsettingswater.cpp | 2 +- indra/newview/llenvironment.cpp | 50 ++++++++++++++------------------ indra/newview/llenvironment.h | 8 ++--- 7 files changed, 78 insertions(+), 91 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 23afbdfa3a..76b1e0b2a6 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -35,7 +35,7 @@ //========================================================================= namespace { - const LLSettingsBase::BlendFactor BREAK_POINT = 0.5; + const LLSettingsBase::TrackPosition BREAK_POINT = 0.5; } //========================================================================= @@ -554,10 +554,10 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) //========================================================================= void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) { - setPosition(blendf); + setBlendFactor(blendf); } -F64 LLSettingsBlender::setPosition(const LLSettingsBase::TrackPosition& blendf_in) +F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in) { LLSettingsBase::TrackPosition blendf = blendf_in; if (blendf >= 1.0) @@ -565,7 +565,7 @@ F64 LLSettingsBlender::setPosition(const LLSettingsBase::TrackPosition& blendf_i triggerComplete(); return 1.0; } - blendf = llclamp(blendf, 0.0, 1.0); + blendf = llclamp(blendf, 0.0f, 1.0f); mTarget->replaceSettings(mInitial->getSettings()); if (!mFinal || (mInitial == mFinal) || (blendf == 0.0)) @@ -590,7 +590,7 @@ LLSettingsBase::BlendFactor LLSettingsBlenderTimeDelta::calculateBlend(const LLS return LLSettingsBase::BlendFactor(fmod((F64)spanpos, (F64)spanlen) / (F64)spanlen); } -void LLSettingsBlenderTimeDelta::advance(const LLSettingsBase::Seconds& timedelta) +void LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& timedelta) { mTimeSpent += timedelta; @@ -602,5 +602,5 @@ void LLSettingsBlenderTimeDelta::advance(const LLSettingsBase::Seconds& timedelt LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); - setPosition(blendf); + update(blendf); } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index a8e1cc5eea..374a2ec246 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -48,9 +48,6 @@ #define PTR_NAMESPACE std #define SETTINGS_OVERRIDE override -//#define PTR_NAMESPACE boost -//#define SETTINGS_OVERRIDE - class LLSettingsBase : public PTR_NAMESPACE::enable_shared_from_this, private boost::noncopyable @@ -63,7 +60,7 @@ class LLSettingsBase : public: typedef F64Seconds Seconds; typedef F64 BlendFactor; - typedef F64 TrackPosition; + typedef F32 TrackPosition; // 32-bit as these are stored in LLSD as such static const std::string SETTING_ID; static const std::string SETTING_NAME; @@ -305,7 +302,7 @@ public: virtual ~LLSettingsBlender() {} - virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) + virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::TrackPosition&) { // note: the 'span' reset parameter is unused by the base class. if (!mInitial) @@ -341,9 +338,15 @@ public: } virtual void update(const LLSettingsBase::BlendFactor& blendf); - virtual F64 setPosition(const LLSettingsBase::TrackPosition& position); + virtual void applyTimeDelta(const LLSettingsBase::Seconds& delta) + { + llassert(false); + // your derived class needs to implement an override of this func + } + + virtual F64 setBlendFactor(const LLSettingsBase::BlendFactor& position); - virtual void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor& position) { /*NoOp*/ } + virtual void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) { /*NoOp*/ } protected: void triggerComplete(); @@ -359,9 +362,9 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender { public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds seconds) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds blend_span) : LLSettingsBlender(target, initsetting, endsetting), - mBlendSpan(seconds), + mBlendSpan(blend_span), mLastUpdate(0.0f), mTimeSpent(0.0f) { @@ -373,22 +376,22 @@ public: { } - virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) SETTINGS_OVERRIDE + virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::TrackPosition& blend_span) SETTINGS_OVERRIDE { - LLSettingsBlender::reset(initsetting, endsetting, span); + LLSettingsBlender::reset(initsetting, endsetting, blend_span); - mBlendSpan = span; + mBlendSpan = blend_span; mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; mTimeSpent = LLSettingsBase::Seconds(0.0); } - virtual void advance(const LLSettingsBase::Seconds& timedelta); + virtual void applyTimeDelta(const LLSettingsBase::Seconds& timedelta) SETTINGS_OVERRIDE; protected: LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const; - LLSettingsBase::Seconds mBlendSpan; + LLSettingsBase::TrackPosition mBlendSpan; LLSettingsBase::Seconds mLastUpdate; LLSettingsBase::Seconds mTimeSpent; LLSettingsBase::Seconds mTimeStart; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index cd2102a527..00391ca82d 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -51,7 +51,7 @@ namespace } else if (begin > end) { - return 1.0 - (begin - end); + return T(1.0) - (begin - end); } return 0; @@ -227,9 +227,8 @@ bool LLSettingsDay::initialize() LLSD curtrack = tracks[i]; for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { - LLSettingsBase::Seconds keyframe = LLSettingsBase::Seconds((*it)[SETTING_KEYKFRAME].asReal()); - // is this supposed to be a blend factor or a time value? - //keyframe = llclamp((F32)keyframe, 0.0f, 1.0f); + LLSettingsBase::TrackPosition keyframe = LLSettingsBase::TrackPosition((*it)[SETTING_KEYKFRAME].asReal()); + keyframe = llclamp(keyframe, 0.0f, 1.0f); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -262,10 +261,6 @@ bool LLSettingsDay::initialize() hassky |= true; mDayTracks[i][keyframe] = setting; } - else - { - LL_WARNS("SETTINGS", "DAYCYCLE") << "Skipping frame on track #" << i << " at time index " << keyframe << LL_ENDL; - } } } @@ -312,6 +307,7 @@ LLSD LLSettingsDay::defaults() dfltsetting[SETTING_FRAMES] = frames; dfltsetting[SETTING_TYPE] = "daycycle"; + return dfltsetting; } @@ -365,7 +361,7 @@ namespace continue; } - F32 frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); + LLSettingsBase::TrackPosition frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); if ((frame < 0.0) || (frame > 1.0)) { frame = llclamp(frame, 0.0f, 1.0f); @@ -483,8 +479,6 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track) //========================================================================= void LLSettingsDay::startDayCycle() { - LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); - if (!mInitialized) { LL_WARNS("DAYCYCLE") << "Attempt to start day cycle on uninitialized object." << LL_ENDL; @@ -519,7 +513,7 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) return keyframes; } -bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame) +bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPosition& old_frame, const LLSettingsBase::TrackPosition& new_frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -538,8 +532,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds { LLSettingsBase::ptr_t base = iter->second; track.erase(iter); - // why are we clamping a time value as if its a blend factor - //track[llclamp(new_frame, 0.0f, 1.0f)] = base; + track[llclamp(new_frame, 0.0f, 1.0f)] = base; track[new_frame] = base; return true; } @@ -548,7 +541,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds } -bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& frame) +bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPosition& frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -568,18 +561,18 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::Secon return false; } -void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe) +void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::TrackPosition& keyframe) { setSettingsAtKeyframe(water, keyframe, TRACK_WATER); } -LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const +LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::TrackPosition& keyframe) const { LLSettingsBase* p = getSettingsAtKeyframe(keyframe, TRACK_WATER).get(); return LLSettingsWater::ptr_t((LLSettingsWater*)p); } -void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track) +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::TrackPosition& keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { @@ -590,18 +583,18 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSe setSettingsAtKeyframe(sky, keyframe, track); } -LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const +LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const { if ((track < 1) || (track >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; return LLSettingsSky::ptr_t(); } - LLSettingsBase* p = getSettingsAtKeyframe(keyframe, track).get(); - return LLSettingsSky::ptr_t((LLSettingsSky*)p); + + return PTR_NAMESPACE::dynamic_pointer_cast(getSettingsAtKeyframe(keyframe, track)); } -void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track) +void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track) { if ((track < 0) || (track >= TRACK_MAX)) { @@ -609,12 +602,11 @@ void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, return; } - //mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; - mDayTracks[track][keyframe] = settings; + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; setDirtyFlag(true); } -LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const +LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const { if ((track < 0) || (track >= TRACK_MAX)) { diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 6f54833c74..6635bc0c5a 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -59,9 +59,9 @@ public: static const Seconds DEFAULT_DAYOFFSET; static const Seconds MAXIMUM_DAYOFFSET; - static const S32 TRACK_WATER; - static const S32 TRACK_MAX; - static const S32 FRAME_MAX; + static const S32 TRACK_WATER; + static const S32 TRACK_MAX; + static const S32 FRAME_MAX; typedef std::map CycleTrack_t; typedef std::vector CycleList_t; @@ -91,15 +91,15 @@ public: //--------------------------------------------------------------------- KeyframeList_t getTrackKeyframes(S32 track); - bool moveTrackKeyframe(S32 track, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame); - bool removeTrackKeyframe(S32 track, const LLSettingsBase::Seconds& frame); - - void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe); - LLSettingsWaterPtr_t getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const; - void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track); - LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const; - void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track); - LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const; + bool moveTrackKeyframe(S32 track, const LLSettingsBase::TrackPosition& old_frame, const LLSettingsBase::TrackPosition& new_frame); + bool removeTrackKeyframe(S32 track, const LLSettingsBase::TrackPosition& frame); + + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::TrackPosition& keyframe); + LLSettingsWaterPtr_t getWaterAtKeyframe(const LLSettingsBase::TrackPosition& keyframe) const; + void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, const LLSettingsBase::TrackPosition& keyframe, S32 track); + LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const; + void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track); + LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const; //--------------------------------------------------------------------- void startDayCycle(); diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 03e174b454..ba147baed7 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -165,7 +165,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsWater::ptr_t other((LLSettingsWater*)end.get()); + LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3f6241fa0b..cc9cd4fb86 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -121,6 +121,13 @@ namespace return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } + // Find normalized track position of given time along full length of cycle + inline LLSettingsBase::TrackPosition convert_time_to_position(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len) + { + LLSettingsBase::TrackPosition position = LLSettingsBase::TrackPosition(fmod((F64)time, (F64)len) / (F64)len); + return llclamp(position, 0.0f, 1.0f); + } + //--------------------------------------------------------------------- class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { @@ -143,8 +150,7 @@ namespace setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } - - void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor&) override + void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition&) override { S32 use_trackno = selectTrackNumber(trackno); @@ -160,7 +166,7 @@ namespace LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); - LLSettingsBase::TrackPosition targetpos = convertTimeToPosition(now) - (*bounds.first).first; + LLSettingsBase::TrackPosition targetpos = convert_time_to_position(now, mCycleLength) - (*bounds.first).first; LLSettingsBase::TrackPosition targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); @@ -191,8 +197,7 @@ namespace LLSettingsDay::TrackBound_t getBoundingEntries(LLSettingsBase::Seconds time) { LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); - F64 position = convertTimeToPosition(time); - + LLSettingsBase::TrackPosition position = convert_time_to_position(time, mCycleLength); LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); return bounds; } @@ -209,12 +214,6 @@ namespace return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } - LLSettingsBase::TrackPosition convertTimeToPosition(const LLSettingsBase::Seconds& time) - { - F64 position = fmod((F64)time, (F64)mCycleLength) / (F64)mCycleLength; - return llclamp(position, 0.0, 1.0); - } - private: LLSettingsDay::ptr_t mDay; S32 mTrackNo; @@ -764,7 +763,7 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); - mCurrentEnvironment->update(delta); + mCurrentEnvironment->applyTimeDelta(delta); // update clouds, sun, and general updateCloudScroll(); @@ -1640,20 +1639,15 @@ LLEnvironment::DayInstance::DayInstance() : mSkyTrack(1) { } -void LLEnvironment::DayInstance::update(LLSettingsBase::Seconds delta) +void LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& delta) { if (!mInitialized) initialize(); if (mBlenderSky) - mBlenderSky->update(delta.value()); + mBlenderSky->applyTimeDelta(delta); if (mBlenderWater) - mBlenderWater->update(delta.value()); - -// if (mSky) -// mSky->update(); -// if (mWater) -// mWater->update(); + mBlenderWater->applyTimeDelta(delta); } void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) @@ -1747,11 +1741,9 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky mBlenderWater = waterblend; } -F64 LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) +LLSettingsBase::TrackPosition LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { - F64 frame = static_cast(seconds.value() % mDayLength.value()) / static_cast(mDayLength.value()); - - return llclamp(frame, 0.0, 1.0); + return convert_time_to_position(seconds, mDayLength); } void LLEnvironment::DayInstance::animate() @@ -1814,10 +1806,10 @@ LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart } -void LLEnvironment::DayTransition::update(LLSettingsBase::Seconds delta) +void LLEnvironment::DayTransition::applyTimeDelta(const LLSettingsBase::Seconds& delta) { - mNextInstance->update(delta); - DayInstance::update(delta); + mNextInstance->applyTimeDelta(delta); + DayInstance::applyTimeDelta(delta); } void LLEnvironment::DayTransition::animate() @@ -1866,7 +1858,7 @@ LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::p LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSettingsBase::TrackPosition& position) { - mPosition = llclamp(position, 0.0, 1.0); + mPosition = llclamp(position, 0.0f, 1.0f); LLSettingsDay::TrackBound_t bounds = getBoundingEntries(mPosition); @@ -1883,7 +1875,7 @@ LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSet F64 spanPos = ((mPosition < (*bounds.first).first) ? (mPosition + 1.0) : mPosition) - (*bounds.first).first; F64 blendf = fmod(spanPos, spanLength) / spanLength; - return LLSettingsBlender::setPosition(blendf); + return LLSettingsBlender::setBlendFactor(blendf); } void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 1be846b710..b7a8ea84c4 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -262,7 +262,7 @@ private: DayInstance(); virtual ~DayInstance() { }; - virtual void update(LLSettingsBase::Seconds); + virtual void applyTimeDelta(const LLSettingsBase::Seconds& delta); void setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset); void setSky(const LLSettingsSky::ptr_t &psky); @@ -302,7 +302,7 @@ private: LLSettingsBlender::ptr_t mBlenderSky; LLSettingsBlender::ptr_t mBlenderWater; - F64 secondsToKeyframe(LLSettingsDay::Seconds seconds); + LLSettingsBase::TrackPosition secondsToKeyframe(LLSettingsDay::Seconds seconds); }; typedef std::array InstanceArray_t; @@ -313,7 +313,7 @@ private: DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, LLSettingsDay::Seconds time); virtual ~DayTransition() { }; - virtual void update(LLSettingsBase::Seconds); + virtual void applyTimeDelta(const LLSettingsBase::Seconds& delta); virtual void animate(); protected: @@ -410,7 +410,7 @@ class LLTrackBlenderLoopingManual : public LLSettingsBlender public: LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno); - F64 setPosition(const LLSettingsBase::TrackPosition& position) override; + F64 setPosition(const LLSettingsBase::TrackPosition& position); virtual void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) override; S32 getTrack() const { return mTrackNo; } -- cgit v1.3 From b06803225bff30e863ea18cae1d33f42a4fd937e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 4 Jun 2018 16:50:13 -0700 Subject: Reconnect apply to region and parcel reconnected to interface. --- indra/llinventory/llsettingsdaycycle.cpp | 12 ++ indra/llinventory/llsettingsdaycycle.h | 1 + indra/newview/llenvironment.cpp | 146 ++++++++++++++++++++- indra/newview/llenvironment.h | 13 ++ indra/newview/llfloatereditextdaycycle.cpp | 36 +++-- indra/newview/llfloaterfixedenvironment.cpp | 39 ++++-- indra/newview/llinventorybridge.cpp | 48 ++++--- indra/newview/llinventorybridge.h | 8 +- .../newview/skins/default/xui/en/notifications.xml | 27 ++++ 9 files changed, 285 insertions(+), 45 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index e67da95a6c..60e962b612 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -614,6 +614,18 @@ LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 tra return LLSettingsBase::ptr_t(); } +void LLSettingsDay::clearTrack(S32 track) +{ + if ((track < 0) || (track >= TRACK_MAX)) + { + LL_WARNS("DAYCYCLE") << "Attempt to clear track (#" << track << ") out of range!" << LL_ENDL; + return; + } + + mDayTracks[track].clear(); +} + + F32 LLSettingsDay::getUpperBoundFrame(S32 track, F32 keyframe) { return get_wrapping_atafter(mDayTracks[track], keyframe)->first; diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 101cacc3a2..6fb48225c7 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -98,6 +98,7 @@ public: LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track) const; void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track); LLSettingsBase::ptr_t getSettingsAtKeyframe(F32 keyframe, S32 track) const; + void clearTrack(S32 track); //--------------------------------------------------------------------- void startDayCycle(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 228a396c0d..21c38302d1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -318,6 +318,27 @@ bool LLEnvironment::canEdit() const return true; } +bool LLEnvironment::canAgentUpdateParcelEnvironment(bool useselected) const +{ + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + return false; + // *TODO* + //LLParcel* parcel = (useselected) ? LLViewerParcelMgr::instance().getParcelSelection() : LLViewerParcelMgr::instance().getAgentParcel(); + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (parcel) + { + return parcel->allowTerraformBy(gAgent.getID()); + } + + return false; +} + +bool LLEnvironment::canAgentUpdateRegionEnvironment() const +{ + return gAgent.getRegion()->canManageEstate(); +} + + bool LLEnvironment::isExtendedEnvironmentEnabled() const { return !gAgent.getRegionCapability("ExtEnvironment").empty(); @@ -1011,7 +1032,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); } - /*TODO: track_altitudes*/ updateEnvironment(); } @@ -1038,6 +1058,29 @@ void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset); } +void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset) +{ + if (!isExtendedEnvironmentEnabled()) + { + LL_WARNS("ENVIRONMENT") << "attempt to apply asset id to region not supporting it." << LL_ENDL; + LLNotificationsUtil::add("NoEnvironmentSettings"); + return; + } + + updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset); +} + +void LLEnvironment::updateRegion(LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +{ + updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset); +} + +void LLEnvironment::updateRegion(LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +{ + updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset); +} + + void LLEnvironment::resetRegion() { resetParcel(INVALID_PARCEL_ID); @@ -1051,6 +1094,52 @@ void LLEnvironment::requestParcel(S32 parcel_id) [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); } +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) +{ + LLSettingsVOBase::getSettingsAsset(asset_id, + [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); +} + +void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) +{ + if (status) + { + LL_WARNS("ENVIRONMENT") << "Unable to get settings asset with id " << asset_id << "!" << LL_ENDL; + LLNotificationsUtil::add("FailedToLoadSettingsApply"); + return; + } + + LLSettingsDay::ptr_t pday; + + if (settings->getSettingType() == "daycycle") + pday = std::static_pointer_cast(settings); + else + { + pday = createDayCycleFromEnvironment( (parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, settings); + } + + if (!pday) + { + LL_WARNS("ENVIRONMENT") << "Unable to construct day around " << asset_id << "!" << LL_ENDL; + LLNotificationsUtil::add("FailedToBuildSettingsDay"); + return; + } + + updateParcel(parcel_id, pday, day_length, day_offset); +} + +void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +{ + LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); + updateParcel(parcel_id, pday, day_length, day_offset); +} + +void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +{ + LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); + updateParcel(parcel_id, pday, day_length, day_offset); +} + void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { std::string coroname = @@ -1136,6 +1225,20 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd if (url.empty()) return; + if (day_length < 1) + { + day_length = getEnvironmentDayLength((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); + if ((day_length < 1) && (parcel_id != INVALID_PARCEL_ID)) + day_length = getEnvironmentDayLength(ENV_REGION).value(); + } + + if (day_offset < 1) + { + day_offset = getEnvironmentDayOffset((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); + if ((day_offset < 1) && (parcel_id != INVALID_PARCEL_ID)) + day_offset = getEnvironmentDayOffset(ENV_REGION).value(); + } + LLSD body(LLSD::emptyMap()); body["environment"] = LLSD::emptyMap(); @@ -1366,6 +1469,47 @@ LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::st return day; } +LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromEnvironment(EnvSelection_t env, LLSettingsBase::ptr_t settings) +{ + std::string type(settings->getSettingType()); + + if (type == "daycycle") + return std::static_pointer_cast(settings); + + if ((env != ENV_PARCEL) && (env != ENV_REGION)) + { + LL_WARNS("ENVIRONMENT") << "May only create from parcel or region environment." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t day = this->getEnvironmentDay(env); + if (!day && (env == ENV_PARCEL)) + { + day = this->getEnvironmentDay(ENV_REGION); + } + + if (!day) + { + LL_WARNS("ENVIRONMENT") << "Could not retrieve existing day settings." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + day = day->buildClone(); + + if (type == "sky") + { + for (S32 idx = 1; idx < LLSettingsDay::TRACK_MAX; ++idx) + day->clearTrack(idx); + day->setSettingsAtKeyframe(settings, 0.0f, 1); + } + else if (type == "water") + { + day->clearTrack(LLSettingsDay::TRACK_WATER); + day->setSettingsAtKeyframe(settings, 0.0f, LLSettingsDay::TRACK_WATER); + } + + return day; +} void LLEnvironment::legacyLoadAllPresets() { diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 7c8304a7ed..6382e0afd4 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -148,6 +148,8 @@ public: bool canEdit() const; bool isExtendedEnvironmentEnabled() const; bool isInventoryEnabled() const; + bool canAgentUpdateParcelEnvironment(bool useselected = false) const; + bool canAgentUpdateRegionEnvironment() const; LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); } LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); } @@ -211,6 +213,9 @@ public: static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename); static LLSettingsDay::ptr_t createDayCycleFromLegacyPreset(const std::string filename); + // Construct a new day cycle based on the environment. Replacing either the water or the sky tracks. + LLSettingsDay::ptr_t createDayCycleFromEnvironment(EnvSelection_t env, LLSettingsBase::ptr_t settings); + //------------------------------------------- connection_t setSkyListChange(const change_signal_t::slot_type& cb); connection_t setWaterListChange(const change_signal_t::slot_type& cb); @@ -221,10 +226,16 @@ public: void onLegacyRegionSettings(LLSD data); void requestRegion(); + void updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset); void updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void updateRegion(LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); + void updateRegion(LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); void resetRegion(); void requestParcel(S32 parcel_id); + void updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset); void updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void updateParcel(S32 parcel_id, LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); + void updateParcel(S32 parcel_id, LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); void resetParcel(S32 parcel_id); void selectAgentEnvironment(); @@ -390,6 +401,8 @@ private: void onAgentPositionHasChanged(const LLVector3 &localpos); void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); + void onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset); + //========================================================================= void legacyLoadAllPresets(); static std::string getSysDir(const std::string &subdir); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 4703a1ec16..a9f0cffef1 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -267,7 +267,8 @@ void LLFloaterEditExtDayCycle::refresh() mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail); mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, is_inventory_avail); - + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_PARCEL, canApplyParcel()); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_REGION, canApplyRegion()); LLFloater::refresh(); } @@ -950,26 +951,35 @@ void LLFloaterEditExtDayCycle::doApplyUpdateInventory() void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where) { - LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT); - bool updateSimulator(where != ACTION_APPLY_LOCAL); - if (where == ACTION_APPLY_LOCAL) - env = LLEnvironment::ENV_LOCAL; + { + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditDay); + } else if (where == ACTION_APPLY_PARCEL) - env = LLEnvironment::ENV_PARCEL; + { + LLParcelSelectionHandle handle(LLViewerParcelMgr::instance().getParcelSelection()); + LLParcel *parcel(nullptr); + + if (handle) + parcel = handle->getParcel(); + if (!parcel) + parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (!parcel) + return; + + LLEnvironment::instance().updateParcel(parcel->getLocalID(), mEditDay, -1, -1); + } else if (where == ACTION_APPLY_REGION) - env = LLEnvironment::ENV_REGION; + { + LLEnvironment::instance().updateRegion(mEditDay, -1, -1); + } else { LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; return; } - LLEnvironment::instance().setEnvironment(env, mEditDay); - if (updateSimulator) - { - LL_WARNS("ENVIRONMENT") << "Attempting apply" << LL_ENDL; - } } void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) @@ -1038,7 +1048,7 @@ bool LLFloaterEditExtDayCycle::canApplyParcel() const if (!parcel) return false; - return parcel->allowModifyBy(gAgent.getID(), gAgent.getGroupID()) && + return parcel->allowTerraformBy(gAgent.getID()) && LLEnvironment::instance().isExtendedEnvironmentEnabled(); } diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 6c1080294d..e7b8481caa 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -160,6 +160,8 @@ void LLFloaterFixedEnvironment::refresh() mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail); mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, is_inventory_avail); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_PARCEL, canApplyParcel()); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_REGION, canApplyRegion()); mTxtName->setValue(mSettings->getName()); @@ -283,26 +285,41 @@ void LLFloaterFixedEnvironment::doApplyUpdateInventory() void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where) { - LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT); - bool updateSimulator( where != ACTION_APPLY_LOCAL ); - if (where == ACTION_APPLY_LOCAL) - env = LLEnvironment::ENV_LOCAL; + { + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mSettings); + } else if (where == ACTION_APPLY_PARCEL) - env = LLEnvironment::ENV_PARCEL; + { + LLParcelSelectionHandle handle(LLViewerParcelMgr::instance().getParcelSelection()); + LLParcel *parcel(nullptr); + + if (handle) + parcel = handle->getParcel(); + if (!parcel) + parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (!parcel) + return; + + if (mSettings->getSettingType() == "sky") + LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast(mSettings), -1, -1); + else if (mSettings->getSettingType() == "water") + LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast(mSettings), -1, -1); + } else if (where == ACTION_APPLY_REGION) - env = LLEnvironment::ENV_REGION; + { + if (mSettings->getSettingType() == "sky") + LLEnvironment::instance().updateRegion(std::static_pointer_cast(mSettings), -1, -1); + else if (mSettings->getSettingType() == "water") + LLEnvironment::instance().updateRegion(std::static_pointer_cast(mSettings), -1, -1); + } else { LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; return; } - LLEnvironment::instance().setEnvironment(env, mSettings); - if (updateSimulator) - { - LL_WARNS("ENVIRONMENT") << "Attempting apply" << LL_ENDL; - } } void LLFloaterFixedEnvironment::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index fe7d302992..58f6c2065b 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -81,6 +81,8 @@ #include "llwearableitemslist.h" #include "lllandmarkactions.h" #include "llpanellandmarks.h" +#include "llviewerparcelmgr.h" +#include "llparcel.h" #include "llenvironment.h" @@ -6920,11 +6922,16 @@ void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action if (!item) return; LLUUID asset_id = item->getProtectedAssetUUID(); - // *LAPRAS* TODO update on simulator. - LL_WARNS("LAPRAS") << "Only updating locally!!! NOT REALLY PARCEL UPDATE" << LL_ENDL; - LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_PARCEL, asset_id); - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (!parcel) + { + LL_WARNS("INVENTORY") << "could not identify parcel." << LL_ENDL; + return; + } + S32 parcel_id = parcel->getLocalID(); + + LLEnvironment::instance().updateParcel(parcel_id, asset_id, -1, -1); } else if ("apply_settings_region" == action) { @@ -6933,11 +6940,8 @@ void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action if (!item) return; LLUUID asset_id = item->getProtectedAssetUUID(); - // *LAPRAS* TODO update on simulator. - LL_WARNS("LAPRAS") << "Only updating locally!!! NOT REALLY REGION UPDATE" << LL_ENDL; - LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, asset_id); - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + + LLEnvironment::instance().updateRegion(asset_id, -1, -1); } else LLItemBridge::performAction(model, action); @@ -6988,24 +6992,34 @@ void LLSettingsBridge::buildContextMenu(LLMenuGL& menu, U32 flags) items.push_back("Settings Apply Local"); items.push_back("Settings Apply Parcel"); - // *LAPRAS* TODO: test for permission - + if (!canUpdateParcel()) + disabled_items.push_back("Settings Apply Parcel"); + items.push_back("Settings Apply Region"); - // *LAPRAS* TODO: test for permission + if (!canUpdateRegion()) + disabled_items.push_back("Settings Apply Region"); } addLinkReplaceMenuOption(items, disabled_items); hide_context_entries(menu, items, disabled_items); } -std::string LLSettingsBridge::getLabelSuffix() const -{ - return LLItemBridge::getLabelSuffix(); -} BOOL LLSettingsBridge::renameItem(const std::string& new_name) { + /*TODO: change internal settings name? */ return LLItemBridge::renameItem(new_name); } +bool LLSettingsBridge::canUpdateParcel() const +{ + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); +} + +bool LLSettingsBridge::canUpdateRegion() const +{ + return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); +} + + // +=================================================+ // | LLLinkBridge | // +=================================================+ diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index e7df5e4e93..6a04f08cf8 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -622,13 +622,15 @@ public: virtual void performAction(LLInventoryModel* model, std::string action); virtual void openItem(); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); - virtual std::string getLabelSuffix() const; - virtual BOOL renameItem(const std::string& new_name); + virtual BOOL renameItem(const std::string& new_name); virtual LLSettingsType::type_e getSettingsType() const { return mSettingsType; } - protected: + bool canUpdateRegion() const; + bool canUpdateParcel() const; + LLSettingsType::type_e mSettingsType; + }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index d7193c511f..756b711c4c 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11113,4 +11113,31 @@ Failed to find the settisgs named [DESC] in database. fail + +Unable to apply those settings to the environment. + fail + + + +Unable to apply those settings to the environment. + fail + + + +This Region does not support environmental settings. + fail + + -- cgit v1.3 From 499993e3aa89f49412861a6b7daff8e0e6f1c196 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 5 Jun 2018 17:29:58 +0100 Subject: Restore dropped header include and make constness match sim code. --- indra/llinventory/llsettingsbase.h | 2 +- indra/newview/llenvironment.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 374a2ec246..0920af4726 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -362,7 +362,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender { public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds blend_span) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& blend_span) : LLSettingsBlender(target, initsetting, endsetting), mBlendSpan(blend_span), mLastUpdate(0.0f), diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index d79a1b408a..66950b0625 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -36,6 +36,8 @@ #include "llsettingswater.h" #include "llsettingsdaycycle.h" +#include "llatmosphere.h" + #include //------------------------------------------------------------------------- -- cgit v1.3 From 6ea2847b58164f0ea315f7b2b9c34e663a07e60e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 5 Jun 2018 17:58:09 +0100 Subject: Fix uninit data from deleting c++11-style init and not putting it in the ctor. Replace dynamic_pointer_cast so instance isn't accidentally deleted on func exit. --- indra/llinventory/llsettingssky.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 95502f47c3..a6f0d06e7d 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -364,7 +364,9 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) : LLSettingsBase(data), mNextSunTextureId(), mNextMoonTextureId(), - mNextCloudTextureId() + mNextCloudTextureId(), + mPositionsDirty(true), + mLightingDirty(true) { } @@ -372,13 +374,15 @@ LLSettingsSky::LLSettingsSky(): LLSettingsBase(), mNextSunTextureId(), mNextMoonTextureId(), - mNextCloudTextureId() + mNextCloudTextureId(), + mPositionsDirty(true), + mLightingDirty(true) { } void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsSky::ptr_t other((LLSettingsSky*)end.get()); + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); -- cgit v1.3 From 610a793aa8fb9f918fc25eeab02b7415ac18b33b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 5 Jun 2018 11:19:22 -0700 Subject: EOL in llsetingssky.cpp and llrender.cpp. const on ptr_t & in llenvironment --- indra/llinventory/llsettingssky.cpp | 2 +- indra/llrender/llrender.cpp | 2 +- indra/newview/llenvironment.cpp | 12 ++++++------ indra/newview/llenvironment.h | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index a6f0d06e7d..263e721d00 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1052,4 +1052,4 @@ void LLSettingsSky::calculateLightSettings() const LLUUID LLSettingsSky::GetDefaultAssetId() { return DEFAULT_ASSET_ID; -} \ No newline at end of file +} diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5e16aded30..c42d2799d7 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -2436,4 +2436,4 @@ glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up) -f[0], -f[1], -f[2], 0, 0, 0, 0, 1); -} \ No newline at end of file +} diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 097b229587..02d79b2bae 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1134,7 +1134,7 @@ void LLEnvironment::requestRegion() requestParcel(INVALID_PARCEL_ID); } -void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { if (!isExtendedEnvironmentEnabled()) { @@ -1157,12 +1157,12 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset); } -void LLEnvironment::updateRegion(LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) { updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset); } -void LLEnvironment::updateRegion(LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) { updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset); } @@ -1215,19 +1215,19 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 66950b0625..8202564ce7 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -239,15 +239,15 @@ public: void requestRegion(); void updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset); - void updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); - void updateRegion(LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); - void updateRegion(LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); + void updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); + void updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); void resetRegion(); void requestParcel(S32 parcel_id); void updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset); - void updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); - void updateParcel(S32 parcel_id, LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); - void updateParcel(S32 parcel_id, LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); + void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); + void updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); + void updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); void resetParcel(S32 parcel_id); void selectAgentEnvironment(); -- cgit v1.3 From caa5bd3cb9f22a42de9fc1f37bb98b17e2405b5b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 6 Jun 2018 19:48:12 +0100 Subject: Fix legacy haze validation returning warnings as errors. Add assert that calculated spans are > 0 to avoid div by 0 NaNs. Make span calc return 1.0 for case where begin == end. Fix order of ops in LLTrackBlenderLoopingTime ctor causing skies to be init'd with water instances. --- indra/llinventory/llsettingssky.cpp | 2 +- indra/newview/llenvironment.cpp | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 263e721d00..4763215cff 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -226,7 +226,7 @@ bool validateLegacyHaze(LLSD &value) } if (result["warnings"].size() > 0) { - LL_WARNS("SETTINGS") << "Legacy Haze Config Validation warnings: " << result["errors"] << LL_ENDL; + LL_WARNS("SETTINGS") << "Legacy Haze Config Validation warnings: " << result["warnings"] << LL_ENDL; return false; } return true; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 02d79b2bae..5b184d8c25 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -77,7 +77,7 @@ namespace return LLSettingsBase::TrackPosition(1.0) - (begin - end); } - return 0; + return 1.0f; } LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) @@ -139,14 +139,15 @@ namespace mCycleLength(cyclelength), mCycleOffset(cycleoffset) { + // must happen prior to getBoundingEntries call... + mTrackNo = selectTrackNumber(trackno); + LLSettingsDay::TrackBound_t initial = getBoundingEntries(getAdjustedNow()); mInitial = (*initial.first).second; mFinal = (*initial.second).second; mBlendSpan = getSpanTime(initial); - mTrackNo = selectTrackNumber(trackno); - setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } @@ -211,7 +212,9 @@ namespace LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const { - return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + LLSettingsBase::Seconds span = mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + llassert(span > 0.01f); + return span; } private: @@ -1905,11 +1908,6 @@ void LLEnvironment::DayInstance::animate() mWater.reset(); mBlenderWater.reset(); } -// else if (wtrack.size() == 1) -// { -// mWater = std::static_pointer_cast((*(wtrack.begin())).second); -// mBlenderWater.reset(); -// } else { mWater = LLSettingsVOWater::buildDefaultWater(); @@ -1924,11 +1922,6 @@ void LLEnvironment::DayInstance::animate() mSky.reset(); mBlenderSky.reset(); } -// else if (track.size() == 1) -// { -// mSky = std::static_pointer_cast((*(track.begin())).second); -// mBlenderSky.reset(); -// } else { mSky = LLSettingsVOSky::buildDefaultSky(); -- cgit v1.3 From bff5049b9262e703c3ae583962552ea416212e8b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 6 Jun 2018 17:10:58 -0700 Subject: Various editor fixes. Start adding a settings picker. --- indra/llinventory/llsettingsbase.cpp | 2 + indra/llinventory/llsettingsbase.h | 1 + indra/llinventory/llsettingsdaycycle.cpp | 39 ++ indra/llinventory/llsettingsdaycycle.h | 1 + indra/newview/llfloatereditextdaycycle.cpp | 292 ++++++------ indra/newview/llfloatereditextdaycycle.h | 55 +-- indra/newview/llviewerfloaterreg.cpp | 3 + .../default/xui/en/floater_edit_ext_day_cycle.xml | 528 +++++++++++---------- .../default/xui/en/floater_settings_picker.xml | 11 + 9 files changed, 516 insertions(+), 416 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/floater_settings_picker.xml (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 76b1e0b2a6..b677eb36df 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -38,6 +38,8 @@ namespace const LLSettingsBase::TrackPosition BREAK_POINT = 0.5; } +const LLSettingsBase::TrackPosition LLSettingsBase::INVALID_TRACKPOS(-1.0); + //========================================================================= std::ostream &operator <<(std::ostream& os, LLSettingsBase &settings) { diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 0920af4726..4ebec4a99d 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -61,6 +61,7 @@ public: typedef F64Seconds Seconds; typedef F64 BlendFactor; typedef F32 TrackPosition; // 32-bit as these are stored in LLSD as such + static const TrackPosition INVALID_TRACKPOS; static const std::string SETTING_ID; static const std::string SETTING_NAME; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index e000b8f03f..807d8218a1 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -530,6 +530,14 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPo CycleTrack_t::iterator iter = track.find(old_frame); if (iter != track.end()) { + /*TODO check that we are not moving too close to another keyframe */ +// CycleTrack_t::value_type existing = getSettingsNearKeyfarme(new_frame, trackno, 2.5f); +// if ((*iter).first != existing.first) +// { +// LL_WARNS("DAYCYCLE") << "Track too close to existing track. Not moving." << LL_ENDL; +// return false; +// } + LLSettingsBase::ptr_t base = iter->second; track.erase(iter); track[llclamp(new_frame, 0.0f, 1.0f)] = base; @@ -624,6 +632,37 @@ LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase: return LLSettingsBase::ptr_t(); } +LLSettingsDay::CycleTrack_t::value_type LLSettingsDay::getSettingsNearKeyfarme(const LLSettingsBase::TrackPosition &keyframe, S32 track, F32 fudge) const +{ + if ((track < 0) || (track >= TRACK_MAX)) + { + LL_WARNS("DAYCYCLE") << "Attempt to get track (#" << track << ") out of range!" << LL_ENDL; + return CycleTrack_t::value_type(TrackPosition(INVALID_TRACKPOS), LLSettingsBase::ptr_t()); + } + + if (mDayTracks[track].empty()) + { + LL_INFOS("DAYCYCLE") << "Empty track" << LL_ENDL; + return CycleTrack_t::value_type(TrackPosition(INVALID_TRACKPOS), LLSettingsBase::ptr_t()); + } + + TrackPosition startframe(keyframe - fudge); + if (startframe < 0.0f) + startframe = 1.0f + startframe; + + CycleTrack_t::iterator it = get_wrapping_atafter(const_cast(mDayTracks[track]), startframe); + + F32 dist = get_wrapping_distance(startframe, (*it).first); + + LL_WARNS("LAPRAS") << "[" << startframe << " ... " << keyframe << " -> " << (*it).first << "@" << dist << LL_ENDL; + + + if (dist <= (fudge * 2.0f)) + return (*it); + + return CycleTrack_t::value_type(TrackPosition(INVALID_TRACKPOS), LLSettingsBase::ptr_t()); +} + void LLSettingsDay::clearTrack(S32 track) { if ((track < 0) || (track >= TRACK_MAX)) diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index cc6e27b296..5aa6e91183 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -100,6 +100,7 @@ public: LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const; void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track); LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const; + CycleTrack_t::value_type getSettingsNearKeyfarme(const LLSettingsBase::TrackPosition &keyframe, S32 track, F32 fudge) const; void clearTrack(S32 track); //--------------------------------------------------------------------- diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 34e49c73d0..506e03fddc 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -68,6 +68,31 @@ namespace { "sky4_track", }; + const std::string ICN_LOCK_EDIT("icn_lock_edit"); + const std::string BTN_SAVE("save_btn"); + const std::string BTN_FLYOUT("btn_flyout"); + const std::string BTN_CANCEL("cancel_btn"); + const std::string BTN_ADDFRAME("add_frame"); + const std::string BTN_DELFRAME("delete_frame"); + const std::string BTN_IMPORT("btn_import"); + const std::string BTN_LOADFRAME("btn_load_frame"); + const std::string SLDR_TIME("WLTimeSlider"); + const std::string SLDR_KEYFRAMES("WLDayCycleFrames"); + const std::string VIEW_SKY_SETTINGS("frame_settings_sky"); + const std::string VIEW_WATER_SETTINGS("frame_settings_water"); + const std::string LBL_CURRENT_TIME("current_time"); + const std::string TXT_DAY_NAME("day_cycle_name"); + const std::string TABS_SKYS("sky_tabs"); + const std::string TABS_WATER("water_tabs"); + + const std::string EVNT_DAYTRACK("DayCycle.Track"); + const std::string EVNT_PLAY("DayCycle.PlayActions"); + + const std::string ACTION_PLAY("play"); + const std::string ACTION_PAUSE("pause"); + const std::string ACTION_FORWARD("forward"); + const std::string ACTION_BACK("back"); + // For flyout const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml"); // From menu_save_settings.xml, consider moving into flyout since it should be supported by flyout either way @@ -90,16 +115,16 @@ const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length"); //========================================================================= LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) : LLFloater(key), - mFlyoutControl(NULL), - mCancelButton(NULL), + mFlyoutControl(nullptr), mDayLength(0), mCurrentTrack(4), - mTimeSlider(NULL), - mFramesSlider(NULL), - mCurrentTimeLabel(NULL), + mTimeSlider(nullptr), + mFramesSlider(nullptr), + mCurrentTimeLabel(nullptr), mImportButton(nullptr), mInventoryId(), mInventoryItem(nullptr), + mLoadFrame(nullptr), mSkyBlender(), mWaterBlender(), mScratchSky(), @@ -107,8 +132,8 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) : mIsPlaying(false) { - mCommitCallbackRegistrar.add("DayCycle.Track", [this](LLUICtrl *ctrl, const LLSD &data) { onTrackSelectionCallback(data); }); - mCommitCallbackRegistrar.add("DayCycle.PlayActions", [this](LLUICtrl *ctrl, const LLSD &data) { onPlayActionCallback(data); }); + mCommitCallbackRegistrar.add(EVNT_DAYTRACK, [this](LLUICtrl *ctrl, const LLSD &data) { onTrackSelectionCallback(data); }); + mCommitCallbackRegistrar.add(EVNT_PLAY, [this](LLUICtrl *ctrl, const LLSD &data) { onPlayActionCallback(data); }); mScratchSky = LLSettingsVOSky::buildDefaultSky(); mScratchWater = LLSettingsVOWater::buildDefaultWater(); @@ -124,26 +149,27 @@ LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle() // virtual BOOL LLFloaterEditExtDayCycle::postBuild() { - getChild("day_cycle_name")->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL); - - mCancelButton = getChild("cancel_btn", true); - mAddFrameButton = getChild("add_frame", true); - mDeleteFrameButton = getChild("delete_frame", true); - mTimeSlider = getChild("WLTimeSlider"); - mFramesSlider = getChild("WLDayCycleFrames"); - mSkyTabLayoutContainer = getChild("frame_settings_sky", true); - mWaterTabLayoutContainer = getChild("frame_settings_water", true); - mCurrentTimeLabel = getChild("current_time", true); - mImportButton = getChild("btn_import", true); - - mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE); + getChild(TXT_DAY_NAME)->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL); + + mAddFrameButton = getChild(BTN_ADDFRAME, true); + mDeleteFrameButton = getChild(BTN_DELFRAME, true); + mTimeSlider = getChild(SLDR_TIME); + mFramesSlider = getChild(SLDR_KEYFRAMES); + mSkyTabLayoutContainer = getChild(VIEW_SKY_SETTINGS, true); + mWaterTabLayoutContainer = getChild(VIEW_WATER_SETTINGS, true); + mCurrentTimeLabel = getChild(LBL_CURRENT_TIME, true); + mImportButton = getChild(BTN_IMPORT, true); + mLoadFrame = getChild(BTN_LOADFRAME, true); + + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BTN_SAVE, BTN_FLYOUT, XML_FLYOUTMENU_FILE); mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); - mCancelButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onBtnCancel(); }); + getChild(BTN_CANCEL, true)->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onBtnCancel(); }); mTimeSlider->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onTimeSliderMoved(); }); mAddFrameButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onAddTrack(); }); mDeleteFrameButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onRemoveTrack(); }); mImportButton->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonImport(); }); + mLoadFrame->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonLoadFrame(); }); mFramesSlider->setCommitCallback([this](LLUICtrl *, const LLSD &data) { onFrameSliderCallback(data); }); mFramesSlider->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderDoubleClick(x, y, mask); }); @@ -162,7 +188,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); LLEnvironment::instance().updateEnvironment(); - mEditingEnv = LLEnvironment::ENV_NONE; mEditDay.reset(); if (key.has(KEY_INVENTORY_ID)) { @@ -259,7 +284,7 @@ void LLFloaterEditExtDayCycle::refresh() { if (mEditDay) { - LLLineEditor* name_field = getChild("day_cycle_name"); + LLLineEditor* name_field = getChild(TXT_DAY_NAME); name_field->setText(mEditDay->getName()); } @@ -308,29 +333,35 @@ void LLFloaterEditExtDayCycle::onButtonImport() doImportFromDisk(); } +void LLFloaterEditExtDayCycle::onButtonLoadFrame() +{ + +} + void LLFloaterEditExtDayCycle::onAddTrack() { // todo: 2.5% safety zone std::string sldr_key = mFramesSlider->getCurSlider(); LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); LLSettingsBase::ptr_t setting; - if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack) != nullptr) + if ((mEditDay->getSettingsNearKeyfarme(frame, mCurrentTrack, FRAME_SLOP_FACTOR)).second) { + LL_WARNS("SETTINGS") << "Attempt to add new frame too close to existing frame." << LL_ENDL; return; } if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { // scratch water should always have the current water settings. - setting = mScratchWater->buildClone(); - LLSettingsWater::ptr_t water((LLSettingsWater*)setting.get()); - mEditDay->setWaterAtKeyframe(water, frame); + LLSettingsWater::ptr_t water(mScratchWater->buildClone()); + setting = water; + mEditDay->setWaterAtKeyframe( std::static_pointer_cast(setting), frame); } else { // scratch sky should always have the current sky settings. - setting = mScratchSky->buildClone(); - LLSettingsSky::ptr_t sky((LLSettingsSky*)setting.get()); + LLSettingsSky::ptr_t sky(mScratchSky->buildClone()); + setting = sky; mEditDay->setSkyAtKeyframe(sky, frame, mCurrentTrack); } @@ -364,22 +395,22 @@ void LLFloaterEditExtDayCycle::onPlayActionCallback(const LLSD& user_data) { std::string action = user_data.asString(); F32 frame = mTimeSlider->getCurSliderValue(); - if (action == "play") + if (action == ACTION_PLAY) { startPlay(); } - else if (action == "pause") + else if (action == ACTION_PAUSE) { stopPlay(); } else if (mSliderKeyMap.size() != 0) { F32 new_frame = 0; - if (action == "forward") + if (action == ACTION_FORWARD) { new_frame = mEditDay->getUpperBoundFrame(mCurrentTrack, frame); } - else if (action == "back") + else if (action == ACTION_BACK) { new_frame = mEditDay->getLowerBoundFrame(mCurrentTrack, frame - (mTimeSlider->getIncrement() / 2)); } @@ -397,6 +428,7 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) LL_WARNS("LAPRAS") << "Current slider set to \"" << curslider << "\"" << LL_ENDL; F32 sliderpos(0.0); + if (curslider.empty()) { S32 x(0), y(0); @@ -407,78 +439,55 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) else { sliderpos = mFramesSlider->getCurSliderValue(); + + keymap_t::iterator it = mSliderKeyMap.find(curslider); + if (it != mSliderKeyMap.end()) + { + // if (gKeyboard->currentMask(TRUE) == MASK_SHIFT) + // { + // LL_DEBUGS() << "Copying frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL; + // LLSettingsBase::ptr_t new_settings; + // + // // mEditDay still remembers old position, add copy at new position + // if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + // { + // LLSettingsWaterPtr_t water_ptr = std::dynamic_pointer_cast(iter->second.pSettings)->buildClone(); + // mEditDay->setWaterAtKeyframe(water_ptr, new_frame); + // new_settings = water_ptr; + // } + // else + // { + // LLSettingsSkyPtr_t sky_ptr = std::dynamic_pointer_cast(iter->second.pSettings)->buildClone(); + // mEditDay->setSkyAtKeyframe(sky_ptr, new_frame, mCurrentTrack); + // new_settings = sky_ptr; + // } + // + // // mSliderKeyMap still remembers old position, for simplicity, just move it to be identical to slider + // F32 old_frame = iter->second.mFrame; + // iter->second.mFrame = new_frame; + // // slider already moved old frame, create new one in old place + // addSliderFrame(old_frame, new_settings, false /*because we are going to reselect new one*/); + // // reselect new frame + // mFramesSlider->setCurSlider(iter->first); + // } + // else + // { + LL_WARNS("LAPRAS") << "Moving frame from " << (*it).second.mFrame << " to " << sliderpos << LL_ENDL; + if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos)) + { + (*it).second.mFrame = sliderpos; + } + else + { + mFramesSlider->setCurSliderValue((*it).second.mFrame); + } + } + } + + mTimeSlider->setCurSliderValue(sliderpos); -// if (mSliderKeyMap.size() == 0) -// { -// mLastFrameSlider.clear(); -// return; -// } -// // make sure we have a slider -// const std::string& cur_sldr = mFramesSlider->getCurSlider(); -// if (cur_sldr.empty()) -// { -// mLastFrameSlider.clear(); -// return; -// } -// -// F32 new_frame = mFramesSlider->getCurSliderValue(); -// // todo: add safety 2.5% checks -// keymap_t::iterator iter = mSliderKeyMap.find(cur_sldr); -// if (iter != mSliderKeyMap.end() && mEditDay->getSettingsAtKeyframe(new_frame, mCurrentTrack).get() == NULL) -// { -// if (gKeyboard->currentMask(TRUE) == MASK_SHIFT) -// { -// LL_DEBUGS() << "Copying frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL; -// LLSettingsBase::ptr_t new_settings; -// -// // mEditDay still remembers old position, add copy at new position -// if (mCurrentTrack == LLSettingsDay::TRACK_WATER) -// { -// LLSettingsWaterPtr_t water_ptr = std::dynamic_pointer_cast(iter->second.pSettings)->buildClone(); -// mEditDay->setWaterAtKeyframe(water_ptr, new_frame); -// new_settings = water_ptr; -// } -// else -// { -// LLSettingsSkyPtr_t sky_ptr = std::dynamic_pointer_cast(iter->second.pSettings)->buildClone(); -// mEditDay->setSkyAtKeyframe(sky_ptr, new_frame, mCurrentTrack); -// new_settings = sky_ptr; -// } -// -// // mSliderKeyMap still remembers old position, for simplicity, just move it to be identical to slider -// F32 old_frame = iter->second.mFrame; -// iter->second.mFrame = new_frame; -// // slider already moved old frame, create new one in old place -// addSliderFrame(old_frame, new_settings, false /*because we are going to reselect new one*/); -// // reselect new frame -// mFramesSlider->setCurSlider(iter->first); -// } -// else -// { -// LL_DEBUGS() << "Moving frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL; -// if (mEditDay->moveTrackKeyframe(mCurrentTrack, iter->second.mFrame, new_frame)) -// { -// iter->second.mFrame = new_frame; -// } -// } -// } -// -// mTimeSlider->setCurSliderValue(new_frame); -// -// if (mLastFrameSlider != cur_sldr) -// { -// // technically should not be possible for both frame and slider to change -// // but for safety, assume that they can change independently and both -// mLastFrameSlider = cur_sldr; -// updateTabs(); -// } -// else -// { -// updateButtons(); -// updateTimeAndLabel(); -// } } void LLFloaterEditExtDayCycle::onFrameSliderDoubleClick(S32 x, S32 y, MASK mask) @@ -592,7 +601,7 @@ void LLFloaterEditExtDayCycle::updateTabs() void LLFloaterEditExtDayCycle::updateWaterTabs(const LLSettingsWaterPtr_t &p_water) { - LLView* tab_container = mWaterTabLayoutContainer->getChild("water_tabs"); //can't extract panels directly, since it is in 'tuple' + LLView* tab_container = mWaterTabLayoutContainer->getChild(TABS_WATER); //can't extract panels directly, since it is in 'tuple' LLPanelSettingsWaterMainTab* panel = dynamic_cast(tab_container->getChildView("water_panel")); if (panel) { @@ -602,7 +611,7 @@ void LLFloaterEditExtDayCycle::updateWaterTabs(const LLSettingsWaterPtr_t &p_wat void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { - LLView* tab_container = mSkyTabLayoutContainer->getChild("sky_tabs"); //can't extract panels directly, since they are in 'tuple' + LLView* tab_container = mSkyTabLayoutContainer->getChild(TABS_SKYS); //can't extract panels directly, since they are in 'tuple' LLPanelSettingsSky* panel; panel = dynamic_cast(tab_container->getChildView("atmosphere_panel")); @@ -624,7 +633,7 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) void LLFloaterEditExtDayCycle::setWaterTabsEnabled(BOOL enable) { - LLView* tab_container = mWaterTabLayoutContainer->getChild("water_tabs"); //can't extract panels directly, since it is in 'tuple' + LLView* tab_container = mWaterTabLayoutContainer->getChild(TABS_WATER); //can't extract panels directly, since it is in 'tuple' LLPanelSettingsWaterMainTab* panel = dynamic_cast(tab_container->getChildView("water_panel")); if (panel) { @@ -635,7 +644,7 @@ void LLFloaterEditExtDayCycle::setWaterTabsEnabled(BOOL enable) void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) { - LLView* tab_container = mSkyTabLayoutContainer->getChild("sky_tabs"); //can't extract panels directly, since they are in 'tuple' + LLView* tab_container = mSkyTabLayoutContainer->getChild(TABS_SKYS); //can't extract panels directly, since they are in 'tuple' LLPanelSettingsSky* panel; panel = dynamic_cast(tab_container->getChildView("atmosphere_panel")); @@ -662,7 +671,7 @@ void LLFloaterEditExtDayCycle::updateButtons() { LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); LLSettingsBase::ptr_t settings = mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack); - bool can_add = settings.get() == NULL; + bool can_add = static_cast(settings); mAddFrameButton->setEnabled(can_add); mDeleteFrameButton->setEnabled(!can_add); } @@ -815,7 +824,6 @@ void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::pt void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t env) { - mEditingEnv = env; for (S32 idx = static_cast(env); idx <= LLEnvironment::ENV_DEFAULT; ++idx) { LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(static_cast(idx)); @@ -855,75 +863,73 @@ void LLFloaterEditExtDayCycle::updateEditEnvironment(void) void LLFloaterEditExtDayCycle::syncronizeTabs() { // This should probably get moved into "updateTabs" - LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); bool canedit(false); - LLSettingsWater::ptr_t psettingWater; - LLTabContainer * tabs = mWaterTabLayoutContainer->getChild("water_tabs"); + LLSettingsWater::ptr_t psettingW; + LLTabContainer * tabs = mWaterTabLayoutContainer->getChild(TABS_WATER); if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { - canedit = true; - psettingWater = std::static_pointer_cast(mEditDay->getSettingsAtKeyframe(frame, LLSettingsDay::TRACK_WATER)); - if (!psettingWater) + canedit = !mIsPlaying; + LLSettingsDay::CycleTrack_t::value_type found = mEditDay->getSettingsNearKeyfarme(frame, LLSettingsDay::TRACK_WATER, FRAME_SLOP_FACTOR); + psettingW = std::static_pointer_cast(found.second); + if (!psettingW) { canedit = false; - psettingWater = mScratchWater; + psettingW = mScratchWater; } + + getChild(ICN_LOCK_EDIT)->setVisible(!canedit); } else { - psettingWater = mScratchWater; + psettingW = mScratchWater; } - S32 count = tabs->getTabCount(); - for (S32 idx = 0; idx < count; ++idx) - { - LLSettingsEditPanel *panel = static_cast(tabs->getPanelByIndex(idx)); - if (panel) - { - panel->setSettings(psettingWater); - panel->setEnabled(canedit); - panel->setAllChildrenEnabled(canedit); - panel->refresh(); - } - } - - LLSettingsSky::ptr_t psettingSky; + setTabsData(tabs, psettingW, canedit); + LLSettingsSky::ptr_t psettingS; canedit = false; - tabs = mSkyTabLayoutContainer->getChild("sky_tabs"); + tabs = mSkyTabLayoutContainer->getChild(TABS_SKYS); if (mCurrentTrack != LLSettingsDay::TRACK_WATER) { - canedit = true; - psettingSky = std::static_pointer_cast(mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack)); - if (!psettingSky) + canedit = !mIsPlaying; + LLSettingsDay::CycleTrack_t::value_type found = mEditDay->getSettingsNearKeyfarme(frame, mCurrentTrack, FRAME_SLOP_FACTOR); + psettingS = std::static_pointer_cast(found.second); + if (!psettingS) { canedit = false; - psettingSky = mScratchSky; + psettingS = mScratchSky; } + + getChild(ICN_LOCK_EDIT)->setVisible(!canedit); } else { - psettingSky = mScratchSky; + psettingS = mScratchSky; } - count = tabs->getTabCount(); + setTabsData(tabs, psettingS, canedit); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psettingS, psettingW); +} + +void LLFloaterEditExtDayCycle::setTabsData(LLTabContainer * tabcontainer, const LLSettingsBase::ptr_t &settings, bool editable) +{ + S32 count = tabcontainer->getTabCount(); for (S32 idx = 0; idx < count; ++idx) { - LLSettingsEditPanel *panel = static_cast(tabs->getPanelByIndex(idx)); + LLSettingsEditPanel *panel = static_cast(tabcontainer->getPanelByIndex(idx)); if (panel) { - panel->setSettings(psettingSky); - panel->setEnabled(canedit); - panel->setAllChildrenEnabled(canedit); + panel->setSettings(settings); + panel->setEnabled(editable); panel->refresh(); + panel->setAllChildrenEnabled(editable); } } - - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psettingSky, psettingWater); } + void LLFloaterEditExtDayCycle::reblendSettings() { F64 position = mTimeSlider->getCurSliderValue(); diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index fc0b4f5106..ea9f1e1882 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -40,6 +40,7 @@ class LLLineEditor; class LLMultiSliderCtrl; class LLTextBox; class LLTimeCtrl; +class LLTabContainer; class LLInventoryItem; @@ -83,6 +84,7 @@ private: void onButtonApply(LLUICtrl *ctrl, const LLSD &data); void onBtnCancel(); void onButtonImport(); + void onButtonLoadFrame(); void onAddTrack(); void onRemoveTrack(); void onCommitName(class LLLineEditor* caller, void* user_data); @@ -130,46 +132,41 @@ private: void syncronizeTabs(); void reblendSettings(); - // **RIDER** + void setTabsData(LLTabContainer * tabcontainer, const LLSettingsBase::ptr_t &settings, bool editable); // play functions void startPlay(); void stopPlay(); static void onIdlePlay(void *); - LLSettingsDay::ptr_t mEditDay; // edited copy - LLSettingsDay::Seconds mDayLength; - U32 mCurrentTrack; - std::string mLastFrameSlider; - - LLButton* mCancelButton; - LLButton* mAddFrameButton; - LLButton* mDeleteFrameButton; - LLButton* mImportButton; - - LLMultiSliderCtrl* mTimeSlider; - LLMultiSliderCtrl* mFramesSlider; - LLView* mSkyTabLayoutContainer; - LLView* mWaterTabLayoutContainer; - LLTextBox* mCurrentTimeLabel; + LLSettingsDay::ptr_t mEditDay; // edited copy + LLSettingsDay::Seconds mDayLength; + U32 mCurrentTrack; + std::string mLastFrameSlider; + + LLButton* mAddFrameButton; + LLButton* mDeleteFrameButton; + LLButton* mImportButton; + LLButton* mLoadFrame; + LLMultiSliderCtrl* mTimeSlider; + LLMultiSliderCtrl* mFramesSlider; + LLView* mSkyTabLayoutContainer; + LLView* mWaterTabLayoutContainer; + LLTextBox* mCurrentTimeLabel; + LLUUID mInventoryId; + LLInventoryItem * mInventoryItem; + LLFlyoutComboBtnCtrl * mFlyoutControl; - // **RIDER** - LLUUID mInventoryId; - LLInventoryItem * mInventoryItem; - LLEnvironment::EnvSelection_t mEditingEnv; LLTrackBlenderLoopingManual::ptr_t mSkyBlender; LLTrackBlenderLoopingManual::ptr_t mWaterBlender; - LLSettingsSky::ptr_t mScratchSky; - LLSettingsWater::ptr_t mScratchWater; - // **RIDER** - - LLFlyoutComboBtnCtrl * mFlyoutControl; + LLSettingsSky::ptr_t mScratchSky; + LLSettingsWater::ptr_t mScratchWater; - LLFrameTimer mPlayTimer; - F32 mPlayStartFrame; // an env frame - bool mIsPlaying; + LLFrameTimer mPlayTimer; + F32 mPlayStartFrame; // an env frame + bool mIsPlaying; - edit_commit_signal_t mCommitSignal; + edit_commit_signal_t mCommitSignal; // For map of sliders to parameters class FrameData diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 528987f3bf..78c868c6f4 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -253,6 +253,9 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + +// LLFloaterReg::add("floater_settings_picker", "floater_settings_picker.xml" , (LLFloaterBuildFunc)&LLFloaterReg::build); + LLInspectAvatarUtil::registerFloater(); LLInspectGroupUtil::registerFloater(); LLInspectObjectUtil::registerFloater(); diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index 86c580f354..a1140b2532 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -41,7 +41,7 @@ left="15" top="5" width="105"> - Day Cycle Name: + Day Cycle Name: + function="DayCycle.Track" + parameter="4" /> - + + follows="left|top" + height="15" + layout="topleft" + left="10" + name="p0" + top_pad="5" + value="0%[DSC]" + width="80" /> + follows="left|top|right" + height="15" + layout="topleft" + left_pad="39" + name="p1" + top_delta="0" + value="25%[DSC]" + width="80" /> + follows="left|top|right" + height="15" + layout="topleft" + left_pad="39" + name="p2" + top_delta="0" + value="50%[DSC]" + width="80" /> + follows="left|top|right" + height="15" + layout="topleft" + left_pad="39" + name="p3" + top_delta="0" + value="75%[DSC]" + width="80" /> + follows="left|top|right" + height="15" + layout="topleft" + left_pad="39" + name="p4" + top_delta="0" + value="100%[DSC]" + width="80" /> + decimal_digits="0" + draw_track="false" + follows="bottom" + height="10" + increment="0.01" + initial_value="0" + layout="topleft" + left="10" + max_sliders="1" + max_val="1" + name="WLTimeSlider" + show_text="false" + top_pad="0" + use_triangle="true" + width="525" /> + decimal_digits="0" + follows="bottom" + height="10" + increment="0.01" + initial_value="0" + layout="topleft" + left="10" + max_sliders="20" + max_val="1" + name="WLDayCycleFrames" + show_text="false" + top_pad="15" + width="525" /> + follows="left|bottom" + height="20" + layout="topleft" + left_pad="0" + name="current_time" + value="[PRCNT]%[DSC]" + top_delta="-5" + width="70" /> + name="progress_control" + follows="top|left" + height="25" + width="83" + layout="topleft" + animate="false" + left="225" + top_pad="40" + orientation="horizontal"> + name="skip_back" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25"> + name="play_layout" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25"> + name="pause_layout" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25" + visible="false"> + name="skip_forward" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25">