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/llcommon/llassettype.cpp | 69 ++--- indra/llcommon/llassettype.h | 18 +- indra/llinventory/llfoldertype.cpp | 2 +- indra/llinventory/llinventorydefines.h | 4 + indra/llinventory/llinventorytype.cpp | 10 + indra/llinventory/llinventorytype.h | 6 +- indra/llmath/CMakeLists.txt | 1 + indra/llmath/llquaternion.cpp | 4 + indra/llmath/llquaternion.h | 24 ++ indra/llmath/v2math.cpp | 2 +- indra/llmath/v2math.h | 7 +- indra/llmath/v3colorutil.h | 95 ++++++ indra/llmath/v4math.h | 15 + indra/newview/CMakeLists.txt | 4 + indra/newview/llinventoryicon.cpp | 8 + indra/newview/llinventorymodel.cpp | 2 +- indra/newview/llsettingsbase.cpp | 246 ++++++++++++++++ indra/newview/llsettingsbase.h | 155 ++++++++++ indra/newview/llsettingssky.cpp | 513 +++++++++++++++++++++++++++++++++ indra/newview/llsettingssky.h | 314 ++++++++++++++++++++ indra/newview/llviewershadermgr.cpp | 1 + indra/newview/llvosky.cpp | 63 +--- indra/newview/llwlparammanager.cpp | 5 + 23 files changed, 1459 insertions(+), 109 deletions(-) create mode 100644 indra/llmath/v3colorutil.h create mode 100644 indra/newview/llsettingsbase.cpp create mode 100644 indra/newview/llsettingsbase.h create mode 100644 indra/newview/llsettingssky.cpp create mode 100644 indra/newview/llsettingssky.h diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index 4304db36be..22d6bae0eb 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -70,35 +70,38 @@ LLAssetDictionary::LLAssetDictionary() { // DESCRIPTION TYPE NAME HUMAN NAME CAN LINK? CAN FETCH? CAN KNOW? // |--------------------|-----------|-------------------|-----------|-----------|---------| - addEntry(LLAssetType::AT_TEXTURE, new AssetEntry("TEXTURE", "texture", "texture", true, false, true)); - addEntry(LLAssetType::AT_SOUND, new AssetEntry("SOUND", "sound", "sound", true, true, true)); - addEntry(LLAssetType::AT_CALLINGCARD, new AssetEntry("CALLINGCARD", "callcard", "calling card", true, false, false)); - addEntry(LLAssetType::AT_LANDMARK, new AssetEntry("LANDMARK", "landmark", "landmark", true, true, true)); - addEntry(LLAssetType::AT_SCRIPT, new AssetEntry("SCRIPT", "script", "legacy script", true, false, false)); - addEntry(LLAssetType::AT_CLOTHING, new AssetEntry("CLOTHING", "clothing", "clothing", true, true, true)); - addEntry(LLAssetType::AT_OBJECT, new AssetEntry("OBJECT", "object", "object", true, false, false)); - addEntry(LLAssetType::AT_NOTECARD, new AssetEntry("NOTECARD", "notecard", "note card", true, false, true)); - addEntry(LLAssetType::AT_CATEGORY, new AssetEntry("CATEGORY", "category", "folder", true, false, false)); - addEntry(LLAssetType::AT_LSL_TEXT, new AssetEntry("LSL_TEXT", "lsltext", "lsl2 script", true, false, false)); - addEntry(LLAssetType::AT_LSL_BYTECODE, new AssetEntry("LSL_BYTECODE", "lslbyte", "lsl bytecode", true, false, false)); - addEntry(LLAssetType::AT_TEXTURE_TGA, new AssetEntry("TEXTURE_TGA", "txtr_tga", "tga texture", true, false, false)); - addEntry(LLAssetType::AT_BODYPART, new AssetEntry("BODYPART", "bodypart", "body part", true, true, true)); - addEntry(LLAssetType::AT_SOUND_WAV, new AssetEntry("SOUND_WAV", "snd_wav", "sound", true, false, false)); - addEntry(LLAssetType::AT_IMAGE_TGA, new AssetEntry("IMAGE_TGA", "img_tga", "targa image", true, false, false)); - addEntry(LLAssetType::AT_IMAGE_JPEG, new AssetEntry("IMAGE_JPEG", "jpeg", "jpeg image", true, false, false)); - addEntry(LLAssetType::AT_ANIMATION, new AssetEntry("ANIMATION", "animatn", "animation", true, true, true)); - addEntry(LLAssetType::AT_GESTURE, new AssetEntry("GESTURE", "gesture", "gesture", true, true, true)); - addEntry(LLAssetType::AT_SIMSTATE, new AssetEntry("SIMSTATE", "simstate", "simstate", false, false, false)); - - addEntry(LLAssetType::AT_LINK, new AssetEntry("LINK", "link", "sym link", false, false, true)); - addEntry(LLAssetType::AT_LINK_FOLDER, new AssetEntry("FOLDER_LINK", "link_f", "sym folder link", false, false, true)); - addEntry(LLAssetType::AT_MESH, new AssetEntry("MESH", "mesh", "mesh", false, false, false)); - addEntry(LLAssetType::AT_WIDGET, new AssetEntry("WIDGET", "widget", "widget", false, false, false)); - addEntry(LLAssetType::AT_PERSON, new AssetEntry("PERSON", "person", "person", false, false, false)); - addEntry(LLAssetType::AT_NONE, new AssetEntry("NONE", "-1", NULL, FALSE, FALSE, FALSE)); + addEntry(LLAssetType::AT_TEXTURE, new AssetEntry("TEXTURE", "texture", "texture", true, false, true)); + addEntry(LLAssetType::AT_SOUND, new AssetEntry("SOUND", "sound", "sound", true, true, true)); + addEntry(LLAssetType::AT_CALLINGCARD, new AssetEntry("CALLINGCARD", "callcard", "calling card", true, false, false)); + addEntry(LLAssetType::AT_LANDMARK, new AssetEntry("LANDMARK", "landmark", "landmark", true, true, true)); + addEntry(LLAssetType::AT_SCRIPT, new AssetEntry("SCRIPT", "script", "legacy script", true, false, false)); + addEntry(LLAssetType::AT_CLOTHING, new AssetEntry("CLOTHING", "clothing", "clothing", true, true, true)); + addEntry(LLAssetType::AT_OBJECT, new AssetEntry("OBJECT", "object", "object", true, false, false)); + addEntry(LLAssetType::AT_NOTECARD, new AssetEntry("NOTECARD", "notecard", "note card", true, false, true)); + addEntry(LLAssetType::AT_CATEGORY, new AssetEntry("CATEGORY", "category", "folder", true, false, false)); + addEntry(LLAssetType::AT_LSL_TEXT, new AssetEntry("LSL_TEXT", "lsltext", "lsl2 script", true, false, false)); + addEntry(LLAssetType::AT_LSL_BYTECODE, new AssetEntry("LSL_BYTECODE", "lslbyte", "lsl bytecode", true, false, false)); + addEntry(LLAssetType::AT_TEXTURE_TGA, new AssetEntry("TEXTURE_TGA", "txtr_tga", "tga texture", true, false, false)); + addEntry(LLAssetType::AT_BODYPART, new AssetEntry("BODYPART", "bodypart", "body part", true, true, true)); + addEntry(LLAssetType::AT_SOUND_WAV, new AssetEntry("SOUND_WAV", "snd_wav", "sound", true, false, false)); + addEntry(LLAssetType::AT_IMAGE_TGA, new AssetEntry("IMAGE_TGA", "img_tga", "targa image", true, false, false)); + addEntry(LLAssetType::AT_IMAGE_JPEG, new AssetEntry("IMAGE_JPEG", "jpeg", "jpeg image", true, false, false)); + addEntry(LLAssetType::AT_ANIMATION, new AssetEntry("ANIMATION", "animatn", "animation", true, true, true)); + addEntry(LLAssetType::AT_GESTURE, new AssetEntry("GESTURE", "gesture", "gesture", true, true, true)); + addEntry(LLAssetType::AT_SIMSTATE, new AssetEntry("SIMSTATE", "simstate", "simstate", false, false, false)); + + addEntry(LLAssetType::AT_LINK, new AssetEntry("LINK", "link", "sym link", false, false, true)); + addEntry(LLAssetType::AT_LINK_FOLDER, new AssetEntry("FOLDER_LINK", "link_f", "sym folder link", false, false, true)); + addEntry(LLAssetType::AT_MESH, new AssetEntry("MESH", "mesh", "mesh", false, false, false)); + addEntry(LLAssetType::AT_WIDGET, new AssetEntry("WIDGET", "widget", "widget", false, false, false)); + addEntry(LLAssetType::AT_PERSON, new AssetEntry("PERSON", "person", "person", false, false, false)); + addEntry(LLAssetType::AT_SETTINGS, new AssetEntry("SETTINGS", "settings", "settings blob", false, true, true)); + addEntry(LLAssetType::AT_NONE, new AssetEntry("NONE", "-1", NULL, FALSE, FALSE, FALSE)); }; +const std::string LLAssetType::BADLOOKUP("llassettype_bad_lookup"); + // static LLAssetType::EType LLAssetType::getType(const std::string& desc_name) { @@ -117,7 +120,7 @@ const std::string &LLAssetType::getDesc(LLAssetType::EType asset_type) } else { - return badLookup(); + return BADLOOKUP; } } @@ -132,7 +135,7 @@ const char *LLAssetType::lookup(LLAssetType::EType asset_type) } else { - return badLookup().c_str(); + return BADLOOKUP.c_str(); } } @@ -170,7 +173,7 @@ const char *LLAssetType::lookupHumanReadable(LLAssetType::EType asset_type) } else { - return badLookup().c_str(); + return BADLOOKUP.c_str(); } } @@ -220,14 +223,6 @@ bool LLAssetType::lookupIsLinkType(EType asset_type) return false; } -// static -const std::string &LLAssetType::badLookup() -{ - static const std::string sBadLookup = "llassettype_bad_lookup"; - return sBadLookup; - -} - // static bool LLAssetType::lookupIsAssetFetchByIDAllowed(EType asset_type) { diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h index b849be9f16..3a660496e3 100644 --- a/indra/llcommon/llassettype.h +++ b/indra/llcommon/llassettype.h @@ -116,10 +116,18 @@ public: AT_PERSON = 45, // A user uuid which is not an inventory asset type, used in viewer only for adding a person to a chat via drag and drop. - AT_MESH = 49, - // Mesh data in our proprietary SLM format - - AT_COUNT = 50, + AT_MESH = 49, + // Mesh data in our proprietary SLM format + + AT_RESERVED_1 = 50, + AT_RESERVED_2 = 51, + AT_RESERVED_3 = 52, + AT_RESERVED_4 = 53, + AT_RESERVED_5 = 54, + + AT_SETTINGS = 55, // Collection of settings + + AT_COUNT = 56, // +*********************************************************+ // | TO ADD AN ELEMENT TO THIS ENUM: | @@ -153,7 +161,7 @@ public: static bool lookupIsAssetFetchByIDAllowed(EType asset_type); // the asset allows direct download static bool lookupIsAssetIDKnowable(EType asset_type); // asset data can be known by the viewer - static const std::string& badLookup(); // error string when a lookup fails + static const std::string BADLOOKUP; protected: LLAssetType() {} 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 diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index 4c8bcdac91..61d13c0b1c 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -87,6 +87,7 @@ set(llmath_HEADER_FILES raytrace.h v2math.h v3color.h + v3colorutil.h v3dmath.h v3math.h v4color.h diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp index 47374c287f..dcef2b345e 100644 --- a/indra/llmath/llquaternion.cpp +++ b/indra/llmath/llquaternion.cpp @@ -103,6 +103,10 @@ LLQuaternion::LLQuaternion(const LLVector3 &x_axis, *this = mat.quaternion(); normalize(); } +LLQuaternion::LLQuaternion(const LLSD &sd) +{ + setValue(sd); +} // Quatizations void LLQuaternion::quantize16(F32 lower, F32 upper) diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index aa0b1752f4..11b6abf800 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -28,6 +28,7 @@ #define LLQUATERNION_H #include +#include "llsd.h" #ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies #error "Please include llmath.h first." @@ -63,6 +64,10 @@ public: LLQuaternion(const LLVector3 &x_axis, const LLVector3 &y_axis, const LLVector3 &z_axis); // Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis] + explicit LLQuaternion(const LLSD &sd); // Initializes Quaternion from LLSD array. + + LLSD getValue() const; + void setValue(const LLSD& sd); BOOL isIdentity() const; BOOL isNotIdentity() const; @@ -166,6 +171,25 @@ public: //static U32 mMultCount; }; +inline LLSD LLQuaternion::getValue() const +{ + LLSD ret; + ret[0] = mQ[0]; + ret[1] = mQ[1]; + ret[2] = mQ[2]; + ret[3] = mQ[3]; + return ret; +} + +inline void LLQuaternion::setValue(const LLSD& sd) +{ + mQ[0] = sd[0].asReal(); + mQ[1] = sd[1].asReal(); + mQ[2] = sd[2].asReal(); + mQ[3] = sd[3].asReal(); +} + + // checker inline BOOL LLQuaternion::isFinite() const { diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp index a0cd642853..a24571f2c8 100644 --- a/indra/llmath/v2math.cpp +++ b/indra/llmath/v2math.cpp @@ -118,7 +118,7 @@ LLSD LLVector2::getValue() const return ret; } -void LLVector2::setValue(LLSD& sd) +void LLVector2::setValue(const LLSD& sd) { mV[0] = (F32) sd[0].asReal(); mV[1] = (F32) sd[1].asReal(); diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index 8d5db96f5e..2335a2e327 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -49,6 +49,7 @@ class LLVector2 LLVector2(F32 x, F32 y); // Initializes LLVector2 to (x. y) LLVector2(const F32 *vec); // Initializes LLVector2 to (vec[0]. vec[1]) explicit LLVector2(const LLVector3 &vec); // Initializes LLVector2 to (vec[0]. vec[1]) + explicit LLVector2(const LLSD &sd); // Clears LLVector2 to (0, 0). DEPRECATED - prefer zeroVec. void clear(); @@ -61,7 +62,7 @@ class LLVector2 void set(const F32 *vec); // Sets LLVector2 to vec LLSD getValue() const; - void setValue(LLSD& sd); + void setValue(const LLSD& sd); void setVec(F32 x, F32 y); // deprecated void setVec(const LLVector2 &vec); // deprecated @@ -145,6 +146,10 @@ inline LLVector2::LLVector2(const LLVector3 &vec) mV[VY] = vec.mV[VY]; } +inline LLVector2::LLVector2(const LLSD &sd) +{ + setValue(sd); +} // Clear and Assignment Functions diff --git a/indra/llmath/v3colorutil.h b/indra/llmath/v3colorutil.h new file mode 100644 index 0000000000..00b36132d8 --- /dev/null +++ b/indra/llmath/v3colorutil.h @@ -0,0 +1,95 @@ +/** + * @file v3color.h + * @brief LLColor3 class header file. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * 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_V3COLORUTIL_H +#define LL_V3COLORUTIL_H + +#include "v3color.h" + +inline LLColor3 componentDiv(LLColor3 const &left, LLColor3 const & right) +{ + return LLColor3(left.mV[0] / right.mV[0], + left.mV[1] / right.mV[1], + left.mV[2] / right.mV[2]); +} + + +inline LLColor3 componentMult(LLColor3 const &left, LLColor3 const & right) +{ + return LLColor3(left.mV[0] * right.mV[0], + left.mV[1] * right.mV[1], + left.mV[2] * right.mV[2]); +} + + +inline LLColor3 componentExp(LLColor3 const &v) +{ + return LLColor3(exp(v.mV[0]), + exp(v.mV[1]), + exp(v.mV[2])); +} + +inline LLColor3 componentPow(LLColor3 const &v, F32 exponent) +{ + return LLColor3(pow(v.mV[0], exponent), + pow(v.mV[1], exponent), + pow(v.mV[2], exponent)); +} + +inline LLColor3 componentSaturate(LLColor3 const &v) +{ + return LLColor3(std::max(std::min(v.mV[0], 1.f), 0.f), + std::max(std::min(v.mV[1], 1.f), 0.f), + std::max(std::min(v.mV[2], 1.f), 0.f)); +} + + +inline LLColor3 componentSqrt(LLColor3 const &v) +{ + return LLColor3(sqrt(v.mV[0]), + sqrt(v.mV[1]), + sqrt(v.mV[2])); +} + +inline void componentMultBy(LLColor3 & left, LLColor3 const & right) +{ + left.mV[0] *= right.mV[0]; + left.mV[1] *= right.mV[1]; + left.mV[2] *= right.mV[2]; +} + +inline LLColor3 colorMix(LLColor3 const & left, LLColor3 const & right, F32 amount) +{ + return (left + ((right - left) * amount)); +} + +inline LLColor3 smear(F32 val) +{ + return LLColor3(val, val, val); +} + + +#endif diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index 623c8b2003..293005a627 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -48,6 +48,7 @@ class LLVector4 explicit LLVector4(const F64 *vec); // Initialized LLVector4 to ((F32) vec[0], (F32) vec[1], (F32) vec[3], (F32) vec[4]); explicit LLVector4(const LLVector3 &vec); // Initializes LLVector4 to (vec, 1) explicit LLVector4(const LLVector3 &vec, F32 w); // Initializes LLVector4 to (vec, w) + explicit LLVector4(const LLSD &sd); LLVector4(F32 x, F32 y, F32 z); // Initializes LLVector4 to (x. y, z, 1) LLVector4(F32 x, F32 y, F32 z, F32 w); @@ -61,6 +62,15 @@ class LLVector4 return ret; } + void setValue(const LLSD& sd) + { + mV[0] = sd[0].asReal(); + mV[1] = sd[1].asReal(); + mV[2] = sd[2].asReal(); + mV[3] = sd[3].asReal(); + } + + inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite inline void clear(); // Clears LLVector4 to (0, 0, 0, 1) @@ -191,6 +201,11 @@ inline LLVector4::LLVector4(const LLVector3 &vec, F32 w) mV[VW] = w; } +inline LLVector4::LLVector4(const LLSD &sd) +{ + setValue(sd); +} + inline BOOL LLVector4::isFinite() const { diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index f353109deb..f3811fffe7 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -533,6 +533,8 @@ set(viewer_SOURCE_FILES llsecapi.cpp llsechandler_basic.cpp llselectmgr.cpp + llsettingsbase.cpp + llsettingssky.cpp llshareavatarhandler.cpp llsidepanelappearance.cpp llsidepanelinventory.cpp @@ -1145,6 +1147,8 @@ set(viewer_HEADER_FILES llsecapi.h llsechandler_basic.h llselectmgr.h + llsettingsbase.h + llsettingssky.h llsidepanelappearance.h llsidepanelinventory.h llsidepanelinventorysubpanel.h diff --git a/indra/newview/llinventoryicon.cpp b/indra/newview/llinventoryicon.cpp index 495180f087..64b48228f6 100644 --- a/indra/newview/llinventoryicon.cpp +++ b/indra/newview/llinventoryicon.cpp @@ -92,6 +92,9 @@ LLIconDictionary::LLIconDictionary() addEntry(LLInventoryType::ICONNAME_LINKFOLDER, new IconEntry("Inv_LinkFolder")); addEntry(LLInventoryType::ICONNAME_MESH, new IconEntry("Inv_Mesh")); + addEntry(LLInventoryType::ICONNAME_SETTINGS_SKY, new IconEntry("Inv_SettingSky")); + addEntry(LLInventoryType::ICONNAME_SETTINGS_WATER, new IconEntry("Inv_SettingWater")); + addEntry(LLInventoryType::ICONNAME_INVALID, new IconEntry("Inv_Invalid")); addEntry(LLInventoryType::ICONNAME_NONE, new IconEntry("NONE")); @@ -166,6 +169,11 @@ const std::string& LLInventoryIcon::getIconName(LLAssetType::EType asset_type, break; case LLAssetType::AT_MESH: idx = LLInventoryType::ICONNAME_MESH; + break; + case LLAssetType::AT_SETTINGS: + // TODO: distinguish between Sky and Water settings. + idx = LLInventoryType::ICONNAME_SETTINGS_SKY; + break; default: break; } diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index e5fd126d53..c26f2f07ce 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -1801,7 +1801,7 @@ void LLInventoryModel::addItem(LLViewerInventoryItem* item) // For example, there is a known backwards compatibility issue in some viewer prototypes prior to when // the AT_LINK enum changed from 23 to 24. if ((item->getType() == LLAssetType::AT_NONE) - || LLAssetType::lookup(item->getType()) == LLAssetType::badLookup()) + || LLAssetType::lookup(item->getType()) == LLAssetType::BADLOOKUP) { LL_WARNS(LOG_INV) << "Got bad asset type for item [ name: " << item->getName() << " type: " << item->getType() diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp new file mode 100644 index 0000000000..1aafacae45 --- /dev/null +++ b/indra/newview/llsettingsbase.cpp @@ -0,0 +1,246 @@ +/** +* @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; +} + +//========================================================================= +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; + 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; + 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: + // 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; +} + + +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; + } +} diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h new file mode 100644 index 0000000000..01a19c8734 --- /dev/null +++ b/indra/newview/llsettingsbase.h @@ -0,0 +1,155 @@ +/** +* @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 "llsd.h" +#include "llsdutil.h" +#include "v2math.h" +#include "v3math.h" +#include "v4math.h" +#include "llquaternion.h" +#include "v4color.h" + +class LLSettingsBase: private boost::noncopyable +{ + friend class LLEnvironment; + +public: + 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 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()) + { + 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; + +protected: + 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); + + /// 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 stringset_t getSkipApplyKeys() const { return stringset_t(); } + // Apply any settings that need special handling. + virtual void applySpecial(void *) { }; + + LLSD mSettings; + +private: + bool mDirty; + + LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const; + +}; + + +#endif diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp new file mode 100644 index 0000000000..364c211344 --- /dev/null +++ b/indra/newview/llsettingssky.cpp @@ -0,0 +1,513 @@ +/** +* @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 "llsky.h" + +//========================================================================= +namespace +{ + const LLVector3 DUE_EAST(-1.0f, 0.0f, 0.0); + + LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params"); + LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); + +} + +//========================================================================= +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_NAME("name"); +const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); +const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); +const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); +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() +{ +} + +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::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +{ + LLSD newsettings(LLSD::emptyMap()); + + 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] = LLColor4(oldsettings[SETTING_CLOUD_COLOR]).getValue(); + } + if (oldsettings.has(SETTING_SUNLIGHT_COLOR)) + { + newsettings[SETTING_SUNLIGHT_COLOR] = LLColor4(oldsettings[SETTING_SUNLIGHT_COLOR]).getValue(); + } + if (oldsettings.has(SETTING_CLOUD_SHADOW)) + { + newsettings[SETTING_CLOUD_SHADOW] = LLSD::Real(oldsettings[SETTING_CLOUD_SHADOW][0].asReal()); + } + + if (oldsettings.has(SETTING_CLOUD_POS_DENSITY1)) + { + newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor4(oldsettings[SETTING_CLOUD_POS_DENSITY1]).getValue(); + } + if (oldsettings.has(SETTING_CLOUD_POS_DENSITY2)) + { + newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor4(oldsettings[SETTING_CLOUD_POS_DENSITY2]).getValue(); + } + if (oldsettings.has(SETTING_LIGHT_NORMAL)) + { + newsettings[SETTING_LIGHT_NORMAL] = LLVector4(oldsettings[SETTING_LIGHT_NORMAL]).getValue(); + } + + if (oldsettings.has(SETTING_CLOUD_SCALE)) + { + newsettings[SETTING_CLOUD_SCALE] = LLSD::Real(oldsettings[SETTING_CLOUD_SCALE][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_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_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_GLOW)) + { + newsettings[SETTING_GLOW] = LLColor3(oldsettings[SETTING_GLOW]).getValue(); + } + + if (oldsettings.has(SETTING_GAMMA)) + { + newsettings[SETTING_GAMMA] = LLSD::Real(oldsettings[SETTING_GAMMA][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_LEGACY_EAST_ANGLE) && oldsettings.has(SETTING_LEGACY_SUN_ANGLE)) + { // convert the east and sun angles into a quaternion. + F32 east = oldsettings[SETTING_LEGACY_EAST_ANGLE].asReal(); + F32 azimuth = oldsettings[SETTING_LEGACY_SUN_ANGLE].asReal(); + + LLQuaternion sunquat; + sunquat.setEulerAngles(azimuth, 0.0, east); +// // set the sun direction from SunAngle and EastAngle +// F32 sinTheta = sin(east); +// F32 cosTheta = cos(east); +// +// F32 sinPhi = sin(azimuth); +// F32 cosPhi = cos(azimuth); +// +// LLVector4 sunDir; +// sunDir.mV[0] = -sinTheta * cosPhi; +// sunDir.mV[1] = sinPhi; +// sunDir.mV[2] = cosTheta * cosPhi; +// sunDir.mV[3] = 0; +// +// LLQuaternion sunquat = LLQuaternion(0.1, sunDir); // small rotation around axis + LLQuaternion moonquat = ~sunquat; + + newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); + newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); + } + + LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); + skyp->update(); + + return skyp; +} + +LLSettingsSky::ptr_t LLSettingsSky::buildDefaultSky() +{ + LLSD settings = LLSettingsSky::defaults(); + + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + skyp->update(); + + return skyp; +} + + +// Settings status + +LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const +{ + LL_RECORD_BLOCK_TIME(FTM_BLEND_ENVIRONMENT); + LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL; + + LLSettingsSky::ptr_t skyp = boost::make_shared(mSettings); + // the settings in the initial constructor are references tho this' settings block. + // They will be replaced in the following lerp + skyp->lerpSettings(*other, mix); + + return skyp; +} + + +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] = LLColor3::white.getValue(); + dfltsetting[SETTING_BLUE_DENSITY] = LLColor3(0.2447, 0.4487, 0.7599).getValue(); + dfltsetting[SETTING_BLUE_HORIZON] = LLColor3(0.4954, 0.4954, 0.6399).getValue(); + dfltsetting[SETTING_CLOUD_COLOR] = LLColor3(0.4099, 0.4099, 0.4099).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor3(1.0000, 0.5260, 1.0000).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor3(1.0000, 0.5260, 1.0000).getValue(); + dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); + dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); + dfltsetting[SETTING_CLOUD_SHADOW] = LLColor3(0.2699, 0.0000, 0.0000).getValue(); + dfltsetting[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(0.0001); + dfltsetting[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(0.8000); + dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(1.0); + dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(0.0); + dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0000); + dfltsetting[SETTING_GLOW] = LLColor3(5.000, 0.0010, -0.4799).getValue(); // *RIDER: This is really weird for a color... TODO: check if right. + dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999); + dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899); + dfltsetting[SETTING_LIGHT_NORMAL] = LLVector4(0.0000, 0.9126, -0.4086, 0.0000).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] = LLColor3(0.7342, 0.7815, 0.8999).getValue(); + dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); + + dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_MOON_TEXTUREID] = IMG_SUN; // gMoonTextureID; // These two are returned by the login... wow! + dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_MOON; // gSunTextureID; + + return dfltsetting; +} + +void LLSettingsSky::updateSettings() +{ + LL_RECORD_BLOCK_TIME(FTM_UPDATE_ENVIRONMENT); + 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] > 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.normVec(); + mLightDirection = vec; + } + else + { + mLightDirection = mMoonDirection; + } + + // calculate the clamp lightnorm for sky (to prevent ugly banding in sky + // when haze goes below the horizon + mLightDirectionClamped = mSunDirection; + + if (mLightDirectionClamped.mV[1] < -0.1f) + { + mLightDirectionClamped.mV[1] = -0.1f; + } +} + +void LLSettingsSky::calculateLightSettings() +{ + LLColor3 vary_HazeColor; + LLColor3 vary_SunlightColor; + LLColor3 vary_AmbientColor; + { + // Initialize temp variables + LLColor3 sunlight = getSunlightColor(); + + // Fetch these once... + F32 haze_density = getHazeDensity(); + F32 haze_horizon = getHazeHorizon(); + F32 density_multiplier = getDensityMultiplier(); + F32 max_y = getMaxY(); + F32 gamma = getGama(); + F32 cloud_shadow = getCloudShadow(); + LLColor3 blue_density = getBlueDensity(); + LLColor3 blue_horizon = getBlueHorizon(); + LLColor3 ambient = getAmbientColor(); + + + // 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 = mLightDirection[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); + + } + + float dp = getSunDirection() * LLVector3(0, 0, 1.f); // a dot b + 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 = std::max(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); + + mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + + mSunDiffuse = vary_SunlightColor; + mSunAmbient = vary_AmbientColor; + mMoonDiffuse = vary_SunlightColor; + mMoonAmbient = vary_AmbientColor; + + mTotalAmbient = vary_AmbientColor; + mTotalAmbient.setAlpha(1); + + mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; + mFadeColor.setAlpha(0); + +} + + +LLSettingsSky::stringset_t LLSettingsSky::getSkipApplyKeys() const +{ + + static stringset_t skip_apply_set; + + if (skip_apply_set.empty()) + { + skip_apply_set.insert(SETTING_GAMMA); + skip_apply_set.insert(SETTING_MOON_ROTATION); + skip_apply_set.insert(SETTING_SUN_ROTATION); + skip_apply_set.insert(SETTING_NAME); + skip_apply_set.insert(SETTING_STAR_BRIGHTNESS); + skip_apply_set.insert(SETTING_CLOUD_SCROLL_RATE); + skip_apply_set.insert(SETTING_LIGHT_NORMAL); + skip_apply_set.insert(SETTING_CLOUD_POS_DENSITY1); + } + + return skip_apply_set; +} + +void LLSettingsSky::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + if (shader->mShaderGroup == LLGLSLShader::SG_SKY) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); + } + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + + shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); +} + +//------------------------------------------------------------------------- +// const std::string LLSettingsSky::SETTING_DENSITY_MULTIPLIER("density_multiplier"); +// const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); +// const std::string LLSettingsSky::SETTING_NAME("name"); diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h new file mode 100644 index 0000000000..5b8691fa8b --- /dev/null +++ b/indra/newview/llsettingssky.h @@ -0,0 +1,314 @@ +/** +* @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_NAME; + 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; + + 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; + + typedef boost::shared_ptr ptr_t; + + //--------------------------------------------------------------------- + LLSettingsSky(const LLSD &data); + virtual ~LLSettingsSky() { }; + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildDefaultSky(); + + //--------------------------------------------------------------------- + virtual std::string getSettingType() const { return std::string("sky"); } + + // Settings status + ptr_t blend(const ptr_t &other, F32 mix) const; + + static LLSD defaults(); + + //--------------------------------------------------------------------- + LLColor3 getAmbientColor() const + { + return LLColor3(mSettings[SETTING_AMBIENT]); + } + + LLUUID getBloomTextureId() const + { + return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); + } + + LLColor3 getBlueDensity() const + { + return LLColor3(mSettings[SETTING_BLUE_DENSITY]); + } + + LLColor3 getBlueHorizon() const + { + return LLColor3(mSettings[SETTING_BLUE_HORIZON]); + } + + LLColor3 getCloudColor() const + { + return mSettings[SETTING_CLOUD_COLOR].asReal(); + } + + LLUUID getCloudNoiseTextureId() const + { + return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); + } + + LLColor3 getCloudPosDensity1() const + { + return mSettings[SETTING_CLOUD_POS_DENSITY1].asReal(); + } + + LLColor3 getCloudPosDensity2() const + { + return mSettings[SETTING_CLOUD_POS_DENSITY2].asReal(); + } + + F32 getCloudScale() const + { + return mSettings[SETTING_CLOUD_SCALE].asReal(); + } + + LLVector2 getCloudScrollRate() const + { + return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); + } + + F32 getCloudShadow() const + { + return mSettings[SETTING_CLOUD_SHADOW].asReal(); + } + + F32 getDensityMultiplier() const + { + return mSettings[SETTING_DENSITY_MULTIPLIER].asReal(); + } + + F32 getDistanceMultiplier() const + { + return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal(); + } + + F32 getDomeOffset() const + { + return mSettings[SETTING_DOME_OFFSET].asReal(); + } + + F32 getDomeRadius() const + { + return mSettings[SETTING_DOME_RADIUS].asReal(); + } + + F32 getGama() const + { + return mSettings[SETTING_GAMMA].asReal(); + } + + LLColor3 getGlow() const + { + return mSettings[SETTING_GLOW].asReal(); + } + + F32 getHazeDensity() const + { + return mSettings[SETTING_HAZE_DENSITY].asReal(); + } + + F32 getHazeHorizon() const + { + return mSettings[SETTING_HAZE_HORIZON].asReal(); + } + + F32 getMaxY() const + { + return mSettings[SETTING_MAX_Y].asReal(); + } + + LLQuaternion getMoonRotation() const + { + return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); + } + + LLUUID getMoonTextureId() const + { + return mSettings[SETTING_MOON_TEXTUREID].asUUID(); + } + + F32 getStarBrightness() const + { + return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); + } + + LLColor3 getSunlightColor() const + { + return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); + } + + LLQuaternion getSunRotation() const + { + return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); + } + + LLUUID getSunTextureId() const + { + return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); + } + + + // Internal/calculated settings + LLVector3 getLightDirection() const + { + update(); + return mLightDirection; + }; + + LLVector3 getLightDirectionClamped() const + { + update(); + return mLightDirectionClamped; + }; + + F32 getSceneLightStrength() const + { + update(); + return mSceneLightStrength; + } + + LLVector3 getSunDirection() const + { + update(); + return mSunDirection; + } + + LLVector3 getMoonDirection() const + { + update(); + return mMoonDirection; + } + + LLColor3 getSunDiffuse() const + { + update(); + return mSunDiffuse; + } + + LLColor3 getSunAmbient() const + { + update(); + return mSunAmbient; + } + + LLColor3 getMoonDiffuse() const + { + update(); + return mMoonDiffuse; + } + + LLColor3 getMoonAmbient() const + { + update(); + return mMoonAmbient; + } + + LLColor4 getTotalAmbient() const + { + update(); + return mTotalAmbient; + } + + LLColor4 getFadeColor() const + { + update(); + return mFadeColor; + } + +protected: + LLSettingsSky(); + + virtual stringset_t getSlerpKeys() const; + + virtual void updateSettings(); + + virtual stringset_t getSkipApplyKeys() const; + virtual void applySpecial(void *); + +private: + void calculateHeavnlyBodyPositions(); + void calculateLightSettings(); + + LLVector3 mSunDirection; + LLVector3 mMoonDirection; + F32 mSceneLightStrength; + LLVector3 mLightDirection; + LLVector3 mLightDirectionClamped; + + LLColor3 mSunDiffuse; + LLColor3 mSunAmbient; + LLColor3 mMoonDiffuse; + LLColor3 mMoonAmbient; + + LLColor4 mTotalAmbient; + LLColor4 mFadeColor; +}; + +#endif diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 3e0cec0f09..8adc86b423 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -3429,6 +3429,7 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { + //*LAPRAS*/ LLWLParamManager::getInstance()->updateShaderUniforms(shader); LLWaterParamManager::getInstance()->updateShaderUniforms(shader); } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 6b4a450e6f..03dfdf92fa 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -50,6 +50,7 @@ #include "lldrawpoolwlsky.h" #include "llwlparammanager.h" #include "llwaterparammanager.h" +#include "v3colorutil.h" #undef min #undef max @@ -560,68 +561,6 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile) } } -static inline LLColor3 componentDiv(LLColor3 const &left, LLColor3 const & right) -{ - return LLColor3(left.mV[0]/right.mV[0], - left.mV[1]/right.mV[1], - left.mV[2]/right.mV[2]); -} - - -static inline LLColor3 componentMult(LLColor3 const &left, LLColor3 const & right) -{ - return LLColor3(left.mV[0]*right.mV[0], - left.mV[1]*right.mV[1], - left.mV[2]*right.mV[2]); -} - - -static inline LLColor3 componentExp(LLColor3 const &v) -{ - return LLColor3(exp(v.mV[0]), - exp(v.mV[1]), - exp(v.mV[2])); -} - -static inline LLColor3 componentPow(LLColor3 const &v, F32 exponent) -{ - return LLColor3(pow(v.mV[0], exponent), - pow(v.mV[1], exponent), - pow(v.mV[2], exponent)); -} - -static inline LLColor3 componentSaturate(LLColor3 const &v) -{ - return LLColor3(std::max(std::min(v.mV[0], 1.f), 0.f), - std::max(std::min(v.mV[1], 1.f), 0.f), - std::max(std::min(v.mV[2], 1.f), 0.f)); -} - - -static inline LLColor3 componentSqrt(LLColor3 const &v) -{ - return LLColor3(sqrt(v.mV[0]), - sqrt(v.mV[1]), - sqrt(v.mV[2])); -} - -static inline void componentMultBy(LLColor3 & left, LLColor3 const & right) -{ - left.mV[0] *= right.mV[0]; - left.mV[1] *= right.mV[1]; - left.mV[2] *= right.mV[2]; -} - -static inline LLColor3 colorMix(LLColor3 const & left, LLColor3 const & right, F32 amount) -{ - return (left + ((right - left) * amount)); -} - -static inline LLColor3 smear(F32 val) -{ - return LLColor3(val, val, val); -} - void LLVOSky::initAtmospherics(void) { bool error; diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 4b4393b07b..980fe96c2b 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -317,6 +317,10 @@ bool LLWLParamManager::loadPreset(const std::string& path) addParamSet(key, params_data); } + //*RIDER temp code testing conversion old preset to new settings. + //LLSettingsSky::ptr_t test = LLSettingsSky::buildFromLegacyPreset(name, params_data); + //test->exportSettings(name); + return true; } @@ -708,3 +712,4 @@ std::string LLWLParamManager::escapeString(const std::string& str) return escaped_str; } + -- cgit v1.2.3 From d4d0520f38f59c4f60da098da9c2217ca6e45d65 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 20 Sep 2017 14:29:36 -0700 Subject: Cleanup inside GLSLShader for uniform mapping. --- indra/llrender/llglslshader.cpp | 319 ++++++++++++++----------------------- indra/llrender/llglslshader.h | 29 +++- indra/newview/CMakeLists.txt | 2 + indra/newview/llwlparammanager.cpp | 7 +- 4 files changed, 152 insertions(+), 205 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 5d669fb955..79421e6bdc 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -154,8 +154,7 @@ void LLGLSLShader::clearStats() mSamplesDrawn = 0; mDrawCalls = 0; mTextureStateFetched = false; - mTextureMagFilter.clear(); - mTextureMinFilter.clear(); + mTextureMagMinFilter.clear(); } void LLGLSLShader::dumpStats() @@ -168,14 +167,16 @@ void LLGLSLShader::dumpStats() { LL_INFOS() << mShaderFiles[i].first << LL_ENDL; } - for (U32 i = 0; i < mTexture.size(); ++i) + for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it) { - GLint idx = mTexture[i]; + S32 i = (*it).first; + GLint idx = (*it).second; if (idx >= 0) { GLint uniform_idx = getUniformLocation(i); - LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << LL_ENDL; + 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() << "=============================================" << LL_ENDL; @@ -232,14 +233,13 @@ void LLGLSLShader::placeProfileQuery() if (!mTextureStateFetched) { mTextureStateFetched = true; - mTextureMagFilter.resize(mTexture.size()); - mTextureMinFilter.resize(mTexture.size()); U32 cur_active = gGL.getCurrentTexUnitIndex(); - for (U32 i = 0; i < mTexture.size(); ++i) + for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it) { - GLint idx = mTexture[i]; + S32 i = (*it).first; + GLint idx = (*it).second; if (idx >= 0) { @@ -253,8 +253,7 @@ void LLGLSLShader::placeProfileQuery() glGetTexParameteriv(type, GL_TEXTURE_MAG_FILTER, (GLint*) &mag); glGetTexParameteriv(type, GL_TEXTURE_MIN_FILTER, (GLint*) &min); - mTextureMagFilter[i] = mag; - mTextureMinFilter[i] = min; + mTextureMagMinFilter[i] = magmin_values_t(mag, min); } } @@ -470,13 +469,14 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, } S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten - for (U32 i = 0; i < mTexture.size(); i++) + for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it) { - if (mTexture[i] > -1 && mTexture[i] < channel_count) + int i = (*it).first; + if (((*it).second >= 0) && ((*it).second < channel_count)) { llassert(cur_tex < gGLManager.mNumTextureImageUnits); uniform1i(i, cur_tex); - mTexture[i] = cur_tex++; + (*it).second = cur_tex++; } } unbind(); @@ -655,13 +655,16 @@ void LLGLSLShader::mapUniform(GLint index, const vector * //find the index of this uniform for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++) { - if ( (mUniform[i] == -1) - && (LLShaderMgr::instance()->mReservedUniforms[i] == name)) + if (LLShaderMgr::instance()->mReservedUniforms[i] == name) { - //found it - mUniform[i] = location; - mTexture[i] = mapUniformTextureChannel(location, type); - return; + std::pair result; + + result = mUniform.insert(uniforms_index_t::value_type(i, location)); + if (result.second) + { + mTexture[i] = mapUniformTextureChannel(location, type); + return; + } } } @@ -669,13 +672,17 @@ void LLGLSLShader::mapUniform(GLint index, const vector * { for (U32 i = 0; i < uniforms->size(); i++) { - if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1) - && ((*uniforms)[i].String() == name)) + std::pair result; + S32 index = i + LLShaderMgr::instance()->mReservedUniforms.size(); + + if ((*uniforms)[i].String() == name) { - //found it - mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location; - mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type); - return; + result = mUniform.insert(uniforms_index_t::value_type(index, location)); + if (result.second) + { + mTexture[index] = mapUniformTextureChannel(location, type); + return; + } } } } @@ -715,10 +722,6 @@ 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(); @@ -910,20 +913,14 @@ S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LL S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode) { - if (uniform < 0 || uniform >= (S32)mTexture.size()) - { - UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; - return -1; - } - - uniform = mTexture[uniform]; + GLint channel = getTexChannelForIndex(uniform); - if (uniform > -1) + if (channel > -1) { - gGL.getTexUnit(uniform)->bind(texture, mode); + gGL.getTexUnit(channel)->bind(texture, mode); } - return uniform; + return channel; } S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode) @@ -936,82 +933,64 @@ S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureT S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode) { - if (uniform < 0 || uniform >= (S32)mTexture.size()) - { - UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; - return -1; - } - - uniform = mTexture[uniform]; - - if (uniform > -1) + GLint channel = getTexChannelForIndex(uniform); + + if (channel > -1) { - gGL.getTexUnit(uniform)->unbind(mode); + gGL.getTexUnit(channel)->unbind(mode); } - return uniform; + return channel; } S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode) { - 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) + GLint channel = getTexChannelForIndex(uniform); + + if (channel != -1) { - gGL.getTexUnit(index)->activate(); - gGL.getTexUnit(index)->enable(mode); + gGL.getTexUnit(channel)->activate(); + gGL.getTexUnit(channel)->enable(mode); } - return index; + return channel; } S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) { - 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) + GLint channel = getTexChannelForIndex(uniform); + + if (channel != -1 && gGL.getTexUnit(channel)->getCurrType() != LLTexUnit::TT_NONE) { - if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode) + if (gDebugGL && gGL.getTexUnit(channel)->getCurrType() != mode) { if (gDebugSession) { - gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl; + gFailLog << "Texture channel " << channel << " texture type corrupted." << std::endl; ll_fail("LLGLSLShader::disableTexture failed"); } else { - LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL; + LL_ERRS() << "Texture channel " << channel << " texture type corrupted." << LL_ENDL; } } - gGL.getTexUnit(index)->disable(); + gGL.getTexUnit(channel)->disable(); } - return index; + return channel; } void LLGLSLShader::uniform1i(U32 index, GLint x) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); if (iter == mValue.end() || iter->second.mV[0] != x) { - glUniform1iARB(mUniform[index], x); - mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f); + glUniform1iARB(location, x); + mValue[location] = LLVector4(x,0.f,0.f,0.f); } } } @@ -1021,19 +1000,15 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); if (iter == mValue.end() || iter->second.mV[0] != x) { - glUniform1fARB(mUniform[index], x); - mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f); + glUniform1fARB(location, x); + mValue[location] = LLVector4(x,0.f,0.f,0.f); } } } @@ -1043,20 +1018,16 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(x,y,0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec)) { - glUniform2fARB(mUniform[index], x, y); - mValue[mUniform[index]] = vec; + glUniform2fARB(location, x, y); + mValue[location] = vec; } } } @@ -1066,20 +1037,16 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(x,y,z,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec)) { - glUniform3fARB(mUniform[index], x, y, z); - mValue[mUniform[index]] = vec; + glUniform3fARB(location, x, y, z); + mValue[location] = vec; } } } @@ -1089,20 +1056,16 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(x,y,z,w); if (iter == mValue.end() || shouldChange(iter->second,vec)) { - glUniform4fARB(mUniform[index], x, y, z, w); - mValue[mUniform[index]] = vec; + glUniform4fARB(location, x, y, z, w); + mValue[location] = vec; } } } @@ -1112,20 +1075,16 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(v[0],0.f,0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform1ivARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; + glUniform1ivARB(location, count, v); + mValue[location] = vec; } } } @@ -1135,20 +1094,16 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(v[0],0.f,0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform1fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; + glUniform1fvARB(location, count, v); + mValue[location] = vec; } } } @@ -1158,20 +1113,16 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(v[0],v[1],0.f,0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform2fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; + glUniform2fvARB(location, count, v); + mValue[location] = vec; } } } @@ -1181,20 +1132,16 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(v[0],v[1],v[2],0.f); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform3fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; + glUniform3fvARB(location, count, v); + mValue[location] = vec; } } } @@ -1204,20 +1151,16 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - std::map::iterator iter = mValue.find(mUniform[index]); + std::map::iterator iter = mValue.find(location); LLVector4 vec(v[0],v[1],v[2],v[3]); if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1) { - glUniform4fvARB(mUniform[index], count, v); - mValue[mUniform[index]] = vec; + glUniform4fvARB(location, count, v); + mValue[location] = vec; } } } @@ -1227,15 +1170,11 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - glUniformMatrix2fvARB(mUniform[index], count, transpose, v); + glUniformMatrix2fvARB(location, count, transpose, v); } } } @@ -1244,15 +1183,11 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - glUniformMatrix3fvARB(mUniform[index], count, transpose, v); + glUniformMatrix3fvARB(location, count, transpose, v); } } } @@ -1261,15 +1196,11 @@ void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - glUniformMatrix3x4fv(mUniform[index], count, transpose, v); + glUniformMatrix3x4fv(location, count, transpose, v); } } } @@ -1278,15 +1209,11 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c { if (mProgramObject > 0) { - if (mUniform.size() <= index) - { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; - return; - } + GLint location = getLocationForIndex(index); - if (mUniform[index] >= 0) + if (location >= 0) { - glUniformMatrix4fvARB(mUniform[index], count, transpose, v); + glUniformMatrix4fvARB(location, count, transpose, v); } } } @@ -1317,14 +1244,8 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) GLint LLGLSLShader::getUniformLocation(U32 index) { - GLint ret = -1; - if (mProgramObject > 0) - { - llassert(index < mUniform.size()); - return mUniform[index]; - } - - return ret; + /*TODO: flatten this... change calls to gUL(U32) */ + return getLocationForIndex(index); } GLint LLGLSLShader::getAttribLocation(U32 attrib) diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 6f10d122cb..75cb6cf757 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -166,14 +166,20 @@ 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; std::vector mAttribute; //lookup table of attribute enum to attribute channel U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask()) - std::vector mUniform; //lookup table of uniform enum to uniform location + uniforms_index_t mUniform; + uniforms_index_t mTexture; + 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; @@ -197,11 +203,26 @@ public: static U32 sTotalDrawCalls; bool mTextureStateFetched; - std::vector mTextureMagFilter; - std::vector mTextureMinFilter; + magmin_filter_t mTextureMagMinFilter; private: void unloadInternal(); + + inline GLint getLocationForIndex(S32 index) + { + uniforms_index_t::iterator it = mUniform.find(index); + if (it == mUniform.end()) + return -1; + return (*it).second; + } + + inline GLint getTexChannelForIndex(S32 index) + { + 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/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index f3811fffe7..72339b2f51 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -181,6 +181,7 @@ set(viewer_SOURCE_FILES lldrawpoolwlsky.cpp lldynamictexture.cpp llemote.cpp + llenvironment.cpp llenvmanager.cpp llestateinfomodel.cpp lleventnotifier.cpp @@ -803,6 +804,7 @@ set(viewer_HEADER_FILES lldrawpoolwlsky.h lldynamictexture.h llemote.h + llenvironment.h llenvmanager.h llestateinfomodel.h lleventnotifier.h diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 980fe96c2b..41783c8667 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -59,6 +59,8 @@ #include "curl/curl.h" #include "llstreamtools.h" +#include "llenvironment.h" + LLWLParamManager::LLWLParamManager() : //set the defaults for the controls @@ -317,8 +319,9 @@ bool LLWLParamManager::loadPreset(const std::string& path) addParamSet(key, params_data); } - //*RIDER temp code testing conversion old preset to new settings. - //LLSettingsSky::ptr_t test = LLSettingsSky::buildFromLegacyPreset(name, params_data); + //*LAPRAS temp code testing conversion old preset to new settings. + LLSettingsSky::ptr_t test = LLSettingsSky::buildFromLegacyPreset(name, params_data); + LLEnvironment::instance().addSky(test); //test->exportSettings(name); return true; -- cgit v1.2.3 From 150fba7c5cd24ad9ab343e762bfd15032e6a9462 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 21 Sep 2017 15:58:13 -0700 Subject: Still not working. Black Sky. --- indra/newview/lldrawpoolwlsky.cpp | 10 +- indra/newview/llenvironment.cpp | 271 +++++++++++++++++++++++++++++++++++++ indra/newview/llenvironment.h | 81 +++++++++++ indra/newview/llsettingsbase.h | 5 + indra/newview/llsettingssky.cpp | 69 +++++++--- indra/newview/llsettingssky.h | 15 +- indra/newview/llvosky.cpp | 50 +++---- indra/newview/llwlparammanager.cpp | 3 +- indra/newview/llwlparamset.cpp | 20 ++- 9 files changed, 468 insertions(+), 56 deletions(-) create mode 100644 indra/newview/llenvironment.cpp create mode 100644 indra/newview/llenvironment.h diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 309f535c39..e10bc10bc2 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -42,6 +42,8 @@ #include "llface.h" #include "llrender.h" +#include "llenvironment.h" + LLPointer LLDrawPoolWLSky::sCloudNoiseTexture = NULL; LLPointer LLDrawPoolWLSky::sCloudNoiseRawImage = NULL; @@ -190,14 +192,14 @@ void LLDrawPoolWLSky::renderStars(void) const // *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid // clamping and allow the star_alpha param to brighten the stars. - bool error; LLColor4 star_alpha(LLColor4::black); - star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f; + // *LAPRAS + star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 2.f; // If start_brightness is not set, exit - if( error ) + if( star_alpha.mV[3] < 0.001 ) { - LL_WARNS() << "star_brightness missing in mCurParams" << LL_ENDL; + LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL; return; } diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp new file mode 100644 index 0000000000..dec2930970 --- /dev/null +++ b/indra/newview/llenvironment.cpp @@ -0,0 +1,271 @@ +/** + * @file llenvmanager.cpp + * @brief Implementation of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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 "llenvironment.h" + +#include "llagent.h" +#include "lldaycyclemanager.h" +#include "llviewercontrol.h" // for gSavedSettings +#include "llviewerregion.h" +#include "llwaterparammanager.h" +#include "llwlhandlers.h" +#include "llwlparammanager.h" +#include "lltrans.h" +#include "lltrace.h" +#include "llfasttimer.h" +#include "llviewercamera.h" +#include "pipeline.h" + +//========================================================================= +const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg + +namespace +{ + LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); + LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); +} + +//------------------------------------------------------------------------- +LLEnvironment::LLEnvironment(): + mCurrentSky(), + mSkysById(), + mSkysByName() +{ + LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); + addSky(p_default_sky); + mCurrentSky = p_default_sky; +} + +LLEnvironment::~LLEnvironment() +{ +} + +//------------------------------------------------------------------------- +void LLEnvironment::update(const LLViewerCamera * cam) +{ + LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE); + + // update clouds, sun, and general + updateCloudScroll(); + mCurrentSky->update(); + +// // update only if running +// if (mAnimator.getIsRunning()) +// { +// mAnimator.update(mCurParams); +// } + + LLVector3 lightdir = mCurrentSky->getLightDirection(); + // update the shaders and the menu + + F32 camYaw = cam->getYaw(); + + stop_glerror(); + + // *TODO: potential optimization - this block may only need to be + // executed some of the time. For example for water shaders only. + { + LLVector3 lightNorm3(mCurrentSky->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) + { + if ((shaders_iter->mProgramObject != 0) + && (gPipeline.canUseWindLightShaders() + || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) + { + shaders_iter->mUniformsDirty = TRUE; + } + } + } +} + +void LLEnvironment::updateCloudScroll() +{ + // This is a function of the environment rather than the sky, since it should + // persist through sky transitions. + static LLTimer s_cloud_timer; + + F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); + + LLVector2 cloud_delta = static_cast(delta_t) * (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + + mCloudScroll += cloud_delta; + +} + +void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting) +{ + LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE); + + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + LLSettingsBase::parammapping_t params = psetting->getParameterMap(); + for (LLSettingsBase::parammapping_t::iterator it = params.begin(); it != params.end(); ++it) + { + if (!psetting->mSettings.has((*it).first)) + continue; + + LLSD value = psetting->mSettings[(*it).first]; + LLSD::Type setting_type = value.type(); + + stop_glerror(); + switch (setting_type) + { + case LLSD::TypeInteger: + shader->uniform1i((*it).second, value.asInteger()); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + case LLSD::TypeReal: + shader->uniform1f((*it).second, value.asReal()); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + + case LLSD::TypeBoolean: + shader->uniform1i((*it).second, value.asBoolean() ? 1 : 0); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + + case LLSD::TypeArray: + { + LLVector4 vect4(value); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; + shader->uniform4fv((*it).second, 4, vect4.mV); + + break; + } + + // case LLSD::TypeMap: + // case LLSD::TypeString: + // case LLSD::TypeUUID: + // case LLSD::TypeURI: + // case LLSD::TypeBinary: + // case LLSD::TypeDate: + default: + break; + } + stop_glerror(); + } + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + +// psetting->applySpecial(shader); + + if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); + } + else + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); + } + +} + +void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) +{ + + if (gPipeline.canUseWindLightShaders()) + { + updateGLVariablesForSettings(shader, mCurrentSky); + } + + 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, mCurrentSky->getLightDirectionClamped().mV); + stop_glerror(); + } + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->getSceneLightStrength()); + + { + LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); +// val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; +// val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; +// val.mV[2] = (F32)i->second[2].asReal(); +// val.mV[3] = (F32)i->second[3].asReal(); + + stop_glerror(); + shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV); + stop_glerror(); + } + + +} +//-------------------------------------------------------------------------- + +void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) +{ + std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); + + std::pair result; + result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); + + if (!result.second) + (*(result.first)).second = sky; +} + +void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) +{ + // std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); + // + // std::pair result; + // result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); + // + // if (!result.second) + // (*(result.first)).second = sky; +} + +void LLEnvironment::removeSky(const std::string &name) +{ + NamedSkyMap_t::iterator it = mSkysByName.find(name); + if (it != mSkysByName.end()) + mSkysByName.erase(it); +} + +void LLEnvironment::removeSky(const LLUUID &id) +{ + +} + +void LLEnvironment::clearAllSkys() +{ + mSkysByName.clear(); + mSkysById.clear(); +} + diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h new file mode 100644 index 0000000000..bbb5f45ad9 --- /dev/null +++ b/indra/newview/llenvironment.h @@ -0,0 +1,81 @@ +/** + * @file llenvmanager.h + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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_ENVIRONMENT_H +#define LL_ENVIRONMENT_H + +#include "llmemory.h" +#include "llsd.h" + +#include "llsettingssky.h" + +class LLViewerCamera; +class LLGLSLShader; + +//------------------------------------------------------------------------- +class LLEnvironment : public LLSingleton +{ + LLSINGLETON(LLEnvironment); + LOG_CLASS(LLEnvironment); + +public: + virtual ~LLEnvironment(); + + LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } + + void update(const LLViewerCamera * cam); + + LLVector4 getRotatedLightDir() const { return mRotatedLight; } + + void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); + void updateShaderUniforms(LLGLSLShader *shader); + + void addSky(const LLSettingsSky::ptr_t &sky); +private: + static const F32 SUN_DELTA_YAW; + + typedef std::map NamedSkyMap_t; + typedef std::map AssetSkyMap_t; + + LLVector4 mRotatedLight; + LLVector2 mCloudScroll; + + LLSettingsSky::ptr_t mCurrentSky; + + NamedSkyMap_t mSkysByName; + AssetSkyMap_t mSkysById; + + void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + void removeSky(const std::string &name); + void removeSky(const LLUUID &id); + void clearAllSkys(); + + void updateCloudScroll(); +}; + + +#endif // LL_ENVIRONMENT_H + diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index 01a19c8734..cd5098cbb6 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -45,6 +45,8 @@ class LLSettingsBase: private boost::noncopyable friend class LLEnvironment; public: + typedef std::map parammapping_t; + typedef boost::shared_ptr ptr_t; virtual ~LLSettingsBase() { }; @@ -122,6 +124,7 @@ protected: typedef std::set stringset_t; + // combining settings objects. Customize for specific setting types virtual void lerpSettings(const LLSettingsBase &other, F32 mix); @@ -141,6 +144,8 @@ protected: // Apply any settings that need special handling. virtual void applySpecial(void *) { }; + virtual parammapping_t getParameterMap() const { return parammapping_t(); } + LLSD mSettings; private: diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 364c211344..26ed719b3b 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -117,17 +117,17 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam if (oldsettings.has(SETTING_AMBIENT)) { - newsettings[SETTING_AMBIENT] = LLColor3(oldsettings[SETTING_AMBIENT]).getValue(); + newsettings[SETTING_AMBIENT] = LLColor4(oldsettings[SETTING_AMBIENT]).getValue(); } if (oldsettings.has(SETTING_BLUE_DENSITY)) { - newsettings[SETTING_BLUE_DENSITY] = LLColor3(oldsettings[SETTING_BLUE_DENSITY]).getValue(); + newsettings[SETTING_BLUE_DENSITY] = LLColor4(oldsettings[SETTING_BLUE_DENSITY]).getValue(); } if (oldsettings.has(SETTING_BLUE_HORIZON)) { - newsettings[SETTING_BLUE_HORIZON] = LLColor3(oldsettings[SETTING_BLUE_HORIZON]).getValue(); + newsettings[SETTING_BLUE_HORIZON] = LLColor4(oldsettings[SETTING_BLUE_HORIZON]).getValue(); } if (oldsettings.has(SETTING_CLOUD_COLOR)) @@ -188,12 +188,12 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam if (oldsettings.has(SETTING_GLOW)) { - newsettings[SETTING_GLOW] = LLColor3(oldsettings[SETTING_GLOW]).getValue(); + newsettings[SETTING_GLOW] = LLColor4(oldsettings[SETTING_GLOW]).getValue(); } if (oldsettings.has(SETTING_GAMMA)) { - newsettings[SETTING_GAMMA] = LLSD::Real(oldsettings[SETTING_GAMMA][0].asReal()); + newsettings[SETTING_GAMMA] = LLVector4(oldsettings[SETTING_GAMMA]).getValue(); } if (oldsettings.has(SETTING_CLOUD_SCROLL_RATE)) @@ -283,21 +283,21 @@ LLSD LLSettingsSky::defaults() LLQuaternion moonquat = ~sunquat; // Magic constants copied form dfltsetting.xml - dfltsetting[SETTING_AMBIENT] = LLColor3::white.getValue(); - dfltsetting[SETTING_BLUE_DENSITY] = LLColor3(0.2447, 0.4487, 0.7599).getValue(); - dfltsetting[SETTING_BLUE_HORIZON] = LLColor3(0.4954, 0.4954, 0.6399).getValue(); - dfltsetting[SETTING_CLOUD_COLOR] = LLColor3(0.4099, 0.4099, 0.4099).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor3(1.0000, 0.5260, 1.0000).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor3(1.0000, 0.5260, 1.0000).getValue(); + dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue(); + dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 1.0).getValue(); + dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 1.0).getValue(); + dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 1.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 1.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 1.0).getValue(); dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); - dfltsetting[SETTING_CLOUD_SHADOW] = LLColor3(0.2699, 0.0000, 0.0000).getValue(); + 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(1.0); - dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(0.0); - dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0000); - dfltsetting[SETTING_GLOW] = LLColor3(5.000, 0.0010, -0.4799).getValue(); // *RIDER: This is really weird for a color... TODO: check if right. + dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); + dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); + dfltsetting[SETTING_GAMMA] = LLVector4(1.0, 0.0, 0.0, 1.0).getValue(); + dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); // *RIDER: This is really weird for a color... TODO: check if right. dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999); dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899); dfltsetting[SETTING_LIGHT_NORMAL] = LLVector4(0.0000, 0.9126, -0.4086, 0.0000).getValue(); @@ -305,7 +305,7 @@ LLSD LLSettingsSky::defaults() dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); dfltsetting[SETTING_NAME] = std::string("_default_"); dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); - dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor3(0.7342, 0.7815, 0.8999).getValue(); + dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 1.0).getValue(); dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; @@ -468,10 +468,37 @@ void LLSettingsSky::calculateLightSettings() mTotalAmbient.setAlpha(1); mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); + mFadeColor.setAlpha(1); } +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_DENSITY1] = LLShaderMgr::CLOUD_POS_DENSITY1; + 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_GAMMA] = LLShaderMgr::GAMMA; + 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; +} + LLSettingsSky::stringset_t LLSettingsSky::getSkipApplyKeys() const { @@ -480,14 +507,14 @@ LLSettingsSky::stringset_t LLSettingsSky::getSkipApplyKeys() const if (skip_apply_set.empty()) { - skip_apply_set.insert(SETTING_GAMMA); skip_apply_set.insert(SETTING_MOON_ROTATION); skip_apply_set.insert(SETTING_SUN_ROTATION); skip_apply_set.insert(SETTING_NAME); skip_apply_set.insert(SETTING_STAR_BRIGHTNESS); skip_apply_set.insert(SETTING_CLOUD_SCROLL_RATE); skip_apply_set.insert(SETTING_LIGHT_NORMAL); - skip_apply_set.insert(SETTING_CLOUD_POS_DENSITY1); + skip_apply_set.insert(SETTING_DOME_OFFSET); + skip_apply_set.insert(SETTING_DOME_RADIUS); } return skip_apply_set; @@ -505,6 +532,8 @@ void LLSettingsSky::applySpecial(void *ptarget) shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); + + } //------------------------------------------------------------------------- diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 5b8691fa8b..2fb9ff3887 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -161,12 +161,12 @@ public: F32 getGama() const { - return mSettings[SETTING_GAMMA].asReal(); + return mSettings[SETTING_GAMMA][0].asReal(); } LLColor3 getGlow() const { - return mSettings[SETTING_GLOW].asReal(); + return LLColor3(mSettings[SETTING_GLOW]); } F32 getHazeDensity() const @@ -179,6 +179,11 @@ public: return mSettings[SETTING_HAZE_HORIZON].asReal(); } + LLVector3 getLightNormal() const + { + return LLVector3(mSettings[SETTING_LIGHT_NORMAL]); + } + F32 getMaxY() const { return mSettings[SETTING_MAX_Y].asReal(); @@ -289,6 +294,8 @@ protected: virtual void updateSettings(); + virtual parammapping_t getParameterMap() const; + virtual stringset_t getSkipApplyKeys() const; virtual void applySpecial(void *); @@ -309,6 +316,10 @@ private: LLColor4 mTotalAmbient; LLColor4 mFadeColor; + + typedef std::map mapNameToUniformId_t; + + static mapNameToUniformId_t sNameToUniformMapping; }; #endif diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 03dfdf92fa..ce956b7fda 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -52,6 +52,9 @@ #include "llwaterparammanager.h" #include "v3colorutil.h" +#include "llsettingssky.h" +#include "llenvironment.h" + #undef min #undef max @@ -327,8 +330,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mWorldScale(1.f), mBumpSunDir(0.f, 0.f, 1.f) { - bool error = false; - /// WL PARAMS dome_radius = 1.f; dome_offset_ratio = 0.f; @@ -367,7 +368,9 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mAtmHeight = ATM_HEIGHT; mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); - mSunDefaultPosition = LLVector3(LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error)); + // *LAPRAS + mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getLightNormal(); + if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) { initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); @@ -563,27 +566,28 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile) void LLVOSky::initAtmospherics(void) { - bool error; - // uniform parameters for convenience - dome_radius = LLWLParamManager::getInstance()->getDomeRadius(); - dome_offset_ratio = LLWLParamManager::getInstance()->getDomeOffset(); - sunlight_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("sunlight_color", error)); - ambient = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("ambient", error)); - //lightnorm = LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error); - gamma = LLWLParamManager::getInstance()->mCurParams.getFloat("gamma", error); - blue_density = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_density", error)); - blue_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_horizon", error)); - haze_density = LLWLParamManager::getInstance()->mCurParams.getFloat("haze_density", error); - haze_horizon = LLWLParamManager::getInstance()->mCurParams.getFloat("haze_horizon", error); - density_multiplier = LLWLParamManager::getInstance()->mCurParams.getFloat("density_multiplier", error); - max_y = LLWLParamManager::getInstance()->mCurParams.getFloat("max_y", error); - glow = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("glow", error)); - cloud_shadow = LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_shadow", error); - cloud_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_color", error)); - cloud_scale = LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_scale", error); - cloud_pos_density1 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density1", error)); - cloud_pos_density2 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density2", error)); + // *LAPRAS + // uniform parameters for convenience + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); + + dome_radius = sky->getDomeRadius(); + dome_offset_ratio = sky->getDomeOffset(); + sunlight_color = sky->getSunlightColor(); + ambient = sky->getAmbientColor(); + gamma = sky->getGama(); + blue_density = sky->getBlueDensity(); + blue_horizon = sky->getBlueHorizon(); + haze_density = sky->getHazeDensity(); + haze_horizon = sky->getHazeHorizon(); + density_multiplier = sky->getDensityMultiplier(); + max_y = sky->getMaxY(); + glow = sky->getGlow(); + cloud_shadow = sky->getCloudShadow(); + cloud_color = sky->getCloudColor(); + cloud_scale = sky->getCloudScale(); + cloud_pos_density1 = sky->getCloudPosDensity1(); + cloud_pos_density2 = sky->getCloudPosDensity2(); // light norm is different. We need the sun's direction, not the light direction // which could be from the moon. And we need to clamp it diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 41783c8667..de2d3bc41d 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -351,7 +351,8 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (gPipeline.canUseWindLightShaders()) { - mCurParams.update(shader); + LLEnvironment::instance().updateGLVariablesForSettings(shader, LLEnvironment::instance().getCurrentSky()); + //mCurParams.update(shader); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index 066cb9a0ac..a2ff2c0c95 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -65,6 +65,8 @@ static LLTrace::BlockTimerStatHandle FTM_WL_PARAM_UPDATE("WL Param Update"); void LLWLParamSet::update(LLGLSLShader * shader) const { LL_RECORD_BLOCK_TIME(FTM_WL_PARAM_UPDATE); + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + LLSD::map_const_iterator i = mParamValues.beginMap(); std::vector::const_iterator n = mParamHashedNames.begin(); for(;(i != mParamValues.endMap()) && (n != mParamHashedNames.end());++i, n++) @@ -91,7 +93,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const val.mV[3] = (F32) i->second[3].asReal(); stop_glerror(); - shader->uniform4fv(param, 1, val.mV); + //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; + shader->uniform4fv(param, 1, val.mV); stop_glerror(); } else if (param == sCloudScale || param == sCloudShadow || @@ -102,7 +105,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const F32 val = (F32) i->second[0].asReal(); stop_glerror(); - shader->uniform1f(param, val); + //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; + shader->uniform1f(param, val); stop_glerror(); } else // param is the uniform name @@ -118,7 +122,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const val.mV[3] = (F32) i->second[3].asReal(); stop_glerror(); - shader->uniform4fv(param, 1, val.mV); + //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; + shader->uniform4fv(param, 1, val.mV); stop_glerror(); } else if (i->second.isReal()) @@ -126,7 +131,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const F32 val = (F32) i->second.asReal(); stop_glerror(); - shader->uniform1f(param, val); + //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; + shader->uniform1f(param, val); stop_glerror(); } else if (i->second.isInteger()) @@ -134,7 +140,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const S32 val = (S32) i->second.asInteger(); stop_glerror(); - shader->uniform1i(param, val); + //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; + shader->uniform1i(param, val); stop_glerror(); } else if (i->second.isBoolean()) @@ -142,7 +149,8 @@ void LLWLParamSet::update(LLGLSLShader * shader) const S32 val = (i->second.asBoolean() ? 1 : 0); stop_glerror(); - shader->uniform1i(param, val); + //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; + shader->uniform1i(param, val); stop_glerror(); } } -- cgit v1.2.3 From 0d414c1fb579dffc122c4d021a84cd126c612e54 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 26 Sep 2017 09:19:20 -0700 Subject: Clouds still funky but better. --- indra/llmath/v4math.h | 19 +++++++++++++ indra/llrender/llglslshader.cpp | 2 +- indra/llrender/llshadermgr.cpp | 3 +- indra/newview/llenvironment.cpp | 41 +++++++++++++++++---------- indra/newview/llenvironment.h | 5 +++- indra/newview/llsettingsbase.h | 1 - indra/newview/llsettingssky.cpp | 56 +++++++++++++++++-------------------- indra/newview/llsettingssky.h | 5 ++-- indra/newview/llviewerdisplay.cpp | 6 +++- indra/newview/llviewershadermgr.cpp | 4 ++- indra/newview/llwlparammanager.cpp | 4 +-- 11 files changed, 89 insertions(+), 57 deletions(-) diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index 293005a627..3f6d480ed9 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -30,6 +30,7 @@ #include "llerror.h" #include "llmath.h" #include "v3math.h" +#include "v2math.h" class LLMatrix3; class LLMatrix4; @@ -46,6 +47,8 @@ class LLVector4 LLVector4(); // Initializes LLVector4 to (0, 0, 0, 1) explicit LLVector4(const F32 *vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2], vec[3]) explicit LLVector4(const F64 *vec); // Initialized LLVector4 to ((F32) vec[0], (F32) vec[1], (F32) vec[3], (F32) vec[4]); + explicit LLVector4(const LLVector2 &vec); + explicit LLVector4(const LLVector2 &vec, F32 z, F32 w); explicit LLVector4(const LLVector3 &vec); // Initializes LLVector4 to (vec, 1) explicit LLVector4(const LLVector3 &vec, F32 w); // Initializes LLVector4 to (vec, w) explicit LLVector4(const LLSD &sd); @@ -185,6 +188,22 @@ inline LLVector4::LLVector4(const F64 *vec) mV[VW] = (F32) vec[VW]; } +inline LLVector4::LLVector4(const LLVector2 &vec) +{ + mV[VX] = vec[VX]; + mV[VY] = vec[VY]; + mV[VZ] = 0.f; + mV[VW] = 0.f; +} + +inline LLVector4::LLVector4(const LLVector2 &vec, F32 z, F32 w) +{ + mV[VX] = vec[VX]; + mV[VY] = vec[VY]; + mV[VZ] = z; + mV[VW] = w; +} + inline LLVector4::LLVector4(const LLVector3 &vec) { mV[VX] = vec.mV[VX]; diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index e7457826a3..bba94a976f 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -406,7 +406,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 << LL_ENDL; + LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << " shaderhandle=" << shaderhandle << LL_ENDL; if (shaderhandle) { attachObject(shaderhandle); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e721ad93fa..4e9a1f5de5 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -953,7 +953,8 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade // Add shader file to map mShaderObjects[filename] = ret; shader_level = try_gpu_class; - } + LL_WARNS("RIDER") << "Shader '" << filename << "' loaded with handle=" << ret << LL_ENDL; + } else { if (shader_level > 1) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index dec2930970..84a1f2c1ab 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -117,9 +117,20 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - LLVector2 cloud_delta = static_cast(delta_t) * (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + mCloudScrollDelta += cloud_delta; + +// { +// LLVector2 v2(mCurrentSky->getCloudScrollRate()); +// static F32 xoffset(0.f); +// static F32 yoffset(0.f); +// +// xoffset += F32(delta_t * (v2[0] - 10.f) / 100.f); +// yoffset += F32(delta_t * (v2[1] - 10.f) / 100.f); +// +// LL_WARNS("RIDER") << "offset " << mCloudScrollDelta << " vs (" << xoffset << ", " << yoffset << ")" << LL_ENDL; +// } - mCloudScroll += cloud_delta; } @@ -158,7 +169,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS { LLVector4 vect4(value); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv((*it).second, 4, vect4.mV); + shader->uniform4fv((*it).second, 1, vect4.mV); break; } @@ -176,7 +187,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS } //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; -// psetting->applySpecial(shader); + psetting->applySpecial(shader); if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) { @@ -213,17 +224,17 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->getSceneLightStrength()); - { - LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); -// val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; -// val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; -// val.mV[2] = (F32)i->second[2].asReal(); -// val.mV[3] = (F32)i->second[3].asReal(); - - stop_glerror(); - shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV); - stop_glerror(); - } +// { +// LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); +// // val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; +// // val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; +// // val.mV[2] = (F32)i->second[2].asReal(); +// // val.mV[3] = (F32)i->second[3].asReal(); +// +// stop_glerror(); +// shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV); +// stop_glerror(); +// } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index bbb5f45ad9..3a834963f3 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -54,6 +54,9 @@ public: void updateShaderUniforms(LLGLSLShader *shader); void addSky(const LLSettingsSky::ptr_t &sky); + + inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } + private: static const F32 SUN_DELTA_YAW; @@ -61,7 +64,7 @@ private: typedef std::map AssetSkyMap_t; LLVector4 mRotatedLight; - LLVector2 mCloudScroll; + LLVector2 mCloudScrollDelta; // cumulative cloud delta LLSettingsSky::ptr_t mCurrentSky; diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index cd5098cbb6..142b74caf9 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -140,7 +140,6 @@ protected: // Calculate any custom settings that may need to be cached. virtual void updateSettings() { mDirty = false; }; - virtual stringset_t getSkipApplyKeys() const { return stringset_t(); } // Apply any settings that need special handling. virtual void applySpecial(void *) { }; diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 26ed719b3b..1d71140430 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -37,6 +37,7 @@ #include "llglslshader.h" #include "llviewershadermgr.h" +#include "llenvironment.h" #include "llsky.h" //========================================================================= @@ -482,7 +483,7 @@ LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const 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_DENSITY1] = LLShaderMgr::CLOUD_POS_DENSITY1; + 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; @@ -499,44 +500,37 @@ LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const return param_map; } - -LLSettingsSky::stringset_t LLSettingsSky::getSkipApplyKeys() const -{ - - static stringset_t skip_apply_set; - - if (skip_apply_set.empty()) - { - skip_apply_set.insert(SETTING_MOON_ROTATION); - skip_apply_set.insert(SETTING_SUN_ROTATION); - skip_apply_set.insert(SETTING_NAME); - skip_apply_set.insert(SETTING_STAR_BRIGHTNESS); - skip_apply_set.insert(SETTING_CLOUD_SCROLL_RATE); - skip_apply_set.insert(SETTING_LIGHT_NORMAL); - skip_apply_set.insert(SETTING_DOME_OFFSET); - skip_apply_set.insert(SETTING_DOME_RADIUS); - } - - return skip_apply_set; -} - void LLSettingsSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - if (shader->mShaderGroup == LLGLSLShader::SG_SKY) - { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); - } + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); + { + //LLEnvironment::instance().getCloudDelta(); + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + } -} +// { +// LLVector4 val(mSettings[ ]; +// val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; +// val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; +// val.mV[2] = (F32)i->second[2].asReal(); +// val.mV[3] = (F32)i->second[3].asReal(); +// +// stop_glerror(); +// //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; +// shader->uniform4fv(param, 1, val.mV); +// stop_glerror(); +// +// } -//------------------------------------------------------------------------- -// const std::string LLSettingsSky::SETTING_DENSITY_MULTIPLIER("density_multiplier"); -// const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); -// const std::string LLSettingsSky::SETTING_NAME("name"); + //param_map[SETTING_CLOUD_POS_DENSITY1] = LLShaderMgr::CLOUD_POS_DENSITY1; + +} diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 2fb9ff3887..4e333f0584 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -116,12 +116,12 @@ public: LLColor3 getCloudPosDensity1() const { - return mSettings[SETTING_CLOUD_POS_DENSITY1].asReal(); + return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); } LLColor3 getCloudPosDensity2() const { - return mSettings[SETTING_CLOUD_POS_DENSITY2].asReal(); + return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); } F32 getCloudScale() const @@ -296,7 +296,6 @@ protected: virtual parammapping_t getParameterMap() const; - virtual stringset_t getSkipApplyKeys() const; virtual void applySpecial(void *); private: diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index e53db403e1..d810d7077b 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -79,6 +79,8 @@ #include "llpostprocess.h" #include "llscenemonitor.h" +#include "llenvironment.h" + extern LLPointer gStartTexture; extern bool gShiftFrame; @@ -200,7 +202,9 @@ void display_update_camera() gViewerWindow->setup3DRender(); // update all the sky/atmospheric/water settings - LLWLParamManager::getInstance()->update(LLViewerCamera::getInstance()); + // *LAPRAS + //LLWLParamManager::getInstance()->update(LLViewerCamera::getInstance()); + LLEnvironment::instance().update(LLViewerCamera::getInstance()); LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance()); // Update land visibility too diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8adc86b423..313cdaa500 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -45,6 +45,7 @@ #include "llrender.h" #include "lljoint.h" #include "llskinningutil.h" +#include "llenvironment.h" #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") @@ -3430,7 +3431,8 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { //*LAPRAS*/ - LLWLParamManager::getInstance()->updateShaderUniforms(shader); + LLEnvironment::instance().updateShaderUniforms(shader); + //LLWLParamManager::getInstance()->updateShaderUniforms(shader); LLWaterParamManager::getInstance()->updateShaderUniforms(shader); } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index de2d3bc41d..b6e1c36a33 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -351,8 +351,8 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (gPipeline.canUseWindLightShaders()) { - LLEnvironment::instance().updateGLVariablesForSettings(shader, LLEnvironment::instance().getCurrentSky()); - //mCurParams.update(shader); + //LLEnvironment::instance().updateGLVariablesForSettings(shader, LLEnvironment::instance().getCurrentSky()); + mCurParams.update(shader); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) -- cgit v1.2.3 From 52b0d4173cec0f643f37d426aef8f5ab1fdf3232 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 27 Sep 2017 09:36:26 -0700 Subject: No longer 'goth windlight only', sky parameters passed from settings object. --- indra/llmath/v3colorutil.h | 20 ++++ indra/newview/llappviewer.cpp | 1 - indra/newview/lldrawpoolwlsky.cpp | 9 +- indra/newview/llenvironment.cpp | 22 +++- indra/newview/llenvironment.h | 9 ++ indra/newview/llfloaterenvironmentsettings.cpp | 6 +- indra/newview/llsettingssky.cpp | 144 ++++++++++++++----------- indra/newview/llsettingssky.h | 7 -- indra/newview/llviewerdisplay.cpp | 2 - indra/newview/llviewershadermgr.cpp | 3 - indra/newview/llvosky.cpp | 2 +- indra/newview/llvosky.h | 21 +--- indra/newview/llvowlsky.cpp | 11 +- indra/newview/llwaterparammanager.cpp | 10 +- indra/newview/pipeline.cpp | 1 - 15 files changed, 153 insertions(+), 115 deletions(-) diff --git a/indra/llmath/v3colorutil.h b/indra/llmath/v3colorutil.h index 00b36132d8..6d8cd9329b 100644 --- a/indra/llmath/v3colorutil.h +++ b/indra/llmath/v3colorutil.h @@ -91,5 +91,25 @@ inline LLColor3 smear(F32 val) return LLColor3(val, val, val); } +inline F32 color_intens(const LLColor3 &col) +{ + return col.mV[0] + col.mV[1] + col.mV[2]; +} + +inline F32 color_max(const LLColor3 &col) +{ + return llmax(col.mV[0], col.mV[1], col.mV[2]); +} + +inline F32 color_max(const LLColor4 &col) +{ + return llmax(col.mV[0], col.mV[1], col.mV[2]); +} + + +inline F32 color_min(const LLColor3 &col) +{ + return llmin(col.mV[0], col.mV[1], col.mV[2]); +} #endif diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 9bab572b68..529bd429a4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -170,7 +170,6 @@ #include "llviewerparcelmgr.h" #include "llworldmapview.h" #include "llpostprocess.h" -#include "llwlparammanager.h" #include "llwaterparammanager.h" #include "lldebugview.h" diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index e10bc10bc2..2ff4edabe3 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -33,7 +33,6 @@ #include "pipeline.h" #include "llviewercamera.h" #include "llimage.h" -#include "llwlparammanager.h" #include "llviewershadermgr.h" #include "llglslshader.h" #include "llsky.h" @@ -83,7 +82,8 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) : } } - LLWLParamManager::getInstance()->propagateParameters(); + /* *LAPRAS */ +// LLWLParamManager::getInstance()->propagateParameters(); } LLDrawPoolWLSky::~LLDrawPoolWLSky() @@ -312,7 +312,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) } LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); - const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); + + const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); LLGLSNoFog disableFog; LLGLDepthTest depth(GL_TRUE, GL_FALSE); @@ -359,7 +360,7 @@ void LLDrawPoolWLSky::render(S32 pass) } LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); - const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); + const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); LLGLSNoFog disableFog; LLGLDepthTest depth(GL_TRUE, GL_FALSE); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 84a1f2c1ab..ceba7fda88 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -34,7 +34,6 @@ #include "llviewerregion.h" #include "llwaterparammanager.h" #include "llwlhandlers.h" -#include "llwlparammanager.h" #include "lltrans.h" #include "lltrace.h" #include "llfasttimer.h" @@ -65,6 +64,12 @@ LLEnvironment::~LLEnvironment() { } +//------------------------------------------------------------------------- +F32 LLEnvironment::getCamHeight() const +{ + return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -222,7 +227,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) stop_glerror(); } - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->getSceneLightStrength()); + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); // { // LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); @@ -244,6 +249,8 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) { std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); + LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; + std::pair result; result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); @@ -280,3 +287,14 @@ void LLEnvironment::clearAllSkys() mSkysById.clear(); } +void LLEnvironment::selectSky(const std::string &name) +{ + NamedSkyMap_t::iterator it = mSkysByName.find(name); + + if (it == mSkysByName.end()) + return; + + mCurrentSky = (*it).second; + mCurrentSky->setDirtyFlag(true); +} + diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 3a834963f3..0e8f39b4bf 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -54,9 +54,16 @@ public: void updateShaderUniforms(LLGLSLShader *shader); void addSky(const LLSettingsSky::ptr_t &sky); + void selectSky(const std::string &name); inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } + F32 getCamHeight() const; + + inline F32 getSceneLightStrength() const { return mSceneLightStrength; } + inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } + + private: static const F32 SUN_DELTA_YAW; @@ -71,6 +78,8 @@ private: NamedSkyMap_t mSkysByName; AssetSkyMap_t mSkysById; + F32 mSceneLightStrength; + void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); void removeSky(const LLUUID &id); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 4dbc8cdee0..3a059e92dc 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -37,6 +37,8 @@ #include "llwlparamset.h" #include "llwlparammanager.h" +#include "llenvironment.h" + LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key) : LLFloater(key) ,mRegionSettingsRadioGroup(NULL) @@ -188,7 +190,9 @@ void LLFloaterEnvironmentSettings::apply() { if (use_fixed_sky) { - env_mgr.useSkyPreset(sky_preset); + /* LAPRAS */ + //env_mgr.useSkyPreset(sky_preset); + LLEnvironment::instance().selectSky(sky_preset); } else { diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 1d71140430..191ca2d2ec 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -48,8 +48,11 @@ namespace LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params"); LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); + } + //========================================================================= const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); const std::string LLSettingsSky::SETTING_BLOOM_TEXTUREID("bloom_id"); @@ -112,38 +115,27 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) { - LLSD newsettings(LLSD::emptyMap()); + LLSD newsettings(defaults()); newsettings[SETTING_NAME] = name; + if (oldsettings.has(SETTING_AMBIENT)) { newsettings[SETTING_AMBIENT] = LLColor4(oldsettings[SETTING_AMBIENT]).getValue(); } - if (oldsettings.has(SETTING_BLUE_DENSITY)) { newsettings[SETTING_BLUE_DENSITY] = LLColor4(oldsettings[SETTING_BLUE_DENSITY]).getValue(); } - if (oldsettings.has(SETTING_BLUE_HORIZON)) { newsettings[SETTING_BLUE_HORIZON] = LLColor4(oldsettings[SETTING_BLUE_HORIZON]).getValue(); } - if (oldsettings.has(SETTING_CLOUD_COLOR)) { newsettings[SETTING_CLOUD_COLOR] = LLColor4(oldsettings[SETTING_CLOUD_COLOR]).getValue(); } - if (oldsettings.has(SETTING_SUNLIGHT_COLOR)) - { - newsettings[SETTING_SUNLIGHT_COLOR] = LLColor4(oldsettings[SETTING_SUNLIGHT_COLOR]).getValue(); - } - if (oldsettings.has(SETTING_CLOUD_SHADOW)) - { - newsettings[SETTING_CLOUD_SHADOW] = LLSD::Real(oldsettings[SETTING_CLOUD_SHADOW][0].asReal()); - } - if (oldsettings.has(SETTING_CLOUD_POS_DENSITY1)) { newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor4(oldsettings[SETTING_CLOUD_POS_DENSITY1]).getValue(); @@ -152,16 +144,29 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam { newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor4(oldsettings[SETTING_CLOUD_POS_DENSITY2]).getValue(); } - if (oldsettings.has(SETTING_LIGHT_NORMAL)) - { - newsettings[SETTING_LIGHT_NORMAL] = LLVector4(oldsettings[SETTING_LIGHT_NORMAL]).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()); @@ -170,6 +175,14 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam { newsettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(oldsettings[SETTING_DISTANCE_MULTIPLIER][0].asReal()); } + if (oldsettings.has(SETTING_GAMMA)) + { + newsettings[SETTING_GAMMA] = LLVector4(oldsettings[SETTING_GAMMA]).getValue(); + } + if (oldsettings.has(SETTING_GLOW)) + { + newsettings[SETTING_GLOW] = LLColor4(oldsettings[SETTING_GLOW]).getValue(); + } if (oldsettings.has(SETTING_HAZE_DENSITY)) { newsettings[SETTING_HAZE_DENSITY] = LLSD::Real(oldsettings[SETTING_HAZE_DENSITY][0].asReal()); @@ -178,6 +191,10 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam { newsettings[SETTING_HAZE_HORIZON] = LLSD::Real(oldsettings[SETTING_HAZE_HORIZON][0].asReal()); } + if (oldsettings.has(SETTING_LIGHT_NORMAL)) + { + newsettings[SETTING_LIGHT_NORMAL] = LLVector4(oldsettings[SETTING_LIGHT_NORMAL]).getValue(); + } if (oldsettings.has(SETTING_MAX_Y)) { newsettings[SETTING_MAX_Y] = LLSD::Real(oldsettings[SETTING_MAX_Y][0].asReal()); @@ -186,55 +203,29 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam { newsettings[SETTING_STAR_BRIGHTNESS] = LLSD::Real(oldsettings[SETTING_STAR_BRIGHTNESS].asReal()); } - - if (oldsettings.has(SETTING_GLOW)) - { - newsettings[SETTING_GLOW] = LLColor4(oldsettings[SETTING_GLOW]).getValue(); - } - - if (oldsettings.has(SETTING_GAMMA)) + if (oldsettings.has(SETTING_SUNLIGHT_COLOR)) { - newsettings[SETTING_GAMMA] = LLVector4(oldsettings[SETTING_GAMMA]).getValue(); + newsettings[SETTING_SUNLIGHT_COLOR] = LLColor4(oldsettings[SETTING_SUNLIGHT_COLOR]).getValue(); } - 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(); - } +// dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); +// dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); +// +// dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); +// dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); +// +// dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; +// dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; +// dfltsetting[SETTING_MOON_TEXTUREID] = IMG_SUN; // gMoonTextureID; // These two are returned by the login... wow! +// dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_MOON; // gSunTextureID; if (oldsettings.has(SETTING_LEGACY_EAST_ANGLE) && oldsettings.has(SETTING_LEGACY_SUN_ANGLE)) { // convert the east and sun angles into a quaternion. - F32 east = oldsettings[SETTING_LEGACY_EAST_ANGLE].asReal(); - F32 azimuth = oldsettings[SETTING_LEGACY_SUN_ANGLE].asReal(); - - LLQuaternion sunquat; - sunquat.setEulerAngles(azimuth, 0.0, east); -// // set the sun direction from SunAngle and EastAngle -// F32 sinTheta = sin(east); -// F32 cosTheta = cos(east); -// -// F32 sinPhi = sin(azimuth); -// F32 cosPhi = cos(azimuth); -// -// LLVector4 sunDir; -// sunDir.mV[0] = -sinTheta * cosPhi; -// sunDir.mV[1] = sinPhi; -// sunDir.mV[2] = cosTheta * cosPhi; -// sunDir.mV[3] = 0; -// -// LLQuaternion sunquat = LLQuaternion(0.1, sunDir); // small rotation around axis + 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 = ~sunquat; newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); @@ -252,7 +243,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildDefaultSky() LLSD settings = LLSettingsSky::defaults(); LLSettingsSky::ptr_t skyp = boost::make_shared(settings); - skyp->update(); + //skyp->update(); return skyp; } @@ -458,7 +449,7 @@ void LLSettingsSky::calculateLightSettings() // between sunlight and point lights in windlight to normalize point lights. F32 sun_dynamic_range = std::max(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + LLEnvironment::instance().setSceneLightStrength(2.0f * (1.0f + sun_dynamic_range * dp)); mSunDiffuse = vary_SunlightColor; mSunAmbient = vary_AmbientColor; @@ -506,8 +497,6 @@ void LLSettingsSky::applySpecial(void *ptarget) shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); { @@ -534,3 +523,30 @@ void LLSettingsSky::applySpecial(void *ptarget) //param_map[SETTING_CLOUD_POS_DENSITY1] = LLShaderMgr::CLOUD_POS_DENSITY1; } + +//========================================================================= +namespace +{ + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) + { + static const LLVector3 VECT_ZENITH(0.f, 0.f, 1.f); + static const LLVector3 VECT_NORTHSOUTH(0.f, 1.f, 0.f); + + // 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); + + + LL_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL; + + return body_quat; + } +} diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 4e333f0584..b3ac3c2ac9 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -233,12 +233,6 @@ public: return mLightDirectionClamped; }; - F32 getSceneLightStrength() const - { - update(); - return mSceneLightStrength; - } - LLVector3 getSunDirection() const { update(); @@ -304,7 +298,6 @@ private: LLVector3 mSunDirection; LLVector3 mMoonDirection; - F32 mSceneLightStrength; LLVector3 mLightDirection; LLVector3 mLightDirectionClamped; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index d810d7077b..dcf42a201b 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -202,8 +202,6 @@ void display_update_camera() gViewerWindow->setup3DRender(); // update all the sky/atmospheric/water settings - // *LAPRAS - //LLWLParamManager::getInstance()->update(LLViewerCamera::getInstance()); LLEnvironment::instance().update(LLViewerCamera::getInstance()); LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance()); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 313cdaa500..683ff7558a 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -38,7 +38,6 @@ #include "llviewercontrol.h" #include "pipeline.h" #include "llworld.h" -#include "llwlparammanager.h" #include "llwaterparammanager.h" #include "llsky.h" #include "llvosky.h" @@ -3430,9 +3429,7 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { - //*LAPRAS*/ LLEnvironment::instance().updateShaderUniforms(shader); - //LLWLParamManager::getInstance()->updateShaderUniforms(shader); LLWaterParamManager::getInstance()->updateShaderUniforms(shader); } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index ce956b7fda..dc6e6e9e45 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -962,7 +962,7 @@ void LLVOSky::calcAtmospherics(void) // 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); - LLWLParamManager::getInstance()->mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + LLEnvironment::instance().setSceneLightStrength(2.0f * (1.0f + sun_dynamic_range * dp)); mSunDiffuse = vary_SunlightColor; mSunAmbient = vary_AmbientColor; diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 9cfb9773bd..c865e8701c 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -33,6 +33,7 @@ #include "llviewertexture.h" #include "llviewerobject.h" #include "llframetimer.h" +#include "v3colorutil.h" ////////////////////////////////// @@ -85,26 +86,6 @@ BOOL clip_quad_to_horizon(F32& t_left, F32& t_right, LLVector3 v_clipped[4], const LLVector3 v_corner[4], const F32 cos_max_angle); F32 clip_side_to_horizon(const LLVector3& v0, const LLVector3& v1, const F32 cos_max_angle); -inline F32 color_intens ( const LLColor3 &col ) -{ - return col.mV[0] + col.mV[1] + col.mV[2]; -} - -inline F32 color_max(const LLColor3 &col) -{ - return llmax(col.mV[0], col.mV[1], col.mV[2]); -} - -inline F32 color_max(const LLColor4 &col) -{ - return llmax(col.mV[0], col.mV[1], col.mV[2]); -} - - -inline F32 color_min(const LLColor3 &col) -{ - return llmin(col.mV[0], col.mV[1], col.mV[2]); -} class LLFace; class LLHaze; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 16130b5ca7..aff155637e 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -32,8 +32,9 @@ #include "llsky.h" #include "lldrawpoolwlsky.h" #include "llface.h" -#include "llwlparammanager.h" #include "llviewercontrol.h" +#include "llenvironment.h" +#include "llsettingssky.h" #define DOME_SLICES 1 const F32 LLVOWLSky::DISTANCE_TO_STARS = (HORIZON_DIST - 10.f)*0.25f; @@ -232,7 +233,7 @@ void subdivide(LLVertexBuffer& in, LLVertexBuffer* ret) void chop(LLVertexBuffer& in, LLVertexBuffer* out) { //chop off all triangles below horizon - F32 d = LLWLParamManager::sParamMgr->getDomeOffset() * LLWLParamManager::sParamMgr->getDomeRadius(); + F32 d = LLEnvironment::instance().getCamHeight(); std::vector vert; @@ -399,7 +400,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) #else mStripsVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); - const F32 RADIUS = LLWLParamManager::sParamMgr->getDomeRadius(); + const F32 RADIUS = LLEnvironment::getCurrentSky()->getDomeRadius(); LLPointer temp = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, 0); temp->allocateBuffer(12, 60, TRUE); @@ -574,7 +575,7 @@ void LLVOWLSky::buildFanBuffer(LLStrider & vertices, LLStrider & texCoords, LLStrider & indices) { - const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); + const F32 RADIUS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); U32 i, num_slices; F32 phi0, theta, x0, y0, z0; @@ -635,7 +636,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, LLStrider & texCoords, LLStrider & indices) { - const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); + const F32 RADIUS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); U32 i, j, num_slices, num_stacks; F32 phi0, theta, x0, y0, z0; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index b484b6d709..689296a53a 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -52,7 +52,7 @@ #include "llagentcamera.h" #include "llviewerregion.h" -#include "llwlparammanager.h" +#include "llenvironment.h" #include "llwaterparamset.h" #include "curl/curl.h" @@ -187,8 +187,8 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); -shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLightDir().mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, getFogDensity()); @@ -207,7 +207,9 @@ void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate) if (interpolate) { - LLWLParamManager::getInstance()->mAnimator.startInterpolation(params); + // *LAPRAS + + //LLWLParamManager::getInstance()->mAnimator.startInterpolation(params); } else { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c38dafee53..fb2e27d492 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -100,7 +100,6 @@ #include "llviewerstats.h" #include "llviewerjoystick.h" #include "llviewerdisplay.h" -#include "llwlparammanager.h" #include "llwaterparammanager.h" #include "llspatialpartition.h" #include "llmutelist.h" -- cgit v1.2.3 From b8541cddccaa86e90ed9b072b620dcd4ba1acd20 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 27 Sep 2017 09:47:12 -0700 Subject: Fix a conversion. --- indra/newview/llsettingssky.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index b3ac3c2ac9..f6d1087442 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -106,7 +106,7 @@ public: LLColor3 getCloudColor() const { - return mSettings[SETTING_CLOUD_COLOR].asReal(); + return LLColor3(mSettings[SETTING_CLOUD_COLOR]); } LLUUID getCloudNoiseTextureId() const -- cgit v1.2.3 From 23916be3dac32beebb17e0b9336b34176265783d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 29 Sep 2017 16:46:39 -0700 Subject: Moon is showing, sun still not working. --- indra/newview/llenvironment.cpp | 28 +-- indra/newview/llenvironment.h | 7 +- indra/newview/llsettingssky.cpp | 34 ++- indra/newview/llsettingssky.h | 55 ++++- indra/newview/llvosky.cpp | 416 ++++++++++++++++++---------------- indra/newview/llvosky.h | 34 +-- indra/newview/llwaterparammanager.cpp | 2 +- 7 files changed, 314 insertions(+), 262 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ceba7fda88..4192da450e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -85,7 +85,7 @@ void LLEnvironment::update(const LLViewerCamera * cam) // mAnimator.update(mCurParams); // } - LLVector3 lightdir = mCurrentSky->getLightDirection(); + //LLVector3 lightdir = mCurrentSky->getLightDirection(); // update the shaders and the menu F32 camYaw = cam->getYaw(); @@ -95,7 +95,7 @@ void LLEnvironment::update(const LLViewerCamera * cam) // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { - LLVector3 lightNorm3(mCurrentSky->getLightDirection()); + LLVector3 lightNorm3( getLightDirection() ); lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f)); mRotatedLight = LLVector4(lightNorm3, 0.f); @@ -125,16 +125,6 @@ void LLEnvironment::updateCloudScroll() LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; -// { -// LLVector2 v2(mCurrentSky->getCloudScrollRate()); -// static F32 xoffset(0.f); -// static F32 yoffset(0.f); -// -// xoffset += F32(delta_t * (v2[0] - 10.f) / 100.f); -// yoffset += F32(delta_t * (v2[1] - 10.f) / 100.f); -// -// LL_WARNS("RIDER") << "offset " << mCloudScrollDelta << " vs (" << xoffset << ", " << yoffset << ")" << LL_ENDL; -// } } @@ -223,24 +213,12 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) { stop_glerror(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mCurrentSky->getLightDirectionClamped().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); stop_glerror(); } shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); -// { -// LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); -// // val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; -// // val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; -// // val.mV[2] = (F32)i->second[2].asReal(); -// // val.mV[3] = (F32)i->second[3].asReal(); -// -// stop_glerror(); -// shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV); -// stop_glerror(); -// } - } //-------------------------------------------------------------------------- diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 0e8f39b4bf..a1bdf2c38c 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -48,8 +48,6 @@ public: void update(const LLViewerCamera * cam); - LLVector4 getRotatedLightDir() const { return mRotatedLight; } - void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); void updateShaderUniforms(LLGLSLShader *shader); @@ -63,6 +61,9 @@ public: inline F32 getSceneLightStrength() const { return mSceneLightStrength; } inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } + inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } + inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } + inline LLVector4 getRotatedLight() const { return mRotatedLight; } private: static const F32 SUN_DELTA_YAW; @@ -70,7 +71,6 @@ private: typedef std::map NamedSkyMap_t; typedef std::map AssetSkyMap_t; - LLVector4 mRotatedLight; LLVector2 mCloudScrollDelta; // cumulative cloud delta LLSettingsSky::ptr_t mCurrentSky; @@ -79,6 +79,7 @@ private: AssetSkyMap_t mSkysById; F32 mSceneLightStrength; + LLVector4 mRotatedLight; void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 191ca2d2ec..d4d9172a75 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -43,7 +43,7 @@ //========================================================================= namespace { - const LLVector3 DUE_EAST(-1.0f, 0.0f, 0.0); + const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0); LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params"); LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); @@ -52,6 +52,8 @@ namespace } +const F32 LLSettingsSky::DOME_OFFSET(0.96f); +const F32 LLSettingsSky::DOME_RADIUS(15000.f); //========================================================================= const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); @@ -226,7 +228,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam F32 altitude = oldsettings[SETTING_LEGACY_SUN_ANGLE].asReal(); LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude); - LLQuaternion moonquat = ~sunquat; + LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude); newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); @@ -302,8 +304,8 @@ LLSD LLSettingsSky::defaults() dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; - dfltsetting[SETTING_MOON_TEXTUREID] = IMG_SUN; // gMoonTextureID; // These two are returned by the login... wow! - dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_MOON; // gSunTextureID; + dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow! + dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID; return dfltsetting; } @@ -327,6 +329,12 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() 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]); + + gSky.setSunDirection(crf_sunDirection, LLVector3(0, 0, 0)); + gSky.setOverrideSun(TRUE); + } // is the normal from the sun or the moon if (mSunDirection.mV[1] >= 0.0) @@ -338,7 +346,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(mSunDirection); vec.mV[1] = 0.0; - vec.normVec(); + vec.normalize(); mLightDirection = vec; } else @@ -348,16 +356,18 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() // calculate the clamp lightnorm for sky (to prevent ugly banding in sky // when haze goes below the horizon - mLightDirectionClamped = mSunDirection; + mClampedLightDirection = mLightDirection; - if (mLightDirectionClamped.mV[1] < -0.1f) + if (mClampedLightDirection.mV[1] < -0.1f) { - mLightDirectionClamped.mV[1] = -0.1f; + mClampedLightDirection.mV[1] = -0.1f; + mClampedLightDirection.normalize(); } } void LLSettingsSky::calculateLightSettings() { +#if 0 LLColor3 vary_HazeColor; LLColor3 vary_SunlightColor; LLColor3 vary_AmbientColor; @@ -461,7 +471,7 @@ void LLSettingsSky::calculateLightSettings() mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; mFadeColor.setAlpha(1); - +#endif } LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const @@ -495,7 +505,7 @@ void LLSettingsSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDirection.mV); shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); @@ -529,8 +539,8 @@ namespace { LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) { - static const LLVector3 VECT_ZENITH(0.f, 0.f, 1.f); - static const LLVector3 VECT_NORTHSOUTH(0.f, 1.f, 0.f); + static const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); + static const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); // Azimuth is traditionally calculated from North, we are going from East. LLQuaternion rot_azi; diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index f6d1087442..0274661643 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -151,12 +151,14 @@ public: F32 getDomeOffset() const { - return mSettings[SETTING_DOME_OFFSET].asReal(); + return DOME_OFFSET; + //return mSettings[SETTING_DOME_OFFSET].asReal(); } F32 getDomeRadius() const { - return mSettings[SETTING_DOME_RADIUS].asReal(); + return DOME_RADIUS; + //return mSettings[SETTING_DOME_RADIUS].asReal(); } F32 getGama() const @@ -219,7 +221,6 @@ public: return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); } - // Internal/calculated settings LLVector3 getLightDirection() const { @@ -227,6 +228,32 @@ public: return mLightDirection; }; + LLVector3 getClampedLightDirection() const + { + update(); + return mClampedLightDirection; + }; + + LLVector3 getSunDirection() const + { + update(); + return mSunDirection; + } + + LLVector3 getMoonDirection() const + { + update(); + return mMoonDirection; + } + + +#if 0 + LLVector3 getLightDirection() const + { + update(); + return mLightDirection; + }; + LLVector3 getLightDirectionClamped() const { update(); @@ -280,6 +307,7 @@ public: update(); return mFadeColor; } +#endif protected: LLSettingsSky(); @@ -299,15 +327,18 @@ private: LLVector3 mSunDirection; LLVector3 mMoonDirection; LLVector3 mLightDirection; - LLVector3 mLightDirectionClamped; - - LLColor3 mSunDiffuse; - LLColor3 mSunAmbient; - LLColor3 mMoonDiffuse; - LLColor3 mMoonAmbient; - - LLColor4 mTotalAmbient; - LLColor4 mFadeColor; + LLVector3 mClampedLightDirection; + + static const F32 DOME_RADIUS; + static const F32 DOME_OFFSET; + +// LLColor3 mSunDiffuse; +// LLColor3 mSunAmbient; +// LLColor3 mMoonDiffuse; +// LLColor3 mMoonAmbient; +// +// LLColor4 mTotalAmbient; +// LLColor4 mFadeColor; typedef std::map mapNameToUniformId_t; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index dc6e6e9e45..71abad79b6 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -331,24 +331,24 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mBumpSunDir(0.f, 0.f, 1.f) { /// WL PARAMS - dome_radius = 1.f; - dome_offset_ratio = 0.f; - sunlight_color = LLColor3(); - ambient = LLColor3(); - gamma = 1.f; - lightnorm = LLVector4(); - blue_density = LLColor3(); - blue_horizon = LLColor3(); - haze_density = 0.f; - haze_horizon = 1.f; - density_multiplier = 0.f; - max_y = 0.f; - glow = LLColor3(); - cloud_shadow = 0.f; - cloud_color = LLColor3(); - cloud_scale = 0.f; - cloud_pos_density1 = LLColor3(); - cloud_pos_density2 = LLColor3(); +// dome_radius = 1.f; +// dome_offset_ratio = 0.f; +// sunlight_color = LLColor3(); +// ambient = LLColor3(); +// gamma = 1.f; +// lightnorm = LLVector4(); +// blue_density = LLColor3(); +// blue_horizon = LLColor3(); +// haze_density = 0.f; +// haze_horizon = 1.f; +// density_multiplier = 0.f; +// max_y = 0.f; +// glow = LLColor3(); +// cloud_shadow = 0.f; +// cloud_color = LLColor3(); +// cloud_scale = 0.f; +// cloud_pos_density1 = LLColor3(); +// cloud_pos_density2 = LLColor3(); mInitialized = FALSE; mbCanSelect = FALSE; @@ -369,11 +369,12 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); // *LAPRAS - mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getLightNormal(); + mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getSunDirection(); if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) { - initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); + + initSunDirection(LLVector3(mSunDefaultPosition.mV[2], mSunDefaultPosition.mV[0], mSunDefaultPosition.mV[1]), LLVector3(0, 0, 0)); } mAmbientScale = gSavedSettings.getF32("SkyAmbientScale"); mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); @@ -569,33 +570,35 @@ void LLVOSky::initAtmospherics(void) // *LAPRAS // uniform parameters for convenience - LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - - dome_radius = sky->getDomeRadius(); - dome_offset_ratio = sky->getDomeOffset(); - sunlight_color = sky->getSunlightColor(); - ambient = sky->getAmbientColor(); - gamma = sky->getGama(); - blue_density = sky->getBlueDensity(); - blue_horizon = sky->getBlueHorizon(); - haze_density = sky->getHazeDensity(); - haze_horizon = sky->getHazeHorizon(); - density_multiplier = sky->getDensityMultiplier(); - max_y = sky->getMaxY(); - glow = sky->getGlow(); - cloud_shadow = sky->getCloudShadow(); - cloud_color = sky->getCloudColor(); - cloud_scale = sky->getCloudScale(); - cloud_pos_density1 = sky->getCloudPosDensity1(); - cloud_pos_density2 = sky->getCloudPosDensity2(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + +// dome_radius = psky->getDomeRadius(); +// dome_offset_ratio = psky->getDomeOffset(); +// sunlight_color = psky->getSunlightColor(); +// ambient = psky->getAmbientColor(); +// gamma = psky->getGama(); +// blue_density = psky->getBlueDensity(); +// blue_horizon = psky->getBlueHorizon(); +// haze_density = psky->getHazeDensity(); +// haze_horizon = psky->getHazeHorizon(); +// density_multiplier = psky->getDensityMultiplier(); +// max_y = psky->getMaxY(); +// glow = psky->getGlow(); +// cloud_shadow = psky->getCloudShadow(); +// cloud_color = psky->getCloudColor(); +// cloud_scale = psky->getCloudScale(); +// cloud_pos_density1 = psky->getCloudPosDensity1(); +// cloud_pos_density2 = psky->getCloudPosDensity2(); // light norm is different. We need the sun's direction, not the light direction // which could be from the moon. And we need to clamp it // just like for the gpu - LLVector3 sunDir = gSky.getSunDirection(); +// LLVector3 sunDir = gSky.getSunDirection(); + LLVector3 sunDir = psky->getSunDirection(); // CFR_TO_OGL - lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); +// lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); + lightnorm = LLVector4(sunDir, 0); unclamped_lightnorm = lightnorm; if(lightnorm.mV[1] < -0.1f) { @@ -676,6 +679,11 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, LLVector2 vary_HorizontalProjection[2]) { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor3 blue_density = psky->getBlueDensity(); + F32 max_y = psky->getMaxY(); + // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); F32 sinA = sin(F_PI - phi); @@ -684,7 +692,8 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo sinA = 0.01f; } - F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; +// F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; + F32 Plen = psky->getDomeRadius() * sin(F_PI + phi + asin(psky->getDomeOffset() * sinA)) / sinA; Pn *= Plen; @@ -705,7 +714,14 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo Pn /= Plen; // Initialize temp variables - LLColor3 sunlight = sunlight_color; + LLColor3 sunlight = psky->getSunlightColor(); + LLColor3 ambient = psky->getAmbientColor(); + LLColor3 blue_horizon = psky->getBlueHorizon(); + F32 haze_density = psky->getHazeDensity(); + F32 haze_horizon = psky->getHazeHorizon(); + F32 density_multiplier = psky->getDensityMultiplier(); + LLColor3 glow = psky->getGlow(); + F32 cloud_shadow = psky->getCloudShadow(); // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -766,7 +782,7 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo // Final atmosphere additive componentMultBy(vary_HazeColor, LLColor3::white - temp1); - sunlight = sunlight_color; + sunlight = psky->getSunlightColor(); temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f); temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); @@ -807,8 +823,10 @@ LLColor3 LLVOSky::calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, LLVector2 vary_HorizontalProjection[2]) { - LLColor3 res; + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + F32 gamma = psky->getGama(); + LLColor3 res; LLColor3 color0 = vary_HazeColor; if (!gPipeline.canUseWindLightShaders()) @@ -874,6 +892,7 @@ LLColor3 LLVOSky::createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLC void LLVOSky::calcAtmospherics(void) { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); initAtmospherics(); LLColor3 vary_HazeColor; @@ -881,7 +900,16 @@ void LLVOSky::calcAtmospherics(void) LLColor3 vary_AmbientColor; { // Initialize temp variables - LLColor3 sunlight = sunlight_color; + LLColor3 sunlight = psky->getSunlightColor(); + LLColor3 ambient = psky->getAmbientColor(); + F32 gamma = psky->getGama(); + LLColor3 blue_density = psky->getBlueDensity(); + LLColor3 blue_horizon = psky->getBlueHorizon(); + F32 haze_density = psky->getHazeDensity(); + F32 haze_horizon = psky->getHazeHorizon(); + F32 density_multiplier = psky->getDensityMultiplier(); + F32 max_y = psky->getMaxY(); + F32 cloud_shadow = psky->getCloudShadow(); // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -1210,6 +1238,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) } mCameraPosAgent = drawable->getPositionAgent(); + mEarthCenter.mV[0] = mCameraPosAgent.mV[0]; mEarthCenter.mV[1] = mCameraPosAgent.mV[1]; @@ -1808,152 +1837,155 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, LLFace *face = mFace[FACE_REFLECTION]; - if (!face->getVertexBuffer() || quads*4 != face->getGeomCount()) - { - face->setSize(quads * 4, quads * 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); - buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); - face->setIndicesIndex(0); - face->setGeomIndex(0); - face->setVertexBuffer(buff); - } - - LLStrider verticesp; - LLStrider normalsp; - LLStrider texCoordsp; - LLStrider indicesp; - S32 index_offset; - - index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); - if (-1 == index_offset) - { - return; - } - - LLColor3 hb_col3 = HB.getInterpColor(); - hb_col3.clamp(); - const LLColor4 hb_col = LLColor4(hb_col3); - - const F32 min_attenuation = 0.4f; - const F32 max_attenuation = 0.7f; - const F32 attenuation = min_attenuation - + cos_angle_of_view * (max_attenuation - min_attenuation); - - LLColor4 hb_refl_col = (1-attenuation) * hb_col + attenuation * mFogColor; - face->setFaceColor(hb_refl_col); - - LLVector3 v_far[2]; - v_far[0] = v_refl_corner[1]; - v_far[1] = v_refl_corner[3]; - - if(dt_clip > 0) - { - if (dt_clip >= 1) - { - for (S32 vtx = 0; vtx < 4; ++vtx) - { - F32 ratio = far_clip / v_refl_corner[vtx].length(); - *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; - } - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); - face->mCenterAgent = draw_pos; - } - else - { - F32 ratio = far_clip / v_refl_corner[1].length(); - v_sprite_corner[1] = v_refl_corner[1] * ratio; - - ratio = far_clip / v_refl_corner[3].length(); - v_sprite_corner[3] = v_refl_corner[3] * ratio; - - v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; - v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; - v_sprite_corner[0] = v_refl_corner[1]; - v_sprite_corner[2] = v_refl_corner[3]; - - for (S32 vtx = 0; vtx < 4; ++vtx) - { - *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; - } - - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); - face->mCenterAgent = draw_pos; - } - - *(texCoordsp++) = TEX0tt; - *(texCoordsp++) = TEX0t; - *(texCoordsp++) = TEX1tt; - *(texCoordsp++) = TEX1t; - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; - - index_offset += 4; - } - - if (dt_clip < 1) - { - if (dt_clip <= 0) - { - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); - face->mCenterAgent = draw_pos; - } - - const F32 raws_inv = 1.f/raws; - const F32 cols_inv = 1.f/cols; - LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; - LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; - left *= raws_inv; - right *= raws_inv; - - F32 dt_raw = dt; - - for (S32 raw = 0; raw < raws; ++raw) - { - F32 dt_v0 = raw * raws_inv; - F32 dt_v1 = (raw + 1) * raws_inv; - const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; - const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; - const LLVector3 EL = BL + left; - const LLVector3 ER = BR + right; - dt_v0 = dt_raw; - dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); - for (S32 col = 0; col < cols; ++col) - { - F32 dt_h0 = col * cols_inv; - *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; - *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; - F32 dt_h1 = (col + 1) * cols_inv; - *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; - *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; - - *(texCoordsp++) = LLVector2(dt_h0, dt_v1); - *(texCoordsp++) = LLVector2(dt_h0, dt_v0); - *(texCoordsp++) = LLVector2(dt_h1, dt_v1); - *(texCoordsp++) = LLVector2(dt_h1, dt_v0); - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; - - index_offset += 4; - } - } - } - - face->getVertexBuffer()->flush(); + if (face) + { + if (!face->getVertexBuffer() || quads * 4 != face->getGeomCount()) + { + face->setSize(quads * 4, quads * 6); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); + face->setIndicesIndex(0); + face->setGeomIndex(0); + face->setVertexBuffer(buff); + } + + LLStrider verticesp; + LLStrider normalsp; + LLStrider texCoordsp; + LLStrider indicesp; + S32 index_offset; + + index_offset = face->getGeometry(verticesp, normalsp, texCoordsp, indicesp); + if (-1 == index_offset) + { + return; + } + + LLColor3 hb_col3 = HB.getInterpColor(); + hb_col3.clamp(); + const LLColor4 hb_col = LLColor4(hb_col3); + + const F32 min_attenuation = 0.4f; + const F32 max_attenuation = 0.7f; + const F32 attenuation = min_attenuation + + cos_angle_of_view * (max_attenuation - min_attenuation); + + LLColor4 hb_refl_col = (1 - attenuation) * hb_col + attenuation * mFogColor; + face->setFaceColor(hb_refl_col); + + LLVector3 v_far[2]; + v_far[0] = v_refl_corner[1]; + v_far[1] = v_refl_corner[3]; + + if (dt_clip > 0) + { + if (dt_clip >= 1) + { + for (S32 vtx = 0; vtx < 4; ++vtx) + { + F32 ratio = far_clip / v_refl_corner[vtx].length(); + *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; + } + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); + face->mCenterAgent = draw_pos; + } + else + { + F32 ratio = far_clip / v_refl_corner[1].length(); + v_sprite_corner[1] = v_refl_corner[1] * ratio; + + ratio = far_clip / v_refl_corner[3].length(); + v_sprite_corner[3] = v_refl_corner[3] * ratio; + + v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; + v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; + v_sprite_corner[0] = v_refl_corner[1]; + v_sprite_corner[2] = v_refl_corner[3]; + + for (S32 vtx = 0; vtx < 4; ++vtx) + { + *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; + } + + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); + face->mCenterAgent = draw_pos; + } + + *(texCoordsp++) = TEX0tt; + *(texCoordsp++) = TEX0t; + *(texCoordsp++) = TEX1tt; + *(texCoordsp++) = TEX1t; + + *indicesp++ = index_offset + 0; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 1; + + *indicesp++ = index_offset + 1; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 3; + + index_offset += 4; + } + + if (dt_clip < 1) + { + if (dt_clip <= 0) + { + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); + face->mCenterAgent = draw_pos; + } + + const F32 raws_inv = 1.f / raws; + const F32 cols_inv = 1.f / cols; + LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; + LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; + left *= raws_inv; + right *= raws_inv; + + F32 dt_raw = dt; + + for (S32 raw = 0; raw < raws; ++raw) + { + F32 dt_v0 = raw * raws_inv; + F32 dt_v1 = (raw + 1) * raws_inv; + const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; + const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; + const LLVector3 EL = BL + left; + const LLVector3 ER = BR + right; + dt_v0 = dt_raw; + dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); + for (S32 col = 0; col < cols; ++col) + { + F32 dt_h0 = col * cols_inv; + *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; + *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; + F32 dt_h1 = (col + 1) * cols_inv; + *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; + *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; + + *(texCoordsp++) = LLVector2(dt_h0, dt_v1); + *(texCoordsp++) = LLVector2(dt_h0, dt_v0); + *(texCoordsp++) = LLVector2(dt_h1, dt_v1); + *(texCoordsp++) = LLVector2(dt_h1, dt_v0); + + *indicesp++ = index_offset + 0; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 1; + + *indicesp++ = index_offset + 1; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 3; + + index_offset += 4; + } + } + } + + face->getVertexBuffer()->flush(); + } } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index c865e8701c..32b5a7eba8 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -381,25 +381,25 @@ class LLVOSky : public LLStaticViewerObject { public: /// WL PARAMS - F32 dome_radius; - F32 dome_offset_ratio; - LLColor3 sunlight_color; - LLColor3 ambient; - F32 gamma; +// F32 dome_radius; +// F32 dome_offset_ratio; +// LLColor3 sunlight_color; +// LLColor3 ambient; +// F32 gamma; LLVector4 lightnorm; LLVector4 unclamped_lightnorm; - LLColor3 blue_density; - LLColor3 blue_horizon; - F32 haze_density; - F32 haze_horizon; - F32 density_multiplier; - F32 max_y; - LLColor3 glow; - F32 cloud_shadow; - LLColor3 cloud_color; - F32 cloud_scale; - LLColor3 cloud_pos_density1; - LLColor3 cloud_pos_density2; +// LLColor3 blue_density; +// LLColor3 blue_horizon; +// F32 haze_density; +// F32 haze_horizon; +// F32 density_multiplier; +// F32 max_y; +// LLColor3 glow; +// F32 cloud_shadow; +// LLColor3 cloud_color; +// F32 cloud_scale; +// LLColor3 cloud_pos_density1; +// LLColor3 cloud_pos_density2; public: void initAtmospherics(void); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 689296a53a..6d1bb43258 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -187,7 +187,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLightDir().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); -- cgit v1.2.3 From e97c52bdd3cfdf12c3eb2e423b193979de816f34 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 4 Oct 2017 14:36:41 -0700 Subject: Rename uniform "sunlight_color_copy" to sunlight_color in shader. --- indra/llrender/llshadermgr.cpp | 3 +-- .../app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 4e9a1f5de5..b010a4ae64 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -953,7 +953,6 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade // Add shader file to map mShaderObjects[filename] = ret; shader_level = try_gpu_class; - LL_WARNS("RIDER") << "Shader '" << filename << "' loaded with handle=" << ret << LL_ENDL; } else { @@ -1118,7 +1117,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("cloude_noise_texture"); mReservedUniforms.push_back("fullbright"); mReservedUniforms.push_back("lightnorm"); - mReservedUniforms.push_back("sunlight_color_copy"); + mReservedUniforms.push_back("sunlight_color"); mReservedUniforms.push_back("ambient"); mReservedUniforms.push_back("blue_horizon"); mReservedUniforms.push_back("blue_density"); diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl index 6ff860362c..89b6a52909 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl @@ -23,7 +23,7 @@ * $/LicenseInfo$ */ -uniform vec4 sunlight_color_copy; +uniform vec4 sunlight_color; uniform vec4 light_ambient; vec3 atmosAmbient(vec3 light) @@ -33,12 +33,12 @@ vec3 atmosAmbient(vec3 light) vec3 atmosAffectDirectionalLight(float lightIntensity) { - return sunlight_color_copy.rgb * lightIntensity; + return sunlight_color.rgb * lightIntensity; } vec3 atmosGetDiffuseSunlightColor() { - return sunlight_color_copy.rgb; + return sunlight_color.rgb; } vec3 scaleDownLight(vec3 light) -- cgit v1.2.3 From e4b035d0cd3eaa76fd82643c17e3631c67387a54 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 5 Oct 2017 15:40:48 -0700 Subject: Skys settings object active. --- indra/llmath/v4color.h | 11 + indra/llrender/llshadermgr.h | 7 +- indra/newview/CMakeLists.txt | 2 + indra/newview/llenvadapters.cpp | 55 ++++ indra/newview/llenvadapters.h | 225 ++++++++++++++++ indra/newview/llfloatereditsky.cpp | 539 +++++++++++++++---------------------- indra/newview/llfloatereditsky.h | 17 +- indra/newview/llsettingsbase.cpp | 21 ++ indra/newview/llsettingsbase.h | 3 +- indra/newview/llsettingssky.cpp | 176 +++++++----- indra/newview/llsettingssky.h | 199 ++++++++++---- indra/newview/llvosky.cpp | 205 ++++---------- indra/newview/llvosky.h | 49 +--- indra/newview/llwlparammanager.cpp | 34 +-- indra/newview/llwlparammanager.h | 9 +- 15 files changed, 894 insertions(+), 658 deletions(-) create mode 100644 indra/newview/llenvadapters.cpp create mode 100644 indra/newview/llenvadapters.h diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 8f353ead5a..614cdc9f3e 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -114,9 +114,11 @@ class LLColor4 friend LLColor4 operator-(const LLColor4 &a, const LLColor4 &b); // Return vector a minus b friend LLColor4 operator*(const LLColor4 &a, const LLColor4 &b); // Return component wise a * b friend LLColor4 operator*(const LLColor4 &a, F32 k); // Return rgb times scaler k (no alpha change) + friend LLColor4 operator/(const LLColor4 &a, F32 k); // Return rgb divided by scalar k (no alpha change) friend LLColor4 operator*(F32 k, const LLColor4 &a); // Return rgb times scaler k (no alpha change) friend LLColor4 operator%(const LLColor4 &a, F32 k); // Return alpha times scaler k (no rgb change) friend LLColor4 operator%(F32 k, const LLColor4 &a); // Return alpha times scaler k (no rgb change) + friend bool operator==(const LLColor4 &a, const LLColor4 &b); // Return a == b friend bool operator!=(const LLColor4 &a, const LLColor4 &b); // Return a != b @@ -477,6 +479,15 @@ inline LLColor4 operator*(const LLColor4 &a, F32 k) a.mV[VW]); } +inline LLColor4 operator/(const LLColor4 &a, F32 k) +{ + return LLColor4( + a.mV[VX] / k, + a.mV[VY] / k, + a.mV[VZ] / k, + a.mV[VW]); +} + inline LLColor4 operator*(F32 k, const LLColor4 &a) { // only affects rgb (not a!) diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 394b38f832..7bdd97200d 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -30,6 +30,11 @@ #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: @@ -215,7 +220,7 @@ public: TERRAIN_ALPHARAMP, SHINY_ORIGIN, -DISPLAY_GAMMA, + DISPLAY_GAMMA, END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 72339b2f51..d8d1c0b51e 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -181,6 +181,7 @@ set(viewer_SOURCE_FILES lldrawpoolwlsky.cpp lldynamictexture.cpp llemote.cpp + llenvadapters.cpp llenvironment.cpp llenvmanager.cpp llestateinfomodel.cpp @@ -804,6 +805,7 @@ set(viewer_HEADER_FILES lldrawpoolwlsky.h lldynamictexture.h llemote.h + llenvadapters.h llenvironment.h llenvmanager.h llestateinfomodel.h diff --git a/indra/newview/llenvadapters.cpp b/indra/newview/llenvadapters.cpp new file mode 100644 index 0000000000..8bed0737dd --- /dev/null +++ b/indra/newview/llenvadapters.cpp @@ -0,0 +1,55 @@ +/** + * @file llenvadapters.cpp + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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 "llenvadapters.h" + +#include "llsettingssky.h" +//========================================================================= + +LLSkySettingsAdapter::LLSkySettingsAdapter(): + mWLGamma(1.0f, LLSettingsSky::SETTING_GAMMA), + mBlueHorizon(LLColor4(0.25f, 0.25f, 1.0f, 1.0f), LLSettingsSky::SETTING_BLUE_HORIZON, "WLBlueHorizon"), + mHazeDensity(1.0f, LLSettingsSky::SETTING_HAZE_DENSITY), + mBlueDensity(LLColor4(0.25f, 0.25f, 0.25f, 1.0f), LLSettingsSky::SETTING_BLUE_DENSITY, "WLBlueDensity"), + mDensityMult(1.0f, LLSettingsSky::SETTING_DENSITY_MULTIPLIER, 1000), + mHazeHorizon(1.0f, LLSettingsSky::SETTING_HAZE_HORIZON), + mMaxAlt(4000.0f, LLSettingsSky::SETTING_MAX_Y), + // Lighting + mLightnorm(LLColor4(0.f, 0.707f, -0.707f, 1.f), LLSettingsSky::SETTING_LIGHT_NORMAL), + mSunlight(LLColor4(0.5f, 0.5f, 0.5f, 1.0f), LLSettingsSky::SETTING_SUNLIGHT_COLOR, "WLSunlight"), + mAmbient(LLColor4(0.5f, 0.75f, 1.0f, 1.19f), LLSettingsSky::SETTING_AMBIENT, "WLAmbient"), + mGlow(LLColor4(18.0f, 0.0f, -0.01f, 1.0f), LLSettingsSky::SETTING_GLOW), + // Clouds + mCloudColor(LLColor4(0.5f, 0.5f, 0.5f, 1.0f), LLSettingsSky::SETTING_CLOUD_COLOR, "WLCloudColor"), + mCloudMain(LLColor4(0.5f, 0.5f, 0.125f, 1.0f), LLSettingsSky::SETTING_CLOUD_POS_DENSITY1), + mCloudCoverage(0.0f, LLSettingsSky::SETTING_CLOUD_SHADOW), + mCloudDetail(LLColor4(0.0f, 0.0f, 0.0f, 1.0f), LLSettingsSky::SETTING_CLOUD_POS_DENSITY2), + mDistanceMult(1.0f, LLSettingsSky::SETTING_DISTANCE_MULTIPLIER), + mCloudScale(0.42f, LLSettingsSky::SETTING_CLOUD_SCALE) +{ + +} diff --git a/indra/newview/llenvadapters.h b/indra/newview/llenvadapters.h new file mode 100644 index 0000000000..fc7a47be1b --- /dev/null +++ b/indra/newview/llenvadapters.h @@ -0,0 +1,225 @@ +/** + * @file llenvadapters.h + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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_ENVADAPTERS_H +#define LL_ENVADAPTERS_H + +#include "v3math.h" +#include "v3color.h" +#include "v4math.h" +#include "llsettingsbase.h" + +class WLColorControl +{ +public: + inline WLColorControl(LLColor4 color, const std::string& n, const std::string& slider_name = std::string()): + mColor(color), + mName(n), + mSliderName(slider_name), + mHasSliderName(false), + mIsSunOrAmbientColor(false), + mIsBlueHorizonOrDensity(false) + { + // if there's a slider name, say we have one + mHasSliderName = !mSliderName.empty(); + + // if it's the sun controller + mIsSunOrAmbientColor = (mSliderName == "WLSunlight" || mSliderName == "WLAmbient"); + mIsBlueHorizonOrDensity = (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity"); + } + + inline WLColorControl & operator = (const LLColor4 & val) + { + mColor = val; + return *this; + } + + inline operator LLColor4 (void) const + { + return mColor; + } + + inline operator LLColor3 (void) const + { + return vec4to3(mColor); + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, mColor); + } + + inline bool getHasSliderName() const + { + return mHasSliderName; + } + + inline std::string getSliderName() const + { + return mSliderName; + } + + inline bool getIsSunOrAmbientColor() const + { + return mIsSunOrAmbientColor; + } + + inline bool getIsBlueHorizonOrDensity() const + { + return mIsBlueHorizonOrDensity; + } + + inline F32 getRed() const + { + return mColor[0]; + } + + inline F32 getGreen() const + { + return mColor[1]; + } + + inline F32 getBlue() const + { + return mColor[2]; + } + + inline F32 getIntensity() const + { + return mColor[3]; + } + + inline void setRed(F32 red) + { + mColor[0] = red; + } + + inline void setGreen(F32 green) + { + mColor[1] = green; + } + + inline void setBlue(F32 blue) + { + mColor[2] = blue; + } + + inline void setIntensity(F32 intensity) + { + mColor[3] = intensity; + } + +private: + LLColor4 mColor; /// [3] is intensity, not alpha + std::string mName; /// name to use to dereference params + std::string mSliderName; /// name of the slider in menu + bool mHasSliderName; /// only set slider name for true color types + bool mIsSunOrAmbientColor; /// flag for if it's the sun or ambient color controller + bool mIsBlueHorizonOrDensity; /// flag for if it's the Blue Horizon or Density color controller + +}; + +// float slider control +class WLFloatControl +{ +public: + inline WLFloatControl(F32 val, const std::string& n, F32 m = 1.0f): + x(val), + mName(n), + mult(m) + { + } + + inline WLFloatControl &operator = (F32 val) + { + x = val; + return *this; + } + + inline operator F32 (void) const + { + return x; + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, x); + } + + inline F32 getMult() const + { + return mult; + } + + inline void setValue(F32 val) + { + x = val; + } + +private: + F32 x; + std::string mName; + F32 mult; +}; + + +//------------------------------------------------------------------------- +class LLSkySettingsAdapter +{ +public: + typedef std::shared_ptr ptr_t; + + LLSkySettingsAdapter(); + + WLFloatControl mWLGamma; + + /// Atmospherics + WLColorControl mBlueHorizon; + WLFloatControl mHazeDensity; + WLColorControl mBlueDensity; + WLFloatControl mDensityMult; + WLFloatControl mHazeHorizon; + WLFloatControl mMaxAlt; + + /// Lighting + WLColorControl mLightnorm; + WLColorControl mSunlight; + WLColorControl mAmbient; + WLColorControl mGlow; + + /// Clouds + WLColorControl mCloudColor; + WLColorControl mCloudMain; + WLFloatControl mCloudCoverage; + WLColorControl mCloudDetail; + WLFloatControl mDistanceMult; + WLFloatControl mCloudScale; + + +}; + +#endif // LL_ENVIRONMENT_H + diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index d809211ea7..1ca61e758f 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -28,6 +28,8 @@ #include "llfloatereditsky.h" +#include + // libs #include "llbutton.h" #include "llcheckboxctrl.h" @@ -45,6 +47,10 @@ #include "llregioninfomodel.h" #include "llviewerregion.h" +#include "v3colorutil.h" +#include "llenvironment.h" +#include "llenvadapters.h" + static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; static const F32 WL_BLUE_HORIZON_DENSITY_SCALE = 2.0f; static const F32 WL_CLOUD_SLIDER_SCALE = 1.0f; @@ -61,12 +67,13 @@ static F32 time24_to_sun_pos(F32 time24) return sun_pos; } -LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) -: LLFloater(key) -, mSkyPresetNameEditor(NULL) -, mSkyPresetCombo(NULL) -, mMakeDefaultCheckBox(NULL) -, mSaveButton(NULL) +LLFloaterEditSky::LLFloaterEditSky(const LLSD &key): + LLFloater(key), + mSkyPresetNameEditor(NULL), + mSkyPresetCombo(NULL), + mMakeDefaultCheckBox(NULL), + mSaveButton(NULL), + mSkyAdapter() { } @@ -77,6 +84,7 @@ BOOL LLFloaterEditSky::postBuild() mSkyPresetCombo = getChild("sky_preset_combo"); mMakeDefaultCheckBox = getChild("make_default_cb"); mSaveButton = getChild("save"); + mSkyAdapter = boost::make_shared(); initCallbacks(); @@ -115,7 +123,7 @@ void LLFloaterEditSky::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment +// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment } } @@ -137,71 +145,69 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); + // *LAPRAS + // TODO: +// LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); +// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); //------------------------------------------------------------------------- - LLWLParamManager& param_mgr = LLWLParamManager::instance(); - // blue horizon - getChild("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueHorizon)); // haze density, horizon, mult, and altitude - getChild("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mHazeDensity)); - getChild("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mHazeHorizon)); - getChild("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDensityMult)); - getChild("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mMaxAlt)); + getChild("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mHazeDensity)); + getChild("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mHazeHorizon)); + getChild("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDensityMult)); + getChild("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mMaxAlt)); // blue density - getChild("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueDensity)); + getChild("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueDensity)); // Lighting // sunlight - getChild("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mSunlight)); + getChild("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mSunlight)); // glow - getChild("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, ¶m_mgr.mGlow)); - getChild("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, ¶m_mgr.mGlow)); + getChild("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, &mSkyAdapter->mGlow)); + getChild("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, &mSkyAdapter->mGlow)); // ambient - getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mAmbient)); + getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient)); // time of day - getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // multi-slider + getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl - getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); + getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // Clouds // Cloud Color - getChild("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mCloudColor)); // Cloud - getChild("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudMain)); - getChild("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudMain)); - getChild("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudMain)); + getChild("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudMain)); + getChild("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudMain)); + getChild("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudMain)); // Cloud Detail - getChild("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudDetail)); - getChild("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudDetail)); - getChild("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudDetail)); + getChild("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudDetail)); + getChild("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudDetail)); + getChild("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudDetail)); // Cloud extras - getChild("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudCoverage)); - getChild("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudScale)); - getChild("WLCloudLockX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXToggled, this, _1)); - getChild("WLCloudLockY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYToggled, this, _1)); + getChild("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudCoverage)); + getChild("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudScale)); getChild("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXMoved, this, _1)); getChild("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYMoved, this, _1)); - getChild("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDistanceMult)); + getChild("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDistanceMult)); // Dome - getChild("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mWLGamma)); + getChild("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mWLGamma)); getChild("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterEditSky::onStarAlphaMoved, this, _1)); } @@ -209,320 +215,250 @@ void LLFloaterEditSky::initCallbacks(void) void LLFloaterEditSky::syncControls() { - bool err; + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + mEditSettings = psky; - LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); - - LLWLParamSet& cur_params = param_mgr->mCurParams; // blue horizon - param_mgr->mBlueHorizon = cur_params.getVector(param_mgr->mBlueHorizon.mName, err); - setColorSwatch("WLBlueHorizon", param_mgr->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); + mSkyAdapter->mBlueHorizon = psky->getBlueHorizon(); + setColorSwatch("WLBlueHorizon", mSkyAdapter->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); // haze density, horizon, mult, and altitude - param_mgr->mHazeDensity = cur_params.getFloat(param_mgr->mHazeDensity.mName, err); - childSetValue("WLHazeDensity", (F32) param_mgr->mHazeDensity); - param_mgr->mHazeHorizon = cur_params.getFloat(param_mgr->mHazeHorizon.mName, err); - childSetValue("WLHazeHorizon", (F32) param_mgr->mHazeHorizon); - param_mgr->mDensityMult = cur_params.getFloat(param_mgr->mDensityMult.mName, err); - childSetValue("WLDensityMult", ((F32) param_mgr->mDensityMult) * param_mgr->mDensityMult.mult); - param_mgr->mMaxAlt = cur_params.getFloat(param_mgr->mMaxAlt.mName, err); - childSetValue("WLMaxAltitude", (F32) param_mgr->mMaxAlt); + mSkyAdapter->mHazeDensity = psky->getHazeDensity(); + childSetValue("WLHazeDensity", (F32) mSkyAdapter->mHazeDensity); + mSkyAdapter->mHazeHorizon = psky->getHazeHorizon(); + childSetValue("WLHazeHorizon", (F32) mSkyAdapter->mHazeHorizon); + mSkyAdapter->mDensityMult = psky->getDensityMultiplier(); + childSetValue("WLDensityMult", ((F32) mSkyAdapter->mDensityMult) * mSkyAdapter->mDensityMult.getMult()); + mSkyAdapter->mMaxAlt = psky->getMaxY(); + childSetValue("WLMaxAltitude", (F32) mSkyAdapter->mMaxAlt); // blue density - param_mgr->mBlueDensity = cur_params.getVector(param_mgr->mBlueDensity.mName, err); - setColorSwatch("WLBlueDensity", param_mgr->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); + mSkyAdapter->mBlueDensity = psky->getBlueDensity(); + setColorSwatch("WLBlueDensity", mSkyAdapter->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); // Lighting // sunlight - param_mgr->mSunlight = cur_params.getVector(param_mgr->mSunlight.mName, err); - setColorSwatch("WLSunlight", param_mgr->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); + mSkyAdapter->mSunlight = psky->getSunlightColor(); + setColorSwatch("WLSunlight", mSkyAdapter->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); // glow - param_mgr->mGlow = cur_params.getVector(param_mgr->mGlow.mName, err); - childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f); - childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f); + mSkyAdapter->mGlow = psky->getGlow(); + childSetValue("WLGlowR", 2 - mSkyAdapter->mGlow.getRed() / 20.0f); + childSetValue("WLGlowB", -mSkyAdapter->mGlow.getBlue() / 5.0f); // ambient - param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); - setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); + mSkyAdapter->mAmbient = psky->getAmbientColor(); + setColorSwatch("WLAmbient", mSkyAdapter->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); + + LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); - F32 time24 = sun_pos_to_time24(param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); + F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI); getChild("WLSunPos")->setCurSliderValue(time24, TRUE); getChild("WLDayTime")->setTime24(time24); - childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); + childSetValue("WLEastAngle", azal.first / F_TWO_PI); // Clouds // Cloud Color - param_mgr->mCloudColor = cur_params.getVector(param_mgr->mCloudColor.mName, err); - setColorSwatch("WLCloudColor", param_mgr->mCloudColor, WL_CLOUD_SLIDER_SCALE); + mSkyAdapter->mCloudColor = psky->getCloudColor(); + setColorSwatch("WLCloudColor", mSkyAdapter->mCloudColor, WL_CLOUD_SLIDER_SCALE); // Cloud - param_mgr->mCloudMain = cur_params.getVector(param_mgr->mCloudMain.mName, err); - childSetValue("WLCloudX", param_mgr->mCloudMain.r); - childSetValue("WLCloudY", param_mgr->mCloudMain.g); - childSetValue("WLCloudDensity", param_mgr->mCloudMain.b); + mSkyAdapter->mCloudMain = psky->getCloudPosDensity1(); + childSetValue("WLCloudX", mSkyAdapter->mCloudMain.getRed()); + childSetValue("WLCloudY", mSkyAdapter->mCloudMain.getGreen()); + childSetValue("WLCloudDensity", mSkyAdapter->mCloudMain.getBlue()); // Cloud Detail - param_mgr->mCloudDetail = cur_params.getVector(param_mgr->mCloudDetail.mName, err); - childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r); - childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g); - childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b); + mSkyAdapter->mCloudDetail = psky->getCloudPosDensity2(); + childSetValue("WLCloudDetailX", mSkyAdapter->mCloudDetail.getRed()); + childSetValue("WLCloudDetailY", mSkyAdapter->mCloudDetail.getGreen()); + childSetValue("WLCloudDetailDensity", mSkyAdapter->mCloudDetail.getBlue()); // Cloud extras - param_mgr->mCloudCoverage = cur_params.getFloat(param_mgr->mCloudCoverage.mName, err); - param_mgr->mCloudScale = cur_params.getFloat(param_mgr->mCloudScale.mName, err); - childSetValue("WLCloudCoverage", (F32) param_mgr->mCloudCoverage); - childSetValue("WLCloudScale", (F32) param_mgr->mCloudScale); + mSkyAdapter->mCloudCoverage = psky->getCloudShadow(); + mSkyAdapter->mCloudScale = psky->getCloudScale(); + childSetValue("WLCloudCoverage", (F32) mSkyAdapter->mCloudCoverage); + childSetValue("WLCloudScale", (F32) mSkyAdapter->mCloudScale); // cloud scrolling - bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX(); - bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); - childSetValue("WLCloudLockX", lockX); - childSetValue("WLCloudLockY", lockY); + LLVector2 scroll_rate = psky->getCloudScrollRate(); + + // LAPRAS: These should go away... + childDisable("WLCloudLockX"); + childDisable("WLCloudLockY"); // disable if locked, enable if not - if (lockX) - { - childDisable("WLCloudScrollX"); - } - else - { - childEnable("WLCloudScrollX"); - } - if (lockY) - { - childDisable("WLCloudScrollY"); - } - else - { - childEnable("WLCloudScrollY"); - } + childEnable("WLCloudScrollX"); + childEnable("WLCloudScrollY"); // *HACK cloud scrolling is off my an additive of 10 - childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f); - childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f); + childSetValue("WLCloudScrollX", scroll_rate[0] - 10.0f); + childSetValue("WLCloudScrollY", scroll_rate[1] - 10.0f); - param_mgr->mDistanceMult = cur_params.getFloat(param_mgr->mDistanceMult.mName, err); - childSetValue("WLDistanceMult", (F32) param_mgr->mDistanceMult); + mSkyAdapter->mDistanceMult = psky->getDistanceMultiplier(); + childSetValue("WLDistanceMult", (F32) mSkyAdapter->mDistanceMult); // Tweak extras - param_mgr->mWLGamma = cur_params.getFloat(param_mgr->mWLGamma.mName, err); - childSetValue("WLGamma", (F32) param_mgr->mWLGamma); + mSkyAdapter->mWLGamma = psky->getGamma(); + childSetValue("WLGamma", (F32) mSkyAdapter->mWLGamma); - childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); + childSetValue("WLStarAlpha", psky->getStarBrightness()); } void LLFloaterEditSky::setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k) { // Set the value, dividing it by first. - LLVector4 color_vec = from_ctrl; - getChild(name)->set(LLColor4(color_vec / k)); + LLColor4 color = from_ctrl; + getChild(name)->set(color / k); } // color control callbacks void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + //LLWLParamManager::getInstance()->mAnimator.deactivate(); LLColorSwatchCtrl* swatch = static_cast(ctrl); - LLVector4 color_vec(swatch->get().mV); - - // Set intensity to maximum of the RGB values. - color_vec.mV[3] = llmax(color_vec.mV[0], llmax(color_vec.mV[1], color_vec.mV[2])); + LLColor4 color_vec(swatch->get().mV); // Multiply RGB values by the appropriate factor. F32 k = WL_CLOUD_SLIDER_SCALE; - if (color_ctrl->isSunOrAmbientColor) + if (color_ctrl->getIsSunOrAmbientColor()) { k = WL_SUN_AMBIENT_SLIDER_SCALE; } - if (color_ctrl->isBlueHorizonOrDensity) + else if (color_ctrl->getIsBlueHorizonOrDensity()) { k = WL_BLUE_HORIZON_DENSITY_SCALE; } color_vec *= k; // intensity isn't affected by the multiplication + // Set intensity to maximum of the RGB values. + color_vec.mV[3] = color_max(color_vec); + // Apply the new RGBI value. *color_ctrl = color_vec; - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); WLColorControl* color_ctrl = static_cast(userdata); - color_ctrl->r = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->r *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) + F32 red_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; + + if (color_ctrl->getIsSunOrAmbientColor()) { - color_ctrl->r *= WL_BLUE_HORIZON_DENSITY_SCALE; + k = WL_SUN_AMBIENT_SLIDER_SCALE; } - - // move i if it's the max - if (color_ctrl->r >= color_ctrl->g && color_ctrl->r >= color_ctrl->b && color_ctrl->hasSliderName) + if (color_ctrl->getIsBlueHorizonOrDensity()) { - color_ctrl->i = color_ctrl->r; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->r / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->r / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->r); - } + k = WL_BLUE_HORIZON_DENSITY_SCALE; } + color_ctrl->setRed(red_value * k); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - - LLWLParamManager::getInstance()->propagateParameters(); + adjustIntensity(color_ctrl, red_value, k); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - WLColorControl* color_ctrl = static_cast(userdata); - - color_ctrl->g = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->g *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) - { - color_ctrl->g *= WL_BLUE_HORIZON_DENSITY_SCALE; - } + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); - // move i if it's the max - if (color_ctrl->g >= color_ctrl->r && color_ctrl->g >= color_ctrl->b && color_ctrl->hasSliderName) - { - color_ctrl->i = color_ctrl->g; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->g / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->g / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->g); - } - } + F32 green_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setGreen(green_value * k); - LLWLParamManager::getInstance()->propagateParameters(); + adjustIntensity(color_ctrl, green_value, k); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - WLColorControl* color_ctrl = static_cast(userdata); + F32 blue_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; - color_ctrl->b = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->b *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) - { - color_ctrl->b *= WL_BLUE_HORIZON_DENSITY_SCALE; - } + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setBlue(blue_value * k); - // move i if it's the max - if (color_ctrl->b >= color_ctrl->r && color_ctrl->b >= color_ctrl->g && color_ctrl->hasSliderName) - { - color_ctrl->i = color_ctrl->b; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->b / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->b / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->b); - } - } + adjustIntensity(color_ctrl, blue_value, k); + color_ctrl->update(mEditSettings); +} - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); +void LLFloaterEditSky::adjustIntensity(WLColorControl *ctrl, F32 val, F32 scale) +{ + if (ctrl->getHasSliderName()) + { + LLColor4 color = static_cast(*ctrl); + F32 i = color_max(color) / scale; + ctrl->setIntensity(i); + std::string name = ctrl->getSliderName(); + name.append("I"); - LLWLParamManager::getInstance()->propagateParameters(); + childSetValue(name, i); + } } + /// GLOW SPECIFIC CODE void LLFloaterEditSky::onGlowRMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldr_ctrl = static_cast(ctrl); WLColorControl* color_ctrl = static_cast(userdata); // scaled by 20 - color_ctrl->r = (2 - sldr_ctrl->getValueF32()) * 20; + color_ctrl->setRed((2 - sldr_ctrl->getValueF32()) * 20); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } /// \NOTE that we want NEGATIVE (-) B void LLFloaterEditSky::onGlowBMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); WLColorControl* color_ctrl = static_cast(userdata); /// \NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big - color_ctrl->b = -sldr_ctrl->getValueF32() * 5; + color_ctrl->setBlue(-sldr_ctrl->getValueF32() * 5); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); WLFloatControl * floatControl = static_cast(userdata); - floatControl->x = sldr_ctrl->getValueF32() / floatControl->mult; + floatControl->setValue(sldr_ctrl->getValueF32() / floatControl->getMult()); - floatControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + floatControl->update(mEditSettings); } @@ -531,8 +467,6 @@ void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) // time of day void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLMultiSliderCtrl* sun_msldr = getChild("WLSunPos"); LLSliderCtrl* east_sldr = getChild("WLEastAngle"); LLTimeCtrl* time_ctrl = getChild("WLDayTime"); @@ -542,99 +476,44 @@ void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) time_ctrl->setTime24(time24); // sync the time ctrl with the new sun position // get the two angles - LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); - - param_mgr->mCurParams.setSunAngle(F_TWO_PI * time24_to_sun_pos(time24)); - param_mgr->mCurParams.setEastAngle(F_TWO_PI * east_sldr->getValueF32()); + F32 azimuth = F_TWO_PI * east_sldr->getValueF32(); + F32 altitude = F_TWO_PI * time24_to_sun_pos(time24); + mEditSettings->setSunRotation(azimuth, altitude); + mEditSettings->setMoonRotation(azimuth + F_PI, -altitude); - // set the sun vector - color_ctrl->r = -sin(param_mgr->mCurParams.getEastAngle()) * - cos(param_mgr->mCurParams.getSunAngle()); - color_ctrl->g = sin(param_mgr->mCurParams.getSunAngle()); - color_ctrl->b = cos(param_mgr->mCurParams.getEastAngle()) * - cos(param_mgr->mCurParams.getSunAngle()); - color_ctrl->i = 1.f; + LLVector4 sunnorm( mEditSettings->getSunDirection(), 1.f ); - color_ctrl->update(param_mgr->mCurParams); - param_mgr->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onTimeChanged() { F32 time24 = getChild("WLDayTime")->getTime24(); getChild("WLSunPos")->setCurSliderValue(time24, TRUE); - onSunMoved(getChild("WLSunPos"), &LLWLParamManager::instance().mLightnorm); + onSunMoved(getChild("WLSunPos"), &(mSkyAdapter->mLightnorm)); } void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - LLWLParamManager::getInstance()->mCurParams.setStarBrightness(sldr_ctrl->getValueF32()); + mEditSettings->setStarBrightness(sldr_ctrl->getValueF32()); } // Clouds void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::getInstance()->mCurParams.setCloudScrollX(sldr_ctrl->getValueF32() + 10.0f); + mEditSettings->setCloudScrollRateX(sldr_ctrl->getValueF32() + 10.0f); } void LLFloaterEditSky::onCloudScrollYMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::getInstance()->mCurParams.setCloudScrollY(sldr_ctrl->getValueF32() + 10.0f); -} - -void LLFloaterEditSky::onCloudScrollXToggled(LLUICtrl* ctrl) -{ - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLCheckBoxCtrl* cb_ctrl = static_cast(ctrl); - - bool lock = cb_ctrl->get(); - LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollX(!lock); - - LLSliderCtrl* sldr = getChild("WLCloudScrollX"); - - if (cb_ctrl->get()) - { - sldr->setEnabled(false); - } - else - { - sldr->setEnabled(true); - } - -} - -void LLFloaterEditSky::onCloudScrollYToggled(LLUICtrl* ctrl) -{ - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLCheckBoxCtrl* cb_ctrl = static_cast(ctrl); - bool lock = cb_ctrl->get(); - LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollY(!lock); - - LLSliderCtrl* sldr = getChild("WLCloudScrollY"); - - if (cb_ctrl->get()) - { - sldr->setEnabled(false); - } - else - { - sldr->setEnabled(true); - } + mEditSettings->setCloudScrollRateY(sldr_ctrl->getValueF32() + 10.0f); } //================================================================================================= @@ -662,6 +541,7 @@ bool LLFloaterEditSky::isNewPreset() const void LLFloaterEditSky::refreshSkyPresetsList() { +#if 0 mSkyPresetCombo->removeall(); LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; @@ -698,6 +578,7 @@ void LLFloaterEditSky::refreshSkyPresetsList() } mSkyPresetCombo->setLabel(getString("combo_label")); +#endif } void LLFloaterEditSky::enableEditing(bool enable) @@ -718,6 +599,7 @@ void LLFloaterEditSky::enableEditing(bool enable) void LLFloaterEditSky::saveRegionSky() { +#if 0 LLWLParamKey key(getSelectedSkyPreset()); llassert(key.scope == LLEnvKey::SCOPE_REGION); @@ -728,44 +610,48 @@ void LLFloaterEditSky::saveRegionSky() // *TODO: save to cached region settings. LL_WARNS("Windlight") << "Saving region sky is not fully implemented yet" << LL_ENDL; +#endif } -LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() -{ - LLWLParamKey key; - - if (mSkyPresetNameEditor->getVisible()) - { - key.name = mSkyPresetNameEditor->getText(); - key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - LLSD combo_val = mSkyPresetCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - key.name = combo_val.asString(); - key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - key.fromLLSD(combo_val); - } - } - - return key; -} +// LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() +// { +// LLWLParamKey key; +// +// if (mSkyPresetNameEditor->getVisible()) +// { +// key.name = mSkyPresetNameEditor->getText(); +// key.scope = LLEnvKey::SCOPE_LOCAL; +// } +// else +// { +// LLSD combo_val = mSkyPresetCombo->getValue(); +// +// if (!combo_val.isArray()) // manually typed text +// { +// key.name = combo_val.asString(); +// key.scope = LLEnvKey::SCOPE_LOCAL; +// } +// else +// { +// key.fromLLSD(combo_val); +// } +// } +// +// return key; +// } void LLFloaterEditSky::onSkyPresetNameEdited() { +#if 0 // Disable saving a sky preset having empty name. LLWLParamKey key = getSelectedSkyPreset(); mSaveButton->setEnabled(!key.name.empty()); +#endif } void LLFloaterEditSky::onSkyPresetSelected() { +#if 0 LLWLParamKey key = getSelectedSkyPreset(); LLWLParamSet sky_params; @@ -783,6 +669,7 @@ void LLFloaterEditSky::onSkyPresetSelected() enableEditing(can_edit); mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); +#endif } bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -800,6 +687,7 @@ bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& respon void LLFloaterEditSky::onSaveConfirmed() { +#if 0 // Save current params to the selected preset. LLWLParamKey key(getSelectedSkyPreset()); @@ -824,10 +712,12 @@ void LLFloaterEditSky::onSaveConfirmed() } closeFloater(); +#endif } void LLFloaterEditSky::onBtnSave() { +#if 0 LLWLParamKey selected_sky = getSelectedSkyPreset(); LLWLParamManager& wl_mgr = LLWLParamManager::instance(); @@ -863,6 +753,7 @@ void LLFloaterEditSky::onBtnSave() // new preset, hence no confirmation needed onSaveConfirmed(); } +#endif } void LLFloaterEditSky::onBtnCancel() @@ -872,6 +763,7 @@ void LLFloaterEditSky::onBtnCancel() void LLFloaterEditSky::onSkyPresetListChange() { +#if 0 LLWLParamKey key = getSelectedSkyPreset(); // preset being edited if (!LLWLParamManager::instance().hasParamSet(key)) { @@ -884,10 +776,12 @@ void LLFloaterEditSky::onSkyPresetListChange() // Refresh the presets list, though it may not make sense as the floater is about to be closed. refreshSkyPresetsList(); } +#endif } void LLFloaterEditSky::onRegionSettingsChange() { +#if 0 // If creating a new sky, don't bother. if (isNewPreset()) { @@ -905,10 +799,12 @@ void LLFloaterEditSky::onRegionSettingsChange() { refreshSkyPresetsList(); } +#endif } void LLFloaterEditSky::onRegionInfoUpdate() { +#if 0 bool can_edit = true; // If we've selected a region sky preset for editing. @@ -919,4 +815,5 @@ void LLFloaterEditSky::onRegionInfoUpdate() } enableEditing(can_edit); +#endif } diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h index a06c4fc5fa..6aec87014d 100644 --- a/indra/newview/llfloatereditsky.h +++ b/indra/newview/llfloatereditsky.h @@ -28,12 +28,17 @@ #define LL_LLFLOATEREDITSKY_H #include "llfloater.h" -#include "llwlparammanager.h" +#include "llsettingssky.h" class LLButton; class LLCheckBoxCtrl; class LLComboBox; class LLLineEditor; +class WLColorControl; +class LLSkySettingsAdapter; + +typedef boost::shared_ptr LLSkySettingsAdapterPtr; + /** * Floater for creating or editing a sky preset. @@ -66,6 +71,8 @@ private: void onColorControlBMoved(LLUICtrl* ctrl, void* userdata); void onFloatControlMoved(LLUICtrl* ctrl, void* userdata); + void adjustIntensity(WLColorControl *ctrl, F32 color, F32 scale); + // lighting callbacks for glow void onGlowRMoved(LLUICtrl* ctrl, void* userdata); void onGlowBMoved(LLUICtrl* ctrl, void* userdata); @@ -80,8 +87,6 @@ private: // handle cloud scrolling void onCloudScrollXMoved(LLUICtrl* ctrl); void onCloudScrollYMoved(LLUICtrl* ctrl); - void onCloudScrollXToggled(LLUICtrl* ctrl); - void onCloudScrollYToggled(LLUICtrl* ctrl); //-- WL stuff ends -------------------------------------------------------- @@ -90,7 +95,7 @@ private: void refreshSkyPresetsList(); void enableEditing(bool enable); void saveRegionSky(); - LLWLParamKey getSelectedSkyPreset(); +// LLWLParamKey getSelectedSkyPreset(); void onSkyPresetNameEdited(); void onSkyPresetSelected(); @@ -104,10 +109,14 @@ private: void onRegionSettingsChange(); void onRegionInfoUpdate(); + LLSettingsSky::ptr_t mEditSettings; + LLLineEditor* mSkyPresetNameEditor; LLComboBox* mSkyPresetCombo; LLCheckBoxCtrl* mMakeDefaultCheckBox; LLButton* mSaveButton; + LLSkySettingsAdapterPtr mSkyAdapter; + }; #endif // LL_LLFLOATEREDITSKY_H diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp index 1aafacae45..71ec240214 100644 --- a/indra/newview/llsettingsbase.cpp +++ b/indra/newview/llsettingsbase.cpp @@ -80,6 +80,14 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons 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; @@ -106,6 +114,14 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons 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; @@ -219,6 +235,11 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F return newSettings; } +LLSD LLSettingsBase::cloneSettings() const +{ + return combineSDMaps(mSettings, LLSD()); +} + void LLSettingsBase::exportSettings(std::string name) const { diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index 142b74caf9..02f5ffc8af 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -124,7 +124,6 @@ protected: typedef std::set stringset_t; - // combining settings objects. Customize for specific setting types virtual void lerpSettings(const LLSettingsBase &other, F32 mix); @@ -147,6 +146,8 @@ protected: LLSD mSettings; + LLSD cloneSettings() const; + private: bool mDirty; diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index d4d9172a75..898cdad7be 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -44,12 +44,14 @@ 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_ENVIRONMENT("Blending Environment Params"); LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); 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); @@ -101,6 +103,32 @@ LLSettingsSky::LLSettingsSky(): { } +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; @@ -124,27 +152,27 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam if (oldsettings.has(SETTING_AMBIENT)) { - newsettings[SETTING_AMBIENT] = LLColor4(oldsettings[SETTING_AMBIENT]).getValue(); + newsettings[SETTING_AMBIENT] = LLColor3(oldsettings[SETTING_AMBIENT]).getValue(); } if (oldsettings.has(SETTING_BLUE_DENSITY)) { - newsettings[SETTING_BLUE_DENSITY] = LLColor4(oldsettings[SETTING_BLUE_DENSITY]).getValue(); + newsettings[SETTING_BLUE_DENSITY] = LLColor3(oldsettings[SETTING_BLUE_DENSITY]).getValue(); } if (oldsettings.has(SETTING_BLUE_HORIZON)) { - newsettings[SETTING_BLUE_HORIZON] = LLColor4(oldsettings[SETTING_BLUE_HORIZON]).getValue(); + newsettings[SETTING_BLUE_HORIZON] = LLColor3(oldsettings[SETTING_BLUE_HORIZON]).getValue(); } if (oldsettings.has(SETTING_CLOUD_COLOR)) { - newsettings[SETTING_CLOUD_COLOR] = LLColor4(oldsettings[SETTING_CLOUD_COLOR]).getValue(); + newsettings[SETTING_CLOUD_COLOR] = LLColor3(oldsettings[SETTING_CLOUD_COLOR]).getValue(); } if (oldsettings.has(SETTING_CLOUD_POS_DENSITY1)) { - newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor4(oldsettings[SETTING_CLOUD_POS_DENSITY1]).getValue(); + newsettings[SETTING_CLOUD_POS_DENSITY1] = LLColor3(oldsettings[SETTING_CLOUD_POS_DENSITY1]).getValue(); } if (oldsettings.has(SETTING_CLOUD_POS_DENSITY2)) { - newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor4(oldsettings[SETTING_CLOUD_POS_DENSITY2]).getValue(); + newsettings[SETTING_CLOUD_POS_DENSITY2] = LLColor3(oldsettings[SETTING_CLOUD_POS_DENSITY2]).getValue(); } if (oldsettings.has(SETTING_CLOUD_SCALE)) { @@ -179,11 +207,11 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam } if (oldsettings.has(SETTING_GAMMA)) { - newsettings[SETTING_GAMMA] = LLVector4(oldsettings[SETTING_GAMMA]).getValue(); + newsettings[SETTING_GAMMA] = oldsettings[SETTING_GAMMA][0].asReal(); } if (oldsettings.has(SETTING_GLOW)) { - newsettings[SETTING_GLOW] = LLColor4(oldsettings[SETTING_GLOW]).getValue(); + newsettings[SETTING_GLOW] = LLColor3(oldsettings[SETTING_GLOW]).getValue(); } if (oldsettings.has(SETTING_HAZE_DENSITY)) { @@ -230,6 +258,9 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam 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(); } @@ -245,11 +276,18 @@ LLSettingsSky::ptr_t LLSettingsSky::buildDefaultSky() LLSD settings = LLSettingsSky::defaults(); LLSettingsSky::ptr_t skyp = boost::make_shared(settings); - //skyp->update(); return skyp; } +LLSettingsSky::ptr_t LLSettingsSky::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsSky::ptr_t skyp = boost::make_shared(settings); + + return skyp; +} // Settings status @@ -278,11 +316,11 @@ LLSD LLSettingsSky::defaults() // Magic constants copied form dfltsetting.xml dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue(); - dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 1.0).getValue(); - dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 1.0).getValue(); - dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 1.0).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 1.0).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 1.0).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); @@ -290,7 +328,7 @@ LLSD LLSettingsSky::defaults() 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] = LLVector4(1.0, 0.0, 0.0, 1.0).getValue(); + dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); // *RIDER: This is really weird for a color... TODO: check if right. dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999); dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899); @@ -299,7 +337,7 @@ LLSD LLSettingsSky::defaults() 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, 1.0).getValue(); + 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; @@ -367,29 +405,26 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() void LLSettingsSky::calculateLightSettings() { -#if 0 LLColor3 vary_HazeColor; LLColor3 vary_SunlightColor; LLColor3 vary_AmbientColor; { // Initialize temp variables - LLColor3 sunlight = getSunlightColor(); - - // Fetch these once... - F32 haze_density = getHazeDensity(); - F32 haze_horizon = getHazeHorizon(); - F32 density_multiplier = getDensityMultiplier(); - F32 max_y = getMaxY(); - F32 gamma = getGama(); - F32 cloud_shadow = getCloudShadow(); - LLColor3 blue_density = getBlueDensity(); - LLColor3 blue_horizon = getBlueHorizon(); - LLColor3 ambient = getAmbientColor(); - + 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 = + LLColor3 light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); // Calculate relative weights @@ -403,14 +438,14 @@ void LLSettingsSky::calculateLightSettings() // 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 = mLightDirection[1]; + 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) + if(temp2.mV[1] > 0.f) { temp2.mV[1] = 1.f / temp2.mV[1]; } @@ -429,9 +464,9 @@ void LLSettingsSky::calculateLightSettings() //haze color vary_HazeColor = - (blue_horizon * blue_weight * (sunlight*(1.f - cloud_shadow) + tmpAmbient) + (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; @@ -449,7 +484,16 @@ void LLSettingsSky::calculateLightSettings() } - float dp = getSunDirection() * LLVector3(0, 0, 1.f); // a dot b +#if 0 + mSun.setColor(vary_SunlightColor); + mMoon.setColor(LLColor3(1.0f, 1.0f, 1.0f)); + + mSun.renewDirection(); + mSun.renewColor(); + mMoon.renewDirection(); + mMoon.renewColor(); + + float dp = getToSunLast() * LLVector3(0,0,1.f); if (dp < 0) { dp = 0; @@ -457,21 +501,19 @@ void LLSettingsSky::calculateLightSettings() // 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 = std::max(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - + F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); LLEnvironment::instance().setSceneLightStrength(2.0f * (1.0f + sun_dynamic_range * dp)); +#endif mSunDiffuse = vary_SunlightColor; mSunAmbient = vary_AmbientColor; mMoonDiffuse = vary_SunlightColor; mMoonAmbient = vary_AmbientColor; - mTotalAmbient = vary_AmbientColor; - mTotalAmbient.setAlpha(1); + mTotalAmbient = LLColor4(vary_AmbientColor, 1.0f); mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(1); -#endif + mFadeColor.setAlpha(0); } LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const @@ -490,7 +532,6 @@ LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const 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_GAMMA] = LLShaderMgr::GAMMA; param_map[SETTING_GLOW] = LLShaderMgr::GLOW; param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; @@ -507,7 +548,7 @@ void LLSettingsSky::applySpecial(void *ptarget) shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDirection.mV); - shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); + shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0); { //LLEnvironment::instance().getCloudDelta(); @@ -515,23 +556,6 @@ void LLSettingsSky::applySpecial(void *ptarget) vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); } - -// { -// LLVector4 val(mSettings[ ]; -// val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; -// val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; -// val.mV[2] = (F32)i->second[2].asReal(); -// val.mV[3] = (F32)i->second[3].asReal(); -// -// stop_glerror(); -// //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; -// shader->uniform4fv(param, 1, val.mV); -// stop_glerror(); -// -// } - - //param_map[SETTING_CLOUD_POS_DENSITY1] = LLShaderMgr::CLOUD_POS_DENSITY1; - } //========================================================================= @@ -539,9 +563,6 @@ namespace { LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) { - static const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); - static const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); - // Azimuth is traditionally calculated from North, we are going from East. LLQuaternion rot_azi; LLQuaternion rot_alt; @@ -552,11 +573,26 @@ namespace LLQuaternion body_quat = rot_alt * rot_azi; body_quat.normalize(); - LLVector3 sun_vector = (DUE_EAST * body_quat); - - - LL_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL; - + //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/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 0274661643..012244d1f9 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -67,13 +67,15 @@ public: static const std::string SETTING_LEGACY_SUN_ANGLE; 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(); + 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"); } @@ -89,6 +91,11 @@ public: return LLColor3(mSettings[SETTING_AMBIENT]); } + void setAmbientColor(const LLColor3 &val) + { + setValue(SETTING_AMBIENT, val); + } + LLUUID getBloomTextureId() const { return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); @@ -99,16 +106,31 @@ public: 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(); @@ -119,36 +141,83 @@ public: 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; @@ -161,9 +230,15 @@ public: //return mSettings[SETTING_DOME_RADIUS].asReal(); } - F32 getGama() const + F32 getGamma() const + { + return mSettings[SETTING_GAMMA].asReal(); + } + + void setGamma(F32 val) { - return mSettings[SETTING_GAMMA][0].asReal(); + mSettings[SETTING_GAMMA] = LLSD::Real(val); + setDirtyFlag(true); } LLColor3 getGlow() const @@ -171,21 +246,41 @@ public: 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(); @@ -196,6 +291,20 @@ public: 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(); @@ -206,58 +315,56 @@ public: return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); } + void setStarBrightness(F32 val) + { + setValue(SETTING_STAR_BRIGHTNESS, val); + } + LLColor3 getSunlightColor() const { return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); } - LLQuaternion getSunRotation() const + void setSunlightColor(const LLColor3 &val) { - return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); + setValue(SETTING_SUNLIGHT_COLOR, val); } - LLUUID getSunTextureId() const + LLQuaternion getSunRotation() const { - return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); + return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); } - // Internal/calculated settings - LLVector3 getLightDirection() const - { - update(); - return mLightDirection; - }; + azimalt_t getSunRotationAzAl() const; - LLVector3 getClampedLightDirection() const + void setSunRotation(const LLQuaternion &val) { - update(); - return mClampedLightDirection; - }; + setValue(SETTING_SUN_ROTATION, val); + } - LLVector3 getSunDirection() const + void setSunRotation(F32 azimuth, F32 altitude); + + void setSunRotation(const azimalt_t & azimalt) { - update(); - return mSunDirection; + setSunRotation(azimalt.first, azimalt.second); } - LLVector3 getMoonDirection() const + LLUUID getSunTextureId() const { - update(); - return mMoonDirection; + return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); } - -#if 0 + // Internal/calculated settings LLVector3 getLightDirection() const { update(); return mLightDirection; }; - LLVector3 getLightDirectionClamped() const + LLVector3 getClampedLightDirection() const { update(); - return mLightDirectionClamped; + return mClampedLightDirection; }; LLVector3 getSunDirection() const @@ -272,16 +379,16 @@ public: return mMoonDirection; } - LLColor3 getSunDiffuse() const + LLColor4U getFadeColor() const { update(); - return mSunDiffuse; + return mFadeColor; } - LLColor3 getSunAmbient() const + LLColor4 getMoonAmbient() const { update(); - return mSunAmbient; + return mMoonAmbient; } LLColor3 getMoonDiffuse() const @@ -290,24 +397,23 @@ public: return mMoonDiffuse; } - LLColor3 getMoonAmbient() const + LLColor4 getSunAmbient() const { update(); - return mMoonAmbient; + return mSunAmbient; } - LLColor4 getTotalAmbient() const + LLColor3 getSunDiffuse() const { update(); - return mTotalAmbient; + return mSunDiffuse; } - LLColor4 getFadeColor() const + LLColor4 getTotalAmbient() const { update(); - return mFadeColor; + return mTotalAmbient; } -#endif protected: LLSettingsSky(); @@ -320,6 +426,7 @@ protected: virtual void applySpecial(void *); + private: void calculateHeavnlyBodyPositions(); void calculateLightSettings(); @@ -332,13 +439,13 @@ private: static const F32 DOME_RADIUS; static const F32 DOME_OFFSET; -// LLColor3 mSunDiffuse; -// LLColor3 mSunAmbient; -// LLColor3 mMoonDiffuse; -// LLColor3 mMoonAmbient; -// -// LLColor4 mTotalAmbient; -// LLColor4 mFadeColor; + LLColor4U mFadeColor; + LLColor4 mMoonAmbient; + LLColor3 mMoonDiffuse; + LLColor4 mSunAmbient; + LLColor3 mSunDiffuse; + + LLColor4 mTotalAmbient; typedef std::map mapNameToUniformId_t; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 71abad79b6..93ca7945ba 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -331,24 +331,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mBumpSunDir(0.f, 0.f, 1.f) { /// WL PARAMS -// dome_radius = 1.f; -// dome_offset_ratio = 0.f; -// sunlight_color = LLColor3(); -// ambient = LLColor3(); -// gamma = 1.f; -// lightnorm = LLVector4(); -// blue_density = LLColor3(); -// blue_horizon = LLColor3(); -// haze_density = 0.f; -// haze_horizon = 1.f; -// density_multiplier = 0.f; -// max_y = 0.f; -// glow = LLColor3(); -// cloud_shadow = 0.f; -// cloud_color = LLColor3(); -// cloud_scale = 0.f; -// cloud_pos_density1 = LLColor3(); -// cloud_pos_density2 = LLColor3(); mInitialized = FALSE; mbCanSelect = FALSE; @@ -565,48 +547,6 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile) } } -void LLVOSky::initAtmospherics(void) -{ - - // *LAPRAS - // uniform parameters for convenience - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - -// dome_radius = psky->getDomeRadius(); -// dome_offset_ratio = psky->getDomeOffset(); -// sunlight_color = psky->getSunlightColor(); -// ambient = psky->getAmbientColor(); -// gamma = psky->getGama(); -// blue_density = psky->getBlueDensity(); -// blue_horizon = psky->getBlueHorizon(); -// haze_density = psky->getHazeDensity(); -// haze_horizon = psky->getHazeHorizon(); -// density_multiplier = psky->getDensityMultiplier(); -// max_y = psky->getMaxY(); -// glow = psky->getGlow(); -// cloud_shadow = psky->getCloudShadow(); -// cloud_color = psky->getCloudColor(); -// cloud_scale = psky->getCloudScale(); -// cloud_pos_density1 = psky->getCloudPosDensity1(); -// cloud_pos_density2 = psky->getCloudPosDensity2(); - - // light norm is different. We need the sun's direction, not the light direction - // which could be from the moon. And we need to clamp it - // just like for the gpu -// LLVector3 sunDir = gSky.getSunDirection(); - LLVector3 sunDir = psky->getSunDirection(); - - // CFR_TO_OGL -// lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); - lightnorm = LLVector4(sunDir, 0); - unclamped_lightnorm = lightnorm; - if(lightnorm.mV[1] < -0.1f) - { - lightnorm.mV[1] = -0.1f; - } - -} - LLColor4 LLVOSky::calcSkyColorInDir(const LLVector3 &dir, bool isShiny) { F32 saturation = 0.3f; @@ -681,8 +621,9 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLColor3 blue_density = psky->getBlueDensity(); - F32 max_y = psky->getMaxY(); + LLColor3 blue_density = psky->getBlueDensity(); + F32 max_y = psky->getMaxY(); + LLVector3 lightnorm = psky->getLightNormal(); // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); @@ -692,7 +633,6 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo sinA = 0.01f; } -// F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; F32 Plen = psky->getDomeRadius() * sin(F_PI + phi + asin(psky->getDomeOffset() * sinA)) / sinA; Pn *= Plen; @@ -748,7 +688,7 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo // Compute haze glow - temp2.mV[0] = Pn * LLVector3(lightnorm); + temp2.mV[0] = Pn * lightnorm; temp2.mV[0] = 1.f - temp2.mV[0]; // temp2.x is 0 at the sun and increases away from sun @@ -824,7 +764,7 @@ LLColor3 LLVOSky::calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLVector2 vary_HorizontalProjection[2]) { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - F32 gamma = psky->getGama(); + F32 gamma = psky->getGamma(); LLColor3 res; LLColor3 color0 = vary_HazeColor; @@ -893,87 +833,8 @@ LLColor3 LLVOSky::createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLC void LLVOSky::calcAtmospherics(void) { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - initAtmospherics(); - - LLColor3 vary_HazeColor; - LLColor3 vary_SunlightColor; - LLColor3 vary_AmbientColor; - { - // Initialize temp variables - LLColor3 sunlight = psky->getSunlightColor(); - LLColor3 ambient = psky->getAmbientColor(); - F32 gamma = psky->getGama(); - LLColor3 blue_density = psky->getBlueDensity(); - LLColor3 blue_horizon = psky->getBlueHorizon(); - F32 haze_density = psky->getHazeDensity(); - F32 haze_horizon = psky->getHazeHorizon(); - F32 density_multiplier = psky->getDensityMultiplier(); - F32 max_y = psky->getMaxY(); - F32 cloud_shadow = psky->getCloudShadow(); - - // 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 = unclamped_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); - } - - mSun.setColor(vary_SunlightColor); + mSun.setColor(psky->getSunlightColor()); mMoon.setColor(LLColor3(1.0f, 1.0f, 1.0f)); mSun.renewDirection(); @@ -992,16 +853,6 @@ void LLVOSky::calcAtmospherics(void) F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); LLEnvironment::instance().setSceneLightStrength(2.0f * (1.0f + sun_dynamic_range * dp)); - mSunDiffuse = vary_SunlightColor; - mSunAmbient = vary_AmbientColor; - mMoonDiffuse = vary_SunlightColor; - mMoonAmbient = vary_AmbientColor; - - mTotalAmbient = vary_AmbientColor; - mTotalAmbient.setAlpha(1); - - mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); } void LLVOSky::idleUpdate(LLAgent &agent, const F64 &time) @@ -1010,6 +861,10 @@ void LLVOSky::idleUpdate(LLAgent &agent, const F64 &time) BOOL LLVOSky::updateSky() { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor4 total_ambient = psky->getTotalAmbient(); + if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))) { return TRUE; @@ -1055,9 +910,9 @@ BOOL LLVOSky::updateSky() const F32 dot_lighting = direction * mLastLightingDirection; LLColor3 delta_color; - delta_color.setVec(mLastTotalAmbient.mV[0] - mTotalAmbient.mV[0], - mLastTotalAmbient.mV[1] - mTotalAmbient.mV[1], - mLastTotalAmbient.mV[2] - mTotalAmbient.mV[2]); + delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0], + mLastTotalAmbient.mV[1] - total_ambient.mV[1], + mLastTotalAmbient.mV[2] - total_ambient.mV[2]); if ( mForceUpdate || (((dot_lighting < LIGHT_DIRECTION_THRESHOLD) @@ -1066,7 +921,7 @@ BOOL LLVOSky::updateSky() && !direction.isExactlyZero())) { mLastLightingDirection = direction; - mLastTotalAmbient = mTotalAmbient; + mLastTotalAmbient = total_ambient; mInitialized = TRUE; if (mCubeMap) @@ -2039,7 +1894,6 @@ void LLVOSky::updateFog(const F32 distance) tosun_45.normalize(); // Sky colors, just slightly above the horizon in the direction of the sun, perpendicular to the sun, and at a 45 degree angle to the sun. - initAtmospherics(); res_color[0] = calcSkyColorInDir(tosun); res_color[1] = calcSkyColorInDir(perp_tosun); res_color[2] = calcSkyColorInDir(tosun_45); @@ -2240,3 +2094,34 @@ void LLVOSky::setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang mForceUpdate = TRUE; } } + + +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(); +} diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 32b5a7eba8..fe2d85df02 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -379,30 +379,8 @@ class LLCubeMap; class LLVOSky : public LLStaticViewerObject { -public: - /// WL PARAMS -// F32 dome_radius; -// F32 dome_offset_ratio; -// LLColor3 sunlight_color; -// LLColor3 ambient; -// F32 gamma; - LLVector4 lightnorm; - LLVector4 unclamped_lightnorm; -// LLColor3 blue_density; -// LLColor3 blue_horizon; -// F32 haze_density; -// F32 haze_horizon; -// F32 density_multiplier; -// F32 max_y; -// LLColor3 glow; -// F32 cloud_shadow; -// LLColor3 cloud_color; -// F32 cloud_scale; -// LLColor3 cloud_pos_density1; -// LLColor3 cloud_pos_density2; public: - void initAtmospherics(void); void calcAtmospherics(void); LLColor3 createDiffuseFromWL(LLColor3 diffuse, LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient); LLColor3 createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient); @@ -470,13 +448,12 @@ public: const LLVector3& getToMoon() const { return mMoon.getDirection(); } const LLVector3& getToMoonLast() const { return mMoon.getDirectionCached(); } BOOL isSunUp() const { return mSun.getDirectionCached().mV[2] > -0.05f; } - void calculateColors(); - LLColor3 getSunDiffuseColor() const { return mSunDiffuse; } - LLColor3 getMoonDiffuseColor() const { return mMoonDiffuse; } - LLColor4 getSunAmbientColor() const { return mSunAmbient; } - LLColor4 getMoonAmbientColor() const { return mMoonAmbient; } - const LLColor4& getTotalAmbientColor() const { return mTotalAmbient; } + LLColor3 getSunDiffuseColor() const; + LLColor3 getMoonDiffuseColor() const; + LLColor4 getSunAmbientColor() const; + LLColor4 getMoonAmbientColor() const; + LLColor4 getTotalAmbientColor() const; LLColor4 getFogColor() const { return mFogColor; } LLColor4 getGLFogColor() const { return mGLFogCol; } @@ -508,8 +485,8 @@ public: void setWorldScale(const F32 s) { mWorldScale = s; } void updateFog(const F32 distance); void setFogRatio(const F32 fog_ratio) { mFogRatio = fog_ratio; } - LLColor4U getFadeColor() const { return mFadeColor; } - F32 getFogRatio() const { return mFogRatio; } + LLColor4U getFadeColor() const; + F32 getFogRatio() const { return mFogRatio; } void setCloudDensity(F32 cloud_density) { mCloudDensity = cloud_density; } void setWind ( const LLVector3& wind ) { mWind = wind.length(); } @@ -576,12 +553,12 @@ protected: F32 mFogRatio; F32 mWorldScale; - LLColor4 mSunAmbient; - LLColor4 mMoonAmbient; - LLColor4 mTotalAmbient; - LLColor3 mSunDiffuse; - LLColor3 mMoonDiffuse; - LLColor4U mFadeColor; // Color to fade in from +// LLColor4 mSunAmbient; +// LLColor4 mMoonAmbient; +// LLColor4 mTotalAmbient; +// LLColor3 mSunDiffuse; +// LLColor3 mMoonDiffuse; +// LLColor4U mFadeColor; // Color to fade in from LLPointer mCubeMap; // Cube map for the environment S32 mDrawRefl; diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index b6e1c36a33..a6dc2b343b 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -68,28 +68,28 @@ LLWLParamManager::LLWLParamManager() : /// Sun Delta Terrain tweak variables. mSunDeltaYaw(180.0f), mSceneLightStrength(2.0f), - mWLGamma(1.0f, "gamma"), +// mWLGamma(1.0f, "gamma"), - mBlueHorizon(0.25f, 0.25f, 1.0f, 1.0f, "blue_horizon", "WLBlueHorizon"), - mHazeDensity(1.0f, "haze_density"), - mBlueDensity(0.25f, 0.25f, 0.25f, 1.0f, "blue_density", "WLBlueDensity"), - mDensityMult(1.0f, "density_multiplier", 1000), - mHazeHorizon(1.0f, "haze_horizon"), - mMaxAlt(4000.0f, "max_y"), +// mBlueHorizon(0.25f, 0.25f, 1.0f, 1.0f, "blue_horizon", "WLBlueHorizon"), +// mHazeDensity(1.0f, "haze_density"), +// mBlueDensity(0.25f, 0.25f, 0.25f, 1.0f, "blue_density", "WLBlueDensity"), +// mDensityMult(1.0f, "density_multiplier", 1000), +// mHazeHorizon(1.0f, "haze_horizon"), +// mMaxAlt(4000.0f, "max_y"), // Lighting - mLightnorm(0.f, 0.707f, -0.707f, 1.f, "lightnorm"), - mSunlight(0.5f, 0.5f, 0.5f, 1.0f, "sunlight_color", "WLSunlight"), - mAmbient(0.5f, 0.75f, 1.0f, 1.19f, "ambient", "WLAmbient"), - mGlow(18.0f, 0.0f, -0.01f, 1.0f, "glow"), +// mLightnorm(0.f, 0.707f, -0.707f, 1.f, "lightnorm"), +// mSunlight(0.5f, 0.5f, 0.5f, 1.0f, "sunlight_color", "WLSunlight"), +// mAmbient(0.5f, 0.75f, 1.0f, 1.19f, "ambient", "WLAmbient"), +// mGlow(18.0f, 0.0f, -0.01f, 1.0f, "glow"), // Clouds - mCloudColor(0.5f, 0.5f, 0.5f, 1.0f, "cloud_color", "WLCloudColor"), - mCloudMain(0.5f, 0.5f, 0.125f, 1.0f, "cloud_pos_density1"), - mCloudCoverage(0.0f, "cloud_shadow"), - mCloudDetail(0.0f, 0.0f, 0.0f, 1.0f, "cloud_pos_density2"), - mDistanceMult(1.0f, "distance_multiplier"), - mCloudScale(0.42f, "cloud_scale"), +// mCloudColor(0.5f, 0.5f, 0.5f, 1.0f, "cloud_color", "WLCloudColor"), +// mCloudMain(0.5f, 0.5f, 0.125f, 1.0f, "cloud_pos_density1"), +// mCloudCoverage(0.0f, "cloud_shadow"), +// mCloudDetail(0.0f, 0.0f, 0.0f, 1.0f, "cloud_pos_density2"), +// mDistanceMult(1.0f, "distance_multiplier"), +// mCloudScale(0.42f, "cloud_scale"), // sky dome mDomeOffset(0.96f), diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 61f86b747f..f7f4baee12 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -37,6 +37,7 @@ class LLGLSLShader; +#if 0 // color control struct WLColorControl { @@ -115,6 +116,8 @@ struct WLFloatControl { } }; +#endif + /// WindLight parameter manager class - what controls all the wind light shaders class LLWLParamManager : public LLSingleton { @@ -245,10 +248,12 @@ public: /// Sun Delta Terrain tweak variables. F32 mSunDeltaYaw; +#if 0 WLFloatControl mWLGamma; - +#endif F32 mSceneLightStrength; +#if 0 /// Atmospherics WLColorControl mBlueHorizon; WLFloatControl mHazeDensity; @@ -270,7 +275,7 @@ public: WLColorControl mCloudDetail; WLFloatControl mDistanceMult; WLFloatControl mCloudScale; - +#endif /// sky dome F32 mDomeOffset; F32 mDomeRadius; -- cgit v1.2.3 From cc22ffc6d799544e8f2a9dfed6813081d908c88d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 13 Oct 2017 17:17:49 -0700 Subject: Watter settings active and start of new joystick button type. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llappviewer.cpp | 1 - indra/newview/lldrawpoolwater.cpp | 116 ++++---- indra/newview/lldrawpoolwater.h | 5 +- indra/newview/llenvadapters.cpp | 18 ++ indra/newview/llenvadapters.h | 221 ++++++++++++-- indra/newview/llenvironment.cpp | 155 ++++++++-- indra/newview/llenvironment.h | 69 ++++- indra/newview/llfloatereditsky.cpp | 5 - indra/newview/llfloatereditwater.cpp | 381 ++++++++----------------- indra/newview/llfloatereditwater.h | 50 ++-- indra/newview/llfloaterenvironmentsettings.cpp | 18 +- indra/newview/lljoystickbutton.cpp | 184 +++++++++++- indra/newview/lljoystickbutton.h | 31 ++ indra/newview/llsettingssky.cpp | 15 +- indra/newview/llsettingssky.h | 8 +- indra/newview/llsettingswater.cpp | 268 +++++++++++++++++ indra/newview/llsettingswater.h | 234 +++++++++++++++ indra/newview/llstartup.cpp | 6 +- indra/newview/llviewerdisplay.cpp | 4 +- indra/newview/llviewershadermgr.cpp | 1 - indra/newview/llvosky.cpp | 6 +- indra/newview/llwaterparammanager.cpp | 34 ++- indra/newview/llwaterparammanager.h | 10 +- indra/newview/pipeline.cpp | 4 +- 25 files changed, 1401 insertions(+), 445 deletions(-) create mode 100644 indra/newview/llsettingswater.cpp create mode 100644 indra/newview/llsettingswater.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index d8d1c0b51e..b46e0971e2 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -537,6 +537,7 @@ set(viewer_SOURCE_FILES llselectmgr.cpp llsettingsbase.cpp llsettingssky.cpp + llsettingswater.cpp llshareavatarhandler.cpp llsidepanelappearance.cpp llsidepanelinventory.cpp @@ -1153,6 +1154,7 @@ set(viewer_HEADER_FILES llselectmgr.h llsettingsbase.h llsettingssky.h + llsettingswater.h llsidepanelappearance.h llsidepanelinventory.h llsidepanelinventorysubpanel.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 529bd429a4..3794c19bb1 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -170,7 +170,6 @@ #include "llviewerparcelmgr.h" #include "llworldmapview.h" #include "llpostprocess.h" -#include "llwaterparammanager.h" #include "lldebugview.h" #include "llconsole.h" diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index df06ad31e6..567172e647 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -46,7 +46,9 @@ #include "llworld.h" #include "pipeline.h" #include "llviewershadermgr.h" -#include "llwaterparammanager.h" +#include "llenvironment.h" +#include "llsettingssky.h" +#include "llsettingswater.h" const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004"); const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); @@ -58,10 +60,10 @@ BOOL deferred_render = FALSE; BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE; BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE; BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; -LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); +//LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); F32 LLDrawPoolWater::sWaterFogEnd = 0.f; -LLVector3 LLDrawPoolWater::sLightDir; +//LLVector3 LLDrawPoolWater::sLightDir; LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER) @@ -110,8 +112,6 @@ void LLDrawPoolWater::prerender() // got rid of modulation by light color since it got a little too // green at sunset and sl-57047 (underwater turns black at 8:00) - sWaterFogColor = LLWaterParamManager::instance().getFogColor(); - sWaterFogColor.mV[3] = 0; } @@ -488,29 +488,50 @@ void LLDrawPoolWater::shade() LLVector3 light_dir; LLColor3 light_color; - if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) - { - light_dir = gSky.getSunDirection(); - light_dir.normVec(); - light_color = gSky.getSunDiffuseColor(); - if(gSky.mVOSkyp) { - light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); - light_diffuse.normVec(); - } - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - light_diffuse *= light_exp + 0.25f; - } - else - { - light_dir = gSky.getMoonDirection(); - light_dir.normVec(); - light_color = gSky.getMoonDiffuseColor(); - light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); - light_diffuse.normVec(); - light_diffuse *= 0.5f; - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + + light_dir = psky->getLightDirection(); + if (LLEnvironment::instance().getIsDayTime()) + { + light_color = psky->getSunAmbient(); + light_diffuse = psky->getSunDiffuse(); + light_diffuse.normalize(); + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); + light_diffuse *= (light_exp + 0.25f); + } + else + { + light_color = psky->getMoonAmbient(); + light_diffuse = psky->getMoonDiffuse(); + light_diffuse.normalize(); + light_diffuse *= 0.5f; + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); } +// if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) +// { +// light_dir = gSky.getSunDirection(); +// light_dir.normVec(); +// light_color = gSky.getSunDiffuseColor(); +// if(gSky.mVOSkyp) { +// light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); +// light_diffuse.normVec(); +// } +// light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); +// light_diffuse *= light_exp + 0.25f; +// } +// else +// { +// light_dir = gSky.getMoonDirection(); +// light_dir.normVec(); +// light_color = gSky.getMoonDiffuseColor(); +// light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); +// light_diffuse.normVec(); +// light_diffuse *= 0.5f; +// light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); +// } + light_exp *= light_exp; light_exp *= light_exp; light_exp *= light_exp; @@ -518,9 +539,11 @@ void LLDrawPoolWater::shade() light_exp *= 256.f; light_exp = light_exp > 32.f ? light_exp : 32.f; + light_diffuse *= 6.f; + LLGLSLShader* shader; - F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight(); if (eyedepth < 0.f && LLPipeline::sWaterReflections) { @@ -551,7 +574,7 @@ void LLDrawPoolWater::shade() shader->bind(); } - sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; + sTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f; S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); @@ -565,12 +588,10 @@ void LLDrawPoolWater::shade() //bind normal map S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); - LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); - // change mWaterNormp if needed - if (mWaterNormp->getID() != param_mgr->getNormalMapID()) + if (mWaterNormp->getID() != pwater->getNormalMapID()) { - mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); + mWaterNormp = LLViewerTextureManager::getFetchedTexture(pwater->getNormalMapID()); } mWaterNormp->addTextureStats(1024.f*1024.f); @@ -588,9 +609,8 @@ void LLDrawPoolWater::shade() if (screentex > -1) { - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, - param_mgr->getFogDensity()); + shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getFogColor().mV); + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, pwater->getFogDensity()); gPipeline.mWaterDis.bindTexture(0, screentex); } @@ -600,8 +620,9 @@ void LLDrawPoolWater::shade() if (mVertexShaderLevel == 1) { - sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + LLColor4 fog_color(pwater->getFogColor(), 0.f); + fog_color[3] = pwater->getFogDensity(); + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV); } F32 screenRes[] = @@ -615,25 +636,20 @@ void LLDrawPoolWater::shade() S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP); stop_glerror(); - light_dir.normVec(); - sLightDir = light_dir; - - light_diffuse *= 6.f; - //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth); shader->uniform1f(LLShaderMgr::WATER_TIME, sTime); shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); - shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); - shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, pwater->getWave1Dir().mV); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, pwater->getWave2Dir().mV); shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); - shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV); - shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale()); - shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset()); - shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier()); + shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, pwater->getNormalScale().mV); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, pwater->getFresnelScale()); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, pwater->getFresnelOffset()); + shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, pwater->getBlurMultiplier()); F32 sunAngle = llmax(0.f, light_dir.mV[2]); F32 scaledAngle = 1.f - sunAngle; @@ -648,12 +664,12 @@ void LLDrawPoolWater::shade() if (LLViewerCamera::getInstance()->cameraUnderWater()) { water_color.setVec(1.f, 1.f, 1.f, 0.4f); - shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleBelow()); } else { water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleAbove()); } if (water_color.mV[3] > 0.9f) diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h index aeeba179d6..55f892d249 100644 --- a/indra/newview/lldrawpoolwater.h +++ b/indra/newview/lldrawpoolwater.h @@ -46,9 +46,8 @@ public: static BOOL sSkipScreenCopy; static BOOL sNeedsReflectionUpdate; static BOOL sNeedsDistortionUpdate; - static LLVector3 sLightDir; - - static LLColor4 sWaterFogColor; +// static LLVector3 sLightDir; +// static LLColor4 sWaterFogColor; static F32 sWaterFogEnd; enum diff --git a/indra/newview/llenvadapters.cpp b/indra/newview/llenvadapters.cpp index 8bed0737dd..34fd862655 100644 --- a/indra/newview/llenvadapters.cpp +++ b/indra/newview/llenvadapters.cpp @@ -28,6 +28,7 @@ #include "llenvadapters.h" #include "llsettingssky.h" +#include "llsettingswater.h" //========================================================================= LLSkySettingsAdapter::LLSkySettingsAdapter(): @@ -53,3 +54,20 @@ LLSkySettingsAdapter::LLSkySettingsAdapter(): { } + +LLWatterSettingsAdapter::LLWatterSettingsAdapter(): + mFogColor(LLColor4((22.f / 255.f), (43.f / 255.f), (54.f / 255.f), (0.0f)), LLSettingsWater::SETTING_FOG_COLOR, "WaterFogColor"), + mFogDensity(4, LLSettingsWater::SETTING_FOG_DENSITY, 2), + mUnderWaterFogMod(0.25, LLSettingsWater::SETTING_FOG_MOD), + mNormalScale(LLVector3(2.f, 2.f, 2.f), LLSettingsWater::SETTING_NORMAL_SCALE), + mFresnelScale(0.5f, LLSettingsWater::SETTING_FRESNEL_SCALE), + mFresnelOffset(0.4f, LLSettingsWater::SETTING_FRESNEL_OFFSET), + mScaleAbove(0.025f, LLSettingsWater::SETTING_SCALE_ABOVE), + mScaleBelow(0.2f, LLSettingsWater::SETTING_SCALE_BELOW), + mBlurMultiplier(0.1f, LLSettingsWater::SETTING_BLUR_MULTIPILER), + mWave1Dir(LLVector2(0.5f, 0.5f), LLSettingsWater::SETTING_WAVE1_DIR), + mWave2Dir(LLVector2(0.5f, 0.5f), LLSettingsWater::SETTING_WAVE2_DIR) + +{ + +} diff --git a/indra/newview/llenvadapters.h b/indra/newview/llenvadapters.h index fc7a47be1b..3241e43191 100644 --- a/indra/newview/llenvadapters.h +++ b/indra/newview/llenvadapters.h @@ -185,6 +185,169 @@ private: F32 mult; }; +class WLXFloatControl +{ +public: + inline WLXFloatControl(F32 val, const std::string& n, F32 b): + mExp(val), + mBase(b), + mName(n) + { + } + + inline WLXFloatControl & operator = (F32 val) + { + mExp = log(val) / log(mBase); + + return *this; + } + + inline operator F32 (void) const + { + return pow(mBase, mExp); + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, pow(mBase, mExp)); + } + + inline F32 getExp() const + { + return mExp; + } + + inline void setExp(F32 val) + { + mExp = val; + } + + inline F32 getBase() const + { + return mBase; + } + + inline void setBase(F32 val) + { + mBase = val; + } + +private: + F32 mExp; + F32 mBase; + std::string mName; +}; + +class WLVect2Control +{ +public: + inline WLVect2Control(LLVector2 val, const std::string& n): + mU(val.mV[0]), + mV(val.mV[1]), + mName(n) + { + } + + inline WLVect2Control & operator = (const LLVector2 & val) + { + mU = val.mV[0]; + mV = val.mV[1]; + + return *this; + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, LLVector2(mU, mV)); + } + + inline F32 getU() const + { + return mU; + } + + inline void setU(F32 val) + { + mU = val; + } + + inline F32 getV() const + { + return mV; + } + + inline void setV(F32 val) + { + mV = val; + } + +private: + F32 mU; + F32 mV; + std::string mName; +}; + +class WLVect3Control +{ +public: + inline WLVect3Control(LLVector3 val, const std::string& n): + mX(val.mV[0]), + mY(val.mV[1]), + mZ(val.mV[2]), + mName(n) + { + } + + inline WLVect3Control & operator = (const LLVector3 & val) + { + mX = val.mV[0]; + mY = val.mV[1]; + mZ = val.mV[2]; + + return *this; + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, LLVector3(mX, mY, mZ)); + } + + inline F32 getX() const + { + return mX; + } + + inline void setX(F32 val) + { + mX = val; + } + + inline F32 getY() const + { + return mY; + } + + inline void setY(F32 val) + { + mY = val; + } + + inline F32 getZ() const + { + return mZ; + } + + inline void setZ(F32 val) + { + mZ = val; + } + +private: + F32 mX; + F32 mY; + F32 mZ; + std::string mName; +}; //------------------------------------------------------------------------- class LLSkySettingsAdapter @@ -194,32 +357,54 @@ public: LLSkySettingsAdapter(); - WLFloatControl mWLGamma; + WLFloatControl mWLGamma; /// Atmospherics - WLColorControl mBlueHorizon; - WLFloatControl mHazeDensity; - WLColorControl mBlueDensity; - WLFloatControl mDensityMult; - WLFloatControl mHazeHorizon; - WLFloatControl mMaxAlt; + WLColorControl mBlueHorizon; + WLFloatControl mHazeDensity; + WLColorControl mBlueDensity; + WLFloatControl mDensityMult; + WLFloatControl mHazeHorizon; + WLFloatControl mMaxAlt; /// Lighting - WLColorControl mLightnorm; - WLColorControl mSunlight; - WLColorControl mAmbient; - WLColorControl mGlow; + WLColorControl mLightnorm; + WLColorControl mSunlight; + WLColorControl mAmbient; + WLColorControl mGlow; /// Clouds - WLColorControl mCloudColor; - WLColorControl mCloudMain; - WLFloatControl mCloudCoverage; - WLColorControl mCloudDetail; - WLFloatControl mDistanceMult; - WLFloatControl mCloudScale; + WLColorControl mCloudColor; + WLColorControl mCloudMain; + WLFloatControl mCloudCoverage; + WLColorControl mCloudDetail; + WLFloatControl mDistanceMult; + WLFloatControl mCloudScale; +}; + +class LLWatterSettingsAdapter +{ +public: + typedef std::shared_ptr ptr_t; + + LLWatterSettingsAdapter(); + WLColorControl mFogColor; + WLXFloatControl mFogDensity; + WLFloatControl mUnderWaterFogMod; + + /// wavelet scales and directions + WLVect3Control mNormalScale; + WLVect2Control mWave1Dir; + WLVect2Control mWave2Dir; + + // controls how water is reflected and refracted + WLFloatControl mFresnelScale; + WLFloatControl mFresnelOffset; + WLFloatControl mScaleAbove; + WLFloatControl mScaleBelow; + WLFloatControl mBlurMultiplier; }; #endif // LL_ENVIRONMENT_H - diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 4192da450e..921f3ef910 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -32,44 +32,69 @@ #include "lldaycyclemanager.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewerregion.h" -#include "llwaterparammanager.h" #include "llwlhandlers.h" #include "lltrans.h" #include "lltrace.h" #include "llfasttimer.h" #include "llviewercamera.h" #include "pipeline.h" +#include "llsky.h" //========================================================================= -const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg - namespace { LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); } +//========================================================================= +const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg +const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); + //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): mCurrentSky(), + mCurrentWater(), mSkysById(), - mSkysByName() + mSkysByName(), + mWaterByName(), + mWaterById(), + mUserPrefs() { LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); addSky(p_default_sky); mCurrentSky = p_default_sky; + + LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); + addWater(p_default_water); + mCurrentWater = p_default_water; } LLEnvironment::~LLEnvironment() { } +void LLEnvironment::loadPreferences() +{ + mUserPrefs.load(); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); } +F32 LLEnvironment::getWaterHeight() const +{ + return gAgent.getRegion()->getWaterHeight(); +} + +bool LLEnvironment::getIsDayTime() const +{ + return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -201,6 +226,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) if (gPipeline.canUseWindLightShaders()) { updateGLVariablesForSettings(shader, mCurrentSky); + updateGLVariablesForSettings(shader, mCurrentWater); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -229,35 +255,35 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; - std::pair result; - result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); + std::pair result; + result = mSkysByName.insert(NamedSettingMap_t::value_type(name, sky)); if (!result.second) (*(result.first)).second = sky; } -void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) -{ - // std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); - // - // std::pair result; - // result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); - // - // if (!result.second) - // (*(result.first)).second = sky; -} +// void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) +// { +// // std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); +// // +// // std::pair result; +// // result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); +// // +// // if (!result.second) +// // (*(result.first)).second = sky; +// } void LLEnvironment::removeSky(const std::string &name) { - NamedSkyMap_t::iterator it = mSkysByName.find(name); + NamedSettingMap_t::iterator it = mSkysByName.find(name); if (it != mSkysByName.end()) mSkysByName.erase(it); } -void LLEnvironment::removeSky(const LLUUID &id) -{ - -} +// void LLEnvironment::removeSky(const LLUUID &id) +// { +// +// } void LLEnvironment::clearAllSkys() { @@ -267,12 +293,95 @@ void LLEnvironment::clearAllSkys() void LLEnvironment::selectSky(const std::string &name) { - NamedSkyMap_t::iterator it = mSkysByName.find(name); + NamedSettingMap_t::iterator it = mSkysByName.find(name); if (it == mSkysByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; return; + } - mCurrentSky = (*it).second; + mCurrentSky = boost::static_pointer_cast((*it).second); mCurrentSky->setDirtyFlag(true); } +void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) +{ + std::string name = water->getValue(LLSettingsWater::SETTING_NAME).asString(); + + LL_WARNS("RIDER") << "Adding water as '" << name << "'" << LL_ENDL; + + std::pair result; + result = mWaterByName.insert(NamedSettingMap_t::value_type(name, water)); + + if (!result.second) + (*(result.first)).second = water; +} + +//void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + +void LLEnvironment::selectWater(const std::string &name) +{ + NamedSettingMap_t::iterator it = mWaterByName.find(name); + + if (it == mWaterByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; + return; + } + + mCurrentWater = boost::static_pointer_cast((*it).second); + mCurrentWater->setDirtyFlag(true); +} + +void LLEnvironment::removeWater(const std::string &name) +{ + NamedSettingMap_t::iterator it = mWaterByName.find(name); + if (it != mWaterByName.end()) + mWaterByName.erase(it); +} + +//void LLEnvironment::removeWater(const LLUUID &id); +void LLEnvironment::clearAllWater() +{ + mWaterByName.clear(); + mWaterById.clear(); +} + + +//========================================================================= +LLEnvironment::UserPrefs::UserPrefs(): + mUseRegionSettings(true), + mUseDayCycle(true), + mPersistEnvironment(false), + mWaterPresetName(), + mSkyPresetName(), + mDayCycleName() +{} + + +void LLEnvironment::UserPrefs::load() +{ + mPersistEnvironment = gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin"); + + mWaterPresetName = gSavedSettings.getString("WaterPresetName"); + mSkyPresetName = gSavedSettings.getString("SkyPresetName"); + mDayCycleName = gSavedSettings.getString("DayCycleName"); + + mUseRegionSettings = mPersistEnvironment ? gSavedSettings.getBOOL("UseEnvironmentFromRegion") : true; + mUseDayCycle = mPersistEnvironment ? gSavedSettings.getBOOL("UseDayCycle") : true; +} + +void LLEnvironment::UserPrefs::store() +{ + gSavedSettings.setBOOL("EnvironmentPersistAcrossLogin", mPersistEnvironment); + if (mPersistEnvironment) + { + gSavedSettings.setString("WaterPresetName", getWaterPresetName()); + gSavedSettings.setString("SkyPresetName", getSkyPresetName()); + gSavedSettings.setString("DayCycleName", getDayCycleName()); + + gSavedSettings.setBOOL("UseEnvironmentFromRegion", getUseRegionSettings()); + gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); + } +} diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index a1bdf2c38c..7506b37e3e 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -31,10 +31,14 @@ #include "llsd.h" #include "llsettingssky.h" +#include "llsettingswater.h" class LLViewerCamera; class LLGLSLShader; +//------------------------------------------------------------------------- + + //------------------------------------------------------------------------- class LLEnvironment : public LLSingleton { @@ -42,9 +46,44 @@ class LLEnvironment : public LLSingleton LOG_CLASS(LLEnvironment); public: + class UserPrefs + { + friend class LLEnvironment; + public: + UserPrefs(); + + bool getUseRegionSettings() const { return mUseRegionSettings; } + bool getUseDayCycle() const { return mUseDayCycle; } + bool getUseFixedSky() const { return !getUseDayCycle(); } + + std::string getWaterPresetName() const { return mWaterPresetName; } + std::string getSkyPresetName() const { return mSkyPresetName; } + std::string getDayCycleName() const { return mDayCycleName; } + + void setUseRegionSettings(bool val); + void setUseWaterPreset(const std::string& name); + void setUseSkyPreset(const std::string& name); + void setUseDayCycle(const std::string& name); + + private: + void load(); + void store(); + + bool mUseRegionSettings; + bool mUseDayCycle; + bool mPersistEnvironment; + std::string mWaterPresetName; + std::string mSkyPresetName; + std::string mDayCycleName; + }; + virtual ~LLEnvironment(); + void loadPreferences(); + const UserPrefs & getPreferences() const { return mUserPrefs; } + LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } + LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } void update(const LLViewerCamera * cam); @@ -53,10 +92,15 @@ public: void addSky(const LLSettingsSky::ptr_t &sky); void selectSky(const std::string &name); + void addWater(const LLSettingsWater::ptr_t &sky); + void selectWater(const std::string &name); inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } F32 getCamHeight() const; + F32 getWaterHeight() const; + bool getIsDayTime() const; // "Day Time" is defined as the sun above the horizon. + bool getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time" inline F32 getSceneLightStrength() const { return mSceneLightStrength; } inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } @@ -65,27 +109,40 @@ public: inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } inline LLVector4 getRotatedLight() const { return mRotatedLight; } + private: static const F32 SUN_DELTA_YAW; + static const F32 NIGHTTIME_ELEVATION_COS; - typedef std::map NamedSkyMap_t; - typedef std::map AssetSkyMap_t; + typedef std::map NamedSettingMap_t; + typedef std::map AssetSettingMap_t; LLVector2 mCloudScrollDelta; // cumulative cloud delta LLSettingsSky::ptr_t mCurrentSky; + LLSettingsWater::ptr_t mCurrentWater; + + NamedSettingMap_t mSkysByName; + AssetSettingMap_t mSkysById; - NamedSkyMap_t mSkysByName; - AssetSkyMap_t mSkysById; + NamedSettingMap_t mWaterByName; + AssetSettingMap_t mWaterById; F32 mSceneLightStrength; LLVector4 mRotatedLight; - void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + UserPrefs mUserPrefs; + + //void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); - void removeSky(const LLUUID &id); + //void removeSky(const LLUUID &id); void clearAllSkys(); + //void addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + void removeWater(const std::string &name); + //void removeWater(const LLUUID &id); + void clearAllWater(); + void updateCloudScroll(); }; diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 1ca61e758f..40f86e3778 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -145,11 +145,6 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); - // *LAPRAS - // TODO: -// LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); -// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); - // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 43b44eae37..41180b5da8 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -28,6 +28,8 @@ #include "llfloatereditwater.h" +#include + // libs #include "llbutton.h" #include "llcheckboxctrl.h" @@ -42,16 +44,22 @@ #include "llagent.h" #include "llregioninfomodel.h" #include "llviewerregion.h" -#include "llwaterparammanager.h" + +#include "llenvironment.h" +#include "llsettingswater.h" +#include "llenvadapters.h" + +#include "v3colorutil.h" #undef max // Fixes a Windows compiler error -LLFloaterEditWater::LLFloaterEditWater(const LLSD &key) -: LLFloater(key) -, mWaterPresetNameEditor(NULL) -, mWaterPresetCombo(NULL) -, mMakeDefaultCheckBox(NULL) -, mSaveButton(NULL) +LLFloaterEditWater::LLFloaterEditWater(const LLSD &key): + LLFloater(key), + mWaterPresetNameEditor(NULL), + mWaterPresetCombo(NULL), + mMakeDefaultCheckBox(NULL), + mSaveButton(NULL), + mWaterAdapter() { } @@ -63,6 +71,8 @@ BOOL LLFloaterEditWater::postBuild() mMakeDefaultCheckBox = getChild("make_default_cb"); mSaveButton = getChild("save"); + mWaterAdapter = boost::make_shared(); + initCallbacks(); refreshWaterPresetsList(); syncControls(); @@ -99,7 +109,7 @@ void LLFloaterEditWater::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment +// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment } } @@ -119,44 +129,38 @@ void LLFloaterEditWater::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnSave, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnCancel, this)); - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditWater::onRegionSettingsChange, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this)); - // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditWater::onRegionInfoUpdate, this)); //------------------------------------------------------------------------- - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - - getChild("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onWaterFogColorMoved, this, _1, &water_mgr.mFogColor)); - //getChild("WaterGlow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlAMoved, this, _1, &water_mgr.mFogColor)); + getChild("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlMoved, this, _1, &mWaterAdapter->mFogColor)); // fog density - getChild("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &water_mgr.mFogDensity)); - getChild("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mUnderWaterFogMod)); + getChild("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &mWaterAdapter->mFogDensity)); + getChild("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mUnderWaterFogMod)); // blue density - getChild("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &water_mgr.mNormalScale)); - getChild("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &water_mgr.mNormalScale)); - getChild("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &water_mgr.mNormalScale)); + getChild("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &mWaterAdapter->mNormalScale)); + getChild("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &mWaterAdapter->mNormalScale)); + getChild("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &mWaterAdapter->mNormalScale)); // fresnel - getChild("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelScale)); - getChild("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelOffset)); + getChild("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelScale)); + getChild("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelOffset)); // scale above/below - getChild("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleAbove)); - getChild("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleBelow)); + getChild("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleAbove)); + getChild("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleBelow)); // blur mult - getChild("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mBlurMultiplier)); + getChild("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mBlurMultiplier)); // wave direction - getChild("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave1Dir)); - getChild("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave1Dir)); - getChild("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave2Dir)); - getChild("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave2Dir)); + getChild("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave1Dir)); + getChild("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave1Dir)); + getChild("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave2Dir)); + getChild("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave2Dir)); LLTextureCtrl* texture_ctrl = getChild("WaterNormalMap"); texture_ctrl->setDefaultImageAssetID(DEFAULT_WATER_NORMAL); @@ -169,304 +173,128 @@ void LLFloaterEditWater::syncControls() { // *TODO: Eliminate slow getChild() calls. - bool err; + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mEditSettings = pwater; - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - - LLWaterParamSet& current_params = water_mgr.mCurParams; - - // blue horizon - water_mgr.mFogColor = current_params.getVector4(water_mgr.mFogColor.mName, err); - - LLColor4 col = water_mgr.getFogColor(); //getChild("WaterGlow")->setValue(col.mV[3]); - col.mV[3] = 1.0f; - getChild("WaterFogColor")->set(col); + getChild("WaterFogColor")->set(LLColor4(pwater->getFogColor())); // fog and wavelets - water_mgr.mFogDensity.mExp = - log(current_params.getFloat(water_mgr.mFogDensity.mName, err)) / - log(water_mgr.mFogDensity.mBase); - water_mgr.setDensitySliderValue(water_mgr.mFogDensity.mExp); - getChild("WaterFogDensity")->setValue(water_mgr.mFogDensity.mExp); + mWaterAdapter->mFogDensity = pwater->getFogDensity(); + getChild("WaterFogDensity")->setValue(mWaterAdapter->mFogDensity.getExp()); - water_mgr.mUnderWaterFogMod.mX = - current_params.getFloat(water_mgr.mUnderWaterFogMod.mName, err); - getChild("WaterUnderWaterFogMod")->setValue(water_mgr.mUnderWaterFogMod.mX); + mWaterAdapter->mUnderWaterFogMod = pwater->getFogMod(); + getChild("WaterUnderWaterFogMod")->setValue(static_cast(mWaterAdapter->mUnderWaterFogMod)); - water_mgr.mNormalScale = current_params.getVector3(water_mgr.mNormalScale.mName, err); - getChild("WaterNormalScaleX")->setValue(water_mgr.mNormalScale.mX); - getChild("WaterNormalScaleY")->setValue(water_mgr.mNormalScale.mY); - getChild("WaterNormalScaleZ")->setValue(water_mgr.mNormalScale.mZ); + mWaterAdapter->mNormalScale = pwater->getNormalScale(); + getChild("WaterNormalScaleX")->setValue(mWaterAdapter->mNormalScale.getX()); + getChild("WaterNormalScaleY")->setValue(mWaterAdapter->mNormalScale.getY()); + getChild("WaterNormalScaleZ")->setValue(mWaterAdapter->mNormalScale.getZ()); // Fresnel - water_mgr.mFresnelScale.mX = current_params.getFloat(water_mgr.mFresnelScale.mName, err); - getChild("WaterFresnelScale")->setValue(water_mgr.mFresnelScale.mX); - water_mgr.mFresnelOffset.mX = current_params.getFloat(water_mgr.mFresnelOffset.mName, err); - getChild("WaterFresnelOffset")->setValue(water_mgr.mFresnelOffset.mX); + mWaterAdapter->mFresnelScale = pwater->getFresnelScale(); + getChild("WaterFresnelScale")->setValue(static_cast(mWaterAdapter->mFresnelScale)); + mWaterAdapter->mFresnelOffset = pwater->getFresnelOffset(); + getChild("WaterFresnelOffset")->setValue(static_cast(mWaterAdapter->mFresnelOffset)); // Scale Above/Below - water_mgr.mScaleAbove.mX = current_params.getFloat(water_mgr.mScaleAbove.mName, err); - getChild("WaterScaleAbove")->setValue(water_mgr.mScaleAbove.mX); - water_mgr.mScaleBelow.mX = current_params.getFloat(water_mgr.mScaleBelow.mName, err); - getChild("WaterScaleBelow")->setValue(water_mgr.mScaleBelow.mX); + mWaterAdapter->mScaleAbove = pwater->getScaleAbove(); + getChild("WaterScaleAbove")->setValue(static_cast(mWaterAdapter->mScaleAbove)); + mWaterAdapter->mScaleBelow = pwater->getScaleBelow(); + getChild("WaterScaleBelow")->setValue(static_cast(mWaterAdapter->mScaleBelow)); // blur mult - water_mgr.mBlurMultiplier.mX = current_params.getFloat(water_mgr.mBlurMultiplier.mName, err); - getChild("WaterBlurMult")->setValue(water_mgr.mBlurMultiplier.mX); + mWaterAdapter->mBlurMultiplier = pwater->getBlurMultiplier(); + getChild("WaterBlurMult")->setValue(static_cast(mWaterAdapter->mBlurMultiplier)); // wave directions - water_mgr.mWave1Dir = current_params.getVector2(water_mgr.mWave1Dir.mName, err); - getChild("WaterWave1DirX")->setValue(water_mgr.mWave1Dir.mX); - getChild("WaterWave1DirY")->setValue(water_mgr.mWave1Dir.mY); + mWaterAdapter->mWave1Dir = pwater->getWave1Dir(); + getChild("WaterWave1DirX")->setValue(mWaterAdapter->mWave1Dir.getU()); + getChild("WaterWave1DirY")->setValue(mWaterAdapter->mWave1Dir.getV()); - water_mgr.mWave2Dir = current_params.getVector2(water_mgr.mWave2Dir.mName, err); - getChild("WaterWave2DirX")->setValue(water_mgr.mWave2Dir.mX); - getChild("WaterWave2DirY")->setValue(water_mgr.mWave2Dir.mY); + mWaterAdapter->mWave2Dir = pwater->getWave2Dir(); + getChild("WaterWave2DirX")->setValue(mWaterAdapter->mWave2Dir.getU()); + getChild("WaterWave2DirY")->setValue(mWaterAdapter->mWave2Dir.getV()); LLTextureCtrl* textCtrl = getChild("WaterNormalMap"); - textCtrl->setImageAssetID(water_mgr.getNormalMapID()); -} - -// color control callbacks -void LLFloaterEditWater::onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - color_ctrl->mR = sldr_ctrl->getValueF32(); - - // move i if it's the max - if (color_ctrl->mR >= color_ctrl->mG - && color_ctrl->mR >= color_ctrl->mB - && color_ctrl->mHasSliderName) - { - color_ctrl->mI = color_ctrl->mR; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - getChild(name)->setValue(color_ctrl->mR); - } - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - color_ctrl->mG = sldr_ctrl->getValueF32(); - - // move i if it's the max - if (color_ctrl->mG >= color_ctrl->mR - && color_ctrl->mG >= color_ctrl->mB - && color_ctrl->mHasSliderName) - { - color_ctrl->mI = color_ctrl->mG; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - getChild(name)->setValue(color_ctrl->mG); - - } - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - color_ctrl->mB = sldr_ctrl->getValueF32(); - - // move i if it's the max - if (color_ctrl->mB >= color_ctrl->mR - && color_ctrl->mB >= color_ctrl->mG - && color_ctrl->mHasSliderName) - { - color_ctrl->mI = color_ctrl->mB; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - getChild(name)->setValue(color_ctrl->mB); - } - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - color_ctrl->mA = sldr_ctrl->getValueF32(); - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + textCtrl->setImageAssetID(pwater->getNormalMapID()); } -void LLFloaterEditWater::onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - color_ctrl->mI = sldr_ctrl->getValueF32(); - - // only for sliders where we pass a name - if (color_ctrl->mHasSliderName) - { - // set it to the top - F32 maxVal = std::max(std::max(color_ctrl->mR, color_ctrl->mG), color_ctrl->mB); - F32 iVal; - - iVal = color_ctrl->mI; - - // get the names of the other sliders - std::string rName = color_ctrl->mSliderName; - rName.append("R"); - std::string gName = color_ctrl->mSliderName; - gName.append("G"); - std::string bName = color_ctrl->mSliderName; - bName.append("B"); - - // handle if at 0 - if (iVal == 0) - { - color_ctrl->mR = 0; - color_ctrl->mG = 0; - color_ctrl->mB = 0; - - // if all at the start - // set them all to the intensity - } - else if (maxVal == 0) - { - color_ctrl->mR = iVal; - color_ctrl->mG = iVal; - color_ctrl->mB = iVal; - } - else - { - // add delta amounts to each - F32 delta = (iVal - maxVal) / maxVal; - color_ctrl->mR *= (1.0f + delta); - color_ctrl->mG *= (1.0f + delta); - color_ctrl->mB *= (1.0f + delta); - } - - // set the sliders to the new vals - getChild(rName)->setValue(color_ctrl->mR); - getChild(gName)->setValue(color_ctrl->mG); - getChild(bName)->setValue(color_ctrl->mB); - } - - // now update the current parameters and send them to shaders - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); -} - // vector control callbacks -void LLFloaterEditWater::onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlXMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl) { LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - vector_ctrl->mX = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setX( sldr_ctrl->getValueF32() ); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlYMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl) { LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - vector_ctrl->mY = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setY(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlZMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl) { - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - vector_ctrl->mZ = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setZ(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl) +void LLFloaterEditWater::onVector2ControlXMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl) { - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - vector_ctrl->mX = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setU(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl) +void LLFloaterEditWater::onVector2ControlYMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl) { - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - vector_ctrl->mY = sldr_ctrl->getValueF32(); + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setV(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } -void LLFloaterEditWater::onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl) +void LLFloaterEditWater::onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl) { - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - floatControl->mX = sldr_ctrl->getValueF32() / floatControl->mMult; + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - floatControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); + floatControl->setValue(sldr_ctrl->getValueF32()); + floatControl->update(mEditSettings); } -void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl) +void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WLXFloatControl* expFloatControl) { LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - F32 val = sldr_ctrl->getValueF32(); - expFloatControl->mExp = val; - LLWaterParamManager::getInstance()->setDensitySliderValue(val); - - expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); + expFloatControl->setExp(sldr_ctrl->getValueF32()); + expFloatControl->update(mEditSettings); } -void LLFloaterEditWater::onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) +void LLFloaterEditWater::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { LLColorSwatchCtrl* swatch = static_cast(ctrl); *color_ctrl = swatch->get(); - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditWater::onNormalMapPicked(LLUICtrl* ctrl) { LLTextureCtrl* textCtrl = static_cast(ctrl); LLUUID textID = textCtrl->getImageAssetID(); - LLWaterParamManager::getInstance()->setNormalMapID(textID); + mEditSettings->setNormalMapID(textID); } //============================================================================= @@ -494,6 +322,7 @@ bool LLFloaterEditWater::isNewPreset() const void LLFloaterEditWater::refreshWaterPresetsList() { +#if 0 mWaterPresetCombo->removeall(); #if 0 // *TODO: enable when we have a clear workflow to edit existing region environment @@ -530,6 +359,7 @@ void LLFloaterEditWater::refreshWaterPresetsList() } mWaterPresetCombo->setLabel(getString("combo_label")); +#endif } void LLFloaterEditWater::enableEditing(bool enable) @@ -544,6 +374,7 @@ void LLFloaterEditWater::enableEditing(bool enable) void LLFloaterEditWater::saveRegionWater() { +#if 0 llassert(getCurrentScope() == LLEnvKey::SCOPE_REGION); // make sure we're editing region water LL_DEBUGS("Windlight") << "Saving region water preset" << LL_ENDL; @@ -552,8 +383,10 @@ void LLFloaterEditWater::saveRegionWater() // *TODO: save to cached region settings. LL_WARNS("Windlight") << "Saving region water is not fully implemented yet" << LL_ENDL; +#endif } +#if 0 std::string LLFloaterEditWater::getCurrentPresetName() const { std::string name; @@ -561,7 +394,9 @@ std::string LLFloaterEditWater::getCurrentPresetName() const getSelectedPreset(name, scope); return name; } +#endif +#if 0 LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const { std::string name; @@ -569,9 +404,12 @@ LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const getSelectedPreset(name, scope); return scope; } +#endif +#if 0 void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const { + if (mWaterPresetNameEditor->getVisible()) { name = mWaterPresetNameEditor->getText(); @@ -592,16 +430,21 @@ void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope = (LLEnvKey::EScope) combo_val[1].asInteger(); } } + } +#endif void LLFloaterEditWater::onWaterPresetNameEdited() { +#if 0 // Disable saving a water preset having empty name. mSaveButton->setEnabled(!getCurrentPresetName().empty()); +#endif } void LLFloaterEditWater::onWaterPresetSelected() { +#if 0 LLWaterParamSet water_params; std::string name; LLEnvKey::EScope scope; @@ -629,23 +472,26 @@ void LLFloaterEditWater::onWaterPresetSelected() enableEditing(can_edit); mMakeDefaultCheckBox->setEnabled(scope == LLEnvKey::SCOPE_LOCAL); +#endif } bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); +#if 0 + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); // If they choose save, do it. Otherwise, don't do anything if (option == 0) { onSaveConfirmed(); } - +#endif return false; } void LLFloaterEditWater::onSaveConfirmed() { +#if 0 // Save currently displayed water params to the selected preset. std::string name = getCurrentPresetName(); @@ -670,10 +516,12 @@ void LLFloaterEditWater::onSaveConfirmed() } closeFloater(); +#endif } void LLFloaterEditWater::onBtnSave() { +#if 0 LLEnvKey::EScope scope; std::string name; getSelectedPreset(name, scope); @@ -710,6 +558,7 @@ void LLFloaterEditWater::onBtnSave() // new preset, hence no confirmation needed onSaveConfirmed(); } +#endif } void LLFloaterEditWater::onBtnCancel() @@ -719,6 +568,7 @@ void LLFloaterEditWater::onBtnCancel() void LLFloaterEditWater::onWaterPresetListChange() { +#if 0 std::string name; LLEnvKey::EScope scope; getSelectedPreset(name, scope); // preset being edited @@ -734,10 +584,12 @@ void LLFloaterEditWater::onWaterPresetListChange() // Refresh the presets list, though it may not make sense as the floater is about to be closed. refreshWaterPresetsList(); } +#endif } void LLFloaterEditWater::onRegionSettingsChange() { +#if 0 // If creating a new preset, don't bother. if (isNewPreset()) { @@ -755,10 +607,12 @@ void LLFloaterEditWater::onRegionSettingsChange() { refreshWaterPresetsList(); } +#endif } void LLFloaterEditWater::onRegionInfoUpdate() { +#if 0 bool can_edit = true; // If we've selected the region water for editing. @@ -769,4 +623,5 @@ void LLFloaterEditWater::onRegionInfoUpdate() } enableEditing(can_edit); +#endif } diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h index 2211bca59f..7d9e493ac2 100644 --- a/indra/newview/llfloatereditwater.h +++ b/indra/newview/llfloatereditwater.h @@ -28,18 +28,22 @@ #define LL_LLFLOATEREDITWATER_H #include "llfloater.h" -#include "llenvmanager.h" // for LLEnvKey +#include "llsettingswater.h" class LLButton; class LLCheckBoxCtrl; class LLComboBox; class LLLineEditor; -struct WaterVector2Control; -struct WaterVector3Control; -struct WaterColorControl; -struct WaterFloatControl; -struct WaterExpFloatControl; +class WLVect2Control; +class WLVect3Control; +class WLColorControl; +class WLFloatControl; +class WLXFloatControl; + +class LLWatterSettingsAdapter; + +typedef boost::shared_ptr LLWaterSettingsAdapterPtr; class LLFloaterEditWater : public LLFloater { @@ -60,29 +64,22 @@ private: void syncControls(); /// sync up sliders with parameters - // general purpose callbacks for dealing with color controllers - void onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); + void onVector3ControlXMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl); + void onVector3ControlYMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl); + void onVector3ControlZMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl); - void onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); - void onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); - void onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); + void onVector2ControlXMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl); + void onVector2ControlYMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl); - void onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl); - void onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl); + void onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl); - void onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl); + void onExpFloatControlMoved(LLUICtrl* ctrl, WLXFloatControl* expFloatControl); - void onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl); - - void onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); + void onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl); void onNormalMapPicked(LLUICtrl* ctrl); /// handle if they choose a new normal map - //-- WL stuff ends -------------------------------------------------------- + //-- WL stuff ends -------------------------------------------------------- void reset(); bool isNewPreset() const; @@ -90,9 +87,9 @@ private: void enableEditing(bool enable); void saveRegionWater(); - std::string getCurrentPresetName() const; - LLEnvKey::EScope getCurrentScope() const; - void getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const; +// std::string getCurrentPresetName() const; +// LLEnvKey::EScope getCurrentScope() const; +// void getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const; void onWaterPresetNameEdited(); void onWaterPresetSelected(); @@ -110,6 +107,9 @@ private: LLComboBox* mWaterPresetCombo; LLCheckBoxCtrl* mMakeDefaultCheckBox; LLButton* mSaveButton; + + LLWaterSettingsAdapterPtr mWaterAdapter; + LLSettingsWater::ptr_t mEditSettings; }; #endif // LL_LLFLOATEREDITWATER_H diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 3a059e92dc..39907b19a3 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -32,10 +32,6 @@ #include "llradiogroup.h" #include "lldaycyclemanager.h" -#include "llenvmanager.h" -#include "llwaterparammanager.h" -#include "llwlparamset.h" -#include "llwlparammanager.h" #include "llenvironment.h" @@ -74,10 +70,10 @@ BOOL LLFloaterEnvironmentSettings::postBuild() setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); - LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); +// LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); +// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); +// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); +// LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); return TRUE; } @@ -199,7 +195,9 @@ void LLFloaterEnvironmentSettings::apply() env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); } - env_mgr.useWaterPreset(water_preset); + /* LAPRAS */ + //env_mgr.useWaterPreset(water_preset); + LLEnvironment::instance().selectWater(water_preset); } } @@ -214,7 +212,7 @@ void LLFloaterEnvironmentSettings::populateWaterPresetsList() mWaterPresetCombo->removeall(); std::list user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + //LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); // Add user presets first. for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 59e14e6cc0..5b35d5c3a5 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -48,7 +48,7 @@ static LLDefaultChildRegistry::Register r1("joystick_slide static LLDefaultChildRegistry::Register r2("joystick_turn"); static LLDefaultChildRegistry::Register r3("joystick_rotate"); static LLDefaultChildRegistry::Register r5("joystick_track"); - +static LLDefaultChildRegistry::Register r6("joystick_quat"); const F32 NUDGE_TIME = 0.25f; // in seconds @@ -646,3 +646,185 @@ void LLJoystickCameraTrack::onHeldDown() gAgentCamera.setPanDownKey(getOrbitRate()); } } + +//------------------------------------------------------------------------------- +// LLJoystickQuaternion +//------------------------------------------------------------------------------- + +LLJoystickQuaternion::Params::Params() +{ +} + +LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p): + LLJoystick(p), + mInLeft(false), + mInTop(false), + mInRight(false), + mInBottom(false) +{ +} + +void LLJoystickQuaternion::setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom) +{ + mInLeft = left; + mInTop = top; + mInRight = right; + mInBottom = bottom; +} + +BOOL LLJoystickQuaternion::handleMouseDown(S32 x, S32 y, MASK mask) +{ + updateSlop(); + + // Set initial offset based on initial click location + S32 horiz_center = getRect().getWidth() / 2; + S32 vert_center = getRect().getHeight() / 2; + + S32 dx = x - horiz_center; + S32 dy = y - vert_center; + + if (dy > dx && dy > -dx) + { + // top + mInitialOffset.mX = 0; + mInitialOffset.mY = (mVertSlopNear + mVertSlopFar) / 2; + mInitialQuadrant = JQ_UP; + } + else if (dy > dx && dy <= -dx) + { + // left + mInitialOffset.mX = -(mHorizSlopNear + mHorizSlopFar) / 2; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_LEFT; + } + else if (dy <= dx && dy <= -dx) + { + // bottom + mInitialOffset.mX = 0; + mInitialOffset.mY = -(mVertSlopNear + mVertSlopFar) / 2; + mInitialQuadrant = JQ_DOWN; + } + else + { + // right + mInitialOffset.mX = (mHorizSlopNear + mHorizSlopFar) / 2; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_RIGHT; + } + + return LLJoystick::handleMouseDown(x, y, mask); +} + +BOOL LLJoystickQuaternion::handleMouseUp(S32 x, S32 y, MASK mask) +{ + return LLJoystick::handleMouseUp(x, y, mask); +} + +void LLJoystickQuaternion::onHeldDown() +{ + updateSlop(); + + S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX; + S32 dy = mLastMouse.mY - mFirstMouse.mY + mInitialOffset.mY; + + // left-right rotation + if (dx > mHorizSlopNear) + { + } + else if (dx < -mHorizSlopNear) + { + } + + // over/under rotation + if (dy > mVertSlopNear) + { + } + else if (dy < -mVertSlopNear) + { + } +} + +void LLJoystickQuaternion::draw() +{ + LLGLSUIDefault gls_ui; + + getImageUnselected()->draw(0, 0); + LLPointer image = getImageSelected(); + + if (mInTop) + { + drawRotatedImage(getImageSelected(), 0); + } + + if (mInRight) + { + drawRotatedImage(getImageSelected(), 1); + } + + if (mInBottom) + { + drawRotatedImage(getImageSelected(), 2); + } + + if (mInLeft) + { + drawRotatedImage(getImageSelected(), 3); + } +} + +F32 LLJoystickQuaternion::getOrbitRate() +{ + return 1; +} + +void LLJoystickQuaternion::updateSlop() +{ + // small fixed slop region + mVertSlopNear = 16; + mVertSlopFar = 32; + + mHorizSlopNear = 16; + mHorizSlopFar = 32; +} + +void LLJoystickQuaternion::drawRotatedImage(LLPointer image, S32 rotations) +{ + S32 width = image->getWidth(); + S32 height = image->getHeight(); + LLTexture* texture = image->getImage(); + + /* + * Scale texture coordinate system + * to handle the different between image size and size of texture. + */ + F32 uv[][2] = + { + { (F32)width / texture->getWidth(), (F32)height / texture->getHeight() }, + { 0.f, (F32)height / texture->getHeight() }, + { 0.f, 0.f }, + { (F32)width / texture->getWidth(), 0.f } + }; + + gGL.getTexUnit(0)->bind(texture); + + gGL.color4fv(UI_VERTEX_COLOR.mV); + + gGL.begin(LLRender::QUADS); + { + gGL.texCoord2fv(uv[(rotations + 0) % 4]); + gGL.vertex2i(width, height); + + gGL.texCoord2fv(uv[(rotations + 1) % 4]); + gGL.vertex2i(0, height); + + gGL.texCoord2fv(uv[(rotations + 2) % 4]); + gGL.vertex2i(0, 0); + + gGL.texCoord2fv(uv[(rotations + 3) % 4]); + gGL.vertex2i(width, 0); + } + gGL.end(); +} + + + diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index 4e6c774cad..ae8de1bf32 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -178,4 +178,35 @@ public: virtual void onHeldDown(); }; +// +class LLJoystickQuaternion : + public LLJoystick +{ +public: + struct Params : + public LLInitParam::Block + { + Params(); + }; + + LLJoystickQuaternion(const LLJoystickQuaternion::Params &); + + virtual void setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom); + + virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + virtual void onHeldDown(); + virtual void draw(); + +protected: + F32 getOrbitRate(); + virtual void updateSlop(); + void drawRotatedImage(LLPointer image, S32 rotations); + + BOOL mInLeft; + BOOL mInTop; + BOOL mInRight; + BOOL mInBottom; +}; + #endif // LL_LLJOYSTICKBUTTON_H diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 898cdad7be..c91d4e59ce 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -47,8 +47,8 @@ namespace const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); - LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params"); - LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); + 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); @@ -266,8 +266,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam } LLSettingsSky::ptr_t skyp = boost::make_shared(newsettings); - skyp->update(); - + return skyp; } @@ -293,11 +292,11 @@ LLSettingsSky::ptr_t LLSettingsSky::buildClone() LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const { - LL_RECORD_BLOCK_TIME(FTM_BLEND_ENVIRONMENT); + LL_RECORD_BLOCK_TIME(FTM_BLEND_SKYVALUES); LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL; LLSettingsSky::ptr_t skyp = boost::make_shared(mSettings); - // the settings in the initial constructor are references tho this' settings block. + // the settings in the initial constructor are references to this' settings block. // They will be replaced in the following lerp skyp->lerpSettings(*other, mix); @@ -329,7 +328,7 @@ LLSD LLSettingsSky::defaults() 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(); // *RIDER: This is really weird for a color... TODO: check if right. + 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] = LLVector4(0.0000, 0.9126, -0.4086, 0.0000).getValue(); @@ -350,7 +349,7 @@ LLSD LLSettingsSky::defaults() void LLSettingsSky::updateSettings() { - LL_RECORD_BLOCK_TIME(FTM_UPDATE_ENVIRONMENT); + 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 diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 012244d1f9..8052651030 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -62,10 +62,6 @@ public: static const std::string SETTING_SUN_ROTATION; static const std::string SETTING_SUN_TEXUTUREID; - 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; - typedef boost::shared_ptr ptr_t; typedef std::pair azimalt_t; @@ -428,6 +424,10 @@ protected: 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(); diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp new file mode 100644 index 0000000000..7efa89e6f1 --- /dev/null +++ b/indra/newview/llsettingswater.cpp @@ -0,0 +1,268 @@ +/** +* @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"); + + LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); + void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); +} + +//========================================================================= +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_NAME("name"); +const std::string LLSettingsWater::SETTING_NORMAL_MAP("normal_map"); +const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale"); +const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above"); +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 F32 LLSettingsWater::WATER_FOG_LIGHT_CLAMP(0.3f); + +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); + + return waterp; +} + +LLSettingsWater::ptr_t LLSettingsWater::buildDefaultWater() +{ + LLSD settings = LLSettingsWater::defaults(); + + LLSettingsWater::ptr_t skyp = boost::make_shared(settings); + + return skyp; +} + +LLSettingsWater::ptr_t LLSettingsWater::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsWater::ptr_t skyp = boost::make_shared(settings); + + return skyp; +} + +//========================================================================= + +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; +} + +void LLSettingsWater::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 LLSettingsWater::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 new file mode 100644 index 0000000000..d8c9ff5cc6 --- /dev/null +++ b/indra/newview/llsettingswater.h @@ -0,0 +1,234 @@ +/** +* @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_NAME; + 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 + ptr_t blend(const ptr_t &other, F32 mix) const; + + 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 void updateSettings(); + + virtual parammapping_t getParameterMap() const; + + virtual void applySpecial(void *); + + +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; + + static const F32 WATER_FOG_LIGHT_CLAMP; + + LLVector4 mWaterPlane; + F32 mWaterFogKS; +}; + +#endif diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 485b88e4c7..e50a4a0b5d 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -180,7 +180,6 @@ #include "llnamebox.h" #include "llnameeditor.h" #include "llpostprocess.h" -#include "llwlparammanager.h" #include "llwaterparammanager.h" #include "llagentlanguage.h" #include "llwearable.h" @@ -197,6 +196,9 @@ #include "llexperiencelog.h" #include "llcleanup.h" +#include "llenvironment.h" +#include "llenvmanager.h" + #include "llstacktrace.h" #if LL_WINDOWS @@ -1461,7 +1463,7 @@ bool idle_startup() LLGLState::checkStates(); LLGLState::checkTextureChannels(); - LLEnvManagerNew::getInstance()->usePrefs(); // Load all presets and settings + LLEnvironment::instance().loadPreferences(); gSky.init(initial_sun_direction); LLGLState::checkStates(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index dcf42a201b..f25471d4f0 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -74,7 +74,6 @@ #include "llviewerregion.h" #include "lldrawpoolwater.h" #include "lldrawpoolbump.h" -#include "llwlparammanager.h" #include "llwaterparammanager.h" #include "llpostprocess.h" #include "llscenemonitor.h" @@ -203,7 +202,6 @@ void display_update_camera() // update all the sky/atmospheric/water settings LLEnvironment::instance().update(LLViewerCamera::getInstance()); - LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance()); // Update land visibility too LLWorld::getInstance()->setLandFarClip(final_far); @@ -920,7 +918,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.mScreen.bindTarget(); if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders()) { - const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; + const LLColor4 &col = LLEnvironment::instance().getCurrentWater()->getFogColor(); glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); } gPipeline.mScreen.clear(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 683ff7558a..f0924486df 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -3430,7 +3430,6 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { LLEnvironment::instance().updateShaderUniforms(shader); - LLWaterParamManager::getInstance()->updateShaderUniforms(shader); } LLViewerShaderMgr::shader_iter LLViewerShaderMgr::beginShaders() const diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 93ca7945ba..20afc7a41d 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -48,7 +48,6 @@ #include "llworld.h" #include "pipeline.h" #include "lldrawpoolwlsky.h" -#include "llwlparammanager.h" #include "llwaterparammanager.h" #include "v3colorutil.h" @@ -1952,11 +1951,12 @@ void LLVOSky::updateFog(const F32 distance) } else { + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); F32 depth = water_height - camera_height; // get the water param manager variables - float water_fog_density = LLWaterParamManager::getInstance()->getFogDensity(); - LLColor4 water_fog_color(LLDrawPoolWater::sWaterFogColor.mV); + float water_fog_density = pwater->getFogDensity(); + LLColor4 water_fog_color(pwater->getFogColor()); // adjust the color based on depth. We're doing linear approximations float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 6d1bb43258..eb21f3c4b4 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -58,17 +58,17 @@ #include "curl/curl.h" LLWaterParamManager::LLWaterParamManager() : - mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), - mFogDensity(4, "waterFogDensity", 2), - mUnderWaterFogMod(0.25, "underWaterFogMod"), - mNormalScale(2.f, 2.f, 2.f, "normScale"), - mFresnelScale(0.5f, "fresnelScale"), - mFresnelOffset(0.4f, "fresnelOffset"), - mScaleAbove(0.025f, "scaleAbove"), - mScaleBelow(0.2f, "scaleBelow"), - mBlurMultiplier(0.1f, "blurMultiplier"), - mWave1Dir(.5f, .5f, "wave1Dir"), - mWave2Dir(.5f, .5f, "wave2Dir"), +// mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), +// mFogDensity(4, "waterFogDensity", 2), +// mUnderWaterFogMod(0.25, "underWaterFogMod"), +// mNormalScale(2.f, 2.f, 2.f, "normScale"), +// mFresnelScale(0.5f, "fresnelScale"), +// mFresnelOffset(0.4f, "fresnelOffset"), +// mScaleAbove(0.025f, "scaleAbove"), +// mScaleBelow(0.2f, "scaleBelow"), +// mBlurMultiplier(0.1f, "blurMultiplier"), +// mWave1Dir(.5f, .5f, "wave1Dir"), +// mWave2Dir(.5f, .5f, "wave2Dir"), mDensitySliderValue(1.0f), mWaterFogKS(1.0f) { @@ -135,6 +135,10 @@ bool LLWaterParamManager::loadPreset(const std::string& path) addParamSet(name, params_data); } + //*LAPRAS temp code testing conversion old preset to new settings. + LLSettingsWater::ptr_t test = LLSettingsWater::buildFromLegacyPreset(name, params_data); + LLEnvironment::instance().addWater(test); + return true; } @@ -175,16 +179,19 @@ void LLWaterParamManager::propagateParameters(void) } } - bool err; - F32 fog_density_slider = +#if 0 + bool err; + F32 fog_density_slider = log(mCurParams.getFloat(mFogDensity.mName, err)) / log(mFogDensity.mBase); setDensitySliderValue(fog_density_slider); +#endif } void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { +#if 0 if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); @@ -195,6 +202,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) shader->uniform1f(LLShaderMgr::WATER_FOGKS, mWaterFogKS); shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); } +#endif } void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate) diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index 3f169e439a..392e287e3f 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -34,7 +34,7 @@ #include "v4color.h" const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; - +#if 0 // color control struct WaterColorControl { @@ -209,7 +209,7 @@ struct WaterExpFloatControl params.set(mName, pow(mBase, mExp)); } }; - +#endif /// WindLight parameter manager class - what controls all the wind light shaders class LLWaterParamManager : public LLSingleton @@ -298,7 +298,7 @@ public: public: LLWaterParamSet mCurParams; - +#if 0 /// Atmospherics WaterColorControl mFogColor; WaterExpFloatControl mFogDensity; @@ -315,8 +315,8 @@ public: WaterFloatControl mScaleAbove; WaterFloatControl mScaleBelow; WaterFloatControl mBlurMultiplier; - - F32 mDensitySliderValue; +#endif + F32 mDensitySliderValue; private: /*virtual*/ void initSingleton(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index fb2e27d492..e8338f3e8c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -115,6 +115,8 @@ #include "llprogressview.h" #include "llcleanup.h" +#include "llenvironment.h" + #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 //#define DEBUG_INDICES @@ -9949,7 +9951,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLColor4& col = LLDrawPoolWater::sWaterFogColor; + LLColor3 col = LLEnvironment::instance().getCurrentWater()->getFogColor(); glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); mWaterDis.bindTarget(); LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; -- cgit v1.2.3 From b4d1b1c43b4cf046a4a9df1911b5edc2d92d0a7b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 16 Oct 2017 11:13:45 -0700 Subject: Removed conversions from WLColor Control in favor of setter/getter --- indra/newview/llenvadapters.h | 12 ++++++++---- indra/newview/llfloatereditsky.cpp | 22 +++++++++++----------- indra/newview/llfloatereditwater.cpp | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/indra/newview/llenvadapters.h b/indra/newview/llenvadapters.h index 3241e43191..8b93bbbe9f 100644 --- a/indra/newview/llenvadapters.h +++ b/indra/newview/llenvadapters.h @@ -51,18 +51,22 @@ public: mIsBlueHorizonOrDensity = (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity"); } - inline WLColorControl & operator = (const LLColor4 & val) + inline void setColor4(const LLColor4 & val) + { + mColor = val; + } + + inline void setColor3(const LLColor3 & val) { mColor = val; - return *this; } - inline operator LLColor4 (void) const + inline LLColor4 getColor4() const { return mColor; } - inline operator LLColor3 (void) const + inline LLColor3 getColor3(void) const { return vec4to3(mColor); } diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 40f86e3778..a6f3f1ebe7 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -215,7 +215,7 @@ void LLFloaterEditSky::syncControls() // blue horizon - mSkyAdapter->mBlueHorizon = psky->getBlueHorizon(); + mSkyAdapter->mBlueHorizon.setColor3( psky->getBlueHorizon() ); setColorSwatch("WLBlueHorizon", mSkyAdapter->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); // haze density, horizon, mult, and altitude @@ -229,22 +229,22 @@ void LLFloaterEditSky::syncControls() childSetValue("WLMaxAltitude", (F32) mSkyAdapter->mMaxAlt); // blue density - mSkyAdapter->mBlueDensity = psky->getBlueDensity(); + mSkyAdapter->mBlueDensity.setColor3( psky->getBlueDensity() ); setColorSwatch("WLBlueDensity", mSkyAdapter->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); // Lighting // sunlight - mSkyAdapter->mSunlight = psky->getSunlightColor(); + mSkyAdapter->mSunlight.setColor3( psky->getSunlightColor() ); setColorSwatch("WLSunlight", mSkyAdapter->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); // glow - mSkyAdapter->mGlow = psky->getGlow(); + mSkyAdapter->mGlow.setColor3( psky->getGlow() ); childSetValue("WLGlowR", 2 - mSkyAdapter->mGlow.getRed() / 20.0f); childSetValue("WLGlowB", -mSkyAdapter->mGlow.getBlue() / 5.0f); // ambient - mSkyAdapter->mAmbient = psky->getAmbientColor(); + mSkyAdapter->mAmbient.setColor3( psky->getAmbientColor() ); setColorSwatch("WLAmbient", mSkyAdapter->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); @@ -257,17 +257,17 @@ void LLFloaterEditSky::syncControls() // Clouds // Cloud Color - mSkyAdapter->mCloudColor = psky->getCloudColor(); + mSkyAdapter->mCloudColor.setColor3( psky->getCloudColor() ); setColorSwatch("WLCloudColor", mSkyAdapter->mCloudColor, WL_CLOUD_SLIDER_SCALE); // Cloud - mSkyAdapter->mCloudMain = psky->getCloudPosDensity1(); + mSkyAdapter->mCloudMain.setColor3( psky->getCloudPosDensity1() ); childSetValue("WLCloudX", mSkyAdapter->mCloudMain.getRed()); childSetValue("WLCloudY", mSkyAdapter->mCloudMain.getGreen()); childSetValue("WLCloudDensity", mSkyAdapter->mCloudMain.getBlue()); // Cloud Detail - mSkyAdapter->mCloudDetail = psky->getCloudPosDensity2(); + mSkyAdapter->mCloudDetail.setColor3( psky->getCloudPosDensity2() ); childSetValue("WLCloudDetailX", mSkyAdapter->mCloudDetail.getRed()); childSetValue("WLCloudDetailY", mSkyAdapter->mCloudDetail.getGreen()); childSetValue("WLCloudDetailDensity", mSkyAdapter->mCloudDetail.getBlue()); @@ -307,7 +307,7 @@ void LLFloaterEditSky::syncControls() void LLFloaterEditSky::setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k) { // Set the value, dividing it by first. - LLColor4 color = from_ctrl; + LLColor4 color = from_ctrl.getColor4(); getChild(name)->set(color / k); } @@ -336,7 +336,7 @@ void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color color_vec.mV[3] = color_max(color_vec); // Apply the new RGBI value. - *color_ctrl = color_vec; + color_ctrl->setColor4(color_vec); color_ctrl->update(mEditSettings); } @@ -410,7 +410,7 @@ void LLFloaterEditSky::adjustIntensity(WLColorControl *ctrl, F32 val, F32 scale) { if (ctrl->getHasSliderName()) { - LLColor4 color = static_cast(*ctrl); + LLColor4 color = ctrl->getColor4(); F32 i = color_max(color) / scale; ctrl->setIntensity(i); std::string name = ctrl->getSliderName(); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 41180b5da8..b025680da1 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -286,7 +286,7 @@ void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WLXFloatControl* void LLFloaterEditWater::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { LLColorSwatchCtrl* swatch = static_cast(ctrl); - *color_ctrl = swatch->get(); + color_ctrl->setColor4( swatch->get() ); color_ctrl->update(mEditSettings); } -- cgit v1.2.3 From 00ce291f013ce434b202da675bfb38431014a077 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 17 Oct 2017 12:03:26 -0700 Subject: New prototype control for moving sun and moon in sky. --- indra/newview/llfloatereditsky.cpp | 43 +++++++++++----- indra/newview/llfloatereditsky.h | 3 ++ indra/newview/lljoystickbutton.cpp | 57 +++++++++++++++++++++- indra/newview/lljoystickbutton.h | 13 +++++ .../default/xui/en/floater_edit_sky_preset.xml | 31 +++++++++++- .../skins/default/xui/en/widgets/joystick_quat.xml | 7 +++ .../default/xui/en/widgets/joystick_rotate.xml | 4 +- 7 files changed, 141 insertions(+), 17 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/widgets/joystick_quat.xml diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index a6f3f1ebe7..bd83bdd9c5 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -40,6 +40,7 @@ #include "llsliderctrl.h" #include "lltabcontainer.h" #include "lltimectrl.h" +#include "lljoystickbutton.h" // newview #include "llagent.h" @@ -88,8 +89,8 @@ BOOL LLFloaterEditSky::postBuild() initCallbacks(); - // Create the sun position scrubber on the slider. - getChild("WLSunPos")->addSlider(12.f); +// // Create the sun position scrubber on the slider. +// getChild("WLSunPos")->addSlider(12.f); return TRUE; } @@ -175,9 +176,11 @@ void LLFloaterEditSky::initCallbacks(void) getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient)); // time of day - getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider - getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl - getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); +// getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider +// getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl +// getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); + getChild("WLSunRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunRotationChanged, this)); + getChild("WLMoonRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onMoonRotationChanged, this)); // Clouds @@ -247,12 +250,14 @@ void LLFloaterEditSky::syncControls() mSkyAdapter->mAmbient.setColor3( psky->getAmbientColor() ); setColorSwatch("WLAmbient", mSkyAdapter->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); - LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); - - F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI); - getChild("WLSunPos")->setCurSliderValue(time24, TRUE); - getChild("WLDayTime")->setTime24(time24); - childSetValue("WLEastAngle", azal.first / F_TWO_PI); +// LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); +// +// F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI); +// getChild("WLSunPos")->setCurSliderValue(time24, TRUE); +// getChild("WLDayTime")->setTime24(time24); +// childSetValue("WLEastAngle", azal.first / F_TWO_PI); + getChild("WLSunRotation")->setRotation(psky->getSunRotation()); + getChild("WLMoonRotation")->setRotation(psky->getMoonRotation()); // Clouds @@ -488,6 +493,22 @@ void LLFloaterEditSky::onTimeChanged() onSunMoved(getChild("WLSunPos"), &(mSkyAdapter->mLightnorm)); } +void LLFloaterEditSky::onSunRotationChanged() +{ + LLJoystickQuaternion* sun_spinner = getChild("WLSunRotation"); + LLQuaternion sunrot(sun_spinner->getRotation()); + + mEditSettings->setSunRotation(sunrot); +} + +void LLFloaterEditSky::onMoonRotationChanged() +{ + LLJoystickQuaternion* moon_spinner = getChild("WLMoonRotation"); + LLQuaternion moonrot(moon_spinner->getRotation()); + + mEditSettings->setMoonRotation(moonrot); +} + void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) { LLSliderCtrl* sldr_ctrl = static_cast(ctrl); diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h index 6aec87014d..51be50a481 100644 --- a/indra/newview/llfloatereditsky.h +++ b/indra/newview/llfloatereditsky.h @@ -81,6 +81,9 @@ private: void onSunMoved(LLUICtrl* ctrl, void* userdata); void onTimeChanged(); + void onSunRotationChanged(); + void onMoonRotationChanged(); + // for handling when the star slider is moved to adjust the alpha void onStarAlphaMoved(LLUICtrl* ctrl); diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 5b35d5c3a5..7fcd6f4361 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -660,8 +660,20 @@ LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p mInLeft(false), mInTop(false), mInRight(false), - mInBottom(false) -{ + mInBottom(false), + mVectorZero(0.0f, 0.0f, 1.0f), + mRotation(), + mUpDnAxis(1.0f, 0.0f, 0.0f), + mLfRtAxis(0.0f, 0.0f, 1.0f), + mXAxisIndex(2), // left & right across the control + mYAxisIndex(0), // up & down across the control + mZAxisIndex(1) // tested for above and below +{ + for (int i = 0; i < 3; ++i) + { + mLfRtAxis.mV[i] = (mXAxisIndex == i) ? 1.0 : 0.0; + mUpDnAxis.mV[i] = (mYAxisIndex == i) ? 1.0 : 0.0; + } } void LLJoystickQuaternion::setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom) @@ -722,6 +734,7 @@ BOOL LLJoystickQuaternion::handleMouseUp(S32 x, S32 y, MASK mask) void LLJoystickQuaternion::onHeldDown() { + LLVector3 axis; updateSlop(); S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX; @@ -730,18 +743,34 @@ void LLJoystickQuaternion::onHeldDown() // left-right rotation if (dx > mHorizSlopNear) { + axis += mUpDnAxis; } else if (dx < -mHorizSlopNear) { + axis -= mUpDnAxis; } // over/under rotation if (dy > mVertSlopNear) { + axis += mLfRtAxis; } else if (dy < -mVertSlopNear) { + axis -= mLfRtAxis; } + + if (axis.isNull()) + return; + + axis.normalize(); + + LLQuaternion delta; + delta.setAngleAxis(0.0523599f, axis); // about 3deg + + mRotation *= delta; + setValue(mRotation.getValue()); + onCommit(); } void LLJoystickQuaternion::draw() @@ -770,6 +799,16 @@ void LLJoystickQuaternion::draw() { drawRotatedImage(getImageSelected(), 3); } + + LLVector3 draw_point = mVectorZero * mRotation; + S32 halfwidth = getRect().getWidth() / 2; + S32 halfheight = getRect().getHeight() / 2; + draw_point.mV[mXAxisIndex] = (draw_point.mV[mXAxisIndex] + 1.0) * halfwidth; + draw_point.mV[mYAxisIndex] = (draw_point.mV[mYAxisIndex] + 1.0) * halfheight; + + gl_circle_2d(draw_point.mV[mXAxisIndex], draw_point.mV[mYAxisIndex], 4, 8, + draw_point.mV[mZAxisIndex] >= 0.f); + } F32 LLJoystickQuaternion::getOrbitRate() @@ -826,5 +865,19 @@ void LLJoystickQuaternion::drawRotatedImage(LLPointer image, S32 rota gGL.end(); } +void LLJoystickQuaternion::setRotation(const LLQuaternion &value) +{ + if (value != mRotation) + { + mRotation = value; + mRotation.normalize(); + LLJoystick::setValue(mRotation.getValue()); + } +} + +LLQuaternion LLJoystickQuaternion::getRotation() const +{ + return mRotation; +} diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index ae8de1bf32..ee66088b56 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -30,6 +30,7 @@ #include "llbutton.h" #include "llcoord.h" #include "llviewertexture.h" +#include "llquaternion.h" typedef enum e_joystick_quadrant { @@ -198,6 +199,9 @@ public: virtual void onHeldDown(); virtual void draw(); + void setRotation(const LLQuaternion &value); + LLQuaternion getRotation() const; + protected: F32 getOrbitRate(); virtual void updateSlop(); @@ -207,6 +211,15 @@ protected: BOOL mInTop; BOOL mInRight; BOOL mInBottom; + + S32 mXAxisIndex; + S32 mYAxisIndex; + S32 mZAxisIndex; + + LLVector3 mVectorZero; + LLQuaternion mRotation; + LLVector3 mUpDnAxis; + LLVector3 mLfRtAxis; }; #endif // LL_LLJOYSTICKBUTTON_H diff --git a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml index 56233d91ee..c03a206e88 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml @@ -454,7 +454,34 @@ width="200"> Sun/Moon Position - /> + + /> + + + diff --git a/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml b/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml index a190da3909..cbf721b346 100644 --- a/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml +++ b/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml @@ -1,7 +1,7 @@ - -- cgit v1.2.3 From 24ed3844afe2d54a03975c1704c595cf02e5643f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 17 Oct 2017 14:40:21 -0700 Subject: Initial day cycle checkin. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llsettingsdaycycle.cpp | 113 +++++++++++++++++++++++++++++++++++ indra/newview/llsettingsdaycycle.h | 66 ++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 indra/newview/llsettingsdaycycle.cpp create mode 100644 indra/newview/llsettingsdaycycle.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index b46e0971e2..8cb029a2be 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -536,6 +536,7 @@ set(viewer_SOURCE_FILES llsechandler_basic.cpp llselectmgr.cpp llsettingsbase.cpp + llsettingsdaycycle.cpp llsettingssky.cpp llsettingswater.cpp llshareavatarhandler.cpp @@ -1153,6 +1154,7 @@ set(viewer_HEADER_FILES llsechandler_basic.h llselectmgr.h llsettingsbase.h + llsettingsdaycycle.h llsettingssky.h llsettingswater.h llsidepanelappearance.h diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp new file mode 100644 index 0000000000..859fc5822f --- /dev/null +++ b/indra/newview/llsettingsdaycycle.cpp @@ -0,0 +1,113 @@ +/** +* @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" + +//========================================================================= +namespace +{ + LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); + LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); +} + +//========================================================================= + + +//========================================================================= +LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) : + LLSettingsBase(data) +{ +} + +LLSettingsDayCycle::LLSettingsDayCycle() : + LLSettingsBase() +{ +} + +//========================================================================= +LLSD LLSettingsDayCycle::defaults() +{ + LLSD dfltsetting; + + + return dfltsetting; +} + + +LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +{ + LLSD newsettings(defaults()); + + //newsettings[SETTING_NAME] = name; + + + + LLSettingsDayCycle::ptr_t dayp = boost::make_shared(newsettings); + + return dayp; +} + +LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildDefaultDayCycle() +{ + LLSD settings = LLSettingsDayCycle::defaults(); + + LLSettingsDayCycle::ptr_t dayp = boost::make_shared(settings); + + return dayp; +} + +LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsDayCycle::ptr_t dayp = boost::make_shared(settings); + + return dayp; +} + +//========================================================================= +void LLSettingsDayCycle::updateSettings() +{ + +} + +//========================================================================= diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h new file mode 100644 index 0000000000..c562844bca --- /dev/null +++ b/indra/newview/llsettingsdaycycle.h @@ -0,0 +1,66 @@ +/** +* @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 LLSettingsDayCycle : public LLSettingsBase +{ +public: + + typedef boost::shared_ptr ptr_t; + + //--------------------------------------------------------------------- + LLSettingsDayCycle(const LLSD &data); + virtual ~LLSettingsDayCycle() { }; + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildDefaultDayCycle(); + ptr_t buildClone(); + + //--------------------------------------------------------------------- + virtual std::string getSettingType() const { return std::string("daycycle"); } + + // Settings status + ptr_t blend(const ptr_t &other, F32 mix) const; + + static LLSD defaults(); + + //--------------------------------------------------------------------- + +protected: + LLSettingsDayCycle(); + + virtual void updateSettings(); + + +private: +}; + +#endif -- cgit v1.2.3 From ec8e163910c24e4d04d3bb154b6c983a84d84421 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 17 Oct 2017 16:00:07 -0700 Subject: Comment out unused static function for mac --- indra/newview/llfloatereditsky.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index bd83bdd9c5..5fd559c060 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -56,10 +56,10 @@ static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; static const F32 WL_BLUE_HORIZON_DENSITY_SCALE = 2.0f; static const F32 WL_CLOUD_SLIDER_SCALE = 1.0f; -static F32 sun_pos_to_time24(F32 sun_pos) -{ - return fmodf(sun_pos * 24.0f + 6, 24.0f); -} +// static F32 sun_pos_to_time24(F32 sun_pos) +// { +// return fmodf(sun_pos * 24.0f + 6, 24.0f); +// } static F32 time24_to_sun_pos(F32 time24) { -- cgit v1.2.3 From c6ae9408aaeaa7b2c022a92773a9b4b74c0eeee1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 19 Oct 2017 10:03:10 -0700 Subject: Fix mac compile unused names in namespace. --- indra/newview/llsettingswater.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index 7efa89e6f1..9b7d4dd647 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -43,14 +43,11 @@ #include "pipeline.h" //========================================================================= -namespace -{ - LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); - LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); - - LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); - void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); -} +// 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"); -- cgit v1.2.3 From de622ea576e106382d59e38cb966fe1a29f80ec0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 19 Oct 2017 11:24:16 -0700 Subject: Put the timer block back in. --- indra/newview/llsettingsdaycycle.cpp | 32 ++++++++++++++++++++++++++++++++ indra/newview/llsettingsdaycycle.h | 28 ++++++++++++++++++++++++++++ indra/newview/llsettingswater.cpp | 8 ++++---- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp index 859fc5822f..abf73877ed 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -42,6 +42,10 @@ #include "llagent.h" #include "pipeline.h" + +#include "llsettingssky.h" +#include "llsettingswater.h" + //========================================================================= namespace { @@ -50,7 +54,10 @@ namespace } //========================================================================= +const std::string LLSettingsDayCycle::SETTING_DAYLENGTH("day_length"); +const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days //========================================================================= LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) : @@ -104,6 +111,14 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() return dayp; } +//========================================================================= +F32 LLSettingsDayCycle::secondsToOffset(S32 seconds) +{ + S32 daylength = getDayLength(); + + return static_cast(seconds % daylength) / static_cast(daylength); +} + //========================================================================= void LLSettingsDayCycle::updateSettings() { @@ -111,3 +126,20 @@ void LLSettingsDayCycle::updateSettings() } //========================================================================= +void LLSettingsDayCycle::setDayLength(S32 seconds) +{ + seconds = llclamp(seconds, MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); + + setValue(SETTING_DAYLENGTH, seconds); +} + +void LLSettingsDayCycle::setWaterAt(const LLSettingsSkyPtr_t &water, S32 seconds) +{ +// F32 offset = secondsToOffset(seconds); + +} + +void setSkyAtOnTrack(const LLSettingsSkyPtr_t &water, S32 seconds, S32 track) +{ + +} diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index c562844bca..9aaa30c24f 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -30,9 +30,19 @@ #include "llsettingsbase.h" +class LLSettingsWater; +class LLSettingsSky; + +typedef boost::shared_ptr LLSettingsWaterPtr_t; +typedef boost::shared_ptr LLSettingsSkyPtr_t; + class LLSettingsDayCycle : public LLSettingsBase { public: + static const std::string SETTING_DAYLENGTH; + + static const S32 MINIMUM_DAYLENGTH; + static const S32 MAXIMUM_DAYLENGTH; typedef boost::shared_ptr ptr_t; @@ -53,14 +63,32 @@ public: static LLSD defaults(); //--------------------------------------------------------------------- + S32 getDayLength() const + { + return mSettings[SETTING_DAYLENGTH].asInteger(); + } + + void setDayLength(S32 seconds); + + void setWaterAt(const LLSettingsSkyPtr_t &water, S32 seconds); + void setSkyAtOnTrack(const LLSettingsSkyPtr_t &water, S32 seconds, S32 track); + //--------------------------------------------------------------------- protected: LLSettingsDayCycle(); virtual void updateSettings(); + typedef std::map CycleTrack_t; + typedef std::vector CycleList_t; + typedef std::pair TrackBound_t; + + CycleList_t mDayTracks; + + F32 secondsToOffset(S32 seconds); private: + }; #endif diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index 9b7d4dd647..d6b1234336 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -43,11 +43,11 @@ #include "pipeline.h" //========================================================================= -// namespace -// { +namespace +{ // LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); -// LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); -// } + LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); +} //========================================================================= const std::string LLSettingsWater::SETTING_BLUR_MULTIPILER("blur_multiplier"); -- cgit v1.2.3 From ea90ebff22e87c86c9de0cc6702d29783309ebf9 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 19 Oct 2017 14:55:46 -0700 Subject: Figure out later why this block timer suddenly starts crashing. --- indra/newview/llsettingswater.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index d6b1234336..babaa0b218 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -45,7 +45,7 @@ //========================================================================= namespace { -// LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); + LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); } @@ -228,7 +228,7 @@ void LLSettingsWater::applySpecial(void *ptarget) //========================================================================= void LLSettingsWater::updateSettings() { - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); +// 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 -- cgit v1.2.3 From 2161788711f6d89564afc933707b6a0b8c1b0562 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 20 Oct 2017 16:37:03 -0700 Subject: Day cycles start --- indra/newview/llenvironment.cpp | 38 +++++-- indra/newview/llenvironment.h | 5 + indra/newview/llsettingsbase.cpp | 12 ++ indra/newview/llsettingsbase.h | 7 +- indra/newview/llsettingsdaycycle.cpp | 210 ++++++++++++++++++++++++++++++++++- indra/newview/llsettingsdaycycle.h | 42 +++++-- indra/newview/llsettingssky.cpp | 11 ++ indra/newview/llsettingssky.h | 2 + indra/newview/llsettingswater.cpp | 11 ++ indra/newview/llsettingswater.h | 2 +- 10 files changed, 318 insertions(+), 22 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 921f3ef910..fbb713c6d8 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -293,15 +293,14 @@ void LLEnvironment::clearAllSkys() void LLEnvironment::selectSky(const std::string &name) { - NamedSettingMap_t::iterator it = mSkysByName.find(name); - - if (it == mSkysByName.end()) + LLSettingsSky::ptr_t next_sky = findSkyByName(name); + if (!next_sky) { LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; return; } - mCurrentSky = boost::static_pointer_cast((*it).second); + mCurrentSky = next_sky; mCurrentSky->setDirtyFlag(true); } @@ -322,15 +321,15 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) void LLEnvironment::selectWater(const std::string &name) { - NamedSettingMap_t::iterator it = mWaterByName.find(name); + LLSettingsWater::ptr_t next_water = findWaterByName(name); - if (it == mWaterByName.end()) + if (!next_water) { LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; return; } - mCurrentWater = boost::static_pointer_cast((*it).second); + mCurrentWater = next_water; mCurrentWater->setDirtyFlag(true); } @@ -348,6 +347,31 @@ void LLEnvironment::clearAllWater() mWaterById.clear(); } +LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const +{ + NamedSettingMap_t::const_iterator it = mSkysByName.find(name); + + if (it == mSkysByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to find sky with unknown name '" << name << "'" << LL_ENDL; + return LLSettingsSky::ptr_t(); + } + + return boost::static_pointer_cast((*it).second); +} + +LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const +{ + NamedSettingMap_t::const_iterator it = mWaterByName.find(name); + + if (it == mWaterByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to find water with unknown name '" << name << "'" << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + + return boost::static_pointer_cast((*it).second); +} //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 7506b37e3e..493fff1769 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -85,6 +85,8 @@ public: LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } + + void update(const LLViewerCamera * cam); void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); @@ -92,6 +94,9 @@ public: void addSky(const LLSettingsSky::ptr_t &sky); void selectSky(const std::string &name); + LLSettingsSky::ptr_t findSkyByName(std::string name) const; + LLSettingsWater::ptr_t findWaterByName(std::string name) const; + void addWater(const LLSettingsWater::ptr_t &sky); void selectWater(const std::string &name); diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp index 71ec240214..1f155776bf 100644 --- a/indra/newview/llsettingsbase.cpp +++ b/indra/newview/llsettingsbase.cpp @@ -240,6 +240,18 @@ LLSD LLSettingsBase::cloneSettings() const return combineSDMaps(mSettings, LLSD()); } +LLSettingsBase::ptr_t LLSettingsBase::buildBlend(const ptr_t &begin, const ptr_t &end, F32 blendf) +{ + if (begin->getSettingType() != end->getSettingType()) + { + LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " << + begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL; + + return LLSettingsBase::ptr_t(); + } + + return begin->blend(end, blendf); +} void LLSettingsBase::exportSettings(std::string name) const { diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index 02f5ffc8af..f7015fb12b 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -43,6 +43,7 @@ class LLSettingsBase: private boost::noncopyable { friend class LLEnvironment; + friend class LLSettingsDayCycle; public: typedef std::map parammapping_t; @@ -54,6 +55,8 @@ public: //--------------------------------------------------------------------- virtual std::string getSettingType() const = 0; + static ptr_t buildBlend(const ptr_t &begin, const ptr_t &end, F32 blendf); + //--------------------------------------------------------------------- // Settings status inline bool hasSetting(const std::string ¶m) const { return mSettings.has(param); } @@ -124,8 +127,11 @@ protected: typedef std::set stringset_t; + virtual ptr_t blend(const ptr_t &end, F32 blendf) const = 0; + // combining settings objects. Customize for specific setting types virtual void lerpSettings(const LLSettingsBase &other, F32 mix); + 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. @@ -152,7 +158,6 @@ private: bool mDirty; LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F32 mix) const; }; diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp index abf73877ed..bda3c7c138 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -42,32 +42,86 @@ #include "llagent.h" #include "pipeline.h" - #include "llsettingssky.h" #include "llsettingswater.h" +#include "llenvironment.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) + { + return 1.0 - fabs((begin + 1.0) - end); + } + + LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDayCycle::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDayCycle::CycleTrack_t::iterator it = collection.upper_bound(key); + + if (it == collection.end()) + { // wrap around + it = collection.begin(); + } + + return it; + } + + LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDayCycle::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDayCycle::CycleTrack_t::iterator it = collection.lower_bound(key); + + if (it == collection.end()) + { // all offsets are lower, take the last one. + --it; // we know the range is not empty + } + else if ((*it).first > key) + { // the offset we are interested in is smaller than the found. + if (it == collection.begin()) + it = collection.end(); + --it; + } + + return it; + } + + } //========================================================================= const std::string LLSettingsDayCycle::SETTING_DAYLENGTH("day_length"); +const std::string LLSettingsDayCycle::SETTING_KEYID("key_id"); +const std::string LLSettingsDayCycle::SETTING_KEYNAME("key_name"); +const std::string LLSettingsDayCycle::SETTING_KEYOFFSET("key_offset"); +const std::string LLSettingsDayCycle::SETTING_NAME("name"); +const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks"); const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days +const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0 +const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water + //========================================================================= LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) : LLSettingsBase(data) { + mDayTracks.resize(TRACK_MAX); } LLSettingsDayCycle::LLSettingsDayCycle() : LLSettingsBase() { + mDayTracks.resize(TRACK_MAX); } //========================================================================= @@ -75,18 +129,36 @@ LLSD LLSettingsDayCycle::defaults() { LLSD dfltsetting; + dfltsetting[SETTING_NAME] = "_default_"; + dfltsetting[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; + dfltsetting[SETTING_TRACKS] = LLSDArray( + LLSDArray(LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) + (LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); return dfltsetting; } - LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) { LLSD newsettings(defaults()); - //newsettings[SETTING_NAME] = name; + newsettings[SETTING_NAME] = name; + newsettings[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; + + LLSD watertrack = LLSDArray( + LLSDMap ( SETTING_KEYOFFSET, LLSD::Real(0.0f) ) + ( SETTING_KEYNAME, "Default" )); + LLSD skytrack = LLSD::emptyArray(); + for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) + { + LLSD entry = LLSDMap(SETTING_KEYOFFSET, (*it)[0].asReal()) + (SETTING_KEYNAME, (*it)[1].asString()); + skytrack.append(entry); + } + + newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); LLSettingsDayCycle::ptr_t dayp = boost::make_shared(newsettings); @@ -102,6 +174,39 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildDefaultDayCycle() return dayp; } +void LLSettingsDayCycle::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 offset = (*it)[SETTING_KEYOFFSET].asReal(); + 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][offset] = setting; + } + } +} + + LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() { LLSD settings = cloneSettings(); @@ -111,6 +216,12 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() return dayp; } +LLSettingsBase::ptr_t LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) const +{ + LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; + return LLSettingsBase::ptr_t(); +} + //========================================================================= F32 LLSettingsDayCycle::secondsToOffset(S32 seconds) { @@ -119,6 +230,13 @@ F32 LLSettingsDayCycle::secondsToOffset(S32 seconds) return static_cast(seconds % daylength) / static_cast(daylength); } +S32 LLSettingsDayCycle::offsetToSeconds(F32 offset) +{ + S32 daylength = getDayLength(); + + return static_cast(offset * static_cast(daylength)); +} + //========================================================================= void LLSettingsDayCycle::updateSettings() { @@ -133,13 +251,93 @@ void LLSettingsDayCycle::setDayLength(S32 seconds) setValue(SETTING_DAYLENGTH, seconds); } -void LLSettingsDayCycle::setWaterAt(const LLSettingsSkyPtr_t &water, S32 seconds) +LLSettingsDayCycle::OffsetList_t LLSettingsDayCycle::getTrackOffsets(S32 trackno) { -// F32 offset = secondsToOffset(seconds); + if ((trackno < 1) || (trackno >= TRACK_MAX)) + { + LL_WARNS("DAYCYCLE") << "Attempt get track (#" << trackno << ") out of range!" << LL_ENDL; + return OffsetList_t(); + } + OffsetList_t offsets; + CycleTrack_t &track = mDayTracks[trackno]; + + offsets.reserve(track.size()); + + for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) + { + offsets.push_back((*it).first); + } + + return offsets; +} + +LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) +{ + OffsetList_t offsets = getTrackOffsets(trackno); + + if (offsets.empty()) + return TimeList_t(); + + TimeList_t times; + + times.reserve(offsets.size()); + for (OffsetList_t::iterator it = offsets.begin(); it != offsets.end(); ++it) + { + times.push_back(offsetToSeconds(*it)); + } + + return times; +} + +void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds) +{ + F32 offset = secondsToOffset(seconds); + setWaterAtOffset(water, offset); +} + +void LLSettingsDayCycle::setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset) +{ + mDayTracks[TRACK_WATER][offset] = water; + setDirtyFlag(true); } -void setSkyAtOnTrack(const LLSettingsSkyPtr_t &water, S32 seconds, S32 track) + +void LLSettingsDayCycle::setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track) { + if ((track < 1) || (track >= TRACK_MAX)) + { + LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; + return; + } + F32 offset = secondsToOffset(seconds); + + mDayTracks[track][offset] = sky; + setDirtyFlag(true); + +} +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 offset) +{ + return TrackBound_t(get_wrapping_atbefore(track, offset), get_wrapping_atafter(track, offset)); } + +LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 offset) +{ + TrackBound_t bounds = getBoundingEntries(track, offset); + + if (bounds.first == track.end()) + return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. + + if (bounds.first == bounds.second) + { // Single entry. Nothing to blend + return (*bounds.first).second; + } + + F32 blendf = get_wrapping_distance((*bounds.first).first, offset) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + LLSettingsBase::ptr_t base = (*bounds.first).second; + return base->blend((*bounds.second).second, blendf); +} + +//========================================================================= diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index 9aaa30c24f..5eb704cdb7 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -40,11 +40,24 @@ class LLSettingsDayCycle : 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_KEYOFFSET; + static const std::string SETTING_NAME; + static const std::string SETTING_TRACKS; static const S32 MINIMUM_DAYLENGTH; static const S32 MAXIMUM_DAYLENGTH; - typedef boost::shared_ptr ptr_t; + static const S32 TRACK_WATER; + static const S32 TRACK_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 OffsetList_t; + typedef std::pair TrackBound_t; //--------------------------------------------------------------------- LLSettingsDayCycle(const LLSD &data); @@ -58,7 +71,7 @@ public: virtual std::string getSettingType() const { return std::string("daycycle"); } // Settings status - ptr_t blend(const ptr_t &other, F32 mix) const; + virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &other, F32 mix) const; static LLSD defaults(); @@ -70,8 +83,14 @@ public: void setDayLength(S32 seconds); - void setWaterAt(const LLSettingsSkyPtr_t &water, S32 seconds); - void setSkyAtOnTrack(const LLSettingsSkyPtr_t &water, S32 seconds, S32 track); + OffsetList_t getTrackOffsets(S32 track); + TimeList_t getTrackTimes(S32 track); + + void setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds); + void setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset); + LLSettingsSkyPtr_t getBlendedWaterAt(S32 seconds); + + void setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track); //--------------------------------------------------------------------- protected: @@ -79,13 +98,22 @@ protected: virtual void updateSettings(); - typedef std::map CycleTrack_t; - typedef std::vector CycleList_t; - typedef std::pair TrackBound_t; CycleList_t mDayTracks; F32 secondsToOffset(S32 seconds); + S32 offsetToSeconds(F32 offset); + + LLSettingsBase::ptr_t getBlendedEntry(CycleTrack_t &track, F32 offset); + + void parseFromLLSD(LLSD &data); +// CycleList_t & getTrackRef(S32 trackno); + + static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 offset); + static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 offset); + + static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 offset); + private: diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index c91d4e59ce..782703c7f7 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -103,6 +103,17 @@ LLSettingsSky::LLSettingsSky(): { } +LLSettingsBase::ptr_t LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const +{ + LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + + LLSettingsSky::ptr_t skyp = boost::make_shared(blenddata); + + return skyp; +} + + void LLSettingsSky::setMoonRotation(F32 azimuth, F32 altitude) { setValue(SETTING_MOON_ROTATION, ::body_position_from_angles(azimuth, altitude)); diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 8052651030..977ab5141e 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -414,6 +414,8 @@ public: protected: LLSettingsSky(); + virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const; + virtual stringset_t getSlerpKeys() const; virtual void updateSettings(); diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index babaa0b218..52448bd4af 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -195,6 +195,17 @@ LLSettingsWater::ptr_t LLSettingsWater::buildClone() return skyp; } +LLSettingsBase::ptr_t LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const +{ + LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + + LLSettingsWater::ptr_t waterp = boost::make_shared(blenddata); + + return waterp; +} + + //========================================================================= LLSettingsWater::parammapping_t LLSettingsWater::getParameterMap() const diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h index d8c9ff5cc6..6a7e692c25 100644 --- a/indra/newview/llsettingswater.h +++ b/indra/newview/llsettingswater.h @@ -63,7 +63,7 @@ public: virtual std::string getSettingType() const { return std::string("water"); } // Settings status - ptr_t blend(const ptr_t &other, F32 mix) const; + virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const; static LLSD defaults(); -- cgit v1.2.3 From 61e6632a713041e8e4ccebf72874767238bf8a48 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Nov 2017 11:28:08 -0700 Subject: Initial day cycle impl. --- indra/newview/lldaycyclemanager.cpp | 3 + indra/newview/llenvironment.cpp | 469 +++++++++++++++++++++++-- indra/newview/llenvironment.h | 146 +++++--- indra/newview/llenvmanager.h | 1 + indra/newview/llfloatereditdaycycle.cpp | 1 + indra/newview/llfloatereditsky.cpp | 167 +++------ indra/newview/llfloatereditsky.h | 2 +- indra/newview/llfloatereditwater.cpp | 164 ++------- indra/newview/llfloatereditwater.h | 1 + indra/newview/llfloaterenvironmentsettings.cpp | 112 +++--- indra/newview/llfloaterenvironmentsettings.h | 1 + indra/newview/llsettingsbase.cpp | 24 +- indra/newview/llsettingsbase.h | 34 +- indra/newview/llsettingsdaycycle.cpp | 179 +++++++--- indra/newview/llsettingsdaycycle.h | 28 +- indra/newview/llsettingssky.cpp | 31 +- indra/newview/llsettingssky.h | 4 +- indra/newview/llsettingswater.cpp | 9 +- indra/newview/llsettingswater.h | 3 +- indra/newview/llwaterparammanager.cpp | 4 - indra/newview/llwlparammanager.cpp | 5 - 21 files changed, 875 insertions(+), 513 deletions(-) diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp index 803e2b2fb2..23d442f3b6 100644 --- a/indra/newview/lldaycyclemanager.cpp +++ b/indra/newview/lldaycyclemanager.cpp @@ -30,6 +30,9 @@ #include "lldiriterator.h" +#include "llenvironment.h" +#include "llsettingsdaycycle.h" + void LLDayCycleManager::getPresetNames(preset_name_list_t& names) const { names.clear(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index fbb713c6d8..9c654bbeb5 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -29,7 +29,6 @@ #include "llenvironment.h" #include "llagent.h" -#include "lldaycyclemanager.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewerregion.h" #include "llwlhandlers.h" @@ -40,6 +39,10 @@ #include "pipeline.h" #include "llsky.h" +#include "llviewershadermgr.h" + +#include "llsdserialize.h" +#include "lldiriterator.h" //========================================================================= namespace { @@ -53,21 +56,37 @@ const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS) //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): - mCurrentSky(), - mCurrentWater(), + mSelectedSky(), + mSelectedWater(), + mSelectedDayCycle(), mSkysById(), mSkysByName(), mWaterByName(), mWaterById(), + mDayCycleByName(), + mDayCycleById(), mUserPrefs() +{ +} + +void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); addSky(p_default_sky); - mCurrentSky = p_default_sky; + mSelectedSky = p_default_sky; LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); addWater(p_default_water); - mCurrentWater = p_default_water; + mSelectedWater = p_default_water; + + LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle(); + addDayCycle(p_default_day); + mSelectedDayCycle.reset(); + + applyAllSelected(); + + // LEGACY! + legacyLoadAllPresets(); } LLEnvironment::~LLEnvironment() @@ -79,10 +98,25 @@ void LLEnvironment::loadPreferences() mUserPrefs.load(); } +LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) +{ + return mSkyListChange.connect(cb); +} + +LLEnvironment::connection_t LLEnvironment::setWaterListChange(const LLEnvironment::change_signal_t::slot_type& cb) +{ + return mWaterListChange.connect(cb); +} + +LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnvironment::change_signal_t::slot_type& cb) +{ + return mDayCycleListChange.connect(cb); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); + return (mSelectedSky->getDomeOffset() * mSelectedSky->getDomeRadius()); } F32 LLEnvironment::getWaterHeight() const @@ -92,7 +126,7 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mSelectedSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } //------------------------------------------------------------------------- @@ -102,7 +136,13 @@ void LLEnvironment::update(const LLViewerCamera * cam) // update clouds, sun, and general updateCloudScroll(); - mCurrentSky->update(); + if (mSelectedDayCycle) + mSelectedDayCycle->update(); + + if (mSelectedSky) + mSelectedSky->update(); + if (mSelectedWater) + mSelectedWater->update(); // // update only if running // if (mAnimator.getIsRunning()) @@ -139,6 +179,11 @@ void LLEnvironment::update(const LLViewerCamera * cam) } } +void advanceDay(F32 delta) +{ + +} + void LLEnvironment::updateCloudScroll() { // This is a function of the environment rather than the sky, since it should @@ -147,7 +192,7 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast(delta_t)* (mSelectedSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; @@ -225,8 +270,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) if (gPipeline.canUseWindLightShaders()) { - updateGLVariablesForSettings(shader, mCurrentSky); - updateGLVariablesForSettings(shader, mCurrentWater); + updateGLVariablesForSettings(shader, mSelectedSky); + updateGLVariablesForSettings(shader, mSelectedWater); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -248,6 +293,176 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } //-------------------------------------------------------------------------- +void LLEnvironment::selectSky(const std::string &name) +{ + LLSettingsSky::ptr_t next_sky = findSkyByName(name); + if (!next_sky) + { + LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; + return; + } + + selectSky(next_sky); +} + +void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky) +{ + if (!sky) + { + mSelectedSky = mCurrentSky; + return; + } + mSelectedSky = sky; + mSelectedSky->setDirtyFlag(true); +} + +void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky) +{ + if (sky) + { + mCurrentSky = sky; + } + else + { + mCurrentSky = mSelectedSky; + } +} + +void LLEnvironment::selectWater(const std::string &name) +{ + LLSettingsWater::ptr_t next_water = findWaterByName(name); + + if (!next_water) + { + LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; + return; + } + + selectWater(next_water); +} + +void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water) +{ + if (!water) + { + mSelectedWater = mCurrentWater; + return; + } + mSelectedWater = water; + mSelectedWater->setDirtyFlag(true); +} + +void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water) +{ + if (water) + { + mCurrentWater = water; + } + else + { + mCurrentWater = mSelectedWater; + } +} + +void LLEnvironment::selectDayCycle(const std::string &name) +{ + LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name); + + if (!next_daycycle) + { + LL_WARNS("ENVIRONMENT") << "Unable to select daycycle with unknown name '" << name << "'" << LL_ENDL; + return; + } + + mSelectedDayCycle = next_daycycle; + mSelectedDayCycle->setDirtyFlag(true); +} + +void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +{ + if (!daycycle) + { + mSelectedDayCycle = mCurrentDayCycle; + return; + } + + mSelectedDayCycle = daycycle; + mSelectedDayCycle->setDirtyFlag(true); +} + +void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +{ + if (daycycle) + { + mCurrentDayCycle = daycycle; + } + else + { + mCurrentDayCycle = mSelectedDayCycle; + } +} + +void LLEnvironment::clearAllSelected() +{ + if (mSelectedSky != mCurrentSky) + selectSky(); + if (mSelectedWater != mCurrentWater) + selectWater(); + if (mSelectedDayCycle != mCurrentDayCycle) + selectDayCycle(); +} + +void LLEnvironment::applyAllSelected() +{ + if (mSelectedSky != mCurrentSky) + applySky(); + if (mSelectedWater != mCurrentWater) + applyWater(); + if (mSelectedDayCycle != mCurrentDayCycle) + applyDayCycle(); +} + +LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const +{ + list_name_id_t list; + + list.reserve(mSkysByName.size()); + + for (NamedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it) + { + list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + } + + return list; +} + +LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const +{ + list_name_id_t list; + + list.reserve(mWaterByName.size()); + + for (NamedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it) + { + list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + } + + return list; +} + +LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const +{ + list_name_id_t list; + + list.reserve(mDayCycleByName.size()); + + for (NamedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it) + { + list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + } + + return list; +} void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) { @@ -260,6 +475,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) if (!result.second) (*(result.first)).second = sky; + mSkyListChange(); } // void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) @@ -278,6 +494,7 @@ void LLEnvironment::removeSky(const std::string &name) NamedSettingMap_t::iterator it = mSkysByName.find(name); if (it != mSkysByName.end()) mSkysByName.erase(it); + mSkyListChange(); } // void LLEnvironment::removeSky(const LLUUID &id) @@ -289,19 +506,7 @@ void LLEnvironment::clearAllSkys() { mSkysByName.clear(); mSkysById.clear(); -} - -void LLEnvironment::selectSky(const std::string &name) -{ - LLSettingsSky::ptr_t next_sky = findSkyByName(name); - if (!next_sky) - { - LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; - return; - } - - mCurrentSky = next_sky; - mCurrentSky->setDirtyFlag(true); + mSkyListChange(); } void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) @@ -315,29 +520,17 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) if (!result.second) (*(result.first)).second = water; + mWaterListChange(); } //void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); -void LLEnvironment::selectWater(const std::string &name) -{ - LLSettingsWater::ptr_t next_water = findWaterByName(name); - - if (!next_water) - { - LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; - return; - } - - mCurrentWater = next_water; - mCurrentWater->setDirtyFlag(true); -} - void LLEnvironment::removeWater(const std::string &name) { NamedSettingMap_t::iterator it = mWaterByName.find(name); if (it != mWaterByName.end()) mWaterByName.erase(it); + mWaterListChange(); } //void LLEnvironment::removeWater(const LLUUID &id); @@ -345,6 +538,39 @@ void LLEnvironment::clearAllWater() { mWaterByName.clear(); mWaterById.clear(); + mWaterListChange(); +} + +void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +{ + std::string name = daycycle->getValue(LLSettingsDayCycle::SETTING_NAME).asString(); + + LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; + + std::pair result; + result = mDayCycleByName.insert(NamedSettingMap_t::value_type(name, daycycle)); + + if (!result.second) + (*(result.first)).second = daycycle; + mDayCycleListChange(); +} + +//void LLEnvironment::addDayCycle(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + +void LLEnvironment::removeDayCycle(const std::string &name) +{ + NamedSettingMap_t::iterator it = mDayCycleByName.find(name); + if (it != mDayCycleByName.end()) + mDayCycleByName.erase(it); + mDayCycleListChange(); +} + +//void LLEnvironment::removeDayCycle(const LLUUID &id); +void LLEnvironment::clearAllDayCycles() +{ + mDayCycleByName.clear(); + mWaterById.clear(); + mDayCycleListChange(); } LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const @@ -373,6 +599,19 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const return boost::static_pointer_cast((*it).second); } +LLSettingsDayCycle::ptr_t LLEnvironment::findDayCycleByName(std::string name) const +{ + NamedSettingMap_t::const_iterator it = mDayCycleByName.find(name); + + if (it == mDayCycleByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to find daycycle with unknown name '" << name << "'" << LL_ENDL; + return LLSettingsDayCycle::ptr_t(); + } + + return boost::static_pointer_cast((*it).second); +} + //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): mUseRegionSettings(true), @@ -409,3 +648,157 @@ void LLEnvironment::UserPrefs::store() gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); } } + + +//========================================================================= +// Transitional Code. +// static +std::string LLEnvironment::getSysDir(const std::string &subdir) +{ + return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight\\"+subdir, ""); +} + +// static +std::string LLEnvironment::getUserDir(const std::string &subdir) +{ + return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "windlight\\"+subdir, ""); +} + +LLSD LLEnvironment::legacyLoadPreset(const std::string& path) +{ + llifstream xml_file; + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); + + xml_file.open(path.c_str()); + if (!xml_file) + { + return LLSD(); + } + + LLSD params_data; + LLPointer parser = new LLSDXMLParser(); + parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + xml_file.close(); + + return params_data; +} + +void LLEnvironment::legacyLoadAllPresets() +{ + std::string dir; + std::string file; + + // System skies + { + dir = getSysDir("skies"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addSky(sky); + } + } + } + + // User skies + { + dir = getUserDir("skies"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addSky(sky); + } + } + } + + // System water + { + dir = getSysDir("water"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addWater(water); + } + } + } + + // User water + { + dir = getUserDir("water"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addWater(water); + } + } + } + + // System water + { + dir = getSysDir("days"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addDayCycle(day); + } + } + } + + // User water + { + dir = getUserDir("days"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addDayCycle(day); + } + } + } +} diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 493fff1769..a3fc9eef66 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -32,6 +32,7 @@ #include "llsettingssky.h" #include "llsettingswater.h" +#include "llsettingsdaycycle.h" class LLViewerCamera; class LLGLSLShader; @@ -52,22 +53,22 @@ public: public: UserPrefs(); - bool getUseRegionSettings() const { return mUseRegionSettings; } - bool getUseDayCycle() const { return mUseDayCycle; } - bool getUseFixedSky() const { return !getUseDayCycle(); } + bool getUseRegionSettings() const { return mUseRegionSettings; } + bool getUseDayCycle() const { return mUseDayCycle; } + bool getUseFixedSky() const { return !getUseDayCycle(); } - std::string getWaterPresetName() const { return mWaterPresetName; } - std::string getSkyPresetName() const { return mSkyPresetName; } - std::string getDayCycleName() const { return mDayCycleName; } + std::string getWaterPresetName() const { return mWaterPresetName; } + std::string getSkyPresetName() const { return mSkyPresetName; } + std::string getDayCycleName() const { return mDayCycleName; } - void setUseRegionSettings(bool val); - void setUseWaterPreset(const std::string& name); - void setUseSkyPreset(const std::string& name); - void setUseDayCycle(const std::string& name); + void setUseRegionSettings(bool val); + void setUseWaterPreset(const std::string& name); + void setUseSkyPreset(const std::string& name); + void setUseDayCycle(const std::string& name); private: - void load(); - void store(); + void load(); + void store(); bool mUseRegionSettings; bool mUseDayCycle; @@ -77,66 +78,104 @@ public: std::string mDayCycleName; }; + typedef std::pair name_id_t; + typedef std::vector list_name_id_t; + typedef boost::signals2::signal change_signal_t; + typedef boost::signals2::connection connection_t; + virtual ~LLEnvironment(); - void loadPreferences(); - const UserPrefs & getPreferences() const { return mUserPrefs; } + void loadPreferences(); + const UserPrefs & getPreferences() const { return mUserPrefs; } + + LLSettingsSky::ptr_t getCurrentSky() const { return mSelectedSky; } + LLSettingsWater::ptr_t getCurrentWater() const { return mSelectedWater; } - LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } - LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } + void update(const LLViewerCamera * cam); + void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); + void updateShaderUniforms(LLGLSLShader *shader); + void addSky(const LLSettingsSky::ptr_t &sky); + void addWater(const LLSettingsWater::ptr_t &sky); + void addDayCycle(const LLSettingsDayCycle::ptr_t &day); - void update(const LLViewerCamera * cam); + void selectSky(const std::string &name); + void selectSky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); + void applySky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); + void selectWater(const std::string &name); + void selectWater(const LLSettingsWater::ptr_t &water = LLSettingsWater::ptr_t()); + void applyWater(const LLSettingsWater::ptr_t water = LLSettingsWater::ptr_t()); + void selectDayCycle(const std::string &name); + void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); + void applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); + void clearAllSelected(); + void applyAllSelected(); - void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); - void updateShaderUniforms(LLGLSLShader *shader); + list_name_id_t getSkyList() const; + list_name_id_t getWaterList() const; + list_name_id_t getDayCycleList() const; - void addSky(const LLSettingsSky::ptr_t &sky); - void selectSky(const std::string &name); - LLSettingsSky::ptr_t findSkyByName(std::string name) const; - LLSettingsWater::ptr_t findWaterByName(std::string name) const; + LLSettingsSky::ptr_t findSkyByName(std::string name) const; + LLSettingsWater::ptr_t findWaterByName(std::string name) const; + LLSettingsDayCycle::ptr_t findDayCycleByName(std::string name) const; - void addWater(const LLSettingsWater::ptr_t &sky); - void selectWater(const std::string &name); + inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } - inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } + F32 getCamHeight() const; + F32 getWaterHeight() const; + bool getIsDayTime() const; // "Day Time" is defined as the sun above the horizon. + bool getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time" - F32 getCamHeight() const; - F32 getWaterHeight() const; - bool getIsDayTime() const; // "Day Time" is defined as the sun above the horizon. - bool getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time" + inline F32 getSceneLightStrength() const { return mSceneLightStrength; } + inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } - inline F32 getSceneLightStrength() const { return mSceneLightStrength; } - inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } + inline LLVector4 getLightDirection() const { return LLVector4(mSelectedSky->getLightDirection(), 0.0f); } + inline LLVector4 getClampedLightDirection() const { return LLVector4(mSelectedSky->getClampedLightDirection(), 0.0f); } + inline LLVector4 getRotatedLight() const { return mRotatedLight; } - inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } - inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } - inline LLVector4 getRotatedLight() const { return mRotatedLight; } + //------------------------------------------- + connection_t setSkyListChange(const change_signal_t::slot_type& cb); + connection_t setWaterListChange(const change_signal_t::slot_type& cb); + connection_t setDayCycleListChange(const change_signal_t::slot_type& cb); +protected: + virtual void initSingleton(); private: - static const F32 SUN_DELTA_YAW; - static const F32 NIGHTTIME_ELEVATION_COS; + static const F32 SUN_DELTA_YAW; + static const F32 NIGHTTIME_ELEVATION_COS; typedef std::map NamedSettingMap_t; typedef std::map AssetSettingMap_t; - LLVector2 mCloudScrollDelta; // cumulative cloud delta + LLVector2 mCloudScrollDelta; // cumulative cloud delta + + LLSettingsSky::ptr_t mSelectedSky; + LLSettingsWater::ptr_t mSelectedWater; + LLSettingsDayCycle::ptr_t mSelectedDayCycle; + + LLSettingsSky::ptr_t mCurrentSky; + LLSettingsWater::ptr_t mCurrentWater; + LLSettingsDayCycle::ptr_t mCurrentDayCycle; + + NamedSettingMap_t mSkysByName; + AssetSettingMap_t mSkysById; - LLSettingsSky::ptr_t mCurrentSky; - LLSettingsWater::ptr_t mCurrentWater; + NamedSettingMap_t mWaterByName; + AssetSettingMap_t mWaterById; - NamedSettingMap_t mSkysByName; - AssetSettingMap_t mSkysById; + NamedSettingMap_t mDayCycleByName; + AssetSettingMap_t mDayCycleById; - NamedSettingMap_t mWaterByName; - AssetSettingMap_t mWaterById; + F32 mSceneLightStrength; + LLVector4 mRotatedLight; - F32 mSceneLightStrength; - LLVector4 mRotatedLight; + UserPrefs mUserPrefs; - UserPrefs mUserPrefs; + change_signal_t mSkyListChange; + change_signal_t mWaterListChange; + change_signal_t mDayCycleListChange; //void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); @@ -148,7 +187,20 @@ private: //void removeWater(const LLUUID &id); void clearAllWater(); + //void addDayCycle(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + void removeDayCycle(const std::string &name); + //void removeDayCycle(const LLUUID &id); + void clearAllDayCycles(); + + void updateCloudScroll(); + + //========================================================================= + void legacyLoadAllPresets(); + LLSD legacyLoadPreset(const std::string& path); + static std::string getSysDir(const std::string &subdir); + static std::string getUserDir(const std::string &subdir); + }; diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 54bbf85e86..31a093ad5d 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -328,6 +328,7 @@ private: void onRegionChange(); + /// Emitted when user environment preferences change. prefs_change_signal_t mUsePrefsChangeSignal; diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index 5c0991b0b3..97d87ee13e 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -691,6 +691,7 @@ void LLFloaterEditDayCycle::onDayCycleNameEdited() void LLFloaterEditDayCycle::onDayCycleSelected() { + LLSD day_data; LLWLParamKey dc_key = getSelectedDayCycle(); bool can_edit = true; diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 5fd559c060..23744e5b07 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -87,6 +87,8 @@ BOOL LLFloaterEditSky::postBuild() mSaveButton = getChild("save"); mSkyAdapter = boost::make_shared(); + LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); + initCallbacks(); // // Create the sun position scrubber on the slider. @@ -124,7 +126,7 @@ void LLFloaterEditSky::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { -// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment + LLEnvironment::instance().clearAllSelected(); } } @@ -216,6 +218,10 @@ void LLFloaterEditSky::syncControls() LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); mEditSettings = psky; + std::string name = psky->getName(); + + mSkyPresetNameEditor->setText(name); + mSkyPresetCombo->setValue(name); // blue horizon mSkyAdapter->mBlueHorizon.setColor3( psky->getBlueHorizon() ); @@ -557,44 +563,16 @@ bool LLFloaterEditSky::isNewPreset() const void LLFloaterEditSky::refreshSkyPresetsList() { -#if 0 mSkyPresetCombo->removeall(); - LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - -#if 0 // Disable editing region skies until the workflow is clear enough. - // Add region presets. - std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) - { - std::string item_title = *it + " (" + region_name + ")"; - mSkyPresetCombo->add(item_title, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toLLSD()); - } - if (region_presets.size() > 0) - { - mSkyPresetCombo->addSeparator(); - } -#endif + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList(); - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - if (user_presets.size() > 0) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } mSkyPresetCombo->setLabel(getString("combo_label")); -#endif } void LLFloaterEditSky::enableEditing(bool enable) @@ -629,63 +607,51 @@ void LLFloaterEditSky::saveRegionSky() #endif } -// LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() -// { -// LLWLParamKey key; -// -// if (mSkyPresetNameEditor->getVisible()) -// { -// key.name = mSkyPresetNameEditor->getText(); -// key.scope = LLEnvKey::SCOPE_LOCAL; -// } -// else -// { -// LLSD combo_val = mSkyPresetCombo->getValue(); -// -// if (!combo_val.isArray()) // manually typed text -// { -// key.name = combo_val.asString(); -// key.scope = LLEnvKey::SCOPE_LOCAL; -// } -// else -// { -// key.fromLLSD(combo_val); -// } -// } -// -// return key; -// } +std::string LLFloaterEditSky::getSelectedPresetName() const +{ + std::string name; + if (mSkyPresetNameEditor->getVisible()) + { + name = mSkyPresetNameEditor->getText(); + } + else + { + LLSD combo_val = mSkyPresetCombo->getValue(); + name = combo_val[0].asString(); + } + + return name; +} void LLFloaterEditSky::onSkyPresetNameEdited() { -#if 0 - // Disable saving a sky preset having empty name. - LLWLParamKey key = getSelectedSkyPreset(); - mSaveButton->setEnabled(!key.name.empty()); -#endif + std::string name = mSkyPresetNameEditor->getText(); + LLSettingsWater::ptr_t psky = LLEnvironment::instance().getCurrentWater(); + + psky->setName(name); } void LLFloaterEditSky::onSkyPresetSelected() { -#if 0 - LLWLParamKey key = getSelectedSkyPreset(); - LLWLParamSet sky_params; + std::string name; - if (!LLWLParamManager::instance().getParamSet(key, sky_params)) - { - // Manually entered string? - LL_WARNS("Windlight") << "No sky preset named " << key.toString() << LL_ENDL; - return; - } + name = getSelectedPresetName(); - LLEnvManagerNew::instance().useSkyParams(sky_params.getAll()); - //syncControls(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(name); - bool can_edit = (key.scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); - enableEditing(can_edit); + if (!psky) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } + + psky = psky->buildClone(); + LLEnvironment::instance().selectSky(psky); + + syncControls(); + enableEditing(true); - mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); -#endif } bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -733,43 +699,11 @@ void LLFloaterEditSky::onSaveConfirmed() void LLFloaterEditSky::onBtnSave() { -#if 0 - LLWLParamKey selected_sky = getSelectedSkyPreset(); - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - if (selected_sky.scope == LLEnvKey::SCOPE_REGION) - { - saveRegionSky(); - closeFloater(); - return; - } - - std::string name = selected_sky.name; - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty sky preset name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - if (wl_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLEnvironment::instance().addSky(psky); - // Save, ask for confirmation for overwriting an existing preset. - if (wl_mgr.hasParamSet(selected_sky)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditSky::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } -#endif + LLEnvironment::instance().applySky(); + closeFloater(); } void LLFloaterEditSky::onBtnCancel() @@ -779,6 +713,7 @@ void LLFloaterEditSky::onBtnCancel() void LLFloaterEditSky::onSkyPresetListChange() { + refreshSkyPresetsList(); #if 0 LLWLParamKey key = getSelectedSkyPreset(); // preset being edited if (!LLWLParamManager::instance().hasParamSet(key)) diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h index 51be50a481..36438becce 100644 --- a/indra/newview/llfloatereditsky.h +++ b/indra/newview/llfloatereditsky.h @@ -98,7 +98,7 @@ private: void refreshSkyPresetsList(); void enableEditing(bool enable); void saveRegionSky(); -// LLWLParamKey getSelectedSkyPreset(); + std::string getSelectedPresetName() const; void onSkyPresetNameEdited(); void onSkyPresetSelected(); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index b025680da1..2868a0609a 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -73,6 +73,8 @@ BOOL LLFloaterEditWater::postBuild() mWaterAdapter = boost::make_shared(); + LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this)); + initCallbacks(); refreshWaterPresetsList(); syncControls(); @@ -109,7 +111,7 @@ void LLFloaterEditWater::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { -// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment + LLEnvironment::instance().clearAllSelected(); } } @@ -176,6 +178,10 @@ void LLFloaterEditWater::syncControls() LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); mEditSettings = pwater; + std::string name = pwater->getName(); + mWaterPresetNameEditor->setText(name); + mWaterPresetCombo->setValue(name); + //getChild("WaterGlow")->setValue(col.mV[3]); getChild("WaterFogColor")->set(LLColor4(pwater->getFogColor())); @@ -322,44 +328,16 @@ bool LLFloaterEditWater::isNewPreset() const void LLFloaterEditWater::refreshWaterPresetsList() { -#if 0 mWaterPresetCombo->removeall(); -#if 0 // *TODO: enable when we have a clear workflow to edit existing region environment - // If the region already has water params, add them to the list. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getWaterParams().size() != 0) - { - const std::string& region_name = gAgent.getRegion()->getName(); - mWaterPresetCombo->add(region_name, LLSD().with(0, region_name).with(1, LLEnvKey::SCOPE_REGION)); - mWaterPresetCombo->addSeparator(); - } -#endif - - std::list user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList(); - // Add local user presets first. - for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - const std::string& name = *it; - mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [, ] - } - - 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) - { - const std::string& name = *it; - mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [, ] - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } mWaterPresetCombo->setLabel(getString("combo_label")); -#endif } void LLFloaterEditWater::enableEditing(bool enable) @@ -406,36 +384,28 @@ LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const } #endif -#if 0 -void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const +std::string LLFloaterEditWater::getSelectedPresetName() const { - + std::string name; if (mWaterPresetNameEditor->getVisible()) { name = mWaterPresetNameEditor->getText(); - scope = LLEnvKey::SCOPE_LOCAL; } else { LLSD combo_val = mWaterPresetCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - name = combo_val.asString(); - scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - name = combo_val[0].asString(); - scope = (LLEnvKey::EScope) combo_val[1].asInteger(); - } + name = combo_val[0].asString(); } + return name; } -#endif void LLFloaterEditWater::onWaterPresetNameEdited() { + std::string name = mWaterPresetNameEditor->getText(); + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + + pwater->setName(name); #if 0 // Disable saving a water preset having empty name. mSaveButton->setEnabled(!getCurrentPresetName().empty()); @@ -444,35 +414,24 @@ void LLFloaterEditWater::onWaterPresetNameEdited() void LLFloaterEditWater::onWaterPresetSelected() { -#if 0 - LLWaterParamSet water_params; std::string name; - LLEnvKey::EScope scope; - getSelectedPreset(name, scope); + name = getSelectedPresetName(); - // Display selected preset. - if (scope == LLEnvKey::SCOPE_REGION) - { - water_params.setAll(LLEnvManagerNew::instance().getRegionSettings().getWaterParams()); - } - else // local preset selected - { - if (!LLWaterParamManager::instance().getParamSet(name, water_params)) - { - // Manually entered string? - LL_WARNS("Windlight") << "No water preset named " << name << LL_ENDL; - return; - } - } + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(name); - LLEnvManagerNew::instance().useWaterParams(water_params.getAll()); + if (!pwater) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } - bool can_edit = (scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); - enableEditing(can_edit); + pwater = pwater->buildClone(); + LLEnvironment::instance().selectWater(pwater); - mMakeDefaultCheckBox->setEnabled(scope == LLEnvKey::SCOPE_LOCAL); -#endif + syncControls(); + enableEditing(true); } bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -521,44 +480,11 @@ void LLFloaterEditWater::onSaveConfirmed() void LLFloaterEditWater::onBtnSave() { -#if 0 - LLEnvKey::EScope scope; - std::string name; - getSelectedPreset(name, scope); - - if (scope == LLEnvKey::SCOPE_REGION) - { - saveRegionWater(); - closeFloater(); - return; - } - - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty water preset name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - if (water_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + LLEnvironment::instance().addWater(pwater); - // Save, ask for confirmation for overwriting an existing preset. - if (water_mgr.hasParamSet(name)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditWater::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } -#endif + LLEnvironment::instance().applyWater(); + closeFloater(); } void LLFloaterEditWater::onBtnCancel() @@ -568,23 +494,7 @@ void LLFloaterEditWater::onBtnCancel() void LLFloaterEditWater::onWaterPresetListChange() { -#if 0 - std::string name; - LLEnvKey::EScope scope; - getSelectedPreset(name, scope); // preset being edited - - if (scope == LLEnvKey::SCOPE_LOCAL && !LLWaterParamManager::instance().hasParamSet(name)) - { - // Preset we've been editing doesn't exist anymore. Close the floater. - closeFloater(false); - } - else - { - // A new preset has been added. - // Refresh the presets list, though it may not make sense as the floater is about to be closed. - refreshWaterPresetsList(); - } -#endif + refreshWaterPresetsList(); } void LLFloaterEditWater::onRegionSettingsChange() diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h index 7d9e493ac2..081b939039 100644 --- a/indra/newview/llfloatereditwater.h +++ b/indra/newview/llfloatereditwater.h @@ -87,6 +87,7 @@ private: void enableEditing(bool enable); void saveRegionWater(); + std::string getSelectedPresetName() const; // std::string getCurrentPresetName() const; // LLEnvKey::EScope getCurrentScope() const; // void getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const; diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 39907b19a3..e25c5cedbf 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -70,10 +70,10 @@ BOOL LLFloaterEnvironmentSettings::postBuild() setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); + LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); + LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); + LLEnvironment::instance().setDayCycleListChange(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); // LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); -// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); -// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); -// LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); return TRUE; } @@ -84,6 +84,14 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) refresh(); } +//virtual +void LLFloaterEnvironmentSettings::onClose(bool app_quitting) +{ + if (!app_quitting) + LLEnvironment::instance().clearAllSelected(); +} + + void LLFloaterEnvironmentSettings::onSwitchRegionSettings() { getChild("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); @@ -133,6 +141,7 @@ void LLFloaterEnvironmentSettings::onBtnOK() use_region_settings); // *TODO: This triggers applying user preferences again, which is suboptimal. + LLEnvironment::instance().applyAllSelected(); closeFloater(); } @@ -173,9 +182,9 @@ void LLFloaterEnvironmentSettings::apply() // Update environment with the user choice. bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - std::string water_preset = mWaterPresetCombo->getValue().asString(); - std::string sky_preset = mSkyPresetCombo->getValue().asString(); - std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); + std::string water_preset = mWaterPresetCombo->getValue()[0].asString(); + std::string sky_preset = mSkyPresetCombo->getValue()[0].asString(); + std::string day_cycle = mDayCyclePresetCombo->getValue()[0].asString(); LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); if (use_region_settings) @@ -186,18 +195,23 @@ void LLFloaterEnvironmentSettings::apply() { if (use_fixed_sky) { - /* LAPRAS */ - //env_mgr.useSkyPreset(sky_preset); - LLEnvironment::instance().selectSky(sky_preset); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset); + if (psky) + LLEnvironment::instance().selectSky(psky); } else { - env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); + LLSettingsDayCycle::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle); + if (pday) + LLEnvironment::instance().selectDayCycle(pday); + +// LLEnvironment::instance().selectDayCycle(day_cycle); +// env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); } - /* LAPRAS */ - //env_mgr.useWaterPreset(water_preset); - LLEnvironment::instance().selectWater(water_preset); + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset); + if (pwater) + LLEnvironment::instance().selectWater(pwater); } } @@ -209,76 +223,36 @@ void LLFloaterEnvironmentSettings::cancel() void LLFloaterEnvironmentSettings::populateWaterPresetsList() { - mWaterPresetCombo->removeall(); + mWaterPresetCombo->removeall(); - std::list user_presets, system_presets; - //LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList(); - // Add user presets first. - for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mWaterPresetCombo->add(*it); - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add system presets. - for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - mWaterPresetCombo->add(*it); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } } void LLFloaterEnvironmentSettings::populateSkyPresetsList() { mSkyPresetCombo->removeall(); - LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList(); - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it); - } - - if (!user_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } } void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() { mDayCyclePresetCombo->removeall(); - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getDayCycleList(); - // Add user days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it); - } - - if (user_days.size() > 0) - { - mDayCyclePresetCombo->addSeparator(); - } - - // Add system days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mDayCyclePresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } } diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h index 0ab458a0f6..2236d57ff4 100644 --- a/indra/newview/llfloaterenvironmentsettings.h +++ b/indra/newview/llfloaterenvironmentsettings.h @@ -40,6 +40,7 @@ public: LLFloaterEnvironmentSettings(const LLSD &key); /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); private: void onSwitchRegionSettings(); diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp index 1f155776bf..a2e705d1fa 100644 --- a/indra/newview/llsettingsbase.cpp +++ b/indra/newview/llsettingsbase.cpp @@ -33,11 +33,16 @@ #include "llsdserialize.h" +//========================================================================= namespace { const F32 BREAK_POINT = 0.5; } +//========================================================================= +const std::string LLSettingsBase::SETTING_ID("id"); +const std::string LLSettingsBase::SETTING_NAME("name"); + //========================================================================= LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), @@ -242,15 +247,16 @@ LLSD LLSettingsBase::cloneSettings() const LLSettingsBase::ptr_t LLSettingsBase::buildBlend(const ptr_t &begin, const ptr_t &end, F32 blendf) { - if (begin->getSettingType() != end->getSettingType()) - { - LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " << - begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL; - - return LLSettingsBase::ptr_t(); - } - - return begin->blend(end, blendf); +// if (begin->getSettingType() != end->getSettingType()) +// { +// LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " << +// begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL; +// +// return LLSettingsBase::ptr_t(); +// } + +// return begin->blend(end, blendf); + return LLSettingsBase::ptr_t(); } void LLSettingsBase::exportSettings(std::string name) const diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index f7015fb12b..205351c401 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -46,6 +46,9 @@ class LLSettingsBase: private boost::noncopyable friend class LLSettingsDayCycle; public: + static const std::string SETTING_ID; + static const std::string SETTING_NAME; + typedef std::map parammapping_t; typedef boost::shared_ptr ptr_t; @@ -63,6 +66,32 @@ public: inline bool isDirty() const { return mDirty; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; } + inline LLUUID getId() const + { + return getValue(SETTING_ID).asUUID(); + } + + inline std::string getName() const + { + return getValue(SETTING_NAME).asString(); + } + + inline void setName(std::string val) + { + setValue(SETTING_NAME, val); + } + + inline void replaceSettings(LLSD settings) + { + mSettings = settings; + setDirtyFlag(true); + } + + inline LLSD getSettings() const + { + return mSettings; + } + //--------------------------------------------------------------------- // inline void setValue(const std::string &name, const LLSD &value) @@ -71,7 +100,7 @@ public: mDirty = true; } - inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const { if (!mSettings.has(name)) return deflt; @@ -121,13 +150,14 @@ public: // TODO: This is temporary virtual void exportSettings(std::string name) const; + virtual void blend(const ptr_t &end, F32 blendf) = 0; + protected: LLSettingsBase(); LLSettingsBase(const LLSD setting); typedef std::set stringset_t; - virtual ptr_t blend(const ptr_t &end, F32 blendf) const = 0; // combining settings objects. Customize for specific setting types virtual void lerpSettings(const LLSettingsBase &other, F32 mix); diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp index bda3c7c138..2d97ea865f 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -47,6 +47,8 @@ #include "llenvironment.h" +#include "llworld.h" + //========================================================================= namespace { @@ -55,7 +57,16 @@ namespace inline F32 get_wrapping_distance(F32 begin, F32 end) { - return 1.0 - fabs((begin + 1.0) - end); + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; } LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDayCycle::CycleTrack_t &collection, F32 key) @@ -81,11 +92,11 @@ namespace LLSettingsDayCycle::CycleTrack_t::iterator it = collection.lower_bound(key); if (it == collection.end()) - { // all offsets are lower, take the last one. + { // all keyframes are lower, take the last one. --it; // we know the range is not empty } else if ((*it).first > key) - { // the offset we are interested in is smaller than the found. + { // the keyframe we are interested in is smaller than the found. if (it == collection.begin()) it = collection.end(); --it; @@ -101,11 +112,13 @@ namespace const std::string LLSettingsDayCycle::SETTING_DAYLENGTH("day_length"); const std::string LLSettingsDayCycle::SETTING_KEYID("key_id"); const std::string LLSettingsDayCycle::SETTING_KEYNAME("key_name"); -const std::string LLSettingsDayCycle::SETTING_KEYOFFSET("key_offset"); +const std::string LLSettingsDayCycle::SETTING_KEYKFRAME("key_keyframe"); const std::string LLSettingsDayCycle::SETTING_NAME("name"); const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks"); -const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins + +//const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0 @@ -113,13 +126,15 @@ const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water //========================================================================= LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) : - LLSettingsBase(data) + LLSettingsBase(data), + mHasParsed(false) { mDayTracks.resize(TRACK_MAX); } LLSettingsDayCycle::LLSettingsDayCycle() : - LLSettingsBase() + LLSettingsBase(), + mHasParsed(false) { mDayTracks.resize(TRACK_MAX); } @@ -132,8 +147,8 @@ LLSD LLSettingsDayCycle::defaults() dfltsetting[SETTING_NAME] = "_default_"; dfltsetting[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; dfltsetting[SETTING_TRACKS] = LLSDArray( - LLSDArray(LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) - (LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); + LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) + (LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); return dfltsetting; } @@ -146,14 +161,14 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s newsettings[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; LLSD watertrack = LLSDArray( - LLSDMap ( SETTING_KEYOFFSET, LLSD::Real(0.0f) ) + LLSDMap ( SETTING_KEYKFRAME, LLSD::Real(0.0f) ) ( SETTING_KEYNAME, "Default" )); LLSD skytrack = LLSD::emptyArray(); for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) { - LLSD entry = LLSDMap(SETTING_KEYOFFSET, (*it)[0].asReal()) + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) (SETTING_KEYNAME, (*it)[1].asString()); skytrack.append(entry); } @@ -185,7 +200,7 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) LLSD curtrack = tracks[i]; for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { - F32 offset = (*it)[SETTING_KEYOFFSET].asReal(); + F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -201,9 +216,10 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) } if (setting) - mDayTracks[i][offset] = setting; + mDayTracks[i][keyframe] = setting; } } + mHasParsed = true; } @@ -216,31 +232,85 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() return dayp; } -LLSettingsBase::ptr_t LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) const +void LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; - return LLSettingsBase::ptr_t(); } //========================================================================= -F32 LLSettingsDayCycle::secondsToOffset(S32 seconds) +F32 LLSettingsDayCycle::secondsToKeyframe(S32 seconds) { S32 daylength = getDayLength(); return static_cast(seconds % daylength) / static_cast(daylength); } -S32 LLSettingsDayCycle::offsetToSeconds(F32 offset) +S32 LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) { S32 daylength = getDayLength(); - return static_cast(offset * static_cast(daylength)); + return static_cast(keyframe * static_cast(daylength)); } //========================================================================= void LLSettingsDayCycle::updateSettings() { + if (!mHasParsed) + parseFromLLSD(mSettings); + //F64Seconds time_now(LLWorld::instance().getSpaceTimeUSec()); + F64Seconds time_now(LLDate::now().secondsSinceEpoch()); + + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + if (!mBlendedWater) + { + mBlendedWater = LLEnvironment::instance().getCurrentWater()->buildClone(); + LLEnvironment::instance().selectWater(mBlendedWater); + } + + if (!mBlendedSky) + { + mBlendedSky = LLEnvironment::instance().getCurrentSky()->buildClone(); + LLEnvironment::instance().selectSky(mBlendedSky); + } + + + if ((time_now < mLastUpdateTime) || ((time_now - mLastUpdateTime) > static_cast(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); } //========================================================================= @@ -251,40 +321,40 @@ void LLSettingsDayCycle::setDayLength(S32 seconds) setValue(SETTING_DAYLENGTH, seconds); } -LLSettingsDayCycle::OffsetList_t LLSettingsDayCycle::getTrackOffsets(S32 trackno) +LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 trackno) { if ((trackno < 1) || (trackno >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt get track (#" << trackno << ") out of range!" << LL_ENDL; - return OffsetList_t(); + return KeyframeList_t(); } - OffsetList_t offsets; + KeyframeList_t keyframes; CycleTrack_t &track = mDayTracks[trackno]; - offsets.reserve(track.size()); + keyframes.reserve(track.size()); for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) { - offsets.push_back((*it).first); + keyframes.push_back((*it).first); } - return offsets; + return keyframes; } LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) { - OffsetList_t offsets = getTrackOffsets(trackno); + KeyframeList_t keyframes = getTrackKeyframes(trackno); - if (offsets.empty()) + if (keyframes.empty()) return TimeList_t(); TimeList_t times; - times.reserve(offsets.size()); - for (OffsetList_t::iterator it = offsets.begin(); it != offsets.end(); ++it) + times.reserve(keyframes.size()); + for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it) { - times.push_back(offsetToSeconds(*it)); + times.push_back(keyframeToSeconds(*it)); } return times; @@ -292,13 +362,13 @@ LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds) { - F32 offset = secondsToOffset(seconds); - setWaterAtOffset(water, offset); + F32 keyframe = secondsToKeyframe(seconds); + setWaterAtKeyframe(water, keyframe); } -void LLSettingsDayCycle::setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset) +void LLSettingsDayCycle::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { - mDayTracks[TRACK_WATER][offset] = water; + mDayTracks[TRACK_WATER][keyframe] = water; setDirtyFlag(true); } @@ -310,34 +380,33 @@ void LLSettingsDayCycle::setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seco LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; return; } - F32 offset = secondsToOffset(seconds); + F32 keyframe = secondsToKeyframe(seconds); - mDayTracks[track][offset] = sky; + mDayTracks[track][keyframe] = sky; setDirtyFlag(true); - } -LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 offset) +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 keyframe) { - return TrackBound_t(get_wrapping_atbefore(track, offset), get_wrapping_atafter(track, offset)); + return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } -LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 offset) -{ - TrackBound_t bounds = getBoundingEntries(track, offset); - - if (bounds.first == track.end()) - return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. - - if (bounds.first == bounds.second) - { // Single entry. Nothing to blend - return (*bounds.first).second; - } - - F32 blendf = get_wrapping_distance((*bounds.first).first, offset) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - - LLSettingsBase::ptr_t base = (*bounds.first).second; - return base->blend((*bounds.second).second, blendf); -} +// LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 keyframe) +// { +// TrackBound_t bounds = getBoundingEntries(track, keyframe); +// +// if (bounds.first == track.end()) +// return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. +// +// if (bounds.first == bounds.second) +// { // Single entry. Nothing to blend +// return (*bounds.first).second; +// } +// +// F32 blendf = get_wrapping_distance((*bounds.first).first, keyframe) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); +// +// LLSettingsBase::ptr_t base = (*bounds.first).second; +// return base->blend((*bounds.second).second, blendf); +// } //========================================================================= diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index 5eb704cdb7..f332b85dee 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -42,7 +42,7 @@ public: static const std::string SETTING_DAYLENGTH; static const std::string SETTING_KEYID; static const std::string SETTING_KEYNAME; - static const std::string SETTING_KEYOFFSET; + static const std::string SETTING_KEYKFRAME; static const std::string SETTING_NAME; static const std::string SETTING_TRACKS; @@ -56,7 +56,7 @@ public: typedef std::vector CycleList_t; typedef boost::shared_ptr ptr_t; typedef std::vector TimeList_t; - typedef std::vector OffsetList_t; + typedef std::vector KeyframeList_t; typedef std::pair TrackBound_t; //--------------------------------------------------------------------- @@ -71,7 +71,7 @@ public: virtual std::string getSettingType() const { return std::string("daycycle"); } // Settings status - virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &other, F32 mix) const; + virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix); static LLSD defaults(); @@ -83,11 +83,11 @@ public: void setDayLength(S32 seconds); - OffsetList_t getTrackOffsets(S32 track); + KeyframeList_t getTrackKeyframes(S32 track); TimeList_t getTrackTimes(S32 track); void setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds); - void setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset); + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); LLSettingsSkyPtr_t getBlendedWaterAt(S32 seconds); void setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track); @@ -98,23 +98,27 @@ protected: virtual void updateSettings(); + LLSettingsSkyPtr_t mBlendedSky; + LLSettingsWaterPtr_t mBlendedWater; CycleList_t mDayTracks; - F32 secondsToOffset(S32 seconds); - S32 offsetToSeconds(F32 offset); + bool mHasParsed; - LLSettingsBase::ptr_t getBlendedEntry(CycleTrack_t &track, F32 offset); + F32 secondsToKeyframe(S32 seconds); + S32 keyframeToSeconds(F32 keyframe); + + //LLSettingsBase::ptr_t getBlendedEntry(const CycleTrack_t &track, F32 keyframe); void parseFromLLSD(LLSD &data); // CycleList_t & getTrackRef(S32 trackno); - static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 offset); - static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 offset); - - static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 offset); + static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); + static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); + static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + F32Seconds mLastUpdateTime; private: }; diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 782703c7f7..c420ebca1e 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -81,7 +81,6 @@ const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); const std::string LLSettingsSky::SETTING_MAX_Y("max_y"); const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation"); const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id"); -const std::string LLSettingsSky::SETTING_NAME("name"); const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); @@ -103,14 +102,12 @@ LLSettingsSky::LLSettingsSky(): { } -LLSettingsBase::ptr_t LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const +void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) { LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); - LLSettingsSky::ptr_t skyp = boost::make_shared(blenddata); - - return skyp; + replaceSettings(blenddata); } @@ -301,18 +298,18 @@ LLSettingsSky::ptr_t LLSettingsSky::buildClone() // Settings status -LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const -{ - LL_RECORD_BLOCK_TIME(FTM_BLEND_SKYVALUES); - LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL; - - LLSettingsSky::ptr_t skyp = boost::make_shared(mSettings); - // the settings in the initial constructor are references to this' settings block. - // They will be replaced in the following lerp - skyp->lerpSettings(*other, mix); - - return skyp; -} +// LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const +// { +// LL_RECORD_BLOCK_TIME(FTM_BLEND_SKYVALUES); +// LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL; +// +// LLSettingsSky::ptr_t skyp = boost::make_shared(mSettings); +// // the settings in the initial constructor are references to this' settings block. +// // They will be replaced in the following lerp +// skyp->lerpSettings(*other, mix); +// +// return skyp; +// } LLSD LLSettingsSky::defaults() diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 977ab5141e..ade5a06553 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -56,7 +56,6 @@ public: static const std::string SETTING_MAX_Y; static const std::string SETTING_MOON_ROTATION; static const std::string SETTING_MOON_TEXTUREID; - static const std::string SETTING_NAME; static const std::string SETTING_STAR_BRIGHTNESS; static const std::string SETTING_SUNLIGHT_COLOR; static const std::string SETTING_SUN_ROTATION; @@ -77,7 +76,7 @@ public: virtual std::string getSettingType() const { return std::string("sky"); } // Settings status - ptr_t blend(const ptr_t &other, F32 mix) const; + virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); static LLSD defaults(); @@ -414,7 +413,6 @@ public: protected: LLSettingsSky(); - virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const; virtual stringset_t getSlerpKeys() const; diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index 52448bd4af..9a6dfc15fd 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -56,7 +56,6 @@ const std::string LLSettingsWater::SETTING_FOG_DENSITY("water_fog_density"); const std::string LLSettingsWater::SETTING_FOG_MOD("underwater_fog_mod"); const std::string LLSettingsWater::SETTING_FRESNEL_OFFSET("fresnel_offset"); const std::string LLSettingsWater::SETTING_FRESNEL_SCALE("fresnel_scale"); -const std::string LLSettingsWater::SETTING_NAME("name"); const std::string LLSettingsWater::SETTING_NORMAL_MAP("normal_map"); const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale"); const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above"); @@ -195,14 +194,12 @@ LLSettingsWater::ptr_t LLSettingsWater::buildClone() return skyp; } -LLSettingsBase::ptr_t LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const +void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) { LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); - - LLSettingsWater::ptr_t waterp = boost::make_shared(blenddata); - - return waterp; + + replaceSettings(blenddata); } diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h index 6a7e692c25..1550ba4004 100644 --- a/indra/newview/llsettingswater.h +++ b/indra/newview/llsettingswater.h @@ -39,7 +39,6 @@ public: static const std::string SETTING_FOG_MOD; static const std::string SETTING_FRESNEL_OFFSET; static const std::string SETTING_FRESNEL_SCALE; - static const std::string SETTING_NAME; static const std::string SETTING_NORMAL_MAP; static const std::string SETTING_NORMAL_SCALE; static const std::string SETTING_SCALE_ABOVE; @@ -63,7 +62,7 @@ public: virtual std::string getSettingType() const { return std::string("water"); } // Settings status - virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const; + virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); static LLSD defaults(); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index eb21f3c4b4..9e275fd108 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -135,10 +135,6 @@ bool LLWaterParamManager::loadPreset(const std::string& path) addParamSet(name, params_data); } - //*LAPRAS temp code testing conversion old preset to new settings. - LLSettingsWater::ptr_t test = LLSettingsWater::buildFromLegacyPreset(name, params_data); - LLEnvironment::instance().addWater(test); - return true; } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index a6dc2b343b..966a7840cf 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -319,11 +319,6 @@ bool LLWLParamManager::loadPreset(const std::string& path) addParamSet(key, params_data); } - //*LAPRAS temp code testing conversion old preset to new settings. - LLSettingsSky::ptr_t test = LLSettingsSky::buildFromLegacyPreset(name, params_data); - LLEnvironment::instance().addSky(test); - //test->exportSettings(name); - return true; } -- cgit v1.2.3 From fe846ec9942af5ad2ab6a4aad9e8561ba9bc1fba Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Nov 2017 16:02:20 -0800 Subject: Day cycles and animated sky/water blending. --- indra/newview/llenvironment.cpp | 214 +++++++++++++++++-------- indra/newview/llenvironment.h | 58 ++++--- indra/newview/llenvmanager.cpp | 2 +- indra/newview/llfloatereditsky.cpp | 11 +- indra/newview/llfloatereditwater.cpp | 7 +- indra/newview/llfloaterenvironmentsettings.cpp | 17 +- indra/newview/llsettingsbase.cpp | 25 +++ indra/newview/llsettingsbase.h | 71 ++++++++ indra/newview/llsettingsdaycycle.cpp | 205 ++++++++++++++++++----- indra/newview/llsettingsdaycycle.h | 69 ++++---- indra/newview/llsettingssky.cpp | 2 +- indra/newview/llsettingswater.cpp | 2 +- indra/newview/llviewermenu.cpp | 18 +-- indra/newview/llwlhandlers.cpp | 7 +- 14 files changed, 526 insertions(+), 182 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 9c654bbeb5..01ee6d6d54 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -43,6 +43,8 @@ #include "llsdserialize.h" #include "lldiriterator.h" + +#include //========================================================================= namespace { @@ -51,6 +53,11 @@ namespace } //========================================================================= +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 F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); @@ -73,20 +80,23 @@ void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); addSky(p_default_sky); - mSelectedSky = p_default_sky; + mCurrentSky = p_default_sky; LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); addWater(p_default_water); - mSelectedWater = p_default_water; + mCurrentWater = p_default_water; LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle(); addDayCycle(p_default_day); - mSelectedDayCycle.reset(); + mCurrentDayCycle.reset(); applyAllSelected(); // LEGACY! legacyLoadAllPresets(); + + LLEnvironmentRequest::initiate(); + gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); } LLEnvironment::~LLEnvironment() @@ -113,10 +123,16 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron return mDayCycleListChange.connect(cb); } + +void LLEnvironment::onRegionChange() +{ + LLEnvironmentRequest::initiate(); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mSelectedSky->getDomeOffset() * mSelectedSky->getDomeRadius()); + return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); } F32 LLEnvironment::getWaterHeight() const @@ -126,32 +142,34 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mSelectedSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE); + //F32Seconds now(LLDate::now().secondsSinceEpoch()); + static LLFrameTimer timer; + + F32Seconds delta(timer.getElapsedTimeAndResetF32()); + + if (mBlenderSky) + mBlenderSky->update(delta); + if (mBlenderWater) + mBlenderWater->update(delta); // update clouds, sun, and general updateCloudScroll(); - if (mSelectedDayCycle) - mSelectedDayCycle->update(); - if (mSelectedSky) - mSelectedSky->update(); - if (mSelectedWater) - mSelectedWater->update(); + if (mCurrentDayCycle) + mCurrentDayCycle->update(); -// // update only if running -// if (mAnimator.getIsRunning()) -// { -// mAnimator.update(mCurParams); -// } + if (mCurrentSky) + mCurrentSky->update(); + if (mCurrentWater) + mCurrentWater->update(); - //LLVector3 lightdir = mCurrentSky->getLightDirection(); - // update the shaders and the menu F32 camYaw = cam->getYaw(); @@ -179,11 +197,6 @@ void LLEnvironment::update(const LLViewerCamera * cam) } } -void advanceDay(F32 delta) -{ - -} - void LLEnvironment::updateCloudScroll() { // This is a function of the environment rather than the sky, since it should @@ -192,7 +205,7 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - LLVector2 cloud_delta = static_cast(delta_t)* (mSelectedSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; @@ -270,8 +283,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) if (gPipeline.canUseWindLightShaders()) { - updateGLVariablesForSettings(shader, mSelectedSky); - updateGLVariablesForSettings(shader, mSelectedWater); + updateGLVariablesForSettings(shader, mCurrentSky); + updateGLVariablesForSettings(shader, mCurrentWater); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -293,7 +306,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } //-------------------------------------------------------------------------- -void LLEnvironment::selectSky(const std::string &name) +void LLEnvironment::selectSky(const std::string &name, F32Seconds transition) { LLSettingsSky::ptr_t next_sky = findSkyByName(name); if (!next_sky) @@ -302,33 +315,57 @@ void LLEnvironment::selectSky(const std::string &name) return; } - selectSky(next_sky); + selectSky(next_sky, transition); } -void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky) +void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition) { if (!sky) { - mSelectedSky = mCurrentSky; + mCurrentSky = mSelectedSky; + mBlenderSky.reset(); return; } mSelectedSky = sky; - mSelectedSky->setDirtyFlag(true); + if (fabs(transition.value()) <= F_ALMOST_ZERO) + { + mBlenderSky.reset(); + mCurrentSky = sky; + mCurrentSky->setDirtyFlag(true); + mSelectedSky = sky; + } + else + { + LLSettingsSky::ptr_t skytarget = mCurrentSky->buildClone(); + + mBlenderSky = boost::make_shared( skytarget, mCurrentSky, sky, transition ); + mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::onSkyTransitionDone, this, _1)); + mCurrentSky = skytarget; + mSelectedSky = sky; + } +} + +void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender) +{ + mCurrentSky = mSelectedSky; + mBlenderSky.reset(); } void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky) { +#if 0 if (sky) { mCurrentSky = sky; } else { - mCurrentSky = mSelectedSky; + mCurrentSky = mCurrentSky; } +#endif } -void LLEnvironment::selectWater(const std::string &name) +void LLEnvironment::selectWater(const std::string &name, F32Seconds transition) { LLSettingsWater::ptr_t next_water = findWaterByName(name); @@ -338,33 +375,57 @@ void LLEnvironment::selectWater(const std::string &name) return; } - selectWater(next_water); + selectWater(next_water, transition); } -void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water) +void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition) { if (!water) { - mSelectedWater = mCurrentWater; + mCurrentWater = mSelectedWater; + mBlenderWater.reset(); return; } mSelectedWater = water; - mSelectedWater->setDirtyFlag(true); + if (fabs(transition.value()) <= F_ALMOST_ZERO) + { + mBlenderWater.reset(); + mCurrentWater = water; + mCurrentWater->setDirtyFlag(true); + mSelectedWater = water; + } + else + { + LLSettingsWater::ptr_t watertarget = mCurrentWater->buildClone(); + + mBlenderWater = boost::make_shared(watertarget, mCurrentWater, water, transition); + mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::onWaterTransitionDone, this, _1)); + mCurrentWater = watertarget; + mSelectedWater = water; + } +} + +void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) +{ + mCurrentWater = mSelectedWater; + mBlenderWater.reset(); } void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water) { +#if 0 if (water) { mCurrentWater = water; } else { - mCurrentWater = mSelectedWater; + mCurrentWater = mCurrentWater; } +#endif } -void LLEnvironment::selectDayCycle(const std::string &name) +void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition) { LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name); @@ -374,51 +435,56 @@ void LLEnvironment::selectDayCycle(const std::string &name) return; } - mSelectedDayCycle = next_daycycle; - mSelectedDayCycle->setDirtyFlag(true); + selectDayCycle(next_daycycle, transition); } -void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition) { if (!daycycle) { - mSelectedDayCycle = mCurrentDayCycle; return; } - mSelectedDayCycle = daycycle; - mSelectedDayCycle->setDirtyFlag(true); + mCurrentDayCycle = daycycle; + + daycycle->startDayCycle(); + selectWater(daycycle->getCurrentWater(), transition); + selectSky(daycycle->getCurrentSky(), transition); } void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) { +#if 0 if (daycycle) { mCurrentDayCycle = daycycle; } else { - mCurrentDayCycle = mSelectedDayCycle; + mCurrentDayCycle = mCurrentDayCycle; } +#endif } void LLEnvironment::clearAllSelected() { - if (mSelectedSky != mCurrentSky) +#if 0 + if (mCurrentSky != mCurrentSky) selectSky(); - if (mSelectedWater != mCurrentWater) + if (mCurrentWater != mCurrentWater) selectWater(); - if (mSelectedDayCycle != mCurrentDayCycle) + if (mCurrentDayCycle != mCurrentDayCycle) selectDayCycle(); +#endif } void LLEnvironment::applyAllSelected() { - if (mSelectedSky != mCurrentSky) + if (mCurrentSky != mCurrentSky) applySky(); - if (mSelectedWater != mCurrentWater) + if (mCurrentWater != mCurrentWater) applyWater(); - if (mSelectedDayCycle != mCurrentDayCycle) + if (mCurrentDayCycle != mCurrentDayCycle) applyDayCycle(); } @@ -428,7 +494,7 @@ LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const list.reserve(mSkysByName.size()); - for (NamedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it) + for (namedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it) { list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); } @@ -442,7 +508,7 @@ LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const list.reserve(mWaterByName.size()); - for (NamedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it) + for (namedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it) { list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); } @@ -456,7 +522,7 @@ LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const list.reserve(mDayCycleByName.size()); - for (NamedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it) + for (namedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it) { list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); } @@ -470,8 +536,8 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; - std::pair result; - result = mSkysByName.insert(NamedSettingMap_t::value_type(name, sky)); + std::pair result; + result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); if (!result.second) (*(result.first)).second = sky; @@ -491,7 +557,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) void LLEnvironment::removeSky(const std::string &name) { - NamedSettingMap_t::iterator it = mSkysByName.find(name); + namedSettingMap_t::iterator it = mSkysByName.find(name); if (it != mSkysByName.end()) mSkysByName.erase(it); mSkyListChange(); @@ -515,8 +581,8 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) LL_WARNS("RIDER") << "Adding water as '" << name << "'" << LL_ENDL; - std::pair result; - result = mWaterByName.insert(NamedSettingMap_t::value_type(name, water)); + std::pair result; + result = mWaterByName.insert(namedSettingMap_t::value_type(name, water)); if (!result.second) (*(result.first)).second = water; @@ -527,7 +593,7 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) void LLEnvironment::removeWater(const std::string &name) { - NamedSettingMap_t::iterator it = mWaterByName.find(name); + namedSettingMap_t::iterator it = mWaterByName.find(name); if (it != mWaterByName.end()) mWaterByName.erase(it); mWaterListChange(); @@ -547,8 +613,8 @@ void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; - std::pair result; - result = mDayCycleByName.insert(NamedSettingMap_t::value_type(name, daycycle)); + std::pair result; + result = mDayCycleByName.insert(namedSettingMap_t::value_type(name, daycycle)); if (!result.second) (*(result.first)).second = daycycle; @@ -559,7 +625,7 @@ void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) void LLEnvironment::removeDayCycle(const std::string &name) { - NamedSettingMap_t::iterator it = mDayCycleByName.find(name); + namedSettingMap_t::iterator it = mDayCycleByName.find(name); if (it != mDayCycleByName.end()) mDayCycleByName.erase(it); mDayCycleListChange(); @@ -575,7 +641,7 @@ void LLEnvironment::clearAllDayCycles() LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const { - NamedSettingMap_t::const_iterator it = mSkysByName.find(name); + namedSettingMap_t::const_iterator it = mSkysByName.find(name); if (it == mSkysByName.end()) { @@ -588,7 +654,7 @@ LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const { - NamedSettingMap_t::const_iterator it = mWaterByName.find(name); + namedSettingMap_t::const_iterator it = mWaterByName.find(name); if (it == mWaterByName.end()) { @@ -601,7 +667,7 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const LLSettingsDayCycle::ptr_t LLEnvironment::findDayCycleByName(std::string name) const { - NamedSettingMap_t::const_iterator it = mDayCycleByName.find(name); + namedSettingMap_t::const_iterator it = mDayCycleByName.find(name); if (it == mDayCycleByName.end()) { @@ -649,9 +715,21 @@ void LLEnvironment::UserPrefs::store() } } - //========================================================================= // Transitional Code. +void LLEnvironment::onLegacyRegionSettings(LLSD data) +{ + LLUUID regionId = data[0]["regionID"].asUUID(); + + LLSettingsDayCycle::ptr_t regionday; + if (data[1].isUndefined()) + regionday = LLEnvironment::findDayCycleByName("Default"); + else + regionday = LLSettingsDayCycle::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); + + selectDayCycle(regionday, TRANSITION_DEFAULT); +} + // static std::string LLEnvironment::getSysDir(const std::string &subdir) { diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index a3fc9eef66..7894d2ff6e 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -30,16 +30,15 @@ #include "llmemory.h" #include "llsd.h" +#include "llsettingsbase.h" #include "llsettingssky.h" #include "llsettingswater.h" #include "llsettingsdaycycle.h" +//------------------------------------------------------------------------- class LLViewerCamera; class LLGLSLShader; -//------------------------------------------------------------------------- - - //------------------------------------------------------------------------- class LLEnvironment : public LLSingleton { @@ -47,6 +46,13 @@ class LLEnvironment : public LLSingleton LOG_CLASS(LLEnvironment); public: + static const F32Seconds LLEnvironment::TRANSITION_INSTANT; + static const F32Seconds LLEnvironment::TRANSITION_FAST; + static const F32Seconds LLEnvironment::TRANSITION_DEFAULT; + static const F32Seconds LLEnvironment::TRANSITION_SLOW; + + typedef boost::signals2::connection connection_t; + class UserPrefs { friend class LLEnvironment; @@ -78,18 +84,18 @@ public: std::string mDayCycleName; }; - typedef std::pair name_id_t; - typedef std::vector list_name_id_t; - typedef boost::signals2::signal change_signal_t; - typedef boost::signals2::connection connection_t; + typedef std::map namedSettingMap_t; + typedef std::pair name_id_t; + typedef std::vector list_name_id_t; + typedef boost::signals2::signal change_signal_t; virtual ~LLEnvironment(); void loadPreferences(); const UserPrefs & getPreferences() const { return mUserPrefs; } - LLSettingsSky::ptr_t getCurrentSky() const { return mSelectedSky; } - LLSettingsWater::ptr_t getCurrentWater() const { return mSelectedWater; } + LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } + LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } void update(const LLViewerCamera * cam); @@ -100,14 +106,14 @@ public: void addWater(const LLSettingsWater::ptr_t &sky); void addDayCycle(const LLSettingsDayCycle::ptr_t &day); - void selectSky(const std::string &name); - void selectSky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); + void selectSky(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); + void selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition = TRANSITION_DEFAULT); void applySky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); - void selectWater(const std::string &name); - void selectWater(const LLSettingsWater::ptr_t &water = LLSettingsWater::ptr_t()); + void selectWater(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); + void selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition = TRANSITION_DEFAULT); void applyWater(const LLSettingsWater::ptr_t water = LLSettingsWater::ptr_t()); - void selectDayCycle(const std::string &name); - void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); + void selectDayCycle(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); + void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition = TRANSITION_DEFAULT); void applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); void clearAllSelected(); void applyAllSelected(); @@ -130,8 +136,8 @@ public: inline F32 getSceneLightStrength() const { return mSceneLightStrength; } inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } - inline LLVector4 getLightDirection() const { return LLVector4(mSelectedSky->getLightDirection(), 0.0f); } - inline LLVector4 getClampedLightDirection() const { return LLVector4(mSelectedSky->getClampedLightDirection(), 0.0f); } + inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } + inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } inline LLVector4 getRotatedLight() const { return mRotatedLight; } //------------------------------------------- @@ -139,6 +145,8 @@ public: connection_t setWaterListChange(const change_signal_t::slot_type& cb); connection_t setDayCycleListChange(const change_signal_t::slot_type& cb); + void onLegacyRegionSettings(LLSD data); + protected: virtual void initSingleton(); @@ -146,7 +154,6 @@ private: static const F32 SUN_DELTA_YAW; static const F32 NIGHTTIME_ELEVATION_COS; - typedef std::map NamedSettingMap_t; typedef std::map AssetSettingMap_t; LLVector2 mCloudScrollDelta; // cumulative cloud delta @@ -155,17 +162,20 @@ private: LLSettingsWater::ptr_t mSelectedWater; LLSettingsDayCycle::ptr_t mSelectedDayCycle; + LLSettingsBlender::ptr_t mBlenderSky; + LLSettingsBlender::ptr_t mBlenderWater; + LLSettingsSky::ptr_t mCurrentSky; LLSettingsWater::ptr_t mCurrentWater; LLSettingsDayCycle::ptr_t mCurrentDayCycle; - NamedSettingMap_t mSkysByName; + namedSettingMap_t mSkysByName; AssetSettingMap_t mSkysById; - NamedSettingMap_t mWaterByName; + namedSettingMap_t mWaterByName; AssetSettingMap_t mWaterById; - NamedSettingMap_t mDayCycleByName; + namedSettingMap_t mDayCycleByName; AssetSettingMap_t mDayCycleById; F32 mSceneLightStrength; @@ -177,6 +187,10 @@ private: change_signal_t mWaterListChange; change_signal_t mDayCycleListChange; + void onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender); + void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); + + //void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); //void removeSky(const LLUUID &id); @@ -195,6 +209,8 @@ private: void updateCloudScroll(); + void onRegionChange(); + //========================================================================= void legacyLoadAllPresets(); LLSD legacyLoadPreset(const std::string& path); diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index fa1c3b983e..82f4cb8ed9 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -486,7 +486,7 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) mLastReceivedID = content[0]["messageID"].asUUID(); // Refresh cached region settings. - LL_DEBUGS("Windlight") << "Received region environment settings: " << content << LL_ENDL; + LL_WARNS("Windlight") << "Received region environment settings: " << content << LL_ENDL; F32 sun_hour = 0; // *TODO LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); mCachedRegionPrefs = new_settings; diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 23744e5b07..715376cfa3 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -52,9 +52,12 @@ #include "llenvironment.h" #include "llenvadapters.h" -static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -static const F32 WL_BLUE_HORIZON_DENSITY_SCALE = 2.0f; -static const F32 WL_CLOUD_SLIDER_SCALE = 1.0f; +namespace +{ + const F32 WL_SUN_AMBIENT_SLIDER_SCALE(3.0f); + const F32 WL_BLUE_HORIZON_DENSITY_SCALE(2.0f); + const F32 WL_CLOUD_SLIDER_SCALE(1.0f); +} // static F32 sun_pos_to_time24(F32 sun_pos) // { @@ -647,7 +650,7 @@ void LLFloaterEditSky::onSkyPresetSelected() } psky = psky->buildClone(); - LLEnvironment::instance().selectSky(psky); + LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST); syncControls(); enableEditing(true); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 2868a0609a..447ec56ce1 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -52,6 +52,11 @@ #include "v3colorutil.h" #undef max // Fixes a Windows compiler error +namespace +{ + const F32 SWITCH_TRANSITION(1.0); +} + LLFloaterEditWater::LLFloaterEditWater(const LLSD &key): LLFloater(key), @@ -428,7 +433,7 @@ void LLFloaterEditWater::onWaterPresetSelected() } pwater = pwater->buildClone(); - LLEnvironment::instance().selectWater(pwater); + LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST); syncControls(); enableEditing(true); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index e25c5cedbf..eaef017f08 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llfloaterenvironmentsettings.cpp * @brief LLFloaterEnvironmentSettings class definition * * $LicenseInfo:firstyear=2011&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2011, 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$ */ @@ -35,6 +35,7 @@ #include "llenvironment.h" + LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key) : LLFloater(key) ,mRegionSettingsRadioGroup(NULL) @@ -197,13 +198,13 @@ void LLFloaterEnvironmentSettings::apply() { LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset); if (psky) - LLEnvironment::instance().selectSky(psky); + LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST); } else { LLSettingsDayCycle::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle); if (pday) - LLEnvironment::instance().selectDayCycle(pday); + LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_FAST); // LLEnvironment::instance().selectDayCycle(day_cycle); // env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); @@ -211,7 +212,7 @@ void LLFloaterEnvironmentSettings::apply() LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset); if (pwater) - LLEnvironment::instance().selectWater(pwater); + LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST); } } diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp index a2e705d1fa..c538cbe320 100644 --- a/indra/newview/llsettingsbase.cpp +++ b/indra/newview/llsettingsbase.cpp @@ -43,6 +43,8 @@ namespace 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()), @@ -218,6 +220,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F // 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; @@ -283,3 +286,25 @@ void LLSettingsBase::exportSettings(std::string name) const LL_WARNS("Presets") << "Cannot open for output preset file " << path_name << LL_ENDL; } } + + +//========================================================================= + +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 index 205351c401..533c9288fe 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "llsd.h" #include "llsdutil.h" @@ -192,4 +193,74 @@ private: }; +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 index 2d97ea865f..f098acde02 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -116,10 +116,10 @@ const std::string LLSettingsDayCycle::SETTING_KEYKFRAME("key_keyframe"); const std::string LLSettingsDayCycle::SETTING_NAME("name"); const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks"); -const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins +//const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins -//const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours -const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days +const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S64 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water @@ -145,11 +145,11 @@ LLSD LLSettingsDayCycle::defaults() LLSD dfltsetting; dfltsetting[SETTING_NAME] = "_default_"; - dfltsetting[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; + 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; } @@ -158,7 +158,7 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s LLSD newsettings(defaults()); newsettings[SETTING_NAME] = name; - newsettings[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; + newsettings[SETTING_DAYLENGTH] = static_cast(MINIMUM_DAYLENGTH); LLSD watertrack = LLSDArray( LLSDMap ( SETTING_KEYKFRAME, LLSD::Real(0.0f) ) @@ -176,15 +176,54 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); LLSettingsDayCycle::ptr_t dayp = boost::make_shared(newsettings); + dayp->parseFromLLSD(dayp->mSettings); return dayp; } +LLSettingsDayCycle::ptr_t LLSettingsDayCycle::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; + } + + LLSettingsDayCycle::ptr_t day = buildFromLegacyPreset("Region (legacy)", daycycle); + + day->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; + day->setSkyAtKeyframe(boost::static_pointer_cast((*it).second), frame, 1); + + LL_WARNS("WindlightCaps") << "Added '" << name << "' to region day cycle at " << frame << LL_ENDL; + } + + day->mHasParsed = true; + + return day; +} + LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildDefaultDayCycle() { LLSD settings = LLSettingsDayCycle::defaults(); LLSettingsDayCycle::ptr_t dayp = boost::make_shared(settings); + dayp->parseFromLLSD(dayp->mSettings); return dayp; } @@ -201,6 +240,7 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) 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)) @@ -238,25 +278,88 @@ void LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) } //========================================================================= -F32 LLSettingsDayCycle::secondsToKeyframe(S32 seconds) +F32 LLSettingsDayCycle::secondsToKeyframe(S64Seconds seconds) { - S32 daylength = getDayLength(); + S64Seconds daylength = getDayLength(); - return static_cast(seconds % daylength) / static_cast(daylength); + return llclamp(static_cast(seconds.value() % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); } -S32 LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) +F64Seconds LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) { - S32 daylength = getDayLength(); + S64Seconds daylength = getDayLength(); - return static_cast(keyframe * static_cast(daylength)); + return F64Seconds(static_cast(keyframe * static_cast(daylength.value()))); } //========================================================================= -void LLSettingsDayCycle::updateSettings() +void LLSettingsDayCycle::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(&LLSettingsDayCycle::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(&LLSettingsDayCycle::onSkyTransitionDone, this, 1, _1)); + } +} + + +void LLSettingsDayCycle::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()); @@ -311,14 +414,15 @@ void LLSettingsDayCycle::updateSettings() // Always mark the day cycle as dirty.So that the blend check can be handled. setDirtyFlag(true); +#endif } //========================================================================= -void LLSettingsDayCycle::setDayLength(S32 seconds) +void LLSettingsDayCycle::setDayLength(S64Seconds seconds) { - seconds = llclamp(seconds, MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); + S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); - setValue(SETTING_DAYLENGTH, seconds); + setValue(SETTING_DAYLENGTH, val); } LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 trackno) @@ -360,7 +464,7 @@ LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) return times; } -void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds) +void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) { F32 keyframe = secondsToKeyframe(seconds); setWaterAtKeyframe(water, keyframe); @@ -368,45 +472,68 @@ void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 s void LLSettingsDayCycle::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { - mDayTracks[TRACK_WATER][keyframe] = water; + mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; setDirtyFlag(true); } -void LLSettingsDayCycle::setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track) +void LLSettingsDayCycle::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) +{ + F32 keyframe = secondsToKeyframe(seconds); + setSkyAtKeyframe(sky, keyframe, track); +} + +void LLSettingsDayCycle::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; } - F32 keyframe = secondsToKeyframe(seconds); - mDayTracks[track][keyframe] = sky; + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = sky; setDirtyFlag(true); } -LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 keyframe) +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettingsDayCycle::CycleTrack_t &track, F32 keyframe) { return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } -// LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 keyframe) -// { -// TrackBound_t bounds = getBoundingEntries(track, keyframe); -// -// if (bounds.first == track.end()) -// return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. -// -// if (bounds.first == bounds.second) -// { // Single entry. Nothing to blend -// return (*bounds.first).second; -// } -// -// F32 blendf = get_wrapping_distance((*bounds.first).first, keyframe) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); -// -// LLSettingsBase::ptr_t base = (*bounds.first).second; -// return base->blend((*bounds.second).second, blendf); -// } +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettingsDayCycle::CycleTrack_t &track, F64Seconds time) +{ + F32 frame = secondsToKeyframe(time); + + return getBoundingEntries(track, frame); +} //========================================================================= +void LLSettingsDayCycle::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(&LLSettingsDayCycle::onSkyTransitionDone, this, track, _1)); +} + +void LLSettingsDayCycle::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(&LLSettingsDayCycle::onWaterTransitionDone, this, _1)); +} diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index f332b85dee..5132ebeea5 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -46,8 +46,8 @@ public: static const std::string SETTING_NAME; static const std::string SETTING_TRACKS; - static const S32 MINIMUM_DAYLENGTH; - static const S32 MAXIMUM_DAYLENGTH; + static const S64 MINIMUM_DAYLENGTH; + static const S64 MAXIMUM_DAYLENGTH; static const S32 TRACK_WATER; static const S32 TRACK_MAX; @@ -55,7 +55,7 @@ public: typedef std::map CycleTrack_t; typedef std::vector CycleList_t; typedef boost::shared_ptr ptr_t; - typedef std::vector TimeList_t; + typedef std::vector TimeList_t; typedef std::vector KeyframeList_t; typedef std::pair TrackBound_t; @@ -64,6 +64,7 @@ public: virtual ~LLSettingsDayCycle() { }; 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(); @@ -76,51 +77,65 @@ public: static LLSD defaults(); //--------------------------------------------------------------------- - S32 getDayLength() const + S64Seconds getDayLength() const { - return mSettings[SETTING_DAYLENGTH].asInteger(); + return S64Seconds(mSettings[SETTING_DAYLENGTH].asInteger()); } - void setDayLength(S32 seconds); + void setDayLength(S64Seconds seconds); - KeyframeList_t getTrackKeyframes(S32 track); - TimeList_t getTrackTimes(S32 track); + KeyframeList_t getTrackKeyframes(S32 track); + TimeList_t getTrackTimes(S32 track); - void setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds); - void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - LLSettingsSkyPtr_t getBlendedWaterAt(S32 seconds); + void setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds); + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - void setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track); - //--------------------------------------------------------------------- + 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: LLSettingsDayCycle(); - virtual void updateSettings(); + virtual void updateSettings(); - LLSettingsSkyPtr_t mBlendedSky; - LLSettingsWaterPtr_t mBlendedWater; +private: + LLSettingsBlender::ptr_t mSkyBlender; // convert to [] for altitudes + LLSettingsBlender::ptr_t mWaterBlender; - CycleList_t mDayTracks; + LLSettingsSkyPtr_t mBlendedSky; + LLSettingsWaterPtr_t mBlendedWater; - bool mHasParsed; + CycleList_t mDayTracks; - F32 secondsToKeyframe(S32 seconds); - S32 keyframeToSeconds(F32 keyframe); + bool mHasParsed; + F64Seconds mLastUpdateTime; - //LLSettingsBase::ptr_t getBlendedEntry(const CycleTrack_t &track, F32 keyframe); + F32 secondsToKeyframe(S64Seconds seconds); + F64Seconds keyframeToSeconds(F32 keyframe); - void parseFromLLSD(LLSD &data); -// CycleList_t & getTrackRef(S32 trackno); + void parseFromLLSD(LLSD &data); static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); - static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + 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); - F32Seconds mLastUpdateTime; -private: - }; #endif diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index c420ebca1e..024277a228 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -358,7 +358,7 @@ LLSD LLSettingsSky::defaults() void LLSettingsSky::updateSettings() { LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); - LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; + //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(); diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index 9a6dfc15fd..70688ee1ef 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -237,7 +237,7 @@ void LLSettingsWater::applySpecial(void *ptarget) void LLSettingsWater::updateSettings() { // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); - LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; +// 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(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 5bbf5650ad..8ce0eaf7dd 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -53,7 +53,7 @@ #include "llconsole.h" #include "lldaycyclemanager.h" #include "lldebugview.h" -#include "llenvmanager.h" +#include "llenvironment.h" #include "llfacebookconnect.h" #include "llfilepicker.h" #include "llfirstuse.h" @@ -8394,19 +8394,19 @@ class LLWorldEnvSettings : public view_listener_t if (tod == "sunrise") { - LLEnvManagerNew::instance().setUseSkyPreset("Sunrise"); + LLEnvironment::instance().selectSky("Sunrise"); } else if (tod == "noon") { - LLEnvManagerNew::instance().setUseSkyPreset("Midday"); + LLEnvironment::instance().selectSky("Midday"); } else if (tod == "sunset") { - LLEnvManagerNew::instance().setUseSkyPreset("Sunset"); + LLEnvironment::instance().selectSky("Sunset"); } else if (tod == "midnight") { - LLEnvManagerNew::instance().setUseSkyPreset("Midnight"); + LLEnvironment::instance().selectSky("Midnight"); } else { @@ -8440,19 +8440,19 @@ class LLWorldEnableEnvSettings : public view_listener_t { if (tod == "sunrise") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Sunrise"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Sunrise"); } else if (tod == "noon") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Midday"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Midday"); } else if (tod == "sunset") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Sunset"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Sunset"); } else if (tod == "midnight") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Midnight"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Midnight"); } else if (tod == "region") { diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index ea65a0c6d9..c3543f051d 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -34,6 +34,8 @@ #include "llnotificationsutil.h" #include "llcorehttputil.h" +#include "llenvironment.h" + /**** * LLEnvironmentRequest ****/ @@ -114,7 +116,8 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) if (!status) { LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " << LL_ENDL; - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(LLSD()); + LLEnvironment::instance().onLegacyRegionSettings(LLSD()); + return; } result = result["content"]; @@ -134,7 +137,7 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) return; } - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(result); + LLEnvironment::instance().onLegacyRegionSettings(result); } -- cgit v1.2.3 From a700c2a2e97eaa934b6ba570c6885243918cc1ab Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Nov 2017 16:28:02 -0800 Subject: Quick fix --- indra/newview/llenvironment.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 7894d2ff6e..13985bbc94 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -46,10 +46,10 @@ class LLEnvironment : public LLSingleton LOG_CLASS(LLEnvironment); public: - static const F32Seconds LLEnvironment::TRANSITION_INSTANT; - static const F32Seconds LLEnvironment::TRANSITION_FAST; - static const F32Seconds LLEnvironment::TRANSITION_DEFAULT; - static const F32Seconds LLEnvironment::TRANSITION_SLOW; + static const F32Seconds TRANSITION_INSTANT; + static const F32Seconds TRANSITION_FAST; + static const F32Seconds TRANSITION_DEFAULT; + static const F32Seconds TRANSITION_SLOW; typedef boost::signals2::connection connection_t; -- cgit v1.2.3 From 77091b8080ed48f0f4116dd04cfe6d3bf1c9fa29 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Thu, 9 Nov 2017 17:42:26 +0200 Subject: MAINT-47 [PUBLIC]WindLight: Special overlays (including property lines and hilights for beacons) aren't visible in shader water FIXED --- indra/newview/pipeline.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e8338f3e8c..55c0a092bf 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9988,7 +9988,19 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) } else { - renderGeom(camera); + renderGeom(camera); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + + LLWorld::getInstance()->renderPropertyLines(); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } } if (LLPipeline::sRenderDeferred && materials_in_water) -- cgit v1.2.3 From d709c7f35ebfd1945fd036b859f56b349d01dfe7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 9 Nov 2017 09:54:23 -0800 Subject: Remove unused constant. --- indra/newview/llfloatereditwater.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 447ec56ce1..52c896d6aa 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -52,11 +52,6 @@ #include "v3colorutil.h" #undef max // Fixes a Windows compiler error -namespace -{ - const F32 SWITCH_TRANSITION(1.0); -} - LLFloaterEditWater::LLFloaterEditWater(const LLSD &key): LLFloater(key), -- cgit v1.2.3 From b37eb2642f6e6e4d1e32a49c7ab31f70321cd979 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Nov 2017 16:17:25 -0800 Subject: Remove delete preset dialog, Initial settings for selection level (Region/Parcel/Local) --- indra/newview/CMakeLists.txt | 2 - indra/newview/llagent.cpp | 1 - indra/newview/llenvironment.cpp | 249 ++++++++++-------- indra/newview/llenvironment.h | 88 ++++++- indra/newview/llenvmanager.cpp | 3 +- indra/newview/llfloaterdeleteenvpreset.cpp | 285 --------------------- indra/newview/llfloaterdeleteenvpreset.h | 62 ----- indra/newview/llfloatereditdaycycle.cpp | 23 +- indra/newview/llfloatereditsky.cpp | 44 +--- indra/newview/llfloatereditwater.cpp | 29 +-- indra/newview/llfloaterenvironmentsettings.cpp | 88 +++++-- indra/newview/llfloaterregioninfo.cpp | 33 ++- indra/newview/llfloaterregioninfo.h | 3 +- indra/newview/lllocationinputctrl.cpp | 1 - .../llmenuoptionpathfindingrebakenavmesh.cpp | 1 - indra/newview/llpreviewscript.cpp | 1 - indra/newview/llsettingsbase.h | 2 +- indra/newview/llsettingsdaycycle.cpp | 94 +++---- indra/newview/llsettingsdaycycle.h | 10 +- indra/newview/llsky.cpp | 1 - indra/newview/llstartup.cpp | 1 - indra/newview/llviewerfloaterreg.cpp | 2 - indra/newview/llviewermenu.cpp | 95 +++---- indra/newview/llwlanimator.h | 3 +- indra/newview/llwldaycycle.h | 1 - indra/newview/llwlhandlers.cpp | 5 +- indra/newview/llwlparammanager.h | 1 + .../default/xui/de/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/de/menu_viewer.xml | 3 - .../default/xui/en/floater_delete_env_preset.xml | 59 ----- indra/newview/skins/default/xui/en/menu_viewer.xml | 30 --- .../default/xui/es/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/es/menu_viewer.xml | 3 - .../default/xui/fr/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/fr/menu_viewer.xml | 3 - .../default/xui/it/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/it/menu_viewer.xml | 3 - .../default/xui/ja/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/ja/menu_viewer.xml | 3 - .../default/xui/pl/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/pl/menu_viewer.xml | 3 - .../default/xui/pt/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/pt/menu_viewer.xml | 3 - .../default/xui/ru/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/ru/menu_viewer.xml | 3 - .../default/xui/tr/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/tr/menu_viewer.xml | 3 - .../default/xui/zh/floater_delete_env_preset.xml | 35 --- indra/newview/skins/default/xui/zh/menu_viewer.xml | 3 - 49 files changed, 457 insertions(+), 1140 deletions(-) delete mode 100644 indra/newview/llfloaterdeleteenvpreset.cpp delete mode 100644 indra/newview/llfloaterdeleteenvpreset.h delete mode 100644 indra/newview/skins/default/xui/de/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/en/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/es/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/fr/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/it/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/ja/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/pl/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/pt/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/ru/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/tr/floater_delete_env_preset.xml delete mode 100644 indra/newview/skins/default/xui/zh/floater_delete_env_preset.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 931856ca31..369ce6f24e 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -223,7 +223,6 @@ set(viewer_SOURCE_FILES llfloatercolorpicker.cpp llfloaterconversationlog.cpp llfloaterconversationpreview.cpp - llfloaterdeleteenvpreset.cpp llfloaterdeleteprefpreset.cpp llfloaterdestinations.cpp llfloatereditdaycycle.cpp @@ -850,7 +849,6 @@ set(viewer_HEADER_FILES llfloaterconversationlog.h llfloaterconversationpreview.h llfloaterdeleteprefpreset.h - llfloaterdeleteenvpreset.h llfloaterdestinations.h llfloatereditdaycycle.h llfloatereditsky.h diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 8dd0b06ed2..89b50fd966 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -42,7 +42,6 @@ #include "llchicletbar.h" #include "llconsole.h" #include "lldonotdisturbnotificationstorage.h" -#include "llenvmanager.h" #include "llfirstuse.h" #include "llfloatercamera.h" #include "llfloaterimcontainer.h" diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 01ee6d6d54..8b879710da 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -65,15 +65,19 @@ const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS) LLEnvironment::LLEnvironment(): mSelectedSky(), mSelectedWater(), - mSelectedDayCycle(), + mSelectedDay(), mSkysById(), mSkysByName(), mWaterByName(), mWaterById(), mDayCycleByName(), mDayCycleById(), - mUserPrefs() + mUserPrefs(), + mSelectedEnvironment(ENV_LOCAL) { + mSetSkys.resize(ENV_END); + mSetWater.resize(ENV_END); + mSetDays.resize(ENV_END); } void LLEnvironment::initSingleton() @@ -86,16 +90,14 @@ void LLEnvironment::initSingleton() addWater(p_default_water); mCurrentWater = p_default_water; - LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle(); + LLSettingsDay::ptr_t p_default_day = LLSettingsDay::buildDefaultDayCycle(); addDayCycle(p_default_day); - mCurrentDayCycle.reset(); - - applyAllSelected(); + mCurrentDay.reset(); // LEGACY! legacyLoadAllPresets(); - LLEnvironmentRequest::initiate(); + requestRegionEnvironment(); gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); } @@ -108,6 +110,17 @@ void LLEnvironment::loadPreferences() mUserPrefs.load(); } +void LLEnvironment::updatePreferences() +{ + /*NOOP for now. TODO record prefs and store.*/ +} + +bool LLEnvironment::canEdit() const +{ + return true; +} + + LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) { return mSkyListChange.connect(cb); @@ -125,10 +138,32 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron void LLEnvironment::onRegionChange() +{ + requestRegionEnvironment(); +} + +void LLEnvironment::requestRegionEnvironment() { LLEnvironmentRequest::initiate(); } +void LLEnvironment::onLegacyRegionSettings(LLSD data) +{ + LLUUID regionId = data[0]["regionID"].asUUID(); + + LLSettingsDay::ptr_t regionday; + if (data[1].isUndefined()) + regionday = LLEnvironment::findDayCycleByName("Default"); + else + regionday = LLSettingsDay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); + + setSkyFor(ENV_REGION, LLSettingsSky::ptr_t()); + setWaterFor(ENV_REGION, LLSettingsWater::ptr_t()); + setDayFor(ENV_REGION, regionday); + + applyChosenEnvironment(); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { @@ -162,8 +197,8 @@ void LLEnvironment::update(const LLViewerCamera * cam) // update clouds, sun, and general updateCloudScroll(); - if (mCurrentDayCycle) - mCurrentDayCycle->update(); + if (mCurrentDay) + mCurrentDay->update(); if (mCurrentSky) mCurrentSky->update(); @@ -351,20 +386,6 @@ void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender) mBlenderSky.reset(); } -void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky) -{ -#if 0 - if (sky) - { - mCurrentSky = sky; - } - else - { - mCurrentSky = mCurrentSky; - } -#endif -} - void LLEnvironment::selectWater(const std::string &name, F32Seconds transition) { LLSettingsWater::ptr_t next_water = findWaterByName(name); @@ -411,23 +432,9 @@ void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blende mBlenderWater.reset(); } -void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water) -{ -#if 0 - if (water) - { - mCurrentWater = water; - } - else - { - mCurrentWater = mCurrentWater; - } -#endif -} - void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition) { - LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name); + LLSettingsDay::ptr_t next_daycycle = findDayCycleByName(name); if (!next_daycycle) { @@ -438,56 +445,127 @@ void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transitio selectDayCycle(next_daycycle, transition); } -void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition) +void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition) { if (!daycycle) { return; } - mCurrentDayCycle = daycycle; + mCurrentDay = daycycle; daycycle->startDayCycle(); selectWater(daycycle->getCurrentWater(), transition); selectSky(daycycle->getCurrentSky(), transition); } -void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) + +void LLEnvironment::setSelectedEnvironment(EnvSelection_t env) +{ + if (env == mSelectedEnvironment) + { // No action to take + return; + } + + mSelectedEnvironment = env; + applyChosenEnvironment(); +} + +void LLEnvironment::applyChosenEnvironment() { -#if 0 - if (daycycle) + mSelectedSky.reset(); + mSelectedWater.reset(); + mSelectedDay.reset(); + + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) { - mCurrentDayCycle = daycycle; + if (mSetDays[idx] && !mSelectedSky && !mSelectedWater) + selectDayCycle(mSetDays[idx]); + if (mSetSkys[idx] && !mSelectedSky) + selectSky(mSetSkys[idx]); + if (mSetWater[idx] && !mSelectedWater) + selectWater(mSetWater[idx]); + if (mSelectedSky && mSelectedWater) + return; } - else + + if (!mSelectedSky) + selectSky("Default"); + if (!mSelectedWater) + selectWater("Default"); +} + +LLSettingsSky::ptr_t LLEnvironment::getChosenSky() const +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + { + if (mSetSkys[idx]) + return mSetSkys[idx]; + } + + return LLSettingsSky::ptr_t(); +} + +LLSettingsWater::ptr_t LLEnvironment::getChosenWater() const +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) { - mCurrentDayCycle = mCurrentDayCycle; + if (mSetWater[idx]) + return mSetWater[idx]; } -#endif + + return LLSettingsWater::ptr_t(); +} + +LLSettingsDay::ptr_t LLEnvironment::getChosenDay() const +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + { + if (mSetDays[idx]) + return mSetDays[idx]; + } + + return LLSettingsDay::ptr_t(); +} + +void LLEnvironment::setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky) +{ + mSetSkys[env] = sky; } -void LLEnvironment::clearAllSelected() +LLSettingsSky::ptr_t LLEnvironment::getSkyFor(EnvSelection_t env) const { -#if 0 - if (mCurrentSky != mCurrentSky) - selectSky(); - if (mCurrentWater != mCurrentWater) - selectWater(); - if (mCurrentDayCycle != mCurrentDayCycle) - selectDayCycle(); -#endif + return mSetSkys[env]; } -void LLEnvironment::applyAllSelected() +void LLEnvironment::setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water) { - if (mCurrentSky != mCurrentSky) - applySky(); - if (mCurrentWater != mCurrentWater) - applyWater(); - if (mCurrentDayCycle != mCurrentDayCycle) - applyDayCycle(); + mSetWater[env] = water; } +LLSettingsWater::ptr_t LLEnvironment::getWaterFor(EnvSelection_t env) const +{ + return mSetWater[env]; +} + +void LLEnvironment::setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day) +{ + mSetDays[env] = day; +} + +LLSettingsDay::ptr_t LLEnvironment::getDayFor(EnvSelection_t env) const +{ + return mSetDays[env]; +} + +void LLEnvironment::clearUserSettings() +{ + mSetSkys[ENV_LOCAL].reset(); + mSetWater[ENV_LOCAL].reset(); + mSetDays[ENV_LOCAL].reset(); +} + + LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const { list_name_id_t list; @@ -544,17 +622,6 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) mSkyListChange(); } -// void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) -// { -// // std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); -// // -// // std::pair result; -// // result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); -// // -// // if (!result.second) -// // (*(result.first)).second = sky; -// } - void LLEnvironment::removeSky(const std::string &name) { namedSettingMap_t::iterator it = mSkysByName.find(name); @@ -563,11 +630,6 @@ void LLEnvironment::removeSky(const std::string &name) mSkyListChange(); } -// void LLEnvironment::removeSky(const LLUUID &id) -// { -// -// } - void LLEnvironment::clearAllSkys() { mSkysByName.clear(); @@ -589,7 +651,6 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) mWaterListChange(); } -//void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void LLEnvironment::removeWater(const std::string &name) { @@ -599,7 +660,6 @@ void LLEnvironment::removeWater(const std::string &name) mWaterListChange(); } -//void LLEnvironment::removeWater(const LLUUID &id); void LLEnvironment::clearAllWater() { mWaterByName.clear(); @@ -607,9 +667,9 @@ void LLEnvironment::clearAllWater() mWaterListChange(); } -void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle) { - std::string name = daycycle->getValue(LLSettingsDayCycle::SETTING_NAME).asString(); + std::string name = daycycle->getValue(LLSettingsDay::SETTING_NAME).asString(); LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; @@ -665,17 +725,17 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const return boost::static_pointer_cast((*it).second); } -LLSettingsDayCycle::ptr_t LLEnvironment::findDayCycleByName(std::string name) const +LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const { namedSettingMap_t::const_iterator it = mDayCycleByName.find(name); if (it == mDayCycleByName.end()) { LL_WARNS("ENVIRONMENT") << "Unable to find daycycle with unknown name '" << name << "'" << LL_ENDL; - return LLSettingsDayCycle::ptr_t(); + return LLSettingsDay::ptr_t(); } - return boost::static_pointer_cast((*it).second); + return boost::static_pointer_cast((*it).second); } //========================================================================= @@ -717,19 +777,6 @@ void LLEnvironment::UserPrefs::store() //========================================================================= // Transitional Code. -void LLEnvironment::onLegacyRegionSettings(LLSD data) -{ - LLUUID regionId = data[0]["regionID"].asUUID(); - - LLSettingsDayCycle::ptr_t regionday; - if (data[1].isUndefined()) - regionday = LLEnvironment::findDayCycleByName("Default"); - else - regionday = LLSettingsDayCycle::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); - - selectDayCycle(regionday, TRANSITION_DEFAULT); -} - // static std::string LLEnvironment::getSysDir(const std::string &subdir) { @@ -855,7 +902,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } @@ -874,7 +921,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 13985bbc94..ce8c08f692 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -51,6 +51,14 @@ public: static const F32Seconds TRANSITION_DEFAULT; static const F32Seconds TRANSITION_SLOW; + enum EnvSelection_t + { + ENV_LOCAL, + ENV_PARCEL, + ENV_REGION, + ENV_END + }; + typedef boost::signals2::connection connection_t; class UserPrefs @@ -92,8 +100,11 @@ public: virtual ~LLEnvironment(); void loadPreferences(); + void updatePreferences(); const UserPrefs & getPreferences() const { return mUserPrefs; } + bool canEdit() const; + LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } @@ -104,19 +115,46 @@ public: void addSky(const LLSettingsSky::ptr_t &sky); void addWater(const LLSettingsWater::ptr_t &sky); - void addDayCycle(const LLSettingsDayCycle::ptr_t &day); + void addDayCycle(const LLSettingsDay::ptr_t &day); void selectSky(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); void selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition = TRANSITION_DEFAULT); - void applySky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); void selectWater(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); void selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition = TRANSITION_DEFAULT); - void applyWater(const LLSettingsWater::ptr_t water = LLSettingsWater::ptr_t()); void selectDayCycle(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); - void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition = TRANSITION_DEFAULT); - void applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); - void clearAllSelected(); - void applyAllSelected(); + void selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition = TRANSITION_DEFAULT); + + void setUserSky(const LLSettingsSky::ptr_t &sky) + { + setSkyFor(ENV_LOCAL, sky); + } + void setUserWater(const LLSettingsWater::ptr_t &water) + { + setWaterFor(ENV_LOCAL, water); + } + void setUserDaycycle(const LLSettingsDay::ptr_t &day) + { + setDayFor(ENV_LOCAL, day); + } + + void setSelectedEnvironment(EnvSelection_t env); + EnvSelection_t getSelectedEnvironment() const + { + return mSelectedEnvironment; + } + void applyChosenEnvironment(); + LLSettingsSky::ptr_t getChosenSky() const; + LLSettingsWater::ptr_t getChosenWater() const; + LLSettingsDay::ptr_t getChosenDay() const; + + void setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky); + LLSettingsSky::ptr_t getSkyFor(EnvSelection_t env) const; + void setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water); + LLSettingsWater::ptr_t getWaterFor(EnvSelection_t env) const; + void setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day); + LLSettingsDay::ptr_t getDayFor(EnvSelection_t env) const; + + void clearUserSettings(); list_name_id_t getSkyList() const; list_name_id_t getWaterList() const; @@ -124,7 +162,7 @@ public: LLSettingsSky::ptr_t findSkyByName(std::string name) const; LLSettingsWater::ptr_t findWaterByName(std::string name) const; - LLSettingsDayCycle::ptr_t findDayCycleByName(std::string name) const; + LLSettingsDay::ptr_t findDayCycleByName(std::string name) const; inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } @@ -145,6 +183,8 @@ public: connection_t setWaterListChange(const change_signal_t::slot_type& cb); connection_t setDayCycleListChange(const change_signal_t::slot_type& cb); + void requestRegionEnvironment(); + void onLegacyRegionSettings(LLSD data); protected: @@ -160,14 +200,38 @@ private: LLSettingsSky::ptr_t mSelectedSky; LLSettingsWater::ptr_t mSelectedWater; - LLSettingsDayCycle::ptr_t mSelectedDayCycle; + LLSettingsDay::ptr_t mSelectedDay; - LLSettingsBlender::ptr_t mBlenderSky; - LLSettingsBlender::ptr_t mBlenderWater; + LLSettingsBlender::ptr_t mBlenderSky; + LLSettingsBlender::ptr_t mBlenderWater; LLSettingsSky::ptr_t mCurrentSky; LLSettingsWater::ptr_t mCurrentWater; - LLSettingsDayCycle::ptr_t mCurrentDayCycle; + LLSettingsDay::ptr_t mCurrentDay; + + EnvSelection_t mSelectedEnvironment; + + typedef std::vector SkyList_t; + typedef std::vector WaterList_t; + typedef std::vector DayList_t; + + SkyList_t mSetSkys; + 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; diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 82f4cb8ed9..5fc9231506 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -26,8 +26,6 @@ #include "llviewerprecompiledheaders.h" -#include "llenvmanager.h" - #include "llagent.h" #include "lldaycyclemanager.h" #include "llviewercontrol.h" // for gSavedSettings @@ -36,6 +34,7 @@ #include "llwlhandlers.h" #include "llwlparammanager.h" #include "lltrans.h" +#include "llenvmanager.h" std::string LLWLParamKey::toString() const { diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp deleted file mode 100644 index bb11c813b4..0000000000 --- a/indra/newview/llfloaterdeleteenvpreset.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/** - * @file llfloaterdeleteenvpreset.cpp - * @brief Floater to delete a water / sky / day cycle preset. - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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 "llfloaterdeleteenvpreset.h" - -// libs -#include "llbutton.h" -#include "llcombobox.h" -#include "llnotificationsutil.h" - -// newview -#include "lldaycyclemanager.h" -#include "llwaterparammanager.h" - -static bool confirmation_callback(const LLSD& notification, const LLSD& response, boost::function cb) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option == 0) - { - cb(); - } - return false; - -} - -LLFloaterDeleteEnvPreset::LLFloaterDeleteEnvPreset(const LLSD &key) -: LLFloater(key) -, mPresetCombo(NULL) -{ -} - -// virtual -BOOL LLFloaterDeleteEnvPreset::postBuild() -{ - mPresetCombo = getChild("preset_combo"); - mPresetCombo->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::postPopulate, this)); - - getChild("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this)); - getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this)); - - // Listen to user preferences change, in which case we need to rebuild the presets list - // to disable the [new] current preset. - LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populatePresetsList, this)); - - // Listen to presets addition/removal. - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateDayCyclesList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateWaterPresetsList, this)); - - return TRUE; -} - -// virtual -void LLFloaterDeleteEnvPreset::onOpen(const LLSD& key) -{ - std::string param = key.asString(); - std::string floater_title = getString(std::string("title_") + param); - std::string combo_label = getString(std::string("label_" + param)); - - // Update floater title. - setTitle(floater_title); - - // Update the combobox label. - getChild("label")->setValue(combo_label); - - // Populate the combobox. - populatePresetsList(); -} - -void LLFloaterDeleteEnvPreset::onBtnDelete() -{ - std::string param = mKey.asString(); - std::string preset_name = mPresetCombo->getValue().asString(); - boost::function confirm_cb; - - if (param == "water") - { - // Don't allow deleting system presets. - if (LLWaterParamManager::instance().isSystemPreset(preset_name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - confirm_cb = boost::bind(&LLFloaterDeleteEnvPreset::onDeleteWaterPresetConfirmation, this); - } - else if (param == "sky") - { - // Don't allow deleting presets referenced by local day cycles. - if (LLDayCycleManager::instance().isSkyPresetReferenced(preset_name)) - { - LLNotificationsUtil::add("GenericAlert", LLSD().with("MESSAGE", getString("msg_sky_is_referenced"))); - return; - } - - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - // Don't allow deleting system presets. - if (wl_mgr.isSystemPreset(preset_name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - confirm_cb = boost::bind(&LLFloaterDeleteEnvPreset::onDeleteSkyPresetConfirmation, this); - } - else if (param == "day_cycle") - { - LLDayCycleManager& day_mgr = LLDayCycleManager::instance(); - - // Don't allow deleting system presets. - if (day_mgr.isSystemPreset(preset_name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - confirm_cb = boost::bind(&LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation, this); - } - else - { - LL_WARNS() << "Unrecognized key" << LL_ENDL; - } - - LLSD args; - args["MESSAGE"] = getString("msg_confirm_deletion"); - LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), - boost::bind(&confirmation_callback, _1, _2, confirm_cb)); -} - -void LLFloaterDeleteEnvPreset::onBtnCancel() -{ - closeFloater(); -} - -void LLFloaterDeleteEnvPreset::populatePresetsList() -{ - std::string param = mKey.asString(); - - if (param == "water") - { - populateWaterPresetsList(); - } - else if (param == "sky") - { - populateSkyPresetsList(); - } - else if (param == "day_cycle") - { - populateDayCyclesList(); - } - else - { - LL_WARNS() << "Unrecognized key" << LL_ENDL; - } -} - -void LLFloaterDeleteEnvPreset::populateWaterPresetsList() -{ - if (mKey.asString() != "water") return; - - mPresetCombo->removeall(); - - std::string cur_preset; - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (!env_mgr.getUseRegionSettings()) - { - cur_preset = env_mgr.getWaterPresetName(); - } - - LLWaterParamManager::preset_name_list_t presets; - LLWaterParamManager::instance().getUserPresetNames(presets); // list only user presets - for (LLWaterParamManager::preset_name_list_t::const_iterator it = presets.begin(); it != presets.end(); ++it) - { - std::string name = *it; - - bool enabled = (name != cur_preset); // don't allow deleting current preset - mPresetCombo->add(name, ADD_BOTTOM, enabled); - } - - postPopulate(); -} - -void LLFloaterDeleteEnvPreset::populateSkyPresetsList() -{ - if (mKey.asString() != "sky") return; - - mPresetCombo->removeall(); - - std::string cur_preset; - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (!env_mgr.getUseRegionSettings() && env_mgr.getUseFixedSky()) - { - cur_preset = env_mgr.getSkyPresetName(); - } - - LLWLParamManager::preset_name_list_t user_presets; - LLWLParamManager::instance().getUserPresetNames(user_presets); - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - const std::string& name = *it; - mPresetCombo->add(name, ADD_BOTTOM, /*enabled = */ name != cur_preset); - } - - postPopulate(); -} - -void LLFloaterDeleteEnvPreset::populateDayCyclesList() -{ - if (mKey.asString() != "day_cycle") return; - - mPresetCombo->removeall(); - - std::string cur_day; - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (!env_mgr.getUseRegionSettings() && env_mgr.getUseDayCycle()) - { - cur_day = env_mgr.getDayCycleName(); - } - - LLDayCycleManager& day_mgr = LLDayCycleManager::instance(); - LLDayCycleManager::preset_name_list_t user_days; - day_mgr.getUserPresetNames(user_days); // list only user presets - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - const std::string& name = *it; - mPresetCombo->add(name, ADD_BOTTOM, name != cur_day); - } - - postPopulate(); -} - -void LLFloaterDeleteEnvPreset::postPopulate() -{ - // Handle empty list and empty selection. - bool has_selection = mPresetCombo->getItemCount() > 0 && mPresetCombo->getSelectedValue().isDefined(); - - if (!has_selection) - { - mPresetCombo->setLabel(getString("combo_label")); - } - - getChild("delete")->setEnabled(has_selection); -} - -void LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation() -{ - LLDayCycleManager::instance().deletePreset(mPresetCombo->getValue().asString()); -} - -void LLFloaterDeleteEnvPreset::onDeleteSkyPresetConfirmation() -{ - LLWLParamKey key(mPresetCombo->getValue().asString(), LLEnvKey::SCOPE_LOCAL); - LLWLParamManager::instance().removeParamSet(key, true); -} - -void LLFloaterDeleteEnvPreset::onDeleteWaterPresetConfirmation() -{ - LLWaterParamManager::instance().removeParamSet(mPresetCombo->getValue().asString(), true); -} diff --git a/indra/newview/llfloaterdeleteenvpreset.h b/indra/newview/llfloaterdeleteenvpreset.h deleted file mode 100644 index 1211505273..0000000000 --- a/indra/newview/llfloaterdeleteenvpreset.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file llfloaterdeleteenvpreset.h - * @brief Floater to delete a water / sky / day cycle preset. - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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_LLFLOATERDELETEENVPRESET_H -#define LL_LLFLOATERDELETEENVPRESET_H - -#include "llfloater.h" - -class LLComboBox; - -class LLFloaterDeleteEnvPreset : public LLFloater -{ - LOG_CLASS(LLFloaterDeleteEnvPreset); - -public: - LLFloaterDeleteEnvPreset(const LLSD &key); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - - void onBtnDelete(); - void onBtnCancel(); - -private: - void populatePresetsList(); - void populateWaterPresetsList(); - void populateSkyPresetsList(); - void populateDayCyclesList(); - - void postPopulate(); - - void onDeleteDayCycleConfirmation(); - void onDeleteSkyPresetConfirmation(); - void onDeleteWaterPresetConfirmation(); - - LLComboBox* mPresetCombo; -}; - -#endif // LL_LLFLOATERDELETEENVPRESET_H diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index 97d87ee13e..31b0b0c090 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -42,11 +42,12 @@ // newview #include "llagent.h" #include "lldaycyclemanager.h" -#include "llenvmanager.h" #include "llregioninfomodel.h" #include "llviewerregion.h" #include "llwlparammanager.h" +#include "llenvironment.h" + const F32 LLFloaterEditDayCycle::sHoursPerDay = 24.0f; LLFloaterEditDayCycle::LLFloaterEditDayCycle(const LLSD &key) @@ -114,7 +115,7 @@ void LLFloaterEditDayCycle::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current day cycle + LLEnvironment::instance().applyChosenEnvironment(); } } @@ -142,11 +143,13 @@ void LLFloaterEditDayCycle::initCallbacks(void) mSaveButton->setRightMouseDownCallback(boost::bind(&LLFloaterEditDayCycle::dumpTrack, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onBtnCancel, this)); +#if 0 // Connect to env manager events. LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); env_mgr.setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsChange, this)); gAgent.addRegionChangedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionChange, this)); env_mgr.setRegionSettingsAppliedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsApplied, this, _1)); +#endif // Connect to day cycle manager events. LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleListChange, this)); @@ -420,6 +423,7 @@ void LLFloaterEditDayCycle::onAddKey() break; } +#if 0 if ((S32)mSliderToKey.size() >= max_sliders) { LLSD args; @@ -428,6 +432,7 @@ void LLFloaterEditDayCycle::onAddKey() LLNotificationsUtil::add("DayCycleTooManyKeyframes", args, LLSD(), LLNotificationFunctorRegistry::instance().DONOTHING); return; } +#endif // add the slider key std::string key_val = mSkyPresetsCombo->getSelectedValue().asString(); @@ -547,6 +552,7 @@ void LLFloaterEditDayCycle::reset() void LLFloaterEditDayCycle::saveRegionDayCycle() { +#if 0 LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; // the day cycle being edited @@ -570,6 +576,7 @@ void LLFloaterEditDayCycle::saveRegionDayCycle() setApplyProgress(true); #endif +#endif } void LLFloaterEditDayCycle::setApplyProgress(bool started) @@ -628,6 +635,7 @@ void LLFloaterEditDayCycle::onDeleteKey() void LLFloaterEditDayCycle::onRegionSettingsChange() { +#if 0 LL_DEBUGS("Windlight") << "Region settings changed" << LL_ENDL; if (getApplyProgress()) // our region settings have being applied @@ -643,6 +651,7 @@ void LLFloaterEditDayCycle::onRegionSettingsChange() closeFloater(); } +#endif } void LLFloaterEditDayCycle::onRegionChange() @@ -669,6 +678,7 @@ void LLFloaterEditDayCycle::onRegionSettingsApplied(bool success) void LLFloaterEditDayCycle::onRegionInfoUpdate() { +#if 0 LL_DEBUGS("Windlight") << "Region info updated" << LL_ENDL; bool can_edit = true; @@ -680,6 +690,7 @@ void LLFloaterEditDayCycle::onRegionInfoUpdate() } enableEditing(can_edit); +#endif } void LLFloaterEditDayCycle::onDayCycleNameEdited() @@ -691,6 +702,7 @@ void LLFloaterEditDayCycle::onDayCycleNameEdited() void LLFloaterEditDayCycle::onDayCycleSelected() { +#if 0 LLSD day_data; LLWLParamKey dc_key = getSelectedDayCycle(); @@ -723,8 +735,8 @@ void LLFloaterEditDayCycle::onDayCycleSelected() F32 slider_time = mTimeSlider->getCurSliderValue() / sHoursPerDay; LLWLParamManager::instance().applyDayCycleParams(day_data, dc_key.scope, slider_time); loadTrack(); - - enableEditing(can_edit); +#endif + enableEditing(false); } void LLFloaterEditDayCycle::onBtnSave() @@ -786,6 +798,7 @@ bool LLFloaterEditDayCycle::onSaveAnswer(const LLSD& notification, const LLSD& r void LLFloaterEditDayCycle::onSaveConfirmed() { +#if 0 std::string name = getSelectedDayCycle().name; // Save preset. @@ -799,7 +812,7 @@ void LLFloaterEditDayCycle::onSaveConfirmed() LL_DEBUGS("Windlight") << name << " is now the new preferred day cycle" << LL_ENDL; LLEnvManagerNew::instance().setUseDayCycle(name); } - +#endif closeFloater(); } diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 715376cfa3..a779241cf4 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -59,10 +59,6 @@ namespace const F32 WL_CLOUD_SLIDER_SCALE(1.0f); } -// static F32 sun_pos_to_time24(F32 sun_pos) -// { -// return fmodf(sun_pos * 24.0f + 6, 24.0f); -// } static F32 time24_to_sun_pos(F32 time24) { @@ -129,7 +125,7 @@ void LLFloaterEditSky::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvironment::instance().clearAllSelected(); + LLEnvironment::instance().applyChosenEnvironment(); } } @@ -672,40 +668,28 @@ bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& respon void LLFloaterEditSky::onSaveConfirmed() { -#if 0 - // Save current params to the selected preset. - LLWLParamKey key(getSelectedSkyPreset()); + // Save currently displayed water params to the selected preset. + std::string name = mEditSettings->getName(); - LL_DEBUGS("Windlight") << "Saving sky preset " << key.name << LL_ENDL; - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - if (wl_mgr.hasParamSet(key)) - { - wl_mgr.setParamSet(key, wl_mgr.mCurParams); - } - else - { - wl_mgr.addParamSet(key, wl_mgr.mCurParams); - } + LL_DEBUGS("Windlight") << "Saving sky preset " << name << LL_ENDL; - wl_mgr.savePreset(key); + LLEnvironment::instance().addSky(mEditSettings); - // Change preference if requested. - if (mMakeDefaultCheckBox->getValue()) - { - LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << LL_ENDL; - LLEnvManagerNew::instance().setUseSkyPreset(key.name); - } + // Change preference if requested. + if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue()) + { + LL_DEBUGS("Windlight") << name << " is now the new preferred sky preset" << LL_ENDL; + LLEnvironment::instance().setUserSky(mEditSettings); + } - closeFloater(); -#endif + closeFloater(); } void LLFloaterEditSky::onBtnSave() { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLEnvironment::instance().addSky(psky); + LLEnvironment::instance().addSky(mEditSettings); + LLEnvironment::instance().setUserSky(mEditSettings); - LLEnvironment::instance().applySky(); closeFloater(); } diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 52c896d6aa..6b218d5008 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -111,7 +111,7 @@ void LLFloaterEditWater::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvironment::instance().clearAllSelected(); + LLEnvironment::instance().applyChosenEnvironment(); } } @@ -436,7 +436,6 @@ void LLFloaterEditWater::onWaterPresetSelected() bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response) { -#if 0 S32 option = LLNotificationsUtil::getSelectedOption(notification, response); // If they choose save, do it. Otherwise, don't do anything @@ -444,46 +443,34 @@ bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& resp { onSaveConfirmed(); } -#endif - return false; + + return false; } void LLFloaterEditWater::onSaveConfirmed() { -#if 0 // Save currently displayed water params to the selected preset. - std::string name = getCurrentPresetName(); + std::string name = mEditSettings->getName(); LL_DEBUGS("Windlight") << "Saving sky preset " << name << LL_ENDL; - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - if (water_mgr.hasParamSet(name)) - { - water_mgr.setParamSet(name, water_mgr.mCurParams); - } - else - { - water_mgr.addParamSet(name, water_mgr.mCurParams); - } - water_mgr.savePreset(name); + LLEnvironment::instance().addWater(mEditSettings); // Change preference if requested. if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue()) { LL_DEBUGS("Windlight") << name << " is now the new preferred water preset" << LL_ENDL; - LLEnvManagerNew::instance().setUseWaterPreset(name); + LLEnvironment::instance().setUserWater(mEditSettings); } closeFloater(); -#endif } void LLFloaterEditWater::onBtnSave() { - LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); - LLEnvironment::instance().addWater(pwater); + LLEnvironment::instance().addWater(mEditSettings); + LLEnvironment::instance().setUserWater(mEditSettings); - LLEnvironment::instance().applyWater(); closeFloater(); } diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index eaef017f08..6908363839 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -65,16 +65,13 @@ BOOL LLFloaterEnvironmentSettings::postBuild() mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectDayCyclePreset, this)); childSetCommitCallback("ok_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnOK, this), NULL); - getChild("ok_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); childSetCommitCallback("cancel_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnCancel, this), NULL); - getChild("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); LLEnvironment::instance().setDayCycleListChange(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); -// LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); return TRUE; } @@ -89,7 +86,7 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) void LLFloaterEnvironmentSettings::onClose(bool app_quitting) { if (!app_quitting) - LLEnvironment::instance().clearAllSelected(); + LLEnvironment::instance().applyChosenEnvironment(); } @@ -127,6 +124,41 @@ void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() void LLFloaterEnvironmentSettings::onBtnOK() { + bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + + if (use_region_settings) + { + LLEnvironment::instance().clearUserSettings(); + } + else + { + LLEnvironment::instance().clearUserSettings(); + + bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + + if (!use_fixed_sky) + { + std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); + LLSettingsDay::ptr_t day = LLEnvironment::instance().findDayCycleByName(day_cycle); + if (day) + { + LLEnvironment::instance().setDayFor(LLEnvironment::ENV_LOCAL, day); + } + } + else + { + std::string water_preset = mWaterPresetCombo->getValue().asString(); + std::string sky_preset = mSkyPresetCombo->getValue().asString(); + + LLSettingsSky::ptr_t sky = LLEnvironment::instance().findSkyByName(sky_preset); + LLSettingsWater::ptr_t water = LLEnvironment::instance().findWaterByName(water_preset); + + LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, sky); + LLEnvironment::instance().setWaterFor(LLEnvironment::ENV_LOCAL, water); + } + } + +#if 0 // Save and apply new user preferences. bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; @@ -142,8 +174,8 @@ void LLFloaterEnvironmentSettings::onBtnOK() use_region_settings); // *TODO: This triggers applying user preferences again, which is suboptimal. - LLEnvironment::instance().applyAllSelected(); - closeFloater(); +#endif + closeFloater(); } void LLFloaterEnvironmentSettings::onBtnCancel() @@ -153,10 +185,13 @@ void LLFloaterEnvironmentSettings::onBtnCancel() void LLFloaterEnvironmentSettings::refresh() { - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + LLSettingsDay::ptr_t day = LLEnvironment::instance().getChosenDay(); + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getChosenSky(); + LLSettingsWater::ptr_t water = LLEnvironment::instance().getChosenWater(); - bool use_region_settings = env_mgr.getUseRegionSettings(); - bool use_fixed_sky = env_mgr.getUseFixedSky(); + + bool use_region_settings = true; + bool use_fixed_sky = !day; // Set up radio buttons according to user preferences. mRegionSettingsRadioGroup->setSelectedIndex(use_region_settings ? 0 : 1); @@ -173,9 +208,18 @@ void LLFloaterEnvironmentSettings::refresh() mDayCyclePresetCombo->setEnabled(!use_fixed_sky); // Select the current presets in combo boxes. - mWaterPresetCombo->selectByValue(env_mgr.getWaterPresetName()); - mSkyPresetCombo->selectByValue(env_mgr.getSkyPresetName()); - mDayCyclePresetCombo->selectByValue(env_mgr.getDayCycleName()); + if (water) + mWaterPresetCombo->selectByValue(water->getName()); + else + mWaterPresetCombo->selectByValue(LLSD()); + if (sky) + mSkyPresetCombo->selectByValue(sky->getName()); + else + mSkyPresetCombo->selectByValue(LLSD()); + if (day) + mDayCyclePresetCombo->selectByValue(day->getName()); + else + mDayCyclePresetCombo->selectByValue(LLSD()); } void LLFloaterEnvironmentSettings::apply() @@ -183,14 +227,13 @@ void LLFloaterEnvironmentSettings::apply() // Update environment with the user choice. bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - std::string water_preset = mWaterPresetCombo->getValue()[0].asString(); - std::string sky_preset = mSkyPresetCombo->getValue()[0].asString(); - std::string day_cycle = mDayCyclePresetCombo->getValue()[0].asString(); + std::string water_preset = mWaterPresetCombo->getValue().asString(); + std::string sky_preset = mSkyPresetCombo->getValue().asString(); + std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); if (use_region_settings) { - env_mgr.useRegionSettings(); + //env_mgr.useRegionSettings(); } else { @@ -202,12 +245,9 @@ void LLFloaterEnvironmentSettings::apply() } else { - LLSettingsDayCycle::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle); + LLSettingsDay::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle); if (pday) LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_FAST); - -// LLEnvironment::instance().selectDayCycle(day_cycle); -// env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); } LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset); @@ -230,7 +270,7 @@ void LLFloaterEnvironmentSettings::populateWaterPresetsList() for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) { - mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + mWaterPresetCombo->add((*it).first, LLSD::String((*it).first)); // } } @@ -242,7 +282,7 @@ void LLFloaterEnvironmentSettings::populateSkyPresetsList() for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) { - mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + mSkyPresetCombo->add((*it).first, LLSD::String((*it).first)); } } @@ -254,6 +294,6 @@ void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) { - mDayCyclePresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + mDayCyclePresetCombo->add((*it).first, LLSD::String((*it).first)); } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index af68a2aae1..4f0603fe59 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -53,7 +53,6 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldaycyclemanager.h" -#include "llenvmanager.h" #include "llestateinfomodel.h" #include "llfilepicker.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() @@ -99,6 +98,8 @@ #include "llpanelexperiences.h" #include "llcorehttputil.h" +#include "llenvmanager.h" + const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -3115,7 +3116,7 @@ BOOL LLPanelEnvironmentInfo::postBuild() mDayCyclePresetCombo = getChild("dayc_settings_preset_combo"); mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); + 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())); @@ -3191,9 +3192,9 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) mRegionSettingsRadioGroup->setEnabled(enabled); mDayCycleSettingsRadioGroup->setEnabled(enabled); - mWaterPresetCombo->setEnabled(enabled); - mSkyPresetCombo->setEnabled(enabled); - mDayCyclePresetCombo->setEnabled(enabled); + mWaterPresetCombo->setEnabled(false); + mSkyPresetCombo->setEnabled(false); + mDayCyclePresetCombo->setEnabled(false); getChildView("apply_btn")->setEnabled(enabled); getChildView("cancel_btn")->setEnabled(enabled); @@ -3234,6 +3235,7 @@ void LLPanelEnvironmentInfo::setDirty(bool dirty) void LLPanelEnvironmentInfo::sendRegionSunUpdate() { +#if 0 LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); // If the region is being switched to fixed sky, @@ -3258,6 +3260,7 @@ void LLPanelEnvironmentInfo::sendRegionSunUpdate() LL_DEBUGS("Windlight Sync") << "Sun hour: " << region_info.mSunHour << LL_ENDL; region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); +#endif } void LLPanelEnvironmentInfo::fixEstateSun() @@ -3276,6 +3279,7 @@ void LLPanelEnvironmentInfo::fixEstateSun() void LLPanelEnvironmentInfo::populateWaterPresetsList() { +#if 0 mWaterPresetCombo->removeall(); // If the region already has water params, add them to the list. @@ -3308,10 +3312,12 @@ void LLPanelEnvironmentInfo::populateWaterPresetsList() } // 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; @@ -3356,10 +3362,12 @@ void LLPanelEnvironmentInfo::populateSkyPresetsList() 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. @@ -3394,10 +3402,12 @@ void LLPanelEnvironmentInfo::populateDayCyclesList() } // 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) @@ -3417,10 +3427,13 @@ bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) } 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); @@ -3435,10 +3448,13 @@ bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& 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; @@ -3468,6 +3484,8 @@ bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sk scope = dc.scope; return true; +#endif + return false; } void LLPanelEnvironmentInfo::onSwitchRegionSettings() { @@ -3615,6 +3633,7 @@ void LLPanelEnvironmentInfo::onBtnApply() } } +#if 0 // Send settings apply request. LLEnvironmentSettings new_region_settings; new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f); @@ -3627,6 +3646,7 @@ void LLPanelEnvironmentInfo::onBtnApply() // 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); @@ -3637,6 +3657,8 @@ 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(); @@ -3644,6 +3666,7 @@ void LLPanelEnvironmentInfo::onBtnCancel() 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() diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index c9d0e51640..105280bd99 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -35,7 +35,6 @@ #include "llpanel.h" #include "llextendedstatus.h" -#include "llenvmanager.h" // for LLEnvironmentSettings #include "lleventcoro.h" class LLAvatarName; @@ -463,7 +462,7 @@ private: void onRegionSettingsApplied(bool ok); /// New environment settings that are being applied to the region. - LLEnvironmentSettings mNewRegionSettings; +// LLEnvironmentSettings mNewRegionSettings; bool mEnableEditing; diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 11bc1425f9..c01a2fbf8a 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -44,7 +44,6 @@ // newview includes #include "llagent.h" -#include "llenvmanager.h" #include "llfloatersidepanelcontainer.h" #include "llinventoryobserver.h" #include "lllandmarkactions.h" diff --git a/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp b/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp index 63d97f6ac2..0663dd41ee 100644 --- a/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp +++ b/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp @@ -34,7 +34,6 @@ #include #include "llagent.h" -#include "llenvmanager.h" #include "llnotificationsutil.h" #include "llpathfindingmanager.h" #include "llpathfindingnavmesh.h" diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 6ecc4c7fb9..3795e043ba 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -33,7 +33,6 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldir.h" -#include "llenvmanager.h" #include "llexternaleditor.h" #include "llfilepicker.h" #include "llfloaterreg.h" diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index 533c9288fe..bf4053a4b1 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -44,7 +44,7 @@ class LLSettingsBase: private boost::noncopyable { friend class LLEnvironment; - friend class LLSettingsDayCycle; + friend class LLSettingsDay; public: static const std::string SETTING_ID; diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp index f098acde02..da384304d6 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -69,12 +69,12 @@ namespace return 0; } - LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDayCycle::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) { if (collection.empty()) return collection.end(); - LLSettingsDayCycle::CycleTrack_t::iterator it = collection.upper_bound(key); + LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); if (it == collection.end()) { // wrap around @@ -84,12 +84,12 @@ namespace return it; } - LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDayCycle::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) { if (collection.empty()) return collection.end(); - LLSettingsDayCycle::CycleTrack_t::iterator it = collection.lower_bound(key); + LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); if (it == collection.end()) { // all keyframes are lower, take the last one. @@ -109,30 +109,30 @@ namespace } //========================================================================= -const std::string LLSettingsDayCycle::SETTING_DAYLENGTH("day_length"); -const std::string LLSettingsDayCycle::SETTING_KEYID("key_id"); -const std::string LLSettingsDayCycle::SETTING_KEYNAME("key_name"); -const std::string LLSettingsDayCycle::SETTING_KEYKFRAME("key_keyframe"); -const std::string LLSettingsDayCycle::SETTING_NAME("name"); -const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks"); +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_NAME("name"); +const std::string LLSettingsDay::SETTING_TRACKS("tracks"); //const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins -const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours -const S64 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days +const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days -const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0 -const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water +const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 +const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water //========================================================================= -LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) : +LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), mHasParsed(false) { mDayTracks.resize(TRACK_MAX); } -LLSettingsDayCycle::LLSettingsDayCycle() : +LLSettingsDay::LLSettingsDay() : LLSettingsBase(), mHasParsed(false) { @@ -140,7 +140,7 @@ LLSettingsDayCycle::LLSettingsDayCycle() : } //========================================================================= -LLSD LLSettingsDayCycle::defaults() +LLSD LLSettingsDay::defaults() { LLSD dfltsetting; @@ -153,7 +153,7 @@ LLSD LLSettingsDayCycle::defaults() return dfltsetting; } -LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +LLSettingsDay::ptr_t LLSettingsDay::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) { LLSD newsettings(defaults()); @@ -175,13 +175,13 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); - LLSettingsDayCycle::ptr_t dayp = boost::make_shared(newsettings); + LLSettingsDay::ptr_t dayp = boost::make_shared(newsettings); dayp->parseFromLLSD(dayp->mSettings); return dayp; } -LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) +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; @@ -195,7 +195,7 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyMessage(const LLUUI LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; } - LLSettingsDayCycle::ptr_t day = buildFromLegacyPreset("Region (legacy)", daycycle); + LLSettingsDay::ptr_t day = buildFromLegacyPreset("Region (legacy)", daycycle); day->setWaterAtKeyframe(water, 0.0f); @@ -218,17 +218,17 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyMessage(const LLUUI return day; } -LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildDefaultDayCycle() +LLSettingsDay::ptr_t LLSettingsDay::buildDefaultDayCycle() { - LLSD settings = LLSettingsDayCycle::defaults(); + LLSD settings = LLSettingsDay::defaults(); - LLSettingsDayCycle::ptr_t dayp = boost::make_shared(settings); + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); dayp->parseFromLLSD(dayp->mSettings); return dayp; } -void LLSettingsDayCycle::parseFromLLSD(LLSD &data) +void LLSettingsDay::parseFromLLSD(LLSD &data) { LLEnvironment &environment(LLEnvironment::instance()); LLSD tracks = data[SETTING_TRACKS]; @@ -263,29 +263,29 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) } -LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() +LLSettingsDay::ptr_t LLSettingsDay::buildClone() { LLSD settings = cloneSettings(); - LLSettingsDayCycle::ptr_t dayp = boost::make_shared(settings); + LLSettingsDay::ptr_t dayp = boost::make_shared(settings); return dayp; } -void LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) +void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F32 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; } //========================================================================= -F32 LLSettingsDayCycle::secondsToKeyframe(S64Seconds seconds) +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 LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) +F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe) { S64Seconds daylength = getDayLength(); @@ -293,7 +293,7 @@ F64Seconds LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) } //========================================================================= -void LLSettingsDayCycle::startDayCycle() +void LLSettingsDay::startDayCycle() { F64Seconds now(LLDate::now().secondsSinceEpoch()); @@ -320,7 +320,7 @@ void LLSettingsDayCycle::startDayCycle() mBlendedWater = LLSettingsWater::buildDefaultWater(); mWaterBlender = boost::make_shared(mBlendedWater, (*bounds.first).second, (*bounds.second).second, timespan); - mWaterBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onWaterTransitionDone, this, _1)); + mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); } // sky @@ -342,12 +342,12 @@ void LLSettingsDayCycle::startDayCycle() mBlendedSky = LLSettingsSky::buildDefaultSky(); mSkyBlender = boost::make_shared(mBlendedSky, (*bounds.first).second, (*bounds.second).second, timespan); - mSkyBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onSkyTransitionDone, this, 1, _1)); + mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, 1, _1)); } } -void LLSettingsDayCycle::updateSettings() +void LLSettingsDay::updateSettings() { static LLFrameTimer timer; @@ -418,14 +418,14 @@ void LLSettingsDayCycle::updateSettings() } //========================================================================= -void LLSettingsDayCycle::setDayLength(S64Seconds seconds) +void LLSettingsDay::setDayLength(S64Seconds seconds) { S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); setValue(SETTING_DAYLENGTH, val); } -LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 trackno) +LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) { if ((trackno < 1) || (trackno >= TRACK_MAX)) { @@ -446,7 +446,7 @@ LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 tra return keyframes; } -LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) +LLSettingsDay::TimeList_t LLSettingsDay::getTrackTimes(S32 trackno) { KeyframeList_t keyframes = getTrackKeyframes(trackno); @@ -464,26 +464,26 @@ LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) return times; } -void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) +void LLSettingsDay::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) { F32 keyframe = secondsToKeyframe(seconds); setWaterAtKeyframe(water, keyframe); } -void LLSettingsDayCycle::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) +void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; setDirtyFlag(true); } -void LLSettingsDayCycle::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) +void LLSettingsDay::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) { F32 keyframe = secondsToKeyframe(seconds); setSkyAtKeyframe(sky, keyframe, track); } -void LLSettingsDayCycle::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { @@ -495,12 +495,12 @@ void LLSettingsDayCycle::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 key setDirtyFlag(true); } -LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettingsDayCycle::CycleTrack_t &track, F32 keyframe) +LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) { return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } -LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettingsDayCycle::CycleTrack_t &track, F64Seconds time) +LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F64Seconds time) { F32 frame = secondsToKeyframe(time); @@ -508,7 +508,7 @@ LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettin } //========================================================================= -void LLSettingsDayCycle::onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender) +void LLSettingsDay::onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender) { F64Seconds now(LLDate::now().secondsSinceEpoch()); TrackBound_t bounds = getBoundingEntries(mDayTracks[track], now); @@ -522,10 +522,10 @@ void LLSettingsDayCycle::onSkyTransitionDone(S32 track, const LLSettingsBlender: mSkyBlender = boost::make_shared(mBlendedSky, (*bounds.first).second, (*bounds.second).second, timespan); - mSkyBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onSkyTransitionDone, this, track, _1)); + mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, track, _1)); } -void LLSettingsDayCycle::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) +void LLSettingsDay::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) { F64Seconds now(LLDate::now().secondsSinceEpoch()); TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); @@ -535,5 +535,5 @@ void LLSettingsDayCycle::onWaterTransitionDone(const LLSettingsBlender::ptr_t &b mWaterBlender = boost::make_shared(mBlendedWater, (*bounds.first).second, (*bounds.second).second, timespan); - mWaterBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onWaterTransitionDone, this, _1)); + mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); } diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index 5132ebeea5..ba3d592bd6 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -36,7 +36,7 @@ class LLSettingsSky; typedef boost::shared_ptr LLSettingsWaterPtr_t; typedef boost::shared_ptr LLSettingsSkyPtr_t; -class LLSettingsDayCycle : public LLSettingsBase +class LLSettingsDay : public LLSettingsBase { public: static const std::string SETTING_DAYLENGTH; @@ -54,14 +54,14 @@ public: typedef std::map CycleTrack_t; typedef std::vector CycleList_t; - typedef boost::shared_ptr ptr_t; + typedef boost::shared_ptr ptr_t; typedef std::vector TimeList_t; typedef std::vector KeyframeList_t; typedef std::pair TrackBound_t; //--------------------------------------------------------------------- - LLSettingsDayCycle(const LLSD &data); - virtual ~LLSettingsDayCycle() { }; + 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); @@ -106,7 +106,7 @@ public: } protected: - LLSettingsDayCycle(); + LLSettingsDay(); virtual void updateSettings(); diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp index 3ef89ba920..a961f0e3b4 100644 --- a/indra/newview/llsky.cpp +++ b/indra/newview/llsky.cpp @@ -51,7 +51,6 @@ #include "llvosky.h" #include "llcubemap.h" #include "llviewercontrol.h" -#include "llenvmanager.h" #include "llvowlsky.h" diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index bdb8d83e59..92b294678b 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -197,7 +197,6 @@ #include "llcleanup.h" #include "llenvironment.h" -#include "llenvmanager.h" #include "llstacktrace.h" diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 0ebacddd9b..c0fed2fff5 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -55,7 +55,6 @@ #include "llfloaterchatvoicevolume.h" #include "llfloaterconversationlog.h" #include "llfloaterconversationpreview.h" -#include "llfloaterdeleteenvpreset.h" #include "llfloaterdeleteprefpreset.h" #include "llfloaterdestinations.h" #include "llfloatereditdaycycle.h" @@ -222,7 +221,6 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 8ce0eaf7dd..57eef7e776 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8394,32 +8394,30 @@ class LLWorldEnvSettings : public view_listener_t if (tod == "sunrise") { - LLEnvironment::instance().selectSky("Sunrise"); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunrise"); + LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky); } else if (tod == "noon") { - LLEnvironment::instance().selectSky("Midday"); - } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midday"); + LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky); + } else if (tod == "sunset") { - LLEnvironment::instance().selectSky("Sunset"); - } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunset"); + LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky); + } else if (tod == "midnight") { - LLEnvironment::instance().selectSky("Midnight"); - } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midnight"); + LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky); + } else { - LLEnvManagerNew &envmgr = LLEnvManagerNew::instance(); - // reset all environmental settings to track the region defaults, make this reset 'sticky' like the other sun settings. - bool use_fixed_sky = false; - bool use_region_settings = true; - envmgr.setUserPrefs(envmgr.getWaterPresetName(), - envmgr.getSkyPresetName(), - envmgr.getDayCycleName(), - use_fixed_sky, use_region_settings); + LLEnvironment::instance().clearUserSettings(); } - + + LLEnvironment::instance().applyChosenEnvironment(); return true; } }; @@ -8431,37 +8429,38 @@ class LLWorldEnableEnvSettings : public view_listener_t bool result = false; std::string tod = userdata.asString(); - if (LLEnvManagerNew::instance().getUseRegionSettings()) + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getSkyFor(LLEnvironment::ENV_LOCAL); + + if (!sky) { return (tod == "region"); } - if (LLEnvManagerNew::instance().getUseFixedSky()) + std::string skyname = (sky) ? sky->getName() : ""; + + if (tod == "sunrise") { - if (tod == "sunrise") - { - result = (LLEnvironment::instance().getCurrentSky()->getName() == "Sunrise"); - } - else if (tod == "noon") - { - result = (LLEnvironment::instance().getCurrentSky()->getName() == "Midday"); - } - else if (tod == "sunset") - { - result = (LLEnvironment::instance().getCurrentSky()->getName() == "Sunset"); - } - else if (tod == "midnight") - { - result = (LLEnvironment::instance().getCurrentSky()->getName() == "Midnight"); - } - else if (tod == "region") - { - return false; - } - else - { - LL_WARNS() << "Unknown time-of-day item: " << tod << LL_ENDL; - } + result = (skyname == "Sunrise"); + } + else if (tod == "noon") + { + result = (skyname == "Midday"); + } + else if (tod == "sunset") + { + result = (skyname == "Sunset"); + } + else if (tod == "midnight") + { + result = (skyname == "Midnight"); + } + else if (tod == "region") + { + return false; + } + else + { + LL_WARNS() << "Unknown time-of-day item: " << tod << LL_ENDL; } return result; } @@ -8481,10 +8480,6 @@ class LLWorldEnvPreset : public view_listener_t { LLFloaterReg::showInstance("env_edit_water", "edit"); } - else if (item == "delete_water") - { - LLFloaterReg::showInstance("env_delete_preset", "water"); - } else if (item == "new_sky") { LLFloaterReg::showInstance("env_edit_sky", "new"); @@ -8493,10 +8488,6 @@ class LLWorldEnvPreset : public view_listener_t { LLFloaterReg::showInstance("env_edit_sky", "edit"); } - else if (item == "delete_sky") - { - LLFloaterReg::showInstance("env_delete_preset", "sky"); - } else if (item == "new_day_cycle") { LLFloaterReg::showInstance("env_edit_day_cycle", "new"); @@ -8505,10 +8496,6 @@ class LLWorldEnvPreset : public view_listener_t { LLFloaterReg::showInstance("env_edit_day_cycle", "edit"); } - else if (item == "delete_day_cycle") - { - LLFloaterReg::showInstance("env_delete_preset", "day_cycle"); - } else { LL_WARNS() << "Unknown item selected" << LL_ENDL; diff --git a/indra/newview/llwlanimator.h b/indra/newview/llwlanimator.h index e2e49c7305..cbb12eb9b7 100644 --- a/indra/newview/llwlanimator.h +++ b/indra/newview/llwlanimator.h @@ -28,8 +28,9 @@ #define LL_WL_ANIMATOR_H #include "llwlparamset.h" -#include "llenvmanager.h" #include "llwaterparamset.h" +#include "llenvmanager.h" + #include #include diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index c8585564ed..aef999f3ec 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -35,7 +35,6 @@ class LLWLDayCycle; #include "llwlparamset.h" #include "llwlanimator.h" struct LLWLParamKey; -#include "llenvmanager.h" // for LLEnvKey::EScope class LLWLDayCycle { diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index c3543f051d..0e4017a1c0 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -30,7 +30,6 @@ #include "llagent.h" #include "llviewerregion.h" -#include "llenvmanager.h" #include "llnotificationsutil.h" #include "llcorehttputil.h" @@ -245,13 +244,13 @@ 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); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); } while (false); if (!notify.isUndefined()) { LLNotificationsUtil::add("WLRegionApplyFail", notify); - LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); } } diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index f7f4baee12..d475a26da6 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -34,6 +34,7 @@ #include "llwldaycycle.h" #include "llviewercamera.h" #include "lltrans.h" +#include "llenvmanager.h" class LLGLSLShader; diff --git a/indra/newview/skins/default/xui/de/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/de/floater_delete_env_preset.xml deleted file mode 100644 index cc14ce640d..0000000000 --- a/indra/newview/skins/default/xui/de/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - Wasser-Voreinstellung löschen - - - Himmel-Voreinstellung löschen - - - Tageszyklus löschen - - - Voreinstellung: - - - Voreinstellung: - - - Tageszyklus: - - - Möchten Sie die ausgewählte Voreinstellung wirklich löschen? - - - Eine Voreinstellung, auf die sich ein Tageszyklus bezieht, kann nicht gelöscht werden. - - - -Voreinstellung auswählen- - - - Voreinstellung: - - + + + + + + + + + + + + - 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.2.3 From fbaa01d9a0c63386f13f0e43437c69f700950fd6 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 May 2018 09:30:39 -0700 Subject: Removed mSavedEnvironment so the Mac build will be happy. --- indra/newview/llfloatereditextdaycycle.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 3a1f29382a..6ef3563e8f 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -129,8 +129,6 @@ private: // data for restoring previous displayed environment - S32 mSavedEnvironment; - LLSettingsDay::ptr_t mEditDay; // edited copy LLSettingsDay::ptr_t mOriginalDay; // the one we are editing S64Seconds mDayLength; -- cgit v1.2.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(-) 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.2.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(-) 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.2.3 From 2ddad24c4d5e64711cdbffd98e290d3da8e9714a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 30 May 2018 17:08:28 -0700 Subject: Timeline behavior in day cycle edit. --- indra/llui/llmultislider.cpp | 30 +- indra/llui/llmultislider.h | 1 + indra/llui/llmultisliderctrl.h | 4 +- indra/newview/llenvironment.h | 6 +- indra/newview/llfloatereditextdaycycle.cpp | 358 +++++++++++---------- indra/newview/llfloatereditextdaycycle.h | 22 +- indra/newview/llsettingsvo.cpp | 2 +- .../default/xui/en/floater_edit_ext_day_cycle.xml | 2 +- .../skins/default/xui/en/menu_save_settings.xml | 2 +- 9 files changed, 240 insertions(+), 187 deletions(-) diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 93045a6578..5cfe79267f 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -210,6 +210,19 @@ void LLMultiSlider::setCurSlider(const std::string& name) } } +F32 LLMultiSlider::getSliderValueFromX(S32 xpos) const +{ + S32 left_edge = mThumbWidth / 2; + S32 right_edge = getRect().getWidth() - (mThumbWidth / 2); + + xpos += mMouseOffset; + xpos = llclamp(xpos, left_edge, right_edge); + + F32 t = F32(xpos - left_edge) / (right_edge - left_edge); + + return((t * (mMaxValue - mMinValue)) + mMinValue); +} + void LLMultiSlider::resetCurSlider() { mCurSlider = LLStringUtil::null; @@ -359,14 +372,15 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask) { if( gFocusMgr.getMouseCapture() == this ) { - S32 left_edge = mThumbWidth/2; - S32 right_edge = getRect().getWidth() - (mThumbWidth/2); - - x += mMouseOffset; - x = llclamp( x, left_edge, right_edge ); - - F32 t = F32(x - left_edge) / (right_edge - left_edge); - setCurSliderValue(t * (mMaxValue - mMinValue) + mMinValue ); +// S32 left_edge = mThumbWidth/2; +// S32 right_edge = getRect().getWidth() - (mThumbWidth/2); +// +// x += mMouseOffset; +// x = llclamp( x, left_edge, right_edge ); +// +// F32 t = F32(x - left_edge) / (right_edge - left_edge); +// setCurSliderValue(t * (mMaxValue - mMinValue) + mMinValue ); + setCurSliderValue(getSliderValueFromX(x)); onCommit(); getWindow()->setCursor(UI_CURSOR_ARROW); diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index 927063a5fd..0177597da2 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -72,6 +72,7 @@ public: virtual ~LLMultiSlider(); void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE); F32 getSliderValue(const std::string& name) const; + F32 getSliderValueFromX(S32 xpos) const; const std::string& getCurSlider() const { return mCurSlider; } F32 getCurSliderValue() const { return getSliderValue(mCurSlider); } diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index 84378ff7b2..5c4777ebd0 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -74,7 +74,7 @@ protected: public: virtual ~LLMultiSliderCtrl(); - F32 getSliderValue(const std::string& name) const; + F32 getSliderValue(const std::string& name) const { return mMultiSlider->getSliderValue(name); } void setSliderValue(const std::string& name, F32 v, BOOL from_event = FALSE); virtual void setValue(const LLSD& value ); @@ -99,6 +99,8 @@ public: void setMaxValue(F32 max_value) {mMultiSlider->setMaxValue(max_value);} void setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);} + F32 getSliderValueFromX(S32 x) const { return mMultiSlider->getSliderValueFromX(x); } + /// for adding and deleting sliders const std::string& addSlider(); const std::string& addSlider(F32 val); diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 398c97ebe9..32ce99ccc9 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -129,6 +129,8 @@ public: typedef boost::signals2::signal change_signal_t; typedef std::function environment_apply_fn; + typedef std::array altitude_list_t; + virtual ~LLEnvironment(); void loadPreferences(); @@ -217,6 +219,8 @@ public: S32 calculateSkyTrackForAltitude(F64 altitude); + const altitude_list_t & getRegionAltitudes() const { return mTrackAltitudes; } + protected: virtual void initSingleton(); @@ -338,7 +342,7 @@ private: change_signal_t mDayCycleListChange; S32 mCurrentTrack; - std::array mTrackAltitudes; + altitude_list_t mTrackAltitudes; DayInstance::ptr_t getEnvironmentInstance(EnvSelection_t env, bool create = false); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index f4de71426e..706dd99fc9 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -58,36 +58,37 @@ #include "llenvironment.h" #include "lltrans.h" -static const std::string track_tabs[] = { - "water_track", - "sky1_track", - "sky2_track", - "sky3_track", - "sky4_track", -}; - -// 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 -const std::string ACTION_SAVE("save_settings"); -const std::string ACTION_SAVEAS("save_as_new_settings"); -const std::string ACTION_APPLY_LOCAL("apply_local"); -const std::string ACTION_APPLY_PARCEL("apply_parcel"); -const std::string ACTION_APPLY_REGION("apply_region"); - -const F32 DAY_CYCLE_PLAY_TIME_SECONDS = 60; - - //========================================================================= -// **RIDER** +namespace { + const std::string track_tabs[] = { + "water_track", + "sky1_track", + "sky2_track", + "sky3_track", + "sky4_track", + }; + + // 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 + const std::string ACTION_SAVE("save_settings"); + const std::string ACTION_SAVEAS("save_as_new_settings"); + const std::string ACTION_APPLY_LOCAL("apply_local"); + const std::string ACTION_APPLY_PARCEL("apply_parcel"); + const std::string ACTION_APPLY_REGION("apply_region"); + + const F32 DAY_CYCLE_PLAY_TIME_SECONDS = 60; + + const F32 FRAME_SLOP_FACTOR = 0.025f; +} +//========================================================================= const std::string LLFloaterEditExtDayCycle::KEY_INVENTORY_ID("inventory_id"); const std::string LLFloaterEditExtDayCycle::KEY_LIVE_ENVIRONMENT("live_environment"); const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length"); -// **RIDER** - -LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): +//========================================================================= +LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) : LLFloater(key), mFlyoutControl(NULL), mCancelButton(NULL), @@ -96,15 +97,14 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): mTimeSlider(NULL), mFramesSlider(NULL), mCurrentTimeLabel(NULL), - // **RIDER** mImportButton(nullptr), mInventoryId(), mInventoryItem(nullptr), mSkyBlender(), mWaterBlender(), mScratchSky(), - mScratchWater() - // **RIDER** + mScratchWater(), + mIsPlaying(false) { mCommitCallbackRegistrar.add("DayCycle.Track", [this](LLUICtrl *ctrl, const LLSD &data) { onTrackSelectionCallback(data); }); @@ -139,17 +139,20 @@ BOOL LLFloaterEditExtDayCycle::postBuild() mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE); mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); - mCancelButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, this)); - mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onTimeSliderMoved, this)); - mFramesSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onFrameSliderCallback, this)); - mAddFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this)); - mDeleteFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onRemoveTrack, this)); + mCancelButton->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(); }); - mTimeSlider->addSlider(0); + mFramesSlider->setCommitCallback([this](LLUICtrl *, const LLSD &data) { onFrameSliderCallback(data); }); + mFramesSlider->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderDoubleClick(x, y, mask); }); + mFramesSlider->setMouseDownCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderMouseDown(x, y, mask); }); + mFramesSlider->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderMouseUp(x, y, mask); }); + mTimeSlider->addSlider(0); - getChild("sky4_track", true)->setToggleState(true); + //getChild("sky1_track", true)->setToggleState(true); return TRUE; } @@ -159,8 +162,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); LLEnvironment::instance().updateEnvironment(); - // **RIDER** - mEditingEnv = LLEnvironment::ENV_NONE; mEditDay.reset(); if (key.has(KEY_INVENTORY_ID)) @@ -184,10 +185,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) mDayLength.value(key[KEY_DAY_LENGTH].asReal()); } - // **RIDER** - - selectTrack(mCurrentTrack); - // time labels mCurrentTimeLabel->setTextArg("[PRCNT]", std::string("0")); const S32 max_elm = 5; @@ -221,6 +218,16 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) } mCurrentTimeLabel->setTextArg("[DSC]", std::string()); } + + const LLEnvironment::altitude_list_t &altitudes = LLEnvironment::instance().getRegionAltitudes(); + + for (S32 idx = 1; idx < 4; ++idx) + { + std::stringstream label; + label << altitudes[idx] << "m"; + getChild(track_tabs[idx + 1], true)->setTextArg("[DSC]", label.str()); + } + } void LLFloaterEditExtDayCycle::onClose(bool app_quitting) @@ -313,49 +320,14 @@ void LLFloaterEditExtDayCycle::onAddTrack() if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { - // **RIDER** // scratch water should always have the current water settings. setting = mScratchWater->buildClone(); -// if (mSliderKeyMap.empty()) -// { -// // No existing points, use defaults -// setting = LLSettingsVOWater::buildDefaultWater(); -// } -// else -// { -// // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels -// LLView* tab_container = mWaterTabLayoutContainer->getChild("water_tabs"); //can't extract panels directly, since it is in 'tuple' -// LLPanelSettingsWaterMainTab* panel = dynamic_cast(tab_container->getChildView("water_panel")); -// if (panel) -// { -// setting = panel->getWater()->buildClone(); -// } -// } - // **RIDER** mEditDay->setWaterAtKeyframe(std::dynamic_pointer_cast(setting), frame); } else { - // **RIDER** // scratch sky should always have the current sky settings. setting = mScratchSky->buildClone(); -// if (mSliderKeyMap.empty()) -// { -// // No existing points, use defaults -// setting = LLSettingsVOSky::buildDefaultSky(); -// } -// else -// { -// // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels -// LLView* tab_container = mSkyTabLayoutContainer->getChild("sky_tabs"); //can't extract panels directly, since they are in 'tuple' -// -// LLPanelSettingsSky* panel = dynamic_cast(tab_container->getChildView("atmosphere_panel")); -// if (panel) -// { -// setting = panel->getSky()->buildClone(); -// } -// } - // **RIDER** mEditDay->setSkyAtKeyframe(std::dynamic_pointer_cast(setting), frame, mCurrentTrack); } @@ -413,77 +385,132 @@ void LLFloaterEditExtDayCycle::onPlayActionCallback(const LLSD& user_data) } } -void LLFloaterEditExtDayCycle::onFrameSliderCallback() +void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) { - if (mSliderKeyMap.size() == 0) + //LL_WARNS("LAPRAS") << "LLFloaterEditExtDayCycle::onFrameSliderCallback(" << data << ")" << LL_ENDL; + + std::string curslider = mFramesSlider->getCurSlider(); + + LL_WARNS("LAPRAS") << "Current slider set to \"" << curslider << "\"" << LL_ENDL; + F32 sliderpos(0.0); + + if (curslider.empty()) { - mLastFrameSlider.clear(); - return; + S32 x(0), y(0); + LLUI::getMousePositionLocal(mFramesSlider, &x, &y); + + sliderpos = mFramesSlider->getSliderValueFromX(x); } - // make sure we have a slider - const std::string& cur_sldr = mFramesSlider->getCurSlider(); - if (cur_sldr.empty()) + else { - mLastFrameSlider.clear(); - return; + sliderpos = mFramesSlider->getCurSliderValue(); } - 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) + 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) +{ + onAddTrack(); +} + +void LLFloaterEditExtDayCycle::onFrameSliderMouseDown(S32 x, S32 y, MASK mask) +{ + stopPlay(); + F32 sliderpos = mFramesSlider->getSliderValueFromX(x); + + std::string slidername = mFramesSlider->getCurSlider(); + + if (!slidername.empty()) { - 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 + F32 sliderval = mFramesSlider->getSliderValue(slidername); + + LL_WARNS("LAPRAS") << "Selected vs mouse delta = " << (sliderval - sliderpos) << LL_ENDL; + + if (fabs(sliderval - sliderpos) > FRAME_SLOP_FACTOR) { - 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; - } + mFramesSlider->resetCurSlider(); } } + LL_WARNS("LAPRAS") << "DOWN: X=" << x << " Y=" << y << " MASK=" << mask << " Position=" << sliderpos << LL_ENDL; +} - mTimeSlider->setCurSliderValue(new_frame); +void LLFloaterEditExtDayCycle::onFrameSliderMouseUp(S32 x, S32 y, MASK mask) +{ + F32 sliderpos = mFramesSlider->getSliderValueFromX(x); - 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(); - } + LL_WARNS("LAPRAS") << " UP: X=" << x << " Y=" << y << " MASK=" << mask << " Position=" << sliderpos << LL_ENDL; + mTimeSlider->setCurSliderValue(sliderpos); + selectFrame(sliderpos); } void LLFloaterEditExtDayCycle::onTimeSliderMoved() @@ -491,23 +518,21 @@ void LLFloaterEditExtDayCycle::onTimeSliderMoved() selectFrame(mTimeSlider->getCurSliderValue()); } -void LLFloaterEditExtDayCycle::selectTrack(U32 track_index) +void LLFloaterEditExtDayCycle::selectTrack(U32 track_index, bool force ) { mCurrentTrack = track_index; LLButton* button = getChild(track_tabs[track_index], true); - if (button->getToggleState()) + if (button->getToggleState() && !force) { return; } for (int i = 0; i < LLSettingsDay::TRACK_MAX; i++) // use max value { - getChild(track_tabs[i], true)->setToggleState(false); + getChild(track_tabs[i], true)->setToggleState(i == track_index); } - button->setToggleState(true); - - bool show_water = mCurrentTrack == LLSettingsDay::TRACK_WATER; + bool show_water = (mCurrentTrack == LLSettingsDay::TRACK_WATER); mSkyTabLayoutContainer->setVisible(!show_water); mWaterTabLayoutContainer->setVisible(show_water); updateSlider(); @@ -517,20 +542,21 @@ void LLFloaterEditExtDayCycle::selectFrame(F32 frame) { mFramesSlider->resetCurSlider(); - mTimeSlider->setCurSliderValue(frame); keymap_t::iterator iter = mSliderKeyMap.begin(); keymap_t::iterator end_iter = mSliderKeyMap.end(); while (iter != end_iter) { - if (iter->second.mFrame == frame) + if (fabs(iter->second.mFrame - frame) <= FRAME_SLOP_FACTOR) { mFramesSlider->setCurSlider(iter->first); + frame = iter->second.mFrame; break; } iter++; } + mTimeSlider->setCurSliderValue(frame); // block or update tabs according to new selection updateTabs(); } @@ -554,24 +580,6 @@ void LLFloaterEditExtDayCycle::clearTabs() void LLFloaterEditExtDayCycle::updateTabs() { -// std::string sldr = mFramesSlider->getCurSlider(); -// if (sldr.empty()) -// { -// // keep old settings for duplicating if there are any -// setWaterTabsEnabled(FALSE); -// setSkyTabsEnabled(FALSE); -// } -// else if (mCurrentTrack == LLSettingsDay::TRACK_WATER) -// { -// const LLSettingsWaterPtr_t p_water = sldr.empty() ? LLSettingsWaterPtr_t(NULL) : mEditDay->getWaterAtKeyframe(mFramesSlider->getCurSliderValue()); -// updateWaterTabs(p_water); -// } -// else -// { -// const LLSettingsSkyPtr_t p_sky = sldr.empty() ? LLSettingsSkyPtr_t(NULL) : mEditDay->getSkyAtKeyframe(mFramesSlider->getCurSliderValue(), mCurrentTrack); -// updateSkyTabs(p_sky); -// } - reblendSettings(); syncronizeTabs(); @@ -658,6 +666,7 @@ void LLFloaterEditExtDayCycle::updateButtons() void LLFloaterEditExtDayCycle::updateSlider() { + F32 frame_position = mTimeSlider->getCurSliderValue(); mFramesSlider->clear(); mSliderKeyMap.clear(); @@ -671,7 +680,6 @@ void LLFloaterEditExtDayCycle::updateSlider() { // update positions mLastFrameSlider = mFramesSlider->getCurSlider(); - mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue()); updateTabs(); } else @@ -680,6 +688,8 @@ void LLFloaterEditExtDayCycle::updateSlider() clearTabs(); mLastFrameSlider.clear(); } + + selectFrame(frame_position); } void LLFloaterEditExtDayCycle::updateTimeAndLabel() @@ -749,11 +759,11 @@ LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSi return mCommitSignal.connect(cb); } -// **RIDER** void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId) { if (inventoryId.isNull()) { + LL_WARNS("SETTINGS") << "Attempt to load NULL inventory ID" << LL_ENDL; mInventoryItem = nullptr; mInventoryId.setNull(); return; @@ -771,6 +781,14 @@ void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId) return; } + if (mInventoryItem->getAssetUUID().isNull()) + { + LL_WARNS("SETTINGS") << "Asset ID in inventory item is NULL (" << mInventoryId << ")" << LL_ENDL; + mInventoryId.setNull(); + mInventoryItem = nullptr; + return; + } + LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), [this](LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status, LLExtStat) { onAssetLoaded(asset_id, settins, status); }); } @@ -810,10 +828,13 @@ void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t void LLFloaterEditExtDayCycle::updateEditEnvironment(void) { + S32 skytrack = (mCurrentTrack) ? mCurrentTrack : 1; mSkyBlender = std::make_shared(mScratchSky, mEditDay, skytrack); mWaterBlender = std::make_shared(mScratchWater, mEditDay, LLSettingsDay::TRACK_WATER); + selectTrack(1, true); + reblendSettings(); LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mScratchSky, mScratchWater); @@ -978,7 +999,8 @@ void LLFloaterEditExtDayCycle::doImportFromDisk() } mEditDay = legacyday; - + mCurrentTrack = 1; + updateSlider(); updateEditEnvironment(); syncronizeTabs(); refresh(); @@ -1012,10 +1034,10 @@ bool LLFloaterEditExtDayCycle::canApplyParcel() const LLEnvironment::instance().isExtendedEnvironmentEnabled(); } -// **RIDER** - void LLFloaterEditExtDayCycle::startPlay() { + mIsPlaying = true; + mFramesSlider->resetCurSlider(); mPlayTimer.reset(); mPlayTimer.start(); gIdleCallbacks.addFunction(onIdlePlay, this); @@ -1027,8 +1049,14 @@ void LLFloaterEditExtDayCycle::startPlay() void LLFloaterEditExtDayCycle::stopPlay() { + if (!mIsPlaying) + return; + + mIsPlaying = false; gIdleCallbacks.deleteFunction(onIdlePlay, this); mPlayTimer.stop(); + F32 frame = mTimeSlider->getCurSliderValue(); + selectFrame(frame); getChild("play_layout", true)->setVisible(TRUE); getChild("pause_layout", true)->setVisible(FALSE); diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index f2462ee1cc..bee5e17b95 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -91,9 +91,12 @@ private: // time slider moved void onTimeSliderMoved(); // a frame moved or frame selection changed - void onFrameSliderCallback(); + void onFrameSliderCallback(const LLSD &); + void onFrameSliderDoubleClick(S32 x, S32 y, MASK mask); + void onFrameSliderMouseDown(S32 x, S32 y, MASK mask); + void onFrameSliderMouseUp(S32 x, S32 y, MASK mask); - void selectTrack(U32 track_index); + void selectTrack(U32 track_index, bool force = false); void selectFrame(F32 frame); void clearTabs(); void updateTabs(); @@ -139,10 +142,10 @@ private: U32 mCurrentTrack; std::string mLastFrameSlider; - LLButton* mCancelButton; - LLButton* mAddFrameButton; - LLButton* mDeleteFrameButton; - LLButton* mImportButton; + LLButton* mCancelButton; + LLButton* mAddFrameButton; + LLButton* mDeleteFrameButton; + LLButton* mImportButton; LLMultiSliderCtrl* mTimeSlider; LLMultiSliderCtrl* mFramesSlider; @@ -160,10 +163,11 @@ private: LLSettingsWater::ptr_t mScratchWater; // **RIDER** - LLFlyoutComboBtnCtrl * mFlyoutControl; + LLFlyoutComboBtnCtrl * mFlyoutControl; - LLFrameTimer mPlayTimer; - F32 mPlayStartFrame; // an env frame + LLFrameTimer mPlayTimer; + F32 mPlayStartFrame; // an env frame + bool mIsPlaying; edit_commit_signal_t mCommitSignal; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index ed3c18ef4e..1ac607cd1f 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -240,7 +240,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { - LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << " ext_status=" << ext_status << LL_ENDL; + LL_WARNS("SETTINGS") << "Error retrieving asset asset_id. Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; } callback(asset_id, settings, status, ext_status); } 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 1b07d1aa27..86c580f354 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 @@ -121,7 +121,7 @@ - + + 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"> - - - - - - - - - - - - - - - - - - - - - + background_visible="false"> + + + - - - - - - - - - - - + + + + + + + + + + - + follows="top|left" + height="23" + width="90" + label="Clone From" + left="10" + top_pad="10" + name="copy_track" /> + - + width="83" + layout="topleft" + animate="false" + left="31" + top="40" + orientation="horizontal"> + + + + + + + + + + + + + + + + + + user_resize="false" + width="190" + height="150" + min_height="0" + visible="true"> - - + follows="top|right" + height="23" + width="90" + right="-10" + top_pad="10" + label="Add [FRAME]" + name="add_frame" /> + follows="top|left" + height="23" + width="90" + label="Load [FRAME]" + top_pad="0" + left_delta="0" + name="btn_load_frame" /> + - \ No newline at end of file + -- cgit v1.2.3 From 518f8addd1a7e2da79ce7c6966fa5774cc8e6415 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 16 Jan 2020 20:10:55 +0000 Subject: SL-12587 - added ViewerBenefits to requested caps. --- indra/newview/llviewerregion.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 75e707aaa3..5d8660143e 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2969,6 +2969,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("UploadBakedTexture"); capabilityNames.append("UserInfo"); capabilityNames.append("ViewerAsset"); + capabilityNames.append("ViewerBenefits"); capabilityNames.append("ViewerMetrics"); capabilityNames.append("ViewerStartAuction"); capabilityNames.append("ViewerStats"); -- cgit v1.2.3 From e63381a9365d69204b8e7593f47b963d3d037689 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 17 Jan 2020 17:32:29 +0000 Subject: SL-12587 - trigger build update --- indra/edit-me-to-trigger-new-build.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/edit-me-to-trigger-new-build.txt b/indra/edit-me-to-trigger-new-build.txt index b28b04f643..fd40910d9e 100644 --- a/indra/edit-me-to-trigger-new-build.txt +++ b/indra/edit-me-to-trigger-new-build.txt @@ -1,3 +1,4 @@ + -- cgit v1.2.3 From 1c17e51279faba9bda608c70db6e50b25e5714fd Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 22 Jan 2020 13:06:57 -0700 Subject: DRTVWR-440, whitespace change to test TeamCity trigger --- indra/newview/llfeaturemanager.cpp | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index aa9cba0c18..d915a9fd26 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -617,36 +617,36 @@ void LLFeatureManager::applyFeatures(bool skipFeatures) void LLFeatureManager::setGraphicsLevel(U32 level, bool skipFeatures) { - LLViewerShaderMgr::sSkipReload = true; + LLViewerShaderMgr::sSkipReload = true; - applyBaseMasks(); + applyBaseMasks(); - // if we're passed an invalid level, default to "Low" - std::string features(isValidGraphicsLevel(level)? getNameForGraphicsLevel(level) : "Low"); - if (features == "Low") - { + // if we're passed an invalid level, default to "Low" + std::string features(isValidGraphicsLevel(level)? getNameForGraphicsLevel(level) : "Low"); + if (features == "Low") + { #if LL_DARWIN - // This Mac-specific change is to insure that we force 'Basic Shaders' for all Mac - // systems which support them instead of falling back to fixed-function unnecessarily - // MAINT-2157 - if (gGLManager.mGLVersion < 2.1f) + // This Mac-specific change is to insure that we force 'Basic Shaders' for all Mac + // systems which support them instead of falling back to fixed-function unnecessarily + // MAINT-2157 + if (gGLManager.mGLVersion < 2.1f) #else - // only use fixed function by default if GL version < 3.0 or this is an intel graphics chip - if (gGLManager.mGLVersion < 3.f || gGLManager.mIsIntel) + // only use fixed function by default if GL version < 3.0 or this is an intel graphics chip + if (gGLManager.mGLVersion < 3.f || gGLManager.mIsIntel) #endif - { + { // same as Low, but with "Basic Shaders" disabled - features = "LowFixedFunction"; - } - } + features = "LowFixedFunction"; + } + } - maskFeatures(features); + maskFeatures(features); - applyFeatures(skipFeatures); + applyFeatures(skipFeatures); - LLViewerShaderMgr::sSkipReload = false; - LLViewerShaderMgr::instance()->setShaders(); - gPipeline.refreshCachedSettings(); + LLViewerShaderMgr::sSkipReload = false; + LLViewerShaderMgr::instance()->setShaders(); + gPipeline.refreshCachedSettings(); } void LLFeatureManager::applyBaseMasks() -- cgit v1.2.3 From 16699fe8a563202c9b53b2f8e80a49c336b518d4 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 23 Jan 2020 16:29:43 +0200 Subject: SL-12591 Fixed float comparison --- indra/llinventory/llsettingsdaycycle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index b80e74791e..8498425f4e 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -724,7 +724,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPo return false; } - if (old_frame == new_frame) + if (llabs(old_frame - new_frame) < F_APPROXIMATELY_ZERO) { return false; } -- cgit v1.2.3 From 3e44cb06df22dd1b684dc8574c3b44d0851527bc Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 23 Jan 2020 13:30:14 -0700 Subject: DRTVWR-440, another whitespace only (detabify) to test TeamCity triggers --- indra/newview/llviewershadermgr.cpp | 292 ++++++++++++++++++------------------ 1 file changed, 146 insertions(+), 146 deletions(-) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index bdd0330cca..5628f257c5 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -392,84 +392,84 @@ S32 LLViewerShaderMgr::getShaderLevel(S32 type) void LLViewerShaderMgr::setShaders() { - //setShaders might be called redundantly by gSavedSettings, so return on reentrance - static bool reentrance = false; - - if (!gPipeline.mInitialized || !sInitialized || reentrance || sSkipReload) - { - return; - } + //setShaders might be called redundantly by gSavedSettings, so return on reentrance + static bool reentrance = false; + + if (!gPipeline.mInitialized || !sInitialized || reentrance || sSkipReload) + { + return; + } - static LLCachedControl max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16); - LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits, (S32) max_texture_index), 1); + static LLCachedControl max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16); + LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits, (S32) max_texture_index), 1); - //NEVER use more than 16 texture channels (work around for prevalent driver bug) - LLGLSLShader::sIndexedTextureChannels = llmin(LLGLSLShader::sIndexedTextureChannels, 16); + //NEVER use more than 16 texture channels (work around for prevalent driver bug) + LLGLSLShader::sIndexedTextureChannels = llmin(LLGLSLShader::sIndexedTextureChannels, 16); - if (gGLManager.mGLSLVersionMajor < 1 || - (gGLManager.mGLSLVersionMajor == 1 && gGLManager.mGLSLVersionMinor <= 20)) - { //NEVER use indexed texture rendering when GLSL version is 1.20 or earlier - LLGLSLShader::sIndexedTextureChannels = 1; - } + if (gGLManager.mGLSLVersionMajor < 1 || + (gGLManager.mGLSLVersionMajor == 1 && gGLManager.mGLSLVersionMinor <= 20)) + { //NEVER use indexed texture rendering when GLSL version is 1.20 or earlier + LLGLSLShader::sIndexedTextureChannels = 1; + } - reentrance = true; + reentrance = true; - if (LLRender::sGLCoreProfile) - { - if (!gSavedSettings.getBOOL("VertexShaderEnable")) - { //vertex shaders MUST be enabled to use core profile - gSavedSettings.setBOOL("VertexShaderEnable", TRUE); - } - } - - //setup preprocessor definitions - LLShaderMgr::instance()->mDefinitions["NUM_TEX_UNITS"] = llformat("%d", gGLManager.mNumTextureImageUnits); - - // Make sure the compiled shader map is cleared before we recompile shaders. + if (LLRender::sGLCoreProfile) + { + if (!gSavedSettings.getBOOL("VertexShaderEnable")) + { //vertex shaders MUST be enabled to use core profile + gSavedSettings.setBOOL("VertexShaderEnable", TRUE); + } + } + + //setup preprocessor definitions + LLShaderMgr::instance()->mDefinitions["NUM_TEX_UNITS"] = llformat("%d", gGLManager.mNumTextureImageUnits); + + // Make sure the compiled shader map is cleared before we recompile shaders. mVertexShaderObjects.clear(); mFragmentShaderObjects.clear(); - - initAttribsAndUniforms(); - gPipeline.releaseGLBuffers(); + + initAttribsAndUniforms(); + gPipeline.releaseGLBuffers(); - if (gSavedSettings.getBOOL("VertexShaderEnable")) - { - LLPipeline::sWaterReflections = gGLManager.mHasCubeMap; - LLPipeline::sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); - LLPipeline::updateRenderDeferred(); - } - else - { - LLPipeline::sRenderGlow = FALSE; - LLPipeline::sWaterReflections = FALSE; - } - - //hack to reset buffers that change behavior with shaders - gPipeline.resetVertexBuffers(); + if (gSavedSettings.getBOOL("VertexShaderEnable")) + { + LLPipeline::sWaterReflections = gGLManager.mHasCubeMap; + LLPipeline::sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); + LLPipeline::updateRenderDeferred(); + } + else + { + LLPipeline::sRenderGlow = FALSE; + LLPipeline::sWaterReflections = FALSE; + } + + //hack to reset buffers that change behavior with shaders + gPipeline.resetVertexBuffers(); - if (gViewerWindow) - { - gViewerWindow->setCursor(UI_CURSOR_WAIT); - } + if (gViewerWindow) + { + gViewerWindow->setCursor(UI_CURSOR_WAIT); + } - // Lighting - gPipeline.setLightingDetail(-1); + // Lighting + gPipeline.setLightingDetail(-1); - // Shaders - LL_INFOS("ShaderLoading") << "\n~~~~~~~~~~~~~~~~~~\n Loading Shaders:\n~~~~~~~~~~~~~~~~~~" << LL_ENDL; - LL_INFOS("ShaderLoading") << llformat("Using GLSL %d.%d", gGLManager.mGLSLVersionMajor, gGLManager.mGLSLVersionMinor) << LL_ENDL; + // Shaders + LL_INFOS("ShaderLoading") << "\n~~~~~~~~~~~~~~~~~~\n Loading Shaders:\n~~~~~~~~~~~~~~~~~~" << LL_ENDL; + LL_INFOS("ShaderLoading") << llformat("Using GLSL %d.%d", gGLManager.mGLSLVersionMajor, gGLManager.mGLSLVersionMinor) << LL_ENDL; - for (S32 i = 0; i < SHADER_COUNT; i++) - { - mShaderLevel[i] = 0; - } - mMaxAvatarShaderLevel = 0; + for (S32 i = 0; i < SHADER_COUNT; i++) + { + mShaderLevel[i] = 0; + } + mMaxAvatarShaderLevel = 0; - LLGLSLShader::sNoFixedFunction = false; - LLVertexBuffer::unbind(); - if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") - && (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 10) - && gSavedSettings.getBOOL("VertexShaderEnable")) + LLGLSLShader::sNoFixedFunction = false; + LLVertexBuffer::unbind(); + if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") + && (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 10) + && gSavedSettings.getBOOL("VertexShaderEnable")) { bool canRenderDeferred = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"); bool hasWindLightShaders = LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"); @@ -477,24 +477,24 @@ void LLViewerShaderMgr::setShaders() bool useRenderDeferred = canRenderDeferred && gSavedSettings.getBOOL("RenderDeferred") && gSavedSettings.getBOOL("RenderAvatarVP"); bool doingWindLight = hasWindLightShaders && gSavedSettings.getBOOL("WindLightUseAtmosShaders"); - //using shaders, disable fixed function - LLGLSLShader::sNoFixedFunction = true; + //using shaders, disable fixed function + LLGLSLShader::sNoFixedFunction = true; - S32 light_class = 3; + S32 light_class = 3; S32 interface_class = 2; - S32 env_class = 2; - S32 obj_class = 2; - S32 effect_class = 2; - S32 wl_class = 1; - S32 water_class = 2; - S32 deferred_class = 0; - S32 transform_class = gGLManager.mHasTransformFeedback ? 1 : 0; - - static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); - if (!use_transform_feedback) - { - transform_class = 0; - } + S32 env_class = 2; + S32 obj_class = 2; + S32 effect_class = 2; + S32 wl_class = 1; + S32 water_class = 2; + S32 deferred_class = 0; + S32 transform_class = gGLManager.mHasTransformFeedback ? 1 : 0; + + static LLCachedControl use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); + if (!use_transform_feedback) + { + transform_class = 0; + } if (useRenderDeferred) { @@ -527,55 +527,55 @@ void LLViewerShaderMgr::setShaders() light_class = 2; } - // Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders - if (!wl_class || (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull())) - { - gSky.mVOSkyp->forceSkyUpdate(); - } + // Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders + if (!wl_class || (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull())) + { + gSky.mVOSkyp->forceSkyUpdate(); + } - // Load lighting shaders - mShaderLevel[SHADER_LIGHTING] = light_class; - mShaderLevel[SHADER_INTERFACE] = interface_class; - mShaderLevel[SHADER_ENVIRONMENT] = env_class; - mShaderLevel[SHADER_WATER] = water_class; - mShaderLevel[SHADER_OBJECT] = obj_class; - mShaderLevel[SHADER_EFFECT] = effect_class; - mShaderLevel[SHADER_WINDLIGHT] = wl_class; - mShaderLevel[SHADER_DEFERRED] = deferred_class; - mShaderLevel[SHADER_TRANSFORM] = transform_class; + // Load lighting shaders + mShaderLevel[SHADER_LIGHTING] = light_class; + mShaderLevel[SHADER_INTERFACE] = interface_class; + mShaderLevel[SHADER_ENVIRONMENT] = env_class; + mShaderLevel[SHADER_WATER] = water_class; + mShaderLevel[SHADER_OBJECT] = obj_class; + mShaderLevel[SHADER_EFFECT] = effect_class; + mShaderLevel[SHADER_WINDLIGHT] = wl_class; + mShaderLevel[SHADER_DEFERRED] = deferred_class; + mShaderLevel[SHADER_TRANSFORM] = transform_class; BOOL loaded = loadBasicShaders(); - if (loaded) - { - LL_INFOS() << "Loaded basic shaders." << LL_ENDL; - } - else - { - LL_WARNS() << "Failed to load basic shaders." << LL_ENDL; - llassert(loaded); - } + if (loaded) + { + LL_INFOS() << "Loaded basic shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load basic shaders." << LL_ENDL; + llassert(loaded); + } - if (loaded) - { - gPipeline.mVertexShadersEnabled = TRUE; - gPipeline.mVertexShadersLoaded = 1; + if (loaded) + { + gPipeline.mVertexShadersEnabled = TRUE; + gPipeline.mVertexShadersLoaded = 1; - // Load all shaders to set max levels - loaded = loadShadersEnvironment(); + // Load all shaders to set max levels + loaded = loadShadersEnvironment(); - if (loaded) - { - LL_INFOS() << "Loaded environment shaders." << LL_ENDL; - } - else - { - LL_WARNS() << "Failed to load environment shaders." << LL_ENDL; - llassert(loaded); - } + if (loaded) + { + LL_INFOS() << "Loaded environment shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load environment shaders." << LL_ENDL; + llassert(loaded); + } - if (loaded) - { - loaded = loadShadersWater(); + if (loaded) + { + loaded = loadShadersWater(); if (loaded) { LL_INFOS() << "Loaded water shaders." << LL_ENDL; @@ -585,10 +585,10 @@ void LLViewerShaderMgr::setShaders() LL_WARNS() << "Failed to load water shaders." << LL_ENDL; llassert(loaded); } - } + } - if (loaded) - { + if (loaded) + { loaded = loadShadersWindLight(); if (loaded) { @@ -599,10 +599,10 @@ void LLViewerShaderMgr::setShaders() LL_WARNS() << "Failed to load windlight shaders." << LL_ENDL; llassert(loaded); } - } + } - if (loaded) - { + if (loaded) + { loaded = loadShadersEffects(); if (loaded) { @@ -613,25 +613,25 @@ void LLViewerShaderMgr::setShaders() LL_WARNS() << "Failed to load effects shaders." << LL_ENDL; llassert(loaded); } - } + } - if (loaded) - { - loaded = loadShadersInterface(); - if (loaded) - { - LL_INFOS() << "Loaded interface shaders." << LL_ENDL; - } - else - { - LL_WARNS() << "Failed to load interface shaders." << LL_ENDL; - llassert(loaded); - } - } + if (loaded) + { + loaded = loadShadersInterface(); + if (loaded) + { + LL_INFOS() << "Loaded interface shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load interface shaders." << LL_ENDL; + llassert(loaded); + } + } - if (loaded) + if (loaded) - { + { loaded = loadTransformShaders(); if (loaded) { @@ -767,7 +767,7 @@ void LLViewerShaderMgr::setShaders() } gPipeline.createGLBuffers(); - reentrance = false; + reentrance = false; } void LLViewerShaderMgr::unloadShaders() -- cgit v1.2.3 From 195f69f603613c3270050169c6a42f84307f8163 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 24 Jan 2020 16:45:36 -0700 Subject: SL-12594, remove the Basic Shaders checkbox from the gui --- indra/newview/skins/default/xui/da/panel_preferences_graphics1.xml | 1 - .../skins/default/xui/de/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/en/floater_preferences_graphics_advanced.xml | 4 +++- .../skins/default/xui/es/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/fr/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/it/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/ja/floater_preferences_graphics_advanced.xml | 1 - indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml | 1 - .../skins/default/xui/pt/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/ru/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/tr/floater_preferences_graphics_advanced.xml | 1 - .../skins/default/xui/zh/floater_preferences_graphics_advanced.xml | 1 - 12 files changed, 3 insertions(+), 12 deletions(-) diff --git a/indra/newview/skins/default/xui/da/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/da/panel_preferences_graphics1.xml index e494b2b755..c7770eb81b 100644 --- a/indra/newview/skins/default/xui/da/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/da/panel_preferences_graphics1.xml @@ -29,7 +29,6 @@ - diff --git a/indra/newview/skins/default/xui/de/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/de/floater_preferences_graphics_advanced.xml index 41e8dc5ef4..cd514f5afd 100644 --- a/indra/newview/skins/default/xui/de/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/de/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - Niedrig diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 70bf3f7c14..f06377f51a 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -623,6 +623,7 @@ top_delta="16" width="300" /> + + - Bajo diff --git a/indra/newview/skins/default/xui/fr/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/fr/floater_preferences_graphics_advanced.xml index fd47254934..42af9c526d 100644 --- a/indra/newview/skins/default/xui/fr/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/fr/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - Faible diff --git a/indra/newview/skins/default/xui/it/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/it/floater_preferences_graphics_advanced.xml index 3773ef3711..53f9ebc6fd 100644 --- a/indra/newview/skins/default/xui/it/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/it/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - Basso diff --git a/indra/newview/skins/default/xui/ja/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/ja/floater_preferences_graphics_advanced.xml index c28afa4c98..8ba537faa2 100644 --- a/indra/newview/skins/default/xui/ja/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/ja/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - 低 diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml index 738805d800..e8c400dbd1 100644 --- a/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml @@ -28,7 +28,6 @@ - diff --git a/indra/newview/skins/default/xui/pt/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/pt/floater_preferences_graphics_advanced.xml index c5039267ca..bbe36e3e03 100644 --- a/indra/newview/skins/default/xui/pt/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/pt/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - Baixo diff --git a/indra/newview/skins/default/xui/ru/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/ru/floater_preferences_graphics_advanced.xml index fc6b6a173e..84e1ff15a0 100644 --- a/indra/newview/skins/default/xui/ru/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/ru/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - Низкая diff --git a/indra/newview/skins/default/xui/tr/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/tr/floater_preferences_graphics_advanced.xml index 01ada1354c..c5ca997336 100644 --- a/indra/newview/skins/default/xui/tr/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/tr/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - Düşük diff --git a/indra/newview/skins/default/xui/zh/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/zh/floater_preferences_graphics_advanced.xml index 7b127acd71..58314efeed 100644 --- a/indra/newview/skins/default/xui/zh/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/zh/floater_preferences_graphics_advanced.xml @@ -82,7 +82,6 @@ - 低 -- cgit v1.2.3 From 18cdf4d2693c0b859a5378e251b1368975f62395 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 24 Jan 2020 17:26:20 -0700 Subject: SL-12594, remove Basic Shader checks Remove checks for Vertex Shader capability and UI selection of no Basic Shaders. --- indra/newview/llfloaterpreference.cpp | 113 +++++++++------------------------- indra/newview/llfloaterpreference.h | 8 +-- indra/newview/pipeline.cpp | 3 - 3 files changed, 33 insertions(+), 91 deletions(-) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 5cfdc466ef..8165207dd0 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -407,7 +407,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this)); mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable", boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreference::updateMaxComplexity, this)); - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onRenderOptionEnable, this)); mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this)); mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::refreshUI,this)); mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2)); @@ -866,12 +866,12 @@ void LLFloaterPreference::onOpen(const LLSD& key) } } -void LLFloaterPreference::onVertexShaderEnable() +void LLFloaterPreference::onRenderOptionEnable() { refreshEnabledGraphics(); } -void LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable() +void LLFloaterPreferenceGraphicsAdvanced::onRenderOptionEnable() { LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences"); if (instance) @@ -1305,20 +1305,19 @@ void LLFloaterPreference::refreshEnabledState() LLCheckBoxCtrl* ctrl_deferred = getChild("UseLightShaders"); // if vertex shaders off, disable all shader related products - if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") || - !LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) + if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) { ctrl_wind_light->setEnabled(FALSE); ctrl_wind_light->setValue(FALSE); } else { - ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable")); + ctrl_wind_light->setEnabled(TRUE); } //Deferred/SSAO/Shadows BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump"); - BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable"); + BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && bumpshiny && shaders && @@ -1375,50 +1374,33 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() { ctrl_avatar_cloth->setEnabled(TRUE); } - - // Vertex Shaders - // Global Shader Enable - LLCheckBoxCtrl* ctrl_shader_enable = getChild("BasicShaders"); - LLSliderCtrl* terrain_detail = getChild("TerrainDetail"); // can be linked with control var - LLTextBox* terrain_text = getChild("TerrainDetailText"); - ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")); - - BOOL shaders = ctrl_shader_enable->get(); - if (shaders) - { - terrain_detail->setEnabled(FALSE); - terrain_text->setEnabled(FALSE); - } - else - { - terrain_detail->setEnabled(TRUE); - terrain_text->setEnabled(TRUE); - } - - // WindLight - LLCheckBoxCtrl* ctrl_wind_light = getChild("WindLightUseAtmosShaders"); - LLSliderCtrl* sky = getChild("SkyMeshDetail"); - LLTextBox* sky_text = getChild("SkyMeshDetailText"); + // Vertex Shaders, Global Shader Enable + // SL-12594 Basic shaders are always enabled. DJH TODO clean up now-orphaned state handling code + LLSliderCtrl* terrain_detail = getChild("TerrainDetail"); // can be linked with control var + LLTextBox* terrain_text = getChild("TerrainDetailText"); - // *HACK just checks to see if we can use shaders... - // maybe some cards that use shaders, but don't support windlight - ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders); + terrain_detail->setEnabled(FALSE); + terrain_text->setEnabled(FALSE); - sky->setEnabled(ctrl_wind_light->get() && shaders); - sky_text->setEnabled(ctrl_wind_light->get() && shaders); + // WindLight + LLCheckBoxCtrl* ctrl_wind_light = getChild("WindLightUseAtmosShaders"); + LLSliderCtrl* sky = getChild("SkyMeshDetail"); + LLTextBox* sky_text = getChild("SkyMeshDetailText"); + ctrl_wind_light->setEnabled(TRUE); + sky->setEnabled(TRUE); + sky_text->setEnabled(TRUE); - //Deferred/SSAO/Shadows - LLCheckBoxCtrl* ctrl_deferred = getChild("UseLightShaders"); - - BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && - ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) && - shaders && - gGLManager.mHasFramebufferObject && - gSavedSettings.getBOOL("RenderAvatarVP") && - (ctrl_wind_light->get()) ? TRUE : FALSE; + //Deferred/SSAO/Shadows + LLCheckBoxCtrl* ctrl_deferred = getChild("UseLightShaders"); + + BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && + ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) && + gGLManager.mHasFramebufferObject && + gSavedSettings.getBOOL("RenderAvatarVP") && + (ctrl_wind_light->get()) ? TRUE : FALSE; - ctrl_deferred->setEnabled(enabled); + ctrl_deferred->setEnabled(enabled); LLCheckBoxCtrl* ctrl_ssao = getChild("UseSSAO"); LLCheckBoxCtrl* ctrl_dof = getChild("UseDoF"); @@ -1516,7 +1498,6 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() LLTextBox* reflections_text = getChild("ReflectionsText"); LLCheckBoxCtrl* ctrl_avatar_vp = getChild("AvatarVertexProgram"); LLCheckBoxCtrl* ctrl_avatar_cloth = getChild("AvatarCloth"); - LLCheckBoxCtrl* ctrl_shader_enable = getChild("BasicShaders"); LLCheckBoxCtrl* ctrl_wind_light = getChild("WindLightUseAtmosShaders"); LLCheckBoxCtrl* ctrl_deferred = getChild("UseLightShaders"); LLComboBox* ctrl_shadows = getChild("ShadowDetail"); @@ -1526,42 +1507,6 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() LLSliderCtrl* sky = getChild("SkyMeshDetail"); LLTextBox* sky_text = getChild("SkyMeshDetailText"); - // if vertex shaders off, disable all shader related products - if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")) - { - ctrl_shader_enable->setEnabled(FALSE); - ctrl_shader_enable->setValue(FALSE); - - ctrl_wind_light->setEnabled(FALSE); - ctrl_wind_light->setValue(FALSE); - - sky->setEnabled(FALSE); - sky_text->setEnabled(FALSE); - - ctrl_reflections->setEnabled(FALSE); - ctrl_reflections->setValue(0); - reflections_text->setEnabled(FALSE); - - ctrl_avatar_vp->setEnabled(FALSE); - ctrl_avatar_vp->setValue(FALSE); - - ctrl_avatar_cloth->setEnabled(FALSE); - ctrl_avatar_cloth->setValue(FALSE); - - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - - ctrl_ssao->setEnabled(FALSE); - ctrl_ssao->setValue(FALSE); - - ctrl_dof->setEnabled(FALSE); - ctrl_dof->setValue(FALSE); - - ctrl_deferred->setEnabled(FALSE); - ctrl_deferred->setValue(FALSE); - } - // disabled windlight if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) { @@ -2928,7 +2873,7 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) : LLFloater(key) { - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onRenderOptionEnable, this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 42f1de4a5d..a0f43bd884 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -122,8 +122,8 @@ protected: // callback for defaults void setHardwareDefaults(); void setRecommended(); - // callback for when client turns on shaders - void onVertexShaderEnable(); + // callback for when client modifies a render option + void onRenderOptionEnable(); // callback for when client turns on impostors void onAvatarImpostorsEnable(); @@ -313,8 +313,8 @@ class LLFloaterPreferenceGraphicsAdvanced : public LLFloater static void setIndirectMaxNonImpostors(); static void setIndirectMaxArc(); void refresh(); - // callback for when client turns on shaders - void onVertexShaderEnable(); + // callback for when client modifies a render option + void onRenderOptionEnable(); void onAdvancedAtmosphericsEnable(); LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced); }; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0395bf1a71..349f2a761c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1407,12 +1407,9 @@ void LLPipeline::restoreGL() bool LLPipeline::canUseVertexShaders() { - static const std::string vertex_shader_enable_feature_string = "VertexShaderEnable"; - if (sDisableShaders || !gGLManager.mHasVertexShader || !gGLManager.mHasFragmentShader || - !LLFeatureManager::getInstance()->isFeatureAvailable(vertex_shader_enable_feature_string) || (assertInitialized() && mVertexShadersLoaded != 1) ) { return false; -- cgit v1.2.3 From a20a506bd1a281fe5d0d54c9a59c47abed23d44a Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 29 Jan 2020 13:18:41 -0700 Subject: SL-12594, rename some lingering VertexShaderEnable variables --- indra/newview/llfloaterpreference.cpp | 4 ++-- .../default/xui/en/floater_preferences_graphics_advanced.xml | 12 ++++++------ .../skins/default/xui/en/panel_preferences_graphics1.xml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 8165207dd0..d11e5e44d2 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -407,7 +407,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this)); mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable", boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreference::updateMaxComplexity, this)); - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onRenderOptionEnable, this)); + mCommitCallbackRegistrar.add("Pref.RenderOptionUpdate", boost::bind(&LLFloaterPreference::onRenderOptionEnable, this)); mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this)); mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::refreshUI,this)); mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2)); @@ -2873,7 +2873,7 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) : LLFloater(key) { - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onRenderOptionEnable, this)); + mCommitCallbackRegistrar.add("Pref.RenderOptionUpdate", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onRenderOptionEnable, this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); } diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index f06377f51a..ce219069e7 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -609,7 +609,7 @@ top_delta="16" width="300"> + function="Pref.RenderOptionUpdate" /> + function="Pref.RenderOptionUpdate" /> + function="Pref.RenderOptionUpdate" /> + function="Pref.RenderOptionUpdate" /> + function="Pref.RenderOptionUpdate" /> + function="Pref.RenderOptionUpdate" /> - - diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml index df3f67a5a1..0ee8e7a059 100644 --- a/indra/newview/app_settings/low_graphics.xml +++ b/indra/newview/app_settings/low_graphics.xml @@ -33,8 +33,6 @@ - - diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml index a10c02b79f..c89e060307 100644 --- a/indra/newview/app_settings/mid_graphics.xml +++ b/indra/newview/app_settings/mid_graphics.xml @@ -33,8 +33,6 @@ - - diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 05722bd8c1..0cb9ee3ace 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14259,6 +14259,7 @@ Value 1 + VivoxAutoPostCrashDumps Comment diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml index 3e7fccbd5f..eb2cd356d9 100644 --- a/indra/newview/app_settings/ultra_graphics.xml +++ b/indra/newview/app_settings/ultra_graphics.xml @@ -34,8 +34,6 @@ - - diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index ce219069e7..e93568a87e 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -623,7 +623,7 @@ top_delta="16" width="300" /> - - ([HH]:[MM]) + ([HH]:[MM]) Sky [ALT] Sky Water @@ -185,44 +185,44 @@ left="10" name="p0" top_pad="5" - value="0%[DSC]" - width="80" /> + value="0% [DSC]" + width="90" /> + value="25% [DSC]" + width="90" /> + value="50% [DSC]" + width="90" /> + value="75% [DSC]" + width="90" /> + value="100% [DSC]" + width="90" /> + width="56" + word_wrap="true"/> Date: Fri, 21 Feb 2020 19:56:44 +0000 Subject: SL-10498 - made benefits debug output a bit less verbose --- indra/newview/llstartup.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index e6ad2373bf..be6e9e520a 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -3294,8 +3294,6 @@ void on_benefits_failed_callback(const LLSD& notification, const LLSD& response) bool init_benefits(LLSD& response) { - LL_DEBUGS("Benefits") << "login success response:" << response << LL_ENDL; - bool succ = true; std::string package_name = response["account_type"].asString(); -- cgit v1.2.3 From d16a79fc4c5d5af016db6c97efc3a7b2d08f62ce Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Feb 2020 21:22:21 +0200 Subject: SL-12741 Moon was using fixed color --- indra/llinventory/llsettingssky.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 8d0b37d01f..306c732920 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1277,11 +1277,7 @@ LLColor4 LLSettingsSky::getTotalAmbient() const LLColor3 LLSettingsSky::getMoonlightColor() const { - F32 moon_brightness = getIsMoonUp() ? getMoonBrightness() : 0.001f; - LLColor3 moonlight_a(0.9, 0.9, 1.32); - LLColor3 moonlight_b(0.66, 0.66, 2.0); - LLColor3 moonlight = lerp(moonlight_b, moonlight_a, moon_brightness); - return moonlight; + return getSunlightColor(); //moon and sun share light color } void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const -- cgit v1.2.3 From db2c32285b95d3517ebcd1dbf84faa2872ab6428 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Feb 2020 18:59:43 +0200 Subject: SL-12591 Fixed slider value comparison --- indra/llui/llmultislider.cpp | 18 +++++++++++------- indra/llui/llmultislider.h | 4 ++++ indra/llui/llmultisliderctrl.h | 1 + indra/newview/llfloatereditextdaycycle.cpp | 9 ++++++++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index fbe0d3f065..acfe4a0cba 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -149,6 +149,16 @@ LLMultiSlider::~LLMultiSlider() delete mMouseUpSignal; } +F32 LLMultiSlider::getNearestIncrement(F32 value) const +{ + value = llclamp(value, mMinValue, mMaxValue); + + // Round to nearest increment (bias towards rounding down) + value -= mMinValue; + value += mIncrement / 2.0001f; + value -= fmod(value, mIncrement); + return mMinValue + value; +} void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event) { @@ -157,13 +167,7 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from return; } - value = llclamp( value, mMinValue, mMaxValue ); - - // Round to nearest increment (bias towards rounding down) - value -= mMinValue; - value += mIncrement/2.0001f; - value -= fmod(value, mIncrement); - F32 newValue = mMinValue + value; + F32 newValue = getNearestIncrement(value); // now, make sure no overlap // if we want that diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index 20c3437ec4..99a78d6e09 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -77,6 +77,10 @@ protected: friend class LLUICtrlFactory; public: virtual ~LLMultiSlider(); + + // Multi-slider rounds values to nearest increments (bias towards rounding down) + F32 getNearestIncrement(F32 value) const; + void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE); F32 getSliderValue(const std::string& name) const; F32 getSliderValueFromPos(S32 xpos, S32 ypos) const; diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index e16737b3c7..adb28676ec 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -107,6 +107,7 @@ public: void setMaxValue(F32 max_value) {mMultiSlider->setMaxValue(max_value);} void setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);} + F32 getNearestIncrement(F32 value) const { return mMultiSlider->getNearestIncrement(value); } F32 getSliderValueFromPos(S32 x, S32 y) const { return mMultiSlider->getSliderValueFromPos(x, y); } LLRect getSliderThumbRect(const std::string &name) const { return mMultiSlider->getSliderThumbRect(name); } diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 2c10835fb0..f57a54163d 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -991,13 +991,20 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) } else { - if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos) && mCanMod) + // slider rounds values to nearest increments, changes can be substanntial (half increment) + if (abs(mFramesSlider->getNearestIncrement((*it).second.mFrame) - sliderpos) < F_APPROXIMATELY_ZERO) + { + // same value + mFramesSlider->setCurSliderValue((*it).second.mFrame); + } + else if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos) && mCanMod) { (*it).second.mFrame = sliderpos; setDirtyFlag(); } else { + // same value, wrong track, no such value, no mod mFramesSlider->setCurSliderValue((*it).second.mFrame); } -- cgit v1.2.3 From b1934b4d05f5d044584b5eb7115639bf1183aa93 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Feb 2020 20:23:12 +0200 Subject: SL-12755 [EEP] The sky level dropdown was not disabled by default --- indra/newview/skins/default/xui/en/floater_settings_picker.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/skins/default/xui/en/floater_settings_picker.xml b/indra/newview/skins/default/xui/en/floater_settings_picker.xml index 132d23492f..c6136904cf 100644 --- a/indra/newview/skins/default/xui/en/floater_settings_picker.xml +++ b/indra/newview/skins/default/xui/en/floater_settings_picker.xml @@ -107,6 +107,7 @@ max_chars="100" mouse_opaque="true" name="track_selection" + enabled="false" top="1" width="190"/> -- cgit v1.2.3 From dbf464e0fd0df27c18b78a77004b40a8477e0c31 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Feb 2020 20:43:15 +0200 Subject: SL-12754 Fixed search field --- indra/newview/skins/default/xui/en/floater_settings_picker.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indra/newview/skins/default/xui/en/floater_settings_picker.xml b/indra/newview/skins/default/xui/en/floater_settings_picker.xml index c6136904cf..3a26c3b547 100644 --- a/indra/newview/skins/default/xui/en/floater_settings_picker.xml +++ b/indra/newview/skins/default/xui/en/floater_settings_picker.xml @@ -58,7 +58,7 @@ Date: Tue, 25 Feb 2020 08:05:24 -0700 Subject: SL-12638, fix overly dark appearance of normal-mapped objects Adds the 'additive' component of calcAtmosphericVars into the sunlit color to reduce darkening of sun lighting component, and adds a further magic number gainto boost final result to rough parity with windlight. Removes all light calculations on fullbright objects, just passing through the unlit diffuse color. --- .../shaders/class1/deferred/fullbrightF.glsl | 3 +- .../shaders/class1/deferred/materialF.glsl | 73 ++++++---------------- 2 files changed, 20 insertions(+), 56 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index c104dc884f..39ed9a6e82 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -86,7 +86,6 @@ void main() color.a = final_alpha; #endif - frag_color.rgb = color.rgb; - frag_color.a = color.a; + frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index d28fc128b6..2df683a5fd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -95,19 +95,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe dist /= la; - /* clip to projector bounds - vec4 proj_tc = proj_mat * lp; - - if (proj_tc.z < 0 - || proj_tc.z > 1 - || proj_tc.x < 0 - || proj_tc.x > 1 - || proj_tc.y < 0 - || proj_tc.y > 1) - { - return col; - }*/ - if (dist > 0.0 && la > 0.0) { //normalize light vector @@ -252,7 +239,11 @@ void main() vec3 norm = vec3(0); float bmap_specular = 1.0; + // Non-physical gain, sole purpose to make EEP viewer better match windlight when normal-mapped. + float eep_bump_gain = 1.0; + #ifdef HAS_NORMAL_MAP + eep_bump_gain = 1.75; vec4 bump_sample = texture2D(bumpMap, vary_texcoord1.xy); norm = (bump_sample.xyz * 2) - vec3(1); bmap_specular = bump_sample.w; @@ -295,7 +286,7 @@ void main() vec4 final_normal = vec4(abnormal, env_intensity, 0.0); vec3 color = vec3(0.0); - float al = 0.0; + float al = 1.0; if (emissive_brightness >= 1.0) { @@ -318,7 +309,12 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - if (emissive_brightness <= 1.0) + if (emissive_brightness >= 1.0) + { + // fullbright = diffuse texture pass-through, no lighting + frag_color = diffuse_srgb; + } + else { //forward rendering, output just lit RGBA vec3 pos = vary_position; @@ -348,40 +344,28 @@ void main() float da = dot(norm, normalize(light_dir)); da = clamp(da, 0.0, 1.0); // No negative light contributions - float ambient = da; - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0 - ambient); - - vec3 sun_contrib = min(da, shadow) * sunlit; + // ambient weight varies from 0.75 at max direct light to 1.0 with sun at grazing angle + float ambient = 1.0 - (0.25 * da * da); -// vec3 debug_sun_contrib = sun_contrib; + vec3 sun_contrib = additive + (min(da, shadow) * sunlit); #if !defined(AMBIENT_KILL) color.rgb = amblit; color.rgb *= ambient; #endif -//vec3 debug_post_ambient = color.rgb; - #if !defined(SUNLIGHT_KILL) - color.rgb += sun_contrib; + color.rgb += eep_bump_gain * sun_contrib; #endif -//vec3 debug_post_sunlight = color.rgb; - - //color.rgb *= diffuse_srgb.rgb; color.rgb *= diffuse_linear.rgb; // SL-12006 -//vec3 debug_post_diffuse = color.rgb; - float glare = 0.0; if (spec.a > 0.0) // specular reflection { vec3 npos = -normalize(pos.xyz); - //vec3 ref = dot(pos+lv, norm); vec3 h = normalize(light_dir.xyz+npos); float nh = dot(norm, h); float nv = dot(norm, npos); @@ -404,8 +388,6 @@ void main() } } -//vec3 debug_post_spec = color.rgb; - if (envIntensity > 0.0) { //add environmentmap @@ -422,15 +404,11 @@ void main() glare += cur_glare; } -//vec3 debug_post_env = color.rgb; - color = atmosFragLighting(color, additive, atten); //convert to linear space before adding local lights color = srgb_to_linear(color); -//vec3 debug_post_atmo = color.rgb; - vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); @@ -453,32 +431,19 @@ void main() #endif color = scaleSoftClipFrag(color); - + // (only) post-deferred needs inline gamma correction color.rgb = linear_to_srgb(color.rgb); -//color.rgb = amblit; -//color.rgb = vec3(ambient); -//color.rgb = sunlit; -//color.rgb = debug_post_ambient; -//color.rgb = vec3(da); -//color.rgb = debug_sun_contrib; -//color.rgb = debug_post_sunlight; -//color.rgb = diffuse_srgb.rgb; -//color.rgb = debug_post_diffuse; -//color.rgb = debug_post_spec; -//color.rgb = debug_post_env; -//color.rgb = debug_post_atmo; - #ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; al = temp.a; #endif - } // !fullbright - frag_color.rgb = color.rgb; - frag_color.a = al; + frag_color.rgb = color.rgb; + frag_color.a = al; + } #else // if DIFFUSE_ALPHA_MODE_BLEND ... -- cgit v1.2.3 From e4a8942843316b6b4f9a88a280596c9311d88a53 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 25 Feb 2020 18:56:11 +0000 Subject: SL-12757 - typo in menu_viewer.xml --- indra/newview/skins/default/xui/en/menu_viewer.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index b1d44302f9..2c9bf99fe2 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1337,7 +1337,7 @@ function="File.VisibleUploadModel"/> Date: Tue, 25 Feb 2020 11:34:23 -0800 Subject: SL-12574: Simplify Direct Ambient --- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 8 ++------ .../app_settings/shaders/class2/deferred/softenLightF.glsl | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index b1dce665a1..705cc2f04e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -81,11 +81,7 @@ void main() norm.xyz = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float da = dot(normalize(norm.xyz), light_dir.xyz); - da = clamp(da, -1.0, 1.0); - - float final_da = da; - final_da = clamp(final_da, 0.0, 1.0); + float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); @@ -108,7 +104,7 @@ void main() ambient *= ambient; ambient = (1.0 - ambient); - vec3 sun_contrib = final_da * sunlit; + vec3 sun_contrib = da * sunlit; #if !defined(AMBIENT_KILL) color.rgb = amblit; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index f49fad5517..593706867d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -85,11 +85,7 @@ void main() float scol = 1.0; vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - float da = dot(normalize(norm.xyz), light_dir.xyz); - da = clamp(da, -1.0, 1.0); - - float final_da = da; - final_da = clamp(final_da, 0.0, 1.0); + float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); @@ -116,7 +112,7 @@ void main() ambient *= ambient; ambient = (1.0 - ambient); - vec3 sun_contrib = min(scol, final_da) * sunlit; + vec3 sun_contrib = min(scol, da) * sunlit; #if !defined(AMBIENT_KILL) color.rgb = amblit; -- cgit v1.2.3 From d180e94a8633bb7d6c355b36aba9712151d90207 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 25 Feb 2020 11:37:24 -0800 Subject: SL-12574: Document shader class summary --- indra/newview/app_settings/shaders/shader_hierarchy.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indra/newview/app_settings/shaders/shader_hierarchy.txt b/indra/newview/app_settings/shaders/shader_hierarchy.txt index ebccaddd55..8ef04d8e1f 100644 --- a/indra/newview/app_settings/shaders/shader_hierarchy.txt +++ b/indra/newview/app_settings/shaders/shader_hierarchy.txt @@ -1,3 +1,9 @@ +Class 3 is highest quality / lowest performance +Class 2 is medium quality / medium performance +Class 1 is lowest quality / highest performance + +Shaders WILL fall back to "lower" classes for functionality. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ avatar/avatarV.glsl - gAvatarProgram, gAvatarWaterProgram main() - avatar/avatarV.glsl -- cgit v1.2.3 From b71e33b48cf321bb76081baeb210511cb9fbc1c8 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 25 Feb 2020 13:08:01 -0800 Subject: SL-12574 Cleanup unused argument --- indra/newview/llvosky.cpp | 27 +++++++++++++-------------- indra/newview/llvosky.h | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 64f34eb619..525251d42c 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -190,9 +190,8 @@ void LLSkyTex::initEmpty(const S32 tex) createGLImage(tex); } -void LLSkyTex::create(const F32 brightness) +void LLSkyTex::create() { - /// Brightness ignored for now. U8* data = mImageRaw[sCurrent]->getData(); for (S32 i = 0; i < sResolution; ++i) { @@ -502,8 +501,8 @@ void LLVOSky::init() initSkyTextureDirs(side, tile); createSkyTexture(m_atmosphericsVars, side, tile); } - mSkyTex[side].create(1.0f); - mShinyTex[side].create(1.0f); + mSkyTex[side].create(); + mShinyTex[side].create(); } initCubeMap(); @@ -764,35 +763,35 @@ bool LLVOSky::updateSky() { LLImageRaw* raw1 = nullptr; LLImageRaw* raw2 = nullptr; - + if (!is_alm_wl_sky) - { + { raw1 = mSkyTex[side].getImageRaw(TRUE); raw2 = mSkyTex[side].getImageRaw(FALSE); raw2->copy(raw1); mSkyTex[side].createGLImage(tex); - } + } raw1 = mShinyTex[side].getImageRaw(TRUE); raw2 = mShinyTex[side].getImageRaw(FALSE); raw2->copy(raw1); mShinyTex[side].createGLImage(tex); -} + } next_frame = 0; // update the sky texture if (!is_alm_wl_sky) { for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) -{ - mSkyTex[i].create(1.0f); + { + mSkyTex[i].create(); } - } + } for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) - { - mShinyTex[i].create(1.0f); - } + { + mShinyTex[i].create(); + } // update the environment map initCubeMap(); diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index fc577ab5f8..39e42bbb24 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -78,7 +78,7 @@ protected: void initEmpty(const S32 tex); - void create(F32 brightness); + void create(); void setDir(const LLVector3 &dir, const S32 i, const S32 j) { -- cgit v1.2.3 From d87cc68a72393cdc56dcbc2e36fd94ec7a814246 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 25 Feb 2020 13:08:37 -0800 Subject: SL-12574 Cleanup inconsistent indentation --- indra/newview/llvosky.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 525251d42c..943704c8de 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -698,20 +698,20 @@ bool LLVOSky::updateSky() LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))) -{ + { return TRUE; -} + } if (mDead) -{ + { // It's dead. Don't update it. return TRUE; -} + } if (gGLManager.mIsDisabled) -{ + { return TRUE; -} + } static S32 next_frame = 0; const S32 total_no_tiles = NUM_CUBEMAP_FACES * NUM_TILES; @@ -743,15 +743,15 @@ bool LLVOSky::updateSky() mNeedUpdate = mNeedUpdate || !same_atmospherics; if (mNeedUpdate && (mForceUpdateThrottle.hasExpired() || mForceUpdate)) -{ + { // start updating cube map sides updateFog(LLViewerCamera::getInstance()->getFar()); mCubeMapUpdateStage = 0; mForceUpdate = FALSE; - } - } + } + } else if (mCubeMapUpdateStage == NUM_CUBEMAP_FACES) - { + { LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); LLSkyTex::stepCurrent(); @@ -805,9 +805,9 @@ bool LLVOSky::updateSky() gPipeline.markRebuild(gSky.mVOGroundp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); if (mDrawable.notNull() && mDrawable->getFace(0) && !mDrawable->getFace(0)->getVertexBuffer()) - { - gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); - } + { + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); + } mCubeMapUpdateStage = -1; } // run 0 to 5 faces, each face in own frame @@ -821,11 +821,11 @@ bool LLVOSky::updateSky() // (i.e. potentially can be made per tile again, can be moved to thread // instead of executing per face, or may be can be moved to shaders) for (S32 tile = 0; tile < NUM_TILES; tile++) - { + { createSkyTexture(m_atmosphericsVars, side, tile); - } + } mCubeMapUpdateStage++; - } + } return TRUE; } -- cgit v1.2.3 From c4c8d2017494dc1e673b2cb09f031a1715efa0af Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 25 Feb 2020 13:23:51 -0800 Subject: SL-12574 Tweak sky to better match Windlight --- indra/newview/lllegacyatmospherics.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 165ef8c797..e061b3ad17 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -208,23 +208,25 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto return calcSkyColorInDir(psky, vars, dir, isShiny); } +// This cubemap is used as "environmentMap" in indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) { - F32 saturation = 0.3f; + F32 sky_saturation = 0.25f; + F32 land_saturation = 0.1f; if (isShiny && dir.mV[VZ] < -0.02f) { LLColor4 col; LLColor3 desat_fog = LLColor3(mFogColor); - F32 brightness = desat_fog.brightness(); + F32 brightness = desat_fog.brightness();// NOTE: Linear brightness! // So that shiny somewhat shows up at night. if (brightness < 0.15f) { brightness = 0.15f; desat_fog = smear(0.15f); } - F32 greyscale_sat = brightness * (1.0f - saturation); - desat_fog = desat_fog * saturation + smear(greyscale_sat); + F32 greyscale_sat = brightness * (1.0f - land_saturation); + desat_fog = desat_fog * land_saturation + smear(greyscale_sat); if (!gPipeline.canUseWindLightShaders()) { col = LLColor4(desat_fog, 0.f); @@ -250,9 +252,9 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm if (isShiny) { F32 brightness = vars.hazeColor.brightness(); - F32 greyscale_sat = brightness * (1.0f - saturation); - LLColor3 sky_color = vars.hazeColor * saturation + smear(greyscale_sat); - sky_color *= (0.5f + 0.5f * brightness); + F32 greyscale_sat = brightness * (1.0f - sky_saturation); + LLColor3 sky_color = vars.hazeColor * sky_saturation + smear(greyscale_sat); + //sky_color *= (0.5f + 0.5f * brightness); // SL-12574 EEP sky was too dark dark grey/blue, lighten it slightly return LLColor4(sky_color, 0.0f); } -- cgit v1.2.3 From 44f0cadad8f51e33d6af49d7ef3b3e175bd5b8b2 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 27 Feb 2020 15:30:09 +0200 Subject: SL-12739 FIXED [EEP] Viewer is crashed after clicking the "Forget" button on the Experience Profile after the llSetAgentEnvironment was used --- indra/newview/llenvironment.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8f778711ce..b8c5648cca 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -397,8 +397,8 @@ namespace void removeInjection(const std::string keyname, LLUUID experience, LLSettingsBase::Seconds transition) { - auto it = mInjections.begin(); - while (it != mInjections.end()) + injections_t injections_buf; + for (auto it = mInjections.begin(); it != mInjections.end(); it++) { if ((keyname.empty() || ((*it)->mKeyName == keyname)) && (experience.isNull() || (experience == (*it)->mExperience))) @@ -406,13 +406,16 @@ namespace if (transition != LLEnvironment::TRANSITION_INSTANT) { typename Injection::ptr_t injection = std::make_shared(transition, keyname, (*it)->mLastValue, false, LLUUID::null); - mInjections.push_front(injection); // push them in at the front so we don't check them again. + injections_buf.push_front(injection); } - mInjections.erase(it++); } else - ++it; + { + injections_buf.push_front(*it); + } } + mInjections.clear(); + mInjections = injections_buf; for (auto itexp = mOverrideExps.begin(); itexp != mOverrideExps.end();) { -- cgit v1.2.3 From 823d8bce6034eaa748b65dfec3618d1283f1ec9d Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 27 Feb 2020 11:48:04 -0700 Subject: SL-12638, further tweaking of normal-map lighting, add some de-saturation --- .../app_settings/shaders/class1/deferred/materialF.glsl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 2df683a5fd..eebb0a5fe5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -164,6 +164,14 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe return max(col, vec3(0.0,0.0,0.0)); } +// Q&D approximate RGB-space de-saturation, strength from 0 (no effect) to 1.0 (complete grey-scale) +vec3 desat(vec3 color, float strength) +{ + float primary_value = max(color.r, max(color.g, color.b)); + vec3 delta = strength * (vec3(primary_value)-color); + return color + delta; +} + #else #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -355,11 +363,15 @@ void main() #endif #if !defined(SUNLIGHT_KILL) - color.rgb += eep_bump_gain * sun_contrib; + color.rgb += sun_contrib; #endif color.rgb *= diffuse_linear.rgb; // SL-12006 + // ad-hoc brighten and de-saturate (normal-mapped only), to match windlight - SL-12638 + color.rgb = desat(color.rgb, 0.33 * (eep_bump_gain - 1.0)); + color.rgb *= eep_bump_gain; + float glare = 0.0; if (spec.a > 0.0) // specular reflection -- cgit v1.2.3 From 54ded3678781f9a5c3b18bb4512918613e35198f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Mar 2020 15:34:38 +0200 Subject: SL-12755 [EEP] The sky level dropdown is not disabled for folders --- indra/newview/llsettingspicker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llsettingspicker.cpp b/indra/newview/llsettingspicker.cpp index b47821ddf2..d2d21063e7 100644 --- a/indra/newview/llsettingspicker.cpp +++ b/indra/newview/llsettingspicker.cpp @@ -271,7 +271,7 @@ void LLFloaterSettingsPicker::onSelectionChange(const LLFloaterSettingsPicker::i } bool track_picker_enabled = mTrackMode != TRACK_NONE; - getChild(CMB_TRACK_SELECTION)->setEnabled(track_picker_enabled && mSettingAssetID == asset_id); + getChild(CMB_TRACK_SELECTION)->setEnabled(is_item && track_picker_enabled && mSettingAssetID == asset_id); getChild(BTN_SELECT)->setEnabled(is_item && (!track_picker_enabled || mSettingAssetID == asset_id)); if (track_picker_enabled && asset_id.notNull() && mSettingAssetID != asset_id) { -- cgit v1.2.3 From c40dd9917ffa9711f883d2a3ea57855bb98a7e23 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Mon, 2 Mar 2020 17:31:25 +0200 Subject: SL-11273 FIXED [EEP] The beacon checkboxes in the Day Cycle window can only be changed while a keyframe is selected. --- indra/newview/llpaneleditsky.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index a069d6655f..2e26b69144 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -512,19 +512,21 @@ void LLPanelSettingsSkySunMoonTab::setEnabled(BOOL enabled) void LLPanelSettingsSkySunMoonTab::refresh() { - if (!mSkySettings) + if (!mSkySettings || !getCanChangeSettings()) { getChildView(PANEL_SKY_SUN_LAYOUT)->setAllChildrenEnabled(FALSE); getChildView(PANEL_SKY_MOON_LAYOUT)->setAllChildrenEnabled(FALSE); getChildView(FIELD_SKY_SUN_BEACON)->setEnabled(TRUE); getChildView(FIELD_SKY_MOON_BEACON)->setEnabled(TRUE); - return; + + if (!mSkySettings) + return; + } + else + { + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); } - - setEnabled(getCanChangeSettings()); - getChildView(PANEL_SKY_SUN_LAYOUT)->setAllChildrenEnabled(getCanChangeSettings()); - getChildView(PANEL_SKY_MOON_LAYOUT)->setAllChildrenEnabled(getCanChangeSettings()); - setAllChildrenEnabled(getCanChangeSettings()); getChild(FIELD_SKY_SUN_MOON_COLOR)->set(mSkySettings->getSunlightColor() / SLIDER_SCALE_SUN_AMBIENT); -- cgit v1.2.3 From 8c2b7e0e83566e9a27a65856d5ae7fbe3558422f Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 3 Mar 2020 16:39:17 -0700 Subject: Revert 2 merges (PR#13, PR#16) related to SL-12638 This reverts commits 9d9b890 and 5f846e4. --- .../shaders/class1/deferred/fullbrightF.glsl | 3 +- .../shaders/class1/deferred/materialF.glsl | 81 ++++++++++++++-------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 39ed9a6e82..c104dc884f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -86,6 +86,7 @@ void main() color.a = final_alpha; #endif - frag_color = color; + frag_color.rgb = color.rgb; + frag_color.a = color.a; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index eebb0a5fe5..d28fc128b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -95,6 +95,19 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe dist /= la; + /* clip to projector bounds + vec4 proj_tc = proj_mat * lp; + + if (proj_tc.z < 0 + || proj_tc.z > 1 + || proj_tc.x < 0 + || proj_tc.x > 1 + || proj_tc.y < 0 + || proj_tc.y > 1) + { + return col; + }*/ + if (dist > 0.0 && la > 0.0) { //normalize light vector @@ -164,14 +177,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe return max(col, vec3(0.0,0.0,0.0)); } -// Q&D approximate RGB-space de-saturation, strength from 0 (no effect) to 1.0 (complete grey-scale) -vec3 desat(vec3 color, float strength) -{ - float primary_value = max(color.r, max(color.g, color.b)); - vec3 delta = strength * (vec3(primary_value)-color); - return color + delta; -} - #else #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -247,11 +252,7 @@ void main() vec3 norm = vec3(0); float bmap_specular = 1.0; - // Non-physical gain, sole purpose to make EEP viewer better match windlight when normal-mapped. - float eep_bump_gain = 1.0; - #ifdef HAS_NORMAL_MAP - eep_bump_gain = 1.75; vec4 bump_sample = texture2D(bumpMap, vary_texcoord1.xy); norm = (bump_sample.xyz * 2) - vec3(1); bmap_specular = bump_sample.w; @@ -294,7 +295,7 @@ void main() vec4 final_normal = vec4(abnormal, env_intensity, 0.0); vec3 color = vec3(0.0); - float al = 1.0; + float al = 0.0; if (emissive_brightness >= 1.0) { @@ -317,12 +318,7 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - if (emissive_brightness >= 1.0) - { - // fullbright = diffuse texture pass-through, no lighting - frag_color = diffuse_srgb; - } - else + if (emissive_brightness <= 1.0) { //forward rendering, output just lit RGBA vec3 pos = vary_position; @@ -352,25 +348,32 @@ void main() float da = dot(norm, normalize(light_dir)); da = clamp(da, 0.0, 1.0); // No negative light contributions - // ambient weight varies from 0.75 at max direct light to 1.0 with sun at grazing angle - float ambient = 1.0 - (0.25 * da * da); + float ambient = da; + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0 - ambient); + + vec3 sun_contrib = min(da, shadow) * sunlit; - vec3 sun_contrib = additive + (min(da, shadow) * sunlit); +// vec3 debug_sun_contrib = sun_contrib; #if !defined(AMBIENT_KILL) color.rgb = amblit; color.rgb *= ambient; #endif +//vec3 debug_post_ambient = color.rgb; + #if !defined(SUNLIGHT_KILL) color.rgb += sun_contrib; #endif +//vec3 debug_post_sunlight = color.rgb; + + //color.rgb *= diffuse_srgb.rgb; color.rgb *= diffuse_linear.rgb; // SL-12006 - // ad-hoc brighten and de-saturate (normal-mapped only), to match windlight - SL-12638 - color.rgb = desat(color.rgb, 0.33 * (eep_bump_gain - 1.0)); - color.rgb *= eep_bump_gain; +//vec3 debug_post_diffuse = color.rgb; float glare = 0.0; @@ -378,6 +381,7 @@ void main() { vec3 npos = -normalize(pos.xyz); + //vec3 ref = dot(pos+lv, norm); vec3 h = normalize(light_dir.xyz+npos); float nh = dot(norm, h); float nv = dot(norm, npos); @@ -400,6 +404,8 @@ void main() } } +//vec3 debug_post_spec = color.rgb; + if (envIntensity > 0.0) { //add environmentmap @@ -416,11 +422,15 @@ void main() glare += cur_glare; } +//vec3 debug_post_env = color.rgb; + color = atmosFragLighting(color, additive, atten); //convert to linear space before adding local lights color = srgb_to_linear(color); +//vec3 debug_post_atmo = color.rgb; + vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); @@ -443,19 +453,32 @@ void main() #endif color = scaleSoftClipFrag(color); - + // (only) post-deferred needs inline gamma correction color.rgb = linear_to_srgb(color.rgb); +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = debug_post_ambient; +//color.rgb = vec3(da); +//color.rgb = debug_sun_contrib; +//color.rgb = debug_post_sunlight; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = debug_post_diffuse; +//color.rgb = debug_post_spec; +//color.rgb = debug_post_env; +//color.rgb = debug_post_atmo; + #ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; al = temp.a; #endif + } // !fullbright - frag_color.rgb = color.rgb; - frag_color.a = al; - } + frag_color.rgb = color.rgb; + frag_color.a = al; #else // if DIFFUSE_ALPHA_MODE_BLEND ... -- cgit v1.2.3 From 1ba0df9abe26a18f2c870210be9b8fe6a1c72699 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 3 Mar 2020 17:13:46 -0700 Subject: Roll back SL-12006 commits to materialF.glsl (Dec23) --- .../shaders/class1/deferred/materialF.glsl | 69 ++++------------------ 1 file changed, 11 insertions(+), 58 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index d28fc128b6..0829968dd1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -95,19 +95,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe dist /= la; - /* clip to projector bounds - vec4 proj_tc = proj_mat * lp; - - if (proj_tc.z < 0 - || proj_tc.z > 1 - || proj_tc.x < 0 - || proj_tc.x > 1 - || proj_tc.y < 0 - || proj_tc.y > 1) - { - return col; - }*/ - if (dist > 0.0 && la > 0.0) { //normalize light vector @@ -273,7 +260,6 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_EMISSIVE) final_color.a = diffuse_linear.a; - final_color.rgb = mix( diffuse_linear.rgb, final_color.rgb*0.5, diffuse_tap.a ); // SL-12171: Fix emissive texture portion being twice as bright. #endif final_color.a = max(final_color.a, emissive_brightness); @@ -295,17 +281,15 @@ void main() vec4 final_normal = vec4(abnormal, env_intensity, 0.0); vec3 color = vec3(0.0); - float al = 0.0; + float al = 0; +#ifdef HAS_SPECULAR_MAP if (emissive_brightness >= 1.0) { -#ifdef HAS_SPECULAR_MAP - // Note: We actually need to adjust all 4 channels not just .rgb - final_color *= 0.666666; -#endif - color.rgb = final_color.rgb; - al = vertex_color.a; + float ei = env_intensity*0.5 + 0.5; + final_normal = vec4(abnormal, ei, 0.0); } +#endif vec4 final_specular = spec; @@ -318,7 +302,6 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - if (emissive_brightness <= 1.0) { //forward rendering, output just lit RGBA vec3 pos = vary_position; @@ -348,33 +331,22 @@ void main() float da = dot(norm, normalize(light_dir)); da = clamp(da, 0.0, 1.0); // No negative light contributions - float ambient = da; - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0 - ambient); + // ambient weight varies from 0.75 at max direct light to 1.0 with sun at grazing angle + float ambient = 1.0 - (0.25 * da * da); vec3 sun_contrib = min(da, shadow) * sunlit; -// vec3 debug_sun_contrib = sun_contrib; - #if !defined(AMBIENT_KILL) color.rgb = amblit; color.rgb *= ambient; #endif -//vec3 debug_post_ambient = color.rgb; - #if !defined(SUNLIGHT_KILL) color.rgb += sun_contrib; #endif -//vec3 debug_post_sunlight = color.rgb; - - //color.rgb *= diffuse_srgb.rgb; - color.rgb *= diffuse_linear.rgb; // SL-12006 - -//vec3 debug_post_diffuse = color.rgb; - + color.rgb *= diffuse_srgb.rgb; + float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -404,8 +376,6 @@ void main() } } -//vec3 debug_post_spec = color.rgb; - if (envIntensity > 0.0) { //add environmentmap @@ -422,15 +392,11 @@ void main() glare += cur_glare; } -//vec3 debug_post_env = color.rgb; - color = atmosFragLighting(color, additive, atten); //convert to linear space before adding local lights color = srgb_to_linear(color); -//vec3 debug_post_atmo = color.rgb; - vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); @@ -457,30 +423,17 @@ void main() // (only) post-deferred needs inline gamma correction color.rgb = linear_to_srgb(color.rgb); -//color.rgb = amblit; -//color.rgb = vec3(ambient); -//color.rgb = sunlit; -//color.rgb = debug_post_ambient; -//color.rgb = vec3(da); -//color.rgb = debug_sun_contrib; -//color.rgb = debug_post_sunlight; -//color.rgb = diffuse_srgb.rgb; -//color.rgb = debug_post_diffuse; -//color.rgb = debug_post_spec; -//color.rgb = debug_post_env; -//color.rgb = debug_post_atmo; - #ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; al = temp.a; #endif - } // !fullbright + } frag_color.rgb = color.rgb; frag_color.a = al; -#else // if DIFFUSE_ALPHA_MODE_BLEND ... +#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer // deferred path frag_data[0] = final_color; -- cgit v1.2.3 From cc5044bce06598aab9f405bba745f0e8209fc5ce Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Wed, 4 Mar 2020 15:56:02 -0600 Subject: WIP - fix various inconsistencies in sRGB vs linear color space. Fix inconsistencies between softenLightF.glsl, materialF.glsl, and alphaF.glsl --- .../shaders/class1/deferred/alphaF.glsl | 19 +++--- .../shaders/class1/deferred/materialF.glsl | 70 +++++++++++----------- .../class1/deferred/postDeferredGammaCorrect.glsl | 3 +- .../shaders/class1/deferred/softenLightF.glsl | 10 ++-- 4 files changed, 50 insertions(+), 52 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 546a502ee1..814d5036db 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -22,7 +22,9 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + +//class1/deferred/alphaF.glsl + #extension GL_ARB_texture_rectangle : enable /*[EXTRA_CODE_HERE]*/ @@ -51,7 +53,7 @@ VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; #ifdef USE_VERTEX_COLOR -VARYING vec4 vertex_color; +VARYING vec4 vertex_color; //vertex color should be treated as sRGB #endif uniform mat4 proj_mat; @@ -190,7 +192,7 @@ void main() float final_alpha = diffuse_srgb.a * vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; - diffuse_linear.rgb *= vertex_color.rgb; + diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb); // Insure we don't pollute depth with invis pixels in impostor rendering // @@ -207,7 +209,7 @@ void main() #ifdef USE_VERTEX_COLOR final_alpha *= vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; - diffuse_linear.rgb *= vertex_color.rgb; + diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb); #endif vec3 sunlit; @@ -249,7 +251,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_srgb.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; @@ -258,10 +260,7 @@ vec3 post_diffuse = color.rgb; vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); - - // to linear! - color.rgb = srgb_to_linear(color.rgb); - + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) @@ -298,7 +297,7 @@ vec3 post_atmo = color.rgb; #endif // WATER_FOG #endif - + frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index eebb0a5fe5..c6ba489d52 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -25,6 +25,10 @@ /*[EXTRA_CODE_HERE]*/ +//class1/deferred/materialF.glsl + +// This shader is used for both writing opaque/masked content to the gbuffer and writing blended content to the framebuffer during the alpha pass. + #define DIFFUSE_ALPHA_MODE_NONE 0 #define DIFFUSE_ALPHA_MODE_BLEND 1 #define DIFFUSE_ALPHA_MODE_MASK 2 @@ -180,7 +184,7 @@ out vec4 frag_data[3]; #endif #endif -uniform sampler2D diffuseMap; +uniform sampler2D diffuseMap; //always in sRGB space #ifdef HAS_NORMAL_MAP uniform sampler2D bumpMap; @@ -218,14 +222,16 @@ void main() vec2 pos_screen = vary_texcoord0.xy; vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy); + diffuse_tap.rgb *= vertex_color.rgb; + //diffuse_tap = vec4(1,1,1,1); -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) +//#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vec4 diffuse_srgb = diffuse_tap; vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); -#else +/*#else vec4 diffuse_linear = diffuse_tap; vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); -#endif +#endif*/ #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) if (diffuse_linear.a < minimum_alpha) @@ -234,9 +240,6 @@ void main() } #endif - diffuse_linear.rgb *= vertex_color.rgb; - diffuse_srgb.rgb *= linear_to_srgb(vertex_color.rgb); - #ifdef HAS_SPECULAR_MAP vec4 spec = texture2D(specularMap, vary_texcoord2.xy); spec.rgb *= specular_color.rgb; @@ -298,10 +301,10 @@ void main() if (emissive_brightness >= 1.0) { -#ifdef HAS_SPECULAR_MAP +/*#ifdef HAS_SPECULAR_MAP // Note: We actually need to adjust all 4 channels not just .rgb final_color *= 0.666666; -#endif +#endif*/ color.rgb = final_color.rgb; al = vertex_color.a; } @@ -320,11 +323,12 @@ void main() if (emissive_brightness >= 1.0) { // fullbright = diffuse texture pass-through, no lighting - frag_color = diffuse_srgb; + color = diffuse_linear.rgb; + al = diffuse_linear.a; } else { - //forward rendering, output just lit RGBA + //forward rendering, output just lit sRGBA vec3 pos = vary_position; float shadow = 1.0f; @@ -349,13 +353,14 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); - float da = dot(norm, normalize(light_dir)); - da = clamp(da, 0.0, 1.0); // No negative light contributions + float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); - // ambient weight varies from 0.75 at max direct light to 1.0 with sun at grazing angle - float ambient = 1.0 - (0.25 * da * da); + float ambient = da; + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0 - ambient); - vec3 sun_contrib = additive + (min(da, shadow) * sunlit); + vec3 sun_contrib = da * sunlit; #if !defined(AMBIENT_KILL) color.rgb = amblit; @@ -367,11 +372,7 @@ void main() #endif color.rgb *= diffuse_linear.rgb; // SL-12006 - - // ad-hoc brighten and de-saturate (normal-mapped only), to match windlight - SL-12638 - color.rgb = desat(color.rgb, 0.33 * (eep_bump_gain - 1.0)); - color.rgb *= eep_bump_gain; - + float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -391,9 +392,9 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 sp = sun_contrib*scol / 16.0f; + vec3 sp = sun_contrib*scol / 6.0f; sp = clamp(sp, vec3(0), vec3(1)); - bloom = dot(sp, sp) / 6.0; + bloom = dot(sp, sp) / 4.0; #if !defined(SUNLIGHT_KILL) color += sp * spec.rgb; #endif @@ -418,9 +419,6 @@ void main() color = atmosFragLighting(color, additive, atten); - //convert to linear space before adding local lights - color = srgb_to_linear(color); - vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); @@ -444,23 +442,23 @@ void main() color = scaleSoftClipFrag(color); - // (only) post-deferred needs inline gamma correction - color.rgb = linear_to_srgb(color.rgb); - -#ifdef WATER_FOG +/*#ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; al = temp.a; -#endif - - frag_color.rgb = color.rgb; - frag_color.a = al; +#endif*/ } -#else // if DIFFUSE_ALPHA_MODE_BLEND ... + // (only) post-deferred needs inline gamma correction + color.rgb = linear_to_srgb(color.rgb); + + frag_color = vec4(color, al); + +#else // if DIFFUSE_ALPHA_MODE_BLEND ... + // deferred path - frag_data[0] = final_color; + frag_data[0] = vec4(linear_to_srgb(final_color.rgb), final_color.a); //gbuffer is sRGB frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 9f519708a2..966c73ef24 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -44,7 +44,8 @@ vec3 linear_to_srgb(vec3 cl); void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - diff.rgb = pow(diff.rgb, vec3(display_gamma)); + //diff.rgb = pow(diff.rgb, vec3(display_gamma)); + diff.rgb = linear_to_srgb(diff.rgb); frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 705cc2f04e..da2eb47e3b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -119,7 +119,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_srgb.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; @@ -157,7 +157,7 @@ vec3 post_diffuse = color.rgb; #ifdef WATER_FOG color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25; #else - color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); + color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a); #endif if (envIntensity > 0.0) @@ -201,7 +201,7 @@ vec3 post_atmo = color.rgb; // convert to linear as fullscreen lights need to sum in linear colorspace // and will be gamma (re)corrected downstream... - color.rgb = srgb_to_linear(color.rgb); + //color.rgb = srgb_to_linear(color.rgb); } // linear debuggables @@ -209,7 +209,7 @@ vec3 post_atmo = color.rgb; //color.rgb = vec3(ambient); //color.rgb = vec3(scol); //color.rgb = diffuse_linear.rgb; - + frag_color.rgb = color.rgb; - frag_color.a = bloom; + frag_color.a = 0.0; //bloom; } -- cgit v1.2.3 From 1481d78bb25a06ca99e0d75e8d6333abd6ce5590 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Wed, 4 Mar 2020 16:23:31 -0600 Subject: Changes somehow missing from last commit --- .../shaders/class1/deferred/multiPointLightF.glsl | 3 ++- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index dcc3750a8f..0d1cc81786 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -102,7 +102,8 @@ void main() dist_atten *= dist_atten; // Tweak falloff slightly to match pre-EEP attenuation - dist_atten *= 2.2; + // NOTE: this magic number also shows up in a great many other places, search for dist_atten *= to audit + dist_atten *= 2.0; dist_atten *= noise; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 593706867d..bacdb6f70f 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -127,7 +127,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_srgb.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; @@ -162,8 +162,10 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; -#ifndef WATER_FOG - color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); +#ifdef WATER_FOG + color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25; +#else + color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a); #endif if (envIntensity > 0.0) @@ -206,9 +208,6 @@ vec3 post_atmo = color.rgb; //color.rgb = post_env; //color.rgb = post_atmo; -// convert to linear as fullscreen lights need to sum in linear colorspace -// and will be gamma (re)corrected downstream... - color.rgb = srgb_to_linear(color.rgb); } // linear debuggables @@ -217,6 +216,8 @@ vec3 post_atmo = color.rgb; //color.rgb = vec3(scol); //color.rgb = diffuse_linear.rgb; + //output linear RGB as lights are summed up in linear space and then gamma corrected prior to the + //post deferred passes frag_color.rgb = color.rgb; frag_color.a = bloom; } -- cgit v1.2.3 From 265cefd2621a7d29e322ac903835bceb365f4f0a Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Wed, 4 Mar 2020 16:38:37 -0600 Subject: Merge fix --- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 57e30c0ef3..ffd9dfed8c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -349,7 +349,7 @@ void main() color.rgb += sun_contrib; #endif - color.rgb *= diffuse_srgb.rgb; + color.rgb *= diffuse_linear.rgb; float glare = 0.0; -- cgit v1.2.3 From ca5cc79dfbc55a2160212f213a1a622691b7f02e Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Wed, 4 Mar 2020 16:43:18 -0600 Subject: Fix line endings? --- .../shaders/class1/deferred/materialF.glsl | 888 ++++++++++----------- 1 file changed, 444 insertions(+), 444 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index ffd9dfed8c..586ce4a9b7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -1,444 +1,444 @@ -/** - * @file materialF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -/*[EXTRA_CODE_HERE]*/ - -//class1/deferred/materialF.glsl - -// This shader is used for both writing opaque/masked content to the gbuffer and writing blended content to the framebuffer during the alpha pass. - -#define DIFFUSE_ALPHA_MODE_NONE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 - -uniform float emissive_brightness; -uniform int sun_up_factor; - -#ifdef WATER_FOG -vec4 applyWaterFogView(vec3 pos, vec4 color); -#endif - -vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); -vec3 scaleSoftClipFrag(vec3 l); - -void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); - -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cs); - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - -#ifdef DEFINE_GL_FRAGCOLOR - out vec4 frag_color; -#else - #define frag_color gl_FragColor -#endif - -#ifdef HAS_SUN_SHADOW - float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); -#endif - -uniform samplerCube environmentMap; -uniform sampler2D lightFunc; - -// Inputs -uniform vec4 morphFactor; -uniform vec3 camPosLocal; -uniform mat3 env_mat; - -uniform vec3 sun_dir; -uniform vec3 moon_dir; -VARYING vec2 vary_fragcoord; - -VARYING vec3 vary_position; - -uniform mat4 proj_mat; -uniform mat4 inv_proj; -uniform vec2 screen_res; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec4 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float getAmbientClamp(); - -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) -{ - vec3 col = vec3(0); - - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float dist = length(lv); - float da = 1.0; - - dist /= la; - - if (dist > 0.0 && la > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0f; - - if (dist_atten <= 0.0) - { - return col; - } - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= dot(n, lv); - - float lit = 0.0f; - - float amb_da = ambiance; - if (da >= 0) - { - lit = max(da * dist_atten,0.0); - col = lit * light_col * diffuse; - amb_da += (da*0.5+0.5) * ambiance; - } - amb_da += (da*da*0.5 + 0.5) * ambiance; - amb_da *= dist_atten; - amb_da = min(amb_da, 1.0f - lit); - - // SL-10969 need to see why these are blown out - //col.rgb += amb_da * light_col * diffuse; - - if (spec.a > 0.0) - { - //vec3 ref = dot(pos+lv, norm); - vec3 h = normalize(lv+npos); - float nh = dot(n, h); - float nv = dot(n, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - - float gtdenom = 2 * nh; - float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 speccol = lit*scol*light_col.rgb*spec.rgb; - speccol = clamp(speccol, vec3(0), vec3(1)); - col += speccol; - - float cur_glare = max(speccol.r, speccol.g); - cur_glare = max(cur_glare, speccol.b); - glare = max(glare, speccol.r); - glare += max(cur_glare, 0.0); - } - } - } - - return max(col, vec3(0.0,0.0,0.0)); -} - -#else -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif -#endif - -uniform sampler2D diffuseMap; //always in sRGB space - -#ifdef HAS_NORMAL_MAP -uniform sampler2D bumpMap; -#endif - -#ifdef HAS_SPECULAR_MAP -uniform sampler2D specularMap; - -VARYING vec2 vary_texcoord2; -#endif - -uniform float env_intensity; -uniform vec4 specular_color; // specular color RGB and specular exponent (glossiness) in alpha - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) -uniform float minimum_alpha; -#endif - -#ifdef HAS_NORMAL_MAP -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; -VARYING vec2 vary_texcoord1; -#else -VARYING vec3 vary_normal; -#endif - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -vec2 encode_normal(vec3 n); - -void main() -{ - vec2 pos_screen = vary_texcoord0.xy; - - vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy); - diffuse_tap.rgb *= vertex_color.rgb; - //diffuse_tap = vec4(1,1,1,1); - -//#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vec4 diffuse_srgb = diffuse_tap; - vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); -/*#else - vec4 diffuse_linear = diffuse_tap; - vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); -#endif*/ - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) - if (diffuse_linear.a < minimum_alpha) - { - discard; - } -#endif - -#ifdef HAS_SPECULAR_MAP - vec4 spec = texture2D(specularMap, vary_texcoord2.xy); - spec.rgb *= specular_color.rgb; -#else - vec4 spec = vec4(specular_color.rgb, 1.0); -#endif - - vec3 norm = vec3(0); - float bmap_specular = 1.0; - -#ifdef HAS_NORMAL_MAP - vec4 bump_sample = texture2D(bumpMap, vary_texcoord1.xy); - norm = (bump_sample.xyz * 2) - vec3(1); - bmap_specular = bump_sample.w; - - // convert sampled normal to tangent space normal - norm = vec3(dot(norm, vary_mat0), - dot(norm, vary_mat1), - dot(norm, vary_mat2)); -#else - norm = vary_normal; -#endif - - norm = normalize(norm); - - vec2 abnormal = encode_normal(norm); - - vec4 final_color = vec4(diffuse_linear.rgb, 0.0); - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_EMISSIVE) - final_color.a = diffuse_linear.a; -#endif - - final_color.a = max(final_color.a, emissive_brightness); - - // Texture - // [x] Full Bright (emissive_brightness >= 1.0) - // Shininess (specular) - // [X] Texture - // Environment Intensity = 1 - // NOTE: There are two shaders that are used depending on the EI byte value: - // EI = 0 fullbright - // EI > 0 .. 255 material - // When it is passed to us it is normalized. - // We can either modify the output environment intensity - // OR - // adjust the final color via: - // final_color *= 0.666666; - // We don't remap the environment intensity but adjust the final color to closely simulate what non-EEP is doing. - vec4 final_normal = vec4(abnormal, env_intensity, 0.0); - - vec3 color = vec3(0.0); - float al = 0; - -#ifdef HAS_SPECULAR_MAP - if (emissive_brightness >= 1.0) - { - float ei = env_intensity*0.5 + 0.5; - final_normal = vec4(abnormal, ei, 0.0); - } -#endif - - vec4 final_specular = spec; - - final_specular.a = specular_color.a; - -#ifdef HAS_SPECULAR_MAP - final_specular.a *= bmap_specular; - final_normal.z *= spec.a; -#endif - - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - { - //forward rendering, output just lit sRGBA - vec3 pos = vary_position; - - float shadow = 1.0f; - -#ifdef HAS_SUN_SHADOW - shadow = sampleDirectionalShadow(pos.xyz, norm, pos_screen); -#endif - - spec = final_specular; - - float envIntensity = final_normal.z; - - vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - - float bloom = 0.0; - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; - - calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); - - vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); - - float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); - - float ambient = da; - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0 - ambient); - - vec3 sun_contrib = min(da, shadow) * sunlit; - -#if !defined(AMBIENT_KILL) - color.rgb = amblit; - color.rgb *= ambient; -#endif - -#if !defined(SUNLIGHT_KILL) - color.rgb += sun_contrib; -#endif - - color.rgb *= diffuse_linear.rgb; - - float glare = 0.0; - - if (spec.a > 0.0) // specular reflection - { - vec3 npos = -normalize(pos.xyz); - - //vec3 ref = dot(pos+lv, norm); - vec3 h = normalize(light_dir.xyz+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - - float gtdenom = 2 * nh; - float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 sp = sun_contrib*scol / 6.0f; - sp = clamp(sp, vec3(0), vec3(1)); - bloom = dot(sp, sp) / 4.0; -#if !defined(SUNLIGHT_KILL) - color += sp * spec.rgb; -#endif - } - } - - if (envIntensity > 0.0) - { - //add environmentmap - vec3 env_vec = env_mat * refnormpersp; - - vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; - -#if !defined(SUNLIGHT_KILL) - color = mix(color.rgb, reflected_color, envIntensity); -#endif - float cur_glare = max(reflected_color.r, reflected_color.g); - cur_glare = max(cur_glare, reflected_color.b); - cur_glare *= envIntensity*4.0; - glare += cur_glare; - } - - color = atmosFragLighting(color, additive, atten); - - vec3 npos = normalize(-pos.xyz); - - vec3 light = vec3(0,0,0); - -#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w ); - - LIGHT_LOOP(1) - LIGHT_LOOP(2) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) - - glare = min(glare, 1.0); - al = max(diffuse_linear.a,glare)*vertex_color.a; - -#if !defined(LOCAL_LIGHT_KILL) - color.rgb += light.rgb; -#endif - - color = scaleSoftClipFrag(color); - -/*#ifdef WATER_FOG - vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); - color.rgb = temp.rgb; - al = temp.a; -#endif*/ - } - - - color.rgb = linear_to_srgb(color.rgb); - - frag_color = vec4(color, al); - -#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer - - // deferred path - frag_data[0] = vec4(linear_to_srgb(final_color.rgb), final_color.a); //gbuffer is sRGB - frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. - frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. -#endif -} - +/** + * @file materialF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +/*[EXTRA_CODE_HERE]*/ + +//class1/deferred/materialF.glsl + +// This shader is used for both writing opaque/masked content to the gbuffer and writing blended content to the framebuffer during the alpha pass. + +#define DIFFUSE_ALPHA_MODE_NONE 0 +#define DIFFUSE_ALPHA_MODE_BLEND 1 +#define DIFFUSE_ALPHA_MODE_MASK 2 +#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +uniform float emissive_brightness; +uniform int sun_up_factor; + +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); +#endif + +vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +vec3 scaleSoftClipFrag(vec3 l); + +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); + +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cs); + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + +#ifdef DEFINE_GL_FRAGCOLOR + out vec4 frag_color; +#else + #define frag_color gl_FragColor +#endif + +#ifdef HAS_SUN_SHADOW + float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +#endif + +uniform samplerCube environmentMap; +uniform sampler2D lightFunc; + +// Inputs +uniform vec4 morphFactor; +uniform vec3 camPosLocal; +uniform mat3 env_mat; + +uniform vec3 sun_dir; +uniform vec3 moon_dir; +VARYING vec2 vary_fragcoord; + +VARYING vec3 vary_position; + +uniform mat4 proj_mat; +uniform mat4 inv_proj; +uniform vec2 screen_res; + +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; +uniform vec4 light_attenuation[8]; +uniform vec3 light_diffuse[8]; + +float getAmbientClamp(); + +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) +{ + vec3 col = vec3(0); + + //get light vector + vec3 lv = lp.xyz-v; + + //get distance + float dist = length(lv); + float da = 1.0; + + dist /= la; + + if (dist > 0.0 && la > 0.0) + { + //normalize light vector + lv = normalize(lv); + + //distance attenuation + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0f; + + if (dist_atten <= 0.0) + { + return col; + } + + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + + //angular attenuation + da *= dot(n, lv); + + float lit = 0.0f; + + float amb_da = ambiance; + if (da >= 0) + { + lit = max(da * dist_atten,0.0); + col = lit * light_col * diffuse; + amb_da += (da*0.5+0.5) * ambiance; + } + amb_da += (da*da*0.5 + 0.5) * ambiance; + amb_da *= dist_atten; + amb_da = min(amb_da, 1.0f - lit); + + // SL-10969 need to see why these are blown out + //col.rgb += amb_da * light_col * diffuse; + + if (spec.a > 0.0) + { + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(n, h); + float nv = dot(n, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + vec3 speccol = lit*scol*light_col.rgb*spec.rgb; + speccol = clamp(speccol, vec3(0), vec3(1)); + col += speccol; + + float cur_glare = max(speccol.r, speccol.g); + cur_glare = max(cur_glare, speccol.b); + glare = max(glare, speccol.r); + glare += max(cur_glare, 0.0); + } + } + } + + return max(col, vec3(0.0,0.0,0.0)); +} + +#else +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif +#endif + +uniform sampler2D diffuseMap; //always in sRGB space + +#ifdef HAS_NORMAL_MAP +uniform sampler2D bumpMap; +#endif + +#ifdef HAS_SPECULAR_MAP +uniform sampler2D specularMap; + +VARYING vec2 vary_texcoord2; +#endif + +uniform float env_intensity; +uniform vec4 specular_color; // specular color RGB and specular exponent (glossiness) in alpha + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) +uniform float minimum_alpha; +#endif + +#ifdef HAS_NORMAL_MAP +VARYING vec3 vary_mat0; +VARYING vec3 vary_mat1; +VARYING vec3 vary_mat2; +VARYING vec2 vary_texcoord1; +#else +VARYING vec3 vary_normal; +#endif + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +vec2 encode_normal(vec3 n); + +void main() +{ + vec2 pos_screen = vary_texcoord0.xy; + + vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy); + diffuse_tap.rgb *= vertex_color.rgb; + //diffuse_tap = vec4(1,1,1,1); + +//#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + vec4 diffuse_srgb = diffuse_tap; + vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); +/*#else + vec4 diffuse_linear = diffuse_tap; + vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); +#endif*/ + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) + if (diffuse_linear.a < minimum_alpha) + { + discard; + } +#endif + +#ifdef HAS_SPECULAR_MAP + vec4 spec = texture2D(specularMap, vary_texcoord2.xy); + spec.rgb *= specular_color.rgb; +#else + vec4 spec = vec4(specular_color.rgb, 1.0); +#endif + + vec3 norm = vec3(0); + float bmap_specular = 1.0; + +#ifdef HAS_NORMAL_MAP + vec4 bump_sample = texture2D(bumpMap, vary_texcoord1.xy); + norm = (bump_sample.xyz * 2) - vec3(1); + bmap_specular = bump_sample.w; + + // convert sampled normal to tangent space normal + norm = vec3(dot(norm, vary_mat0), + dot(norm, vary_mat1), + dot(norm, vary_mat2)); +#else + norm = vary_normal; +#endif + + norm = normalize(norm); + + vec2 abnormal = encode_normal(norm); + + vec4 final_color = vec4(diffuse_linear.rgb, 0.0); + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_EMISSIVE) + final_color.a = diffuse_linear.a; +#endif + + final_color.a = max(final_color.a, emissive_brightness); + + // Texture + // [x] Full Bright (emissive_brightness >= 1.0) + // Shininess (specular) + // [X] Texture + // Environment Intensity = 1 + // NOTE: There are two shaders that are used depending on the EI byte value: + // EI = 0 fullbright + // EI > 0 .. 255 material + // When it is passed to us it is normalized. + // We can either modify the output environment intensity + // OR + // adjust the final color via: + // final_color *= 0.666666; + // We don't remap the environment intensity but adjust the final color to closely simulate what non-EEP is doing. + vec4 final_normal = vec4(abnormal, env_intensity, 0.0); + + vec3 color = vec3(0.0); + float al = 0; + +#ifdef HAS_SPECULAR_MAP + if (emissive_brightness >= 1.0) + { + float ei = env_intensity*0.5 + 0.5; + final_normal = vec4(abnormal, ei, 0.0); + } +#endif + + vec4 final_specular = spec; + + final_specular.a = specular_color.a; + +#ifdef HAS_SPECULAR_MAP + final_specular.a *= bmap_specular; + final_normal.z *= spec.a; +#endif + + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + { + //forward rendering, output just lit sRGBA + vec3 pos = vary_position; + + float shadow = 1.0f; + +#ifdef HAS_SUN_SHADOW + shadow = sampleDirectionalShadow(pos.xyz, norm, pos_screen); +#endif + + spec = final_specular; + + float envIntensity = final_normal.z; + + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + + float bloom = 0.0; + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + + calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); + + vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); + + float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); + + float ambient = da; + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0 - ambient); + + vec3 sun_contrib = min(da, shadow) * sunlit; + +#if !defined(AMBIENT_KILL) + color.rgb = amblit; + color.rgb *= ambient; +#endif + +#if !defined(SUNLIGHT_KILL) + color.rgb += sun_contrib; +#endif + + color.rgb *= diffuse_linear.rgb; + + float glare = 0.0; + + if (spec.a > 0.0) // specular reflection + { + vec3 npos = -normalize(pos.xyz); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(light_dir.xyz+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + vec3 sp = sun_contrib*scol / 6.0f; + sp = clamp(sp, vec3(0), vec3(1)); + bloom = dot(sp, sp) / 4.0; +#if !defined(SUNLIGHT_KILL) + color += sp * spec.rgb; +#endif + } + } + + if (envIntensity > 0.0) + { + //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + + vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; + +#if !defined(SUNLIGHT_KILL) + color = mix(color.rgb, reflected_color, envIntensity); +#endif + float cur_glare = max(reflected_color.r, reflected_color.g); + cur_glare = max(cur_glare, reflected_color.b); + cur_glare *= envIntensity*4.0; + glare += cur_glare; + } + + color = atmosFragLighting(color, additive, atten); + + vec3 npos = normalize(-pos.xyz); + + vec3 light = vec3(0,0,0); + +#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w ); + + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) + + glare = min(glare, 1.0); + al = max(diffuse_linear.a,glare)*vertex_color.a; + +#if !defined(LOCAL_LIGHT_KILL) + color.rgb += light.rgb; +#endif + + color = scaleSoftClipFrag(color); + +/*#ifdef WATER_FOG + vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); + color.rgb = temp.rgb; + al = temp.a; +#endif*/ + } + + + color.rgb = linear_to_srgb(color.rgb); + + frag_color = vec4(color, al); + +#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer + + // deferred path + frag_data[0] = vec4(linear_to_srgb(final_color.rgb), final_color.a); //gbuffer is sRGB + frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. + frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. +#endif +} + -- cgit v1.2.3 From edb4373f7d2a32beb93a7f69ddcdf5e1bc0eb6a1 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 5 Mar 2020 14:13:39 +0200 Subject: SL-9775 FIXED EEP viewer crash when looking at the sun (which is playing parcel media) --- indra/newview/llface.cpp | 3 ++- indra/newview/llface.h | 4 ++++ indra/newview/llviewertexture.cpp | 5 ++++- indra/newview/llvosky.cpp | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 174d8e34d1..59269c2115 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -168,7 +168,8 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) mImportanceToCamera = 0.f ; mBoundingSphereRadius = 0.0f ; - mHasMedia = FALSE ; + mHasMedia = false ; + mIsMediaAllowed = true; } void LLFace::destroy() diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 0c5af5b579..c74d4e3fa8 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -218,6 +218,9 @@ public: void setHasMedia(bool has_media) { mHasMedia = has_media ;} BOOL hasMedia() const ; + void setMediaAllowed(bool is_media_allowed) { mIsMediaAllowed = is_media_allowed; } + BOOL isMediaAllowed() const { return mIsMediaAllowed; } + BOOL switchTexture() ; //vertex buffer tracking @@ -293,6 +296,7 @@ private: F32 mImportanceToCamera ; F32 mBoundingSphereRadius ; bool mHasMedia ; + bool mIsMediaAllowed; protected: diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index f5f9d0d3cc..a2cec9a613 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -3481,7 +3481,10 @@ BOOL LLViewerMediaTexture::findFaces() U32 end = tex->getNumFaces(ch); for(U32 i = 0; i < end; i++) { - mMediaFaceList.push_back((*face_list)[i]); + if ((*face_list)[i]->isMediaAllowed()) + { + mMediaFaceList.push_back((*face_list)[i]); + } } } } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 943704c8de..2037aca7e9 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -881,6 +881,10 @@ LLDrawable *LLVOSky::createDrawable(LLPipeline *pipeline) mFace[FACE_MOON] = mDrawable->addFace(poolp, nullptr); mFace[FACE_BLOOM] = mDrawable->addFace(poolp, nullptr); + mFace[FACE_SUN]->setMediaAllowed(false); + mFace[FACE_MOON]->setMediaAllowed(false); + mFace[FACE_BLOOM]->setMediaAllowed(false); + return mDrawable; } -- cgit v1.2.3 From d33655828c104d1afe484b63093ad5aab1571a3c Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Thu, 5 Mar 2020 11:58:58 -0600 Subject: Reenable water fog in materialF.glsl (oops) --- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 586ce4a9b7..18293f4c11 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -421,16 +421,16 @@ void main() color = scaleSoftClipFrag(color); -/*#ifdef WATER_FOG +#ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; al = temp.a; -#endif*/ +#endif } - - color.rgb = linear_to_srgb(color.rgb); + color.rgb = linear_to_srgb(color.rgb); + frag_color = vec4(color, al); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer -- cgit v1.2.3 From 7c7d71269f5b47397d14bbe44e341e4ac1d96889 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Thu, 5 Mar 2020 16:28:06 -0600 Subject: WIP - Windlight sun lighting should happen in sRGB space, not linear space. This keeps ambient from getting overblown and better matches environment lighting with ALM on/off. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 10 ++++++---- .../shaders/class1/deferred/materialF.glsl | 18 ++++++++++-------- .../shaders/class1/deferred/multiSpotLightF.glsl | 18 ++++++++++++------ .../class1/deferred/postDeferredGammaCorrect.glsl | 1 + .../shaders/class1/deferred/softenLightF.glsl | 11 +++++------ .../shaders/class1/windlight/atmosphericsFuncs.glsl | 3 ++- .../shaders/class2/deferred/multiSpotLightF.glsl | 8 +++++--- .../shaders/class2/deferred/softenLightF.glsl | 6 +++--- .../shaders/class2/deferred/spotLightF.glsl | 3 ++- .../shaders/class3/deferred/multiSpotLightF.glsl | 3 ++- .../shaders/class3/deferred/softenLightF.glsl | 6 ++++-- .../shaders/class3/deferred/spotLightF.glsl | 2 +- 12 files changed, 53 insertions(+), 36 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 814d5036db..e38eeab370 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -251,7 +251,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; vec3 post_diffuse = color.rgb; @@ -261,6 +261,11 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); + color.rgb = scaleSoftClipFrag(color.rgb); + + //convert to linear before applying local lights + color.rgb = srgb_to_linear(color.rgb); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) @@ -275,9 +280,6 @@ vec3 post_atmo = color.rgb; #if !defined(LOCAL_LIGHT_KILL) color.rgb += light.rgb; #endif - - color.rgb = scaleSoftClipFrag(color.rgb); - // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 18293f4c11..e4ebf0edee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -117,7 +117,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 - + //angular attenuation da *= dot(n, lv); @@ -215,8 +215,7 @@ void main() vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy); diffuse_tap.rgb *= vertex_color.rgb; - //diffuse_tap = vec4(1,1,1,1); - + //#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vec4 diffuse_srgb = diffuse_tap; vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); @@ -349,7 +348,7 @@ void main() color.rgb += sun_contrib; #endif - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; float glare = 0.0; @@ -397,11 +396,15 @@ void main() } color = atmosFragLighting(color, additive, atten); + color = scaleSoftClipFrag(color); vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); + //convert to linear before adding local lights + color.rgb = srgb_to_linear(color.rgb); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w ); LIGHT_LOOP(1) @@ -419,8 +422,9 @@ void main() color.rgb += light.rgb; #endif - color = scaleSoftClipFrag(color); - +//convert to srgb as this color is being written post gamma correction + color.rgb = linear_to_srgb(color.rgb); + #ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; @@ -429,8 +433,6 @@ void main() } - color.rgb = linear_to_srgb(color.rgb); - frag_color = vec4(color, al); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index a690cc45a8..9bba45bc4e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -163,15 +163,19 @@ void main() proj_tc.xyz /= proj_tc.w; float fa = falloff+1.0; - float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; + if (dist_atten <= 0.0) { discard; } + float noise = texture2D(noiseMap, frag.xy/128.0).b; + dist_atten *= noise; + lv = proj_origin-pos.xyz; lv = normalize(lv); float da = dot(norm, lv); @@ -179,12 +183,13 @@ void main() vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; // SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space. - // We can't switch to linear here unless we do it everywhere - //diff_tex.rgb = srgb_to_linear(diff_tex.rgb); + // We can't switch to linear here unless we do it everywhere* + // *gbuffer is sRGB, convert to linear whenever sampling from it + diff_tex.rgb = srgb_to_linear(diff_tex.rgb); vec3 dlit = vec3(0, 0, 0); - float noise = texture2D(noiseMap, frag.xy/128.0).b; + if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && proj_tc.y < 1.0 && @@ -203,7 +208,7 @@ void main() dlit = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; + lit = da * dist_atten; col = dlit*lit*diff_tex; amb_da += (da*0.5)*proj_ambiance; @@ -245,7 +250,7 @@ void main() col += dlit*scol*spec.rgb; //col += spec.rgb; } - } + } if (envIntensity > 0.0) { @@ -277,6 +282,7 @@ void main() } #endif + //output linear, sum of lights will be gamma corrected later frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 966c73ef24..cd37a34e0d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -43,6 +43,7 @@ vec3 linear_to_srgb(vec3 cl); void main() { + //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); //diff.rgb = pow(diff.rgb, vec3(display_gamma)); diff.rgb = linear_to_srgb(diff.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index da2eb47e3b..19e737326d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -119,7 +119,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; vec3 post_diffuse = color.rgb; @@ -199,9 +199,6 @@ vec3 post_atmo = color.rgb; //color.rgb = post_env; //color.rgb = post_atmo; -// convert to linear as fullscreen lights need to sum in linear colorspace -// and will be gamma (re)corrected downstream... - //color.rgb = srgb_to_linear(color.rgb); } // linear debuggables @@ -209,7 +206,9 @@ vec3 post_atmo = color.rgb; //color.rgb = vec3(ambient); //color.rgb = vec3(scol); //color.rgb = diffuse_linear.rgb; - - frag_color.rgb = color.rgb; + + // convert to linear as fullscreen lights need to sum in linear colorspace + // and will be gamma (re)corrected downstream... + frag_color.rgb = srgb_to_linear(color.rgb); frag_color.a = 0.0; //bloom; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index e5f1e11180..dcb02bd1c1 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -46,6 +46,7 @@ float getAmbientClamp() return 1.0f; } + void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao) { vec3 P = inPositionEye; @@ -123,7 +124,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou temp2.x *= sun_moon_glow_factor; vec4 amb_color = ambient_color; - + //increase ambient when there are more clouds vec4 tmpAmbient = amb_color + (vec4(1.) - amb_color) * cloud_shadow * 0.5; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 7cde67d11b..5d7a28c359 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -192,8 +192,9 @@ void main() vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; // SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space. - // We can't switch to linear here unless we do it everywhere - //diff_tex.rgb = srgb_to_linear(diff_tex.rgb); + // We can't switch to linear here unless we do it everywhere* + // *gbuffer IS sRGB, convert to linear since this shader outputs linear + diff_tex.rgb = srgb_to_linear(diff_tex.rgb); vec4 spec = texture2DRect(specularRect, frag.xy); @@ -296,6 +297,7 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); - frag_color.rgb = col; + //output linear + frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index bacdb6f70f..58d573c724 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -106,7 +106,7 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true); - + float ambient = da; ambient *= 0.5; ambient *= ambient; @@ -127,7 +127,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; vec3 post_diffuse = color.rgb; @@ -218,6 +218,6 @@ vec3 post_atmo = color.rgb; //output linear RGB as lights are summed up in linear space and then gamma corrected prior to the //post deferred passes - frag_color.rgb = color.rgb; + frag_color.rgb = srgb_to_linear(color.rgb); frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 77f6e6f7ac..5ab0b5c5b4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -189,7 +189,7 @@ void main() lv = normalize(lv); float da = dot(norm, lv); - vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb); vec4 spec = texture2DRect(specularRect, frag.xy); vec3 dlit = vec3(0, 0, 0); @@ -287,6 +287,7 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); + //output linear colors as gamma correction happens down stream frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index 52de7ceaad..9d62b9d180 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -183,7 +183,7 @@ void main() vec3 col = vec3(0,0,0); - vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb); vec4 spec = texture2DRect(specularRect, frag.xy); @@ -285,6 +285,7 @@ void main() col = scaleDownLight(col); + //output linear space color as gamma correction happens down stream frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 978c25b86a..7ed9e7b4fc 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -94,7 +94,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - vec4 diffuse = texture2DRect(diffuseRect, tc); // linear + vec4 diffuse = texture2DRect(diffuseRect, tc); // sRGB + diffuse.rgb = srgb_to_linear(diffuse.rgb); vec3 col; float bloom = 0.0; @@ -169,7 +170,8 @@ void main() bloom = fogged.a; #endif } - + + //output linear since gamma correction happens down stream frag_color.rgb = col; frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index bccd819a43..56b0f4e5ce 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -182,7 +182,7 @@ void main() vec3 col = vec3(0,0,0); - vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb); vec4 spec = texture2DRect(specularRect, frag.xy); -- cgit v1.2.3 From 7d0cf70e4f335056e0d81b0b48264e5dda5be668 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 6 Mar 2020 11:05:55 -0600 Subject: Fix for under water being much brighter and mismatching between alpha and deferred. Don't make terrain fullbright under water. --- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 7 ++----- indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl | 8 -------- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 4 ---- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 19e737326d..54abd56625 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -154,11 +154,7 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; -#ifdef WATER_FOG - color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25; -#else color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a); -#endif if (envIntensity > 0.0) { //add environmentmap @@ -209,6 +205,7 @@ vec3 post_atmo = color.rgb; // convert to linear as fullscreen lights need to sum in linear colorspace // and will be gamma (re)corrected downstream... + frag_color.rgb = srgb_to_linear(color.rgb); - frag_color.a = 0.0; //bloom; + frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index b7bc92c460..6b6eed9db8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl @@ -44,10 +44,6 @@ VARYING vec4 vary_texcoord1; vec2 encode_normal(vec3 n); -#ifdef WATER_FOG -vec4 applyWaterFogView(vec3 pos, vec4 c); -#endif - void main() { /// Note: This should duplicate the blending functionality currently used for the terrain rendering. @@ -63,10 +59,6 @@ void main() vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); outColor.a = 0.0; // yes, downstream atmospherics -#ifdef WATER_FOG - outColor = applyWaterFogView(pos.xyz, outColor); - outColor.a = 1.0; // no downstream atmo -#endif frag_data[0] = outColor; frag_data[1] = vec4(0.0,0.0,0.0,-1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 58d573c724..9ebacd59c7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -162,11 +162,7 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; -#ifdef WATER_FOG - color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25; -#else color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a); -#endif if (envIntensity > 0.0) { //add environmentmap -- cgit v1.2.3 From a3759b4910b94b3a375e16e605dc1a4f096f2256 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 6 Mar 2020 13:54:27 -0600 Subject: Fix for sky in wrong color space. --- indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 2 +- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 54abd56625..1acb8d08eb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -154,7 +154,7 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; - color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a); + color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); if (envIntensity > 0.0) { //add environmentmap diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9ebacd59c7..6f5b0981f9 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -162,7 +162,7 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; - color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a); + color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); if (envIntensity > 0.0) { //add environmentmap -- cgit v1.2.3 From f0a9b6c01bc1e348969e3c4ac1e929aefa538ea8 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 6 Mar 2020 14:27:46 -0600 Subject: Fix for sunlight having improper gamma curve for angular attenuation. Fix for lack of angular attenuation on ambient lighting on triangles facing away from sun. --- indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 3 ++- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 1acb8d08eb..b38f488a1f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -82,6 +82,7 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); + da = pow(da, 1.0/1.3); vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); @@ -99,7 +100,7 @@ void main() calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, false); - float ambient = da; + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 6f5b0981f9..da78691861 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -86,7 +86,7 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); - + da = pow(da, 1.0/1.3); vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); @@ -107,7 +107,7 @@ void main() calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true); - float ambient = da; + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); -- cgit v1.2.3 From 0390dc2fec2afdc053f373813d419178a70b299c Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 6 Mar 2020 14:33:58 -0600 Subject: Fix for mismatch on angular attenuation between sunlight on opaque and transparent objects from last commit. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 5 +++-- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e38eeab370..dc484317e9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -223,6 +223,7 @@ void main() float da = dot(norm.xyz, light_dir.xyz); da = clamp(da, -1.0, 1.0); + da = pow(da, 1.0/1.3); float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); @@ -231,7 +232,7 @@ void main() color.a = final_alpha; - float ambient = da; + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); @@ -262,7 +263,7 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); color.rgb = scaleSoftClipFrag(color.rgb); - + //convert to linear before applying local lights color.rgb = srgb_to_linear(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index e4ebf0edee..d07de529ca 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -331,8 +331,9 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); + da = pow(da, 1.0/1.3); - float ambient = da; + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); -- cgit v1.2.3 From d32821ea5bf17c4de47b9ee03b43a20ae278dfe4 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 6 Mar 2020 17:20:46 -0800 Subject: SL-12574 Fix EEP cubemap not matching non-EEP for both ALM on and off --- .../newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl | 2 +- indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 2 +- .../app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl | 2 +- indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl | 2 +- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl index 4005d5064d..523e7f9e04 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl @@ -56,7 +56,7 @@ void main() color.rgb *= vertex_color.rgb; vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; - color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a*0.75); // MAGIC NUMBER SL-12574; ALM: Off, Quality > Low color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index b38f488a1f..547a159f3a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -162,7 +162,7 @@ vec3 post_diffuse = color.rgb; vec3 env_vec = env_mat * refnormpersp; vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; #if !defined(SUNLIGHT_KILL) - color = mix(color.rgb, reflected_color, envIntensity); + color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality <= Mid+ #endif } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl index 64ecf1f392..567811cd75 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl @@ -44,7 +44,7 @@ void fullbright_shiny_lighting() color.rgb *= vertex_color.rgb; vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; - color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a*0.75); // MAGIC NUMBER SL-12574; ALM: Off, Quality > Low color.rgb = fullbrightShinyAtmosTransport(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl index 5bbd71002d..f621a00785 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl @@ -45,7 +45,7 @@ void shiny_lighting() color.rgb *= vertex_color.rgb; vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; - color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a*0.75); // MAGIC NUMBER SL-12574; ALM: Off, Quality > Low color.rgb = atmosLighting(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index da78691861..15a3bc349a 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -169,7 +169,7 @@ vec3 post_diffuse = color.rgb; vec3 env_vec = env_mat * refnormpersp; vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; #if !defined(SUNLIGHT_KILL) - color = mix(color.rgb, reflected_color, envIntensity); + color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality >= High #endif } -- cgit v1.2.3 From 3f96aeff8c84e55164ce5d652e38041b4e1db82b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 10 Mar 2020 16:33:55 +0200 Subject: SL-12817 New text for snapshot upload --- indra/newview/llpanelsnapshotinventory.cpp | 1 - .../default/xui/en/panel_outfit_snapshot_inventory.xml | 6 ++++-- .../skins/default/xui/en/panel_snapshot_inventory.xml | 2 +- .../skins/default/xui/en/panel_snapshot_options.xml | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index 594cbed7ad..9e56a04b3b 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -136,7 +136,6 @@ BOOL LLPanelSnapshotInventory::postBuild() // virtual void LLPanelSnapshotInventory::onOpen(const LLSD& key) { - getChild("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost())); LLPanelSnapshot::onOpen(key); } diff --git a/indra/newview/skins/default/xui/en/panel_outfit_snapshot_inventory.xml b/indra/newview/skins/default/xui/en/panel_outfit_snapshot_inventory.xml index ace0ee01e2..441cf97e87 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_snapshot_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_snapshot_inventory.xml @@ -41,7 +41,7 @@ - Uploading an image to your inventory costs L$[UPLOAD_COST]. +Uploading an image to your inventory costs L$[UPLOAD_COST]. + +Fee is based on your subscription level. Higher levels are charged lower fees. + + Fee is based on your subscription level. Higher levels are charged lower fees. + \ No newline at end of file -- cgit v1.2.3 From f9eada575bfa46a1da5aeaf27c73537a9b86aa76 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 10 Mar 2020 00:21:52 -0600 Subject: SL-12592, avoid light modulation of fullbright and preserve diffuse alpha component --- .../shaders/class1/deferred/materialF.glsl | 191 +++++++++++---------- 1 file changed, 96 insertions(+), 95 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index d07de529ca..21a462e2db 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -1,28 +1,28 @@ -/** - * @file materialF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - +/** +* @file materialF.glsl +* +* $LicenseInfo:firstyear=2007&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2007, 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$ +*/ + /*[EXTRA_CODE_HERE]*/ //class1/deferred/materialF.glsl @@ -34,7 +34,7 @@ #define DIFFUSE_ALPHA_MODE_MASK 2 #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 -uniform float emissive_brightness; +uniform float emissive_brightness; // fullbright flag, 1.0 == fullbright, 0.0 otherwise uniform int sun_up_factor; #ifdef WATER_FOG @@ -52,13 +52,13 @@ vec3 linear_to_srgb(vec3 cs); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) #ifdef DEFINE_GL_FRAGCOLOR - out vec4 frag_color; +out vec4 frag_color; #else - #define frag_color gl_FragColor +#define frag_color gl_FragColor #endif #ifdef HAS_SUN_SHADOW - float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif uniform samplerCube environmentMap; @@ -81,7 +81,7 @@ uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; -uniform vec4 light_attenuation[8]; +uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; float getAmbientClamp(); @@ -91,7 +91,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe vec3 col = vec3(0); //get light vector - vec3 lv = lp.xyz-v; + vec3 lv = lp.xyz - v; //get distance float dist = length(lv); @@ -103,21 +103,21 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe { //normalize light vector lv = normalize(lv); - + //distance attenuation - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist_atten = clamp(1.0 - (dist - 1.0*(1.0 - fa)) / fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0f; if (dist_atten <= 0.0) { - return col; + return col; } // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 - + //angular attenuation da *= dot(n, lv); @@ -126,9 +126,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe float amb_da = ambiance; if (da >= 0) { - lit = max(da * dist_atten,0.0); + lit = max(da * dist_atten, 0.0); col = lit * light_col * diffuse; - amb_da += (da*0.5+0.5) * ambiance; + amb_da += (da*0.5 + 0.5) * ambiance; } amb_da += (da*da*0.5 + 0.5) * ambiance; amb_da *= dist_atten; @@ -140,19 +140,19 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe if (spec.a > 0.0) { //vec3 ref = dot(pos+lv, norm); - vec3 h = normalize(lv+npos); + vec3 h = normalize(lv + npos); float nh = dot(n, h); float nv = dot(n, npos); float vh = dot(npos, h); float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + float fres = pow(1 - dot(h, npos), 5)*0.4 + 0.5; float gtdenom = 2 * nh; float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - + if (nh > 0.0) { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt / (nh*da); vec3 speccol = lit*scol*light_col.rgb*spec.rgb; speccol = clamp(speccol, vec3(0), vec3(1)); col += speccol; @@ -165,7 +165,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe } } - return max(col, vec3(0.0,0.0,0.0)); + return max(col, vec3(0.0, 0.0, 0.0)); } #else @@ -213,16 +213,9 @@ void main() { vec2 pos_screen = vary_texcoord0.xy; - vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy); - diffuse_tap.rgb *= vertex_color.rgb; - -//#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vec4 diffuse_srgb = diffuse_tap; + vec4 diffuse_srgb = texture2D(diffuseMap, vary_texcoord0.xy); + diffuse_srgb.rgb *= vertex_color.rgb; vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); -/*#else - vec4 diffuse_linear = diffuse_tap; - vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); -#endif*/ #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) if (diffuse_linear.a < minimum_alpha) @@ -248,15 +241,15 @@ void main() // convert sampled normal to tangent space normal norm = vec3(dot(norm, vary_mat0), - dot(norm, vary_mat1), - dot(norm, vary_mat2)); + dot(norm, vary_mat1), + dot(norm, vary_mat2)); #else norm = vary_normal; #endif norm = normalize(norm); - vec2 abnormal = encode_normal(norm); + vec2 abnormal = encode_normal(norm); vec4 final_color = vec4(diffuse_linear.rgb, 0.0); @@ -286,7 +279,7 @@ void main() float al = 0; #ifdef HAS_SPECULAR_MAP - if (emissive_brightness >= 1.0) + if (emissive_brightness >= 1.0) // ie, if fullbright { float ei = env_intensity*0.5 + 0.5; final_normal = vec4(abnormal, ei, 0.0); @@ -304,34 +297,43 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - { - //forward rendering, output just lit sRGBA - vec3 pos = vary_position; - float shadow = 1.0f; + //forward rendering, output just lit sRGBA + vec3 pos = vary_position; + + float shadow = 1.0f; #ifdef HAS_SUN_SHADOW - shadow = sampleDirectionalShadow(pos.xyz, norm, pos_screen); + shadow = sampleDirectionalShadow(pos.xyz, norm, pos_screen); #endif - spec = final_specular; + spec = final_specular; - float envIntensity = final_normal.z; + float envIntensity = final_normal.z; - vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float bloom = 0.0; - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; + float bloom = 0.0; + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; - calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); + if (emissive_brightness >= 1.0) // fullbright, skip lighting calculations + { + // just do atmos attenuation (ad hoc 60% factor to match release viewer) + color = atmosFragLighting(diffuse_srgb.rgb, additive, atten*0.6); + color = scaleSoftClipFrag(color); + al = diffuse_srgb.a; + } + else // not fullbright, calculate lighting + { vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); - da = pow(da, 1.0/1.3); + da = pow(da, 1.0 / 1.3); float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; @@ -341,16 +343,15 @@ void main() vec3 sun_contrib = min(da, shadow) * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit; - color.rgb *= ambient; + color = amblit; + color *= ambient; #endif #if !defined(SUNLIGHT_KILL) - color.rgb += sun_contrib; + color += sun_contrib; #endif + color *= diffuse_srgb.rgb; - color.rgb *= diffuse_srgb.rgb; - float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -358,19 +359,19 @@ void main() vec3 npos = -normalize(pos.xyz); //vec3 ref = dot(pos+lv, norm); - vec3 h = normalize(light_dir.xyz+npos); + vec3 h = normalize(light_dir.xyz + npos); float nh = dot(norm, h); float nv = dot(norm, npos); float vh = dot(npos, h); float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + float fres = pow(1 - dot(h, npos), 5)*0.4 + 0.5; float gtdenom = 2 * nh; float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); if (nh > 0.0) { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt / (nh*da); vec3 sp = sun_contrib*scol / 6.0f; sp = clamp(sp, vec3(0), vec3(1)); bloom = dot(sp, sp) / 4.0; @@ -384,11 +385,11 @@ void main() { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - + vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; #if !defined(SUNLIGHT_KILL) - color = mix(color.rgb, reflected_color, envIntensity); + color = mix(color, reflected_color, envIntensity); #endif float cur_glare = max(reflected_color.r, reflected_color.g); cur_glare = max(cur_glare, reflected_color.b); @@ -401,14 +402,14 @@ void main() vec3 npos = normalize(-pos.xyz); - vec3 light = vec3(0,0,0); + vec3 light = vec3(0, 0, 0); //convert to linear before adding local lights - color.rgb = srgb_to_linear(color.rgb); + color = srgb_to_linear(color); #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w ); - LIGHT_LOOP(1) + LIGHT_LOOP(1) LIGHT_LOOP(2) LIGHT_LOOP(3) LIGHT_LOOP(4) @@ -416,25 +417,25 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - glare = min(glare, 1.0); - al = max(diffuse_linear.a,glare)*vertex_color.a; + glare = min(glare, 1.0); + al = max(diffuse_linear.a, glare)*vertex_color.a; #if !defined(LOCAL_LIGHT_KILL) - color.rgb += light.rgb; + color += light; #endif -//convert to srgb as this color is being written post gamma correction - color.rgb = linear_to_srgb(color.rgb); - + //convert to srgb as this color is being written post gamma correction + color = linear_to_srgb(color); + } + #ifdef WATER_FOG - vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); - color.rgb = temp.rgb; - al = temp.a; + vec4 temp = applyWaterFogView(pos, vec4(color, al)); + color = temp.rgb; + al = temp.a; #endif - } - - frag_color = vec4(color, al); + // Don't allow alpha to exceed input value - SL-12592 + frag_color = vec4(color, min(al, diffuse_srgb.a)); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer -- cgit v1.2.3 From 7d94bcf72918779c311d92db67a7f67e2c737c9d Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 10 Mar 2020 11:41:39 -0600 Subject: DRTVWR-440 Add compile switch SHADER_CRASH_NONFATAL to prevent app exit on shader failure --- indra/newview/llappviewer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 73a58fee16..118edb8beb 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2212,7 +2212,9 @@ void errorCallback(const std::string &error_string) // static info file. LLAppViewer::instance()->writeDebugInfo(); +#ifndef SHADER_CRASH_NONFATAL LLError::crashAndLoop(error_string); +#endif } void LLAppViewer::initLoggingAndGetLastDuration() -- cgit v1.2.3 From b1e2615cd80f27dac6712995edcc890df021041a Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 10 Mar 2020 12:35:12 -0700 Subject: SL-12171 Fix emissive mask being too bright post sRGB/Linear cleanup --- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 21a462e2db..5999063ae5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -254,7 +254,7 @@ void main() vec4 final_color = vec4(diffuse_linear.rgb, 0.0); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_EMISSIVE) - final_color.a = diffuse_linear.a; + final_color.a = diffuse_linear.a * 0.5; // SL-12171 #endif final_color.a = max(final_color.a, emissive_brightness); -- cgit v1.2.3 From 13c8496799581ad88d4ef1f1dd84bcbf331edb5b Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Tue, 10 Mar 2020 23:29:32 +0200 Subject: SL-12779 [EEP] Fix for cropped buttons in 'Edit Day Cycle' floater --- indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 6869eefda2..30e9002230 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 @@ -260,7 +260,7 @@ Date: Thu, 12 Mar 2020 13:22:32 -0600 Subject: DRTVWR-440 fix 'unreachable code' warning-as-error when buildin /Od --- indra/newview/llweb.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index 840eb06acf..a34c5826ed 100644 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -247,6 +247,5 @@ bool LLWeb::useExternalBrowser(const std::string &url) boost::match_results matches; return boost::regex_search(url, matches, pattern); } - return false; #endif } -- cgit v1.2.3 From c7f2712d9576c0122726104f74690c1ee5f94ae2 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 12 Mar 2020 16:52:48 -0600 Subject: SL-12784 restore vertex color alpha contribution --- indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 5999063ae5..553c2f3045 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -214,7 +214,7 @@ void main() vec2 pos_screen = vary_texcoord0.xy; vec4 diffuse_srgb = texture2D(diffuseMap, vary_texcoord0.xy); - diffuse_srgb.rgb *= vertex_color.rgb; + diffuse_srgb *= vertex_color; vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) -- cgit v1.2.3 From 6708b382ac2cbb42f01ec08ee300840a43bb59b5 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 12 Mar 2020 18:37:10 -0700 Subject: SL-12781 Fix Upload 3D Preview not using z-buffer --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d6ff9bd548..fda79984ab 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1250,7 +1250,7 @@ void LLPipeline::createGLBuffers() } // Use FBO for bake tex - mBake.allocate(512, 512, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, true); + mBake.allocate(512, 512, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, true); // SL-12781 Build > Upload > Model; 3D Preview mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE); -- cgit v1.2.3 From 36499c7526682e999648250d39a6d0960d9b72a5 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 12 Mar 2020 18:38:05 -0700 Subject: SL-12781 Cleanup: Update out-of-date color comment --- indra/newview/llfloatermodelpreview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index f32f34c354..267e88612c 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3652,7 +3652,7 @@ BOOL LLModelPreview::render() { gUIProgram.bind(); } - //clear background to blue + //clear background to grey gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); -- cgit v1.2.3 From fe4549c950e5cfcb143650e4d6693bc87db6e011 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 12 Mar 2020 18:40:11 -0700 Subject: SL-12781 Cleanup: Rename non-descript generic var name --- indra/newview/llfloatermodelpreview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 267e88612c..13ac583c1c 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3920,9 +3920,9 @@ BOOL LLModelPreview::render() { glClear(GL_DEPTH_BUFFER_BIT); - for (U32 i = 0; i < 2; i++) + for (U32 pass = 0; pass < 2; pass++) { - if (i == 0) + if (pass == 0) { //depth only pass gGL.setColorMask(false, false); } @@ -3932,7 +3932,7 @@ BOOL LLModelPreview::render() } //enable alpha blending on second pass but not first pass - LLGLState blend(GL_BLEND, i); + LLGLState blend(GL_BLEND, pass); gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); -- cgit v1.2.3 From b67df8184f273294b1703df25b012dfa0ad36d28 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 12 Mar 2020 18:42:14 -0700 Subject: SL-12781 Cleanup: Remove HACK / MAGIC NUMBER effective constant of mCameraDistance as it is set in setPreviewTarget() via initModelPreview() --- indra/newview/llfloatermodelpreview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 13ac583c1c..d808d4588a 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -108,6 +108,10 @@ const double RETAIN_COEFFICIENT = 100; // So this const is used as a size of Smooth combobox list. const S32 SMOOTH_VALUES_NUMBER = 10; +// mCameraDistance +// Also see: mCameraZoom +const F32 MODEL_PREVIEW_CAMERA_DISTANCE = 16.f; + void drawBoxOutline(const LLVector3& pos, const LLVector3& size); @@ -431,7 +435,7 @@ void LLFloaterModelPreview::initModelPreview() } mModelPreview = new LLModelPreview(512, 512, this ); - mModelPreview->setPreviewTarget(16.f); + mModelPreview->setPreviewTarget(MODEL_PREVIEW_CAMERA_DISTANCE); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::modelUpdated, this, _1)); } @@ -3780,7 +3784,6 @@ BOOL LLModelPreview::render() target_pos = getPreviewAvatar()->getPositionAgent(); z_near = 0.01f; z_far = 1024.f; - mCameraDistance = 16.f; //render avatar previews every frame refresh(); -- cgit v1.2.3 From 2b0b3e86258bef6d4b8a51c519626b9492200025 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 12 Mar 2020 18:45:02 -0700 Subject: SL-12781 Remove expensive and redundant z clear; instead enable/disable z test for background and model preview --- indra/newview/llfloatermodelpreview.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index d808d4588a..8a894c4ec8 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3645,10 +3645,9 @@ BOOL LLModelPreview::render() S32 width = getWidth(); S32 height = getHeight(); - LLGLSUIDefault def; + LLGLSUIDefault def; // GL_BLEND, GL_ALPHA_TEST, GL_CULL_FACE, depth test LLGLDisable no_blend(GL_BLEND); - LLGLEnable cull(GL_CULL_FACE); - LLGLDepthTest depth(GL_TRUE); + LLGLDepthTest depth(GL_FALSE); // SL-12781 disable z-buffer to render background color LLGLDisable fog(GL_FOG); { @@ -3761,7 +3760,7 @@ BOOL LLModelPreview::render() F32 explode = mFMP->childGetValue("physics_explode").asReal(); - glClear(GL_DEPTH_BUFFER_BIT); + LLGLDepthTest gls_depth(GL_TRUE); // SL-12781 re-enable z-buffer for 3D model preview LLRect preview_rect; -- cgit v1.2.3 From 0a0cfcf2ef92375f099ed91f009db1ebf2d410c0 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 13 Mar 2020 12:58:47 -0500 Subject: SL-12233 Fix for disagreement between fullbright implementations with ALM on and off. --- .../app_settings/shaders/class1/deferred/emissiveF.glsl | 1 - .../shaders/class1/deferred/fullbrightF.glsl | 6 ++---- .../app_settings/shaders/class1/deferred/materialF.glsl | 16 ++++++++++++---- .../shaders/class2/windlight/transportF.glsl | 9 +++++++-- .../shaders/class3/windlight/transportF.glsl | 9 +++++++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl index 0ffca8515c..f0522850de 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -44,7 +44,6 @@ void main() float shadow = 1.0; vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; - color.rgb = pow(color.rgb, vec3(2.2)); color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index c104dc884f..46ec20c8b0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -79,11 +79,9 @@ void main() color.rgb = fogged.rgb; color.a = fogged.a; #else - color.rgb = srgb_to_linear(color.rgb); - color.rgb = fullbrightAtmosTransport(color.rgb); + color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); - color.rgb = linear_to_srgb(color.rgb); - color.a = final_alpha; + color.a = final_alpha; #endif frag_color.rgb = color.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 5999063ae5..a69653fe4e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -44,6 +44,9 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); +vec3 fullbrightScaleSoftClip(vec3 light); + void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); vec3 srgb_to_linear(vec3 cs); @@ -320,21 +323,26 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); - + if (emissive_brightness >= 1.0) // fullbright, skip lighting calculations { - // just do atmos attenuation (ad hoc 60% factor to match release viewer) - color = atmosFragLighting(diffuse_srgb.rgb, additive, atten*0.6); - color = scaleSoftClipFrag(color); + color = fullbrightAtmosTransportFrag(diffuse_srgb.rgb, additive, atten); + color = fullbrightScaleSoftClip(color); + al = diffuse_srgb.a; } else // not fullbright, calculate lighting { vec3 refnormpersp = normalize(reflect(pos.xyz, norm)); + //we're in sRGB space, so gamma correct this dot product so + // lighting from the sun stays sharp float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); da = pow(da, 1.0 / 1.3); + //darken ambient for normals perpendicular to light vector so surfaces in shadow + // and facing away from light still have some definition to them. + // do NOT gamma correct this dot product so ambient lighting stays soft float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index 8fc5d750e3..f69d36f715 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -49,10 +49,15 @@ vec3 atmosTransport(vec3 light) return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } -vec3 fullbrightAtmosTransport(vec3 light) +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - return atmosTransportFrag(light * 0.5, getAdditiveColor() * brightness, getAtmosAttenuation()); + return atmosTransportFrag(light * 0.5, additive * brightness, atten); +} + +vec3 fullbrightAtmosTransport(vec3 light) +{ + return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } vec3 fullbrightShinyAtmosTransport(vec3 light) diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl index 18705f785f..aa7dbc39ce 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl @@ -49,10 +49,15 @@ vec3 atmosTransport(vec3 light) return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } -vec3 fullbrightAtmosTransport(vec3 light) +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { float brightness = dot(light.rgb, vec3(0.33333)); - return atmosTransportFrag(light * 0.5, getAdditiveColor() * (brightness * 0.5 + 0.5), getAtmosAttenuation()); + return atmosTransportFrag(light * 0.5, additive * (brightness * 0.5 + 0.5), atten); +} + +vec3 fullbrightAtmosTransport(vec3 light) +{ + return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } vec3 fullbrightShinyAtmosTransport(vec3 light) -- cgit v1.2.3 From 744872b43d4b538a828dad116c46eed3d6d35436 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 13 Mar 2020 11:46:13 -0700 Subject: SL-12850 --- .../newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 6 +++--- .../newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 547a159f3a..69a694a6cd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -154,8 +154,6 @@ vec3 post_diffuse = color.rgb; } vec3 post_spec = color.rgb; - - color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); if (envIntensity > 0.0) { //add environmentmap @@ -165,7 +163,9 @@ vec3 post_diffuse = color.rgb; color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality <= Mid+ #endif } - + else + color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); + vec3 post_env = color.rgb; if (norm.w < 1) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 15a3bc349a..63b0f0b5c8 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -161,8 +161,6 @@ vec3 post_diffuse = color.rgb; } vec3 post_spec = color.rgb; - - color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); if (envIntensity > 0.0) { //add environmentmap @@ -170,9 +168,12 @@ vec3 post_diffuse = color.rgb; vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; #if !defined(SUNLIGHT_KILL) color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality >= High +//color.rgb = reflected_color.rgb; #endif } - + else + color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); + vec3 post_env = color.rgb; if (norm.w < 1) -- cgit v1.2.3 From bedbbdc5c39a4ae684c0b8e569dae4bb0d7b314c Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 13 Mar 2020 12:35:12 -0700 Subject: SL-12850 remove debug --- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 63b0f0b5c8..a1366eec01 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -168,7 +168,6 @@ vec3 post_diffuse = color.rgb; vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; #if !defined(SUNLIGHT_KILL) color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality >= High -//color.rgb = reflected_color.rgb; #endif } else -- cgit v1.2.3 From 3792c3c7debb428d9727136afaa8b16d312abd42 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 13 Mar 2020 12:37:14 -0700 Subject: SL-12850 Adhere to coding standard --- indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | 2 ++ indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 69a694a6cd..20ac78947b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -164,7 +164,9 @@ vec3 post_diffuse = color.rgb; #endif } else + { color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); + } vec3 post_env = color.rgb; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index a1366eec01..9c7a4df767 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -171,7 +171,9 @@ vec3 post_diffuse = color.rgb; #endif } else + { color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); + } vec3 post_env = color.rgb; -- cgit v1.2.3 From 09b13b3981f121f20674b874f47f96bef2ac73ce Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 13 Mar 2020 14:59:11 -0600 Subject: SL-12784 disambiguate vertex_color.a of 0 --- .../app_settings/shaders/class1/deferred/materialF.glsl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index ca11f58888..a8a5cc22db 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -217,7 +217,16 @@ void main() vec2 pos_screen = vary_texcoord0.xy; vec4 diffuse_srgb = texture2D(diffuseMap, vary_texcoord0.xy); - diffuse_srgb *= vertex_color; + diffuse_srgb.rgb *= vertex_color.rgb; + + // For some reason the Transparency slider sets vertex_color.a to 0.0 both for + // fully opaque and for fully transparent objects. This code assumes the 0 alpha + // is always from the opaque end of the scale. TODO: Remove the conditional once + // the root cause of the slider ambiguity is fixed. + if (vertex_color.a > 0.0) + { + diffuse_srgb.a *= vertex_color.a; + } vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) -- cgit v1.2.3 From 5f0303eea5a30c914b61d5de6ade3697e551f9c6 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 13 Mar 2020 16:39:58 -0500 Subject: SL-12005 Fix for projectors getting brighter when switching to single light shader. --- indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 2216afe609..694b19cdfb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -177,9 +177,8 @@ void main() float da = dot(norm, lv); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; - // SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space. - // We can't switch to linear here unless we do it everywhere - //diff_tex.rgb = srgb_to_linear(diff_tex.rgb); + //light shaders output linear and are gamma corrected later in postDeferredGammaCorrectF.glsl + diff_tex.rgb = srgb_to_linear(diff_tex.rgb); vec4 spec = texture2DRect(specularRect, frag.xy); @@ -274,6 +273,7 @@ void main() } #endif + //col.r = 1.0; frag_color.rgb = col; frag_color.a = 0.0; } -- cgit v1.2.3 From 8c1b9d3e7a194c106ee79067e3136c37ea7e84e1 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Mon, 16 Mar 2020 12:10:34 -0500 Subject: Add missing fullbrightAtmosTransportFrag stub. --- indra/newview/app_settings/shaders/class1/windlight/transportF.glsl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl index 79d8d11b32..a937d9fa99 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl @@ -37,6 +37,12 @@ vec3 atmosTransport(vec3 light) return light; } +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + vec3 fullbrightAtmosTransport(vec3 light) { /* stub function for fallback compatibility on class1 hardware */ -- cgit v1.2.3 From 49239e8fe178c313771a1d8b389844761cd740ad Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 16 Mar 2020 19:43:14 -0700 Subject: SL-12574: Tweak sky cubemap to not be as dark to better match Windlight --- indra/newview/lllegacyatmospherics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index e061b3ad17..3c675f7c4f 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -254,7 +254,8 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm F32 brightness = vars.hazeColor.brightness(); F32 greyscale_sat = brightness * (1.0f - sky_saturation); LLColor3 sky_color = vars.hazeColor * sky_saturation + smear(greyscale_sat); - //sky_color *= (0.5f + 0.5f * brightness); // SL-12574 EEP sky was too dark dark grey/blue, lighten it slightly + //sky_color *= (0.5f + 0.5f * brightness); + sky_color *= (0.85f + 0.15f*brightness); // SL-12574 EEP sky is being attenuated too much; brighten it slightly until calcSkyColorWLVert() is fixed to match Windlight return LLColor4(sky_color, 0.0f); } -- cgit v1.2.3 From e85fe64a5649c5250299e6b9caeffc83fcfc409c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 17 Mar 2020 16:38:55 +0200 Subject: SL-12858 Fixed bad merge --- indra/newview/skins/default/xui/de/floater_about_land.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/skins/default/xui/de/floater_about_land.xml b/indra/newview/skins/default/xui/de/floater_about_land.xml index 8fb953d3ab..8f55b3297f 100644 --- a/indra/newview/skins/default/xui/de/floater_about_land.xml +++ b/indra/newview/skins/default/xui/de/floater_about_land.xml @@ -370,8 +370,8 @@ Nur große Parzellen können in der Suche aufgeführt werden. Landepunkt: [LANDING] -