diff options
252 files changed, 7520 insertions, 5487 deletions
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 0851d20be0..c68131402b 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -5,7 +5,11 @@ a0b3021bdcf76859054fda8e30abb3ed47749e83 8444cd9562a6a7b755fcb075864e205122354192 863c541ce0b2e3e1e566cc88423d3e87aaedb6ca +743a1a6d8eabf069d95777c96e5b657cb8702593 +4a00da1ada89af6f313cee30f5177634b0b180a9 # Wrong line endings 1b67dd855c41f5a0cda7ec2a68d98071986ca703 6cc7dd09d5e69cf57e6de7fb568a0ad2693f9c9a e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 +# multiple problems +5370a6d323e14d7b4e32a3f41ef78f7744e361c5 diff --git a/autobuild.xml b/autobuild.xml index 24ccfa1f7a..17fbbee9c8 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -2223,6 +2223,68 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>description</key> <string>Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) Library</string> </map> + <key>openxr</key> + <map> + <key>platforms</key> + <map> + <key>windows64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>3cccc3e3f3137066c286270b35abc00ee0c0bb0c</string> + <key>hash_algorithm</key> + <string>sha1</string> + <key>url</key> + <string>https://github.com/secondlife/3p-openxr/releases/download/v1.1.40-r1/openxr-1.1.40-r1-windows64-10710818432.tar.zst</string> + </map> + <key>name</key> + <string>windows64</string> + </map> + <key>linux64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>f0ad0418a98fb8cb6e158fca3902c15ac1de9d2a</string> + <key>hash_algorithm</key> + <string>sha1</string> + <key>url</key> + <string>https://github.com/secondlife/3p-openxr/releases/download/v1.1.40-r1/openxr-1.1.40-r1-linux64-10710818432.tar.zst</string> + </map> + <key>name</key> + <string>linux64</string> + </map> + <key>darwin64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>a9bfabec63a987bd34bcfdc295b928bd0696e1d7</string> + <key>hash_algorithm</key> + <string>sha1</string> + <key>url</key> + <string>https://github.com/secondlife/3p-openxr/releases/download/v1.1.40-r1/openxr-1.1.40-r1-darwin64-10710818432.tar.zst</string> + </map> + <key>name</key> + <string>darwin64</string> + </map> + </map> + <key>license</key> + <string>Apache 2.0</string> + <key>license_file</key> + <string>LICENSES/openxr.txt</string> + <key>copyright</key> + <string>Copyright 2017-2024, The Khronos Group Inc.</string> + <key>version</key> + <string>1.1.40-r1</string> + <key>name</key> + <string>openxr</string> + <key>canonical_repo</key> + <string>https://github.com/secondlife/3p-openxr</string> + <key>description</key> + <string>Generated headers and sources for OpenXR loader.</string> + </map> <key>slvoice</key> <map> <key>platforms</key> @@ -542,15 +542,6 @@ then fi fi -# Some of the uploads takes a long time to finish in the codeticket backend, -# causing the next codeticket upload attempt to fail. -# Inserting this after each potentially large upload may prevent those errors. -# JJ is making changes to Codeticket that we hope will eliminate this failure, then this can be removed -wait_for_codeticket() -{ - sleep $(( 60 * 6 )) -} - # check status and upload results to S3 if $succeeded then diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 1486024538..5cb25368d2 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -69,9 +69,12 @@ if (WINDOWS) /NODEFAULTLIB:LIBCMT /IGNORE:4099) - add_definitions( - -DNOMINMAX -# /DDOM_DYNAMIC # For shared library colladadom + add_compile_definitions( + WIN32_LEAN_AND_MEAN + NOMINMAX +# DOM_DYNAMIC # For shared library colladadom + _CRT_SECURE_NO_WARNINGS # Allow use of sprintf etc + _WINSOCK_DEPRECATED_NO_WARNINGS # Disable deprecated WinSock API warnings ) add_compile_options( /Zo @@ -107,9 +110,6 @@ if (WINDOWS) string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") endif() - - # Allow use of sprintf etc - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) endif (WINDOWS) if (LINUX) diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 10b17a6e26..b95c0d7ca8 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -25,6 +25,7 @@ set(cmake_SOURCE_FILES FreeType.cmake GLEXT.cmake GLH.cmake + GLM.cmake Havok.cmake Hunspell.cmake LLAddBuildTest.cmake diff --git a/indra/cmake/OpenXR.cmake b/indra/cmake/OpenXR.cmake new file mode 100644 index 0000000000..2cc862b927 --- /dev/null +++ b/indra/cmake/OpenXR.cmake @@ -0,0 +1,22 @@ +# -*- cmake -*- + +include(Prebuilt) + +include_guard() +add_library( ll::openxr INTERFACE IMPORTED ) + +if(USE_CONAN ) + target_link_libraries( ll::openxr INTERFACE CONAN_PKG::openxr ) + return() +endif() + +use_prebuilt_binary(openxr) +if (WINDOWS) + target_link_libraries( ll::openxr INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/openxr_loader.lib ) +else() + target_link_libraries( ll::openxr INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libopenxr_loader.a ) +endif (WINDOWS) + +if( NOT LINUX ) + target_include_directories( ll::openxr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) +endif() diff --git a/indra/cmake/Tracy.cmake b/indra/cmake/Tracy.cmake index d54a32fdc2..9eee9eb57f 100644 --- a/indra/cmake/Tracy.cmake +++ b/indra/cmake/Tracy.cmake @@ -6,12 +6,17 @@ add_library( ll::tracy INTERFACE IMPORTED ) # default Tracy profiling on for test builds, but off for all others string(TOLOWER ${VIEWER_CHANNEL} channel_lower) -if(WINDOWS AND channel_lower MATCHES "^second life test") +if(channel_lower MATCHES "^second life test") option(USE_TRACY "Use Tracy profiler." ON) else() option(USE_TRACY "Use Tracy profiler." OFF) endif() +if (LINUX) + # tracy currently conflicts with llcommon/stdtypes.h on linux. keep it disabled until we fix it + set(USE_TRACY OFF) +endif(LINUX) + if (USE_TRACY) option(USE_TRACY_ON_DEMAND "Use on-demand Tracy profiling." ON) option(USE_TRACY_LOCAL_ONLY "Disallow remote Tracy profiling." OFF) @@ -31,6 +36,11 @@ if (USE_TRACY) target_compile_definitions(ll::tracy INTERFACE -DTRACY_NO_BROADCAST=1 -DTRACY_ONLY_LOCALHOST=1) endif () + # GHA runners don't always provide invariant TSC support, but always build with LL_TESTS enabled + if (DARWIN AND LL_TESTS) + target_compile_definitions(ll::tracy INTERFACE -DTRACY_TIMER_FALLBACK=1) + endif () + # See: indra/llcommon/llprofiler.h add_compile_definitions(LL_PROFILER_CONFIGURATION=3) endif (USE_TRACY) diff --git a/indra/llappearance/llavatarappearancedefines.cpp b/indra/llappearance/llavatarappearancedefines.cpp index 580e6433c5..5f98f2c8c1 100644 --- a/indra/llappearance/llavatarappearancedefines.cpp +++ b/indra/llappearance/llavatarappearancedefines.cpp @@ -28,8 +28,8 @@ #include "llavatarappearancedefines.h" #include "indra_constants.h" -const S32 LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH = 1024; -const S32 LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT = 1024; +const S32 LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH = 2048; +const S32 LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT = 2048; using namespace LLAvatarAppearanceDefines; diff --git a/indra/llappearance/llwearable.cpp b/indra/llappearance/llwearable.cpp index a7e5292fed..ae038e09cc 100644 --- a/indra/llappearance/llwearable.cpp +++ b/indra/llappearance/llwearable.cpp @@ -645,9 +645,10 @@ void LLWearable::addVisualParam(LLVisualParam *param) void LLWearable::setVisualParamWeight(S32 param_index, F32 value) { - if( is_in_map(mVisualParamIndexMap, param_index ) ) + visual_param_index_map_t::iterator found = mVisualParamIndexMap.find(param_index); + if (found != mVisualParamIndexMap.end()) { - LLVisualParam *wearable_param = mVisualParamIndexMap[param_index]; + LLVisualParam *wearable_param = found->second; wearable_param->setWeight(value); } else @@ -658,9 +659,10 @@ void LLWearable::setVisualParamWeight(S32 param_index, F32 value) F32 LLWearable::getVisualParamWeight(S32 param_index) const { - if( is_in_map(mVisualParamIndexMap, param_index ) ) + visual_param_index_map_t::const_iterator found = mVisualParamIndexMap.find(param_index); + if(found != mVisualParamIndexMap.end()) { - const LLVisualParam *wearable_param = mVisualParamIndexMap.find(param_index)->second; + const LLVisualParam *wearable_param = found->second; return wearable_param->getWeight(); } else @@ -733,9 +735,9 @@ void LLWearable::writeToAvatar(LLAvatarAppearance* avatarp) if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (!((LLViewerVisualParam*)param)->getCrossWearable()) ) { S32 param_id = param->getID(); + // get weight from wearable and write back into character F32 weight = getVisualParamWeight(param_id); - - avatarp->setVisualParamWeight( param_id, weight); + param->setWeight(weight); } } } diff --git a/indra/llappearance/llwearabledata.cpp b/indra/llappearance/llwearabledata.cpp index 7598ed67f3..f3b76da224 100644 --- a/indra/llappearance/llwearabledata.cpp +++ b/indra/llappearance/llwearabledata.cpp @@ -286,43 +286,45 @@ const LLWearable* LLWearableData::getWearable(const LLWearableType::EType type, LLWearable* LLWearableData::getTopWearable(const LLWearableType::EType type) { - U32 count = getWearableCount(type); - if ( count == 0) + wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) { return NULL; } + const wearableentry_vec_t& wearable_vec = wearable_iter->second; - return getWearable(type, count-1); + size_t size = wearable_vec.size(); + if (size == 0) + { + return NULL; + } + return wearable_vec[size - 1]; } const LLWearable* LLWearableData::getTopWearable(const LLWearableType::EType type) const { - U32 count = getWearableCount(type); - if ( count == 0) + wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) { return NULL; } + const wearableentry_vec_t& wearable_vec = wearable_iter->second; - return getWearable(type, count-1); -} - -LLWearable* LLWearableData::getBottomWearable(const LLWearableType::EType type) -{ - if (getWearableCount(type) == 0) + size_t size = wearable_vec.size(); + if (size == 0) { return NULL; } + return wearable_vec[size - 1]; +} +LLWearable* LLWearableData::getBottomWearable(const LLWearableType::EType type) +{ return getWearable(type, 0); } const LLWearable* LLWearableData::getBottomWearable(const LLWearableType::EType type) const { - if (getWearableCount(type) == 0) - { - return NULL; - } - return getWearable(type, 0); } diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 437b8d0168..a504e71340 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -119,6 +119,7 @@ set(llcommon_HEADER_FILES commoncontrol.h ctype_workaround.h fix_macros.h + fsyspath.h function_types.h indra_constants.h lazyeventapi.h @@ -240,7 +241,6 @@ set(llcommon_HEADER_FILES lluriparser.h lluuid.h llwin32headers.h - llwin32headerslean.h llworkerthread.h hbxxh.h lockstatic.h diff --git a/indra/llcommon/fsyspath.h b/indra/llcommon/fsyspath.h new file mode 100644 index 0000000000..1b4aec09b4 --- /dev/null +++ b/indra/llcommon/fsyspath.h @@ -0,0 +1,79 @@ +/** + * @file fsyspath.h + * @author Nat Goodspeed + * @date 2024-04-03 + * @brief Adapt our UTF-8 std::strings for std::filesystem::path + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Copyright (c) 2024, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_FSYSPATH_H) +#define LL_FSYSPATH_H + +#include <filesystem> + +// While std::filesystem::path can be directly constructed from std::string on +// both Posix and Windows, that's not what we want on Windows. Per +// https://en.cppreference.com/w/cpp/filesystem/path/path: + +// ... the method of conversion to the native character set depends on the +// character type used by source. +// +// * If the source character type is char, the encoding of the source is +// assumed to be the native narrow encoding (so no conversion takes place on +// POSIX systems). +// * If the source character type is char8_t, conversion from UTF-8 to native +// filesystem encoding is used. (since C++20) +// * If the source character type is wchar_t, the input is assumed to be the +// native wide encoding (so no conversion takes places on Windows). + +// The trouble is that on Windows, from std::string ("source character type is +// char"), the "native narrow encoding" isn't UTF-8, so file paths containing +// non-ASCII characters get mangled. +// +// Once we're building with C++20, we could pass a UTF-8 std::string through a +// vector<char8_t> to engage std::filesystem::path's own UTF-8 conversion. But +// sigh, as of 2024-04-03 we're not yet there. +// +// Anyway, encapsulating the important UTF-8 conversions in our own subclass +// allows us to migrate forward to C++20 conventions without changing +// referencing code. + +class fsyspath: public std::filesystem::path +{ + using super = std::filesystem::path; + +public: + // default + fsyspath() {} + // construct from UTF-8 encoded std::string + fsyspath(const std::string& path): super(std::filesystem::u8path(path)) {} + // construct from UTF-8 encoded const char* + fsyspath(const char* path): super(std::filesystem::u8path(path)) {} + // construct from existing path + fsyspath(const super& path): super(path) {} + + fsyspath& operator=(const super& p) { super::operator=(p); return *this; } + fsyspath& operator=(const std::string& p) + { + super::operator=(std::filesystem::u8path(p)); + return *this; + } + fsyspath& operator=(const char* p) + { + super::operator=(std::filesystem::u8path(p)); + return *this; + } + + // shadow base-class string() method with UTF-8 aware method + std::string string() const { return super::u8string(); } + // On Posix systems, where value_type is already char, this operator + // std::string() method shadows the base class operator string_type() + // method. But on Windows, where value_type is wchar_t, the base class + // doesn't have operator std::string(). Provide it. + operator std::string() const { return string(); } +}; + +#endif /* ! defined(LL_FSYSPATH_H) */ diff --git a/indra/llcommon/hexdump.h b/indra/llcommon/hexdump.h new file mode 100755 index 0000000000..ab5ba2b16d --- /dev/null +++ b/indra/llcommon/hexdump.h @@ -0,0 +1,106 @@ +/** + * @file hexdump.h + * @author Nat Goodspeed + * @date 2023-10-03 + * @brief iostream manipulators to stream hex, or string with nonprinting chars + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Copyright (c) 2023, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_HEXDUMP_H) +#define LL_HEXDUMP_H + +#include <cctype> +#include <iomanip> +#include <iostream> +#include <string_view> + +namespace LL +{ + +// Format a given byte string as 2-digit hex values, no separators +// Usage: std::cout << hexdump(somestring) << ... +class hexdump +{ +public: + hexdump(const std::string_view& data): + hexdump(data.data(), data.length()) + {} + + hexdump(const char* data, size_t len): + hexdump(reinterpret_cast<const unsigned char*>(data), len) + {} + + hexdump(const std::vector<unsigned char>& data): + hexdump(data.data(), data.size()) + {} + + hexdump(const unsigned char* data, size_t len): + mData(data, data + len) + {} + + friend std::ostream& operator<<(std::ostream& out, const hexdump& self) + { + auto oldfmt{ out.flags() }; + auto oldfill{ out.fill() }; + out.setf(std::ios_base::hex, std::ios_base::basefield); + out.fill('0'); + for (auto c : self.mData) + { + out << std::setw(2) << unsigned(c); + } + out.setf(oldfmt, std::ios_base::basefield); + out.fill(oldfill); + return out; + } + +private: + std::vector<unsigned char> mData; +}; + +// Format a given byte string as a mix of printable characters and, for each +// non-printable character, "\xnn" +// Usage: std::cout << hexmix(somestring) << ... +class hexmix +{ +public: + hexmix(const std::string_view& data): + mData(data) + {} + + hexmix(const char* data, size_t len): + mData(data, len) + {} + + friend std::ostream& operator<<(std::ostream& out, const hexmix& self) + { + auto oldfmt{ out.flags() }; + auto oldfill{ out.fill() }; + out.setf(std::ios_base::hex, std::ios_base::basefield); + out.fill('0'); + for (auto c : self.mData) + { + // std::isprint() must be passed an unsigned char! + if (std::isprint(static_cast<unsigned char>(c))) + { + out << c; + } + else + { + out << "\\x" << std::setw(2) << unsigned(c); + } + } + out.setf(oldfmt, std::ios_base::basefield); + out.fill(oldfill); + return out; + } + +private: + std::string mData; +}; + +} // namespace LL + +#endif /* ! defined(LL_HEXDUMP_H) */ diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 6da764f94c..08a43983d3 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -88,10 +88,6 @@ LLApp* LLApp::sApplication = NULL; // and disables crashlogger bool LLApp::sDisableCrashlogger = false; -// Local flag for whether or not to do logging in signal handlers. -//static -bool LLApp::sLogInSignal = true; - // static // Keeps track of application status LLScalarCond<LLApp::EAppStatus> LLApp::sStatus{LLApp::APP_STATUS_STOPPED}; @@ -226,7 +222,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv) if(wargv[ii][0] != '-') { LL_INFOS() << "Did not find option identifier while parsing token: " - << wargv[ii] << LL_ENDL; + << (intptr_t)wargv[ii] << LL_ENDL; return false; } int offset = 1; @@ -596,6 +592,10 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) // We do the somewhat sketchy operation of blocking in here until the error handler // has gracefully stopped the app. + // FIXME(brad) - we are using this handler for asynchronous signals as well, so sLogInSignal is currently + // disabled for safety. we need to find a way to selectively reenable it when it is safe. + // see issue secondlife/viewer#2566 + if (LLApp::sLogInSignal) { LL_INFOS() << "Signal handler - Got signal " << signum << " - " << apr_signal_description_get(signum) << LL_ENDL; diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index d90ecdf661..3d18864b80 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -339,8 +339,12 @@ private: friend void default_unix_signal_handler(int signum, siginfo_t *info, void *); #endif -public: - static bool sLogInSignal; +private: +#ifdef LL_RELEASE_FOR_DOWNLOAD + static constexpr bool sLogInSignal = false; +#else + static constexpr bool sLogInSignal = true; +#endif }; #endif // LL_LLAPP_H diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index faf2d6fc92..ff5c8c6a33 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -35,7 +35,7 @@ #include <memory> #include <boost/noncopyable.hpp> -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include "apr_thread_proc.h" #include "apr_getopt.h" #include "apr_signal.h" diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index ed94ef21ef..d0bc8f7652 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -34,7 +34,7 @@ #include "stringize.h" #if LL_WINDOWS -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <stdlib.h> // Windows errno #include <vector> #else diff --git a/indra/llcommon/llmainthreadtask.h b/indra/llcommon/llmainthreadtask.h index cec95b2356..c3ed7fef52 100644 --- a/indra/llcommon/llmainthreadtask.h +++ b/indra/llcommon/llmainthreadtask.h @@ -89,10 +89,10 @@ private: } // Given arbitrary CALLABLE, which might be a lambda, how are we // supposed to obtain its signature for std::packaged_task? It seems - // redundant to have to add an argument list to engage result_of, then + // redundant to have to add an argument list to engage invoke_result_t, then // add the argument list again to complete the signature. At least we // only support a nullary CALLABLE. - std::packaged_task<typename std::result_of<CALLABLE()>::type()> mTask; + std::packaged_task<std::invoke_result_t<CALLABLE>()> mTask; }; }; diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp index f64f54c262..e999b8f597 100644 --- a/indra/llcommon/llmd5.cpp +++ b/indra/llcommon/llmd5.cpp @@ -68,10 +68,6 @@ documentation and/or software. */ - - - - #include "linden_common.h" #include "llmd5.h" @@ -81,232 +77,203 @@ documentation and/or software. // how many bytes to grab at a time when checking files const int LLMD5::BLOCK_LEN = 4096; - // LLMD5 simple initialization method - LLMD5::LLMD5() { - init(); + init(); } - - - // MD5 block update operation. Continues an MD5 message-digest // operation, processing another message block, and updating the // context. +void LLMD5::update(const uint8_t* input, const size_t input_length) +{ + size_t input_index, buffer_index; + size_t buffer_space; // how much space is left in buffer -void LLMD5::update (const uint8_t *input, const size_t input_length) { - - size_t input_index, buffer_index; - size_t buffer_space; // how much space is left in buffer - - if (finalized){ // so we can't update! - std::cerr << "LLMD5::update: Can't update a finalized digest!" << std::endl; - return; - } - - // Compute number of bytes mod 64 - buffer_index = size_t((count >> 3) & 0x3F); + if (finalized) + { // so we can't update! + std::cerr << "LLMD5::update: Can't update a finalized digest!" << std::endl; + return; + } - // Update number of bits - count += input_length << 3; + // Compute number of bytes mod 64 + buffer_index = size_t((count >> 3) & 0x3F); - buffer_space = 64 - buffer_index; // how much space is left in buffer + // Update number of bits + count += input_length << 3; - // now, transform each 64-byte piece of the input, bypassing the buffer - if (input == NULL || input_length == 0){ - std::cerr << "LLMD5::update: Invalid input!" << std::endl; - return; - } + buffer_space = 64 - buffer_index; // how much space is left in buffer - // Transform as many times as possible. - if (input_length >= buffer_space) { // ie. we have enough to fill the buffer - // fill the rest of the buffer and transform - memcpy( /* Flawfinder: ignore */ - buffer + buffer_index, - input, - buffer_space); - transform (buffer); + // now, transform each 64-byte piece of the input, bypassing the buffer + if (input == NULL || input_length == 0) + { + std::cerr << "LLMD5::update: Invalid input!" << std::endl; + return; + } - for (input_index = buffer_space; input_index + 63 < input_length; - input_index += 64) - transform (input+input_index); + // Transform as many times as possible. + if (input_length >= buffer_space) // ie. we have enough to fill the buffer + { + // fill the rest of the buffer and transform + memcpy(/* Flawfinder: ignore */ + buffer + buffer_index, + input, + buffer_space); + transform(buffer); - buffer_index = 0; // so we can buffer remaining - } - else - input_index=0; // so we can buffer the whole input + for (input_index = buffer_space; input_index + 63 < input_length; input_index += 64) + transform(input + input_index); + buffer_index = 0; // so we can buffer remaining + } + else + input_index = 0; // so we can buffer the whole input - // and here we do the buffering: - memcpy(buffer+buffer_index, input+input_index, input_length-input_index); /* Flawfinder: ignore */ + // and here we do the buffering: + memcpy(buffer + buffer_index, input + input_index, input_length - input_index); /* Flawfinder: ignore */ } - - // MD5 update for files. // Like above, except that it works on files (and uses above as a primitive.) +void LLMD5::update(FILE* file) +{ + unsigned char buffer[BLOCK_LEN]; /* Flawfinder: ignore */ + int len; -void LLMD5::update(FILE* file){ - - unsigned char buffer[BLOCK_LEN]; /* Flawfinder: ignore */ - int len; - - while ( (len=(int)fread(buffer, 1, BLOCK_LEN, file)) ) - update(buffer, len); - - fclose (file); + while ((len = (int)fread(buffer, 1, BLOCK_LEN, file))) + update(buffer, len); + fclose(file); } // MD5 update for istreams. // Like update for files; see above. +void LLMD5::update(std::istream& stream) +{ + unsigned char buffer[BLOCK_LEN]; /* Flawfinder: ignore */ + int len; -void LLMD5::update(std::istream& stream){ - - unsigned char buffer[BLOCK_LEN]; /* Flawfinder: ignore */ - int len; - - while (stream.good()){ - stream.read( (char*)buffer, BLOCK_LEN); /* Flawfinder: ignore */ // note that return value of read is unusable. - len=(int)stream.gcount(); - update(buffer, len); - } - + while (stream.good()) + { + stream.read((char*)buffer, BLOCK_LEN); /* Flawfinder: ignore */ // note that return value of read is unusable. + len = (int)stream.gcount(); + update(buffer, len); + } } -void LLMD5::update(const std::string& s) +void LLMD5::update(const std::string& s) { - update((unsigned char *)s.c_str(),s.length()); + update((unsigned char*)s.c_str(), s.length()); } // MD5 finalization. Ends an MD5 message-digest operation, writing the // the message digest and zeroizing the context. - - -void LLMD5::finalize (){ - - unsigned char bits[8]; /* Flawfinder: ignore */ - size_t index, padLen; - static uint8_t PADDING[64]={ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +void LLMD5::finalize() +{ + unsigned char bits[8]; /* Flawfinder: ignore */ + size_t index, padLen; + static uint8_t PADDING[64] = + { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (finalized){ - std::cerr << "LLMD5::finalize: Already finalized this digest!" << std::endl; - return; - } - - // Save number of bits. - // Treat count, a uint64_t, as uint32_t[2]. - encode (bits, reinterpret_cast<uint32_t*>(&count), 8); + if (finalized) + { + std::cerr << "LLMD5::finalize: Already finalized this digest!" << std::endl; + return; + } - // Pad out to 56 mod 64. - index = size_t((count >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - update (PADDING, padLen); + // Save number of bits. + // Treat count, a uint64_t, as uint32_t[2]. + encode(bits, reinterpret_cast<uint32_t*>(&count), 8); - // Append length (before padding) - update (bits, 8); + // Pad out to 56 mod 64. + index = size_t((count >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + update(PADDING, padLen); - // Store state in digest - encode (digest, state, 16); + // Append length (before padding) + update(bits, 8); - // Zeroize sensitive information - memset (buffer, 0, sizeof(*buffer)); + // Store state in digest + encode(digest, state, 16); - finalized=1; + // Zeroize sensitive information + memset(buffer, 0, sizeof(buffer)); + finalized = true; } - - - -LLMD5::LLMD5(FILE *file){ - - init(); // must be called be all constructors - update(file); - finalize (); +LLMD5::LLMD5(FILE* file) +{ + init(); // must be called be all constructors + update(file); + finalize(); } - - - -LLMD5::LLMD5(std::istream& stream){ - - init(); // must called by all constructors - update (stream); - finalize(); +LLMD5::LLMD5(std::istream& stream) +{ + init(); // must called by all constructors + update(stream); + finalize(); } // Digest a string of the format ("%s:%i" % (s, number)) -LLMD5::LLMD5(const unsigned char *string, const unsigned int number) +LLMD5::LLMD5(const unsigned char* string, const unsigned int number) { - const char *colon = ":"; - char tbuf[16]; /* Flawfinder: ignore */ + const char* colon = ":"; + char tbuf[16]; /* Flawfinder: ignore */ init(); - update(string, (U32)strlen((const char *) string)); /* Flawfinder: ignore */ - update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ - snprintf(tbuf, sizeof(tbuf), "%i", number); /* Flawfinder: ignore */ - update((const unsigned char *) tbuf, (U32)strlen(tbuf)); /* Flawfinder: ignore */ + update(string, (U32)strlen((const char*)string)); /* Flawfinder: ignore */ + update((const unsigned char*)colon, (U32)strlen(colon)); /* Flawfinder: ignore */ + snprintf(tbuf, sizeof(tbuf), "%i", number); /* Flawfinder: ignore */ + update((const unsigned char*)tbuf, (U32)strlen(tbuf)); /* Flawfinder: ignore */ finalize(); } // Digest a string -LLMD5::LLMD5(const unsigned char *s) +LLMD5::LLMD5(const unsigned char* s) { init(); - update(s, (U32)strlen((const char *) s)); /* Flawfinder: ignore */ + update(s, (U32)strlen((const char*)s)); /* Flawfinder: ignore */ finalize(); } -void LLMD5::raw_digest(unsigned char *s) const +void LLMD5::raw_digest(unsigned char* s) const { if (!finalized) { - std::cerr << "LLMD5::raw_digest: Can't get digest if you haven't "<< - "finalized the digest!" << std::endl; + std::cerr << "LLMD5::raw_digest: Can't get digest if you haven't " + << "finalized the digest!" << std::endl; s[0] = '\0'; return; } - memcpy(s, digest, 16); /* Flawfinder: ignore */ - return; + memcpy(s, digest, 16); /* Flawfinder: ignore */ } - - -void LLMD5::hex_digest(char *s) const +void LLMD5::hex_digest(char* s) const { - int i; - if (!finalized) { - std::cerr << "LLMD5::hex_digest: Can't get digest if you haven't "<< - "finalized the digest!" <<std::endl; + std::cerr << "LLMD5::hex_digest: Can't get digest if you haven't " + << "finalized the digest!" << std::endl; s[0] = '\0'; return; } - for (i=0; i<16; i++) + for (int i = 0; i < 16; i++) { - sprintf(s+i*2, "%02x", digest[i]); /* Flawfinder: ignore */ + sprintf(s + i * 2, "%02x", digest[i]); /* Flawfinder: ignore */ } - s[32]='\0'; - - return; + s[32] = '\0'; } - - - - - -std::ostream& operator<<(std::ostream &stream, LLMD5 context) +std::ostream& operator<<(std::ostream& stream, const LLMD5& context) { char s[33]; /* Flawfinder: ignore */ context.hex_digest(s); @@ -320,7 +287,7 @@ bool operator==(const LLMD5& a, const LLMD5& b) unsigned char b_guts[16]; a.raw_digest(a_guts); b.raw_digest(b_guts); - if (memcmp(a_guts,b_guts,16)==0) + if (memcmp(a_guts, b_guts, 16) == 0) return true; else return false; @@ -328,30 +295,27 @@ bool operator==(const LLMD5& a, const LLMD5& b) bool operator!=(const LLMD5& a, const LLMD5& b) { - return !(a==b); + return !(a == b); } // PRIVATE METHODS: +void LLMD5::init() +{ + finalized = false; // we just started! -void LLMD5::init(){ - finalized=0; // we just started! - - // Nothing counted, so count=0 - count = 0; + // Nothing counted, so count=0 + count = 0; - // Load magic initialization constants. - state[0] = 0x67452301; - state[1] = 0xefcdab89; - state[2] = 0x98badcfe; - state[3] = 0x10325476; + // Load magic initialization constants. + state[0] = 0x67452301; + state[1] = 0xefcdab89; + state[2] = 0x98badcfe; + state[3] = 0x10325476; } - - // Constants for MD5Transform routine. // Although we could use C++ style constants, defines are actually better, // since they let us easily evade scope clashes. - #define S11 7 #define S12 12 #define S13 17 @@ -381,153 +345,144 @@ void LLMD5::init(){ /* ROTATE_LEFT rotates x left n bits. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (U32)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (U32)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (U32)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (U32)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - - +#define FF(a, b, c, d, x, s, ac) \ + { \ + (a) += F((b), (c), (d)) + (x) + (U32)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) \ + { \ + (a) += G((b), (c), (d)) + (x) + (U32)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) \ + { \ + (a) += H((b), (c), (d)) + (x) + (U32)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) \ + { \ + (a) += I((b), (c), (d)) + (x) + (U32)(ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ + } // LLMD5 basic transformation. Transforms state based on block. -void LLMD5::transform (const U8 block[64]){ - - uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - decode (x, block, 64); - - assert(!finalized); // not just a user error, since the method is private - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - // Zeroize sensitive information. - memset ( (uint8_t *) x, 0, sizeof(x)); - +void LLMD5::transform(const U8 block[64]) +{ + uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + decode(x, block, 64); + + assert(!finalized); // not just a user error, since the method is private + + /* Round 1 */ + FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ + FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ + FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */ + FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ + FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ + FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */ + FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ + FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ + FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */ + FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ + FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ + GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ + GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ + GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ + GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ + GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */ + GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ + GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */ + GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ + GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */ + GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ + HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ + HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ + HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */ + HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ + HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ + HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ + HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */ + HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ + HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ + II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */ + II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ + II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ + II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ + II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */ + II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ + II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ + II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */ + II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + // Zeroize sensitive information. + memset(x, 0, sizeof(x)); } - - // Encodes input (uint32_t) into output (unsigned char). Assumes len is // a multiple of 4. -void LLMD5::encode (uint8_t *output, const uint32_t *input, const size_t len) { - - size_t i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (uint8_t) (input[i] & 0xff); - output[j+1] = (uint8_t) ((input[i] >> 8) & 0xff); - output[j+2] = (uint8_t) ((input[i] >> 16) & 0xff); - output[j+3] = (uint8_t) ((input[i] >> 24) & 0xff); - } +void LLMD5::encode(uint8_t* output, const uint32_t* input, const size_t len) +{ + for (size_t i = 0, j = 0; j < len; i++, j += 4) + { + output[j] = (uint8_t)(input[i] & 0xff); + output[j + 1] = (uint8_t)((input[i] >> 8) & 0xff); + output[j + 2] = (uint8_t)((input[i] >> 16) & 0xff); + output[j + 3] = (uint8_t)((input[i] >> 24) & 0xff); + } } - - - // Decodes input (unsigned char) into output (uint32_t). Assumes len is // a multiple of 4. -void LLMD5::decode (uint32_t *output, const uint8_t *input, const size_t len){ - - size_t i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | - (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); +void LLMD5::decode(uint32_t* output, const uint8_t* input, const size_t len) +{ + for (size_t i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | + (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); } - - diff --git a/indra/llcommon/llmd5.h b/indra/llcommon/llmd5.h index 46c79cf5a2..ad063fda46 100644 --- a/indra/llcommon/llmd5.h +++ b/indra/llcommon/llmd5.h @@ -67,59 +67,57 @@ documentation and/or software. */ -#include <cstdint> // uint32_t et al. +#include <cstdint> // uint32_t et al. // use for the raw digest output const int MD5RAW_BYTES = 16; // use for outputting hex digests -const int MD5HEX_STR_SIZE = 33; // char hex[MD5HEX_STR_SIZE]; with null +const int MD5HEX_STR_SIZE = 33; // char hex[MD5HEX_STR_SIZE]; with null const int MD5HEX_STR_BYTES = 32; // message system fixed size -class LL_COMMON_API LLMD5 { -// how many bytes to grab at a time when checking files - static const int BLOCK_LEN; +class LL_COMMON_API LLMD5 +{ + // how many bytes to grab at a time when checking files + static const int BLOCK_LEN; public: -// methods for controlled operation: - LLMD5 (); // simple initializer - void update (const uint8_t *input, const size_t input_length); - void update (std::istream& stream); - void update (FILE *file); - void update (const std::string& str); - void finalize (); - -// constructors for special circumstances. All these constructors finalize -// the MD5 context. - LLMD5 (const unsigned char *string); // digest string, finalize - LLMD5 (std::istream& stream); // digest stream, finalize - LLMD5 (FILE *file); // digest file, close, finalize - LLMD5 (const unsigned char *string, const unsigned int number); - -// methods to acquire finalized result - void raw_digest(unsigned char *array) const; // provide 16-byte array for binary data - void hex_digest(char *string) const; // provide 33-byte array for ascii-hex string - - friend LL_COMMON_API std::ostream& operator<< (std::ostream&, LLMD5 context); + // methods for controlled operation: + LLMD5(); // simple initializer + void update(const uint8_t* input, const size_t input_length); + void update(std::istream& stream); + void update(FILE* file); + void update(const std::string& str); + void finalize(); + + // constructors for special circumstances. All these constructors finalize + // the MD5 context. + LLMD5(const unsigned char* string); // digest string, finalize + LLMD5(std::istream& stream); // digest stream, finalize + LLMD5(FILE* file); // digest file, close, finalize + LLMD5(const unsigned char* string, const unsigned int number); + + // methods to acquire finalized result + void raw_digest(unsigned char* array) const; // provide 16-byte array for binary data + void hex_digest(char* string) const; // provide 33-byte array for ascii-hex string + + friend LL_COMMON_API std::ostream& operator<<(std::ostream&, const LLMD5& context); private: - - -// next, the private data: - uint32_t state[4]; - uint64_t count; // number of *bits*, mod 2^64 - uint8_t buffer[64]; // input buffer - uint8_t digest[16]; - uint8_t finalized; - -// last, the private methods, mostly static: - void init (); // called by all constructors - void transform (const uint8_t *buffer); // does the real update work. Note - // that length is implied to be 64. - - static void encode (uint8_t *dest, const uint32_t *src, const size_t length); - static void decode (uint32_t *dest, const uint8_t *src, const size_t length); - + // next, the private data: + uint32_t state[4]; + uint64_t count; // number of *bits*, mod 2^64 + uint8_t buffer[64]; // input buffer + uint8_t digest[16]; + bool finalized; + + // last, the private methods, mostly static: + void init(); // called by all constructors + void transform(const uint8_t* buffer); // does the real update work. Note + // that length is implied to be 64. + + static void encode(uint8_t* dest, const uint32_t* src, const size_t length); + static void decode(uint32_t* dest, const uint8_t* src, const size_t length); }; LL_COMMON_API bool operator==(const LLMD5& a, const LLMD5& b); diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index 6e8cf9643b..62943845a5 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -194,6 +194,18 @@ public: mSharedMutex->unlock<SHARED>(); } + void lock() + { + if (mSharedMutex) + mSharedMutex->lock<SHARED>(); + } + + void unlock() + { + if (mSharedMutex) + mSharedMutex->unlock<SHARED>(); + } + private: LLSharedMutex* mSharedMutex; }; diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 6edff9fa5e..048547e4cc 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -418,6 +418,17 @@ private: bool mStayUnique; }; +template<typename Type> +bool operator!=(Type* lhs, const LLPointer<Type>& rhs) +{ + return (lhs != rhs.get()); +} + +template<typename Type> +bool operator==(Type* lhs, const LLPointer<Type>& rhs) +{ + return (lhs == rhs.get()); +} // boost hash adapter template <class Type> diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 7c6874d279..91c623eae1 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -139,7 +139,7 @@ namespace LLPredicate Rule() {} - void require(ENUM e, bool match) + void mandate(ENUM e, bool match) { mRule.set(e, match); } @@ -154,7 +154,7 @@ namespace LLPredicate return (mRule && value).someSet(); } - bool requires(const Value<ENUM> value) const + bool mandates(const Value<ENUM> value) const { return (mRule && value).someSet() && (!mRule && value).noneSet(); } diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index a528cc7fd8..b499a9ce10 100644 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -98,15 +98,6 @@ # define LL_THREAD_LOCAL __thread #endif -// Static linking with apr on windows needs to be declared. -#if LL_WINDOWS && !LL_COMMON_LINK_SHARED -#ifndef APR_DECLARE_STATIC -#define APR_DECLARE_STATIC // For APR on Windows -#endif -#ifndef APU_DECLARE_STATIC -#define APU_DECLARE_STATIC // For APR util on Windows -#endif -#endif #if defined(LL_WINDOWS) #define BOOST_REGEX_NO_LIB 1 @@ -119,13 +110,6 @@ // Deal with VC++ problems #if LL_MSVC -#ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS // disable warnings for methods considered unsafe -#endif -#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS -#define _WINSOCK_DEPRECATED_NO_WARNINGS // disable deprecated WinSock API warnings -#endif - // level 4 warnings that we need to disable: #pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class #pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h index 39ed29c1b4..cc2d6566fc 100644 --- a/indra/llcommon/llprocess.h +++ b/indra/llcommon/llprocess.h @@ -29,7 +29,6 @@ #include "llinitparam.h" #include "llsdparam.h" -#include "llwin32headerslean.h" #include "llexception.h" #include "apr_thread_proc.h" #include <boost/ptr_container/ptr_vector.hpp> @@ -38,7 +37,7 @@ #include <iosfwd> // std::ostream #if LL_WINDOWS -#include "llwin32headerslean.h" // for HANDLE +#include "llwin32headers.h" // for HANDLE #elif LL_LINUX #if defined(Status) #undef Status diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 3a05407dd0..51b1b967f1 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -34,7 +34,7 @@ //#include <memory> #if LL_WINDOWS -# include "llwin32headerslean.h" +# include "llwin32headers.h" # define _interlockedbittestandset _renamed_interlockedbittestandset # define _interlockedbittestandreset _renamed_interlockedbittestandreset # include <intrin.h> diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp index 5d38e55686..1df2a8f9eb 100644 --- a/indra/llcommon/llsdjson.cpp +++ b/indra/llcommon/llsdjson.cpp @@ -61,12 +61,20 @@ LLSD LlsdFromJson(const boost::json::value& val) result = LLSD(val.as_bool()); break; case boost::json::kind::array: + { result = LLSD::emptyArray(); - for (const auto &element : val.as_array()) + auto& array = val.as_array(); + // allocate elements 0 .. (size() - 1) to avoid incremental allocation + if (! array.empty()) + { + result[array.size() - 1] = LLSD(); + } + for (const auto &element : array) { result.append(LlsdFromJson(element)); } break; + } case boost::json::kind::object: result = LLSD::emptyMap(); for (const auto& element : val.as_object()) @@ -106,6 +114,7 @@ boost::json::value LlsdToJson(const LLSD &val) case LLSD::TypeMap: { boost::json::object& obj = result.emplace_object(); + obj.reserve(val.size()); for (const auto& llsd_dat : llsd::inMap(val)) { obj[llsd_dat.first] = LlsdToJson(llsd_dat.second); @@ -115,6 +124,7 @@ boost::json::value LlsdToJson(const LLSD &val) case LLSD::TypeArray: { boost::json::array& json_array = result.emplace_array(); + json_array.reserve(val.size()); for (const auto& llsd_dat : llsd::inArray(val)) { json_array.push_back(LlsdToJson(llsd_dat)); @@ -123,7 +133,8 @@ boost::json::value LlsdToJson(const LLSD &val) } case LLSD::TypeBinary: default: - LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type (" << val.type() << ")." << LL_ENDL; + LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type (" + << val.type() << ")." << LL_ENDL; break; } diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index 353a924e52..fda47c7a87 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -32,8 +32,7 @@ #include <sstream> #if LL_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include <winsock2.h> // for htonl +# include "llwin32headers.h" // for htonl #elif LL_LINUX # include <netinet/in.h> #elif LL_DARWIN diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp index ca8f4299d9..c223c26bb0 100644 --- a/indra/llcommon/llstacktrace.cpp +++ b/indra/llcommon/llstacktrace.cpp @@ -32,7 +32,7 @@ #include <iostream> #include <sstream> -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <dbghelp.h> typedef USHORT NTAPI RtlCaptureStackBackTrace_Function( diff --git a/indra/llcommon/llstrider.h b/indra/llcommon/llstrider.h index 06cf8d3480..d756aca62b 100644 --- a/indra/llcommon/llstrider.h +++ b/indra/llcommon/llstrider.h @@ -41,6 +41,13 @@ public: LLStrider(Object* first) { mObjectp = first; mSkip = sizeof(Object); } ~LLStrider() { } + const LLStrider<Object>& operator=(const LLStrider<Object>& rhs) + { + mBytep = rhs.mBytep; + mSkip = rhs.mSkip; + return *this; + } + const LLStrider<Object>& operator = (Object *first) { mObjectp = first; return *this;} void setStride (S32 skipBytes) { mSkip = (skipBytes ? skipBytes : sizeof(Object));} diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 505789f9ea..07adf71d18 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -33,8 +33,7 @@ #include <vector> #if LL_WINDOWS -#include "llwin32headerslean.h" -#include <winnls.h> // for WideCharToMultiByte +#include "llwin32headers.h" #endif std::string ll_safe_string(const char* in) @@ -1410,6 +1409,14 @@ bool LLStringUtil::simpleReplacement(std::string &replacement, std::string token template<> void LLStringUtil::setLocale(std::string inLocale) { + if(startsWith(inLocale, "MissingString")) + { + // it seems this hasn't been working for some time, and I'm not sure how it is intentded to + // properly discover the correct locale. early out now to avoid failures later in + // formatNumber() + LL_WARNS() << "Failed attempting to set invalid locale: " << inLocale << LL_ENDL; + return; + } sLocale = inLocale; }; diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index add8f18a62..7e69ddf6fc 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -59,7 +59,7 @@ using namespace llsd; #if LL_WINDOWS -# include "llwin32headerslean.h" +# include "llwin32headers.h" # include <psapi.h> // GetPerformanceInfo() et al. # include <VersionHelpers.h> #elif LL_DARWIN diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 28d6e4e4cc..f36d223100 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -34,7 +34,7 @@ #include <thread> #if LL_WINDOWS -# include "llwin32headerslean.h" +# include "llwin32headers.h" #elif LL_LINUX || LL_DARWIN # include <errno.h> # include <sys/time.h> diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 7aeabc3c4a..b9bd27aa17 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -25,11 +25,8 @@ #include "linden_common.h" - // We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes. #if LL_WINDOWS #include "llwin32headers.h" -// ugh, this is ugly. We need to straighten out our linking for this library -#pragma comment(lib, "IPHLPAPI.lib") #include <iphlpapi.h> #include <nb30.h> #endif diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h index f679adc200..df433deb7a 100644 --- a/indra/llcommon/llwin32headers.h +++ b/indra/llcommon/llwin32headers.h @@ -28,15 +28,8 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS -#ifndef NOMINMAX -#define NOMINMAX -#endif -#undef WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> -// reset to default, which is lean -#define WIN32_LEAN_AND_MEAN -#undef NOMINMAX +#include <windows.h> // Does not include winsock.h because WIN32_LEAN_AND_MEAN is defined +#include <winsock2.h> // Requires windows.h #endif #endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h deleted file mode 100644 index 97c8edb8cf..0000000000 --- a/indra/llcommon/llwin32headerslean.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file llwin32headerslean.h - * @brief sanitized include of windows header files - * - * $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_LLWINDOWS_H -#define LL_LLWINDOWS_H - -#ifdef LL_WINDOWS -#ifndef NOMINMAX -#define NOMINMAX -#endif -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> -#undef NOMINMAX -#endif - -#endif diff --git a/indra/llcorehttp/tests/test_httpoperation.hpp b/indra/llcorehttp/tests/test_httpoperation.hpp index 6778c3440b..361091c7b2 100644 --- a/indra/llcorehttp/tests/test_httpoperation.hpp +++ b/indra/llcorehttp/tests/test_httpoperation.hpp @@ -92,7 +92,7 @@ namespace tut op->setReplyPath(LLCore::HttpOperation::HttpReplyQueuePtr_t(), h1); // Check ref count - ensure(op.unique() == 1); + ensure(op.use_count() == 1); // release the reference, releasing the operation but // not the handlers. diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 8b966b8ea3..6b14b68c78 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -179,7 +179,7 @@ private: public: template<bool SHARED> - class DataLock : LLSharedMutexLockTemplate<SHARED> + class DataLock : public LLSharedMutexLockTemplate<SHARED> { public: DataLock(const LLImageBase* image) diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 753e5d24df..aa161709a1 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -281,7 +281,7 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r S32 height = (h > 0) ? h : 2048; S32 max_dimension = llmax(width, height); // Find largest dimension S32 block_area = MAX_BLOCK_SIZE * MAX_BLOCK_SIZE; // Calculated initial block area from established max block size (currently 64) - block_area *= (max_dimension / MAX_BLOCK_SIZE / max_components); // Adjust initial block area by ratio of largest dimension to block size per component + block_area *= llmax((max_dimension / MAX_BLOCK_SIZE / max_components), 1); // Adjust initial block area by ratio of largest dimension to block size per component S32 totalbytes = (S32) (block_area * max_components * precision); // First block layer computed before loop without compression rate S32 block_layers = 1; // Start at layer 1 since first block layer is computed outside loop while (block_layers < 6) // Walk five layers for the five discards in JPEG2000 diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 4aab3dee3b..0ee71de3a1 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -69,25 +69,99 @@ const U32 LLSettingsBase::Validator::VALIDATION_PARTIAL(0x01 << 0); LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), mDirty(true), - mBlendedFactor(0.0) + mLLSDDirty(true), + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { } LLSettingsBase::LLSettingsBase(const LLSD setting) : mSettings(setting), + mLLSDDirty(true), mDirty(true), - mBlendedFactor(0.0) + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { } +//virtual +void LLSettingsBase::loadValuesFromLLSD() +{ + mLLSDDirty = false; + + mAssetId = mSettings[SETTING_ASSETID].asUUID(); + mSettingId = getValue(SETTING_ID).asUUID(); + mSettingName = getValue(SETTING_NAME).asString(); + if (mSettings.has(SETTING_FLAGS)) + { + mSettingFlags = (U32)mSettings[SETTING_FLAGS].asInteger(); + } + else + { + mSettingFlags = 0; + } +} + +//virtual +void LLSettingsBase::saveValuesToLLSD() +{ + mLLSDDirty = false; + + mSettings[SETTING_NAME] = mSettingName; + if (mAssetId.isNull()) + { + mSettings.erase(SETTING_ASSETID); + } + else + { + mSettings[SETTING_ASSETID] = mAssetId; + } + mSettings[SETTING_FLAGS] = LLSD::Integer(mSettingFlags); +} + +void LLSettingsBase::saveValuesIfNeeded() +{ + if (mLLSDDirty) + { + saveValuesToLLSD(); + } +} + //========================================================================= -void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix) +void LLSettingsBase::lerpSettings(LLSettingsBase &other, F64 mix) { - mSettings = interpolateSDMap(mSettings, other.mSettings, other.getParameterMap(), mix); + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + saveValuesIfNeeded(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mSettings = interpolateSDMap(mSettings, other.getSettings(), other.getParameterMap(), mix, skip, slerps); setDirtyFlag(true); + loadValuesFromLLSD(); +} + +void LLSettingsBase::lerpVector2(LLVector2& a, const LLVector2& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); } -LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) const +void LLSettingsBase::lerpVector3(LLVector3& a, const LLVector3& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); + a.mV[2] = lerp(a.mV[2], b.mV[2], mix); +} + +void LLSettingsBase::lerpColor(LLColor3& a, const LLColor3& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); + a.mV[2] = lerp(a.mV[2], b.mV[2], mix); +} + +LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) { LLSD newSettings; @@ -161,13 +235,10 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons return newSettings; } -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix) const +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix, const stringset_t& skip, const stringset_t& slerps) { LLSD newSettings; - stringset_t skip = getSkipInterpolateKeys(); - stringset_t slerps = getSlerpKeys(); - llassert(mix >= 0.0f && mix <= 1.0f); for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) @@ -204,7 +275,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c } } - newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, skip, slerps); } // Special handling cases @@ -233,12 +304,12 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c if (def_iter != defaults.end()) { // Blend against default value - newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, skip, slerps); } else if ((*it).second.type() == LLSD::TypeMap) { // interpolate in case there are defaults inside (part of legacy) - newSettings[key_name] = interpolateSDValue(key_name, LLSDMap(), (*it).second, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, LLSDMap(), (*it).second, defaults, mix, skip, slerps); } // else do nothing when no known defaults // TODO: Should I blend this out instead? @@ -260,7 +331,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c return newSettings; } -LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const +LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps) { LLSD new_value; @@ -286,7 +357,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD break; case LLSD::TypeMap: // deep copy. - new_value = interpolateSDMap(value, other_value, defaults, mix); + new_value = interpolateSDMap(value, other_value, defaults, mix, skip, slerps); break; case LLSD::TypeArray: @@ -348,13 +419,15 @@ LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const return skipSet; } -LLSD LLSettingsBase::getSettings() const +LLSD& LLSettingsBase::getSettings() { + saveValuesIfNeeded(); return mSettings; } -LLSD LLSettingsBase::cloneSettings() const +LLSD LLSettingsBase::cloneSettings() { + saveValuesIfNeeded(); LLSD settings(combineSDMaps(getSettings(), LLSD())); if (U32 flags = getFlags()) { @@ -363,7 +436,7 @@ LLSD LLSettingsBase::cloneSettings() const return settings; } -size_t LLSettingsBase::getHash() const +size_t LLSettingsBase::getHash() { // get a shallow copy of the LLSD filtering out values to not include in the hash LLSD hash_settings = llsd_shallow(getSettings(), LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true)); @@ -381,7 +454,9 @@ bool LLSettingsBase::validate() mSettings[SETTING_TYPE] = getSettingsType(); } + saveValuesIfNeeded(); LLSD result = LLSettingsBase::settingValidation(mSettings, validations); + loadValuesFromLLSD(); if (result["errors"].size() > 0) { @@ -704,7 +779,7 @@ F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_ if (mTarget) { - mTarget->replaceSettings(mInitial->getSettings()); + mTarget->replaceSettings(mInitial); mTarget->blend(mFinal, blendf); } else @@ -719,7 +794,7 @@ void LLSettingsBlender::triggerComplete() { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; if (mTarget) - mTarget->replaceSettings(mFinal->getSettings()); + mTarget->replaceSettings(mFinal); LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon mTarget->update(); mOnFinished(shared_from_this()); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 9d8d746b7e..816ff3e111 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -109,72 +109,59 @@ public: virtual bool isDirty() const { return mDirty; } virtual bool isVeryDirty() const { return mReplaced; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; clearAssetId(); } + inline void setReplaced() { mReplaced = true; } - size_t getHash() const; // Hash will not include Name, ID or a previously stored Hash + size_t getHash(); // Hash will not include Name, ID or a previously stored Hash inline LLUUID getId() const { - return getValue(SETTING_ID).asUUID(); + return mSettingId; } inline std::string getName() const { - return getValue(SETTING_NAME).asString(); + return mSettingName; } inline void setName(std::string val) { - setValue(SETTING_NAME, val); + mSettingName = val; + setDirtyFlag(true); + setLLSDDirty(); } inline LLUUID getAssetId() const { - if (mSettings.has(SETTING_ASSETID)) - return mSettings[SETTING_ASSETID].asUUID(); - return LLUUID(); + return mAssetId; } inline U32 getFlags() const { - if (mSettings.has(SETTING_FLAGS)) - return static_cast<U32>(mSettings[SETTING_FLAGS].asInteger()); - return 0; + return mSettingFlags; } inline void setFlags(U32 value) { - setLLSD(SETTING_FLAGS, LLSD::Integer(value)); + mSettingFlags = value; + setDirtyFlag(true); + setLLSDDirty(); } inline bool getFlag(U32 flag) const { - if (mSettings.has(SETTING_FLAGS)) - return ((U32)mSettings[SETTING_FLAGS].asInteger() & flag) == flag; - return false; + return (mSettingFlags & flag) == flag; } inline void setFlag(U32 flag) { - U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0); - - flags |= flag; - - if (flags) - mSettings[SETTING_FLAGS] = LLSD::Integer(flags); - else - mSettings.erase(SETTING_FLAGS); + mSettingFlags |= flag; + setLLSDDirty(); } inline void clearFlag(U32 flag) { - U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0); - - flags &= ~flag; - - if (flags) - mSettings[SETTING_FLAGS] = LLSD::Integer(flags); - else - mSettings.erase(SETTING_FLAGS); + mSettingFlags &= ~flag; + setLLSDDirty(); } virtual void replaceSettings(LLSD settings) @@ -183,14 +170,41 @@ public: setDirtyFlag(true); mReplaced = true; mSettings = settings; + loadValuesFromLLSD(); + } + + virtual void replaceSettings(const ptr_t& other) + { + mBlendedFactor = 0.0; + setDirtyFlag(true); + mReplaced = true; + mSettingFlags = other->getFlags(); + mSettingName = other->getName(); + mSettingId = other->getId(); + mAssetId = other->getAssetId(); + setLLSDDirty(); + } + + void setSettings(LLSD settings) + { + setDirtyFlag(true); + mSettings = settings; + loadValuesFromLLSD(); } - virtual LLSD getSettings() const; + // if you are using getSettings to edit them, call setSettings(settings), + // replaceSettings(settings) or loadValuesFromLLSD() afterwards + virtual LLSD& getSettings(); + virtual void setLLSDDirty() + { + mLLSDDirty = true; + } //--------------------------------------------------------------------- // inline void setLLSD(const std::string &name, const LLSD &value) { + saveValuesIfNeeded(); mSettings[name] = value; mDirty = true; if (name != SETTING_ASSETID) @@ -202,8 +216,9 @@ public: setLLSD(name, value); } - inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) { + saveValuesIfNeeded(); if (!mSettings.has(name)) return deflt; return mSettings[name]; @@ -259,11 +274,11 @@ public: (const_cast<LLSettingsBase *>(this))->updateSettings(); } - virtual void blend(const ptr_t &end, BlendFactor blendf) = 0; + virtual void blend(ptr_t &end, BlendFactor blendf) = 0; virtual bool validate(); - virtual ptr_t buildDerivedClone() const = 0; + virtual ptr_t buildDerivedClone() = 0; class Validator { @@ -310,17 +325,24 @@ public: inline void setAssetId(LLUUID value) { // note that this skips setLLSD - mSettings[SETTING_ASSETID] = value; + mAssetId = value; + mLLSDDirty = true; } inline void clearAssetId() { - if (mSettings.has(SETTING_ASSETID)) - mSettings.erase(SETTING_ASSETID); + mAssetId.setNull(); + mLLSDDirty = true; } // Calculate any custom settings that may need to be cached. virtual void updateSettings() { mDirty = false; mReplaced = false; } + LLSD cloneSettings(); + + static void lerpVector2(LLVector2& a, const LLVector2& b, F32 mix); + static void lerpVector3(LLVector3& a, const LLVector3& b, F32 mix); + static void lerpColor(LLColor3& a, const LLColor3& b, F32 mix); + protected: LLSettingsBase(); @@ -331,7 +353,7 @@ protected: typedef std::set<std::string> stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix); + virtual void lerpSettings(LLSettingsBase &other, BlendFactor mix); // combining settings maps where it can based on mix rate // @settings initial value (mix==0) @@ -339,8 +361,8 @@ protected: // @defaults list of default values for legacy fields and (re)setting shaders // @mix from 0 to 1, ratio or rate of transition from initial 'settings' to 'other' // return interpolated and combined LLSD map - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix) const; - LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const; + static LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps); + static LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps); /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -353,32 +375,40 @@ protected: virtual validation_list_t getValidationList() const = 0; - // Apply any settings that need special handling. - virtual void applySpecial(void *, bool force = false) { }; + // Apply settings. + virtual void applyToUniforms(void *) { }; + virtual void applySpecial(void*, bool force = false) { }; virtual parammapping_t getParameterMap() const { return parammapping_t(); } - LLSD mSettings; - - LLSD cloneSettings() const; - inline void setBlendFactor(BlendFactor blendfactor) { mBlendedFactor = blendfactor; } - void replaceWith(LLSettingsBase::ptr_t other) + virtual void replaceWith(const LLSettingsBase::ptr_t other) { - replaceSettings(other->cloneSettings()); + replaceSettings(other); setBlendFactor(other->getBlendFactor()); } + virtual void loadValuesFromLLSD(); + virtual void saveValuesToLLSD(); + void saveValuesIfNeeded(); + + LLUUID mAssetId; + LLUUID mSettingId; + std::string mSettingName; + U32 mSettingFlags; + private: + bool mLLSDDirty; bool mDirty; bool mReplaced; // super dirty! - LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; + static LLSD combineSDMaps(const LLSD &first, const LLSD &other); + LLSD mSettings; BlendFactor mBlendedFactor; }; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 1e7de94414..2b189e7cca 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -124,33 +124,42 @@ static const F32 DEFAULT_MULTISLIDER_INCREMENT(0.005f); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + loadValuesFromLLSD(); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + replaceSettings(defaults()); } //========================================================================= -LLSD LLSettingsDay::getSettings() const +LLSD& LLSettingsDay::getSettings() { - LLSD settings(LLSD::emptyMap()); + if (!mDaySettings.emptyMap()) + { + return mDaySettings; + } + mDaySettings = LLSD::emptyMap(); + LLSD& settings = LLSettingsBase::getSettings(); - if (mSettings.has(SETTING_NAME)) - settings[SETTING_NAME] = mSettings[SETTING_NAME]; + if (settings.has(SETTING_NAME)) + mDaySettings[SETTING_NAME] = settings[SETTING_NAME]; - if (mSettings.has(SETTING_ID)) - settings[SETTING_ID] = mSettings[SETTING_ID]; + if (settings.has(SETTING_ID)) + mDaySettings[SETTING_ID] = settings[SETTING_ID]; - if (mSettings.has(SETTING_ASSETID)) - settings[SETTING_ASSETID] = mSettings[SETTING_ASSETID]; + if (settings.has(SETTING_ASSETID)) + mDaySettings[SETTING_ASSETID] = settings[SETTING_ASSETID]; - settings[SETTING_TYPE] = getSettingsType(); + mDaySettings[SETTING_TYPE] = getSettingsType(); std::map<std::string, LLSettingsBase::ptr_t> in_use; @@ -174,7 +183,7 @@ LLSD LLSettingsDay::getSettings() const } tracks.append(trackout); } - settings[SETTING_TRACKS] = tracks; + mDaySettings[SETTING_TRACKS] = tracks; LLSD frames(LLSD::emptyMap()); for (std::map<std::string, LLSettingsBase::ptr_t>::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) @@ -184,9 +193,15 @@ LLSD LLSettingsDay::getSettings() const frames[(*itFrame).first] = framesettings; } - settings[SETTING_FRAMES] = frames; + mDaySettings[SETTING_FRAMES] = frames; - return settings; + return mDaySettings; +} + +void LLSettingsDay::setLLSDDirty() +{ + mDaySettings = LLSD::emptyMap(); + LLSettingsBase::setLLSDDirty(); } bool LLSettingsDay::initialize(bool validate_frames) @@ -392,6 +407,8 @@ bool LLSettingsDay::initialize(bool validate_frames) mSettings[SETTING_ASSETID] = assetid; } + loadValuesFromLLSD(); + mInitialized = true; return true; } @@ -449,7 +466,7 @@ LLSD LLSettingsDay::defaults() return dfltsetting; } -void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F64 mix) +void LLSettingsDay::blend(LLSettingsBase::ptr_t &other, F64 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; } diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 917b0870f2..d37423ea9a 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -81,9 +81,10 @@ public: bool initialize(bool validate_frames = false); - virtual ptr_t buildClone() const = 0; - virtual ptr_t buildDeepCloneAndUncompress() const = 0; - virtual LLSD getSettings() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() = 0; + virtual ptr_t buildDeepCloneAndUncompress() = 0; + virtual LLSD& getSettings() SETTINGS_OVERRIDE; + virtual void setLLSDDirty() override; virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_DAYCYCLE; } @@ -91,7 +92,7 @@ public: virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -127,7 +128,7 @@ public: virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } LLSettingsBase::TrackPosition getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); LLSettingsBase::TrackPosition getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); @@ -143,6 +144,7 @@ protected: private: CycleList_t mDayTracks; + LLSD mDaySettings; LLSettingsBase::Seconds mLastUpdateTime; diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index cbec2f4906..3685915ffd 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -407,10 +407,11 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) : mNextRainbowTextureId(), mNextHaloTextureId() { + loadValuesFromLLSD(); } LLSettingsSky::LLSettingsSky(): - LLSettingsBase(), + LLSettingsBase(LLSettingsSky::defaults()), mNextSunTextureId(), mNextMoonTextureId(), mNextCloudTextureId(), @@ -418,6 +419,7 @@ LLSettingsSky::LLSettingsSky(): mNextRainbowTextureId(), mNextHaloTextureId() { + replaceSettings(defaults()); } void LLSettingsSky::replaceSettings(LLSD settings) @@ -431,7 +433,80 @@ void LLSettingsSky::replaceSettings(LLSD settings) mNextHaloTextureId.setNull(); } -void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) +void LLSettingsSky::replaceSettings(const LLSettingsBase::ptr_t& other_sky) +{ + LLSettingsBase::replaceSettings(other_sky); + + llassert(getSettingsType() == other_sky->getSettingsType()); + + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(other_sky); + + mCanAutoAdjust = other->mCanAutoAdjust; + mReflectionProbeAmbiance = other->mReflectionProbeAmbiance; + + mSunScale = other->mSunScale; + mSunRotation = other->mSunRotation; + mSunlightColor = other->mSunlightColor; + mStarBrightness = other->mStarBrightness; + mMoonBrightness = other->mMoonBrightness; + mMoonScale = other->mMoonScale; + mMoonRotation = other->mMoonRotation; + mMaxY = other->mMaxY; + mGlow = other->mGlow; + mGamma = other->mGamma; + mCloudVariance = other->mCloudVariance; + mCloudShadow = other->mCloudShadow; + mScrollRate = other->mScrollRate; + mCloudScale = other->mCloudScale; + mCloudPosDensity1 = other->mCloudPosDensity1; + mCloudPosDensity2 = other->mCloudPosDensity2; + mCloudColor = other->mCloudColor; + + mAbsorptionConfigs = other->mAbsorptionConfigs; + mMieConfigs = other->mMieConfigs; + mRayleighConfigs = other->mRayleighConfigs; + + mSunArcRadians = other->mSunArcRadians; + mSkyTopRadius = other->mSkyTopRadius; + mSkyBottomRadius = other->mSkyBottomRadius; + mSkyMoistureLevel = other->mSkyMoistureLevel; + mSkyDropletRadius = other->mSkyDropletRadius; + mSkyIceLevel = other->mSkyIceLevel; + mPlanetRadius = other->mPlanetRadius; + + mHasLegacyHaze = other->mHasLegacyHaze; + mDistanceMultiplier = other->mDistanceMultiplier; + mDensityMultiplier = other->mDensityMultiplier; + mHazeHorizon = other->mHazeHorizon; + mHazeDensity = other->mHazeDensity; + mBlueHorizon = other->mBlueHorizon; + mBlueDensity = other->mBlueDensity; + mAmbientColor = other->mAmbientColor; + + mLegacyDistanceMultiplier = other->mLegacyDistanceMultiplier; + mLegacyDensityMultiplier = other->mLegacyDensityMultiplier; + mLegacyHazeHorizon = other->mLegacyHazeHorizon; + mLegacyHazeDensity = other->mLegacyHazeDensity; + mLegacyBlueHorizon = other->mLegacyBlueHorizon; + mLegacyBlueDensity = other->mLegacyBlueDensity; + mLegacyAmbientColor = other->mLegacyAmbientColor; + + mSunTextureId = other->mSunTextureId; + mMoonTextureId = other->mMoonTextureId; + mCloudTextureId = other->mCloudTextureId; + mHaloTextureId = other->mHaloTextureId; + mRainbowTextureId = other->mRainbowTextureId; + mBloomTextureId = other->mBloomTextureId; + + mNextSunTextureId.setNull(); + mNextMoonTextureId.setNull(); + mNextCloudTextureId.setNull(); + mNextBloomTextureId.setNull(); + mNextRainbowTextureId.setNull(); + mNextHaloTextureId.setNull(); +} + +void LLSettingsSky::replaceWithSky(const LLSettingsSky::ptr_t& pother) { replaceWith(pother); @@ -443,61 +518,158 @@ void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) mNextHaloTextureId = pother->mNextHaloTextureId; } -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +bool lerp_legacy_color(LLColor3& a, bool& a_has_legacy, const LLColor3& b, bool b_has_legacy, const LLColor3& def, F32 mix) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - llassert(getSettingsType() == end->getSettingsType()); + if (b_has_legacy) + { + if (a_has_legacy) + { + LLSettingsBase::lerpColor(a, b, mix); + } + else + { + a = def; + LLSettingsBase::lerpColor(a, b, mix); + a_has_legacy = true; + } + } + else if (a_has_legacy) + { + LLSettingsBase::lerpColor(a, def, mix); + } + else + { + LLSettingsBase::lerpColor(a, b, mix); + } + return a_has_legacy; +} - LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); - if (other) +bool lerp_legacy_float(F32& a, bool& a_has_legacy, F32 b, bool b_has_legacy, F32 def, F32 mix) +{ + if (b_has_legacy) { - if (other->mSettings.has(SETTING_LEGACY_HAZE)) + if (a_has_legacy) { - if (!mSettings.has(SETTING_LEGACY_HAZE) || !mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - // Special case since SETTING_AMBIENT is both in outer and legacy maps, we prioritize legacy one - // see getAmbientColor(), we are about to replaceSettings(), so we are free to set it - setAmbientColor(getAmbientColor()); - } + a = lerp(a, b, mix); } else { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - // Special case due to ambient's duality - // We need to match 'other's' structure for interpolation. - // We are free to change mSettings, since we are about to reset it - mSettings[SETTING_AMBIENT] = getAmbientColor().getValue(); - mSettings[SETTING_LEGACY_HAZE].erase(SETTING_AMBIENT); - } + a = lerp(def, b, mix); + a_has_legacy = true; } + } + else if (!a_has_legacy) + { + a = lerp(a, b, mix); + } + else + { + a = lerp(a, def, mix); + } + return a_has_legacy; +} +void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + llassert(getSettingsType() == end->getSettingsType()); + + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); + if (other) + { LLUUID cloud_noise_id = getCloudNoiseTextureId(); LLUUID cloud_noise_id_next = other->getCloudNoiseTextureId(); - F64 cloud_shadow = 0; if (!cloud_noise_id.isNull() && cloud_noise_id_next.isNull()) { // If there is no cloud texture in destination, reduce coverage to imitate disappearance // See LLDrawPoolWLSky::renderSkyClouds... we don't blend present texture with null // Note: Probably can be done by shader - cloud_shadow = lerp((F32)mSettings[SETTING_CLOUD_SHADOW].asReal(), 0.f, (F32)blendf); + mCloudShadow = lerp(mCloudShadow, 0.f, (F32)blendf); cloud_noise_id_next = cloud_noise_id; } else if (cloud_noise_id.isNull() && !cloud_noise_id_next.isNull()) { // Source has no cloud texture, reduce initial coverage to imitate appearance // use same texture as destination - cloud_shadow = lerp(0.f, (F32)other->mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); + mCloudShadow = lerp(0.f, mCloudShadow, (F32)blendf); setCloudNoiseTextureId(cloud_noise_id_next); } else { - cloud_shadow = lerp((F32)mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)other->mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); + mCloudShadow = lerp(mCloudShadow, (F32)other->mCloudShadow, (F32)blendf); + } + + mSettingFlags |= other->mSettingFlags; + + mCanAutoAdjust = false; // no point? + + mSunRotation = slerp((F32)blendf, mSunRotation, other->mSunRotation); + mMoonRotation = slerp((F32)blendf, mMoonRotation, other->mMoonRotation); + lerpColor(mSunlightColor, other->mSunlightColor, (F32)blendf); + lerpColor(mGlow, other->mGlow, (F32)blendf); + mReflectionProbeAmbiance = lerp(mReflectionProbeAmbiance, other->mReflectionProbeAmbiance, (F32)blendf); + mSunScale = lerp(mSunScale, other->mSunScale, (F32)blendf); + mStarBrightness = lerp(mStarBrightness, other->mStarBrightness, (F32)blendf); + mMoonBrightness = lerp(mMoonBrightness, other->mMoonBrightness, (F32)blendf); + mMoonScale = lerp(mMoonScale, other->mMoonScale, (F32)blendf); + mMaxY = lerp(mMaxY, other->mMaxY, (F32)blendf); + mGamma = lerp(mGamma, other->mGamma, (F32)blendf); + mCloudVariance = lerp(mCloudVariance, other->mCloudVariance, (F32)blendf); + mCloudShadow = lerp(mCloudShadow, other->mCloudShadow, (F32)blendf); + mCloudScale = lerp(mCloudScale, other->mCloudScale, (F32)blendf); + lerpVector2(mScrollRate, other->mScrollRate, (F32)blendf); + lerpColor(mCloudPosDensity1, other->mCloudPosDensity1, (F32)blendf); + lerpColor(mCloudPosDensity2, other->mCloudPosDensity2, (F32)blendf); + lerpColor(mCloudColor, other->mCloudColor, (F32)blendf); + + mSunArcRadians = lerp(mSunArcRadians, other->mSunArcRadians, (F32)blendf); + mSkyTopRadius = lerp(mSkyTopRadius, other->mSkyTopRadius, (F32)blendf); + mSkyBottomRadius = lerp(mSkyBottomRadius, other->mSkyBottomRadius, (F32)blendf); + mSkyMoistureLevel = lerp(mSkyMoistureLevel, other->mSkyMoistureLevel, (F32)blendf); + mSkyDropletRadius = lerp(mSkyDropletRadius, other->mSkyDropletRadius, (F32)blendf); + mSkyIceLevel = lerp(mSkyIceLevel, other->mSkyIceLevel, (F32)blendf); + mPlanetRadius = lerp(mPlanetRadius, other->mPlanetRadius, (F32)blendf); + + // Legacy settings + + if (other->mHasLegacyHaze) + { + if (!mHasLegacyHaze || !mLegacyAmbientColor) + { + // Special case since SETTING_AMBIENT is both in outer and legacy maps, + // we prioritize legacy one + setAmbientColor(other->getAmbientColor()); + mLegacyAmbientColor = true; + mHasLegacyHaze = true; + } + } + else + { + if (mLegacyAmbientColor) + { + // Special case due to ambient's duality + mLegacyAmbientColor = false; + } } - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); - blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(cloud_shadow); - replaceSettings(blenddata); + mHasLegacyHaze |= lerp_legacy_float(mHazeHorizon, mLegacyHazeHorizon, other->mHazeHorizon, other->mLegacyHazeHorizon, 0.19f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mHazeDensity, mLegacyHazeDensity, other->mHazeDensity, other->mLegacyHazeDensity, 0.7f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mDistanceMultiplier, mLegacyDistanceMultiplier, other->mDistanceMultiplier, other->mLegacyDistanceMultiplier, 0.8f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mDensityMultiplier, mLegacyDensityMultiplier, other->mDensityMultiplier, other->mLegacyDensityMultiplier, 0.0001f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_color(mBlueHorizon, mLegacyBlueHorizon, other->mBlueHorizon, other->mLegacyBlueHorizon, LLColor3(0.4954f, 0.4954f, 0.6399f), (F32)blendf); + mHasLegacyHaze |= lerp_legacy_color(mBlueDensity, mLegacyBlueDensity, other->mBlueDensity, other->mLegacyBlueDensity, LLColor3(0.2447f, 0.4487f, 0.7599f), (F32)blendf); + + parammapping_t defaults = other->getParameterMap(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mAbsorptionConfigs = interpolateSDMap(mAbsorptionConfigs, other->mAbsorptionConfigs, defaults, blendf, skip, slerps); + mMieConfigs = interpolateSDMap(mMieConfigs, other->mMieConfigs, defaults, blendf, skip, slerps); + mRayleighConfigs = interpolateSDMap(mRayleighConfigs, other->mRayleighConfigs, defaults, blendf, skip, slerps); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); mNextCloudTextureId = cloud_noise_id_next; @@ -955,6 +1127,184 @@ void LLSettingsSky::updateSettings() calculateLightSettings(); } + +F32 get_float(bool &use_legacy, LLSD& settings, std::string key, F32 default_value) +{ + if (settings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && settings[LLSettingsSky::SETTING_LEGACY_HAZE].has(key)) + { + use_legacy = true; + return (F32)settings[LLSettingsSky::SETTING_LEGACY_HAZE][key].asReal(); + } + if (settings.has(key)) + { + return (F32)settings[key].asReal(); + } + use_legacy = true; + return default_value; +} + +LLColor3 get_color(bool& use_legacy, LLSD& settings, const std::string& key, const LLColor3& default_value) +{ + if (settings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && settings[LLSettingsSky::SETTING_LEGACY_HAZE].has(key)) + { + use_legacy = true; + return LLColor3(settings[LLSettingsSky::SETTING_LEGACY_HAZE][key]); + } + use_legacy = false; + if (settings.has(key)) + { + return LLColor3(settings[key]); + } + use_legacy = true; + return default_value; +} + + +void LLSettingsSky::loadValuesFromLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::loadValuesFromLLSD(); + + LLSD& settings = getSettings(); + mCanAutoAdjust = !settings.has(SETTING_REFLECTION_PROBE_AMBIANCE); + if (mCanAutoAdjust) + { + mReflectionProbeAmbiance = 0; + } + else + { + mReflectionProbeAmbiance = (F32)settings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + } + + mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID(); + mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID(); + mCloudTextureId = settings[SETTING_CLOUD_TEXTUREID].asUUID(); + mHaloTextureId = settings[SETTING_HALO_TEXTUREID].asUUID(); + mRainbowTextureId = settings[SETTING_RAINBOW_TEXTUREID].asUUID(); + mBloomTextureId = settings[SETTING_BLOOM_TEXTUREID].asUUID(); + + mSunScale = (F32)settings[SETTING_SUN_SCALE].asReal(); + mSunRotation = LLQuaternion(settings[SETTING_SUN_ROTATION]); + mSunlightColor = LLColor3(settings[SETTING_SUNLIGHT_COLOR]); + mStarBrightness = (F32)settings[SETTING_STAR_BRIGHTNESS].asReal(); + mMoonBrightness = (F32)settings[SETTING_MOON_BRIGHTNESS].asReal(); + mMoonScale = (F32)settings[SETTING_MOON_SCALE].asReal(); + mMoonRotation = LLQuaternion(settings[SETTING_MOON_ROTATION]); + mMaxY = (F32)settings[SETTING_MAX_Y].asReal(); + mGlow = LLColor3(settings[SETTING_GLOW]); + mGamma = (F32)settings[SETTING_GAMMA].asReal(); + mCloudVariance = (F32)settings[SETTING_CLOUD_VARIANCE].asReal(); + mCloudShadow = (F32)settings[SETTING_CLOUD_SHADOW].asReal(); + mScrollRate = LLVector2(settings[SETTING_CLOUD_SCROLL_RATE]); + mCloudScale = (F32)settings[SETTING_CLOUD_SCALE].asReal(); + mCloudPosDensity1 = LLColor3(settings[SETTING_CLOUD_POS_DENSITY1]); + mCloudPosDensity2 = LLColor3(settings[SETTING_CLOUD_POS_DENSITY2]); + mCloudColor = LLColor3(settings[SETTING_CLOUD_COLOR]); + mAbsorptionConfigs = settings[SETTING_ABSORPTION_CONFIG]; + mMieConfigs = settings[SETTING_MIE_CONFIG]; + mRayleighConfigs = settings[SETTING_RAYLEIGH_CONFIG]; + mSunArcRadians = (F32)settings[SETTING_SUN_ARC_RADIANS].asReal(); + mSkyTopRadius = (F32)settings[SETTING_SKY_TOP_RADIUS].asReal(); + mSkyBottomRadius = (F32)settings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + mSkyMoistureLevel = (F32)settings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + mSkyDropletRadius = (F32)settings[SETTING_SKY_DROPLET_RADIUS].asReal(); + mSkyIceLevel = (F32)settings[SETTING_SKY_ICE_LEVEL].asReal(); + mPlanetRadius = (F32)settings[SETTING_PLANET_RADIUS].asReal(); + + // special case for legacy handling + mHasLegacyHaze = settings.has(LLSettingsSky::SETTING_LEGACY_HAZE); + mDistanceMultiplier = get_float(mLegacyDistanceMultiplier, settings, SETTING_DISTANCE_MULTIPLIER, 0.8f); + mDensityMultiplier = get_float(mLegacyDensityMultiplier, settings, SETTING_DENSITY_MULTIPLIER, 0.0001f); + mHazeHorizon = get_float(mLegacyHazeHorizon, settings, SETTING_HAZE_HORIZON, 0.19f); + mHazeDensity = get_float(mLegacyHazeDensity, settings, SETTING_HAZE_DENSITY, 0.7f); + mBlueHorizon = get_color(mLegacyBlueHorizon, settings, SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); + mBlueDensity = get_color(mLegacyBlueDensity, settings, SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); + mAmbientColor = get_color(mLegacyAmbientColor, settings, SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + // one of these values might be true despite not having SETTING_LEGACY_HAZE if defaults were used + mHasLegacyHaze |= mLegacyDistanceMultiplier + || mLegacyDensityMultiplier + || mLegacyHazeHorizon + || mLegacyHazeDensity + || mLegacyBlueHorizon + || mLegacyBlueDensity + || mLegacyAmbientColor; +} + +void set_legacy(LLSD &settings, LLSD &legacy, const std::string& key, bool has_value, const LLSD & value) +{ + if (has_value) + { + legacy[key] = value; + } + else + { + settings[key] = value; + legacy.erase(key); + } +} + +void LLSettingsSky::saveValuesToLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::saveValuesToLLSD(); + + LLSD& settings = getSettings(); + + if (mCanAutoAdjust) + { + settings.erase(SETTING_REFLECTION_PROBE_AMBIANCE); + } + else + { + settings[SETTING_REFLECTION_PROBE_AMBIANCE] = mReflectionProbeAmbiance; + } + settings[SETTING_SUN_TEXTUREID] = mSunTextureId; + settings[SETTING_MOON_TEXTUREID] = mMoonTextureId; + settings[SETTING_CLOUD_TEXTUREID] = mCloudTextureId; + settings[SETTING_HALO_TEXTUREID] = mHaloTextureId; + settings[SETTING_RAINBOW_TEXTUREID] = mRainbowTextureId; + settings[SETTING_BLOOM_TEXTUREID] = mBloomTextureId; + + settings[SETTING_SUN_SCALE] = mSunScale; + settings[SETTING_SUN_ROTATION] = mSunRotation.getValue(); + settings[SETTING_SUNLIGHT_COLOR] = mSunlightColor.getValue(); + settings[SETTING_STAR_BRIGHTNESS] = mStarBrightness; + settings[SETTING_MOON_BRIGHTNESS] = mMoonBrightness; + settings[SETTING_MOON_SCALE] = mMoonScale; + settings[SETTING_MOON_ROTATION] = mMoonRotation.getValue(); + settings[SETTING_MAX_Y] = mMaxY; + settings[SETTING_GLOW] = mGlow.getValue(); + settings[SETTING_GAMMA] = mGamma; + settings[SETTING_CLOUD_VARIANCE] = mCloudVariance; + settings[SETTING_CLOUD_SHADOW] = mCloudShadow; + settings[SETTING_CLOUD_SCROLL_RATE] = mScrollRate.getValue(); + settings[SETTING_CLOUD_SCALE] = mCloudScale; + settings[SETTING_CLOUD_POS_DENSITY1] = mCloudPosDensity1.getValue(); + settings[SETTING_CLOUD_POS_DENSITY2] = mCloudPosDensity2.getValue(); + settings[SETTING_CLOUD_COLOR] = mCloudColor.getValue(); + settings[SETTING_ABSORPTION_CONFIG] = mAbsorptionConfigs; + settings[SETTING_MIE_CONFIG] = mMieConfigs; + settings[SETTING_RAYLEIGH_CONFIG] = mRayleighConfigs; + settings[SETTING_SUN_ARC_RADIANS] = mSunArcRadians; + settings[SETTING_SKY_TOP_RADIUS] = mSkyTopRadius; + settings[SETTING_SKY_BOTTOM_RADIUS] = mSkyBottomRadius; + settings[SETTING_SKY_MOISTURE_LEVEL] = mSkyMoistureLevel; + settings[SETTING_SKY_DROPLET_RADIUS] = mSkyDropletRadius; + settings[SETTING_SKY_ICE_LEVEL] = mSkyIceLevel; + settings[SETTING_PLANET_RADIUS] = mPlanetRadius; + + LLSD& legacy = settings[SETTING_LEGACY_HAZE]; + set_legacy(settings, legacy, SETTING_DISTANCE_MULTIPLIER, mLegacyDistanceMultiplier, LLSD::Real(mDistanceMultiplier)); + set_legacy(settings, legacy, SETTING_DENSITY_MULTIPLIER, mLegacyDensityMultiplier, LLSD::Real(mDensityMultiplier)); + set_legacy(settings, legacy, SETTING_HAZE_HORIZON, mLegacyHazeHorizon, LLSD::Real(mHazeHorizon)); + set_legacy(settings, legacy, SETTING_HAZE_DENSITY, mLegacyHazeDensity, LLSD::Real(mHazeDensity)); + set_legacy(settings, legacy, SETTING_BLUE_HORIZON, mLegacyBlueHorizon, mBlueHorizon.getValue()); + set_legacy(settings, legacy, SETTING_BLUE_DENSITY, mLegacyBlueDensity, mBlueDensity.getValue()); + set_legacy(settings, legacy, SETTING_AMBIENT, mLegacyAmbientColor, mAmbientColor.getValue()); +} + F32 LLSettingsSky::getSunMoonGlowFactor() const { return getIsSunUp() ? 1.0f : @@ -1024,37 +1374,40 @@ LLColor3 LLSettingsSky::getLightDiffuse() const return LLColor3::white; } -LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) const +LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + LLSD& settings = getSettings(); + if (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(key)) { - return LLColor3(mSettings[SETTING_LEGACY_HAZE][key]); + return LLColor3(settings[SETTING_LEGACY_HAZE][key]); } - if (mSettings.has(key)) + if (settings.has(key)) { - return LLColor3(mSettings[key]); + return LLColor3(settings[key]); } return default_value; } -F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) const +F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + + LLSD& settings = getSettings(); + if (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(key)) { - return (F32)mSettings[SETTING_LEGACY_HAZE][key].asReal(); + return (F32)settings[SETTING_LEGACY_HAZE][key].asReal(); } - if (mSettings.has(key)) + if (settings.has(key)) { - return (F32)mSettings[key].asReal(); + return (F32)settings[key].asReal(); } return default_value; } LLColor3 LLSettingsSky::getAmbientColor() const { - return getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + return mAmbientColor; } LLColor3 LLSettingsSky::getAmbientColorClamped() const @@ -1072,119 +1425,143 @@ LLColor3 LLSettingsSky::getAmbientColorClamped() const LLColor3 LLSettingsSky::getBlueDensity() const { - return getColor(SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); + return mBlueDensity; } LLColor3 LLSettingsSky::getBlueHorizon() const { - return getColor(SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); + return mBlueHorizon; } F32 LLSettingsSky::getHazeDensity() const { - return getFloat(SETTING_HAZE_DENSITY, 0.7f); + return mHazeDensity; } F32 LLSettingsSky::getHazeHorizon() const { - return getFloat(SETTING_HAZE_HORIZON, 0.19f); + return mHazeHorizon; } F32 LLSettingsSky::getDensityMultiplier() const { - return getFloat(SETTING_DENSITY_MULTIPLIER, 0.0001f); + return mDensityMultiplier; } F32 LLSettingsSky::getDistanceMultiplier() const { - return getFloat(SETTING_DISTANCE_MULTIPLIER, 0.8f); + return mDistanceMultiplier; } void LLSettingsSky::setPlanetRadius(F32 radius) { - mSettings[SETTING_PLANET_RADIUS] = radius; + mPlanetRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyBottomRadius(F32 radius) { - mSettings[SETTING_SKY_BOTTOM_RADIUS] = radius; + mSkyBottomRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyTopRadius(F32 radius) { - mSettings[SETTING_SKY_TOP_RADIUS] = radius; + mSkyTopRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSunArcRadians(F32 radians) { - mSettings[SETTING_SUN_ARC_RADIANS] = radians; + mSunArcRadians = radians; + setDirtyFlag(true); } void LLSettingsSky::setMieAnisotropy(F32 aniso_factor) { getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR] = aniso_factor; + setDirtyFlag(true); } void LLSettingsSky::setSkyMoistureLevel(F32 moisture_level) { - setValue(SETTING_SKY_MOISTURE_LEVEL, moisture_level); + mSkyMoistureLevel = moisture_level; + setDirtyFlag(true); } void LLSettingsSky::setSkyDropletRadius(F32 radius) { - setValue(SETTING_SKY_DROPLET_RADIUS,radius); + mSkyDropletRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyIceLevel(F32 ice_level) { - setValue(SETTING_SKY_ICE_LEVEL, ice_level); + mSkyIceLevel = ice_level; + setDirtyFlag(true); } void LLSettingsSky::setReflectionProbeAmbiance(F32 ambiance) { - setValue(SETTING_REFLECTION_PROBE_AMBIANCE, ambiance); + mReflectionProbeAmbiance = ambiance; + mCanAutoAdjust = false; + setLLSDDirty(); } void LLSettingsSky::setAmbientColor(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = val.getValue(); + mAmbientColor = val; + mLegacyAmbientColor = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueDensity(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY] = val.getValue(); + mBlueDensity = val; + mLegacyBlueDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueHorizon(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON] = val.getValue(); + mBlueHorizon = val; + mLegacyBlueHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDensityMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER] = val; + mDensityMultiplier = val; + mLegacyDensityMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDistanceMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER] = val; + mDistanceMultiplier = val; + mLegacyDistanceMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeDensity(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY] = val; + mHazeDensity = val; + mLegacyHazeDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeHorizon(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON] = val; + mHazeHorizon = val; + mLegacyHazeHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } // Get total from rayleigh and mie density values for normalization @@ -1299,7 +1676,7 @@ LLColor3 LLSettingsSky::getMoonlightColor() const return getSunlightColor(); //moon and sun share light color } -void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const +void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) { F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]); if (max_color > scale) @@ -1415,22 +1792,22 @@ LLUUID LLSettingsSky::GetDefaultHaloTextureId() F32 LLSettingsSky::getPlanetRadius() const { - return (F32)mSettings[SETTING_PLANET_RADIUS].asReal(); + return mPlanetRadius; } F32 LLSettingsSky::getSkyMoistureLevel() const { - return (F32)mSettings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + return mSkyMoistureLevel; } F32 LLSettingsSky::getSkyDropletRadius() const { - return (F32)mSettings[SETTING_SKY_DROPLET_RADIUS].asReal(); + return mSkyDropletRadius; } F32 LLSettingsSky::getSkyIceLevel() const { - return (F32)mSettings[SETTING_SKY_ICE_LEVEL].asReal(); + return mSkyIceLevel; } F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const @@ -1440,22 +1817,22 @@ F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const return sAutoAdjustProbeAmbiance; } - return (F32)mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + return mReflectionProbeAmbiance; } F32 LLSettingsSky::getSkyBottomRadius() const { - return (F32)mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + return mSkyBottomRadius; } F32 LLSettingsSky::getSkyTopRadius() const { - return (F32)mSettings[SETTING_SKY_TOP_RADIUS].asReal(); + return mSkyTopRadius; } F32 LLSettingsSky::getSunArcRadians() const { - return (F32)mSettings[SETTING_SUN_ARC_RADIANS].asReal(); + return mSunArcRadians; } F32 LLSettingsSky::getMieAnisotropy() const @@ -1465,158 +1842,171 @@ F32 LLSettingsSky::getMieAnisotropy() const LLSD LLSettingsSky::getRayleighConfig() const { - LLSD copy = *(mSettings[SETTING_RAYLEIGH_CONFIG].beginArray()); + LLSD copy = *(mRayleighConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getMieConfig() const { - LLSD copy = *(mSettings[SETTING_MIE_CONFIG].beginArray()); + LLSD copy = *(mMieConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getAbsorptionConfig() const { - LLSD copy = *(mSettings[SETTING_ABSORPTION_CONFIG].beginArray()); + LLSD copy = *(mAbsorptionConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getRayleighConfigs() const { - return mSettings[SETTING_RAYLEIGH_CONFIG]; + return mRayleighConfigs; } LLSD LLSettingsSky::getMieConfigs() const { - return mSettings[SETTING_MIE_CONFIG]; + return mMieConfigs; } LLSD LLSettingsSky::getAbsorptionConfigs() const { - return mSettings[SETTING_ABSORPTION_CONFIG]; + return mAbsorptionConfigs; } void LLSettingsSky::setRayleighConfigs(const LLSD& rayleighConfig) { - mSettings[SETTING_RAYLEIGH_CONFIG] = rayleighConfig; + mRayleighConfigs = rayleighConfig; + setLLSDDirty(); } void LLSettingsSky::setMieConfigs(const LLSD& mieConfig) { - mSettings[SETTING_MIE_CONFIG] = mieConfig; + mMieConfigs = mieConfig; + setLLSDDirty(); } void LLSettingsSky::setAbsorptionConfigs(const LLSD& absorptionConfig) { - mSettings[SETTING_ABSORPTION_CONFIG] = absorptionConfig; + mAbsorptionConfigs = absorptionConfig; + setLLSDDirty(); } LLUUID LLSettingsSky::getBloomTextureId() const { - return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); + return mBloomTextureId; } LLUUID LLSettingsSky::getRainbowTextureId() const { - return mSettings[SETTING_RAINBOW_TEXTUREID].asUUID(); + return mRainbowTextureId; } LLUUID LLSettingsSky::getHaloTextureId() const { - return mSettings[SETTING_HALO_TEXTUREID].asUUID(); + return mHaloTextureId; } //--------------------------------------------------------------------- LLColor3 LLSettingsSky::getCloudColor() const { - return LLColor3(mSettings[SETTING_CLOUD_COLOR]); + return mCloudColor; } void LLSettingsSky::setCloudColor(const LLColor3 &val) { - setValue(SETTING_CLOUD_COLOR, val); + mCloudColor = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getCloudNoiseTextureId() const { - return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); + return mCloudTextureId; } void LLSettingsSky::setCloudNoiseTextureId(const LLUUID &id) { - setValue(SETTING_CLOUD_TEXTUREID, id); + mCloudTextureId = id; + setLLSDDirty(); } LLColor3 LLSettingsSky::getCloudPosDensity1() const { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); + return mCloudPosDensity1; } void LLSettingsSky::setCloudPosDensity1(const LLColor3 &val) { - setValue(SETTING_CLOUD_POS_DENSITY1, val); + mCloudPosDensity1 = val; + setLLSDDirty(); } LLColor3 LLSettingsSky::getCloudPosDensity2() const { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); + return mCloudPosDensity2; } void LLSettingsSky::setCloudPosDensity2(const LLColor3 &val) { - setValue(SETTING_CLOUD_POS_DENSITY2, val); + mCloudPosDensity2 = val; + setLLSDDirty(); } F32 LLSettingsSky::getCloudScale() const { - return (F32)mSettings[SETTING_CLOUD_SCALE].asReal(); + return mCloudScale; } void LLSettingsSky::setCloudScale(F32 val) { - setValue(SETTING_CLOUD_SCALE, val); + mCloudScale = val; + setLLSDDirty(); } LLVector2 LLSettingsSky::getCloudScrollRate() const { - return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); + return mScrollRate; } void LLSettingsSky::setCloudScrollRate(const LLVector2 &val) { - setValue(SETTING_CLOUD_SCROLL_RATE, val); + mScrollRate = val; + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateX(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; + mScrollRate.mV[0] = val; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateY(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; + mScrollRate.mV[1] = val; setDirtyFlag(true); + setLLSDDirty(); } F32 LLSettingsSky::getCloudShadow() const { - return (F32)mSettings[SETTING_CLOUD_SHADOW].asReal(); + return mCloudShadow; } void LLSettingsSky::setCloudShadow(F32 val) { - setValue(SETTING_CLOUD_SHADOW, val); + mCloudShadow = val; + setLLSDDirty(); } F32 LLSettingsSky::getCloudVariance() const { - return (F32)mSettings[SETTING_CLOUD_VARIANCE].asReal(); + return mCloudVariance; } void LLSettingsSky::setCloudVariance(F32 val) { - setValue(SETTING_CLOUD_VARIANCE, val); + mCloudVariance = val; + setLLSDDirty(); } F32 LLSettingsSky::getDomeOffset() const @@ -1633,88 +2023,95 @@ F32 LLSettingsSky::getDomeRadius() const F32 LLSettingsSky::getGamma() const { - return (F32)mSettings[SETTING_GAMMA].asReal(); + return mGamma; } void LLSettingsSky::setGamma(F32 val) { - mSettings[SETTING_GAMMA] = LLSD::Real(val); + mGamma = val; setDirtyFlag(true); + setLLSDDirty(); } - LLColor3 LLSettingsSky::getGlow() const { - return LLColor3(mSettings[SETTING_GLOW]); + return mGlow; } void LLSettingsSky::setGlow(const LLColor3 &val) { - setValue(SETTING_GLOW, val); + mGlow = val; + setLLSDDirty(); } F32 LLSettingsSky::getMaxY() const { - return (F32)mSettings[SETTING_MAX_Y].asReal(); + return mMaxY; } void LLSettingsSky::setMaxY(F32 val) { - setValue(SETTING_MAX_Y, val); + mMaxY = val; + setLLSDDirty(); } LLQuaternion LLSettingsSky::getMoonRotation() const { - return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); + return mMoonRotation; } void LLSettingsSky::setMoonRotation(const LLQuaternion &val) { - setValue(SETTING_MOON_ROTATION, val); + mMoonRotation = val; + setLLSDDirty(); } F32 LLSettingsSky::getMoonScale() const { - return (F32)mSettings[SETTING_MOON_SCALE].asReal(); + return mMoonScale; } void LLSettingsSky::setMoonScale(F32 val) { - setValue(SETTING_MOON_SCALE, val); + mMoonScale = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getMoonTextureId() const { - return mSettings[SETTING_MOON_TEXTUREID].asUUID(); + return mMoonTextureId; } void LLSettingsSky::setMoonTextureId(LLUUID id) { - setValue(SETTING_MOON_TEXTUREID, id); + mMoonTextureId = id; + setLLSDDirty(); } F32 LLSettingsSky::getMoonBrightness() const { - return (F32)mSettings[SETTING_MOON_BRIGHTNESS].asReal(); + return mMoonBrightness; } void LLSettingsSky::setMoonBrightness(F32 brightness_factor) { - setValue(SETTING_MOON_BRIGHTNESS, brightness_factor); + mMoonBrightness = brightness_factor; + setLLSDDirty(); } F32 LLSettingsSky::getStarBrightness() const { - return (F32)mSettings[SETTING_STAR_BRIGHTNESS].asReal(); + return mStarBrightness; } void LLSettingsSky::setStarBrightness(F32 val) { - setValue(SETTING_STAR_BRIGHTNESS, val); + mStarBrightness = val; + setLLSDDirty(); } LLColor3 LLSettingsSky::getSunlightColor() const { - return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); + return mSunlightColor; } LLColor3 LLSettingsSky::getSunlightColorClamped() const @@ -1733,38 +2130,41 @@ LLColor3 LLSettingsSky::getSunlightColorClamped() const void LLSettingsSky::setSunlightColor(const LLColor3 &val) { - setValue(SETTING_SUNLIGHT_COLOR, val); + mSunlightColor = val; + setLLSDDirty(); } LLQuaternion LLSettingsSky::getSunRotation() const { - return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); + return mSunRotation; } void LLSettingsSky::setSunRotation(const LLQuaternion &val) { - setValue(SETTING_SUN_ROTATION, val); + mSunRotation = val; + setLLSDDirty(); } - F32 LLSettingsSky::getSunScale() const { - return (F32)mSettings[SETTING_SUN_SCALE].asReal(); + return mSunScale; } void LLSettingsSky::setSunScale(F32 val) { - setValue(SETTING_SUN_SCALE, val); + mSunScale = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getSunTextureId() const { - return mSettings[SETTING_SUN_TEXTUREID].asUUID(); + return mSunTextureId; } void LLSettingsSky::setSunTextureId(LLUUID id) { - setValue(SETTING_SUN_TEXTUREID, id); + mSunTextureId = id; + setLLSDDirty(); } LLUUID LLSettingsSky::getNextSunTextureId() const @@ -1790,5 +2190,5 @@ LLUUID LLSettingsSky::getNextBloomTextureId() const // if true, this sky is a candidate for auto-adjustment bool LLSettingsSky::canAutoAdjust() const { - return !mSettings.has(SETTING_REFLECTION_PROBE_AMBIANCE); + return mCanAutoAdjust; } diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 40bb337a48..38c0368423 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -111,20 +111,24 @@ public: LLSettingsSky(const LLSD &data); virtual ~LLSettingsSky() { }; - virtual ptr_t buildClone() const = 0; + virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("sky"); } virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_SKY; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; + virtual void replaceSettings(const LLSettingsBase::ptr_t& other_sky) override; - void replaceWithSky(LLSettingsSky::ptr_t pother); + void replaceWithSky(const LLSettingsSky::ptr_t& pother); static LLSD defaults(const LLSettingsBase::TrackPosition& position = 0.0f); + void loadValuesFromLLSD() override; + void saveValuesToLLSD() override; + F32 getPlanetRadius() const; F32 getSkyBottomRadius() const; F32 getSkyTopRadius() const; @@ -306,7 +310,7 @@ public: LLColor3 getSunlightColorClamped() const; LLColor3 getAmbientColorClamped() const; - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultSunTextureId(); @@ -348,6 +352,12 @@ protected: virtual stringset_t getSlerpKeys() const SETTINGS_OVERRIDE; virtual stringset_t getSkipInterpolateKeys() const SETTINGS_OVERRIDE; + LLUUID mSunTextureId; + LLUUID mMoonTextureId; + LLUUID mCloudTextureId; + LLUUID mBloomTextureId; + LLUUID mRainbowTextureId; + LLUUID mHaloTextureId; LLUUID mNextSunTextureId; LLUUID mNextMoonTextureId; LLUUID mNextCloudTextureId; @@ -355,17 +365,64 @@ protected: LLUUID mNextRainbowTextureId; LLUUID mNextHaloTextureId; + bool mCanAutoAdjust; + LLQuaternion mSunRotation; + LLQuaternion mMoonRotation; + LLColor3 mSunlightColor; + LLColor3 mGlow; + F32 mReflectionProbeAmbiance; + F32 mSunScale; + F32 mStarBrightness; + F32 mMoonBrightness; + F32 mMoonScale; + F32 mMaxY; + F32 mGamma; + F32 mCloudVariance; + F32 mCloudShadow; + F32 mCloudScale; + LLVector2 mScrollRate; + LLColor3 mCloudPosDensity1; + LLColor3 mCloudPosDensity2; + LLColor3 mCloudColor; + LLSD mAbsorptionConfigs; + LLSD mMieConfigs; + LLSD mRayleighConfigs; + F32 mSunArcRadians; + F32 mSkyTopRadius; + F32 mSkyBottomRadius; + F32 mSkyMoistureLevel; + F32 mSkyDropletRadius; + F32 mSkyIceLevel; + F32 mPlanetRadius; + + F32 mHazeHorizon; + F32 mHazeDensity; + F32 mDistanceMultiplier; + F32 mDensityMultiplier; + LLColor3 mBlueHorizon; + LLColor3 mBlueDensity; + LLColor3 mAmbientColor; + + bool mHasLegacyHaze; + bool mLegacyHazeHorizon; + bool mLegacyHazeDensity; + bool mLegacyDistanceMultiplier; + bool mLegacyDensityMultiplier; + bool mLegacyBlueHorizon; + bool mLegacyBlueDensity; + bool mLegacyAmbientColor; + private: static LLSD rayleighConfigDefault(); static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); - LLColor3 getColor(const std::string& key, const LLColor3& default_value) const; - F32 getFloat(const std::string& key, F32 default_value) const; + LLColor3 getColor(const std::string& key, const LLColor3& default_value); + F32 getFloat(const std::string& key, F32 default_value); void calculateHeavenlyBodyPositions() const; void calculateLightSettings() const; - void clampColor(LLColor3& color, F32 gamma, const F32 scale = 1.0f) const; + static void clampColor(LLColor3& color, F32 gamma, const F32 scale = 1.0f); mutable LLVector3 mSunDirection; mutable LLVector3 mMoonDirection; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 161b8cda25..08e18ea26e 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -68,14 +68,18 @@ static const LLUUID DEFAULT_OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf8631 //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : LLSettingsBase(data), - mNextNormalMapID() + mNextNormalMapID(), + mNextTransparentTextureID() { + loadValuesFromLLSD(); } LLSettingsWater::LLSettingsWater() : LLSettingsBase(), - mNextNormalMapID() + mNextNormalMapID(), + mNextTransparentTextureID() { + replaceSettings(defaults()); } //========================================================================= @@ -109,6 +113,53 @@ LLSD LLSettingsWater::defaults(const LLSettingsBase::TrackPosition& position) return dfltsetting; } +void LLSettingsWater::loadValuesFromLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::loadValuesFromLLSD(); + + LLSD& settings = getSettings(); + + mBlurMultiplier = (F32)settings[SETTING_BLUR_MULTIPLIER].asReal(); + mWaterFogColor = LLColor3(settings[SETTING_FOG_COLOR]); + mWaterFogDensity = (F32)settings[SETTING_FOG_DENSITY].asReal(); + mFogMod = (F32)settings[SETTING_FOG_MOD].asReal(); + mFresnelOffset = (F32)settings[SETTING_FRESNEL_OFFSET].asReal(); + mFresnelScale = (F32)settings[SETTING_FRESNEL_SCALE].asReal(); + mNormalScale = LLVector3(settings[SETTING_NORMAL_SCALE]); + mScaleAbove = (F32)settings[SETTING_SCALE_ABOVE].asReal(); + mScaleBelow = (F32)settings[SETTING_SCALE_BELOW].asReal(); + mWave1Dir = LLVector2(settings[SETTING_WAVE1_DIR]); + mWave2Dir = LLVector2(settings[SETTING_WAVE2_DIR]); + + mNormalMapID = getNormalMapID(); + mTransparentTextureID = getTransparentTextureID(); +} + +void LLSettingsWater::saveValuesToLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::saveValuesToLLSD(); + + LLSD & settings = getSettings(); + settings[SETTING_BLUR_MULTIPLIER] = LLSD::Real(mBlurMultiplier); + settings[SETTING_FOG_COLOR] = mWaterFogColor.getValue(); + settings[SETTING_FOG_DENSITY] = LLSD::Real(mWaterFogDensity); + settings[SETTING_FOG_MOD] = LLSD::Real(mFogMod); + settings[SETTING_FRESNEL_OFFSET] = LLSD::Real(mFresnelOffset); + settings[SETTING_FRESNEL_SCALE] = LLSD::Real(mFresnelScale); + settings[SETTING_NORMAL_SCALE] = mNormalScale.getValue(); + settings[SETTING_SCALE_ABOVE] = LLSD::Real(mScaleAbove); + settings[SETTING_SCALE_BELOW] = LLSD::Real(mScaleBelow); + settings[SETTING_WAVE1_DIR] = mWave1Dir.getValue(); + settings[SETTING_WAVE2_DIR] = mWave2Dir.getValue(); + + settings[SETTING_NORMAL_MAP] = mNormalMapID; + settings[SETTING_TRANSPARENT_TEXTURE] = mTransparentTextureID; +} + LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) { bool converted_something(false); @@ -180,13 +231,30 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) return newsettings; } -void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +void LLSettingsWater::blend(LLSettingsBase::ptr_t &end, F64 blendf) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast<LLSettingsWater>(end); if (other) { - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); - replaceSettings(blenddata); + mSettingFlags |= other->mSettingFlags; + + mBlurMultiplier = lerp((F32)blendf, mBlurMultiplier, other->mBlurMultiplier); + lerpColor(mWaterFogColor, other->mWaterFogColor, (F32)blendf); + mWaterFogDensity = lerp((F32)blendf, mWaterFogDensity, other->mWaterFogDensity); + mFogMod = lerp((F32)blendf, mFogMod, other->mFogMod); + mFresnelOffset = lerp((F32)blendf, mFresnelOffset, other->mFresnelOffset); + mFresnelScale = lerp((F32)blendf, mFresnelScale, other->mFresnelScale); + lerpVector3(mNormalScale, other->mNormalScale, (F32)blendf); + mScaleAbove = lerp((F32)blendf, mScaleAbove, other->mScaleAbove); + mScaleBelow = lerp((F32)blendf, mScaleBelow, other->mScaleBelow); + lerpVector2(mWave1Dir, other->mWave1Dir, (F32)blendf); + lerpVector2(mWave2Dir, other->mWave2Dir, (F32)blendf); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + mNextNormalMapID = other->getNormalMapID(); mNextTransparentTextureID = other->getTransparentTextureID(); } @@ -204,7 +272,34 @@ void LLSettingsWater::replaceSettings(LLSD settings) mNextTransparentTextureID.setNull(); } -void LLSettingsWater::replaceWithWater(LLSettingsWater::ptr_t other) +void LLSettingsWater::replaceSettings(const LLSettingsBase::ptr_t& other_water) +{ + LLSettingsBase::replaceSettings(other_water); + + llassert(getSettingsType() == other_water->getSettingsType()); + + LLSettingsWater::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsWater>(other_water); + + mBlurMultiplier = other->mBlurMultiplier; + mWaterFogColor = other->mWaterFogColor; + mWaterFogDensity = other->mWaterFogDensity; + mFogMod = other->mFogMod; + mFresnelOffset = other->mFresnelOffset; + mFresnelScale = other->mFresnelScale; + mNormalScale = other->mNormalScale; + mScaleAbove = other->mScaleAbove; + mScaleBelow = other->mScaleBelow; + mWave1Dir = other->mWave1Dir; + mWave2Dir = other->mWave2Dir; + + mNormalMapID = other->mNormalMapID; + mTransparentTextureID = other->mTransparentTextureID; + + mNextNormalMapID.setNull(); + mNextTransparentTextureID.setNull(); +} + +void LLSettingsWater::replaceWithWater(const LLSettingsWater::ptr_t& other) { replaceWith(other); diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 9e7ff61272..82fc37cfb3 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -55,151 +55,181 @@ public: LLSettingsWater(const LLSD &data); virtual ~LLSettingsWater() { }; - virtual ptr_t buildClone() const = 0; + virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("water"); } virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_WATER; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; - void replaceWithWater(LLSettingsWater::ptr_t other); + virtual void replaceSettings(const LLSettingsBase::ptr_t& other_water) override; + void replaceWithWater(const LLSettingsWater::ptr_t& other); static LLSD defaults(const LLSettingsBase::TrackPosition& position = 0.0f); + void loadValuesFromLLSD() override; + void saveValuesToLLSD() override; + //--------------------------------------------------------------------- F32 getBlurMultiplier() const { - return (F32)mSettings[SETTING_BLUR_MULTIPLIER].asReal(); + return mBlurMultiplier; } void setBlurMultiplier(F32 val) { - setValue(SETTING_BLUR_MULTIPLIER, val); + mBlurMultiplier = val; + setDirtyFlag(true); + setLLSDDirty(); } LLColor3 getWaterFogColor() const { - return LLColor3(mSettings[SETTING_FOG_COLOR]); + return mWaterFogColor; } void setWaterFogColor(LLColor3 val) { - setValue(SETTING_FOG_COLOR, val); + mWaterFogColor = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getWaterFogDensity() const { - return (F32)mSettings[SETTING_FOG_DENSITY].asReal(); + return mWaterFogDensity; } F32 getModifiedWaterFogDensity(bool underwater) const; void setWaterFogDensity(F32 val) { - setValue(SETTING_FOG_DENSITY, val); + mWaterFogDensity = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFogMod() const { - return (F32)mSettings[SETTING_FOG_MOD].asReal(); + return mFogMod; } void setFogMod(F32 val) { - setValue(SETTING_FOG_MOD, val); + mFogMod = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFresnelOffset() const { - return (F32)mSettings[SETTING_FRESNEL_OFFSET].asReal(); + return mFresnelOffset; } void setFresnelOffset(F32 val) { - setValue(SETTING_FRESNEL_OFFSET, val); + mFresnelOffset = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFresnelScale() const { - return (F32)mSettings[SETTING_FRESNEL_SCALE].asReal(); + return mFresnelScale; } void setFresnelScale(F32 val) { - setValue(SETTING_FRESNEL_SCALE, val); + mFresnelScale = val; + setDirtyFlag(true); + setLLSDDirty(); } LLUUID getTransparentTextureID() const { - return mSettings[SETTING_TRANSPARENT_TEXTURE].asUUID(); + return mTransparentTextureID; } void setTransparentTextureID(LLUUID val) { - setValue(SETTING_TRANSPARENT_TEXTURE, val); + mTransparentTextureID = val; + setDirtyFlag(true); + setLLSDDirty(); } LLUUID getNormalMapID() const { - return mSettings[SETTING_NORMAL_MAP].asUUID(); + return mNormalMapID; } void setNormalMapID(LLUUID val) { - setValue(SETTING_NORMAL_MAP, val); + mNormalMapID = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector3 getNormalScale() const { - return LLVector3(mSettings[SETTING_NORMAL_SCALE]); + return mNormalScale; } void setNormalScale(LLVector3 val) { - setValue(SETTING_NORMAL_SCALE, val); + mNormalScale = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getScaleAbove() const { - return (F32)mSettings[SETTING_SCALE_ABOVE].asReal(); + return mScaleAbove; } void setScaleAbove(F32 val) { - setValue(SETTING_SCALE_ABOVE, val); + mScaleAbove = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getScaleBelow() const { - return (F32)mSettings[SETTING_SCALE_BELOW].asReal(); + return mScaleBelow; } void setScaleBelow(F32 val) { - setValue(SETTING_SCALE_BELOW, val); + mScaleBelow = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector2 getWave1Dir() const { - return LLVector2(mSettings[SETTING_WAVE1_DIR]); + return mWave1Dir; } void setWave1Dir(LLVector2 val) { - setValue(SETTING_WAVE1_DIR, val); + mWave1Dir = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector2 getWave2Dir() const { - return LLVector2(mSettings[SETTING_WAVE2_DIR]); + return mWave2Dir; } void setWave2Dir(LLVector2 val) { - setValue(SETTING_WAVE2_DIR, val); + mWave2Dir = val; + setDirtyFlag(true); + setLLSDDirty(); } //------------------------------------------- @@ -218,7 +248,7 @@ public: static LLSD translateLegacySettings(LLSD legacy); - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultWaterNormalAssetId(); @@ -241,9 +271,22 @@ protected: LLSettingsWater(); + LLUUID mTransparentTextureID; + LLUUID mNormalMapID; LLUUID mNextTransparentTextureID; LLUUID mNextNormalMapID; + F32 mBlurMultiplier; + LLColor3 mWaterFogColor; + F32 mWaterFogDensity; + F32 mFogMod; + F32 mFresnelOffset; + F32 mFresnelScale; + LLVector3 mNormalScale; + F32 mScaleAbove; + F32 mScaleBelow; + LLVector2 mWave1Dir; + LLVector2 mWave2Dir; }; #endif diff --git a/indra/llmath/llrigginginfo.h b/indra/llmath/llrigginginfo.h index fb550d013f..d761af68b1 100644 --- a/indra/llmath/llrigginginfo.h +++ b/indra/llmath/llrigginginfo.h @@ -66,6 +66,10 @@ public: const LLJointRiggingInfo& operator[](S32 i) const { return mRigInfoPtr[i]; }; bool needsUpdate() { return mNeedsUpdate; } void setNeedsUpdate(bool val) { mNeedsUpdate = val; } + + LLJointRiggingInfo* begin() { return mRigInfoPtr; } + LLJointRiggingInfo* end() { return mRigInfoPtr + mSize; } + private: // Not implemented LLJointRiggingInfoTab& operator=(const LLJointRiggingInfoTab& src); diff --git a/indra/llmath/llsdutil_math.cpp b/indra/llmath/llsdutil_math.cpp index 0ea1a9c77a..2d5ec7d510 100644 --- a/indra/llmath/llsdutil_math.cpp +++ b/indra/llmath/llsdutil_math.cpp @@ -38,8 +38,7 @@ #include "v4color.h" #if LL_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include <winsock2.h> // for htonl +# include "llwin32headers.h" // for htonl #elif LL_LINUX # include <netinet/in.h> #elif LL_DARWIN diff --git a/indra/llmessage/llhost.cpp b/indra/llmessage/llhost.cpp index ace316512f..e7e3e27f58 100644 --- a/indra/llmessage/llhost.cpp +++ b/indra/llmessage/llhost.cpp @@ -31,8 +31,7 @@ #include "llerror.h" #if LL_WINDOWS - #define WIN32_LEAN_AND_MEAN - #include <winsock2.h> + #include <llwin32headers.h> #else #include <netdb.h> #include <netinet/in.h> // ntonl() diff --git a/indra/llmessage/lliopipe.h b/indra/llmessage/lliopipe.h index 1887b5cd9a..b40539f38c 100644 --- a/indra/llmessage/lliopipe.h +++ b/indra/llmessage/lliopipe.h @@ -30,7 +30,7 @@ #define LL_LLIOPIPE_H #include <boost/intrusive_ptr.hpp> -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include "apr_poll.h" #include "llsd.h" diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index 0a3f2617e6..4b79c77b56 100644 --- a/indra/llmessage/lliosocket.h +++ b/indra/llmessage/lliosocket.h @@ -38,7 +38,7 @@ */ #include "lliopipe.h" -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include "apr_pools.h" #include "apr_network_io.h" #include "llchainio.h" diff --git a/indra/llmessage/llmail.cpp b/indra/llmessage/llmail.cpp index 9e10a356db..b842aeda62 100644 --- a/indra/llmessage/llmail.cpp +++ b/indra/llmessage/llmail.cpp @@ -28,7 +28,6 @@ #include "llmail.h" -// APR on Windows needs full windows headers #include "llwin32headers.h" #include <string> #include <sstream> diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp index 1c49f9be36..f153c938cf 100644 --- a/indra/llmessage/net.cpp +++ b/indra/llmessage/net.cpp @@ -32,7 +32,7 @@ #include <stdexcept> #if LL_WINDOWS -#include "llwin32headerslean.h" +#include "llwin32headers.h" #else #include <sys/types.h> #include <sys/socket.h> diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index bd1e19c294..908f3c8ff5 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -48,7 +48,7 @@ LLPluginProcessParentOwner::~LLPluginProcessParentOwner() bool LLPluginProcessParent::sUseReadThread = false; apr_pollset_t *LLPluginProcessParent::sPollSet = NULL; bool LLPluginProcessParent::sPollsetNeedsRebuild = false; -LLCoros::Mutex *LLPluginProcessParent::sInstancesMutex; +LLCoros::Mutex *LLPluginProcessParent::sInstancesMutex = nullptr; LLPluginProcessParent::mapInstances_t LLPluginProcessParent::sInstances; LLThread *LLPluginProcessParent::sReadThread = NULL; @@ -155,6 +155,12 @@ LLPluginProcessParent::ptr_t LLPluginProcessParent::create(LLPluginProcessParent /*static*/ void LLPluginProcessParent::shutdown() { + if (!sInstancesMutex) + { + // setup was not complete, skip shutdown + return; + } + LLCoros::LockType lock(*sInstancesMutex); mapInstances_t::iterator it; diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 19a43839af..3d8e02cb16 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -7,7 +7,6 @@ include(LLCommon) include(LLCoreHttp) include(LLPhysicsExtensions) include(LLPrimitive) -include(GLH) include(GLM) include(TinyGLTF) @@ -70,7 +69,7 @@ target_link_libraries(llprimitive llrender llphysicsextensions_impl ll::colladadom - ll::glh_linear + ll::glm ) #add unit tests diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 34af3ffece..7fa4230237 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -51,7 +51,8 @@ #include "llsdserialize.h" #include "lljoint.h" -#include "glh/glh_linear.h" +#include "glm/mat4x4.hpp" +#include "glm/gtc/type_ptr.hpp" #include "llmatrix4a.h" #include <boost/regex.hpp> @@ -1216,9 +1217,9 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do mesh_scale *= normalized_transformation; normalized_transformation = mesh_scale; - glh::matrix4f inv_mat((F32*) normalized_transformation.mMatrix); - inv_mat = inv_mat.inverse(); - LLMatrix4 inverse_normalized_transformation(inv_mat.m); + glm::mat4 inv_mat = glm::make_mat4((F32*)normalized_transformation.mMatrix); + inv_mat = glm::inverse(inv_mat); + LLMatrix4 inverse_normalized_transformation(glm::value_ptr(inv_mat)); domSkin::domBind_shape_matrix* bind_mat = skin->getBind_shape_matrix(); diff --git a/indra/llprimitive/llgltfloader.cpp b/indra/llprimitive/llgltfloader.cpp index 776f81cc01..480012699a 100644 --- a/indra/llprimitive/llgltfloader.cpp +++ b/indra/llprimitive/llgltfloader.cpp @@ -51,7 +51,6 @@ #include "llsdserialize.h" #include "lljoint.h" -#include "glh/glh_linear.h" #include "llmatrix4a.h" #include <boost/regex.hpp> diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 77992d93a4..4e3e49ec9f 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1543,6 +1543,13 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) mLockScaleIfJointPosition = false; } + // combine mBindShapeMatrix and mInvBindMatrix into mBindPoseMatrix + mBindPoseMatrix.resize(mInvBindMatrix.size()); + for (U32 i = 0; i < mInvBindMatrix.size(); ++i) + { + matMul(mBindShapeMatrix, mInvBindMatrix[i], mBindPoseMatrix[i]); + } + updateHash(); } diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index bd2ac68bed..c89037a2d2 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -56,12 +56,15 @@ public: LLUUID mMeshID; std::vector<std::string> mJointNames; mutable std::vector<S32> mJointNums; - typedef std::vector<LLMatrix4a, boost::alignment::aligned_allocator<LLMatrix4a, 16>> matrix_list_t; + typedef std::vector<LLMatrix4a> matrix_list_t; matrix_list_t mInvBindMatrix; // bones/joints position overrides matrix_list_t mAlternateBindMatrix; + // cached multiply of mBindShapeMatrix and mInvBindMatrix + matrix_list_t mBindPoseMatrix; + LL_ALIGN_16(LLMatrix4a mBindShapeMatrix); float mPelvisOffset; diff --git a/indra/llprimitive/llmodelloader.cpp b/indra/llprimitive/llmodelloader.cpp index 1a64e6227f..84adec4da5 100644 --- a/indra/llprimitive/llmodelloader.cpp +++ b/indra/llprimitive/llmodelloader.cpp @@ -31,7 +31,6 @@ #include "lljoint.h" #include "llcallbacklist.h" -#include "glh/glh_linear.h" #include "llmatrix4a.h" #include <boost/bind.hpp> diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 9721b020c7..94daba0817 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -271,9 +271,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons const LLFontGlyphInfo* next_glyph = NULL; static constexpr S32 GLYPH_BATCH_SIZE = 30; - static thread_local LLVector3 vertices[GLYPH_BATCH_SIZE * 4]; - static thread_local LLVector2 uvs[GLYPH_BATCH_SIZE * 4]; - static thread_local LLColor4U colors[GLYPH_BATCH_SIZE * 4]; + static thread_local LLVector4a vertices[GLYPH_BATCH_SIZE * 6]; + static thread_local LLVector2 uvs[GLYPH_BATCH_SIZE * 6]; + static thread_local LLColor4U colors[GLYPH_BATCH_SIZE * 6]; LLColor4U text_color(color); // Preserve the transparency to render fading emojis in fading text (e.g. @@ -305,9 +305,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons // otherwise the queued glyphs will be taken from wrong textures. if (glyph_count > 0) { - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 6); } gGL.end(); glyph_count = 0; @@ -338,9 +338,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons if (glyph_count >= GLYPH_BATCH_SIZE) { - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 6); } gGL.end(); @@ -376,9 +376,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_render_y = cur_y; } - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 6); } gGL.end(); @@ -1227,31 +1227,42 @@ LLFontGL &LLFontGL::operator=(const LLFontGL &source) return *this; } -void LLFontGL::renderQuad(LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, F32 slant_amt) const +void LLFontGL::renderTriangle(LLVector4a* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, F32 slant_amt) const { S32 index = 0; - vertex_out[index] = LLVector3(screen_rect.mRight, screen_rect.mTop, 0.f); - uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mTop); + vertex_out[index].set(screen_rect.mRight, screen_rect.mTop, 0.f); + uv_out[index].set(uv_rect.mRight, uv_rect.mTop); colors_out[index] = color; index++; - vertex_out[index] = LLVector3(screen_rect.mLeft, screen_rect.mTop, 0.f); - uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop); + vertex_out[index].set(screen_rect.mLeft, screen_rect.mTop, 0.f); + uv_out[index].set(uv_rect.mLeft, uv_rect.mTop); colors_out[index] = color; index++; - vertex_out[index] = LLVector3(screen_rect.mLeft, screen_rect.mBottom, 0.f); - uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom); + vertex_out[index].set(screen_rect.mLeft, screen_rect.mBottom, 0.f); + uv_out[index].set(uv_rect.mLeft, uv_rect.mBottom); colors_out[index] = color; index++; - vertex_out[index] = LLVector3(screen_rect.mRight, screen_rect.mBottom, 0.f); - uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom); + + vertex_out[index].set(screen_rect.mRight, screen_rect.mTop, 0.f); + uv_out[index].set(uv_rect.mRight, uv_rect.mTop); + colors_out[index] = color; + index++; + + vertex_out[index].set(screen_rect.mLeft, screen_rect.mBottom, 0.f); + uv_out[index].set(uv_rect.mLeft, uv_rect.mBottom); + colors_out[index] = color; + index++; + + vertex_out[index].set(screen_rect.mRight, screen_rect.mBottom, 0.f); + uv_out[index].set(uv_rect.mRight, uv_rect.mBottom); colors_out[index] = color; } -void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_strength) const +void LLFontGL::drawGlyph(S32& glyph_count, LLVector4a* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_strength) const { F32 slant_offset; slant_offset = ((style & ITALIC) ? ( -mFontFreetype->getAscenderHeight() * 0.2f) : 0.f); @@ -1265,7 +1276,7 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_ LLRectf screen_rect_offset = screen_rect; screen_rect_offset.translate((F32)(pass * BOLD_OFFSET), 0.f); - renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, color, slant_offset); + renderTriangle(&vertex_out[glyph_count * 6], &uv_out[glyph_count * 6], &colors_out[glyph_count * 6], screen_rect_offset, uv_rect, color, slant_offset); glyph_count++; } } @@ -1296,10 +1307,10 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_ break; } - renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, shadow_color, slant_offset); + renderTriangle(&vertex_out[glyph_count * 6], &uv_out[glyph_count * 6], &colors_out[glyph_count * 6], screen_rect_offset, uv_rect, shadow_color, slant_offset); glyph_count++; } - renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset); + renderTriangle(&vertex_out[glyph_count * 6], &uv_out[glyph_count * 6], &colors_out[glyph_count * 6], screen_rect, uv_rect, color, slant_offset); glyph_count++; } else if (shadow == DROP_SHADOW) @@ -1308,14 +1319,14 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_ shadow_color.mV[VALPHA] = U8(color.mV[VALPHA] * drop_shadow_strength); LLRectf screen_rect_shadow = screen_rect; screen_rect_shadow.translate(1.f, -1.f); - renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_shadow, uv_rect, shadow_color, slant_offset); + renderTriangle(&vertex_out[glyph_count * 6], &uv_out[glyph_count * 6], &colors_out[glyph_count * 6], screen_rect_shadow, uv_rect, shadow_color, slant_offset); glyph_count++; - renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset); + renderTriangle(&vertex_out[glyph_count * 6], &uv_out[glyph_count * 6], &colors_out[glyph_count * 6], screen_rect, uv_rect, color, slant_offset); glyph_count++; } else // normal rendering { - renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset); + renderTriangle(&vertex_out[glyph_count * 6], &uv_out[glyph_count * 6], &colors_out[glyph_count * 6], screen_rect, uv_rect, color, slant_offset); glyph_count++; } } diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index de7529a583..4bb6c55c65 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -238,8 +238,8 @@ private: LLFontDescriptor mFontDescriptor; LLPointer<LLFontFreetype> mFontFreetype; - void renderQuad(LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, F32 slant_amt) const; - void drawGlyph(S32& glyph_count, LLVector3* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_fade) const; + void renderTriangle(LLVector4a* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, F32 slant_amt) const; + void drawGlyph(S32& glyph_count, LLVector4a* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_fade) const; // Registry holds all instantiated fonts. static LLFontRegistry* sFontRegistry; diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp index 96ec94fe0f..392f235aad 100644 --- a/indra/llrender/llfontvertexbuffer.cpp +++ b/indra/llrender/llfontvertexbuffer.cpp @@ -42,6 +42,8 @@ LLFontVertexBuffer::~LLFontVertexBuffer() void LLFontVertexBuffer::reset() { + // Todo: some form of debug only frequecy check&assert to see if this is happening too often. + // Regenerating this list is expensive mBufferList.clear(); } diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 02996ecc86..15fb289de3 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -50,6 +50,10 @@ #include "llglheaders.h" #include "llglslshader.h" +#include "glm/glm.hpp" +#include <glm/gtc/matrix_access.hpp> +#include "glm/gtc/type_ptr.hpp" + #if LL_WINDOWS #include "lldxhardware.h" #endif @@ -1162,6 +1166,11 @@ bool LLGLManager::initGL() mGLVendorShort = "INTEL"; mIsIntel = true; } + else if (mGLVendor.find("APPLE") != std::string::npos) + { + mGLVendorShort = "APPLE"; + mIsApple = true; + } else { mGLVendorShort = "MISC"; @@ -2691,7 +2700,7 @@ void parse_glsl_version(S32& major, S32& minor) LLStringUtil::convertToS32(minor_str, minor); } -LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply) +LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glm::mat4& modelview, const glm::mat4& projection, bool apply) { mApply = apply; @@ -2718,13 +2727,12 @@ void LLGLUserClipPlane::disable() void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d) { - glh::matrix4f& P = mProjection; - glh::matrix4f& M = mModelview; + const glm::mat4& P = mProjection; + const glm::mat4& M = mModelview; - glh::matrix4f invtrans_MVP = (P * M).inverse().transpose(); - glh::vec4f oplane(a,b,c,d); - glh::vec4f cplane; - invtrans_MVP.mult_matrix_vec(oplane, cplane); + glm::mat4 invtrans_MVP = glm::transpose(glm::inverse(P*M)); + glm::vec4 oplane(a,b,c,d); + glm::vec4 cplane = invtrans_MVP * oplane; cplane /= fabs(cplane[2]); // normalize such that depth is not scaled cplane[3] -= 1; @@ -2732,13 +2740,13 @@ void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d) if(cplane[2] < 0) cplane *= -1; - glh::matrix4f suffix; - suffix.set_row(2, cplane); - glh::matrix4f newP = suffix * P; + glm::mat4 suffix; + suffix = glm::row(suffix, 2, cplane); + glm::mat4 newP = suffix * P; gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); - gGL.loadMatrix(newP.m); - gGLObliqueProjectionInverse = LLMatrix4(newP.inverse().transpose().m); + gGL.loadMatrix(glm::value_ptr(newP)); + gGLObliqueProjectionInverse = LLMatrix4(glm::value_ptr(glm::transpose(glm::inverse(newP)))); gGL.matrixMode(LLRender::MM_MODELVIEW); } @@ -2835,31 +2843,27 @@ void LLGLDepthTest::checkState() LLGLSquashToFarClip::LLGLSquashToFarClip() { - glh::matrix4f proj = get_current_projection(); + glm::mat4 proj = get_current_projection(); setProjectionMatrix(proj, 0); } -LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f& P, U32 layer) +LLGLSquashToFarClip::LLGLSquashToFarClip(const glm::mat4& P, U32 layer) { setProjectionMatrix(P, layer); } - -void LLGLSquashToFarClip::setProjectionMatrix(glh::matrix4f& projection, U32 layer) +void LLGLSquashToFarClip::setProjectionMatrix(glm::mat4 projection, U32 layer) { - F32 depth = 0.99999f - 0.0001f * layer; - for (U32 i = 0; i < 4; i++) - { - projection.element(2, i) = projection.element(3, i) * depth; - } + glm::vec4 P_row_3 = glm::row(projection, 3) * depth; + projection = glm::row(projection, 2, P_row_3); LLRender::eMatrixMode last_matrix_mode = gGL.getMatrixMode(); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); - gGL.loadMatrix(projection.m); + gGL.loadMatrix(glm::value_ptr(projection)); gGL.matrixMode(last_matrix_mode); } diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index cd1ba55b16..f5b1e8d786 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -43,7 +43,7 @@ #include "llinstancetracker.h" #include "llglheaders.h" -#include "glh/glh_linear.h" +#include "glm/mat4x4.hpp" extern bool gDebugGL; extern bool gDebugSession; @@ -102,6 +102,7 @@ public: bool mIsAMD; bool mIsNVIDIA; bool mIsIntel; + bool mIsApple = false; // hints to the render pipe U32 mDownScaleMethod = 0; // see settings.xml RenderDownScaleMethod @@ -317,7 +318,7 @@ class LLGLUserClipPlane { public: - LLGLUserClipPlane(const LLPlane& plane, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply = true); + LLGLUserClipPlane(const LLPlane& plane, const glm::mat4& modelview, const glm::mat4& projection, bool apply = true); ~LLGLUserClipPlane(); void setPlane(F32 a, F32 b, F32 c, F32 d); @@ -326,8 +327,8 @@ public: private: bool mApply; - glh::matrix4f mProjection; - glh::matrix4f mModelview; + glm::mat4 mProjection; + glm::mat4 mModelview; }; /* @@ -341,9 +342,9 @@ class LLGLSquashToFarClip { public: LLGLSquashToFarClip(); - LLGLSquashToFarClip(glh::matrix4f& projection, U32 layer = 0); + LLGLSquashToFarClip(const glm::mat4& projection, U32 layer = 0); - void setProjectionMatrix(glh::matrix4f& projection, U32 layer); + void setProjectionMatrix(glm::mat4 projection, U32 layer); ~LLGLSquashToFarClip(); }; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index df23a9da1d..921adc0f8c 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -62,7 +62,7 @@ // LL_WINDOWS // windows gl headers depend on things like APIENTRY, so include windows. -#include "llwin32headerslean.h" +#include "llwin32headers.h" //---------------------------------------------------------------------------- #include <GL/gl.h> diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index a157bfee21..6ba5463acd 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -63,6 +63,7 @@ U64 LLGLSLShader::sTotalTimeElapsed = 0; U32 LLGLSLShader::sTotalTrianglesDrawn = 0; U64 LLGLSLShader::sTotalSamplesDrawn = 0; U32 LLGLSLShader::sTotalBinds = 0; +boost::json::value LLGLSLShader::sDefaultStats; //UI shader -- declared here so llui_libtest will link properly LLGLSLShader gUIProgram; @@ -101,9 +102,9 @@ void LLGLSLShader::initProfile() sTotalSamplesDrawn = 0; sTotalBinds = 0; - for (std::set<LLGLSLShader*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter) + for (auto ptr : sInstances) { - (*iter)->clearStats(); + ptr->clearStats(); } } @@ -117,45 +118,57 @@ struct LLGLSLShaderCompareTimeElapsed }; //static -void LLGLSLShader::finishProfile(bool emit_report) +void LLGLSLShader::finishProfile(boost::json::value& statsv) { sProfileEnabled = false; - if (emit_report) + if (! statsv.is_null()) { - std::vector<LLGLSLShader*> sorted; - - for (std::set<LLGLSLShader*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter) - { - sorted.push_back(*iter); - } - + std::vector<LLGLSLShader*> sorted(sInstances.begin(), sInstances.end()); std::sort(sorted.begin(), sorted.end(), LLGLSLShaderCompareTimeElapsed()); + auto& stats = statsv.as_object(); + auto shadersit = stats.emplace("shaders", boost::json::array_kind).first; + auto& shaders = shadersit->value().as_array(); bool unbound = false; - for (std::vector<LLGLSLShader*>::iterator iter = sorted.begin(); iter != sorted.end(); ++iter) + for (auto ptr : sorted) { - (*iter)->dumpStats(); - if ((*iter)->mBinds == 0) + if (ptr->mBinds == 0) { unbound = true; } + else + { + auto& shaderit = shaders.emplace_back(boost::json::object_kind); + ptr->dumpStats(shaderit.as_object()); + } } + constexpr float mega = 1'000'000.f; + float totalTimeMs = sTotalTimeElapsed / mega; LL_INFOS() << "-----------------------------------" << LL_ENDL; - LL_INFOS() << "Total rendering time: " << llformat("%.4f ms", sTotalTimeElapsed / 1000000.f) << LL_ENDL; - LL_INFOS() << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn / 1000000.f) << LL_ENDL; - LL_INFOS() << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn / 1000000.f) << LL_ENDL; + LL_INFOS() << "Total rendering time: " << llformat("%.4f ms", totalTimeMs) << LL_ENDL; + LL_INFOS() << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn / mega) << LL_ENDL; + LL_INFOS() << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn / mega) << LL_ENDL; LL_INFOS() << "-----------------------------------" << LL_ENDL; - + auto totalsit = stats.emplace("totals", boost::json::object_kind).first; + auto& totals = totalsit->value().as_object(); + totals.emplace("time", totalTimeMs / 1000.0); + totals.emplace("binds", sTotalBinds); + totals.emplace("samples", sTotalSamplesDrawn); + totals.emplace("triangles", sTotalTrianglesDrawn); + + auto unusedit = stats.emplace("unused", boost::json::array_kind).first; + auto& unused = unusedit->value().as_array(); if (unbound) { LL_INFOS() << "The following shaders were unused: " << LL_ENDL; - for (std::vector<LLGLSLShader*>::iterator iter = sorted.begin(); iter != sorted.end(); ++iter) + for (auto ptr : sorted) { - if ((*iter)->mBinds == 0) + if (ptr->mBinds == 0) { - LL_INFOS() << (*iter)->mName << LL_ENDL; + LL_INFOS() << ptr->mName << LL_ENDL; + unused.emplace_back(ptr->mName); } } } @@ -170,36 +183,43 @@ void LLGLSLShader::clearStats() mBinds = 0; } -void LLGLSLShader::dumpStats() +void LLGLSLShader::dumpStats(boost::json::object& stats) { - if (mBinds > 0) + stats.emplace("name", mName); + auto filesit = stats.emplace("files", boost::json::array_kind).first; + auto& files = filesit->value().as_array(); + LL_INFOS() << "=============================================" << LL_ENDL; + LL_INFOS() << mName << LL_ENDL; + for (U32 i = 0; i < mShaderFiles.size(); ++i) { - LL_INFOS() << "=============================================" << LL_ENDL; - LL_INFOS() << mName << LL_ENDL; - for (U32 i = 0; i < mShaderFiles.size(); ++i) - { - LL_INFOS() << mShaderFiles[i].first << LL_ENDL; - } - LL_INFOS() << "=============================================" << LL_ENDL; + LL_INFOS() << mShaderFiles[i].first << LL_ENDL; + files.emplace_back(mShaderFiles[i].first); + } + LL_INFOS() << "=============================================" << LL_ENDL; - F32 ms = mTimeElapsed / 1000000.f; - F32 seconds = ms / 1000.f; + constexpr float mega = 1'000'000.f; + constexpr double giga = 1'000'000'000.0; + F32 ms = mTimeElapsed / mega; + F32 seconds = ms / 1000.f; - F32 pct_tris = (F32)mTrianglesDrawn / (F32)sTotalTrianglesDrawn * 100.f; - F32 tris_sec = (F32)(mTrianglesDrawn / 1000000.0); - tris_sec /= seconds; + F32 pct_tris = (F32)mTrianglesDrawn / (F32)sTotalTrianglesDrawn * 100.f; + F32 tris_sec = (F32)(mTrianglesDrawn / mega); + tris_sec /= seconds; - F32 pct_samples = (F32)((F64)mSamplesDrawn / (F64)sTotalSamplesDrawn) * 100.f; - F32 samples_sec = (F32)(mSamplesDrawn / 1000000000.0); - samples_sec /= seconds; + F32 pct_samples = (F32)((F64)mSamplesDrawn / (F64)sTotalSamplesDrawn) * 100.f; + F32 samples_sec = (F32)(mSamplesDrawn / giga); + samples_sec /= seconds; - F32 pct_binds = (F32)mBinds / (F32)sTotalBinds * 100.f; + F32 pct_binds = (F32)mBinds / (F32)sTotalBinds * 100.f; - LL_INFOS() << "Triangles Drawn: " << mTrianglesDrawn << " " << llformat("(%.2f pct of total, %.3f million/sec)", pct_tris, tris_sec) << LL_ENDL; - LL_INFOS() << "Binds: " << mBinds << " " << llformat("(%.2f pct of total)", pct_binds) << LL_ENDL; - LL_INFOS() << "SamplesDrawn: " << mSamplesDrawn << " " << llformat("(%.2f pct of total, %.3f billion/sec)", pct_samples, samples_sec) << LL_ENDL; - LL_INFOS() << "Time Elapsed: " << mTimeElapsed << " " << llformat("(%.2f pct of total, %.5f ms)\n", (F32)((F64)mTimeElapsed / (F64)sTotalTimeElapsed) * 100.f, ms) << LL_ENDL; - } + LL_INFOS() << "Triangles Drawn: " << mTrianglesDrawn << " " << llformat("(%.2f pct of total, %.3f million/sec)", pct_tris, tris_sec) << LL_ENDL; + LL_INFOS() << "Binds: " << mBinds << " " << llformat("(%.2f pct of total)", pct_binds) << LL_ENDL; + LL_INFOS() << "SamplesDrawn: " << mSamplesDrawn << " " << llformat("(%.2f pct of total, %.3f billion/sec)", pct_samples, samples_sec) << LL_ENDL; + LL_INFOS() << "Time Elapsed: " << mTimeElapsed << " " << llformat("(%.2f pct of total, %.5f ms)\n", (F32)((F64)mTimeElapsed / (F64)sTotalTimeElapsed) * 100.f, ms) << LL_ENDL; + stats.emplace("time", seconds); + stats.emplace("binds", mBinds); + stats.emplace("samples", mSamplesDrawn); + stats.emplace("triangles", mTrianglesDrawn); } //static diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 27c8f0b7d0..2d669c70a9 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -30,6 +30,7 @@ #include "llgl.h" #include "llrender.h" #include "llstaticstringtable.h" +#include <boost/json.hpp> #include <unordered_map> class LLShaderFeatures @@ -169,14 +170,14 @@ public: static U32 sMaxGLTFNodes; static void initProfile(); - static void finishProfile(bool emit_report = true); + static void finishProfile(boost::json::value& stats=sDefaultStats); static void startProfile(); static void stopProfile(); void unload(); void clearStats(); - void dumpStats(); + void dumpStats(boost::json::object& stats); // place query objects for profiling if profiling is enabled // if for_runtime is true, will place timer query only whether or not profiling is enabled @@ -363,6 +364,11 @@ public: private: void unloadInternal(); + // This must be static because finishProfile() is called at least once + // within a __try block. If we default its stats parameter to a temporary + // json::value, that temporary must be destroyed when the stack is + // unwound, which __try forbids. + static boost::json::value sDefaultStats; }; //UI shader (declared here so llui_libtest will link properly) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 68c20048ec..67b4ada62f 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1045,15 +1045,47 @@ void sub_image_lines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 w { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + LL_PROFILE_ZONE_NUM(width); + LL_PROFILE_ZONE_NUM(height); + U32 components = LLImageGL::dataFormatComponents(pixformat); U32 type_width = type_width_from_pixtype(pixtype); const U32 line_width = data_width * components * type_width; const U32 y_offset_end = y_offset + height; - for (U32 y_pos = y_offset; y_pos < y_offset_end; ++y_pos) + + if (width == data_width && height % 32 == 0) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("subimage - batched lines"); + + // full width, batch multiple lines at a time + // set batch size based on width + U32 batch_size = 32; + + if (width > 1024) + { + batch_size = 8; + } + else if (width > 512) + { + batch_size = 16; + } + + // full width texture, do 32 lines at a time + for (U32 y_pos = y_offset; y_pos < y_offset_end; y_pos += batch_size) + { + glTexSubImage2D(target, miplevel, x_offset, y_pos, width, batch_size, pixformat, pixtype, src); + src += line_width * batch_size; + } + } + else { - glTexSubImage2D(target, miplevel, x_offset, y_pos, width, 1, pixformat, pixtype, src); - src += line_width; + // partial width or strange height + for (U32 y_pos = y_offset; y_pos < y_offset_end; y_pos += 1) + { + glTexSubImage2D(target, miplevel, x_offset, y_pos, width, 1, pixformat, pixtype, src); + src += line_width; + } } } @@ -2139,6 +2171,8 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h) return ; } + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + U32 length = w * h; U32 alphatotal = 0; @@ -2150,15 +2184,15 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h) // this will mid-skew the data (and thus increase the chances of not // being used as a mask) from high-frequency alpha maps which // suffer the worst from aliasing when used as alpha masks. - if (w >= 2 && h >= 2) + if (w >= 4 && h >= 4) { - llassert(w%2 == 0); - llassert(h%2 == 0); + llassert(w%4 == 0); + llassert(h%4 == 0); const GLubyte* rowstart = ((const GLubyte*) data_in) + mAlphaOffset; - for (U32 y = 0; y < h; y+=2) + for (U32 y = 0; y < h; y+=4) { const GLubyte* current = rowstart; - for (U32 x = 0; x < w; x+=2) + for (U32 x = 0; x < w; x+=4) { const U32 s1 = current[0]; alphatotal += s1; @@ -2182,7 +2216,7 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h) } - rowstart += 2 * w * mAlphaStride; + rowstart += 4 * w * mAlphaStride; } length *= 2; // we sampled everything twice, essentially } diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 828a509971..e182b870dc 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -36,6 +36,7 @@ #include "lltexture.h" #include "llshadermgr.h" #include "hbxxh.h" +#include "glm/gtc/type_ptr.hpp" #if LL_WINDOWS extern void APIENTRY gl_debug_callback(GLenum source, @@ -57,8 +58,8 @@ F32 gGLLastProjection[16]; F32 gGLProjection[16]; // transform from last frame's camera space to this frame's camera space (and inverse) -F32 gGLDeltaModelView[16]; -F32 gGLInverseDeltaModelView[16]; +glm::mat4 gGLDeltaModelView; +glm::mat4 gGLInverseDeltaModelView; S32 gGLViewport[4]; @@ -735,10 +736,10 @@ void LLLightState::setPosition(const LLVector4& position) ++gGL.mLightHash; mPosition = position; //transform position by current modelview matrix - glh::vec4f pos(position.mV); - const glh::matrix4f& mat = gGL.getModelviewMatrix(); - mat.mult_matrix_vec(pos); - mPosition.set(pos.v); + glm::vec4 pos(glm::make_vec4(position.mV)); + const glm::mat4& mat = gGL.getModelviewMatrix(); + pos = mat * pos; + mPosition.set(glm::value_ptr(pos)); } void LLLightState::setConstantAttenuation(const F32& atten) @@ -790,19 +791,18 @@ void LLLightState::setSpotDirection(const LLVector3& direction) { //always set direction because modelview matrix may have changed ++gGL.mLightHash; - mSpotDirection = direction; + //transform direction by current modelview matrix - glh::vec3f dir(direction.mV); - const glh::matrix4f& mat = gGL.getModelviewMatrix(); - mat.mult_matrix_dir(dir); + glm::vec3 dir(glm::make_vec3(direction.mV)); + const glm::mat3 mat(gGL.getModelviewMatrix()); + dir = mat * dir; - mSpotDirection.set(dir.v); + mSpotDirection.set(glm::value_ptr(dir)); } LLRender::LLRender() : mDirty(false), mCount(0), - mQuadCycle(0), mMode(LLRender::TRIANGLES), mCurrTextureUnitIndex(0) { @@ -830,6 +830,10 @@ LLRender::LLRender() for (U32 i = 0; i < NUM_MATRIX_MODES; ++i) { + for (U32 j = 0; j < LL_MATRIX_STACK_DEPTH; ++j) + { + mMatrix[i][j] = glm::identity<glm::mat4>(); + } mMatIdx[i] = 0; mMatHash[i] = 0; mCurMatHash[i] = 0xFFFFFFFF; @@ -991,12 +995,12 @@ void LLRender::syncMatrices() LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; - static glh::matrix4f cached_mvp; - static glh::matrix4f cached_inv_mdv; + static glm::mat4 cached_mvp; + static glm::mat4 cached_inv_mdv; static U32 cached_mvp_mdv_hash = 0xFFFFFFFF; static U32 cached_mvp_proj_hash = 0xFFFFFFFF; - static glh::matrix4f cached_normal; + static glm::mat4 cached_normal; static U32 cached_normal_hash = 0xFFFFFFFF; if (shader) @@ -1006,15 +1010,15 @@ void LLRender::syncMatrices() U32 i = MM_MODELVIEW; if (mMatHash[MM_MODELVIEW] != shader->mMatHash[MM_MODELVIEW]) { //update modelview, normal, and MVP - glh::matrix4f& mat = mMatrix[MM_MODELVIEW][mMatIdx[MM_MODELVIEW]]; + const glm::mat4& mat = mMatrix[MM_MODELVIEW][mMatIdx[MM_MODELVIEW]]; // if MDV has changed, update the cached inverse as well if (cached_mvp_mdv_hash != mMatHash[MM_MODELVIEW]) { - cached_inv_mdv = mat.inverse(); + cached_inv_mdv = glm::inverse(mat); } - shader->uniformMatrix4fv(name[MM_MODELVIEW], 1, GL_FALSE, mat.m); + shader->uniformMatrix4fv(name[MM_MODELVIEW], 1, GL_FALSE, glm::value_ptr(mat)); shader->mMatHash[MM_MODELVIEW] = mMatHash[MM_MODELVIEW]; //update normal matrix @@ -1023,17 +1027,17 @@ void LLRender::syncMatrices() { if (cached_normal_hash != mMatHash[i]) { - cached_normal = cached_inv_mdv.transpose(); + cached_normal = glm::transpose(cached_inv_mdv); cached_normal_hash = mMatHash[i]; } - glh::matrix4f& norm = cached_normal; + auto norm = glm::value_ptr(cached_normal); F32 norm_mat[] = { - norm.m[0], norm.m[1], norm.m[2], - norm.m[4], norm.m[5], norm.m[6], - norm.m[8], norm.m[9], norm.m[10] + norm[0], norm[1], norm[2], + norm[4], norm[5], norm[6], + norm[8], norm[9], norm[10] }; shader->uniformMatrix3fv(LLShaderMgr::NORMAL_MATRIX, 1, GL_FALSE, norm_mat); @@ -1041,7 +1045,7 @@ void LLRender::syncMatrices() if (shader->getUniformLocation(LLShaderMgr::INVERSE_MODELVIEW_MATRIX)) { - shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, GL_FALSE, cached_inv_mdv.m); + shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, GL_FALSE, glm::value_ptr(cached_inv_mdv)); } //update MVP matrix @@ -1054,36 +1058,36 @@ void LLRender::syncMatrices() if (cached_mvp_mdv_hash != mMatHash[i] || cached_mvp_proj_hash != mMatHash[MM_PROJECTION]) { cached_mvp = mat; - cached_mvp.mult_left(mMatrix[proj][mMatIdx[proj]]); + cached_mvp = mMatrix[proj][mMatIdx[proj]] * cached_mvp; cached_mvp_mdv_hash = mMatHash[i]; cached_mvp_proj_hash = mMatHash[MM_PROJECTION]; } - shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m); + shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, glm::value_ptr(cached_mvp)); } } i = MM_PROJECTION; if (mMatHash[MM_PROJECTION] != shader->mMatHash[MM_PROJECTION]) { //update projection matrix, normal, and MVP - glh::matrix4f& mat = mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]]; + const glm::mat4& mat = mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]]; // GZ: This was previously disabled seemingly due to a bug involving the deferred renderer's regular pushing and popping of mats. // We're reenabling this and cleaning up the code around that - that would've been the appropriate course initially. // Anything beyond the standard proj and inv proj mats are special cases. Please setup special uniforms accordingly in the future. if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX)) { - glh::matrix4f inv_proj = mat.inverse(); - shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, false, inv_proj.m); + glm::mat4 inv_proj = glm::inverse(mat); + shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, false, glm::value_ptr(inv_proj)); } // Used by some full screen effects - such as full screen lights, glow, etc. if (shader->getUniformLocation(LLShaderMgr::IDENTITY_MATRIX)) { - shader->uniformMatrix4fv(LLShaderMgr::IDENTITY_MATRIX, 1, GL_FALSE, glh::matrix4f::identity().m); + shader->uniformMatrix4fv(LLShaderMgr::IDENTITY_MATRIX, 1, GL_FALSE, glm::value_ptr(glm::identity<glm::mat4>())); } - shader->uniformMatrix4fv(name[MM_PROJECTION], 1, GL_FALSE, mat.m); + shader->uniformMatrix4fv(name[MM_PROJECTION], 1, GL_FALSE, glm::value_ptr(mat)); shader->mMatHash[MM_PROJECTION] = mMatHash[MM_PROJECTION]; if (!mvp_done) @@ -1096,12 +1100,12 @@ void LLRender::syncMatrices() { U32 mdv = MM_MODELVIEW; cached_mvp = mat; - cached_mvp.mult_right(mMatrix[mdv][mMatIdx[mdv]]); + cached_mvp *= mMatrix[mdv][mMatIdx[mdv]]; cached_mvp_mdv_hash = mMatHash[MM_MODELVIEW]; cached_mvp_proj_hash = mMatHash[MM_PROJECTION]; } - shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m); + shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, glm::value_ptr(cached_mvp)); } } } @@ -1110,7 +1114,7 @@ void LLRender::syncMatrices() { if (mMatHash[i] != shader->mMatHash[i]) { - shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mMatrix[i][mMatIdx[i]].m); + shader->uniformMatrix4fv(name[i], 1, GL_FALSE, glm::value_ptr(mMatrix[i][mMatIdx[i]])); shader->mMatHash[i] = mMatHash[i]; } } @@ -1129,12 +1133,7 @@ void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z) flush(); { - glh::matrix4f trans_mat(1,0,0,x, - 0,1,0,y, - 0,0,1,z, - 0,0,0,1); - - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(trans_mat); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = glm::translate(mMatrix[mMatrixMode][mMatIdx[mMatrixMode]], glm::vec3(x, y, z)); mMatHash[mMatrixMode]++; } } @@ -1144,12 +1143,7 @@ void LLRender::scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z) flush(); { - glh::matrix4f scale_mat(x,0,0,0, - 0,y,0,0, - 0,0,z,0, - 0,0,0,1); - - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(scale_mat); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = glm::scale(mMatrix[mMatrixMode][mMatIdx[mMatrixMode]], glm::vec3(x, y, z)); mMatHash[mMatrixMode]++; } } @@ -1159,13 +1153,7 @@ void LLRender::ortho(F32 left, F32 right, F32 bottom, F32 top, F32 zNear, F32 zF flush(); { - - glh::matrix4f ortho_mat(2.f/(right-left),0,0, -(right+left)/(right-left), - 0,2.f/(top-bottom),0, -(top+bottom)/(top-bottom), - 0,0,-2.f/(zFar-zNear), -(zFar+zNear)/(zFar-zNear), - 0,0,0,1); - - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(ortho_mat); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] *= glm::ortho(left, right, bottom, top, zNear, zFar); mMatHash[mMatrixMode]++; } } @@ -1175,19 +1163,7 @@ void LLRender::rotatef(const GLfloat& a, const GLfloat& x, const GLfloat& y, con flush(); { - F32 r = a * DEG_TO_RAD; - - F32 c = cosf(r); - F32 s = sinf(r); - - F32 ic = 1.f-c; - - glh::matrix4f rot_mat(x*x*ic+c, x*y*ic-z*s, x*z*ic+y*s, 0, - x*y*ic+z*s, y*y*ic+c, y*z*ic-x*s, 0, - x*z*ic-y*s, y*z*ic+x*s, z*z*ic+c, 0, - 0,0,0,1); - - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(rot_mat); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = glm::rotate(mMatrix[mMatrixMode][mMatIdx[mMatrixMode]], glm::radians(a), glm::vec3(x,y,z)); mMatHash[mMatrixMode]++; } } @@ -1229,7 +1205,7 @@ void LLRender::loadMatrix(const GLfloat* m) { flush(); { - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].set_value((GLfloat*) m); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = glm::make_mat4((GLfloat*) m); mMatHash[mMatrixMode]++; } } @@ -1238,9 +1214,7 @@ void LLRender::multMatrix(const GLfloat* m) { flush(); { - glh::matrix4f mat((GLfloat*) m); - - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(mat); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] *= glm::make_mat4(m); mMatHash[mMatrixMode]++; } } @@ -1283,17 +1257,17 @@ void LLRender::loadIdentity() { llassert_always(mMatrixMode < NUM_MATRIX_MODES) ; - mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].make_identity(); + mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = glm::identity<glm::mat4>(); mMatHash[mMatrixMode]++; } } -const glh::matrix4f& LLRender::getModelviewMatrix() +const glm::mat4& LLRender::getModelviewMatrix() { return mMatrix[MM_MODELVIEW][mMatIdx[MM_MODELVIEW]]; } -const glh::matrix4f& LLRender::getProjectionMatrix() +const glm::mat4& LLRender::getProjectionMatrix() { return mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]]; } @@ -1324,7 +1298,7 @@ void LLRender::pushUIMatrix() { if (mUIOffset.empty()) { - mUIOffset.push_back(LLVector3(0,0,0)); + mUIOffset.emplace_back(0.f,0.f,0.f); } else { @@ -1333,7 +1307,7 @@ void LLRender::pushUIMatrix() if (mUIScale.empty()) { - mUIScale.push_back(LLVector3(1,1,1)); + mUIScale.emplace_back(1.f,1.f,1.f); } else { @@ -1557,13 +1531,7 @@ void LLRender::begin(const GLuint& mode) { if (mode != mMode) { - if (mode == LLRender::QUADS) - { - mQuadCycle = 1; - } - - if (mMode == LLRender::QUADS || - mMode == LLRender::LINES || + if (mMode == LLRender::LINES || mMode == LLRender::TRIANGLES || mMode == LLRender::POINTS) { @@ -1586,8 +1554,7 @@ void LLRender::end() //IMM_ERRS << "GL begin and end called with no vertices specified." << LL_ENDL; } - if ((mMode != LLRender::QUADS && - mMode != LLRender::LINES && + if ((mMode != LLRender::LINES && mMode != LLRender::TRIANGLES && mMode != LLRender::POINTS) || mCount > 2048) @@ -1612,28 +1579,19 @@ void LLRender::flush() //store mCount in a local variable to avoid re-entrance (drawArrays may call flush) U32 count = mCount; - if (mMode == LLRender::QUADS && !sGLCoreProfile) - { - if (mCount%4 != 0) - { - count -= (mCount % 4); - LL_WARNS() << "Incomplete quad requested." << LL_ENDL; - } - } - - if (mMode == LLRender::TRIANGLES) + if (mMode == LLRender::TRIANGLES) + { + if (mCount%3 != 0) { - if (mCount%3 != 0) - { - count -= (mCount % 3); - LL_WARNS() << "Incomplete triangle requested." << LL_ENDL; - } + count -= (mCount % 3); + LL_WARNS() << "Incomplete triangle requested." << LL_ENDL; } + } - if (mMode == LLRender::LINES) + if (mMode == LLRender::LINES) + { + if (mCount%2 != 0) { - if (mCount%2 != 0) - { count -= (mCount % 2); LL_WARNS() << "Incomplete line requested." << LL_ENDL; } @@ -1760,7 +1718,7 @@ LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count) vb->setBuffer(); - vb->setPositionData((LLVector4a*)mVerticesp.get()); + vb->setPositionData(mVerticesp.get()); if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0) { @@ -1783,16 +1741,7 @@ LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count) void LLRender::drawBuffer(LLVertexBuffer* vb, U32 mode, S32 count) { vb->setBuffer(); - - if (mode == LLRender::QUADS && sGLCoreProfile) - { - vb->drawArrays(LLRender::TRIANGLES, 0, count); - mQuadCycle = 1; - } - else - { - vb->drawArrays(mode, 0, count); - } + vb->drawArrays(mode, 0, count); } void LLRender::resetStriders(S32 count) @@ -1813,7 +1762,6 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) { case LLRender::POINTS: flush(); break; case LLRender::TRIANGLES: if (mCount%3==0) flush(); break; - case LLRender::QUADS: if(mCount%4 == 0) flush(); break; case LLRender::LINES: if (mCount%2 == 0) flush(); break; } } @@ -1826,31 +1774,12 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) if (mUIOffset.empty()) { - mVerticesp[mCount] = LLVector3(x,y,z); + mVerticesp[mCount].set(x,y,z); } else { LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back()); - mVerticesp[mCount] = vert; - } - - if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile) - { - mQuadCycle++; - if (mQuadCycle == 4) - { //copy two vertices so fourth quad element will add a triangle - mQuadCycle = 0; - - mCount++; - mVerticesp[mCount] = mVerticesp[mCount-3]; - mColorsp[mCount] = mColorsp[mCount-3]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-3]; - - mCount++; - mVerticesp[mCount] = mVerticesp[mCount-2]; - mColorsp[mCount] = mColorsp[mCount-2]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-2]; - } + mVerticesp[mCount].set(vert.mV[VX], vert.mV[VY], vert.mV[VZ]); } mCount++; @@ -1859,7 +1788,7 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; } -void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count) +void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count) { if (mCount + vert_count > 4094) { @@ -1867,57 +1796,20 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count) return; } - if (sGLCoreProfile && mMode == LLRender::QUADS) - { //quads are deprecated, convert to triangle list - S32 i = 0; - - while (i < vert_count) - { - //read first three - mVerticesp[mCount++] = verts[i++]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - - mVerticesp[mCount++] = verts[i++]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - - mVerticesp[mCount++] = verts[i++]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - - //copy two - mVerticesp[mCount++] = verts[i-3]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - - mVerticesp[mCount++] = verts[i-1]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - - //copy last one - mVerticesp[mCount++] = verts[i++]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - } - } - else + for (S32 i = 0; i < vert_count; i++) { - for (S32 i = 0; i < vert_count; i++) - { - mVerticesp[mCount] = verts[i]; + mVerticesp[mCount] = verts[i]; - mCount++; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - } + mCount++; + mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; + mColorsp[mCount] = mColorsp[mCount-1]; } if( mCount > 0 ) // ND: Guard against crashes if mCount is zero, yes it can happen mVerticesp[mCount] = mVerticesp[mCount-1]; } -void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count) +void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count) { if (mCount + vert_count > 4094) { @@ -1925,50 +1817,13 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 v return; } - if (sGLCoreProfile && mMode == LLRender::QUADS) - { //quads are deprecated, convert to triangle list - S32 i = 0; - - while (i < vert_count) - { - //read first three - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount++] = uvs[i++]; - mColorsp[mCount] = mColorsp[mCount-1]; - - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount++] = uvs[i++]; - mColorsp[mCount] = mColorsp[mCount-1]; - - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount++] = uvs[i++]; - mColorsp[mCount] = mColorsp[mCount-1]; - - //copy last two - mVerticesp[mCount] = verts[i-3]; - mTexcoordsp[mCount++] = uvs[i-3]; - mColorsp[mCount] = mColorsp[mCount-1]; - - mVerticesp[mCount] = verts[i-1]; - mTexcoordsp[mCount++] = uvs[i-1]; - mColorsp[mCount] = mColorsp[mCount-1]; - - //copy last one - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount++] = uvs[i++]; - mColorsp[mCount] = mColorsp[mCount-1]; - } - } - else + for (S32 i = 0; i < vert_count; i++) { - for (S32 i = 0; i < vert_count; i++) - { - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount] = uvs[i]; + mVerticesp[mCount] = verts[i]; + mTexcoordsp[mCount] = uvs[i]; - mCount++; - mColorsp[mCount] = mColorsp[mCount-1]; - } + mCount++; + mColorsp[mCount] = mColorsp[mCount-1]; } if (mCount > 0) @@ -1978,7 +1833,7 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 v } } -void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count) +void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count) { if (mCount + vert_count > 4094) { @@ -1986,51 +1841,13 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLCol return; } - - if (sGLCoreProfile && mMode == LLRender::QUADS) - { //quads are deprecated, convert to triangle list - S32 i = 0; - - while (i < vert_count) - { - //read first three - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount] = uvs[i]; - mColorsp[mCount++] = colors[i++]; - - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount] = uvs[i]; - mColorsp[mCount++] = colors[i++]; - - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount] = uvs[i]; - mColorsp[mCount++] = colors[i++]; - - //copy last two - mVerticesp[mCount] = verts[i-3]; - mTexcoordsp[mCount] = uvs[i-3]; - mColorsp[mCount++] = colors[i-3]; - - mVerticesp[mCount] = verts[i-1]; - mTexcoordsp[mCount] = uvs[i-1]; - mColorsp[mCount++] = colors[i-1]; - - //copy last one - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount] = uvs[i]; - mColorsp[mCount++] = colors[i++]; - } - } - else + for (S32 i = 0; i < vert_count; i++) { - for (S32 i = 0; i < vert_count; i++) - { - mVerticesp[mCount] = verts[i]; - mTexcoordsp[mCount] = uvs[i]; - mColorsp[mCount] = colors[i]; + mVerticesp[mCount] = verts[i]; + mTexcoordsp[mCount] = uvs[i]; + mColorsp[mCount] = colors[i]; - mCount++; - } + mCount++; } if (mCount > 0) @@ -2063,7 +1880,7 @@ void LLRender::vertex3fv(const GLfloat* v) void LLRender::texCoord2f(const GLfloat& x, const GLfloat& y) { - mTexcoordsp[mCount] = LLVector2(x,y); + mTexcoordsp[mCount].set(x,y); } void LLRender::texCoord2i(const GLint& x, const GLint& y) @@ -2080,7 +1897,7 @@ void LLRender::color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, co { if (!LLGLSLShader::sCurBoundShaderPtr || LLGLSLShader::sCurBoundShaderPtr->mAttributeMask & LLVertexBuffer::MAP_COLOR) { - mColorsp[mCount] = LLColor4U(r,g,b,a); + mColorsp[mCount].set(r,g,b,a); } else { //not using shaders or shader reads color from a uniform @@ -2214,85 +2031,90 @@ void LLRender::debugTexUnits(void) LL_INFOS("TextureUnit") << "Active TexUnit Enabled : " << active_enabled << LL_ENDL; } - - -glh::matrix4f copy_matrix(F32* src) +glm::mat4 get_current_modelview() { - glh::matrix4f ret; - ret.set_value(src); - return ret; + return glm::make_mat4(gGLModelView); } -glh::matrix4f get_current_modelview() +glm::mat4 get_current_projection() { - return copy_matrix(gGLModelView); + return glm::make_mat4(gGLProjection); } -glh::matrix4f get_current_projection() +glm::mat4 get_last_modelview() { - return copy_matrix(gGLProjection); + return glm::make_mat4(gGLLastModelView); } -glh::matrix4f get_last_modelview() +glm::mat4 get_last_projection() { - return copy_matrix(gGLLastModelView); + return glm::make_mat4(gGLLastProjection); } -glh::matrix4f get_last_projection() -{ - return copy_matrix(gGLLastProjection); -} - -void copy_matrix(const glh::matrix4f& src, F32* dst) +void copy_matrix(const glm::mat4& src, F32* dst) { + auto matp = glm::value_ptr(src); for (U32 i = 0; i < 16; i++) { - dst[i] = src.m[i]; + dst[i] = matp[i]; } } -void set_current_modelview(const glh::matrix4f& mat) +void set_current_modelview(const glm::mat4& mat) { copy_matrix(mat, gGLModelView); } -void set_current_projection(glh::matrix4f& mat) +void set_current_projection(const glm::mat4& mat) { copy_matrix(mat, gGLProjection); } -glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar) +void set_last_modelview(const glm::mat4& mat) { - glh::matrix4f ret( - 2.f/(right-left), 0.f, 0.f, -(right+left)/(right-left), - 0.f, 2.f/(top-bottom), 0.f, -(top+bottom)/(top-bottom), - 0.f, 0.f, -2.f/(zfar-znear), -(zfar+znear)/(zfar-znear), - 0.f, 0.f, 0.f, 1.f); - - return ret; + copy_matrix(mat, gGLLastModelView); } -glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) +void set_last_projection(const glm::mat4& mat) { - GLfloat f = 1.f/tanf(DEG_TO_RAD*fovy/2.f); - - return glh::matrix4f(f/aspect, 0, 0, 0, - 0, f, 0, 0, - 0, 0, (zFar+zNear)/(zNear-zFar), (2.f*zFar*zNear)/(zNear-zFar), - 0, 0, -1.f, 0); + copy_matrix(mat, gGLLastProjection); } -glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up) +glm::vec3 mul_mat4_vec3(const glm::mat4& mat, const glm::vec3& vec) { - LLVector3 f = center-eye; - f.normVec(); - up.normVec(); - LLVector3 s = f % up; - LLVector3 u = s % f; + //const float w = vec[0] * mat[0][3] + vec[1] * mat[1][3] + vec[2] * mat[2][3] + mat[3][3]; + //return glm::vec3( + // (vec[0] * mat[0][0] + vec[1] * mat[1][0] + vec[2] * mat[2][0] + mat[3][0]) / w, + // (vec[0] * mat[0][1] + vec[1] * mat[1][1] + vec[2] * mat[2][1] + mat[3][1]) / w, + // (vec[0] * mat[0][2] + vec[1] * mat[1][2] + vec[2] * mat[2][2] + mat[3][2]) / w + //); + LLVector4a x, y, z, s, t, p, q; + + x.splat(vec.x); + y.splat(vec.y); + z.splat(vec.z); + + s.splat<3>(mat[0].data); + t.splat<3>(mat[1].data); + p.splat<3>(mat[2].data); + q.splat<3>(mat[3].data); + + s.mul(x); + t.mul(y); + p.mul(z); + q.add(s); + t.add(p); + q.add(t); - return glh::matrix4f(s[0], s[1], s[2], 0, - u[0], u[1], u[2], 0, - -f[0], -f[1], -f[2], 0, - 0, 0, 0, 1); + x.mul(mat[0].data); + y.mul(mat[1].data); + z.mul(mat[2].data); + x.add(y); + z.add(mat[3].data); + LLVector4a res; + res.load3(glm::value_ptr(vec)); + res.setAdd(x, z); + res.div(q); + return glm::make_vec3(res.getF32ptr()); } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 39c13e328a..fc7c5ccc18 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -42,7 +42,7 @@ #include "llpointer.h" #include "llglheaders.h" #include "llmatrix4a.h" -#include "glh/glh_linear.h" +#include "glm/mat4x4.hpp" #include <array> #include <list> @@ -319,7 +319,6 @@ public: POINTS, LINES, LINE_STRIP, - QUADS, LINE_LOOP, NUM_MODES }; @@ -401,8 +400,8 @@ public: void matrixMode(eMatrixMode mode); eMatrixMode getMatrixMode(); - const glh::matrix4f& getModelviewMatrix(); - const glh::matrix4f& getProjectionMatrix(); + const glm::mat4& getModelviewMatrix(); + const glm::mat4& getProjectionMatrix(); void syncMatrices(); void syncLightState(); @@ -450,9 +449,9 @@ public: void diffuseColor4ubv(const U8* c); void diffuseColor4ub(U8 r, U8 g, U8 b, U8 a); - void vertexBatchPreTransformed(LLVector3* verts, S32 vert_count); - void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count); - void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U*, S32 vert_count); + void vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count); + void vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count); + void vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLColor4U*, S32 vert_count); void setColorMask(bool writeColor, bool writeAlpha); void setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha); @@ -502,20 +501,19 @@ private: eMatrixMode mMatrixMode; U32 mMatIdx[NUM_MATRIX_MODES]; U32 mMatHash[NUM_MATRIX_MODES]; - glh::matrix4f mMatrix[NUM_MATRIX_MODES][LL_MATRIX_STACK_DEPTH]; + glm::mat4 mMatrix[NUM_MATRIX_MODES][LL_MATRIX_STACK_DEPTH]; U32 mCurMatHash[NUM_MATRIX_MODES]; U32 mLightHash; LLColor4 mAmbientLightColor; bool mDirty; - U32 mQuadCycle; U32 mCount; U32 mMode; U32 mCurrTextureUnitIndex; bool mCurrColorMask[4]; LLPointer<LLVertexBuffer> mBuffer; - LLStrider<LLVector3> mVerticesp; + LLStrider<LLVector4a> mVerticesp; LLStrider<LLVector2> mTexcoordsp; LLStrider<LLColor4U> mColorsp; std::array<LLTexUnit, LL_NUM_TEXTURE_LAYERS> mTexUnits; @@ -536,8 +534,8 @@ extern F32 gGLLastModelView[16]; extern F32 gGLLastProjection[16]; extern F32 gGLProjection[16]; extern S32 gGLViewport[4]; -extern F32 gGLDeltaModelView[16]; -extern F32 gGLInverseDeltaModelView[16]; +extern glm::mat4 gGLDeltaModelView; +extern glm::mat4 gGLInverseDeltaModelView; extern thread_local LLRender gGL; @@ -548,19 +546,20 @@ const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X 0.f, 1.f, 0.f, 0.f, // Y becomes Z 0.f, 0.f, 0.f, 1.f }; -glh::matrix4f copy_matrix(F32* src); -glh::matrix4f get_current_modelview(); -glh::matrix4f get_current_projection(); -glh::matrix4f get_last_modelview(); -glh::matrix4f get_last_projection(); +glm::mat4 copy_matrix(F32* src); +glm::mat4 get_current_modelview(); +glm::mat4 get_current_projection(); +glm::mat4 get_last_modelview(); +glm::mat4 get_last_projection(); -void copy_matrix(const glh::matrix4f& src, F32* dst); -void set_current_modelview(const glh::matrix4f& mat); -void set_current_projection(glh::matrix4f& mat); +void copy_matrix(const glm::mat4& src, F32* dst); +void set_current_modelview(const glm::mat4& mat); +void set_current_projection(const glm::mat4& mat); +void set_last_modelview(const glm::mat4& mat); +void set_last_projection(const glm::mat4& mat); -glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar); -glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); -glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up); +// glh compat +glm::vec3 mul_mat4_vec3(const glm::mat4& mat, const glm::vec3& vec); #define LL_SHADER_LOADING_WARNS(...) LL_WARNS() diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index 428370057e..20ad0275bd 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -122,10 +122,13 @@ void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, bool filled ) // Counterclockwise quad will face the viewer if( filled ) { - gGL.begin( LLRender::QUADS ); + gGL.begin( LLRender::TRIANGLES ); gGL.vertex2i(left, top); gGL.vertex2i(left, bottom); gGL.vertex2i(right, bottom); + + gGL.vertex2i(left, top); + gGL.vertex2i(right, bottom); gGL.vertex2i(right, top); gGL.end(); } @@ -172,50 +175,70 @@ void gl_drop_shadow(S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &st LLColor4 end_color = start_color; end_color.mV[VALPHA] = 0.f; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); // Right edge, CCW faces screen gGL.color4fv(start_color.mV); - gGL.vertex2i(right, top-lines); - gGL.vertex2i(right, bottom); + gGL.vertex2i(right, top - lines); + gGL.vertex2i(right, bottom); + gGL.color4fv(end_color.mV); + gGL.vertex2i(right + lines, bottom); + gGL.color4fv(start_color.mV); + gGL.vertex2i(right, top - lines); gGL.color4fv(end_color.mV); - gGL.vertex2i(right+lines, bottom); - gGL.vertex2i(right+lines, top-lines); + gGL.vertex2i(right + lines, bottom); + gGL.vertex2i(right + lines, top - lines); // Bottom edge, CCW faces screen gGL.color4fv(start_color.mV); - gGL.vertex2i(right, bottom); - gGL.vertex2i(left+lines, bottom); + gGL.vertex2i(right, bottom); + gGL.vertex2i(left + lines, bottom); + gGL.color4fv(end_color.mV); + gGL.vertex2i(left + lines, bottom - lines); + gGL.color4fv(start_color.mV); + gGL.vertex2i(right, bottom); gGL.color4fv(end_color.mV); - gGL.vertex2i(left+lines, bottom-lines); - gGL.vertex2i(right, bottom-lines); + gGL.vertex2i(left + lines, bottom - lines); + gGL.vertex2i(right, bottom - lines); // bottom left Corner gGL.color4fv(start_color.mV); - gGL.vertex2i(left+lines, bottom); + gGL.vertex2i(left + lines, bottom); gGL.color4fv(end_color.mV); - gGL.vertex2i(left, bottom); + gGL.vertex2i(left, bottom); // make the bottom left corner not sharp - gGL.vertex2i(left+1, bottom-lines+1); - gGL.vertex2i(left+lines, bottom-lines); + gGL.vertex2i(left + 1, bottom - lines + 1); + gGL.color4fv(start_color.mV); + gGL.vertex2i(left + lines, bottom); + gGL.color4fv(end_color.mV); + gGL.vertex2i(left + 1, bottom - lines + 1); + gGL.vertex2i(left + lines, bottom - lines); // bottom right corner gGL.color4fv(start_color.mV); - gGL.vertex2i(right, bottom); + gGL.vertex2i(right, bottom); gGL.color4fv(end_color.mV); - gGL.vertex2i(right, bottom-lines); + gGL.vertex2i(right, bottom - lines); // make the rightmost corner not sharp - gGL.vertex2i(right+lines-1, bottom-lines+1); - gGL.vertex2i(right+lines, bottom); + gGL.vertex2i(right + lines - 1, bottom - lines + 1); + gGL.color4fv(start_color.mV); + gGL.vertex2i(right, bottom); + gGL.color4fv(end_color.mV); + gGL.vertex2i(right + lines - 1, bottom - lines + 1); + gGL.vertex2i(right + lines, bottom); // top right corner gGL.color4fv(start_color.mV); - gGL.vertex2i( right, top-lines ); + gGL.vertex2i(right, top - lines); gGL.color4fv(end_color.mV); - gGL.vertex2i( right+lines, top-lines ); + gGL.vertex2i(right + lines, top - lines); // make the corner not sharp - gGL.vertex2i( right+lines-1, top-1 ); - gGL.vertex2i( right, top ); + gGL.vertex2i(right + lines - 1, top - 1); + gGL.color4fv(start_color.mV); + gGL.vertex2i(right, top - lines); + gGL.color4fv(end_color.mV); + gGL.vertex2i(right + lines - 1, top - 1); + gGL.vertex2i(right, top); gGL.end(); stop_glerror(); @@ -423,171 +446,251 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex ui_translation.mV[VX] + width * ui_scale.mV[VX], ui_translation.mV[VY]); - LLGLSUIDefault gls_ui; - gGL.getTexUnit(0)->bind(image, true); gGL.color4fv(color.mV); - const S32 NUM_VERTICES = 9 * 4; // 9 quads - LLVector2 uv[NUM_VERTICES]; - LLVector3 pos[NUM_VERTICES]; + constexpr S32 NUM_VERTICES = 9 * 2 * 3; // 9 quads, 2 triangles per quad, 3 vertices per triangle + static thread_local LLVector2 uv[NUM_VERTICES]; + static thread_local LLVector4a pos[NUM_VERTICES]; S32 index = 0; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { - // draw bottom left - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f); + // draw bottom left triangles + // 1 + uv[index].set(uv_outer_rect.mLeft, uv_outer_rect.mBottom); + pos[index].set(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_outer_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); + // 2 + uv[index].set(uv_outer_rect.mLeft, uv_outer_rect.mBottom); + pos[index].set(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f); index++; - // draw bottom middle - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); + uv[index].set(uv_outer_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + // draw bottom middle triangles + uv[index].set(uv_center_rect.mLeft, uv_outer_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mRight, uv_outer_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); index++; - // draw bottom right - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mBottom, 0.f); + // 2 + uv[index].set(uv_center_rect.mLeft, uv_outer_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - // draw left - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); + // draw bottom right triangles + uv[index].set(uv_center_rect.mRight, uv_outer_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_outer_rect.mRight, uv_outer_rect.mBottom); + pos[index].set(draw_outer_rect.mRight, draw_outer_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + uv[index].set(uv_outer_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); + // 2 + uv[index].set(uv_center_rect.mRight, uv_outer_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); index++; - // draw middle - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_outer_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + // draw left triangles + uv[index].set(uv_outer_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - // draw right - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); + // 2 + uv[index].set(uv_outer_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + uv[index].set(uv_outer_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); index++; - // draw top left - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); + // draw middle triangles + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mTop, 0.f); + // 2 + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); index++; - // draw top middle - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); + // draw right triangles + uv[index].set(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + uv[index].set(uv_outer_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - // draw top right - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + uv[index].set(uv_outer_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); + // 2 + uv[index].set(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f); + uv[index].set(uv_outer_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); + uv[index].set(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; + + // draw top left triangles + uv[index].set(uv_outer_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mLeft, uv_outer_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; + + // 2 + uv[index].set(uv_outer_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mLeft, uv_outer_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; + + uv[index].set(uv_outer_rect.mLeft, uv_outer_rect.mTop); + pos[index].set(draw_outer_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; + + // draw top middle triangles + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mRight, uv_outer_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; + + // 2 + uv[index].set(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mRight, uv_outer_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mLeft, uv_outer_rect.mTop); + pos[index].set(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; + + // draw top right triangles + uv[index].set(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_outer_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_outer_rect.mRight, uv_outer_rect.mTop); + pos[index].set(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; + + // 2 + uv[index].set(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; + + uv[index].set(uv_outer_rect.mRight, uv_outer_rect.mTop); + pos[index].set(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; + + uv[index].set(uv_center_rect.mRight, uv_outer_rect.mTop); + pos[index].set(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); index++; gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES); @@ -614,8 +717,6 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre return; } - LLGLSUIDefault gls_ui; - if(image != NULL) { gGL.getTexUnit(0)->bind(image, true); @@ -629,11 +730,11 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre if (degrees == 0.f) { - const S32 NUM_VERTICES = 4; // 9 quads - LLVector2 uv[NUM_VERTICES]; - LLVector3 pos[NUM_VERTICES]; + constexpr S32 NUM_VERTICES = 2 * 3; + static thread_local LLVector2 uv[NUM_VERTICES +1]; + static thread_local LLVector4a pos[NUM_VERTICES +1]; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { LLVector3 ui_scale = gGL.getUIScale(); LLVector3 ui_translation = gGL.getUITranslation(); @@ -644,20 +745,28 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre S32 scaled_width = ll_round(width * ui_scale.mV[VX]); S32 scaled_height = ll_round(height * ui_scale.mV[VY]); - uv[index] = LLVector2(uv_rect.mRight, uv_rect.mTop); - pos[index] = LLVector3(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f); + uv[index].set(uv_rect.mRight, uv_rect.mTop); + pos[index].set(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f); + index++; + + uv[index].set(uv_rect.mLeft, uv_rect.mTop); + pos[index].set(ui_translation.mV[VX], ui_translation.mV[VY] + scaled_height, 0.f); + index++; + + uv[index].set(uv_rect.mLeft, uv_rect.mBottom); + pos[index].set(ui_translation.mV[VX], ui_translation.mV[VY], 0.f); index++; - uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop); - pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY] + scaled_height, 0.f); + uv[index].set(uv_rect.mRight, uv_rect.mTop); + pos[index].set(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f); index++; - uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom); - pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY], 0.f); + uv[index].set(uv_rect.mLeft, uv_rect.mBottom); + pos[index].set(ui_translation.mV[VX], ui_translation.mV[VY], 0.f); index++; - uv[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom); - pos[index] = LLVector3(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY], 0.f); + uv[index].set(uv_rect.mRight, uv_rect.mBottom); + pos[index].set(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY], 0.f); index++; gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES); @@ -687,7 +796,7 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre gGL.color4fv(color.mV); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { LLVector3 v; @@ -703,6 +812,14 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom); gGL.vertex2f(v.mV[0], v.mV[1] ); + v = LLVector3(offset_x, offset_y, 0.f) * quat; + gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop); + gGL.vertex2f(v.mV[0], v.mV[1]); + + v = LLVector3(-offset_x, -offset_y, 0.f) * quat; + gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom); + gGL.vertex2f(v.mV[0], v.mV[1]); + v = LLVector3(offset_x, -offset_y, 0.f) * quat; gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom); gGL.vertex2f(v.mV[0], v.mV[1] ); @@ -948,7 +1065,7 @@ void gl_washer_segment_2d(F32 outer_radius, F32 inner_radius, F32 start_radians, void gl_rect_2d_simple_tex( S32 width, S32 height ) { - gGL.begin( LLRender::QUADS ); + gGL.begin( LLRender::TRIANGLES ); gGL.texCoord2f(1.f, 1.f); gGL.vertex2i(width, height); @@ -959,6 +1076,12 @@ void gl_rect_2d_simple_tex( S32 width, S32 height ) gGL.texCoord2f(0.f, 0.f); gGL.vertex2i(0, 0); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2i(width, height); + + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(0, 0); + gGL.texCoord2f(1.f, 0.f); gGL.vertex2i(width, 0); @@ -967,10 +1090,13 @@ void gl_rect_2d_simple_tex( S32 width, S32 height ) void gl_rect_2d_simple( S32 width, S32 height ) { - gGL.begin( LLRender::QUADS ); + gGL.begin( LLRender::TRIANGLES ); gGL.vertex2i(width, height); gGL.vertex2i(0, height); gGL.vertex2i(0, 0); + + gGL.vertex2i(width, height); + gGL.vertex2i(0, 0); gGL.vertex2i(width, 0); gGL.end(); } @@ -1011,7 +1137,7 @@ void gl_segmented_rect_2d_tex(const S32 left, LLVector2 width_vec((F32)width, 0.f); LLVector2 height_vec(0.f, (F32)height); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { // draw bottom left gGL.texCoord2f(0.f, 0.f); @@ -1023,6 +1149,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(border_uv_scale.mV[VX], border_uv_scale.mV[VY]); gGL.vertex2fv((border_width_left + border_height_bottom).mV); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2f(0.f, 0.f); + + gGL.texCoord2f(border_uv_scale.mV[VX], border_uv_scale.mV[VY]); + gGL.vertex2fv((border_width_left + border_height_bottom).mV); + gGL.texCoord2f(0.f, border_uv_scale.mV[VY]); gGL.vertex2fv(border_height_bottom.mV); @@ -1036,6 +1168,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(1.f - border_uv_scale.mV[VX], border_uv_scale.mV[VY]); gGL.vertex2fv((width_vec - border_width_right + border_height_bottom).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 0.f); + gGL.vertex2fv(border_width_left.mV); + + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], border_uv_scale.mV[VY]); + gGL.vertex2fv((width_vec - border_width_right + border_height_bottom).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], border_uv_scale.mV[VY]); gGL.vertex2fv((border_width_left + border_height_bottom).mV); @@ -1049,6 +1187,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(1.f, border_uv_scale.mV[VY]); gGL.vertex2fv((width_vec + border_height_bottom).mV); + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 0.f); + gGL.vertex2fv((width_vec - border_width_right).mV); + + gGL.texCoord2f(1.f, border_uv_scale.mV[VY]); + gGL.vertex2fv((width_vec + border_height_bottom).mV); + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], border_uv_scale.mV[VY]); gGL.vertex2fv((width_vec - border_width_right + border_height_bottom).mV); @@ -1062,6 +1206,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((border_width_left + height_vec - border_height_top).mV); + gGL.texCoord2f(0.f, border_uv_scale.mV[VY]); + gGL.vertex2fv(border_height_bottom.mV); + + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((border_width_left + height_vec - border_height_top).mV); + gGL.texCoord2f(0.f, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((height_vec - border_height_top).mV); @@ -1075,6 +1225,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((width_vec - border_width_right + height_vec - border_height_top).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], border_uv_scale.mV[VY]); + gGL.vertex2fv((border_width_left + border_height_bottom).mV); + + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((width_vec - border_width_right + height_vec - border_height_top).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((border_width_left + height_vec - border_height_top).mV); @@ -1088,6 +1244,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(1.f, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((width_vec + height_vec - border_height_top).mV); + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], border_uv_scale.mV[VY]); + gGL.vertex2fv((width_vec - border_width_right + border_height_bottom).mV); + + gGL.texCoord2f(1.f, 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((width_vec + height_vec - border_height_top).mV); + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((width_vec - border_width_right + height_vec - border_height_top).mV); @@ -1101,6 +1263,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(border_uv_scale.mV[VX], 1.f); gGL.vertex2fv((border_width_left + height_vec).mV); + gGL.texCoord2f(0.f, 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((height_vec - border_height_top).mV); + + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f); + gGL.vertex2fv((border_width_left + height_vec).mV); + gGL.texCoord2f(0.f, 1.f); gGL.vertex2fv((height_vec).mV); @@ -1114,6 +1282,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f); gGL.vertex2fv((width_vec - border_width_right + height_vec).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((border_width_left + height_vec - border_height_top).mV); + + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f); + gGL.vertex2fv((width_vec - border_width_right + height_vec).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f); gGL.vertex2fv((border_width_left + height_vec).mV); @@ -1127,6 +1301,12 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.texCoord2f(1.f, 1.f); gGL.vertex2fv((width_vec + height_vec).mV); + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((width_vec - border_width_right + height_vec - border_height_top).mV); + + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2fv((width_vec + height_vec).mV); + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f); gGL.vertex2fv((width_vec - border_width_right + height_vec).mV); } @@ -1181,7 +1361,7 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, LLVector2 x_min; LLVector2 x_max; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { if (start_fragment < middle_start) { @@ -1200,6 +1380,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(u_max, border_uv_scale.mV[VY]); gGL.vertex2fv((x_max + border_height_bottom).mV); + gGL.texCoord2f(u_min, 0.f); + gGL.vertex2fv(x_min.mV); + + gGL.texCoord2f(u_max, border_uv_scale.mV[VY]); + gGL.vertex2fv((x_max + border_height_bottom).mV); + gGL.texCoord2f(u_min, border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + border_height_bottom).mV); @@ -1213,6 +1399,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(u_max, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_max + height_vec - border_height_top).mV); + gGL.texCoord2f(u_min, border_uv_scale.mV[VY]); + gGL.vertex2fv((x_min + border_height_bottom).mV); + + gGL.texCoord2f(u_max, 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((x_max + height_vec - border_height_top).mV); + gGL.texCoord2f(u_min, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + height_vec - border_height_top).mV); @@ -1226,6 +1418,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(u_max, 1.f); gGL.vertex2fv((x_max + height_vec).mV); + gGL.texCoord2f(u_min, 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((x_min + height_vec - border_height_top).mV); + + gGL.texCoord2f(u_max, 1.f); + gGL.vertex2fv((x_max + height_vec).mV); + gGL.texCoord2f(u_min, 1.f); gGL.vertex2fv((x_min + height_vec).mV); } @@ -1245,6 +1443,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(1.f - border_uv_scale.mV[VX], border_uv_scale.mV[VY]); gGL.vertex2fv((x_max + border_height_bottom).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 0.f); + gGL.vertex2fv(x_min.mV); + + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], border_uv_scale.mV[VY]); + gGL.vertex2fv((x_max + border_height_bottom).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + border_height_bottom).mV); @@ -1258,6 +1462,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_max + height_vec - border_height_top).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], border_uv_scale.mV[VY]); + gGL.vertex2fv((x_min + border_height_bottom).mV); + + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((x_max + height_vec - border_height_top).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + height_vec - border_height_top).mV); @@ -1271,6 +1481,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f); gGL.vertex2fv((x_max + height_vec).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((x_min + height_vec - border_height_top).mV); + + gGL.texCoord2f(1.f - border_uv_scale.mV[VX], 1.f); + gGL.vertex2fv((x_max + height_vec).mV); + gGL.texCoord2f(border_uv_scale.mV[VX], 1.f); gGL.vertex2fv((x_min + height_vec).mV); } @@ -1292,6 +1508,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(u_max, border_uv_scale.mV[VY]); gGL.vertex2fv((x_max + border_height_bottom).mV); + gGL.texCoord2f(u_min, 0.f); + gGL.vertex2fv((x_min).mV); + + gGL.texCoord2f(u_max, border_uv_scale.mV[VY]); + gGL.vertex2fv((x_max + border_height_bottom).mV); + gGL.texCoord2f(u_min, border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + border_height_bottom).mV); @@ -1305,6 +1527,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(u_max, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_max + height_vec - border_height_top).mV); + gGL.texCoord2f(u_min, border_uv_scale.mV[VY]); + gGL.vertex2fv((x_min + border_height_bottom).mV); + + gGL.texCoord2f(u_max, 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((x_max + height_vec - border_height_top).mV); + gGL.texCoord2f(u_min, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + height_vec - border_height_top).mV); @@ -1318,6 +1546,12 @@ void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, gGL.texCoord2f(u_max, 1.f); gGL.vertex2fv((x_max + height_vec).mV); + gGL.texCoord2f(u_min, 1.f - border_uv_scale.mV[VY]); + gGL.vertex2fv((x_min + height_vec - border_height_top).mV); + + gGL.texCoord2f(u_max, 1.f); + gGL.vertex2fv((x_max + height_vec).mV); + gGL.texCoord2f(u_min, 1.f); gGL.vertex2fv((x_min + height_vec).mV); } @@ -1332,7 +1566,7 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { // draw bottom left gGL.texCoord2f(clip_rect.mLeft, clip_rect.mBottom); @@ -1344,6 +1578,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mBottom); gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mBottom * height_vec).mV); + gGL.texCoord2f(clip_rect.mLeft, clip_rect.mBottom); + gGL.vertex3f(0.f, 0.f, 0.f); + + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mBottom * height_vec).mV); + gGL.texCoord2f(clip_rect.mLeft, center_uv_rect.mBottom); gGL.vertex3fv((center_draw_rect.mBottom * height_vec).mV); @@ -1357,6 +1597,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mBottom); gGL.vertex3fv((center_draw_rect.mRight * width_vec + center_draw_rect.mBottom * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mLeft, clip_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mLeft * width_vec).mV); + + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mRight * width_vec + center_draw_rect.mBottom * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mBottom); gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mBottom * height_vec).mV); @@ -1370,6 +1616,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(clip_rect.mRight, center_uv_rect.mBottom); gGL.vertex3fv((width_vec + center_draw_rect.mBottom * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mRight, clip_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mRight * width_vec).mV); + + gGL.texCoord2f(clip_rect.mRight, center_uv_rect.mBottom); + gGL.vertex3fv((width_vec + center_draw_rect.mBottom * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mBottom); gGL.vertex3fv((center_draw_rect.mRight * width_vec + center_draw_rect.mBottom * height_vec).mV); @@ -1383,6 +1635,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mTop); gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(clip_rect.mLeft, center_uv_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mBottom * height_vec).mV); + + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(clip_rect.mLeft, center_uv_rect.mTop); gGL.vertex3fv((center_draw_rect.mTop * height_vec).mV); @@ -1396,6 +1654,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mTop); gGL.vertex3fv((center_draw_rect.mRight * width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mBottom * height_vec).mV); + + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mRight * width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mTop); gGL.vertex3fv((center_draw_rect.mLeft * width_vec + center_draw_rect.mTop * height_vec).mV); @@ -1409,6 +1673,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(clip_rect.mRight, center_uv_rect.mTop); gGL.vertex3fv((width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mBottom); + gGL.vertex3fv((center_draw_rect.mRight* width_vec + center_draw_rect.mBottom * height_vec).mV); + + gGL.texCoord2f(clip_rect.mRight, center_uv_rect.mTop); + gGL.vertex3fv((width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mTop); gGL.vertex3fv((center_draw_rect.mRight * width_vec + center_draw_rect.mTop * height_vec).mV); @@ -1422,6 +1692,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(center_uv_rect.mLeft, clip_rect.mTop); gGL.vertex3fv((center_draw_rect.mLeft * width_vec + height_vec).mV); + gGL.texCoord2f(clip_rect.mLeft, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mTop* height_vec).mV); + + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mLeft* width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(clip_rect.mLeft, clip_rect.mTop); gGL.vertex3fv((height_vec).mV); @@ -1435,6 +1711,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(center_uv_rect.mRight, clip_rect.mTop); gGL.vertex3fv((center_draw_rect.mRight * width_vec + height_vec).mV); + gGL.texCoord2f(center_uv_rect.mLeft, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mLeft* width_vec + center_draw_rect.mTop * height_vec).mV); + + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mRight* width_vec + center_draw_rect.mTop * height_vec).mV); + gGL.texCoord2f(center_uv_rect.mLeft, clip_rect.mTop); gGL.vertex3fv((center_draw_rect.mLeft * width_vec + height_vec).mV); @@ -1448,6 +1730,12 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv gGL.texCoord2f(clip_rect.mRight, clip_rect.mTop); gGL.vertex3fv((width_vec + height_vec).mV); + gGL.texCoord2f(center_uv_rect.mRight, center_uv_rect.mTop); + gGL.vertex3fv((center_draw_rect.mRight* width_vec + center_draw_rect.mTop * height_vec).mV); + + gGL.texCoord2f(clip_rect.mRight, clip_rect.mTop); + gGL.vertex3fv((width_vec + height_vec).mV); + gGL.texCoord2f(center_uv_rect.mRight, clip_rect.mTop); gGL.vertex3fv((center_draw_rect.mRight * width_vec + height_vec).mV); } diff --git a/indra/llrender/llrendersphere.cpp b/indra/llrender/llrendersphere.cpp index 9570180554..cd8ef7d68e 100644 --- a/indra/llrender/llrendersphere.cpp +++ b/indra/llrender/llrendersphere.cpp @@ -34,6 +34,8 @@ #include "llerror.h" #include "llglheaders.h" +#include "llvertexbuffer.h" +#include "llglslshader.h" LLRenderSphere gSphere; @@ -53,12 +55,20 @@ inline LLVector3 polar_to_cart(F32 latitude, F32 longitude) void LLRenderSphere::renderGGL() { + LL_PROFILE_ZONE_SCOPED; S32 const LATITUDE_SLICES = 20; S32 const LONGITUDE_SLICES = 30; - if (mSpherePoints.empty()) + if (mVertexBuffer.isNull()) { mSpherePoints.resize(LATITUDE_SLICES + 1); + mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX); + + mVertexBuffer->allocateBuffer((U32)(LATITUDE_SLICES + 1) * (LONGITUDE_SLICES + 1), LATITUDE_SLICES * LONGITUDE_SLICES * 6); + + LLStrider<LLVector3> v; + mVertexBuffer->getVertexStrider(v); + for (S32 lat_i = 0; lat_i < LATITUDE_SLICES + 1; lat_i++) { mSpherePoints[lat_i].resize(LONGITUDE_SLICES + 1); @@ -68,24 +78,52 @@ void LLRenderSphere::renderGGL() F32 lon = (F32)lon_i / LONGITUDE_SLICES; mSpherePoints[lat_i][lon_i] = polar_to_cart(lat, lon); + v[lat_i * (LONGITUDE_SLICES + 1) + lon_i] = mSpherePoints[lat_i][lon_i]; } } + + LLStrider<U16> i; + mVertexBuffer->getIndexStrider(i); + + for (S32 lat_i = 0; lat_i < LATITUDE_SLICES; lat_i++) + { + for (S32 lon_i = 0; lon_i < LONGITUDE_SLICES; lon_i++) + { + i[(lat_i * LONGITUDE_SLICES + lon_i) * 6 + 0] = lat_i * (LONGITUDE_SLICES + 1) + lon_i; + i[(lat_i * LONGITUDE_SLICES + lon_i) * 6 + 1] = lat_i * (LONGITUDE_SLICES + 1) + lon_i + 1; + i[(lat_i * LONGITUDE_SLICES + lon_i) * 6 + 2] = (lat_i + 1) * (LONGITUDE_SLICES + 1) + lon_i; + + i[(lat_i * LONGITUDE_SLICES + lon_i) * 6 + 3] = (lat_i + 1) * (LONGITUDE_SLICES + 1) + lon_i; + i[(lat_i * LONGITUDE_SLICES + lon_i) * 6 + 4] = lat_i * (LONGITUDE_SLICES + 1) + lon_i + 1; + i[(lat_i * LONGITUDE_SLICES + lon_i) * 6 + 5] = (lat_i + 1) * (LONGITUDE_SLICES + 1) + lon_i + 1; + } + } + + mVertexBuffer->unmapBuffer(); } - gGL.begin(LLRender::TRIANGLES); - for (S32 lat_i = 0; lat_i < LATITUDE_SLICES; lat_i++) - { - for (S32 lon_i = 0; lon_i < LONGITUDE_SLICES; lon_i++) + if (LLGLSLShader::sCurBoundShaderPtr->mAttributeMask == LLVertexBuffer::MAP_VERTEX) + { // shader expects only vertex positions in vertex buffer, use fast path + mVertexBuffer->setBuffer(); + mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, mVertexBuffer->getNumVerts(), mVertexBuffer->getNumIndices(), 0); + } + else + { //shader wants colors in the vertex stream, use slow path + gGL.begin(LLRender::TRIANGLES); + for (S32 lat_i = 0; lat_i < LATITUDE_SLICES; lat_i++) { - gGL.vertex3fv(mSpherePoints[lat_i][lon_i].mV); - gGL.vertex3fv(mSpherePoints[lat_i][lon_i+1].mV); - gGL.vertex3fv(mSpherePoints[lat_i+1][lon_i].mV); + for (S32 lon_i = 0; lon_i < LONGITUDE_SLICES; lon_i++) + { + gGL.vertex3fv(mSpherePoints[lat_i][lon_i].mV); + gGL.vertex3fv(mSpherePoints[lat_i][lon_i + 1].mV); + gGL.vertex3fv(mSpherePoints[lat_i + 1][lon_i].mV); - gGL.vertex3fv(mSpherePoints[lat_i+1][lon_i].mV); - gGL.vertex3fv(mSpherePoints[lat_i][lon_i+1].mV); - gGL.vertex3fv(mSpherePoints[lat_i+1][lon_i+1].mV); + gGL.vertex3fv(mSpherePoints[lat_i + 1][lon_i].mV); + gGL.vertex3fv(mSpherePoints[lat_i][lon_i + 1].mV); + gGL.vertex3fv(mSpherePoints[lat_i + 1][lon_i + 1].mV); + } } + gGL.end(); } - gGL.end(); } diff --git a/indra/llrender/llrendersphere.h b/indra/llrender/llrendersphere.h index e2e886fa06..5b6eabecb8 100644 --- a/indra/llrender/llrendersphere.h +++ b/indra/llrender/llrendersphere.h @@ -45,6 +45,7 @@ public: private: std::vector< std::vector<LLVector3> > mSpherePoints; + LLPointer<LLVertexBuffer> mVertexBuffer; }; extern LLRenderSphere gSphere; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 156e300853..6f4828397a 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -36,6 +36,7 @@ #include "llshadermgr.h" #include "llglslshader.h" #include "llmemory.h" +#include <glm/gtc/type_ptr.hpp> //Next Highest Power Of Two //helper function, returns first number > v that is a power of 2, or v if v is already a power of 2 @@ -288,22 +289,58 @@ static GLuint gen_buffer() return ret; } -#define ANALYZE_VBO_POOL 0 +static void delete_buffers(S32 count, GLuint* buffers) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + // wait a few frames before actually deleting the buffers to avoid + // synchronization issues with the GPU + static std::vector<GLuint> sFreeList[4]; + + if (gGLManager.mInited) + { + U32 idx = LLImageGL::sFrameCount % 4; + + for (S32 i = 0; i < count; ++i) + { + sFreeList[idx].push_back(buffers[i]); + } + + idx = (LLImageGL::sFrameCount + 3) % 4; + + if (!sFreeList[idx].empty()) + { + glDeleteBuffers((GLsizei)sFreeList[idx].size(), sFreeList[idx].data()); + sFreeList[idx].resize(0); + } + } +} -#if LL_DARWIN -// experimental -- disable VBO pooling on OS X and use glMapBuffer +#define ANALYZE_VBO_POOL 0 + +// VBO Pool interface class LLVBOPool { + public: + virtual ~LLVBOPool() = default; + virtual void allocate(GLenum type, U32 size, GLuint& name, U8*& data) = 0; + virtual void free(GLenum type, U32 size, GLuint name, U8* data) = 0; + virtual U64 getVramBytesUsed() = 0; +}; + +// VBO Pool for Apple GPUs (as in M1/M2 etc, not Intel macs) +// Effectively disables VBO pooling +class LLAppleVBOPool final: public LLVBOPool +{ public: U64 mAllocated = 0; - U64 getVramBytesUsed() + U64 getVramBytesUsed() override { return mAllocated; } - void allocate(GLenum type, U32 size, GLuint& name, U8*& data) + void allocate(GLenum type, U32 size, GLuint& name, U8*& data) override { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; STOP_GLERROR; @@ -323,7 +360,7 @@ public: } } - void free(GLenum type, U32 size, GLuint name, U8* data) + void free(GLenum type, U32 size, GLuint name, U8* data) override { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER); @@ -338,19 +375,17 @@ public: STOP_GLERROR; if (name) { - glDeleteBuffers(1, &name); + delete_buffers(1, &name); } STOP_GLERROR; } }; -#else - -class LLVBOPool +// VBO Pool for GPUs that benefit from VBO pooling +class LLDefaultVBOPool final : public LLVBOPool { public: typedef std::chrono::steady_clock::time_point Time; - struct Entry { U8* mData; @@ -358,7 +393,7 @@ public: Time mAge; }; - ~LLVBOPool() + ~LLDefaultVBOPool() override { clear(); } @@ -376,7 +411,7 @@ public: U32 mMisses = 0; U32 mHits = 0; - U64 getVramBytesUsed() + U64 getVramBytesUsed() override { return mAllocated + mReserved; } @@ -392,7 +427,7 @@ public: size += block_size - (size % block_size); } - void allocate(GLenum type, U32 size, GLuint& name, U8*& data) + void allocate(GLenum type, U32 size, GLuint& name, U8*& data) override { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER); @@ -448,7 +483,7 @@ public: clean(); } - void free(GLenum type, U32 size, GLuint name, U8* data) + void free(GLenum type, U32 size, GLuint name, U8* data) override { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER); @@ -511,7 +546,7 @@ public: LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vbo cache timeout"); auto& entry = entries.back(); ll_aligned_free_16(entry.mData); - glDeleteBuffers(1, &entry.mGLName); + delete_buffers(1, &entry.mGLName); llassert(mReserved >= iter->first); mReserved -= iter->first; entries.pop_back(); @@ -547,7 +582,7 @@ public: for (auto& entry : entries.second) { ll_aligned_free_16(entry.mData); - glDeleteBuffers(1, &entry.mGLName); + delete_buffers(1, &entry.mGLName); } } @@ -556,7 +591,7 @@ public: for (auto& entry : entries.second) { ll_aligned_free_16(entry.mData); - glDeleteBuffers(1, &entry.mGLName); + delete_buffers(1, &entry.mGLName); } } @@ -566,7 +601,6 @@ public: mVBOPool.clear(); } }; -#endif static LLVBOPool* sVBOPool = nullptr; @@ -590,24 +624,16 @@ void LLVertexBufferData::draw() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - gGL.loadMatrix(mModelView.m); + gGL.loadMatrix(glm::value_ptr(mModelView)); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); - gGL.loadMatrix(mProjection.m); + gGL.loadMatrix(glm::value_ptr(mProjection)); gGL.matrixMode(LLRender::MM_TEXTURE0); gGL.pushMatrix(); - gGL.loadMatrix(mTexture0.m); + gGL.loadMatrix(glm::value_ptr(mTexture0)); mVB->setBuffer(); - - if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile) - { - mVB->drawArrays(LLRender::TRIANGLES, 0, mCount); - } - else - { - mVB->drawArrays(mMode, 0, mCount); - } + mVB->drawArrays(mMode, 0, mCount); gGL.popMatrix(); gGL.matrixMode(LLRender::MM_PROJECTION); @@ -680,7 +706,6 @@ const U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = GL_POINTS, GL_LINES, GL_LINE_STRIP, - GL_QUADS, GL_LINE_LOOP, }; @@ -895,7 +920,16 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const void LLVertexBuffer::initClass(LLWindow* window) { llassert(sVBOPool == nullptr); - sVBOPool = new LLVBOPool(); + if (gGLManager.mIsApple) + { + LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL; + sVBOPool = new LLAppleVBOPool(); + } + else + { + LL_INFOS() << "VBO Pooling Enabled" << LL_ENDL; + sVBOPool = new LLDefaultVBOPool(); + } #if ENABLE_GL_WORK_QUEUE sQueue = new GLWorkQueue(); @@ -954,6 +988,24 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask) } } +// list of mapped buffers +// NOTE: must not be LLPointer<LLVertexBuffer> to avoid breaking non-ref-counted LLVertexBuffer instances +static std::vector<LLVertexBuffer*> sMappedBuffers; + +//static +void LLVertexBuffer::flushBuffers() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + // must only be called from main thread + for (auto& buffer : sMappedBuffers) + { + buffer->_unmapBuffer(); + buffer->mMapped = false; + } + + sMappedBuffers.resize(0); +} + //static U32 LLVertexBuffer::calcOffsets(const U32& typemask, U32* offsets, U32 num_vertices) { @@ -997,6 +1049,12 @@ U32 LLVertexBuffer::calcVertexSize(const U32& typemask) //virtual LLVertexBuffer::~LLVertexBuffer() { + if (mMapped) + { // is on the mapped buffer list but doesn't need to be flushed + mMapped = false; + unmapBuffer(); + } + destroyGLBuffer(); destroyGLIndices(); @@ -1198,34 +1256,36 @@ bool expand_region(LLVertexBuffer::MappedRegion& region, U32 start, U32 end) U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 index, S32 count) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + _mapBuffer(); if (count == -1) { count = mNumVerts - index; } -#if !LL_DARWIN - U32 start = mOffsets[type] + sTypeSize[type] * index; - U32 end = start + sTypeSize[type] * count-1; - - bool flagged = false; - // flag region as mapped - for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) + if (!gGLManager.mIsApple) { - MappedRegion& region = mMappedVertexRegions[i]; - if (expand_region(region, start, end)) + U32 start = mOffsets[type] + sTypeSize[type] * index; + U32 end = start + sTypeSize[type] * count-1; + + bool flagged = false; + // flag region as mapped + for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) { - flagged = true; - break; + MappedRegion& region = mMappedVertexRegions[i]; + if (expand_region(region, start, end)) + { + flagged = true; + break; + } } - } - if (!flagged) - { - //didn't expand an existing region, make a new one - mMappedVertexRegions.push_back({ start, end }); + if (!flagged) + { + //didn't expand an existing region, make a new one + mMappedVertexRegions.push_back({ start, end }); + } } -#endif return mMappedData+mOffsets[type]+sTypeSize[type]*index; } @@ -1233,34 +1293,36 @@ U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 inde U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX; + _mapBuffer(); if (count == -1) { count = mNumIndices-index; } -#if !LL_DARWIN - U32 start = sizeof(U16) * index; - U32 end = start + sizeof(U16) * count-1; - - bool flagged = false; - // flag region as mapped - for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) + if (!gGLManager.mIsApple) { - MappedRegion& region = mMappedIndexRegions[i]; - if (expand_region(region, start, end)) + U32 start = sizeof(U16) * index; + U32 end = start + sizeof(U16) * count-1; + + bool flagged = false; + // flag region as mapped + for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) { - flagged = true; - break; + MappedRegion& region = mMappedIndexRegions[i]; + if (expand_region(region, start, end)) + { + flagged = true; + break; + } } - } - if (!flagged) - { - //didn't expand an existing region, make a new one - mMappedIndexRegions.push_back({ start, end }); + if (!flagged) + { + //didn't expand an existing region, make a new one + mMappedIndexRegions.push_back({ start, end }); + } } -#endif return mMappedIndexData + sizeof(U16)*index; } @@ -1273,39 +1335,64 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count) // dst -- mMappedData or mMappedIndexData void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8* dst) { -#if LL_DARWIN - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb memcpy"); - STOP_GLERROR; - // copy into mapped buffer - memcpy(dst+start, data, end-start+1); -#else - llassert(target == GL_ARRAY_BUFFER ? sGLRenderBuffer == mGLBuffer : sGLRenderIndices == mGLIndices); - - // skip mapped data and stream to GPU via glBufferSubData - if (end != 0) + if (gGLManager.mIsApple) { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData"); - LL_PROFILE_ZONE_NUM(start); - LL_PROFILE_ZONE_NUM(end); - LL_PROFILE_ZONE_NUM(end-start); - - constexpr U32 block_size = 8192; + // on OS X, flush_vbo doesn't actually write to the GL buffer, so be sure to call + // _mapBuffer to tag the buffer for flushing to GL + _mapBuffer(); + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb memcpy"); + STOP_GLERROR; + // copy into mapped buffer + memcpy(dst+start, data, end-start+1); + } + else + { + llassert(target == GL_ARRAY_BUFFER ? sGLRenderBuffer == mGLBuffer : sGLRenderIndices == mGLIndices); - for (U32 i = start; i <= end; i += block_size) + // skip mapped data and stream to GPU via glBufferSubData + if (end != 0) { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData block"); - //LL_PROFILE_GPU_ZONE("glBufferSubData"); - U32 tend = llmin(i + block_size, end); - U32 size = tend - i + 1; - glBufferSubData(target, i, size, (U8*) data + (i-start)); + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData"); + LL_PROFILE_ZONE_NUM(start); + LL_PROFILE_ZONE_NUM(end); + LL_PROFILE_ZONE_NUM(end-start); + + constexpr U32 block_size = 65536; + + for (U32 i = start; i <= end; i += block_size) + { + //LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData block"); + //LL_PROFILE_GPU_ZONE("glBufferSubData"); + U32 tend = llmin(i + block_size, end); + U32 size = tend - i + 1; + glBufferSubData(target, i, size, (U8*) data + (i-start)); + } } } -#endif } void LLVertexBuffer::unmapBuffer() { + flushBuffers(); +} + +void LLVertexBuffer::_mapBuffer() +{ + if (!mMapped) + { + mMapped = true; + sMappedBuffers.push_back(this); + } +} + +void LLVertexBuffer::_unmapBuffer() +{ STOP_GLERROR; + if (!mMapped) + { + return; + } + struct SortMappedRegion { bool operator()(const MappedRegion& lhs, const MappedRegion& rhs) @@ -1314,114 +1401,116 @@ void LLVertexBuffer::unmapBuffer() } }; -#if LL_DARWIN - STOP_GLERROR; - if (mMappedData) + if (gGLManager.mIsApple) { - if (mGLBuffer) + STOP_GLERROR; + if (mMappedData) { - glDeleteBuffers(1, &mGLBuffer); + if (mGLBuffer) + { + delete_buffers(1, &mGLBuffer); + } + mGLBuffer = gen_buffer(); + glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); + sGLRenderBuffer = mGLBuffer; + glBufferData(GL_ARRAY_BUFFER, mSize, mMappedData, GL_STATIC_DRAW); } - mGLBuffer = gen_buffer(); - glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); - sGLRenderBuffer = mGLBuffer; - glBufferData(GL_ARRAY_BUFFER, mSize, mMappedData, GL_STATIC_DRAW); - } - else if (mGLBuffer != sGLRenderBuffer) - { - glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); - sGLRenderBuffer = mGLBuffer; - } - STOP_GLERROR; - - if (mMappedIndexData) - { - if (mGLIndices) - { - glDeleteBuffers(1, &mGLIndices); - } - - mGLIndices = gen_buffer(); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); - sGLRenderIndices = mGLIndices; - - glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mMappedIndexData, GL_STATIC_DRAW); - } - else if (mGLIndices != sGLRenderIndices) - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); - sGLRenderIndices = mGLIndices; - } - STOP_GLERROR; -#else - - if (!mMappedVertexRegions.empty()) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - vertex"); - - if (sGLRenderBuffer != mGLBuffer) + else if (mGLBuffer != sGLRenderBuffer) { glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); sGLRenderBuffer = mGLBuffer; } + STOP_GLERROR; - U32 start = 0; - U32 end = 0; - - std::sort(mMappedVertexRegions.begin(), mMappedVertexRegions.end(), SortMappedRegion()); - - for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) + if (mMappedIndexData) { - const MappedRegion& region = mMappedVertexRegions[i]; - if (region.mStart == end + 1) + if (mGLIndices) { - end = region.mEnd; + delete_buffers(1, &mGLIndices); } - else - { - flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start, mMappedData); - start = region.mStart; - end = region.mEnd; - } - } - flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start, mMappedData); - mMappedVertexRegions.clear(); - } - - if (!mMappedIndexRegions.empty()) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - index"); + mGLIndices = gen_buffer(); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); + sGLRenderIndices = mGLIndices; - if (mGLIndices != sGLRenderIndices) + glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mMappedIndexData, GL_STATIC_DRAW); + } + else if (mGLIndices != sGLRenderIndices) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); sGLRenderIndices = mGLIndices; } - U32 start = 0; - U32 end = 0; + STOP_GLERROR; + } + else + { + if (!mMappedVertexRegions.empty()) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - vertex"); - std::sort(mMappedIndexRegions.begin(), mMappedIndexRegions.end(), SortMappedRegion()); + if (sGLRenderBuffer != mGLBuffer) + { + glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); + sGLRenderBuffer = mGLBuffer; + } - for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) + U32 start = 0; + U32 end = 0; + + std::sort(mMappedVertexRegions.begin(), mMappedVertexRegions.end(), SortMappedRegion()); + + for (U32 i = 0; i < mMappedVertexRegions.size(); ++i) + { + const MappedRegion& region = mMappedVertexRegions[i]; + if (region.mStart == end + 1) + { + end = region.mEnd; + } + else + { + flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start, mMappedData); + start = region.mStart; + end = region.mEnd; + } + } + + flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start, mMappedData); + mMappedVertexRegions.clear(); + } + + if (!mMappedIndexRegions.empty()) { - const MappedRegion& region = mMappedIndexRegions[i]; - if (region.mStart == end + 1) + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - index"); + + if (mGLIndices != sGLRenderIndices) { - end = region.mEnd; + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); + sGLRenderIndices = mGLIndices; } - else + U32 start = 0; + U32 end = 0; + + std::sort(mMappedIndexRegions.begin(), mMappedIndexRegions.end(), SortMappedRegion()); + + for (U32 i = 0; i < mMappedIndexRegions.size(); ++i) { - flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start, mMappedIndexData); - start = region.mStart; - end = region.mEnd; + const MappedRegion& region = mMappedIndexRegions[i]; + if (region.mStart == end + 1) + { + end = region.mEnd; + } + else + { + flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start, mMappedIndexData); + start = region.mStart; + end = region.mEnd; + } } - } - flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start, mMappedIndexData); - mMappedIndexRegions.clear(); + flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start, mMappedIndexData); + mMappedIndexRegions.clear(); + } } -#endif } //---------------------------------------------------------------------------- @@ -1543,12 +1632,13 @@ bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, U32 in void LLVertexBuffer::setBuffer() { STOP_GLERROR; -#if LL_DARWIN - if (!mGLBuffer) - { // OS X doesn't allocate a buffer until we call unmapBuffer - return; + + if (mMapped) + { + LL_WARNS_ONCE() << "Missing call to unmapBuffer or flushBuffers" << LL_ENDL; + _unmapBuffer(); } -#endif + // no data may be pending llassert(mMappedVertexRegions.empty()); llassert(mMappedIndexRegions.empty()); diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 2a4affdc60..d4c6fbaf18 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -38,6 +38,7 @@ #include <set> #include <vector> #include <list> +#include <glm/gtc/matrix_transform.hpp> #define LL_MAX_VERTEX_ATTRIB_LOCATION 64 @@ -63,8 +64,11 @@ public: , mMode(0) , mCount(0) , mTexName(0) + , mProjection(glm::identity<glm::mat4>()) + , mModelView(glm::identity<glm::mat4>()) + , mTexture0(glm::identity<glm::mat4>()) {} - LLVertexBufferData(LLVertexBuffer* buffer, U8 mode, U32 count, U32 tex_name, glh::matrix4f model_view, glh::matrix4f projection, glh::matrix4f texture0) + LLVertexBufferData(LLVertexBuffer* buffer, U8 mode, U32 count, U32 tex_name, const glm::mat4& model_view, const glm::mat4& projection, const glm::mat4& texture0) : mVB(buffer) , mMode(mode) , mCount(count) @@ -78,9 +82,9 @@ public: U8 mMode; U32 mCount; U32 mTexName; - glh::matrix4f mProjection; - glh::matrix4f mModelView; - glh::matrix4f mTexture0; + glm::mat4 mProjection; + glm::mat4 mModelView; + glm::mat4 mTexture0; }; typedef std::list<LLVertexBufferData> buffer_data_list_t; @@ -120,6 +124,9 @@ public: // indexed by the following enum static U32 calcOffsets(const U32& typemask, U32* offsets, U32 num_vertices); + // flush any pending mapped buffers + static void flushBuffers(); + //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize // 2 - update LLVertexBuffer::vb_type_name @@ -190,6 +197,8 @@ public: // map for data access (see also getFooStrider below) U8* mapVertexBuffer(AttributeType type, U32 index, S32 count = -1); U8* mapIndexBuffer(U32 index, S32 count = -1); + + // synonym for flushBuffers void unmapBuffer(); // set for rendering @@ -312,6 +321,13 @@ private: bool allocateBuffer(S32 nverts, S32 nindices, bool create) { return allocateBuffer(nverts, nindices); } + // actually unmap buffer + void _unmapBuffer(); + + // add to set of mapped buffers + void _mapBuffer(); + bool mMapped = false; + public: static U64 getBytesAllocated(); diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index c6654ee0aa..42b6f1f07b 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -204,13 +204,13 @@ void renderBadgeBackground(F32 centerX, F32 centerY, F32 width, F32 height, cons (F32)ll_round(x) + width, (F32)ll_round(y) + height); - LLVector3 vertices[4]; - vertices[0] = LLVector3(screen_rect.mRight, screen_rect.mTop, 1.0f); - vertices[1] = LLVector3(screen_rect.mLeft, screen_rect.mTop, 1.0f); - vertices[2] = LLVector3(screen_rect.mLeft, screen_rect.mBottom, 1.0f); - vertices[3] = LLVector3(screen_rect.mRight, screen_rect.mBottom, 1.0f); + LLVector4a vertices[4]; + vertices[0].set(screen_rect.mLeft, screen_rect.mTop, 1.0f); + vertices[1].set(screen_rect.mRight, screen_rect.mTop, 1.0f); + vertices[2].set(screen_rect.mLeft, screen_rect.mBottom, 1.0f); + vertices[3].set(screen_rect.mRight, screen_rect.mBottom, 1.0f); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLE_STRIP); { gGL.vertexBatchPreTransformed(vertices, 4); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 92fb4b75bf..4b904f09e0 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2275,36 +2275,28 @@ void LLFloater::drawConeToOwner(F32 &context_cone_opacity, gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLEnable(GL_CULL_FACE); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLE_STRIP); { gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity); gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); - gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity); gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); - + gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); gGL.vertex2i(local_rect.mRight, local_rect.mTop); gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity); - gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); - - gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); gGL.vertex2i(local_rect.mRight, local_rect.mBottom); gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity); - gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); + gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity); + gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); + gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity); + gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); + gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity); + gGL.vertex2i(local_rect.mLeft, local_rect.mTop); } gGL.end(); } diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index 388dc5b1ac..42a9e267d2 100644 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -1649,7 +1649,7 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr { LLRect local_rect = item->getLocalRect(); S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight(); - S32 label_height = getLabelFontForStyle(mLabelStyle)->getLineHeight(); + S32 label_height = getLabelFont()->getLineHeight(); // when navigating with keyboard, only move top of opened folder on screen, otherwise show whole folder S32 max_height_to_show = item->isOpen() && mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + item->getIconPad()) : local_rect.getHeight(); diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index e4f5664908..18bde344a0 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -48,7 +48,6 @@ static LLDefaultChildRegistry::Register<LLFolderViewItem> r("folder_view_item"); // statics std::map<U8, LLFontGL*> LLFolderViewItem::sFonts; // map of styles to fonts -bool LLFolderViewItem::sColorSetInitialized = false; LLUIColor LLFolderViewItem::sFgColor; LLUIColor LLFolderViewItem::sHighlightBgColor; LLUIColor LLFolderViewItem::sFlashBgColor; @@ -58,6 +57,10 @@ LLUIColor LLFolderViewItem::sFilterBGColor; LLUIColor LLFolderViewItem::sFilterTextColor; LLUIColor LLFolderViewItem::sSuffixColor; LLUIColor LLFolderViewItem::sSearchStatusColor; +S32 LLFolderViewItem::sTopPad = 0; +LLUIImagePtr LLFolderViewItem::sFolderArrowImg; +LLUIImagePtr LLFolderViewItem::sSelectionImg; +LLFontGL* LLFolderViewItem::sSuffixFont = nullptr; // only integers can be initialized in header const F32 LLFolderViewItem::FOLDER_CLOSE_TIME_CONSTANT = 0.02f; @@ -83,15 +86,42 @@ LLFontGL* LLFolderViewItem::getLabelFontForStyle(U8 style) return rtn; } + +const LLFontGL* LLFolderViewItem::getLabelFont() +{ + if (!pLabelFont) + { + pLabelFont = getLabelFontForStyle(mLabelStyle); + } + return pLabelFont; +} //static void LLFolderViewItem::initClass() { + const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>(); + sTopPad = default_params.item_top_pad; + sFolderArrowImg = default_params.folder_arrow_image; + sSelectionImg = default_params.selection_image; + sSuffixFont = getLabelFontForStyle(LLFontGL::NORMAL); + + sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); + sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE); + sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE); + sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE); + sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE); + sFilterBGColor = LLUIColorTable::instance().getColor("FilterBackgroundColor", DEFAULT_WHITE); + sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE); + sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE); + sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE); } //static void LLFolderViewItem::cleanupClass() { sFonts.clear(); + sFolderArrowImg = nullptr; + sSelectionImg = nullptr; + sSuffixFont = nullptr; } @@ -134,6 +164,7 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mIsItemCut(false), mCutGeneration(0), mLabelStyle( LLFontGL::NORMAL ), + pLabelFont(nullptr), mHasVisibleChildren(false), mLocalIndentation(p.folder_indentation), mIndentation(0), @@ -158,20 +189,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mMaxFolderItemOverlap(p.max_folder_item_overlap), mDoubleClickOverride(p.double_click_override) { - if (!sColorSetInitialized) - { - sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); - sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE); - sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE); - sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE); - sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE); - sFilterBGColor = LLUIColorTable::instance().getColor("FilterBackgroundColor", DEFAULT_WHITE); - sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE); - sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE); - sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE); - sColorSetInitialized = true; - } - if (mViewModelItem) { mViewModelItem->setFolderViewItem(this); @@ -307,6 +324,7 @@ void LLFolderViewItem::refresh() LLFolderViewModelItem& vmi = *getViewModelItem(); mLabel = utf8str_to_wstring(vmi.getDisplayName()); + mLabelFontBuffer.reset(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -319,7 +337,9 @@ void LLFolderViewItem::refresh() // Very Expensive! // Can do a number of expensive checks, like checking active motions, wearables or friend list mLabelStyle = vmi.getLabelStyle(); + pLabelFont = nullptr; // refresh can be called from a coro, don't use getLabelFontForStyle, coro trips font list tread safety mLabelSuffix = utf8str_to_wstring(vmi.getLabelSuffix()); + mSuffixFontBuffer.reset(); } // Dirty the filter flag of the model from the view (CHUI-849) @@ -344,6 +364,7 @@ void LLFolderViewItem::refreshSuffix() // Very Expensive! // Can do a number of expensive checks, like checking active motions, wearables or friend list mLabelStyle = vmi->getLabelStyle(); + pLabelFont = nullptr; mLabelSuffix = utf8str_to_wstring(vmi->getLabelSuffix()); } @@ -736,19 +757,17 @@ bool LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, return handled; } -void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color) +void LLFolderViewItem::drawOpenFolderArrow() { //--------------------------------------------------------------------------------// // Draw open folder arrow // - const S32 TOP_PAD = default_params.item_top_pad; if (hasVisibleChildren() || !isFolderComplete()) { - LLUIImage* arrow_image = default_params.folder_arrow_image; gl_draw_scaled_rotated_image( - mIndentation, getRect().getHeight() - mArrowSize - mTextPad - TOP_PAD, - mArrowSize, mArrowSize, mControlLabelRotation, arrow_image->getImage(), fg_color); + mIndentation, getRect().getHeight() - mArrowSize - mTextPad - sTopPad, + mArrowSize, mArrowSize, mControlLabelRotation, sFolderArrowImg->getImage(), sFgColor); } } @@ -764,7 +783,7 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L /*virtual*/ bool LLFolderViewItem::isFadeItem() { - LLClipboard& clipboard = LLClipboard::instance(); + static const LLClipboard& clipboard = LLClipboard::instance(); // Make it a 'simpleton'? if (mCutGeneration != clipboard.getGeneration()) { mCutGeneration = clipboard.getGeneration(); @@ -775,8 +794,9 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L return mIsItemCut; } -void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, - const LLUIColor &focusOutlineColor, const LLUIColor &mouseOverColor) +void LLFolderViewItem::drawHighlight(bool showContent, bool hasKeyboardFocus, + const LLUIColor& selectColor, const LLUIColor& flashColor, + const LLUIColor& focusOutlineColor, const LLUIColor& mouseOverColor) { const S32 focus_top = getRect().getHeight(); const S32 focus_bottom = getRect().getHeight() - mItemHeight; @@ -784,7 +804,7 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo const S32 FOCUS_LEFT = 1; // Determine which background color to use for highlighting - const LLUIColor& bgColor = (isFlashing() ? flashColor : selectColor); + const LLUIColor& bgColor = isFlashing() ? flashColor : selectColor; //--------------------------------------------------------------------------------// // Draw highlight for selected items @@ -792,7 +812,6 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo // items if mShowSingleSelection is false. // if (isHighlightAllowed()) - { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -801,7 +820,7 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo { LLColor4 bg_color = bgColor; // do time-based fade of extra objects - F32 fade_time = (getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.0f); + F32 fade_time = getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.f; if (getRoot() && getRoot()->getShowSingleSelection()) { // fading out @@ -890,7 +909,7 @@ void LLFolderViewItem::drawLabel(const LLFontGL * font, const F32 x, const F32 y //--------------------------------------------------------------------------------// // Draw the actual label text // - font->render(mLabel, 0, x, y, color, + mLabelFontBuffer.render(font, mLabel, 0, x, y, color, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, getRect().getWidth() - (S32) x - mLabelPaddingRight, &right_x, /*use_ellipses*/true); } @@ -900,16 +919,14 @@ void LLFolderViewItem::draw() const bool show_context = (getRoot() ? getRoot()->getShowSelectionContext() : false); const bool filled = show_context || (getRoot() ? getRoot()->getParentPanel()->hasFocus() : false); // If we have keyboard focus, draw selection filled - const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>(); - const S32 TOP_PAD = default_params.item_top_pad; - - const LLFontGL* font = getLabelFontForStyle(mLabelStyle); + const LLFontGL* font = getLabelFont(); + S32 line_height = font->getLineHeight(); getViewModelItem()->update(); - if(!mSingleFolderMode) + if (!mSingleFolderMode) { - drawOpenFolderArrow(default_params, sFgColor); + drawOpenFolderArrow(); } drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor); @@ -918,18 +935,19 @@ void LLFolderViewItem::draw() // Draw open icon // const S32 icon_x = mIndentation + mArrowSize + mTextPad; + const S32 rect_height = getRect().getHeight(); if (!mIconOpen.isNull() && (llabs(mControlLabelRotation) > 80)) // For open folders { - mIconOpen->draw(icon_x, getRect().getHeight() - mIconOpen->getHeight() - TOP_PAD + 1); + mIconOpen->draw(icon_x, rect_height - mIconOpen->getHeight() - sTopPad + 1); } else if (mIcon) { - mIcon->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1); + mIcon->draw(icon_x, rect_height - mIcon->getHeight() - sTopPad + 1); } if (mIconOverlay && getRoot()->showItemLinkOverlays()) { - mIconOverlay->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1); + mIconOverlay->draw(icon_x, rect_height - mIcon->getHeight() - sTopPad + 1); } //--------------------------------------------------------------------------------// @@ -940,26 +958,24 @@ void LLFolderViewItem::draw() return; } - auto filter_string_length = mViewModelItem->hasFilterStringMatch() ? static_cast<S32>(mViewModelItem->getFilterStringSize()) : 0; + S32 filter_string_length = mViewModelItem->hasFilterStringMatch() ? (S32)mViewModelItem->getFilterStringSize() : 0; F32 right_x = 0; - F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; + F32 y = (F32)rect_height - line_height - (F32)mTextPad - (F32)sTopPad; F32 text_left = (F32)getLabelXPos(); LLWString combined_string = mLabel + mLabelSuffix; - const LLFontGL* suffix_font = getLabelFontForStyle(LLFontGL::NORMAL); S32 filter_offset = static_cast<S32>(mViewModelItem->getFilterStringOffset()); if (filter_string_length > 0) { - S32 bottom = getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD; - S32 top = getRect().getHeight() - TOP_PAD; - if(mLabelSuffix.empty() || (font == suffix_font)) + S32 bottom = rect_height - line_height - 3 - sTopPad; + S32 top = rect_height - sTopPad; + if(mLabelSuffix.empty() || (font == sSuffixFont)) { - S32 left = ll_round(text_left) + font->getWidth(combined_string.c_str(), 0, static_cast<S32>(mViewModelItem->getFilterStringOffset())) - 2; - S32 right = left + font->getWidth(combined_string.c_str(), static_cast<S32>(mViewModelItem->getFilterStringOffset()), filter_string_length) + 2; + S32 left = ll_round(text_left) + font->getWidth(combined_string.c_str(), 0, filter_offset) - 2; + S32 right = left + font->getWidth(combined_string.c_str(), filter_offset, filter_string_length) + 2; - LLUIImage* box_image = default_params.selection_image; - LLRect box_rect(left, top, right, bottom); - box_image->draw(box_rect, sFilterBGColor); + LLRect box_rect(left, top, right, bottom); + sSelectionImg->draw(box_rect, sFilterBGColor); } else { @@ -968,19 +984,17 @@ void LLFolderViewItem::draw() { S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel.c_str(), 0, llmin(filter_offset, (S32)mLabel.size()))) - 2; S32 right = left + (S32)font->getWidthF32(mLabel.c_str(), filter_offset, label_filter_length) + 2; - LLUIImage* box_image = default_params.selection_image; LLRect box_rect(left, top, right, bottom); - box_image->draw(box_rect, sFilterBGColor); + sSelectionImg->draw(box_rect, sFilterBGColor); } S32 suffix_filter_length = label_filter_length > 0 ? filter_string_length - label_filter_length : filter_string_length; if(suffix_filter_length > 0) { S32 suffix_offset = llmax(0, filter_offset - (S32)mLabel.size()); - S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel.c_str(), 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix.c_str(), 0, suffix_offset)) - 2; - S32 right = left + (S32)suffix_font->getWidthF32(mLabelSuffix.c_str(), suffix_offset, suffix_filter_length) + 2; - LLUIImage* box_image = default_params.selection_image; + S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel.c_str(), 0, static_cast<S32>(mLabel.size())) + sSuffixFont->getWidthF32(mLabelSuffix.c_str(), 0, suffix_offset)) - 2; + S32 right = left + (S32)sSuffixFont->getWidthF32(mLabelSuffix.c_str(), suffix_offset, suffix_filter_length) + 2; LLRect box_rect(left, top, right, bottom); - box_image->draw(box_rect, sFilterBGColor); + sSelectionImg->draw(box_rect, sFilterBGColor); } } } @@ -999,9 +1013,9 @@ void LLFolderViewItem::draw() // if (!mLabelSuffix.empty()) { - suffix_font->render( mLabelSuffix, 0, right_x, y, isFadeItem() ? color : sSuffixColor.get(), - LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, S32_MAX, &right_x); + mSuffixFontBuffer.render(sSuffixFont, mLabelSuffix, 0, right_x, y, isFadeItem() ? color : sSuffixColor.get(), + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + S32_MAX, S32_MAX, &right_x); } //--------------------------------------------------------------------------------// @@ -1009,10 +1023,10 @@ void LLFolderViewItem::draw() // if (filter_string_length > 0) { - if(mLabelSuffix.empty() || (font == suffix_font)) + if(mLabelSuffix.empty() || (font == sSuffixFont)) { F32 match_string_left = text_left + font->getWidthF32(combined_string.c_str(), 0, filter_offset + filter_string_length) - font->getWidthF32(combined_string.c_str(), filter_offset, filter_string_length); - F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; + F32 yy = (F32)rect_height - line_height - (F32)mTextPad - (F32)sTopPad; font->render(combined_string, filter_offset, match_string_left, yy, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, filter_string_length, S32_MAX, &right_x); @@ -1023,7 +1037,7 @@ void LLFolderViewItem::draw() if(label_filter_length > 0) { F32 match_string_left = text_left + font->getWidthF32(mLabel.c_str(), 0, filter_offset + label_filter_length) - font->getWidthF32(mLabel.c_str(), filter_offset, label_filter_length); - F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; + F32 yy = (F32)rect_height - line_height - (F32)mTextPad - (F32)sTopPad; font->render(mLabel, filter_offset, match_string_left, yy, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, label_filter_length, S32_MAX, &right_x); @@ -1033,9 +1047,9 @@ void LLFolderViewItem::draw() if(suffix_filter_length > 0) { S32 suffix_offset = llmax(0, filter_offset - (S32)mLabel.size()); - F32 match_string_left = text_left + font->getWidthF32(mLabel.c_str(), 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix.c_str(), 0, suffix_offset + suffix_filter_length) - suffix_font->getWidthF32(mLabelSuffix.c_str(), suffix_offset, suffix_filter_length); - F32 yy = (F32)getRect().getHeight() - suffix_font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; - suffix_font->render(mLabelSuffix, suffix_offset, match_string_left, yy, sFilterTextColor, + F32 match_string_left = text_left + font->getWidthF32(mLabel.c_str(), 0, static_cast<S32>(mLabel.size())) + sSuffixFont->getWidthF32(mLabelSuffix.c_str(), 0, suffix_offset + suffix_filter_length) - sSuffixFont->getWidthF32(mLabelSuffix.c_str(), suffix_offset, suffix_filter_length); + F32 yy = (F32)rect_height - sSuffixFont->getLineHeight() - (F32)mTextPad - (F32)sTopPad; + sSuffixFont->render(mLabelSuffix, suffix_offset, match_string_left, yy, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, suffix_filter_length, S32_MAX, &right_x); } diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 60cdac3ab9..cc8a7d934c 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -29,6 +29,7 @@ #include "llflashtimer.h" #include "llview.h" #include "lluiimage.h" +#include "llfontvertexbuffer.h" class LLFolderView; class LLFolderViewModelItem; @@ -134,7 +135,6 @@ protected: LLUIColor mFontHighlightColor; // For now assuming all colors are the same in derived classes. - static bool sColorSetInitialized; static LLUIColor sFgColor; static LLUIColor sFgDisabledColor; static LLUIColor sHighlightBgColor; @@ -157,6 +157,7 @@ protected: virtual void setFlashState(bool) { } static LLFontGL* getLabelFontForStyle(U8 style); + const LLFontGL* getLabelFont(); bool mIsSelected; @@ -296,9 +297,9 @@ public: // virtual void handleDropped(); virtual void draw(); - void drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color); - void drawHighlight(const bool showContent, const bool hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, const LLUIColor &outlineColor, const LLUIColor &mouseOverColor); - void drawLabel(const LLFontGL * font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x); + void drawOpenFolderArrow(); + void drawHighlight(bool showContent, bool hasKeyboardFocus, const LLUIColor& selectColor, const LLUIColor& flashColor, const LLUIColor& outlineColor, const LLUIColor& mouseOverColor); + void drawLabel(const LLFontGL* font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x); virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type, void* cargo_data, @@ -307,6 +308,14 @@ public: private: static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts + static S32 sTopPad; + static LLUIImagePtr sFolderArrowImg; + static LLUIImagePtr sSelectionImg; + static LLFontGL* sSuffixFont; + + LLFontVertexBuffer mLabelFontBuffer; + LLFontVertexBuffer mSuffixFontBuffer; + LLFontGL* pLabelFont{nullptr}; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index b8d6d89971..9372818ca5 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -292,6 +292,7 @@ public: dirtyFilter(); requestSort(); } + virtual void removeChild(LLFolderViewModelItem* child) { mChildren.remove(child); diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 60b6115b34..66b274c33f 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -436,6 +436,9 @@ void LLLineEditor::setText(const LLStringExplicit &new_text, bool use_size_limit { mText.assign(utf8str_symbol_truncate(truncated_utf8, mMaxLengthChars)); } + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); if (all_selected) { @@ -617,6 +620,10 @@ void LLLineEditor::replaceWithSuggestion(U32 index) mText.insert(it->first, suggestion); setCursor(it->first + (S32)suggestion.length()); + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); + break; } } @@ -969,6 +976,10 @@ void LLLineEditor::removeChar() mText.erase(getCursor() - 1, 1); setCursor(getCursor() - 1); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); } else { @@ -992,6 +1003,10 @@ void LLLineEditor::addChar(const llwchar uni_char) return; mText.erase(getCursor(), 1); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); } S32 cur_bytes = static_cast<S32>(mText.getString().size()); @@ -1022,6 +1037,10 @@ void LLLineEditor::addChar(const llwchar uni_char) mText.insert(getCursor(), w_buf); setCursor(getCursor() + 1); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); } else { @@ -1186,6 +1205,10 @@ void LLLineEditor::deleteSelection() mText.erase(left_pos, selection_length); deselect(); setCursor(left_pos); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); } } @@ -1346,6 +1369,10 @@ void LLLineEditor::pasteHelper(bool is_primary) setCursor( getCursor() + (S32)clean_string.length() ); deselect(); + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); + // Validate new string and rollback the if needed. bool need_to_rollback = mPrevalidator && !mPrevalidator.validate(mText.getWString()); if (need_to_rollback) @@ -1506,6 +1533,10 @@ bool LLLineEditor::handleSpecialKey(KEY key, MASK mask) { mText.assign(*(--mCurrentHistoryLine)); setCursorToEnd(); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); } else { @@ -1523,6 +1554,10 @@ bool LLLineEditor::handleSpecialKey(KEY key, MASK mask) { mText.assign( *(++mCurrentHistoryLine) ); setCursorToEnd(); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); } else { @@ -1897,7 +1932,8 @@ void LLLineEditor::draw() if( select_left > mScrollHPos ) { // unselected, left side - rendered_text = mGLFont->render( + rendered_text = mFontBufferPreSelection.render( + mGLFont, mText, mScrollHPos, rendered_pixels_right, text_bottom, text_color, @@ -1919,7 +1955,8 @@ void LLLineEditor::draw() gl_rect_2d(ll_round(rendered_pixels_right), cursor_top, ll_round(rendered_pixels_right)+width, cursor_bottom, color); LLColor4 tmp_color( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha ); - rendered_text += mGLFont->render( + rendered_text += mFontBufferSelection.render( + mGLFont, mText, mScrollHPos + rendered_text, rendered_pixels_right, text_bottom, tmp_color, @@ -1934,7 +1971,8 @@ void LLLineEditor::draw() if( (rendered_pixels_right < (F32)mTextRightEdge) && (rendered_text < text_len) ) { // unselected, right side - rendered_text += mGLFont->render( + rendered_text += mFontBufferPostSelection.render( + mGLFont, mText, mScrollHPos + rendered_text, rendered_pixels_right, text_bottom, text_color, @@ -1948,7 +1986,8 @@ void LLLineEditor::draw() } else { - rendered_text = mGLFont->render( + rendered_text = mFontBufferPreSelection.render( + mGLFont, mText, mScrollHPos, rendered_pixels_right, text_bottom, text_color, @@ -2108,7 +2147,8 @@ void LLLineEditor::draw() //to give indication that it is not text you typed in if (0 == mText.length() && (mReadOnly || mShowLabelFocused)) { - mGLFont->render(mLabel.getWString(), 0, + mFontBufferLabel.render(mGLFont, + mLabel.getWString(), 0, (F32)mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, @@ -2133,7 +2173,8 @@ void LLLineEditor::draw() // draw label if no text provided if (0 == mText.length()) { - mGLFont->render(mLabel.getWString(), 0, + mFontBufferLabel.render(mGLFont, + mLabel.getWString(), 0, (F32)mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, @@ -2404,12 +2445,16 @@ void LLLineEditor::setKeystrokeCallback(callback_t callback, void* user_data) bool LLLineEditor::setTextArg( const std::string& key, const LLStringExplicit& text ) { mText.setArg(key, text); + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); return true; } bool LLLineEditor::setLabelArg( const std::string& key, const LLStringExplicit& text ) { mLabel.setArg(key, text); + mFontBufferLabel.reset(); return true; } @@ -2508,6 +2553,9 @@ void LLLineEditor::updatePreedit(const LLWString &preedit_string, mPreeditOverwrittenWString.clear(); } mText.insert(insert_preedit_at, mPreeditWString); + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); mPreeditStandouts = preedit_standouts; diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index cdd22413e7..12fe800acb 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -40,6 +40,7 @@ #include "llframetimer.h" #include "lleditmenuhandler.h" +#include "llfontvertexbuffer.h" #include "llspellcheckmenuhandler.h" #include "lluictrl.h" #include "lluiimage.h" @@ -344,6 +345,10 @@ protected: LLViewBorder* mBorder; const LLFontGL* mGLFont; + LLFontVertexBuffer mFontBufferPreSelection; + LLFontVertexBuffer mFontBufferSelection; + LLFontVertexBuffer mFontBufferPostSelection; + LLFontVertexBuffer mFontBufferLabel; S32 mMaxLengthBytes; // Max length of the UTF8 string in bytes S32 mMaxLengthChars; // Maximum number of characters in the string S32 mCursorPos; // I-beam is just after the mCursorPos-th character. diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 2693243eb1..62c0401869 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -460,7 +460,7 @@ void LLStatBar::draw() max_value = 0.f; gGL.color4f(1.f, 0.f, 0.f, 1.f); - gGL.begin( LLRender::QUADS ); + gGL.begin(LLRender::TRIANGLES); const S32 max_frame = llmin(num_frames, num_values); U32 num_samples = 0; for (S32 i = 1; i <= max_frame; i++) @@ -498,6 +498,9 @@ void LLStatBar::draw() gGL.vertex2f((F32)bar_rect.mRight - offset, max); gGL.vertex2f((F32)bar_rect.mRight - offset, min); gGL.vertex2f((F32)bar_rect.mRight - offset - 1, min); + + gGL.vertex2f((F32)bar_rect.mRight - offset, max); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, min); gGL.vertex2f((F32)bar_rect.mRight - offset - 1, max); } else @@ -505,7 +508,10 @@ void LLStatBar::draw() gGL.vertex2f(min, (F32)bar_rect.mBottom + offset + 1); gGL.vertex2f(min, (F32)bar_rect.mBottom + offset); gGL.vertex2f(max, (F32)bar_rect.mBottom + offset); - gGL.vertex2f(max, (F32)bar_rect.mBottom + offset + 1 ); + + gGL.vertex2f(min, (F32)bar_rect.mBottom + offset + 1); + gGL.vertex2f(max, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(max, (F32)bar_rect.mBottom + offset + 1); } } gGL.end(); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 0aebf7543c..cbbf83d679 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -948,7 +948,6 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length) { - beforeValueChange(); segment_set_t::iterator seg_iter = getSegIterContaining(pos); while(seg_iter != mSegments.end()) @@ -1325,6 +1324,7 @@ void LLTextBase::reshape(S32 width, S32 height, bool called_from_parent) //virtual void LLTextBase::draw() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; // reflow if needed, on demand reflow(); @@ -2368,6 +2368,34 @@ S32 LLTextBase::removeFirstLine() return 0; } +// virtual +void LLTextBase::copyContents(const LLTextBase* source) +{ + llassert(source); + if (!source) + return; + + beforeValueChange(); + deselect(); + + mSegments.clear(); + for (const LLTextSegmentPtr& segp : source->mSegments) + { + mSegments.emplace(segp->clone(*this)); + } + + mLineInfoList.clear(); + for (const line_info& li : mLineInfoList) + { + mLineInfoList.push_back(line_info(li)); + } + + getViewModel()->setDisplay(source->getViewModel()->getDisplay()); + + onValueChange(0, getLength()); + needsReflow(); +} + void LLTextBase::appendLineBreakSegment(const LLStyle::Params& style_params) { segment_vec_t segments; @@ -2586,6 +2614,11 @@ const LLWString& LLTextBase::getWText() const return getViewModel()->getDisplay(); } +S32 LLTextBase::getTextGeneration() const +{ + return getViewModel()->getDisplayGeneration(); +} + // If round is true, if the position is on the right half of a character, the cursor // will be put to its right. If round is false, the cursor will always be put to the // character's left. @@ -3228,6 +3261,24 @@ boost::signals2::connection LLTextBase::setIsObjectBlockedCallback(const is_bloc LLTextSegment::~LLTextSegment() {} +// static +LLStyleSP LLTextSegment::cloneStyle(LLTextBase& target, const LLStyle* source) +{ + // Take most params from target + LLStyle::Params params = target.getStyleParams(); + LLStyle* style = new LLStyle(params); + + // Take some params from source + style->setLinkHREF(source->getLinkHREF()); + if (source->isImage()) + { + style->setImage(source->getImage()->getName()); + } + + return style; +} + + bool LLTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { width = 0; height = 0; return false; } bool LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { @@ -3280,7 +3331,8 @@ LLNormalTextSegment::LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 e : LLTextSegment(start, end), mStyle( style ), mToken(NULL), - mEditor(editor) + mEditor(editor), + mLastGeneration(-1) { mFontHeight = mStyle->getFont()->getLineHeight(); @@ -3294,7 +3346,8 @@ LLNormalTextSegment::LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 e LLNormalTextSegment::LLNormalTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible) : LLTextSegment(start, end), mToken(NULL), - mEditor(editor) + mEditor(editor), + mLastGeneration(-1) { mStyle = new LLStyle(LLStyle::Params().visible(is_visible).color(color)); @@ -3313,25 +3366,41 @@ F32 LLNormalTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selec { return drawClippedSegment( getStart() + start, getStart() + end, selection_start, selection_end, draw_rect); } + else + { + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); + } return draw_rect.mLeft; } // Draws a single text segment, reversing the color for selection if needed. F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 selection_start, S32 selection_end, LLRectf rect) { - F32 alpha = LLViewDrawContext::getCurrentContext().mAlpha; - - const LLWString &text = getWText(); - F32 right_x = rect.mLeft; if (!mStyle->isVisible()) { return right_x; } - const LLFontGL* font = mStyle->getFont(); + F32 alpha = LLViewDrawContext::getCurrentContext().mAlpha; + + const LLWString& text = getWText(); + S32 text_gen = mEditor.getTextGeneration(); + + if (text_gen != mLastGeneration) + { + mLastGeneration = text_gen; + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); + } + const LLFontGL* font = mStyle->getFont(); LLColor4 color = (mEditor.getReadOnly() ? mStyle->getReadOnlyColor() : mStyle->getColor()) % (alpha * mStyle->getAlpha()); + bool use_font_buffers = useFontBuffers(); if( selection_start > seg_start ) { @@ -3339,16 +3408,40 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele S32 start = seg_start; S32 end = llmin( selection_start, seg_end ); S32 length = end - start; - font->render(text, start, - rect, - color, - LLFontGL::LEFT, mEditor.mTextVAlign, - LLFontGL::NORMAL, - mStyle->getShadowType(), - length, - &right_x, - mEditor.getUseEllipses(), - mEditor.getUseColor()); + if (use_font_buffers) + { + mFontBufferPreSelection.render( + font, + text, start, + rect, + color, + LLFontGL::LEFT, mEditor.mTextVAlign, + LLFontGL::NORMAL, + mStyle->getShadowType(), + length, + &right_x, + mEditor.getUseEllipses(), + mEditor.getUseColor()); + } + else + { + // Font buffer doesn't do well with changes and huge notecard with a bunch + // of segments will see a lot of buffer updates, so instead use derect + // rendering to cache. + // Todo: instead of mLastGeneration make buffer invalidation more fine grained + // like string hash of a given segment. + font->render( + text, start, + rect, + color, + LLFontGL::LEFT, mEditor.mTextVAlign, + LLFontGL::NORMAL, + mStyle->getShadowType(), + length, + &right_x, + mEditor.getUseEllipses(), + mEditor.getUseColor()); + } } rect.mLeft = right_x; @@ -3359,16 +3452,35 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele S32 end = llmin( selection_end, seg_end ); S32 length = end - start; - font->render(text, start, - rect, - mStyle->getSelectedColor().get(), - LLFontGL::LEFT, mEditor.mTextVAlign, - LLFontGL::NORMAL, - LLFontGL::NO_SHADOW, - length, - &right_x, - mEditor.getUseEllipses(), - mEditor.getUseColor()); + if (use_font_buffers) + { + mFontBufferSelection.render( + font, + text, start, + rect, + mStyle->getSelectedColor().get(), + LLFontGL::LEFT, mEditor.mTextVAlign, + LLFontGL::NORMAL, + LLFontGL::NO_SHADOW, + length, + &right_x, + mEditor.getUseEllipses(), + mEditor.getUseColor()); + } + else + { + font->render( + text, start, + rect, + mStyle->getSelectedColor().get(), + LLFontGL::LEFT, mEditor.mTextVAlign, + LLFontGL::NORMAL, + LLFontGL::NO_SHADOW, + length, + &right_x, + mEditor.getUseEllipses(), + mEditor.getUseColor()); + } } rect.mLeft = right_x; if( selection_end < seg_end ) @@ -3377,16 +3489,36 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele S32 start = llmax( selection_end, seg_start ); S32 end = seg_end; S32 length = end - start; - font->render(text, start, - rect, - color, - LLFontGL::LEFT, mEditor.mTextVAlign, - LLFontGL::NORMAL, - mStyle->getShadowType(), - length, - &right_x, - mEditor.getUseEllipses(), - mEditor.getUseColor()); + if (use_font_buffers) + { + mFontBufferPostSelection.render( + font, + text, start, + rect, + color, + LLFontGL::LEFT, mEditor.mTextVAlign, + LLFontGL::NORMAL, + mStyle->getShadowType(), + length, + &right_x, + mEditor.getUseEllipses(), + mEditor.getUseColor()); + } + else + { + font->render( + text, start, + rect, + color, + LLFontGL::LEFT, mEditor.mTextVAlign, + LLFontGL::NORMAL, + mStyle->getShadowType(), + length, + &right_x, + mEditor.getUseEllipses(), + mEditor.getUseColor()); + + } } return right_x; } @@ -3488,6 +3620,13 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip) mTooltip = tooltip; } +// virtual +LLTextSegmentPtr LLNormalTextSegment::clone(LLTextBase& target) const +{ + LLStyleConstSP sp(cloneStyle(target, mStyle)); + return new LLNormalTextSegment(sp, mStart, mEnd, target); +} + bool LLNormalTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { height = 0; @@ -3573,6 +3712,15 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin return num_chars; } +void LLNormalTextSegment::updateLayout(const class LLTextBase& editor) +{ + LLTextSegment::updateLayout(editor); + + mFontBufferPreSelection.reset(); + mFontBufferSelection.reset(); + mFontBufferPostSelection.reset(); +} + void LLNormalTextSegment::dump() const { LL_INFOS() << "Segment [" << @@ -3606,6 +3754,13 @@ LLLabelTextSegment::LLLabelTextSegment( const LLUIColor& color, S32 start, S32 e { } +// virtual +LLTextSegmentPtr LLLabelTextSegment::clone(LLTextBase& target) const +{ + LLStyleConstSP sp(cloneStyle(target, mStyle)); + return new LLLabelTextSegment(sp, mStart, mEnd, target); +} + /*virtual*/ const LLWString& LLLabelTextSegment::getWText() const { @@ -3630,6 +3785,13 @@ LLEmojiTextSegment::LLEmojiTextSegment(const LLUIColor& color, S32 start, S32 en { } +// virtual +LLTextSegmentPtr LLEmojiTextSegment::clone(LLTextBase& target) const +{ + LLStyleConstSP sp(cloneStyle(target, mStyle)); + return new LLEmojiTextSegment(sp, mStart, mEnd, target); +} + bool LLEmojiTextSegment::handleToolTip(S32 x, S32 y, MASK mask) { if (mTooltip.empty()) @@ -3653,6 +3815,14 @@ LLOnHoverChangeableTextSegment::LLOnHoverChangeableTextSegment( LLStyleConstSP s mHoveredStyle(style), mNormalStyle(normal_style){} +// virtual +LLTextSegmentPtr LLOnHoverChangeableTextSegment::clone(LLTextBase& target) const +{ + LLStyleConstSP hsp(cloneStyle(target, mHoveredStyle)); + LLStyleConstSP nsp(cloneStyle(target, mNormalStyle)); + return new LLOnHoverChangeableTextSegment(hsp, nsp, mStart, mEnd, target); +} + /*virtual*/ F32 LLOnHoverChangeableTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect) { @@ -3692,6 +3862,13 @@ LLInlineViewSegment::~LLInlineViewSegment() mView->die(); } +// virtual +LLTextSegmentPtr LLInlineViewSegment::clone(LLTextBase& target) const +{ + llassert_always_msg(false, "NOT SUPPORTED"); + return nullptr; +} + bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { if (first_char == 0 && num_chars == 0) @@ -3779,6 +3956,14 @@ LLLineBreakTextSegment::LLLineBreakTextSegment(LLStyleConstSP style,S32 pos):LLT LLLineBreakTextSegment::~LLLineBreakTextSegment() { } + +// virtual +LLTextSegmentPtr LLLineBreakTextSegment::clone(LLTextBase& target) const +{ + LLLineBreakTextSegment* copy = new LLLineBreakTextSegment(mStart); + copy->mFontHeight = mFontHeight; + return copy; +} bool LLLineBreakTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { width = 0; @@ -3806,8 +3991,16 @@ LLImageTextSegment::~LLImageTextSegment() { } +// virtual +LLTextSegmentPtr LLImageTextSegment::clone(LLTextBase& target) const +{ + LLStyleConstSP sp(cloneStyle(target, mStyle)); + return new LLImageTextSegment(sp, mStart, target); +} + static const S32 IMAGE_HPAD = 3; +// virtual bool LLImageTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { width = 0; diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 00cf66b134..76d4e160af 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -30,6 +30,7 @@ #include "v4color.h" #include "lleditmenuhandler.h" +#include "llfontvertexbuffer.h" #include "llspellcheckmenuhandler.h" #include "llstyle.h" #include "llkeywords.h" @@ -44,6 +45,7 @@ class LLScrollContainer; class LLContextMenu; class LLUrlMatch; +class LLTextBase; /// /// A text segment is used to specify a subsection of a text string @@ -61,6 +63,9 @@ public: mEnd(end) {} virtual ~LLTextSegment(); + virtual LLTextSegmentPtr clone(LLTextBase& terget) const { return new LLTextSegment(mStart, mEnd); } + static LLStyleSP cloneStyle(LLTextBase& target, const LLStyle* source); + bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; virtual bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const; @@ -127,10 +132,12 @@ public: LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor ); LLNormalTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true); virtual ~LLNormalTextSegment(); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const; /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const; /*virtual*/ S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const; /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const; + /*virtual*/ void updateLayout(const class LLTextBase& editor); /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); /*virtual*/ bool canEdit() const { return true; } /*virtual*/ const LLUIColor& getColor() const { return mStyle->getColor(); } @@ -149,6 +156,7 @@ public: /*virtual*/ bool handleToolTip(S32 x, S32 y, MASK mask); protected: + virtual bool useFontBuffers() const { return true; } F32 drawClippedSegment(S32 seg_start, S32 seg_end, S32 selection_start, S32 selection_end, LLRectf rect); virtual const LLWString& getWText() const; @@ -161,6 +169,12 @@ protected: LLKeywordToken* mToken; std::string mTooltip; boost::signals2::connection mImageLoadedConnection; + + // font rendering + LLFontVertexBuffer mFontBufferPreSelection; + LLFontVertexBuffer mFontBufferSelection; + LLFontVertexBuffer mFontBufferPostSelection; + S32 mLastGeneration = -1; }; // This text segment is the same as LLNormalTextSegment, the only difference @@ -171,6 +185,7 @@ class LLLabelTextSegment : public LLNormalTextSegment public: LLLabelTextSegment( LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor ); LLLabelTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const; protected: @@ -185,6 +200,7 @@ class LLEmojiTextSegment : public LLNormalTextSegment public: LLEmojiTextSegment(LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor); LLEmojiTextSegment(const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const override; bool canEdit() const override { return false; } bool handleToolTip(S32 x, S32 y, MASK mask) override; @@ -195,6 +211,7 @@ class LLOnHoverChangeableTextSegment : public LLNormalTextSegment { public: LLOnHoverChangeableTextSegment( LLStyleConstSP style, LLStyleConstSP normal_style, S32 start, S32 end, LLTextBase& editor ); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const; /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask); protected: @@ -209,6 +226,7 @@ class LLIndexSegment : public LLTextSegment { public: LLIndexSegment() : LLTextSegment(0, 0) {} + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const { return new LLIndexSegment(); } }; class LLInlineViewSegment : public LLTextSegment @@ -226,6 +244,8 @@ public: LLInlineViewSegment(const Params& p, S32 start, S32 end); ~LLInlineViewSegment(); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const; + /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const; /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const; /*virtual*/ void updateLayout(const class LLTextBase& editor); @@ -250,6 +270,7 @@ public: LLLineBreakTextSegment(LLStyleConstSP style,S32 pos); LLLineBreakTextSegment(S32 pos); ~LLLineBreakTextSegment(); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const; /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const; S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const; F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); @@ -263,6 +284,8 @@ class LLImageTextSegment : public LLTextSegment public: LLImageTextSegment(LLStyleConstSP style,S32 pos,class LLTextBase& editor); ~LLImageTextSegment(); + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const; + /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const; S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 char_offset, S32 max_chars, S32 line_ind) const; F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect); @@ -432,6 +455,7 @@ public: // wide-char versions void setWText(const LLWString& text); const LLWString& getWText() const; + S32 getTextGeneration() const; void appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params = LLStyle::Params()); @@ -475,7 +499,7 @@ public: LLRect getDocRectFromDocIndex(S32 pos) const; void setReadOnly(bool read_only) { mReadOnly = read_only; } - bool getReadOnly() { return mReadOnly; } + bool getReadOnly() const { return mReadOnly; } void setSkipLinkUnderline(bool skip_link_underline) { mSkipLinkUnderline = skip_link_underline; } bool getSkipLinkUnderline() { return mSkipLinkUnderline; } @@ -500,6 +524,7 @@ public: const LLFontGL* getFont() const override { return mFont; } + virtual void copyContents(const LLTextBase* source); virtual void appendLineBreakSegment(const LLStyle::Params& style_params); virtual void appendImageSegment(const LLStyle::Params& style_params); virtual void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo); diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 0b5acf19a1..e9e7070414 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -271,6 +271,8 @@ protected: virtual bool getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const; virtual S32 getPreeditFontSize() const; virtual LLWString getPreeditString() const { return getWText(); } + + virtual bool useFontBuffers() const { return getReadOnly(); } // // Protected data // diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp index 8410031653..0c6c5b64e4 100644 --- a/indra/llui/lltrans.cpp +++ b/indra/llui/lltrans.cpp @@ -28,12 +28,8 @@ #include "lltrans.h" -#include "llfasttimer.h" // for call count statistics #include "llxuiparser.h" #include "llsd.h" -#include "llxmlnode.h" - -#include <map> LLTrans::template_map_t LLTrans::sStringTemplates; LLTrans::template_map_t LLTrans::sDefaultStringTemplates; @@ -59,7 +55,7 @@ struct StringTable : public LLInitParam::Block<StringTable> }; //static -bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& default_args) +bool LLTrans::parseStrings(LLXMLNodePtr& root, const std::set<std::string>& default_args) { std::string xml_filename = "(strings file)"; if (!root->hasName("strings")) @@ -107,7 +103,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa //static -bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) +bool LLTrans::parseLanguageStrings(LLXMLNodePtr& root) { std::string xml_filename = "(language strings file)"; if (!root->hasName("strings")) @@ -138,10 +134,6 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) return true; } - - -static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string"); - //static std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) { @@ -235,7 +227,7 @@ std::string LLTrans::getDefString(std::string_view xml_desc, const LLSD& msg_arg } //static -bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) +bool LLTrans::findString(std::string& result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -257,7 +249,7 @@ bool LLTrans::findString(std::string &result, std::string_view xml_desc, const L } //static -bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLSD& msg_args) +bool LLTrans::findString(std::string& result, std::string_view xml_desc, const LLSD& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -277,7 +269,7 @@ bool LLTrans::findString(std::string &result, std::string_view xml_desc, const L } //static -std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) +std::string LLTrans::getCountString(std::string_view language, std::string_view xml_desc, S32 count) { // Compute which string identifier to use const char* form = ""; @@ -337,7 +329,7 @@ std::string LLTrans::getCountString(const std::string& language, const std::stri args["[COUNT]"] = llformat("%d", count); // Look up "AgeYearsB" or "AgeWeeksC" including the "form" - std::string key = llformat("%s%s", xml_desc.c_str(), form); + std::string key = llformat("%s%s", xml_desc.data(), form); return getString(key, args); } diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 3492ed0169..c5d01e6f8d 100644 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -30,10 +30,8 @@ #include <map> #include <set> -#include "llpointer.h" #include "llstring.h" - -class LLXMLNode; +#include "llxmlnode.h" class LLSD; @@ -58,17 +56,17 @@ public: class LLTrans { public: - LLTrans(); + LLTrans() = default; /** * @brief Parses the xml root that holds the strings. Used once on startup -// *FIXME * @param xml_filename Filename to parse + * @param root xml root node to parse * @param default_args Set of strings (expected to be in the file) to use as default replacement args, e.g. "SECOND_LIFE" * @returns true if the file was parsed successfully, true if something went wrong */ - static bool parseStrings(LLPointer<LLXMLNode> & root, const std::set<std::string>& default_args); + static bool parseStrings(LLXMLNodePtr& root, const std::set<std::string>& default_args); - static bool parseLanguageStrings(LLPointer<LLXMLNode> & root); + static bool parseLanguageStrings(LLXMLNodePtr& root); /** * @brief Returns a translated string @@ -80,14 +78,14 @@ public: static std::string getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& args); static std::string getString(std::string_view xml_desc, const LLSD& args, bool def_string = false); static std::string getDefString(std::string_view xml_desc, const LLSD& args); - static bool findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& args); - static bool findString(std::string &result, std::string_view xml_desc, const LLSD& args); + static bool findString(std::string& result, std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static bool findString(std::string& result, std::string_view xml_desc, const LLSD& args); // Returns translated string with [COUNT] replaced with a number, following // special per-language logic for plural nouns. For example, some languages // may have different plurals for 0, 1, 2 and > 2. // See "AgeWeeksA", "AgeWeeksB", etc. in strings.xml for examples. - static std::string getCountString(const std::string& language, const std::string& xml_desc, S32 count); + static std::string getCountString(std::string_view language, std::string_view xml_desc, S32 count); /** * @brief Returns a translated string diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 79d2fcd049..3cc0c05ffa 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -600,15 +600,15 @@ void LLUrlEntryAgent::callObservers(const std::string &id, void LLUrlEntryAgent::onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name) { - avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id); - if (it != mAvatarNameCacheConnections.end()) + auto range = mAvatarNameCacheConnections.equal_range(id); + for (avatar_name_cache_connection_map_t::iterator it = range.first; it != range.second; ++it) { if (it->second.connected()) { it->second.disconnect(); } - mAvatarNameCacheConnections.erase(it); } + mAvatarNameCacheConnections.erase(range.first, range.second); std::string label = av_name.getCompleteName(); @@ -695,16 +695,7 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa } else { - avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(agent_id); - if (it != mAvatarNameCacheConnections.end()) - { - if (it->second.connected()) - { - it->second.disconnect(); - } - mAvatarNameCacheConnections.erase(it); - } - mAvatarNameCacheConnections[agent_id] = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2)); + mAvatarNameCacheConnections.emplace(agent_id, LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2))); addObserver(agent_id_string, url, cb); return LLTrans::getString("LoadingData"); @@ -770,17 +761,17 @@ LLUrlEntryAgentName::LLUrlEntryAgentName() {} void LLUrlEntryAgentName::onAvatarNameCache(const LLUUID& id, - const LLAvatarName& av_name) + const LLAvatarName& av_name) { - avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id); - if (it != mAvatarNameCacheConnections.end()) + auto range = mAvatarNameCacheConnections.equal_range(id); + for (avatar_name_cache_connection_map_t::iterator it = range.first; it != range.second; ++it) { if (it->second.connected()) { it->second.disconnect(); } - mAvatarNameCacheConnections.erase(it); } + mAvatarNameCacheConnections.erase(range.first, range.second); std::string label = getName(av_name); // received the agent name from the server - tell our observers @@ -815,16 +806,7 @@ std::string LLUrlEntryAgentName::getLabel(const std::string &url, const LLUrlLab } else { - avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(agent_id); - if (it != mAvatarNameCacheConnections.end()) - { - if (it->second.connected()) - { - it->second.disconnect(); - } - mAvatarNameCacheConnections.erase(it); - } - mAvatarNameCacheConnections[agent_id] = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2)); + mAvatarNameCacheConnections.emplace(agent_id, LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2))); addObserver(agent_id_string, url, cb); return LLTrans::getString("LoadingData"); diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 84ff278942..fffee88496 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -232,7 +232,7 @@ protected: private: void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name); - typedef std::map<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t; + typedef std::multimap<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t; avatar_name_cache_connection_map_t mAvatarNameCacheConnections; }; @@ -264,7 +264,7 @@ protected: private: void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name); - typedef std::map<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t; + typedef std::multimap<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t; avatar_name_cache_connection_map_t mAvatarNameCacheConnections; }; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 7d6c937b85..0206e46b57 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -1370,8 +1370,10 @@ void LLView::drawDebugRect() y = rect_height - LINE_HEIGHT * (depth % lines + 1); - std::string debug_text = llformat("%s (%d x %d)", getName().c_str(), - debug_rect.getWidth(), debug_rect.getHeight()); + std::string debug_text = llformat("%s [%d, %d] + (%d x %d) = [%d, %d]", getName().c_str(), + debug_rect.mLeft, mParentView->getRect().getHeight() - debug_rect.mTop, + debug_rect.getWidth(), debug_rect.getHeight(), + debug_rect.mRight, mParentView->getRect().getHeight() - debug_rect.mBottom); LLFontGL::getFontSansSerifSmall()->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color, LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); } diff --git a/indra/llui/llviewereventrecorder.cpp b/indra/llui/llviewereventrecorder.cpp index e5e0545dad..6d907d7e45 100644 --- a/indra/llui/llviewereventrecorder.cpp +++ b/indra/llui/llviewereventrecorder.cpp @@ -261,7 +261,7 @@ void LLViewerEventRecorder::logKeyUnicodeEvent(llwchar uni_char) { event.insert("event",LLSD("keyDown")); - LL_DEBUGS() << "[VITA] unicode key: " << uni_char << LL_ENDL; + LL_DEBUGS() << "[VITA] unicode key: " << (int)uni_char << LL_ENDL; LL_DEBUGS() << "[VITA] dumpxml " << LLSDXMLStreamer(event) << "\n" << LL_ENDL; diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index 93106b344f..35963c2b99 100644 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -82,11 +82,20 @@ void LLTextViewModel::setValue(const LLSD& value) // approximate LLSD storage usage LLViewModel::setValue(value); mDisplay = utf8str_to_wstring(mStringValue = value.asString()); + mDisplayGeneration++; // mDisplay and mValue agree mUpdateFromDisplay = false; } +LLWString& LLTextViewModel::getEditableDisplay() +{ + mDirty = true; + mDisplayGeneration++; + mUpdateFromDisplay = true; + return mDisplay; +} + void LLTextViewModel::setDisplay(const LLWString& value) { // This is the strange way to alter the value. Normally we'd setValue() @@ -94,6 +103,7 @@ void LLTextViewModel::setDisplay(const LLWString& value) // value. But a text editor might want to edit the display string // directly, then convert back to UTF8 on commit. mDisplay = value; + mDisplayGeneration++; mDirty = true; // Don't immediately convert to UTF8 -- do it lazily -- we expect many // more setDisplay() calls than getValue() calls. Just flag that it needs diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index 6cf2200a81..16b0800ce2 100644 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -105,7 +105,8 @@ public: // New functions /// Get the stored value in string form const LLWString& getDisplay() const { return mDisplay; } - LLWString& getEditableDisplay() { mDirty = true; mUpdateFromDisplay = true; return mDisplay; } + S32 getDisplayGeneration() const { return mDisplayGeneration; } + LLWString& getEditableDisplay(); /** * Set the display string directly (see LLTextEditor). What the user is @@ -120,6 +121,7 @@ private: /// To avoid converting every widget's stored value from LLSD to LLWString /// every frame, cache the converted value LLWString mDisplay; + S32 mDisplayGeneration = -1; /// As the user edits individual characters (setDisplay()), defer /// LLWString-to-UTF8 conversions until s/he's done. diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 55f97b33c5..075e17235a 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -17,6 +17,7 @@ include(LLImage) include(LLWindow) include(UI) include(ViewerMiscLibs) +include(GLM) set(llwindow_SOURCE_FILES llcursortypes.cpp @@ -54,7 +55,7 @@ set(llwindow_LINK_LIBRARIES llrender llfilesystem llxml - ll::glh_linear + ll::glm ll::glext ll::uilibraries ll::SDL diff --git a/indra/llwindow/lldragdropwin32.h b/indra/llwindow/lldragdropwin32.h index 1b30dced27..16d016677b 100644 --- a/indra/llwindow/lldragdropwin32.h +++ b/indra/llwindow/lldragdropwin32.h @@ -31,7 +31,7 @@ #ifndef LL_LLDRAGDROP32_H #define LL_LLDRAGDROP32_H -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <ole2.h> class LLDragDropWin32 @@ -54,7 +54,7 @@ class LLDragDropWin32 #ifndef LL_LLDRAGDROP32_H #define LL_LLDRAGDROP32_H -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <ole2.h> // impostor class that does nothing diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp index ec0055fe60..8d6b8d9b93 100644 --- a/indra/llwindow/llkeyboardwin32.cpp +++ b/indra/llwindow/llkeyboardwin32.cpp @@ -28,7 +28,7 @@ #include "linden_common.h" -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include "llkeyboardwin32.h" #include "llwindowcallbacks.h" diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 76788de876..a48bd35765 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1619,9 +1619,11 @@ const S32 max_format = (S32)num_formats - 1; } else { - LLError::LLUserWarningMsg::show(mCallbacks->translateString("MBVideoDrvErr")); - // mWindowHandle is 0, going to crash either way - LL_ERRS("Window") << "No wgl_ARB_pixel_format extension!" << LL_ENDL; + LL_WARNS("Window") << "No wgl_ARB_pixel_format extension!" << LL_ENDL; + // cannot proceed without wgl_ARB_pixel_format extension, shutdown same as any other gGLManager.initGL() failure + OSMessageBox(mCallbacks->translateString("MBVideoDrvErr"), mCallbacks->translateString("MBError"), OSMB_OK); + close(); + return false; } // Verify what pixel format we actually received. diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 287402faa0..36e89e4586 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -28,7 +28,7 @@ #define LL_LLWINDOWWIN32_H // Limit Windows API to small and manageable set. -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include "llwindow.h" #include "llwindowcallbacks.h" diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7d2cea8371..ff18a5a899 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -33,6 +33,7 @@ include(NVAPI) include(OPENAL) include(OpenGL) include(OpenSSL) +include(OpenXR) include(PNG) include(TemplateCheck) include(TinyEXR) @@ -1927,6 +1928,7 @@ target_link_libraries(${VIEWER_BINARY_NAME} ${LLPHYSICSEXTENSIONS_LIBRARIES} ll::bugsplat ll::tracy + ll::openxr ) if( TARGET ll::intel_memops ) diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt index e0eaaa0bbc..0f9f025fe4 100644 --- a/indra/newview/VIEWER_VERSION.txt +++ b/indra/newview/VIEWER_VERSION.txt @@ -1 +1 @@ -7.1.11 +7.1.12 diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 72c0888644..abf7e18a5a 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -13433,6 +13433,17 @@ <key>Value</key> <integer>4</integer> </map> + <key>VoiceVisualizerEnabled</key> + <map> + <key>Comment</key> + <string>Display voice dot indicator above an avatar</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>WarningsAsChat</key> <map> <key>Comment</key> diff --git a/indra/newview/character/avatar_lad.xml b/indra/newview/character/avatar_lad.xml index 2cdd86267e..90dc361a5c 100644 --- a/indra/newview/character/avatar_lad.xml +++ b/indra/newview/character/avatar_lad.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="US-ASCII" standalone="yes"?> +<?xml version="1.0" encoding="us-ascii" standalone="yes"?> <linden_avatar version="2.0" wearable_definition_version="22"> <!-- The wearable_definition_version is checked during asset upload. --> @@ -8923,8 +8923,8 @@ <!-- =========================================================== --> <layer_set body_region="hair" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer name="base" @@ -9013,8 +9013,8 @@ <layer_set body_region="head" - width="512" - height="512"> + width="2048" + height="2048"> <layer name="head bump base" fixed_color = "128,128,128,255" @@ -10149,8 +10149,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="upper_body" - width="512" - height="512"> + width="2048" + height="2048"> <layer name="base_upperbody bump" render_pass="bump" @@ -11458,8 +11458,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="lower_body" - width="512" - height="512"> + width="2048" + height="2048"> <layer name="lower body bump base" fixed_color = "128,128,128,255" @@ -12448,8 +12448,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="eyes" - width="128" - height="128"> + width="512" + height="512"> <layer name="whites"> <texture @@ -12535,8 +12535,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="skirt" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer name="skirt_fabric" @@ -12774,8 +12774,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="leftarm" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer name="base" @@ -12850,8 +12850,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="leftleg" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer name="base" @@ -12925,8 +12925,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="aux1" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer @@ -13002,8 +13002,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="aux2" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer @@ -13079,8 +13079,8 @@ render_pass="bump"> <!-- =========================================================== --> <layer_set body_region="aux3" - width="512" - height="512" + width="2048" + height="2048" clear_alpha="false"> <layer diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 2e220d2b1c..06ad730a40 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 60 +version 61 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -68,7 +68,8 @@ RenderFSAASamples 1 3 RenderMaxTextureIndex 1 16 RenderGLContextCoreProfile 1 1 RenderGLMultiThreadedTextures 1 0 -RenderGLMultiThreadedMedia 1 0 +RenderGLMultiThreadedMedia 1 1 +RenderAppleUseMultGL 1 1 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 2 RenderScreenSpaceReflections 1 1 @@ -381,6 +382,15 @@ list Intel RenderAnisotropic 1 0 RenderFSAASamples 1 0 +// AppleGPU and NonAppleGPU can be thought of as Apple silicon vs Intel Mac +list AppleGPU +RenderGLMultiThreadedMedia 1 1 +RenderAppleUseMultGL 1 1 + +list NonAppleGPU +RenderGLMultiThreadedMedia 1 0 +RenderAppleUseMultGL 1 0 + list GL3 RenderFSAASamples 0 0 RenderReflectionProbeDetail 0 0 diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index e55d630940..ed66753267 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -371,43 +371,46 @@ void GLTFSceneManager::addGLTFObject(LLViewerObject* obj, LLUUID gltf_id) //static void GLTFSceneManager::onGLTFBinLoadComplete(const LLUUID& id, LLAssetType::EType asset_type, void* user_data, S32 status, LLExtStat ext_status) { - LLViewerObject* obj = (LLViewerObject*)user_data; - llassert(asset_type == LLAssetType::AT_GLTF_BIN); - - if (status == LL_ERR_NOERR) - { - if (obj) + LLAppViewer::instance()->postToMainCoro([=]() { - // find the Buffer with the given id in the asset - if (obj->mGLTFAsset) - { - obj->mGLTFAsset->mPendingBuffers--; - + LLViewerObject* obj = (LLViewerObject*)user_data; + llassert(asset_type == LLAssetType::AT_GLTF_BIN); - if (obj->mGLTFAsset->mPendingBuffers == 0) + if (status == LL_ERR_NOERR) + { + if (obj) { - if (obj->mGLTFAsset->prep()) + // find the Buffer with the given id in the asset + if (obj->mGLTFAsset) { - GLTFSceneManager& mgr = GLTFSceneManager::instance(); - if (std::find(mgr.mObjects.begin(), mgr.mObjects.end(), obj) == mgr.mObjects.end()) + obj->mGLTFAsset->mPendingBuffers--; + + + if (obj->mGLTFAsset->mPendingBuffers == 0) { - GLTFSceneManager::instance().mObjects.push_back(obj); + if (obj->mGLTFAsset->prep()) + { + GLTFSceneManager& mgr = GLTFSceneManager::instance(); + if (std::find(mgr.mObjects.begin(), mgr.mObjects.end(), obj) == mgr.mObjects.end()) + { + GLTFSceneManager::instance().mObjects.push_back(obj); + } + } + else + { + LL_WARNS("GLTF") << "Failed to prepare GLTF asset: " << id << LL_ENDL; + obj->mGLTFAsset = nullptr; + } } } - else - { - LL_WARNS("GLTF") << "Failed to prepare GLTF asset: " << id << LL_ENDL; - obj->mGLTFAsset = nullptr; - } } } - } - } - else - { - LL_WARNS("GLTF") << "Failed to load GLTF asset: " << id << LL_ENDL; - obj->unref(); - } + else + { + LL_WARNS("GLTF") << "Failed to load GLTF asset: " << id << LL_ENDL; + obj->unref(); + } + }); } //static @@ -807,10 +810,10 @@ void GLTFSceneManager::bind(Asset& asset, Material& material) LLMatrix4a inverse(const LLMatrix4a& mat) { - glh::matrix4f m((F32*)mat.mMatrix); - m = m.inverse(); + glm::mat4 m = glm::make_mat4((F32*)mat.mMatrix); + m = glm::inverse(m); LLMatrix4a ret; - ret.loadu(m.m); + ret.loadu(glm::value_ptr(m)); return ret; } diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index c4336758ac..c8b0adbaf8 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -355,6 +355,20 @@ bool LLAgent::isMicrophoneOn(const LLSD& sdname) return LLVoiceClient::getInstance()->getUserPTTState(); } +//static +void LLAgent::toggleHearMediaSoundFromAvatar() +{ + const S32 mediaSoundsEarLocation = gSavedSettings.getS32("MediaSoundsEarLocation"); + gSavedSettings.setS32("MediaSoundsEarLocation", !mediaSoundsEarLocation); +} + +//static +void LLAgent::toggleHearVoiceFromAvatar() +{ + const S32 voiceEarLocation = gSavedSettings.getS32("VoiceEarLocation"); + gSavedSettings.setS32("VoiceEarLocation", !voiceEarLocation); +} + // ************************************************************ // Enabled this definition to compile a 'hacked' viewer that // locally believes the end user has godlike powers. @@ -425,8 +439,6 @@ LLAgent::LLAgent() : mIsDoNotDisturb(false), mControlFlags(0x00000000), - mbFlagsDirty(false), - mbFlagsNeedReset(false), mAutoPilot(false), mAutoPilotFlyOnStop(false), @@ -922,8 +934,6 @@ void LLAgent::setFlying(bool fly, bool fail_sound) // Update Movement Controls according to Fly mode LLFloaterMove::setFlyingMode(fly); - - mbFlagsDirty = true; } @@ -1054,7 +1064,6 @@ void LLAgent::setRegion(LLViewerRegion *regionp) { regionp->setCapabilitiesReceivedCallback(LLAgent::capabilityReceivedCallback); } - } else { @@ -1542,7 +1551,6 @@ U32 LLAgent::getControlFlags() void LLAgent::setControlFlags(U32 mask) { mControlFlags |= mask; - mbFlagsDirty = true; } @@ -1551,28 +1559,7 @@ void LLAgent::setControlFlags(U32 mask) //----------------------------------------------------------------------------- void LLAgent::clearControlFlags(U32 mask) { - U32 old_flags = mControlFlags; mControlFlags &= ~mask; - if (old_flags != mControlFlags) - { - mbFlagsDirty = true; - } -} - -//----------------------------------------------------------------------------- -// controlFlagsDirty() -//----------------------------------------------------------------------------- -bool LLAgent::controlFlagsDirty() const -{ - return mbFlagsDirty; -} - -//----------------------------------------------------------------------------- -// enableControlFlagReset() -//----------------------------------------------------------------------------- -void LLAgent::enableControlFlagReset() -{ - mbFlagsNeedReset = true; } //----------------------------------------------------------------------------- @@ -1580,14 +1567,9 @@ void LLAgent::enableControlFlagReset() //----------------------------------------------------------------------------- void LLAgent::resetControlFlags() { - if (mbFlagsNeedReset) - { - mbFlagsNeedReset = false; - mbFlagsDirty = false; - // reset all of the ephemeral flags - // some flags are managed elsewhere - mControlFlags &= AGENT_CONTROL_AWAY | AGENT_CONTROL_FLY | AGENT_CONTROL_MOUSELOOK; - } + // reset all of the ephemeral flags + // some flags are managed elsewhere + mControlFlags &= AGENT_CONTROL_AWAY | AGENT_CONTROL_FLY | AGENT_CONTROL_MOUSELOOK; } //----------------------------------------------------------------------------- @@ -2071,11 +2053,19 @@ void LLAgent::propagate(const F32 dt) } // handle rotation based on keyboard levels - const F32 YAW_RATE = 90.f * DEG_TO_RAD; // radians per second - yaw(YAW_RATE * gAgentCamera.getYawKey() * dt); + constexpr F32 YAW_RATE = 90.f * DEG_TO_RAD; // radians per second + F32 angle = YAW_RATE * gAgentCamera.getYawKey() * dt; + if (fabs(angle) > 0.0f) + { + yaw(angle); + } - const F32 PITCH_RATE = 90.f * DEG_TO_RAD; // radians per second - pitch(PITCH_RATE * gAgentCamera.getPitchKey() * dt); + constexpr F32 PITCH_RATE = 90.f * DEG_TO_RAD; // radians per second + angle = PITCH_RATE * gAgentCamera.getPitchKey() * dt; + if (fabs(angle) > 0.0f) + { + pitch(angle); + } // handle auto-land behavior if (isAgentAvatarValid()) diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 8f892025c9..afc34f747f 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -375,6 +375,13 @@ private: bool mVoiceConnected; //-------------------------------------------------------------------- + // Sound + //-------------------------------------------------------------------- +public: + static void toggleHearMediaSoundFromAvatar(); + static void toggleHearVoiceFromAvatar(); + + //-------------------------------------------------------------------- // Chat //-------------------------------------------------------------------- public: @@ -475,21 +482,17 @@ public: void setControlFlags(U32 mask); // Performs bitwise mControlFlags |= mask void clearControlFlags(U32 mask); // Performs bitwise mControlFlags &= ~mask bool controlFlagsDirty() const; - void enableControlFlagReset(); void resetControlFlags(); bool anyControlGrabbed() const; // True iff a script has taken over a control bool isControlGrabbed(S32 control_index) const; // Send message to simulator to force grabbed controls to be // released, in case of a poorly written script. void forceReleaseControls(); - void setFlagsDirty() { mbFlagsDirty = true; } private: S32 mControlsTakenCount[TOTAL_CONTROLS]; S32 mControlsTakenPassedOnCount[TOTAL_CONTROLS]; U32 mControlFlags; // Replacement for the mFooKey's - bool mbFlagsDirty; - bool mbFlagsNeedReset; // ! HACK ! For preventing incorrect flags sent when crossing region boundaries //-------------------------------------------------------------------- // Animations diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index e7531f963b..81e79a2ed9 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2204,10 +2204,6 @@ void LLAgentCamera::changeCameraToMouselook(bool animate) mCameraMode = CAMERA_MODE_MOUSELOOK; const U32 old_flags = gAgent.getControlFlags(); gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != gAgent.getControlFlags()) - { - gAgent.setFlagsDirty(); - } if (animate) { diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index f204bdf0eb..ffd333dd33 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -642,8 +642,6 @@ LLAppViewer::LLAppViewer() mQuitRequested(false), mClosingFloaters(false), mLogoutRequestSent(false), - mLastAgentControlFlags(0), - mLastAgentForceUpdate(0), mMainloopTimeout(NULL), mAgentRegionLastAlive(false), mRandomizeFramerate(LLCachedControl<bool>(gSavedSettings,"Randomize Framerate", false)), @@ -3295,10 +3293,10 @@ LLSD LLAppViewer::getViewerInfo() const LLVector3d pos = gAgent.getPositionGlobal(); info["POSITION"] = ll_sd_from_vector3d(pos); info["POSITION_LOCAL"] = ll_sd_from_vector3(gAgent.getPosAgentFromGlobal(pos)); - info["REGION"] = gAgent.getRegion()->getName(); + info["REGION"] = region->getName(); boost::regex regex("\\.(secondlife|lindenlab)\\..*"); - info["HOSTNAME"] = boost::regex_replace(gAgent.getRegion()->getSimHostName(), regex, ""); + info["HOSTNAME"] = boost::regex_replace(region->getSimHostName(), regex, ""); info["SERVER_VERSION"] = gLastVersionChannel; LLSLURL slurl; LLAgentUI::buildSLURL(slurl); @@ -4719,30 +4717,13 @@ void LLAppViewer::idle() gAgent.autoPilot(&yaw); } - static LLFrameTimer agent_update_timer; - - // When appropriate, update agent location to the simulator. - F32 agent_update_time = agent_update_timer.getElapsedTimeF32(); - F32 agent_force_update_time = mLastAgentForceUpdate + agent_update_time; - bool timed_out = agent_update_time > (1.0f / (F32)AGENT_UPDATES_PER_SECOND); - bool force_send = - // if there is something to send - (gAgent.controlFlagsDirty() && timed_out) - // if something changed - || (mLastAgentControlFlags != gAgent.getControlFlags()) - // keep alive - || (agent_force_update_time > (1.0f / (F32) AGENT_FORCE_UPDATES_PER_SECOND)); - // timing out doesn't warranty that an update will be sent, - // just that it will be checked. - if (force_send || timed_out) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; - // Send avatar and camera info - mLastAgentControlFlags = gAgent.getControlFlags(); - mLastAgentForceUpdate = force_send ? 0 : agent_force_update_time; - send_agent_update(force_send); - agent_update_timer.reset(); - } + send_agent_update(false); + + // After calling send_agent_update() in the mainloop we always clear + // the agent's ephemeral ControlFlags (whether an AgentUpdate was + // actually sent or not) because these will be recomputed based on + // real-time key/controller input and resubmitted next frame. + gAgent.resetControlFlags(); } ////////////////////////////////////// @@ -5354,11 +5335,6 @@ void LLAppViewer::idleNetwork() } #endif - - - // we want to clear the control after sending out all necessary agent updates - gAgent.resetControlFlags(); - // Decode enqueued messages... S32 remaining_possible_decodes = MESSAGE_MAX_PER_FRAME - total_decoded; diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 7b456cc542..4ce4259ed8 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -322,8 +322,6 @@ private: bool mQuitRequested; // User wants to quit, may have modified documents open. bool mClosingFloaters; bool mLogoutRequestSent; // Disconnect message sent to simulator, no longer safe to send messages to the sim. - U32 mLastAgentControlFlags; - F32 mLastAgentForceUpdate; struct SettingsFiles* mSettingsLocationList; LLWatchdogTimeout* mMainloopTimeout; @@ -341,10 +339,6 @@ private: bool mIsFirstRun; }; -// consts from viewer.h -const S32 AGENT_UPDATES_PER_SECOND = 125; // Value derived experimentally to avoid Input Delays with latest PBR-Capable Viewers when viewer FPS is highly volatile. -const S32 AGENT_FORCE_UPDATES_PER_SECOND = 1; - // Globals with external linkage. From viewer.h // *NOTE:Mani - These will be removed as the Viewer App Cleanup project continues. // diff --git a/indra/newview/llattachmentsmgr.cpp b/indra/newview/llattachmentsmgr.cpp index deabcd9f42..8b5db2c0fa 100644 --- a/indra/newview/llattachmentsmgr.cpp +++ b/indra/newview/llattachmentsmgr.cpp @@ -465,7 +465,7 @@ bool LLAttachmentsMgr::isAttachmentStateComplete() const // void LLAttachmentsMgr::checkInvalidCOFLinks() { - if (!gInventory.isInventoryUsable()) + if (!gInventory.isInventoryUsable() || mQuestionableCOFLinks.empty()) { return; } diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 038030a1f6..6f6b89ea81 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -242,10 +242,7 @@ static void on_avatar_name_cache_start_call(const LLUUID& agent_id, { std::string name = av_name.getDisplayName(); LLUUID session_id = gIMMgr->addSession(name, IM_NOTHING_SPECIAL, agent_id, LLSD()); - if (session_id != LLUUID::null) - { - gIMMgr->startCall(session_id); - } + gIMMgr->autoStartCallOnStartup(session_id); make_ui_sound("UISndStartIM"); } diff --git a/indra/newview/llbox.cpp b/indra/newview/llbox.cpp index dd12a02907..d0787a3902 100644 --- a/indra/newview/llbox.cpp +++ b/indra/newview/llbox.cpp @@ -76,16 +76,23 @@ void LLBox::renderface(S32 which_face) {7, 4, 0, 3} }; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { //gGL.normal3fv(&normals[which_face][0]); - gGL.texCoord2f(1,0); - gGL.vertex3fv(&mVertex[ faces[which_face][0] ][0]); - gGL.texCoord2f(1,1); - gGL.vertex3fv(&mVertex[ faces[which_face][1] ][0]); - gGL.texCoord2f(0,1); - gGL.vertex3fv(&mVertex[ faces[which_face][2] ][0]); - gGL.texCoord2f(0,0); - gGL.vertex3fv(&mVertex[ faces[which_face][3] ][0]); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3fv(&mVertex[faces[which_face][0]][0]); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex3fv(&mVertex[faces[which_face][1]][0]); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3fv(&mVertex[faces[which_face][2]][0]); + + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3fv(&mVertex[faces[which_face][0]][0]); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3fv(&mVertex[faces[which_face][2]][0]); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex3fv(&mVertex[faces[which_face][3]][0]); + } gGL.end(); } diff --git a/indra/newview/llchatmsgbox.cpp b/indra/newview/llchatmsgbox.cpp index b70b3eac95..eacbb4366d 100644 --- a/indra/newview/llchatmsgbox.cpp +++ b/indra/newview/llchatmsgbox.cpp @@ -41,6 +41,16 @@ public: mEditor(NULL) {} + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const + { + ChatSeparator* copy = new ChatSeparator(mStart, mEnd); + if (mEditor) + { + copy->mEditor = ⌖ + } + return copy; + } + /*virtual*/ void linkToDocument(class LLTextBase* editor) { mEditor = editor; diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp index b19b6f8dec..a1f627c8cc 100644 --- a/indra/newview/llconversationview.cpp +++ b/indra/newview/llconversationview.cpp @@ -313,7 +313,7 @@ void LLConversationViewSession::draw() { // update the rotation angle of open folder arrow updateLabelRotation(); - drawOpenFolderArrow(default_params, sFgColor); + drawOpenFolderArrow(); } LLView::draw(); } diff --git a/indra/newview/lldeferredsounds.cpp b/indra/newview/lldeferredsounds.cpp index 8b7c399af1..44f51545dc 100644 --- a/indra/newview/lldeferredsounds.cpp +++ b/indra/newview/lldeferredsounds.cpp @@ -29,8 +29,6 @@ #include "lldeferredsounds.h" -#include "llaudioengine.h" - void LLDeferredSounds::deferSound(SoundData& sound) { soundVector.push_back(sound); diff --git a/indra/newview/lldeferredsounds.h b/indra/newview/lldeferredsounds.h index e586226184..9f3425fc66 100644 --- a/indra/newview/lldeferredsounds.h +++ b/indra/newview/lldeferredsounds.h @@ -28,8 +28,7 @@ #define LL_LLDEFERREDSOUNDS_H #include "llsingleton.h" - -struct SoundData; +#include "llaudioengine.h" class LLDeferredSounds : public LLSingleton<LLDeferredSounds> { diff --git a/indra/newview/lldirpicker.cpp b/indra/newview/lldirpicker.cpp index 1d996b8c93..51157fa430 100644 --- a/indra/newview/lldirpicker.cpp +++ b/indra/newview/lldirpicker.cpp @@ -35,7 +35,7 @@ #include "lltrans.h" #include "llwindow.h" // beforeDialog() #include "llviewercontrol.h" -#include "llwin32headerslean.h" +#include "llwin32headers.h" #if LL_LINUX || LL_DARWIN # include "llfilepicker.h" diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index ae48db24bc..70ae4ee13f 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1067,16 +1067,16 @@ F32 LLDrawable::getVisibilityRadius() const { return 0.f; } - else if (isLight()) + + if (isLight()) { - const LLVOVolume *vov = getVOVolume(); - if (vov) + if (const LLVOVolume* vov = getVOVolume()) { return llmax(getRadius(), vov->getLightRadius()); - } else { - // LL_WARNS() ? } + // LL_WARNS() ? } + return getRadius(); } @@ -1089,16 +1089,14 @@ bool LLDrawable::isVisible() const { if (LLViewerOctreeEntryData::isVisible()) { - return true; + return true; } + LLViewerOctreeGroup* group = mEntry->getGroup(); + if (group && group->isVisible()) { - LLViewerOctreeGroup* group = mEntry->getGroup(); - if (group && group->isVisible()) - { - LLViewerOctreeEntryData::setVisible(); - return true; - } + LLViewerOctreeEntryData::setVisible(); + return true; } return false; @@ -1107,27 +1105,30 @@ bool LLDrawable::isVisible() const //virtual bool LLDrawable::isRecentlyVisible() const { - //currently visible or visible in the previous frame. - bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); + // Currently visible or visible in the previous frame. + if (LLViewerOctreeEntryData::isRecentlyVisible()) + { + return true; + } - if(!vis) + const U32 MIN_VIS_FRAME_RANGE = 2 ; // Two frames: the current one and the last one. + if (sCurVisible - getVisible() < MIN_VIS_FRAME_RANGE) { - const U32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one. - vis = (sCurVisible - getVisible() < MIN_VIS_FRAME_RANGE); + return true; } - return vis ; + return false; } void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) - { +{ LLSpatialGroup* cur_groupp = (LLSpatialGroup*)getGroup(); //precondition: mGroupp MUST be null or DEAD or mGroupp MUST NOT contain this //llassert(!cur_groupp || cur_groupp->isDead() || !cur_groupp->hasElement(this)); //precondition: groupp MUST be null or groupp MUST contain this - llassert(!groupp || (LLSpatialGroup*)groupp->hasElement(this)); + llassert(!groupp || groupp->hasElement(this)); if (cur_groupp != groupp && getVOVolume()) { @@ -1136,8 +1137,7 @@ void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) //contained by its drawable's spatial group for (S32 i = 0; i < getNumFaces(); ++i) { - LLFace* facep = getFace(i); - if (facep) + if (LLFace* facep = getFace(i)) { facep->clearVertexBuffer(); } @@ -1166,7 +1166,7 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() !getVOVolume() || isStatic()) { - retval = gPipeline.getSpatialPartition((LLViewerObject*)mVObjp); + retval = gPipeline.getSpatialPartition(mVObjp); } else if (isRoot()) { @@ -1274,13 +1274,12 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, bool render_by_group, U32 dat LLSpatialBridge::~LLSpatialBridge() { - if(mEntry) + if (mEntry) { - LLSpatialGroup* group = getSpatialGroup(); - if (group) - { - group->getSpatialPartition()->remove(this, group); - } + if (LLSpatialGroup* group = getSpatialGroup()) + { + group->getSpatialPartition()->remove(this, group); + } } //delete octree here so listeners will still be able to access bridge specific state diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index b4d14e22f3..87b6ce6cb3 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -757,7 +757,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (current_shader) { - current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, spec_color.mV[0], spec_color.mV[1], spec_color.mV[2], spec_color.mV[3]); + current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, spec_color.mV[VRED], spec_color.mV[VGREEN], spec_color.mV[VBLUE], spec_color.mV[VALPHA]); current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, env_intensity); current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, brightness); } diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index fe6cd4e37d..33325e352f 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -191,44 +191,42 @@ bool LLViewerDynamicTexture::updateAllInstances() return true; } - LLRenderTarget& bake_target = gPipeline.mAuxillaryRT.deferredScreen; - - if (!bake_target.isComplete()) + LLRenderTarget& preview_target = gPipeline.mAuxillaryRT.deferredScreen; + LLRenderTarget& bake_target = gPipeline.mBakeMap; + if (!preview_target.isComplete() || !bake_target.isComplete()) { llassert(false); return false; } - llassert(bake_target.getWidth() >= LLPipeline::MAX_BAKE_WIDTH); - llassert(bake_target.getHeight() >= LLPipeline::MAX_BAKE_WIDTH); + llassert(preview_target.getWidth() >= LLPipeline::MAX_PREVIEW_WIDTH); + llassert(preview_target.getHeight() >= LLPipeline::MAX_PREVIEW_WIDTH); + llassert(bake_target.getWidth() >= (U32) LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH); + llassert(bake_target.getHeight() >= (U32) LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT); - bake_target.bindTarget(); - bake_target.clear(); + preview_target.bindTarget(); + preview_target.clear(); LLGLSLShader::unbind(); LLVertexBuffer::unbind(); bool result = false; bool ret = false ; - for( S32 order = 0; order < ORDER_COUNT; order++ ) - { - for (instance_list_t::iterator iter = LLViewerDynamicTexture::sInstances[order].begin(); - iter != LLViewerDynamicTexture::sInstances[order].end(); ++iter) + auto update_func = [&](LLViewerDynamicTexture* dynamicTexture, LLRenderTarget& renderTarget, S32 width, S32 height) { - LLViewerDynamicTexture *dynamicTexture = *iter; if (dynamicTexture->needsRender()) { - llassert(dynamicTexture->getFullWidth() <= S32(LLPipeline::MAX_BAKE_WIDTH)); - llassert(dynamicTexture->getFullHeight() <= S32(LLPipeline::MAX_BAKE_WIDTH)); + llassert(dynamicTexture->getFullWidth() <= width); + llassert(dynamicTexture->getFullHeight() <= height); glClear(GL_DEPTH_BUFFER_BIT); - gGL.color4f(1,1,1,1); - dynamicTexture->setBoundTarget(&bake_target); + gGL.color4f(1.f, 1.f, 1.f, 1.f); + dynamicTexture->setBoundTarget(&renderTarget); dynamicTexture->preRender(); // Must be called outside of startRender() result = false; if (dynamicTexture->render()) { - ret = true ; + ret = true; result = true; sNumRenders++; } @@ -237,9 +235,31 @@ bool LLViewerDynamicTexture::updateAllInstances() dynamicTexture->setBoundTarget(nullptr); dynamicTexture->postRender(result); } + }; + + // ORDER_FIRST is unused, ORDER_MIDDLE is various ui preview + for(S32 order = 0; order < ORDER_LAST; ++order) + { + for (LLViewerDynamicTexture* dynamicTexture : LLViewerDynamicTexture::sInstances[order]) + { + update_func(dynamicTexture, preview_target, LLPipeline::MAX_PREVIEW_WIDTH, LLPipeline::MAX_PREVIEW_WIDTH); } } + preview_target.flush(); + + // ORDER_LAST is baked skin preview, ORDER_RESET resets appearance parameters and does not render. + bake_target.bindTarget(); + bake_target.clear(); + result = false; + ret = false; + for (S32 order = ORDER_LAST; order < ORDER_COUNT; ++order) + { + for (LLViewerDynamicTexture* dynamicTexture : LLViewerDynamicTexture::sInstances[order]) + { + update_func(dynamicTexture, bake_target, LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH, LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT); + } + } bake_target.flush(); gGL.flush(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 0b4630dfc3..05bd704556 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -453,11 +453,11 @@ namespace void applyInjections(LLSettingsBase::Seconds delta) { - this->mSettings = this->mSource->getSettings(); + LLSD settings = this->mSource->cloneSettings(); for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) { - this->mSettings[(*ito).first] = (*ito).second; + settings[(*ito).first] = (*ito).second; } const LLSettingsBase::stringset_t &slerps = this->getSlerpKeys(); @@ -469,7 +469,7 @@ namespace { std::string key_name = (*it)->mKeyName; - LLSD value = this->mSettings[key_name]; + LLSD value = settings[key_name]; LLSD target = (*it)->mValue; if ((*it)->mFirstTime) @@ -485,11 +485,11 @@ namespace { mOverrideValues[key_name] = target; mOverrideExps[key_name] = (*it)->mExperience; - this->mSettings[key_name] = target; + settings[key_name] = target; } else { - this->mSettings.erase(key_name); + settings.erase(key_name); } } else if (specials.find(key_name) != specials.end()) @@ -500,8 +500,8 @@ namespace { if (!(*it)->mBlendIn) mix = 1.0 - mix; - (*it)->mLastValue = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); - this->mSettings[key_name] = (*it)->mLastValue; + (*it)->mLastValue = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, skips, slerps); + settings[key_name] = (*it)->mLastValue; } } @@ -520,7 +520,7 @@ namespace { mInjections.erase(mInjections.begin(), mInjections.end()); } - + this->setSettings(settings); } bool hasInjections() const @@ -685,7 +685,8 @@ namespace if (!injection->mBlendIn) mix = 1.0 - mix; stringset_t dummy; - F64 value = this->mSettings[injection->mKeyName].asReal(); + LLSD settings = this->cloneSettings(); + F64 value = settings[injection->mKeyName].asReal(); if (this->getCloudNoiseTextureId().isNull()) { value = 0; // there was no texture so start from zero coverage @@ -695,7 +696,8 @@ namespace // with different transitions, don't ignore it F64 result = lerp((F32)value, (F32)injection->mValue.asReal(), (F32)mix); injection->mLastValue = LLSD::Real(result); - this->mSettings[injection->mKeyName] = injection->mLastValue; + settings[injection->mKeyName] = injection->mLastValue; + this->setSettings(settings); } // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. @@ -1740,90 +1742,9 @@ void LLEnvironment::updateGLVariablesForSettings(LLShaderUniforms* uniforms, con { uniforms[i].clear(); } - - LLShaderUniforms* shader = &uniforms[LLGLSLShader::SG_ANY]; - //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; - LLSettingsBase::parammapping_t params = psetting->getParameterMap(); - for (auto &it: params) - { - LLSD value; - // legacy first since it contains ambient color and we prioritize value from legacy, see getAmbientColor() - if (psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first)) - { - value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; - } - else if (psetting->mSettings.has(it.first)) - { - value = psetting->mSettings[it.first]; - } - else - { - // We need to reset shaders, use defaults - value = it.second.getDefaultValue(); - } - - LLSD::Type setting_type = value.type(); - stop_glerror(); - switch (setting_type) - { - case LLSD::TypeInteger: - shader->uniform1i(it.second.getShaderKey(), value.asInteger()); - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; - break; - case LLSD::TypeReal: - shader->uniform1f(it.second.getShaderKey(), (F32)value.asReal()); - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; - break; - - case LLSD::TypeBoolean: - shader->uniform1i(it.second.getShaderKey(), value.asBoolean() ? 1 : 0); - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; - break; - - case LLSD::TypeArray: - { - LLVector4 vect4(value); - // always identify as a radiance pass if desaturating irradiance is disabled - static LLCachedControl<bool> desaturate_irradiance(gSavedSettings, "RenderDesaturateIrradiance", true); - - if (desaturate_irradiance && gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass()) - { // maximize and remove tinting if this is an irradiance map render pass and the parameter feeds into the sky background color - auto max_vec = [](LLVector4 col) - { - LLColor3 color(col); - F32 h, s, l; - color.calcHSL(&h, &s, &l); - - col.mV[0] = col.mV[1] = col.mV[2] = l; - return col; - }; - - switch (it.second.getShaderKey()) - { - case LLShaderMgr::BLUE_HORIZON: - case LLShaderMgr::BLUE_DENSITY: - vect4 = max_vec(vect4); - break; - } - } - - //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform3fv(it.second.getShaderKey(), LLVector3(vect4.mV) ); - break; - } - - // case LLSD::TypeMap: - // case LLSD::TypeString: - // case LLSD::TypeUUID: - // case LLSD::TypeURI: - // case LLSD::TypeBinary: - // case LLSD::TypeDate: - default: - break; - } - } //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + psetting->applyToUniforms(uniforms); psetting->applySpecial(uniforms); } diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index 748e10160c..5c46eb9d80 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -44,6 +44,14 @@ public: mExpanderLabel(utf8str_to_wstring(more_text)) {} + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const + { + LLStyleSP sp(cloneStyle(target, mStyle)); + LLExpanderSegment* copy = new LLExpanderSegment(sp, mStart, mEnd, LLStringUtil::null, target); + copy->mExpanderLabel = mExpanderLabel; + return copy; + } + /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { // more label always spans width of text box diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 570061d491..f3cb07739d 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -56,6 +56,7 @@ #include "llvoavatar.h" #include "llsculptidsize.h" #include "llmeshrepository.h" +#include "llskinningutil.h" #define LL_MAX_INDICES_COUNT 1000000 @@ -1480,9 +1481,9 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, } //TODO -- cache this (check profile marker above)? - glh::matrix4f m((F32*) skin->mBindShapeMatrix.getF32ptr()); - m = m.inverse().transpose(); - mat_normal.loadu(m.m); + glm::mat4 m = glm::make_mat4((F32*)skin->mBindShapeMatrix.getF32ptr()); + m = glm::transpose(glm::inverse(m)); + mat_normal.loadu(glm::value_ptr(m)); } else { @@ -1734,7 +1735,7 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, { //bump mapped or has material, just do the whole expensive loop LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - texgen default"); - std::vector<LLVector2> bump_tc; + LLStrider<LLVector2> bump_tc; if (mat && !mat->getNormalID().isNull()) { //writing out normal and specular texture coordinates, not bump offsets @@ -1796,49 +1797,70 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, } const bool do_xform = (xforms & xform_channel) != XFORM_NONE; + // hold onto strider to front of TC array for use later + bump_tc = dst; - for (S32 i = 0; i < num_vertices; i++) { - LLVector2 tc(vf.mTexCoords[i]); - - LLVector4a& norm = vf.mNormals[i]; - - LLVector4a& center = *(vf.mCenter); - - if (texgen != LLTextureEntry::TEX_GEN_DEFAULT) + // NOTE: split TEX_GEN_PLANAR implementation to reduce branchiness of inner loop + // These are per-vertex operations and every little bit counts + if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { - LLVector4a vec = vf.mPositions[i]; + LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("tgd - planar"); + for (S32 i = 0; i < num_vertices; i++) + { + LLVector2 tc(vf.mTexCoords[i]); + LLVector4a& norm = vf.mNormals[i]; + LLVector4a& center = *(vf.mCenter); + LLVector4a vec = vf.mPositions[i]; - vec.mul(scalea); + vec.mul(scalea); - if (texgen == LLTextureEntry::TEX_GEN_PLANAR) - { planarProjection(tc, norm, center, vec); - } - } - if (tex_mode && mTextureMatrix) - { - LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); - tmp = tmp * *mTextureMatrix; - tc.mV[0] = tmp.mV[0]; - tc.mV[1] = tmp.mV[1]; + if (tex_mode && mTextureMatrix) + { + LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); + tmp = tmp * *mTextureMatrix; + tc.mV[0] = tmp.mV[0]; + tc.mV[1] = tmp.mV[1]; + } + else if (do_xform) + { + xform(tc, cos_ang, sin_ang, os, ot, ms, mt); + } + + *dst++ = tc; + } } - else if (do_xform) + else { - xform(tc, cos_ang, sin_ang, os, ot, ms, mt); - } + LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("tgd - transform"); - *dst++ = tc; - if (do_bump) - { - bump_tc.push_back(tc); + for (S32 i = 0; i < num_vertices; i++) + { + LLVector2 tc(vf.mTexCoords[i]); + + if (tex_mode && mTextureMatrix) + { + LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); + tmp = tmp * *mTextureMatrix; + tc.mV[0] = tmp.mV[0]; + tc.mV[1] = tmp.mV[1]; + } + else if (do_xform) + { + xform(tc, cos_ang, sin_ang, os, ot, ms, mt); + } + + *dst++ = tc; + } } } } if ((!mat && !gltf_mat) && do_bump) { + LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("tgd - do bump"); mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount); mVObjp->getVolume()->genTangents(face_index); @@ -2156,28 +2178,96 @@ F32 LLFace::getTextureVirtualSize() bool LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) { + constexpr F32 PIXEL_AREA_UPDATE_PERIOD = 0.1f; + // this is an expensive operation and the result is valid (enough) for several frames + // don't update every frame + if (gFrameTimeSeconds - mLastPixelAreaUpdate < PIXEL_AREA_UPDATE_PERIOD) + { + return true; + } + LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; //get area of circle around face - LLVector4a center; LLVector4a size; - if (isState(LLFace::RIGGED)) { - //override with avatar bounding box + LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("calcPixelArea - rigged"); + //override with joint volume face joint bounding boxes LLVOAvatar* avatar = mVObjp->getAvatar(); + bool hasRiggedExtents = false; + if (avatar && avatar->mDrawable) { - center.load3(avatar->getPositionAgent().mV); - const LLVector4a* exts = avatar->mDrawable->getSpatialExtents(); - size.setSub(exts[1], exts[0]); + LLVolume* volume = mVObjp->getVolume(); + if (volume) + { + LLVolumeFace& face = volume->getVolumeFace(mTEOffset); + + auto& rigInfo = face.mJointRiggingInfoTab; + + if (rigInfo.needsUpdate()) + { + LLVOVolume* vo_volume = (LLVOVolume*)mVObjp.get(); + LLVOAvatar* avatar = mVObjp->getAvatar(); + const LLMeshSkinInfo* skin = vo_volume->getSkinInfo(); + LLSkinningUtil::updateRiggingInfo(skin, avatar, face); + } + + // calculate the world space bounding box of the face by combining the bounding boxes of all the joints + LLVector4a& minp = mRiggedExtents[0]; + LLVector4a& maxp = mRiggedExtents[1]; + minp = LLVector4a(FLT_MAX, FLT_MAX, FLT_MAX); + maxp = LLVector4a(-FLT_MAX, -FLT_MAX, -FLT_MAX); + + for (S32 i = 0; i < rigInfo.size(); i++) + { + auto& jointInfo = rigInfo[i]; + if (jointInfo.isRiggedTo()) + { + LLJoint* joint = avatar->getJoint(i); + + if (joint) + { + LLVector4a jointPos; + + LLMatrix4a worldMat; + worldMat.loadu((F32*)&joint->getWorldMatrix().mMatrix[0][0]); + + LLVector4a extents[2]; + + matMulBoundBox(worldMat, jointInfo.getRiggedExtents(), extents); + + minp.setMin(minp, extents[0]); + maxp.setMax(maxp, extents[1]); + hasRiggedExtents = true; + } + } + } + } } - else + + if (!hasRiggedExtents) { + // no rigged extents, zero out bounding box and skip update + mRiggedExtents[0] = mRiggedExtents[1] = LLVector4a(0.f, 0.f, 0.f); + return false; } + + center.setAdd(mRiggedExtents[1], mRiggedExtents[0]); + center.mul(0.5f); + size.setSub(mRiggedExtents[1], mRiggedExtents[0]); + } + else if (mDrawablep && mVObjp.notNull() && mVObjp->getPartitionType() == LLViewerRegion::PARTITION_PARTICLE && mDrawablep->getSpatialGroup()) + { // use box of spatial group for particles (over approximates size, but we don't actually have a good size per particle) + LLSpatialGroup* group = mDrawablep->getSpatialGroup(); + const LLVector4a* extents = group->getExtents(); + size.setSub(extents[1], extents[0]); + center.setAdd(extents[1], extents[0]); + center.mul(0.5f); } else { @@ -2203,6 +2293,10 @@ bool LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) F32 app_angle = atanf((F32) sqrt(size_squared) / dist); radius = app_angle*LLDrawable::sCurPixelAngle; mPixelArea = radius*radius * 3.14159f; + + // remember last update time, add 10% noise to avoid all faces updating at the same time + mLastPixelAreaUpdate = gFrameTimeSeconds + ll_frand() * PIXEL_AREA_UPDATE_PERIOD * 0.1f; + LLVector4a x_axis; x_axis.load3(camera->getXAxis().mV); cos_angle_to_view_dir = lookAt.dot3(x_axis).getF32(); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 99642016f7..65637fbf85 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -234,8 +234,14 @@ public: // return true if this face is in an alpha draw pool bool isInAlphaPool() const; public: //aligned members + + // bounding box of face in drawable space LLVector4a mExtents[2]; + // cached bounding box of rigged face in world space + // calculated on-demand by LLFace::calcPixelArea and may not be up-to-date + LLVector4a mRiggedExtents[2] = { LLVector4a(0,0,0), LLVector4a(0,0,0) }; + private: friend class LLViewerTextureList; F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius ); @@ -301,7 +307,14 @@ private: S32 mReferenceIndex; std::vector<S32> mRiggedIndex; + // gFrameTimeSeconds when mPixelArea was last updated + F32 mLastPixelAreaUpdate = 0.f; + + // virtual size of face in texture area (mPixelArea adjusted by texture repeats) + // used to determine desired resolution of texture F32 mVSize; + + // pixel area face covers on screen F32 mPixelArea; //importance factor, in the range [0, 1.0]. diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index bf046e200f..fcc3423b4d 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -392,7 +392,7 @@ bool LLFeatureManager::loadGPUClass() catch (const std::exception& e) { // HACK - ensure that profiling is disabled - LLGLSLShader::finishProfile(false); + LLGLSLShader::finishProfile(); gbps = -1.f; LL_WARNS("RenderInit") << "GPU benchmark failed: " << e.what() << LL_ENDL; } @@ -628,6 +628,14 @@ void LLFeatureManager::applyBaseMasks() { maskFeatures("Intel"); } + if (gGLManager.mIsApple) + { + maskFeatures("AppleGPU"); + } + else + { + maskFeatures("NonAppleGPU"); + } if (gGLManager.mGLVersion < 3.f) { maskFeatures("OpenGLPre30"); diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 11505e3047..a38cc94328 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -163,6 +163,7 @@ public: void updateParcelInfo(); void updateCovenantInfo(); static void onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data); + void updateFloaterCovenant(const LLTextBase* source, const LLUUID &asset_id); void updateFloaterCovenantText(const std::string& string, const LLUUID &asset_id); void updateFloaterEstateName(const std::string& name); void updateFloaterLastModified(const std::string& text); @@ -201,6 +202,8 @@ public: void onVisibilityChanged ( const LLSD& new_visibility ); +private: + void onCovenantTextUpdated(const LLUUID& asset_id); }; // static @@ -222,6 +225,15 @@ void LLFloaterBuyLand::buyLand( } // static +void LLFloaterBuyLand::updateCovenant(const LLTextBase* source, const LLUUID& asset_id) +{ + if (LLFloaterBuyLandUI* floater = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land")) + { + floater->updateFloaterCovenant(source, asset_id); + } +} + +// static void LLFloaterBuyLand::updateCovenantText(const std::string& string, const LLUUID &asset_id) { LLFloaterBuyLandUI* floater = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land"); @@ -560,11 +572,24 @@ void LLFloaterBuyLandUI::onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data) } } +void LLFloaterBuyLandUI::updateFloaterCovenant(const LLTextBase* source, const LLUUID& asset_id) +{ + LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("covenant_editor"); + editor->copyContents(source); + + onCovenantTextUpdated(asset_id); +} + void LLFloaterBuyLandUI::updateFloaterCovenantText(const std::string &string, const LLUUID& asset_id) { LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("covenant_editor"); editor->setText(string); + onCovenantTextUpdated(asset_id); +} + +void LLFloaterBuyLandUI::onCovenantTextUpdated(const LLUUID& asset_id) +{ LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant"); LLTextBox* box = getChild<LLTextBox>("covenant_text"); if (asset_id.isNull()) diff --git a/indra/newview/llfloaterbuyland.h b/indra/newview/llfloaterbuyland.h index f750a4017a..732312f10f 100644 --- a/indra/newview/llfloaterbuyland.h +++ b/indra/newview/llfloaterbuyland.h @@ -27,6 +27,7 @@ #ifndef LL_LLFLOATERBUYLAND_H #define LL_LLFLOATERBUYLAND_H +class LLTextBase; class LLFloater; class LLViewerRegion; class LLParcelSelection; @@ -37,6 +38,7 @@ public: static void buyLand(LLViewerRegion* region, LLSafeHandle<LLParcelSelection> parcel, bool is_for_group); + static void updateCovenant(const LLTextBase* source, const LLUUID& asset_id); static void updateCovenantText(const std::string& string, const LLUUID& asset_id); static void updateEstateName(const std::string& name); static void updateLastModified(const std::string& text); diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index 3d81d01e16..b94c31ec04 100644 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -406,7 +406,7 @@ void LLFloaterBvhPreview::draw() gGL.getTexUnit(0)->bind(mAnimPreview); - gGL.begin( LLRender::QUADS ); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(0.f, 1.f); gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); @@ -414,6 +414,11 @@ void LLFloaterBvhPreview::draw() gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); gGL.texCoord2f(1.f, 0.f); gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); gGL.texCoord2f(1.f, 1.f); gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); } diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp index d2cf24f1dd..a127f5d43e 100644 --- a/indra/newview/llfloatergltfasseteditor.cpp +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -209,7 +209,7 @@ void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* par std::string name = node.mName; if (node.mName.empty()) { - name = getString("node_tittle"); + name = getString("node_title"); } else { @@ -243,7 +243,7 @@ void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* par std::string name = mAsset->mMeshes[node.mMesh].mName; if (name.empty()) { - name = getString("mesh_tittle"); + name = getString("mesh_title"); } loadItem(node.mMesh, name, LLGLTFFolderItem::TYPE_MESH, view); } @@ -253,7 +253,7 @@ void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* par std::string name = mAsset->mSkins[node.mSkin].mName; if (name.empty()) { - name = getString("skin_tittle"); + name = getString("skin_title"); } loadItem(node.mSkin, name, LLGLTFFolderItem::TYPE_SKIN, view); } @@ -306,7 +306,7 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() std::string name = scene.mName; if (scene.mName.empty()) { - name = getString("scene_tittle"); + name = getString("scene_title"); } else { diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index a900e04707..989e1d8d04 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -285,7 +285,7 @@ void LLFloaterImagePreview::draw() } gGL.color3f(1.f, 1.f, 1.f); - gGL.begin( LLRender::QUADS ); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); @@ -293,6 +293,11 @@ void LLFloaterImagePreview::draw() gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + + gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mTop); gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); } @@ -317,7 +322,7 @@ void LLFloaterImagePreview::draw() gGL.getTexUnit(0)->bind(mAvatarPreview); } - gGL.begin( LLRender::QUADS ); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(0.f, 1.f); gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); @@ -325,6 +330,11 @@ void LLFloaterImagePreview::draw() gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); gGL.texCoord2f(1.f, 0.f); gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); gGL.texCoord2f(1.f, 1.f); gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); } @@ -852,7 +862,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) } // build indices - for (U16 i = 0; i < num_indices; i++) + for (U32 i = 0; i < num_indices; i++) { *(index_strider++) = vf.mIndices[i]; } diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index abf15ea9cf..e55bf50724 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -306,6 +306,9 @@ bool LLFloaterIMContainer::postBuild() mParticipantRefreshTimer.setTimerExpirySec(0); mParticipantRefreshTimer.start(); + mGeneralTitleInUse = true; // avoid reseting strings on idle + setTitle(mGeneralTitle); + return true; } @@ -521,7 +524,12 @@ void LLFloaterIMContainer::idleUpdate() // Update floater's title as required by the currently selected session or use the default title LLFloaterIMSession * conversation_floaterp = LLFloaterIMSession::findInstance(current_session->getUUID()); - setTitle(conversation_floaterp && conversation_floaterp->needsTitleOverwrite() ? conversation_floaterp->getTitle() : mGeneralTitle); + bool needs_override = conversation_floaterp && conversation_floaterp->needsTitleOverwrite(); + if (mGeneralTitleInUse == needs_override) + { + mGeneralTitleInUse = !needs_override; + setTitle(needs_override ? conversation_floaterp->getTitle() : mGeneralTitle); + } } mParticipantRefreshTimer.setTimerExpirySec(1.0f); diff --git a/indra/newview/llfloaterimcontainer.h b/indra/newview/llfloaterimcontainer.h index d1cfd3442c..e5486e67da 100644 --- a/indra/newview/llfloaterimcontainer.h +++ b/indra/newview/llfloaterimcontainer.h @@ -234,6 +234,7 @@ private: conversations_items_deque mConversationEventQueue; LLTimer mParticipantRefreshTimer; + bool mGeneralTitleInUse = true; }; #endif // LL_LLFLOATERIMCONTAINER_H diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 00e7dae657..fe0916bf15 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -450,7 +450,8 @@ void LLFloaterIMSessionTab::enableDisableCallBtn() else { // We allow to start call from this state only - if (mSession->mVoiceChannel->getState() == LLVoiceChannel::STATE_NO_CHANNEL_INFO && + if (mSession->mVoiceChannel && + !mSession->mVoiceChannel->callStarted() && LLVoiceClient::instanceExists()) { LLVoiceClient* client = LLVoiceClient::getInstance(); @@ -494,10 +495,7 @@ void LLFloaterIMSessionTab::onCallButtonClicked() } else { - LLVoiceChannel::EState channel_state = mSession && mSession->mVoiceChannel ? - mSession->mVoiceChannel->getState() : LLVoiceChannel::STATE_NO_CHANNEL_INFO; - // We allow to start call from this state only - if (channel_state == LLVoiceChannel::STATE_NO_CHANNEL_INFO) + if (mSession->mVoiceChannel && !mSession->mVoiceChannel->callStarted()) { gIMMgr->startCall(mSessionID); } diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index bec76fe5e4..52a3e78d04 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -3124,6 +3124,16 @@ void LLPanelLandCovenant::refresh() } // static +void LLPanelLandCovenant::updateCovenant(const LLTextBase* source) +{ + if (LLPanelLandCovenant* self = LLFloaterLand::getCurrentPanelLandCovenant()) + { + LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("covenant_editor"); + editor->copyContents(source); + } +} + +// static void LLPanelLandCovenant::updateCovenantText(const std::string &string) { LLPanelLandCovenant* self = LLFloaterLand::getCurrentPanelLandCovenant(); diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 95f6a44a94..8af0caab33 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -50,6 +50,7 @@ class LLRadioGroup; class LLParcelSelectionObserver; class LLSpinCtrl; class LLTabContainer; +class LLTextBase; class LLTextBox; class LLTextEditor; class LLTextureCtrl; @@ -416,6 +417,7 @@ public: virtual ~LLPanelLandCovenant(); virtual bool postBuild(); void refresh(); + static void updateCovenant(const LLTextBase* source); static void updateCovenantText(const std::string& string); static void updateEstateName(const std::string& name); static void updateLastModified(const std::string& text); diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 5ca727cf66..8332a430e6 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -782,16 +782,21 @@ void LLFloaterModelPreview::draw3dPreview() gGL.getTexUnit(0)->bind(mModelPreview); - gGL.begin( LLRender::QUADS ); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(mPreviewRect.mLeft+1, mPreviewRect.mTop-1); + gGL.vertex2i(mPreviewRect.mLeft + 1, mPreviewRect.mTop - 1); gGL.texCoord2f(0.f, 0.f); - gGL.vertex2i(mPreviewRect.mLeft+1, mPreviewRect.mBottom+1); + gGL.vertex2i(mPreviewRect.mLeft + 1, mPreviewRect.mBottom + 1); gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(mPreviewRect.mRight-1, mPreviewRect.mBottom+1); + gGL.vertex2i(mPreviewRect.mRight - 1, mPreviewRect.mBottom + 1); + + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2i(mPreviewRect.mRight - 1, mPreviewRect.mBottom + 1); gGL.texCoord2f(1.f, 1.f); - gGL.vertex2i(mPreviewRect.mRight-1, mPreviewRect.mTop-1); + gGL.vertex2i(mPreviewRect.mRight - 1, mPreviewRect.mTop - 1); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(mPreviewRect.mLeft + 1, mPreviewRect.mTop - 1); } gGL.end(); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 0da250644e..219a9ca520 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -2820,6 +2820,16 @@ void LLPanelEstateCovenant::setEstateName(const std::string& name) } // static +void LLPanelEstateCovenant::updateCovenant(const LLTextBase* source, const LLUUID& asset_id) +{ + if (LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant()) + { + panelp->mEditor->copyContents(source); + panelp->setCovenantID(asset_id); + } +} + +// static void LLPanelEstateCovenant::updateCovenantText(const std::string& string, const LLUUID& asset_id) { LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index b604a28fc3..65c1291728 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -382,6 +382,7 @@ public: void* user_data, S32 status, LLExtStat ext_status); // Accessor functions + static void updateCovenant(const LLTextBase* source, const LLUUID& asset_id); static void updateCovenantText(const std::string& string, const LLUUID& asset_id); static void updateEstateName(const std::string& name); static void updateLastModified(const std::string& text); diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 1f52f1d180..fb4537f22a 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -1297,7 +1297,8 @@ bool LLFloaterSnapshotBase::ImplBase::updatePreviewList(bool initialized) void LLFloaterSnapshotBase::ImplBase::updateLivePreview() { - if (ImplBase::updatePreviewList(true) && mFloater) + // don't update preview for hidden floater + if (mFloater && mFloater->isInVisibleChain() && ImplBase::updatePreviewList(true)) { LL_DEBUGS() << "changed" << LL_ENDL; updateControls(mFloater); diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index fc2cfbcf2b..30ed723db6 100755 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -1773,8 +1773,8 @@ void LLFloaterWorldMap::onCommitSearchResult() } LLStringUtil::toLower(sim_name); - std::map<U64, LLSimInfo*>::const_iterator it; - for (it = LLWorldMap::getInstance()->getRegionMap().begin(); it != LLWorldMap::getInstance()->getRegionMap().end(); ++it) + LLWorldMap::sim_info_map_t::const_iterator end = LLWorldMap::instance().getRegionMap().end(); + for (LLWorldMap::sim_info_map_t::const_iterator it = LLWorldMap::getInstance()->getRegionMap().begin(); it != end; ++it) { LLSimInfo* info = it->second; diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index 734f20830d..c668d414d3 100644 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -234,7 +234,7 @@ bool LLFolderViewModelItemInventory::filterChildItem( LLFolderViewModelItem* ite return continue_filtering; } -bool LLFolderViewModelItemInventory::filter( LLFolderViewFilter& filter) +bool LLFolderViewModelItemInventory::filter(LLFolderViewFilter& filter) { const S32 filter_generation = filter.getCurrentGeneration(); const S32 must_pass_generation = filter.getFirstRequiredGeneration(); diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 0248f5710f..112008172e 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -68,7 +68,7 @@ #include <vector> // Height of the yellow selection highlight posts for land -const F32 PARCEL_POST_HEIGHT = 0.666f; +constexpr F32 PARCEL_POST_HEIGHT = 0.666f; // Returns true if you got at least one object void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) @@ -178,27 +178,27 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) { std::vector<LLDrawable*> potentials; - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList()) { - LLViewerRegion* region = *iter; for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) { - LLSpatialPartition* part = region->getSpatialPartition(i); - if (part) + if (LLSpatialPartition* part = region->getSpatialPartition(i)) { part->cull(*LLViewerCamera::getInstance(), &potentials, true); } } } - for (std::vector<LLDrawable*>::iterator iter = potentials.begin(); - iter != potentials.end(); iter++) + for (LLDrawable* drawable : potentials) { - LLDrawable* drawable = *iter; + if (!drawable) + { + continue; + } + LLViewerObject* vobjp = drawable->getVObj(); - if (!drawable || !vobjp || + if (!vobjp || vobjp->getPCode() != LL_PCODE_VOLUME || vobjp->isAttachment() || (deselect && !vobjp->isSelected())) @@ -244,7 +244,7 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) gViewerWindow->setup3DRender(); } -const F32 WIND_RELATIVE_ALTITUDE = 25.f; +constexpr F32 WIND_RELATIVE_ALTITUDE = 25.f; void LLWind::renderVectors() { @@ -266,14 +266,14 @@ void LLWind::renderVectors() x = mVelX[i + j*mSize] * WIND_SCALE_HACK; y = mVelY[i + j*mSize] * WIND_SCALE_HACK; gGL.pushMatrix(); - gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0); - gGL.color3f(0,1,0); + gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.f); + gGL.color3f(0.f, 1.f, 0.f); gGL.begin(LLRender::POINTS); - gGL.vertex3f(0,0,0); + gGL.vertex3f(0.f, 0.f, 0.f); gGL.end(); - gGL.color3f(1,0,0); + gGL.color3f(1.f, 0.f, 0.f); gGL.begin(LLRender::LINES); - gGL.vertex3f(x * 0.1f, y * 0.1f ,0.f); + gGL.vertex3f(x * 0.1f, y * 0.1f, 0.f); gGL.vertex3f(x, y, 0.f); gGL.end(); gGL.popMatrix(); @@ -287,7 +287,7 @@ void LLWind::renderVectors() // Used by lltoolselectland void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, - const LLVector3d &east_north_top_global ) + const LLVector3d &east_north_top_global) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -338,118 +338,23 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, gGL.end(); gGL.color4f(1.f, 1.f, 0.f, 0.2f); - gGL.begin(LLRender::QUADS); - - gGL.vertex3f(west, north, nw_bottom); - gGL.vertex3f(west, north, nw_top); - gGL.vertex3f(east, north, ne_top); - gGL.vertex3f(east, north, ne_bottom); - - gGL.vertex3f(east, north, ne_bottom); - gGL.vertex3f(east, north, ne_top); - gGL.vertex3f(east, south, se_top); - gGL.vertex3f(east, south, se_bottom); - - gGL.vertex3f(east, south, se_bottom); - gGL.vertex3f(east, south, se_top); - gGL.vertex3f(west, south, sw_top); - gGL.vertex3f(west, south, sw_bottom); - - gGL.vertex3f(west, south, sw_bottom); - gGL.vertex3f(west, south, sw_top); - gGL.vertex3f(west, north, nw_top); - gGL.vertex3f(west, north, nw_bottom); - - gGL.end(); - - LLUI::setLineWidth(1.f); -} - -/* -void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) -{ - S32 i; - S32 count = parcel->getBoxCount(); - for (i = 0; i < count; i++) + gGL.begin(LLRender::TRIANGLE_STRIP); { - const LLParcelBox& box = parcel->getBox(i); - - F32 west = box.mMin.mV[VX]; - F32 south = box.mMin.mV[VY]; - - F32 east = box.mMax.mV[VX]; - F32 north = box.mMax.mV[VY]; - - // HACK: At edge of last region of world, we need to make sure the region - // resolves correctly so we can get a height value. - const F32 FUDGE = 0.01f; - - F32 sw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); - F32 se_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); - F32 ne_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); - F32 nw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); - - // little hack to make nearby lines not Z-fight - east -= 0.1f; - north -= 0.1f; - - F32 sw_top = sw_bottom + POST_HEIGHT; - F32 se_top = se_bottom + POST_HEIGHT; - F32 ne_top = ne_bottom + POST_HEIGHT; - F32 nw_top = nw_bottom + POST_HEIGHT; - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest gls_depth(GL_TRUE); - - LLUI::setLineWidth(2.f); - gGL.color4f(0.f, 1.f, 1.f, 1.f); - - // Cheat and give this the same pick-name as land - gGL.begin(LLRender::LINES); - - gGL.vertex3f(west, north, nw_bottom); - gGL.vertex3f(west, north, nw_top); - - gGL.vertex3f(east, north, ne_bottom); - gGL.vertex3f(east, north, ne_top); - - gGL.vertex3f(east, south, se_bottom); - gGL.vertex3f(east, south, se_top); - - gGL.vertex3f(west, south, sw_bottom); - gGL.vertex3f(west, south, sw_top); - - gGL.end(); - - gGL.color4f(0.f, 1.f, 1.f, 0.2f); - gGL.begin(LLRender::QUADS); - gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); - gGL.vertex3f(east, north, ne_top); - gGL.vertex3f(east, north, ne_bottom); - gGL.vertex3f(east, north, ne_bottom); gGL.vertex3f(east, north, ne_top); - gGL.vertex3f(east, south, se_top); - gGL.vertex3f(east, south, se_bottom); - gGL.vertex3f(east, south, se_bottom); gGL.vertex3f(east, south, se_top); gGL.vertex3f(west, south, sw_top); gGL.vertex3f(west, south, sw_bottom); - - gGL.vertex3f(west, south, sw_bottom); - gGL.vertex3f(west, south, sw_top); gGL.vertex3f(west, north, nw_top); gGL.vertex3f(west, north, nw_bottom); - - gGL.end(); - - LLUI::setLineWidth(1.f); } + gGL.end(); + + LLUI::setLineWidth(1.f); } -*/ // north = a wall going north/south. Need that info to set up texture @@ -493,6 +398,10 @@ void LLViewerParcelMgr::renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 hei gGL.vertex3f(x2, y2, z2); + gGL.vertex3f(x1, y1, z); + + gGL.vertex3f(x2, y2, z2); + z = z2+height; gGL.vertex3f(x2, y2, z); } @@ -523,18 +432,24 @@ void LLViewerParcelMgr::renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 hei } - gGL.texCoord2f(tex_coord1*0.5f+0.5f, z1*0.5f); + gGL.texCoord2f(tex_coord1 * 0.5f + 0.5f, z1 * 0.5f); gGL.vertex3f(x1, y1, z1); - gGL.texCoord2f(tex_coord2*0.5f+0.5f, z2*0.5f); + gGL.texCoord2f(tex_coord2 * 0.5f + 0.5f, z2 * 0.5f); gGL.vertex3f(x2, y2, z2); // top edge stairsteps - z = llmax(z2+height, z1+height); - gGL.texCoord2f(tex_coord2*0.5f+0.5f, z*0.5f); + z = llmax(z2 + height, z1 + height); + gGL.texCoord2f(tex_coord2 * 0.5f + 0.5f, z * 0.5f); + gGL.vertex3f(x2, y2, z); + + gGL.texCoord2f(tex_coord1 * 0.5f + 0.5f, z1 * 0.5f); + gGL.vertex3f(x1, y1, z1); + + gGL.texCoord2f(tex_coord2 * 0.5f + 0.5f, z * 0.5f); gGL.vertex3f(x2, y2, z); - gGL.texCoord2f(tex_coord1*0.5f+0.5f, z*0.5f); + gGL.texCoord2f(tex_coord1 * 0.5f + 0.5f, z * 0.5f); gGL.vertex3f(x1, y1, z); } } @@ -575,7 +490,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi if (!has_segments) { has_segments = true; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); } renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, SOUTH_MASK, regionp); } @@ -591,7 +506,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi if (!has_segments) { has_segments = true; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); } renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, WEST_MASK, regionp); } @@ -647,7 +562,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, bool use_pass, LLV gGL.getTexUnit(0)->bind(mBlockedImage); } - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); for (y = 0; y < STRIDE; y++) { @@ -923,7 +838,7 @@ struct ShaderProfileHelper } ~ShaderProfileHelper() { - LLGLSLShader::finishProfile(false); + LLGLSLShader::finishProfile(); } }; diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index e38ba8762a..cf6b08797d 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.cpp +++ b/indra/newview/llgltfmaterialpreviewmgr.cpp @@ -193,7 +193,7 @@ LLGLTFPreviewTexture::LLGLTFPreviewTexture(LLPointer<LLFetchedGLTFMaterial> mate // static LLPointer<LLGLTFPreviewTexture> LLGLTFPreviewTexture::create(LLPointer<LLFetchedGLTFMaterial> material) { - return new LLGLTFPreviewTexture(material, LLPipeline::MAX_BAKE_WIDTH); + return new LLGLTFPreviewTexture(material, LLPipeline::MAX_PREVIEW_WIDTH); } bool LLGLTFPreviewTexture::needsRender() @@ -471,10 +471,10 @@ bool LLGLTFPreviewTexture::render() PreviewSphere& preview_sphere = get_preview_sphere(mGLTFMaterial, object_transform); gPipeline.setupHWLights(); - glh::matrix4f mat = copy_matrix(gGLModelView); - glh::vec4f transformed_light_dir(light_dir.mV); - mat.mult_matrix_vec(transformed_light_dir); - SetTemporarily<LLVector4> force_sun_direction_high_graphics(&gPipeline.mTransformedSunDir, LLVector4(transformed_light_dir.v)); + glm::mat4 mat = get_current_modelview(); + glm::vec4 transformed_light_dir = glm::make_vec4(light_dir.mV); + transformed_light_dir = mat * transformed_light_dir; + SetTemporarily<LLVector4> force_sun_direction_high_graphics(&gPipeline.mTransformedSunDir, LLVector4(glm::value_ptr(transformed_light_dir))); // Override lights to ensure the sun is always shining from a certain direction (low graphics) // See also force_sun_direction_high_graphics and fixup_shader_constants { diff --git a/indra/newview/llhudeffectblob.cpp b/indra/newview/llhudeffectblob.cpp index b476226d05..bdb21fd96e 100644 --- a/indra/newview/llhudeffectblob.cpp +++ b/indra/newview/llhudeffectblob.cpp @@ -78,16 +78,23 @@ void LLHUDEffectBlob::render() LLVector3 u_scale = pixel_right * (F32)mPixelSize; LLVector3 v_scale = pixel_up * (F32)mPixelSize; - { gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { gGL.texCoord2f(0.f, 1.f); gGL.vertex3fv((v_scale - u_scale).mV); gGL.texCoord2f(0.f, 0.f); gGL.vertex3fv((-v_scale - u_scale).mV); gGL.texCoord2f(1.f, 0.f); gGL.vertex3fv((-v_scale + u_scale).mV); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3fv((v_scale - u_scale).mV); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3fv((-v_scale + u_scale).mV); gGL.texCoord2f(1.f, 1.f); gGL.vertex3fv((v_scale + u_scale).mV); - } gGL.end(); + } + gGL.end(); } gGL.popMatrix(); } diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp index 8fa4118a40..1a4af470bd 100644 --- a/indra/newview/llhudicon.cpp +++ b/indra/newview/llhudicon.cpp @@ -152,7 +152,7 @@ void LLHUDIcon::render() gGL.getTexUnit(0)->bind(mImagep); } - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(0.f, 1.f); gGL.vertex3fv(upper_left.mV); @@ -160,6 +160,11 @@ void LLHUDIcon::render() gGL.vertex3fv(lower_left.mV); gGL.texCoord2f(1.f, 0.f); gGL.vertex3fv(lower_right.mV); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3fv(upper_left.mV); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3fv(lower_right.mV); gGL.texCoord2f(1.f, 1.f); gGL.vertex3fv(upper_right.mV); } diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 19ae35813c..66130a2744 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -275,7 +275,8 @@ void LLHUDNameTag::renderText() LLVector3 x_pixel_vec; LLVector3 y_pixel_vec; - LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + LLViewerCamera* camera = LLViewerCamera::getInstance(); + camera->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); LLVector3 width_vec = mWidth * x_pixel_vec; LLVector3 height_vec = mHeight * y_pixel_vec; @@ -283,7 +284,7 @@ void LLHUDNameTag::renderText() mRadius = (width_vec + height_vec).magVec() * 0.5f; LLCoordGL screen_pos; - LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, false); + camera->projectPosAgentToScreen(mPositionAgent, screen_pos, false); LLVector2 screen_offset = updateScreenPos(mPositionOffset); @@ -310,7 +311,7 @@ void LLHUDNameTag::renderText() const S32 label_height = ll_round((mFontp->getLineHeight() * (F32)mLabelSegments.size() + (VERTICAL_PADDING / 3.f))); label_top_rect.mBottom = label_top_rect.mTop - label_height; LLColor4 label_top_color = text_color; - label_top_color.mV[VALPHA] = gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor; + label_top_color.mV[VALPHA] = bubble_opacity() * alpha_factor; mRoundedRectTopImgp->draw3D(render_position, x_pixel_vec, y_pixel_vec, label_top_rect, label_top_color); } @@ -645,12 +646,13 @@ LLVector2 LLHUDNameTag::updateScreenPos(LLVector2 &offset) LLVector2 screen_pos_vec; LLVector3 x_pixel_vec; LLVector3 y_pixel_vec; - LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + LLViewerCamera* camera = LLViewerCamera::getInstance(); + camera->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); LLVector3 world_pos = mPositionAgent + (offset.mV[VX] * x_pixel_vec) + (offset.mV[VY] * y_pixel_vec); - if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(world_pos, screen_pos, false) && mVisibleOffScreen) + if (!camera->projectPosAgentToScreen(world_pos, screen_pos, false) && mVisibleOffScreen) { // bubble off-screen, so find a spot for it along screen edge - LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(world_pos, screen_pos); + camera->projectPosAgentToScreenEdge(world_pos, screen_pos); } screen_pos_vec.setVec((F32)screen_pos.mX, (F32)screen_pos.mY); diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp index f027aa5552..aa440c6cf5 100644 --- a/indra/newview/llhudrender.cpp +++ b/indra/newview/llhudrender.cpp @@ -38,6 +38,9 @@ #include "llviewerwindow.h" #include "llui.h" +#include <glm/gtc/matrix_transform.hpp> +#include <glm/gtc/type_ptr.hpp> + void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent, LLFontVertexBuffer *font_buffer, const LLFontGL &font, @@ -60,6 +63,7 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, const LLColor4& color, const bool orthographic) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; LLViewerCamera* camera = LLViewerCamera::getInstance(); // Do cheap plane culling LLVector3 dir_vec = pos_agent - camera->getOrigin(); @@ -102,26 +106,10 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, //get the render_pos in screen space - F64 winX, winY, winZ; LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); - S32 viewport[4]; - viewport[0] = world_view_rect.mLeft; - viewport[1] = world_view_rect.mBottom; - viewport[2] = world_view_rect.getWidth(); - viewport[3] = world_view_rect.getHeight(); - - F64 mdlv[16]; - F64 proj[16]; - - for (U32 i = 0; i < 16; i++) - { - mdlv[i] = (F64) gGLModelView[i]; - proj[i] = (F64) gGLProjection[i]; - } + glm::ivec4 viewport(world_view_rect.mLeft, world_view_rect.mBottom, world_view_rect.getWidth(), world_view_rect.getHeight()); - gluProject(render_pos.mV[0], render_pos.mV[1], render_pos.mV[2], - mdlv, proj, (GLint*) viewport, - &winX, &winY, &winZ); + glm::vec3 win_coord = glm::project(glm::make_vec3(render_pos.mV), get_current_modelview(), get_current_projection(), viewport); //fonts all render orthographically, set up projection`` gGL.matrixMode(LLRender::MM_PROJECTION); @@ -133,11 +121,11 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, gl_state_for_2d(world_view_rect.getWidth(), world_view_rect.getHeight()); gViewerWindow->setup3DViewport(); - winX -= world_view_rect.mLeft; - winY -= world_view_rect.mBottom; + win_coord.x -= world_view_rect.mLeft; + win_coord.y -= world_view_rect.mBottom; LLUI::loadIdentity(); gGL.loadIdentity(); - LLUI::translate((F32) winX*1.0f/LLFontGL::sScaleX, (F32) winY*1.0f/(LLFontGL::sScaleY), -(((F32) winZ*2.f)-1.f)); + LLUI::translate((F32) win_coord.x*1.0f/LLFontGL::sScaleX, (F32) win_coord.y*1.0f/(LLFontGL::sScaleY), -(((F32) win_coord.z*2.f)-1.f)); F32 right_x; if (font_buffer) diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index c1e68e0288..590cd09a31 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -488,7 +488,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, case IM_NOTHING_SPECIAL: // p2p IM // Don't show dialog, just do IM if (!gAgent.isGodlike() - && gAgent.getRegion()->isPrelude() + && gAgent.inPrelude() && to_id.isNull()) { // do nothing -- don't distract newbies in diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 136b59f3a6..1402cc8c37 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -390,11 +390,11 @@ void notify_of_message(const LLSD& msg, bool is_dnd_msg) } else { - LLAvatarNameCache::get(participant_id, boost::bind(&on_avatar_name_cache_toast, _1, _2, msg)); + LLAvatarNameCache::get(participant_id, boost::bind(&on_avatar_name_cache_toast, _1, _2, msg)); + } + } } } -} - } if (store_dnd_message) { // If in DND mode, allow notification to be stored so upon DND exit @@ -3551,6 +3551,7 @@ void LLIMMgr::inviteToSession( && voice_invite && "VoiceInviteQuestionDefault" == question_type) { LL_INFOS("IMVIEW") << "Rejecting voice call from initiating muted resident " << caller_name << LL_ENDL; + payload["voice_channel_info"] = voice_channel_info; LLIncomingCallDialog::processCallResponse(1, payload); return; } @@ -3599,6 +3600,7 @@ void LLIMMgr::inviteToSession( send_do_not_disturb_message(gMessageSystem, caller_id, session_id); } // silently decline the call + payload["voice_channel_info"] = voice_channel_info; LLIncomingCallDialog::processCallResponse(1, payload); return; } @@ -4178,11 +4180,16 @@ public: } if (input["body"]["info"].has("voice_channel_info")) { + // new voice channel info incoming, update and re-activate call + // if currently in a call. LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(session_id); if (session) { - session->initVoiceChannel(input["body"]["info"]["voice_channel_info"]); - session->mVoiceChannel->activate(); + if (session->mVoiceChannel && session->mVoiceChannel->callStarted()) + { + session->initVoiceChannel(input["body"]["info"]["voice_channel_info"]); + session->mVoiceChannel->activate(); + } } } } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index ca84c30b66..896c7d8d70 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1897,20 +1897,24 @@ void LLItemBridge::selectItem() } } +// virtual void LLItemBridge::restoreItem() { - LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem()); - if(item) + if (LLViewerInventoryItem* item = getItem()) { - LLInventoryModel* model = getInventoryModel(); - bool is_snapshot = (item->getInventoryType() == LLInventoryType::IT_SNAPSHOT); + bool is_snapshot = item->getInventoryType() == LLInventoryType::IT_SNAPSHOT; + LLFolderType::EType preferred_type = is_snapshot ? + LLFolderType::FT_SNAPSHOT_CATEGORY : + LLFolderType::assetTypeToFolderType(item->getType()); - const LLUUID new_parent = model->findCategoryUUIDForType(is_snapshot? LLFolderType::FT_SNAPSHOT_CATEGORY : LLFolderType::assetTypeToFolderType(item->getType())); - // do not restamp on restore. + LLInventoryModel* model = getInventoryModel(); + LLUUID new_parent = model->findCategoryUUIDForType(preferred_type); + // Do not restamp on restore. LLInvFVBridge::changeItemParent(model, item, new_parent, false); } } +// virtual void LLItemBridge::restoreToWorld() { //Similar functionality to the drag and drop rez logic @@ -1931,26 +1935,27 @@ void LLItemBridge::restoreToWorld() //remove local inventory copy, sim will deal with permissions and removing the item //from the actual inventory if its a no-copy etc - if(!itemp->getPermissions().allowCopyBy(gAgent.getID())) + if (!itemp->getPermissions().allowCopyBy(gAgent.getID())) { remove_from_inventory = true; } // Check if it's in the trash. (again similar to the normal rez logic) const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); - if(gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id)) + if (gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id)) { remove_from_inventory = true; } } - if(remove_from_inventory) + if (remove_from_inventory) { gInventory.deleteObject(itemp->getUUID()); gInventory.notifyObservers(); } } +// virtual void LLItemBridge::gotoItem() { LLInventoryObject *obj = getInventoryObject(); @@ -1960,39 +1965,43 @@ void LLItemBridge::gotoItem() } } +// virtual LLUIImagePtr LLItemBridge::getIcon() const { - LLInventoryObject *obj = getInventoryObject(); - if (obj) + if (LLInventoryObject* obj = getInventoryObject()) { - return LLInventoryIcon::getIcon(obj->getType(), - LLInventoryType::IT_NONE, - mIsLink); + return LLInventoryIcon::getIcon(obj->getType(), LLInventoryType::IT_NONE, mIsLink); } return LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); } +// virtual LLUIImagePtr LLItemBridge::getIconOverlay() const { if (getItem() && getItem()->getIsLinkType()) { return LLUI::getUIImage("Inv_Link"); } + return NULL; } +// virtual PermissionMask LLItemBridge::getPermissionMask() const { - LLViewerInventoryItem* item = getItem(); - PermissionMask perm_mask = 0; - if (item) perm_mask = item->getPermissionMask(); - return perm_mask; + if (LLViewerInventoryItem* item = getItem()) + { + return item->getPermissionMask(); + } + + return 0; } +// virtual void LLItemBridge::buildDisplayName() const { - if(getItem()) + if (getItem()) { mDisplayName.assign(getItem()->getName()); } @@ -2005,14 +2014,15 @@ void LLItemBridge::buildDisplayName() const mSearchableName.append(getLabelSuffix()); LLStringUtil::toUpper(mSearchableName); - //Name set, so trigger a sort + // Name set, so trigger a sort LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter(); - if(mParent && !sorter.isByDate()) + if (mParent && !sorter.isByDate()) { mParent->requestSort(); } } +// virtual LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const { U8 font = LLFontGL::NORMAL; @@ -2023,7 +2033,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const // LL_INFOS() << "BOLD" << LL_ENDL; font |= LLFontGL::BOLD; } - else if(item && item->getIsLinkType()) + else if (item && item->getIsLinkType()) { font |= LLFontGL::ITALIC; } @@ -2031,6 +2041,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const return (LLFontGL::StyleFlags)font; } +// virtual std::string LLItemBridge::getLabelSuffix() const { // String table is loaded before login screen and inventory items are @@ -2040,19 +2051,19 @@ std::string LLItemBridge::getLabelSuffix() const static std::string NO_XFER = LLTrans::getString("no_transfer_lbl"); static std::string LINK = LLTrans::getString("link"); static std::string BROKEN_LINK = LLTrans::getString("broken_link"); + std::string suffix; - LLInventoryItem* item = getItem(); - if(item) + if (LLInventoryItem* item = getItem()) { // Any type can have the link suffix... - bool broken_link = LLAssetType::lookupIsLinkType(item->getType()); - if (broken_link) return BROKEN_LINK; + if (LLAssetType::lookupIsLinkType(item->getType())) + return BROKEN_LINK; - bool link = item->getIsLinkType(); - if (link) return LINK; + if (item->getIsLinkType()) + return LINK; // ...but it's a bit confusing to put nocopy/nomod/etc suffixes on calling cards. - if(LLAssetType::AT_CALLINGCARD != item->getType() + if (LLAssetType::AT_CALLINGCARD != item->getType() && item->getPermissions().getOwner() == gAgent.getID()) { bool copy = item->getPermissions().allowCopyBy(gAgent.getID()); @@ -2067,8 +2078,7 @@ std::string LLItemBridge::getLabelSuffix() const suffix += suffix.empty() ? " " : ","; suffix += NO_MOD; } - bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, - gAgent.getID()); + bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); if (!xfer) { suffix += suffix.empty() ? " " : ","; @@ -2076,24 +2086,25 @@ std::string LLItemBridge::getLabelSuffix() const } } } + return suffix; } +// virtual time_t LLItemBridge::getCreationDate() const { - LLViewerInventoryItem* item = getItem(); - if (item) + if (LLViewerInventoryItem* item = getItem()) { return item->getCreationDate(); } + return 0; } - +// virtual bool LLItemBridge::isItemRenameable() const { - LLViewerInventoryItem* item = getItem(); - if(item) + if (LLViewerInventoryItem* item = getItem()) { // (For now) Don't allow calling card rename since that may confuse users as to // what the calling card points to. @@ -2112,50 +2123,62 @@ bool LLItemBridge::isItemRenameable() const return false; } - return (item->getPermissions().allowModifyBy(gAgent.getID())); + return item->getPermissions().allowModifyBy(gAgent.getID()); } + return false; } +// virtual bool LLItemBridge::renameItem(const std::string& new_name) { - if(!isItemRenameable()) + if (!isItemRenameable()) return false; + LLPreview::dirty(mUUID); LLInventoryModel* model = getInventoryModel(); - if(!model) + if (!model) return false; + LLViewerInventoryItem* item = getItem(); - if(item && (item->getName() != new_name)) + if (item && (item->getName() != new_name)) { LLSD updates; updates["name"] = new_name; update_inventory_item(item->getUUID(),updates, NULL); } - // return false because we either notified observers (& therefore - // rebuilt) or we didn't update. + + // return false because we either notified observers + // (& therefore rebuilt) or we didn't update. return false; } +// virtual bool LLItemBridge::removeItem() { - if(!isItemRemovable()) + if (!isItemRemovable()) { return false; } // move it to the trash LLInventoryModel* model = getInventoryModel(); - if(!model) return false; + if (!model) + return false; + const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); LLViewerInventoryItem* item = getItem(); - if (!item) return false; + if (!item) + return false; + if (item->getType() != LLAssetType::AT_LSL_TEXT) { LLPreview::hide(mUUID, true); } + // Already in trash - if (model->isObjectDescendentOf(mUUID, trash_id)) return false; + if (model->isObjectDescendentOf(mUUID, trash_id)) + return false; LLNotification::Params params("ConfirmItemDeleteHasLinks"); params.functor.function(boost::bind(&LLItemBridge::confirmRemoveItem, this, _1, _2)); @@ -2187,26 +2210,31 @@ bool LLItemBridge::removeItem() bool LLItemBridge::confirmRemoveItem(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) return false; + if (option != 0) + return false; LLInventoryModel* model = getInventoryModel(); - if (!model) return false; + if (!model) + return false; LLViewerInventoryItem* item = getItem(); - if (!item) return false; + if (!item) + return false; const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); // if item is not already in trash - if(item && !model->isObjectDescendentOf(mUUID, trash_id)) + if (item && !model->isObjectDescendentOf(mUUID, trash_id)) { // move to trash, and restamp LLInvFVBridge::changeItemParent(model, item, trash_id, true); // delete was successful return true; } + return false; } +// virtual bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const { LLViewerInventoryItem* item = getItem(); @@ -2214,6 +2242,7 @@ bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const { return false; } + // Can't copy worn objects. // Worn objects are tied to their inworld conterparts // Copy of modified worn object will return object with obsolete asset and inventory @@ -2230,37 +2259,36 @@ bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const LLViewerInventoryItem* LLItemBridge::getItem() const { - LLViewerInventoryItem* item = NULL; - LLInventoryModel* model = getInventoryModel(); - if(model) + if (LLInventoryModel* model = getInventoryModel()) { - item = (LLViewerInventoryItem*)model->getItem(mUUID); + return model->getItem(mUUID); } - return item; + + return NULL; } +// virtual const LLUUID& LLItemBridge::getThumbnailUUID() const { - LLViewerInventoryItem* item = NULL; - LLInventoryModel* model = getInventoryModel(); - if(model) - { - item = (LLViewerInventoryItem*)model->getItem(mUUID); - } - if (item) + if (LLInventoryModel* model = getInventoryModel()) { - return item->getThumbnailUUID(); + if (LLViewerInventoryItem* item = model->getItem(mUUID)) + { + return item->getThumbnailUUID(); + } } + return LLUUID::null; } +// virtual bool LLItemBridge::isItemPermissive() const { - LLViewerInventoryItem* item = getItem(); - if(item) + if (LLViewerInventoryItem* item = getItem()) { return item->getIsFullPerm(); } + return false; } @@ -2583,16 +2611,22 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, LLInventoryModel* model = getInventoryModel(); - if (!inv_cat) return false; // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL - if (!model) return false; - if (!isAgentAvatarValid()) return false; - if (!isAgentInventory()) return false; // cannot drag categories into library + if (!inv_cat) // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL + return false; + if (!model) + return false; + if (!isAgentAvatarValid()) + return false; + if (!isAgentInventory()) + return false; // cannot drag categories into library LLInventoryPanel* destination_panel = mInventoryPanel.get(); - if (!destination_panel) return false; + if (!destination_panel) + return false; LLInventoryFilter* filter = getInventoryFilter(); - if (!filter) return false; + if (!filter) + return false; const LLUUID &cat_id = inv_cat->getUUID(); const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); @@ -2689,7 +2723,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, is_movable = false; } } - if(is_movable && move_is_into_current_outfit && is_link) + if (is_movable && move_is_into_current_outfit && is_link) { is_movable = false; } @@ -2717,7 +2751,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, for (S32 i=0; i < descendent_categories.size(); ++i) { LLInventoryCategory* category = descendent_categories[i]; - if(LLFolderType::lookupIsProtectedType(category->getPreferredType())) + if (LLFolderType::lookupIsProtectedType(category->getPreferredType())) { // Can't move "special folders" (e.g. Textures Folder). is_movable = false; @@ -2749,9 +2783,8 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } if (is_movable && move_is_into_trash) { - for (S32 i=0; i < descendent_items.size(); ++i) + for (LLViewerInventoryItem* item : descendent_items) { - LLInventoryItem* item = descendent_items[i]; if (get_is_item_worn(item->getUUID())) { is_movable = false; @@ -2761,10 +2794,8 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } if (is_movable && move_is_into_landmarks) { - for (S32 i=0; i < descendent_items.size(); ++i) + for (LLViewerInventoryItem* item : descendent_items) { - LLViewerInventoryItem* item = descendent_items[i]; - // Don't move anything except landmarks and categories into Landmarks folder. // We use getType() instead of getActua;Type() to allow links to landmarks and folders. if (LLAssetType::AT_LANDMARK != item->getType() && LLAssetType::AT_CATEGORY != item->getType()) @@ -3055,7 +3086,7 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, // permissions. // content category has same ID as object itself LLViewerObject* object = gObjectList.findObject(object_id); - if(!object) + if (!object) { LL_INFOS() << "Object not found for drop." << LL_ENDL; return false; @@ -3083,11 +3114,9 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, // coming from a task. Need to figure out if the person can // move/copy this item. - LLInventoryObject::object_list_t::iterator it = inventory_objects.begin(); - LLInventoryObject::object_list_t::iterator end = inventory_objects.end(); - for ( ; it != end; ++it) + for (LLPointer<LLInventoryObject> obj : inventory_objects) { - LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(it->get()); + LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(obj.get()); if (!item) { LL_WARNS() << "Invalid inventory item for drop" << LL_ENDL; @@ -3097,13 +3126,13 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, // coming from a task. Need to figure out if the person can // move/copy this item. LLPermissions perm(item->getPermissions()); - if((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID()) + if ((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID()) && perm.allowTransferTo(gAgent.getID()))) // || gAgent.isGodlike()) { accept = true; } - else if(object->permYouOwner()) + else if (object->permYouOwner()) { // If the object cannot be copied, but the object the // inventory is owned by the agent, then the item can be @@ -3123,22 +3152,21 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, } } - if(drop && accept) + if (drop && accept) { - it = inventory_objects.begin(); std::shared_ptr<LLMoveInv> move_inv(new LLMoveInv); move_inv->mObjectID = object_id; move_inv->mCategoryID = category_id; move_inv->mCallback = callback; move_inv->mUserData = user_data; - for ( ; it != end; ++it) + for (LLPointer<LLInventoryObject> obj : inventory_objects) { - two_uuids_t two(category_id, (*it)->getUUID()); + two_uuids_t two(category_id, obj->getUUID()); move_inv->mMoveList.push_back(two); } - if(is_move) + if (is_move) { // Callback called from within here. warn_move_inventory(object, move_inv); @@ -3156,13 +3184,13 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer) { // Bail out immediately if no descendents - if( mComplete.empty() ) + if (mComplete.empty()) { LL_WARNS() << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << LL_ENDL; if (clear_observer) { - gInventory.removeObserver(this); - delete this; + gInventory.removeObserver(this); + delete this; } return; } @@ -3186,13 +3214,13 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer) gInventory.getDirectDescendentsOf(*current_folder, cat_array, item_array); size_t item_count(0); - if( item_array ) + if (item_array) { item_count = item_array->size(); } size_t cat_count(0); - if( cat_array ) + if (cat_array) { cat_count = cat_array->size(); } @@ -3291,20 +3319,16 @@ protected: }; - void LLInventoryCopyAndWearObserver::changed(U32 mask) { - if((mask & (LLInventoryObserver::ADD)) != 0) + if ((mask & (LLInventoryObserver::ADD)) != 0) { if (!mFolderAdded) { const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); - - std::set<LLUUID>::const_iterator id_it = changed_items.begin(); - std::set<LLUUID>::const_iterator id_end = changed_items.end(); - for (;id_it != id_end; ++id_it) + for (const LLUUID& item_id : changed_items) { - if ((*id_it) == mCatID) + if (item_id == mCatID) { mFolderAdded = true; break; @@ -3322,8 +3346,7 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask) } else { - if (category->getDescendentCount() == - mContentsCount) + if (category->getDescendentCount() == mContentsCount) { gInventory.removeObserver(this); LLAppearanceMgr::instance().wearInventoryCategory(category, false, !mReplace); @@ -3335,8 +3358,6 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask) } } - - void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) { if ("open" == action) @@ -3429,19 +3450,19 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) LLMarketplaceValidator::getInstance()->validateMarketplaceListings( version_folder_id, [this](bool result) - { - // todo: might need to ensure bridge/mUUID exists or this will cause crashes - if (!result) { - LLSD subs; - subs["[ERROR_CODE]"] = mMessage; - LLNotificationsUtil::add("MerchantListingFailed", subs); - } - else - { - LLMarketplaceData::instance().activateListing(mUUID, true); - } - }, + // todo: might need to ensure bridge/mUUID exists or this will cause crashes + if (!result) + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantListingFailed", subs); + } + else + { + LLMarketplaceData::instance().activateListing(mUUID, true); + } + }, boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3) ); } @@ -3456,19 +3477,19 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) LLMarketplaceValidator::getInstance()->validateMarketplaceListings( mUUID, [this](bool result) - { - if (!result) { - LLSD subs; - subs["[ERROR_CODE]"] = mMessage; - LLNotificationsUtil::add("MerchantFolderActivationFailed", subs); - } - else - { - LLInventoryCategory* category = gInventory.getCategory(mUUID); - LLMarketplaceData::instance().setVersionFolder(category->getParentUUID(), mUUID); - } - }, + if (!result) + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantFolderActivationFailed", subs); + } + else + { + LLInventoryCategory* category = gInventory.getCategory(mUUID); + LLMarketplaceData::instance().setVersionFolder(category->getParentUUID(), mUUID); + } + }, boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), false, 2); @@ -3500,35 +3521,35 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) LLMarketplaceValidator::getInstance()->validateMarketplaceListings( mUUID, [this](bool result) - { - if (!result) { - mMessage = ""; - - LLMarketplaceValidator::getInstance()->validateMarketplaceListings( - mUUID, - [this](bool result) + if (!result) { - if (result) - { - LLNotificationsUtil::add("MerchantForceValidateListing"); - LLMarketplaceData::instance().createListing(mUUID); - } - else + mMessage = ""; + + LLMarketplaceValidator::getInstance()->validateMarketplaceListings( + mUUID, + [this](bool result) { - LLSD subs; - subs["[ERROR_CODE]"] = mMessage; - LLNotificationsUtil::add("MerchantListingFailed", subs); - } - }, - boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), - true); - } - else - { - LLMarketplaceData::instance().createListing(mUUID); - } - }, + if (result) + { + LLNotificationsUtil::add("MerchantForceValidateListing"); + LLMarketplaceData::instance().createListing(mUUID); + } + else + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantListingFailed", subs); + } + }, + boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), + true); + } + else + { + LLMarketplaceData::instance().createListing(mUUID); + } + }, boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), false); @@ -3607,7 +3628,7 @@ void LLFolderBridge::copyOutfitToClipboard() gInventory.getDirectDescendentsOf(mUUID, cat_array, item_array); size_t item_count(0); - if( item_array ) + if (item_array) { item_count = item_array->size(); } @@ -3699,8 +3720,7 @@ void LLFolderBridge::restoreItem() LLFolderType::EType LLFolderBridge::getPreferredType() const { LLFolderType::EType preferred_type = LLFolderType::FT_NONE; - LLViewerInventoryCategory* cat = getCategory(); - if(cat) + if (LLViewerInventoryCategory* cat = getCategory()) { preferred_type = cat->getPreferredType(); } @@ -3742,7 +3762,6 @@ LLUIImagePtr LLFolderBridge::getIconOverlay() const bool LLFolderBridge::renameItem(const std::string& new_name) { - LLScrollOnRenameObserver *observer = new LLScrollOnRenameObserver(mUUID, mRoot); gInventory.addObserver(observer); @@ -3755,7 +3774,7 @@ bool LLFolderBridge::renameItem(const std::string& new_name) bool LLFolderBridge::removeItem() { - if(!isItemRemovable()) + if (!isItemRemovable()) { return false; } @@ -3771,7 +3790,6 @@ bool LLFolderBridge::removeItem() return true; } - bool LLFolderBridge::removeSystemFolder() { const LLViewerInventoryCategory *cat = getCategory(); diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index e3d4645701..01f2c6c525 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -103,7 +103,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) } std::string desc = listener->getSearchableCreatorName(); - switch(mSearchType) + switch (mSearchType) { case SEARCHTYPE_CREATOR: desc = listener->getSearchableCreatorName(); @@ -129,7 +129,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) boost::char_separator<char> sep(" "); tokenizer tokens(desc, sep); - for (auto token_iter : tokens) + for (const auto& token_iter : tokens) { if (token_iter == mExactToken) { @@ -138,9 +138,9 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) } } } - else if ((mFilterTokens.size() > 0) && (mSearchType == SEARCHTYPE_NAME)) + else if (!mFilterTokens.empty() && mSearchType == SEARCHTYPE_NAME) { - for (auto token_iter : mFilterTokens) + for (const auto& token_iter : mFilterTokens) { if (desc.find(token_iter) == std::string::npos) { @@ -150,7 +150,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) } else { - passed = (mFilterSubString.size() ? desc.find(mFilterSubString) != std::string::npos : true); + passed = checkAgainstFilterSubString(desc); } passed = passed && checkAgainstFilterType(listener); @@ -166,7 +166,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) bool LLInventoryFilter::check(const LLInventoryItem* item) { - const bool passed_string = (mFilterSubString.size() ? item->getName().find(mFilterSubString) != std::string::npos : true); + const bool passed_string = checkAgainstFilterSubString(item->getName()); const bool passed_filtertype = checkAgainstFilterType(item); const bool passed_permissions = checkAgainstPermissions(item); @@ -295,9 +295,19 @@ bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const return true; } +bool LLInventoryFilter::checkAgainstFilterSubString(const std::string& desc) const +{ + if (mFilterSubString.empty()) + return true; + + size_t pos = desc.find(mFilterSubString); + return pos != std::string::npos; +} + bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return false; + if (!listener) + return false; LLInventoryType::EType object_type = listener->getInventoryType(); const LLUUID object_id = listener->getUUID(); @@ -338,7 +348,7 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent } } - if(filterTypes & FILTERTYPE_WORN) + if (filterTypes & FILTERTYPE_WORN) { if (!get_is_item_worn(object_id)) { @@ -351,7 +361,8 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { - if (!object) return false; + if (!object) + return false; if (object->getLinkedUUID() != mFilterOps.mFilterUUID) return false; @@ -363,7 +374,7 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent if (filterTypes & FILTERTYPE_DATE) { const U16 HOURS_TO_SECONDS = 3600; - time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS; + time_t earliest = time_corrected() - (U64)mFilterOps.mHoursAgo * HOURS_TO_SECONDS; if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest) { @@ -494,7 +505,8 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { - if (!item) return false; + if (!item) + return false; if (item->getLinkedUUID() != mFilterOps.mFilterUUID) return false; @@ -540,7 +552,8 @@ bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const bool LLInventoryFilter::checkAgainstPermissions(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return false; + if (!listener) + return false; PermissionMask perm = listener->getPermissionMask(); const LLInvFVBridge *bridge = dynamic_cast<const LLInvFVBridge *>(listener); @@ -556,7 +569,8 @@ bool LLInventoryFilter::checkAgainstPermissions(const LLFolderViewModelItemInven bool LLInventoryFilter::checkAgainstPermissions(const LLInventoryItem* item) const { - if (!item) return false; + if (!item) + return false; LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); PermissionMask perm = new_item->getPermissionMask(); @@ -567,11 +581,13 @@ bool LLInventoryFilter::checkAgainstPermissions(const LLInventoryItem* item) con bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return true; + if (!listener) + return true; const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return true; + if (!object) + return true; const bool is_link = object->getIsLinkType(); if (is_link && (mFilterOps.mFilterLinks == FILTERLINK_EXCLUDE_LINKS)) @@ -584,7 +600,8 @@ bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInven bool LLInventoryFilter::checkAgainstFilterThumbnails(const LLUUID& object_id) const { const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return true; + if (!object) + return true; const bool is_thumbnail = object->getThumbnailUUID().notNull(); if (is_thumbnail && (mFilterOps.mFilterThumbnails == FILTER_EXCLUDE_THUMBNAILS)) @@ -596,16 +613,20 @@ bool LLInventoryFilter::checkAgainstFilterThumbnails(const LLUUID& object_id) co bool LLInventoryFilter::checkAgainstCreator(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return true; + if (!listener) + return true; + const bool is_folder = listener->getInventoryType() == LLInventoryType::IT_CATEGORY; switch (mFilterOps.mFilterCreatorType) { case FILTERCREATOR_SELF: - if(is_folder) return false; - return (listener->getSearchableCreatorName() == mUsername); + if (is_folder) + return false; + return listener->getSearchableCreatorName() == mUsername; case FILTERCREATOR_OTHERS: - if(is_folder) return false; - return (listener->getSearchableCreatorName() != mUsername); + if (is_folder) + return false; + return listener->getSearchableCreatorName() != mUsername; case FILTERCREATOR_ALL: default: return true; @@ -618,7 +639,8 @@ bool LLInventoryFilter::checkAgainstSearchVisibility(const LLFolderViewModelItem const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return true; + if (!object) + return true; const bool is_link = object->getIsLinkType(); if (is_link && ((mFilterOps.mSearchVisibility & VISIBILITY_LINKS) == 0)) @@ -647,10 +669,8 @@ std::string::size_type LLInventoryFilter::getStringMatchOffset(LLFolderViewModel { return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos; } - else - { - return std::string::npos; - } + + return std::string::npos; } bool LLInventoryFilter::isDefault() const @@ -725,7 +745,7 @@ void LLInventoryFilter::updateFilterTypes(U64 types, U64& current_types) void LLInventoryFilter::setSearchType(ESearchType type) { - if(mSearchType != type) + if (mSearchType != type) { mSearchType = type; setModified(); @@ -918,6 +938,7 @@ void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) { setModified(FILTER_RESTART); } + mFilterOps.mFilterUUID = object_id; mFilterOps.mFilterTypes = FILTERTYPE_UUID; } @@ -931,7 +952,6 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) if (mFilterSubString != filter_sub_string_new) { - mFilterTokens.clear(); if (filter_sub_string_new.find_first_of("+") != std::string::npos) { @@ -939,7 +959,7 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) boost::char_separator<char> sep("+"); tokenizer tokens(filter_sub_string_new, sep); - for (auto token_iter : tokens) + for (const auto& token_iter : tokens) { mFilterTokens.push_back(token_iter); } @@ -1005,7 +1025,7 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) } // Cancel out UUID once the search string is modified - if (mFilterOps.mFilterTypes == FILTERTYPE_UUID) + if (mFilterOps.mFilterTypes & FILTERTYPE_UUID) { mFilterOps.mFilterTypes &= ~FILTERTYPE_UUID; mFilterOps.mFilterUUID = LLUUID::null; @@ -1243,7 +1263,7 @@ void LLInventoryFilter::setFindAllLinksMode(const std::string &search_name, cons { // Save a copy of settings so that we will be able to restore it later // but make sure we are not searching for links already - if(mFilterOps.mFilterLinks != FILTERLINK_ONLY_LINKS) + if (mFilterOps.mFilterLinks != FILTERLINK_ONLY_LINKS) { mBackupFilterOps = mFilterOps; } @@ -1283,7 +1303,7 @@ void LLInventoryFilter::setModified(EFilterModified behavior) } // if not keeping current filter results, update last valid as well - switch(mFilterModified) + switch (mFilterModified) { case FILTER_RESTART: mFirstRequiredGeneration = mCurrentGeneration; @@ -1499,11 +1519,11 @@ const std::string& LLInventoryFilter::getFilterText() { mFilterText += LLTrans::getString("Since Logoff"); } + return mFilterText; } - -LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& other ) +LLInventoryFilter& LLInventoryFilter::operator =(const LLInventoryFilter& other) { setFilterObjectTypes(other.getFilterObjectTypes()); setDateRange(other.getMinDate(), other.getMaxDate()); @@ -1516,7 +1536,6 @@ LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& othe return *this; } - void LLInventoryFilter::toParams(Params& params) const { params.filter_ops.types = (U32)getFilterObjectTypes(); @@ -1686,14 +1705,13 @@ std::string LLInventoryFilter::getEmptyLookupMessage(bool is_empty_folder) const return LLTrans::getString(mEmptyLookupMessage, args); } - } -bool LLInventoryFilter::areDateLimitsSet() +bool LLInventoryFilter::areDateLimitsSet() const { - return mFilterOps.mMinDate != time_min() - || mFilterOps.mMaxDate != time_max() - || mFilterOps.mHoursAgo != 0; + return mFilterOps.mMinDate != time_min() + || mFilterOps.mMaxDate != time_max() + || mFilterOps.mHoursAgo != 0; } bool LLInventoryFilter::showAllResults() const @@ -1701,8 +1719,6 @@ bool LLInventoryFilter::showAllResults() const return hasFilterString() && !mSingleFolderMode; } - - bool LLInventoryFilter::FilterOps::DateRange::validateBlock( bool emit_errors /*= true*/ ) const { bool valid = LLInitParam::Block<DateRange>::validateBlock(emit_errors); diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 7203c6f743..612a161ba2 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -45,7 +45,8 @@ public: SHOW_NO_FOLDERS }; - enum EFilterType { + enum EFilterType + { FILTERTYPE_NONE = 0, FILTERTYPE_OBJECT = 0x1 << 0, // normal default search-by-object-type FILTERTYPE_CATEGORY = 0x1 << 1, // search by folder type @@ -275,9 +276,9 @@ public: // +-------------------------------------------------------------------+ // + Execution And Results // +-------------------------------------------------------------------+ - bool check(const LLFolderViewModelItem* listener); + bool check(const LLFolderViewModelItem* item); bool check(const LLInventoryItem* item); - bool checkFolder(const LLFolderViewModelItem* listener) const; + bool checkFolder(const LLFolderViewModelItem* item) const; bool checkFolder(const LLUUID& folder_id) const; bool showAllResults() const; @@ -340,7 +341,8 @@ public: bool checkAgainstFilterThumbnails(const LLUUID& object_id) const; private: - bool areDateLimitsSet(); + bool areDateLimitsSet() const; + bool checkAgainstFilterSubString(const std::string& desc) const; bool checkAgainstFilterType(const class LLFolderViewModelItemInventory* listener) const; bool checkAgainstFilterType(const LLInventoryItem* item) const; bool checkAgainstPermissions(const class LLFolderViewModelItemInventory* listener) const; diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 57c0d57190..dadd0590a9 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2400,18 +2400,16 @@ void ungroup_folder_items(const LLUUID& folder_id) LLInventoryModel::cat_array_t cats = *cat_array; LLInventoryModel::item_array_t items = *item_array; - for (LLInventoryModel::cat_array_t::const_iterator cat_iter = cats.begin(); cat_iter != cats.end(); ++cat_iter) + for (const LLPointer<LLViewerInventoryCategory>& cat : cats) { - LLViewerInventoryCategory* cat = *cat_iter; if (cat) { gInventory.changeCategoryParent(cat, new_cat_uuid, false); } } - for (LLInventoryModel::item_array_t::const_iterator item_iter = items.begin(); item_iter != items.end(); ++item_iter) + for (const LLPointer<LLViewerInventoryItem>& item : items) { - LLViewerInventoryItem* item = *item_iter; - if(item) + if (item) { gInventory.changeItemParent(item, new_cat_uuid, false); } @@ -2424,8 +2422,7 @@ std::string get_searchable_description(LLInventoryModel* model, const LLUUID& it { if (model) { - const LLInventoryItem *item = model->getItem(item_id); - if(item) + if (const LLInventoryItem* item = model->getItem(item_id)) { std::string desc = item->getDescription(); LLStringUtil::toUpper(desc); @@ -2439,8 +2436,7 @@ std::string get_searchable_creator_name(LLInventoryModel* model, const LLUUID& i { if (model) { - const LLInventoryItem *item = model->getItem(item_id); - if(item) + if (const LLInventoryItem* item = model->getItem(item_id)) { LLAvatarName av_name; if (LLAvatarNameCache::get(item->getCreatorUUID(), &av_name)) diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 46d1e822de..c4f93cee98 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -2649,7 +2649,8 @@ bool LLInventoryGallery::hasDescendents(const LLUUID& cat_id) bool LLInventoryGallery::checkAgainstFilterType(const LLUUID& object_id) { const LLInventoryObject *object = gInventory.getObject(object_id); - if(!object) return false; + if (!object) + return false; LLInventoryType::EType object_type = LLInventoryType::IT_CATEGORY; LLInventoryItem* inv_item = gInventory.getItem(object_id); @@ -2657,8 +2658,8 @@ bool LLInventoryGallery::checkAgainstFilterType(const LLUUID& object_id) { object_type = inv_item->getInventoryType(); } - const U32 filterTypes = (U32)mFilter->getFilterTypes(); + const U32 filterTypes = (U32)mFilter->getFilterTypes(); if ((filterTypes & LLInventoryFilter::FILTERTYPE_OBJECT) && inv_item) { switch (object_type) @@ -2726,7 +2727,7 @@ bool LLInventoryGallery::hasVisibleItems() void LLInventoryGallery::handleModifiedFilter() { - if(mFilter->isModified()) + if (mFilter->isModified()) { reArrangeRows(); } @@ -2737,7 +2738,7 @@ void LLInventoryGallery::setSortOrder(U32 order, bool update) bool dirty = (mSortOrder != order); mSortOrder = order; - if(update && dirty) + if (update && dirty) { mNeedsArrange = true; gIdleCallbacks.addFunction(onIdle, (void*)this); @@ -2789,11 +2790,11 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E mIsLink = is_link; std::string icon_name = LLInventoryIcon::getIconName(mType, inventory_type, flags); - if(mIsFolder) + if (mIsFolder) { mSortGroup = SG_NORMAL_FOLDER; LLUUID folder_id = mUUID; - if(mIsLink) + if (mIsLink) { LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj) @@ -2820,7 +2821,7 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E else { const LLInventoryItem *item = gInventory.getItem(mUUID); - if(item && (LLAssetType::AT_CALLINGCARD != item->getType()) && !mIsLink) + if (item && (LLAssetType::AT_CALLINGCARD != item->getType()) && !mIsLink) { std::string delim(" --"); bool copy = item->getPermissions().allowCopyBy(gAgent.getID()); @@ -2851,7 +2852,7 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E void LLInventoryGalleryItem::setThumbnail(LLUUID id) { mDefaultImage = id.isNull(); - if(mDefaultImage) + if (mDefaultImage) { mThumbnailCtrl->clearTexture(); } @@ -2900,10 +2901,10 @@ void LLInventoryGalleryItem::setSelected(bool value) mSelected = value; mTextBgPanel->setBackgroundVisible(value); - if(mSelected) + if (mSelected) { LLViewerInventoryItem* item = gInventory.getItem(mUUID); - if(item && !item->isFinished()) + if (item && !item->isFinished()) { LLInventoryModelBackgroundFetch::instance().start(mUUID, false); } @@ -2926,6 +2927,7 @@ bool LLInventoryGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) { mGallery->changeItemSelection(mUUID, false); } + setFocus(true); mGallery->claimEditHandler(); @@ -2958,7 +2960,7 @@ bool LLInventoryGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) bool LLInventoryGalleryItem::handleMouseUp(S32 x, S32 y, MASK mask) { - if(hasMouseCapture()) + if (hasMouseCapture()) { gFocusMgr.setMouseCapture(NULL); return true; @@ -2968,13 +2970,13 @@ bool LLInventoryGalleryItem::handleMouseUp(S32 x, S32 y, MASK mask) bool LLInventoryGalleryItem::handleHover(S32 x, S32 y, MASK mask) { - if(hasMouseCapture()) + if (hasMouseCapture()) { S32 screen_x; S32 screen_y; localPointToScreen(x, y, &screen_x, &screen_y ); - if(LLToolDragAndDrop::getInstance()->isOverThreshold(screen_x, screen_y) && mGallery) + if (LLToolDragAndDrop::getInstance()->isOverThreshold(screen_x, screen_y) && mGallery) { mGallery->startDrag(); return LLToolDragAndDrop::getInstance()->handleHover(x, y, mask); @@ -2993,13 +2995,13 @@ bool LLInventoryGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask) LLHandle<LLPanel> handle = mGallery->getHandle(); LLUUID navigate_to = mUUID; doOnIdleOneTime([handle, navigate_to]() - { - LLInventoryGallery* gallery = (LLInventoryGallery*)handle.get(); - if (gallery) - { - gallery->setRootFolder(navigate_to); - } - }); + { + LLInventoryGallery* gallery = (LLInventoryGallery*)handle.get(); + if (gallery) + { + gallery->setRootFolder(navigate_to); + } + }); } else { @@ -3078,7 +3080,7 @@ void LLInventoryGalleryItem::setWorn(bool value) { mWorn = value; - if(mWorn) + if (mWorn) { mWornSuffix = (mType == LLAssetType::AT_GESTURE) ? LLTrans::getString("active") : LLTrans::getString("worn"); } @@ -3092,7 +3094,7 @@ void LLInventoryGalleryItem::setWorn(bool value) LLFontGL* LLInventoryGalleryItem::getTextFont() { - if(mWorn) + if (mWorn) { return LLFontGL::getFontSansSerifSmallBold(); } @@ -3127,12 +3129,10 @@ bool LLInventoryGalleryItem::isFadeItem() void LLThumbnailsObserver::changed(U32 mask) { std::vector<LLUUID> deleted_ids; - for (item_map_t::iterator iter = mItemMap.begin(); - iter != mItemMap.end(); - ++iter) + for (item_map_t::value_type& it : mItemMap) { - const LLUUID& obj_id = (*iter).first; - LLItemData& data = (*iter).second; + const LLUUID& obj_id = it.first; + LLItemData& data = it.second; LLInventoryObject* obj = gInventory.getObject(obj_id); if (!obj) @@ -3158,8 +3158,7 @@ void LLThumbnailsObserver::changed(U32 mask) bool LLThumbnailsObserver::addItem(const LLUUID& obj_id, callback_t cb) { - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (obj) + if (LLInventoryObject* obj = gInventory.getObject(obj_id)) { mItemMap.insert(item_map_value_t(obj_id, LLItemData(obj_id, obj->getThumbnailUUID(), cb))); return true; @@ -3190,79 +3189,74 @@ bool LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, bool drop, } bool accepted = false; - switch(cargo_type) - { - case DAD_TEXTURE: - case DAD_SOUND: - case DAD_CALLINGCARD: - case DAD_LANDMARK: - case DAD_SCRIPT: - case DAD_CLOTHING: - case DAD_OBJECT: - case DAD_NOTECARD: - case DAD_BODYPART: - case DAD_ANIMATION: - case DAD_GESTURE: - case DAD_MESH: - case DAD_SETTINGS: + switch (cargo_type) + { + case DAD_TEXTURE: + case DAD_SOUND: + case DAD_CALLINGCARD: + case DAD_LANDMARK: + case DAD_SCRIPT: + case DAD_CLOTHING: + case DAD_OBJECT: + case DAD_NOTECARD: + case DAD_BODYPART: + case DAD_ANIMATION: + case DAD_GESTURE: + case DAD_MESH: + case DAD_SETTINGS: + accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); + if (accepted && drop) + { + // Don't select immediately, wait for item to arrive + mItemsToSelect.push_back(inv_item->getUUID()); + } + break; + case DAD_LINK: + // DAD_LINK type might mean one of two asset types: AT_LINK or AT_LINK_FOLDER. + // If we have an item of AT_LINK_FOLDER type we should process the linked + // category being dragged or dropped into folder. + if (inv_item && LLAssetType::AT_LINK_FOLDER == inv_item->getActualType()) + { + LLInventoryCategory* linked_category = gInventory.getCategory(inv_item->getLinkedUUID()); + if (linked_category) + { + accepted = dragCategoryIntoFolder(dest_id, (LLInventoryCategory*)linked_category, drop, tooltip_msg, true); + } + } + else + { accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); + } + if (accepted && drop && inv_item) + { + mItemsToSelect.push_back(inv_item->getUUID()); + } + break; + case DAD_CATEGORY: + if (LLFriendCardsManager::instance().isAnyFriendCategory(dest_id)) + { + accepted = false; + } + else + { + LLInventoryCategory* cat_ptr = (LLInventoryCategory*)cargo_data; + accepted = dragCategoryIntoFolder(dest_id, cat_ptr, drop, tooltip_msg, false); if (accepted && drop) { - // Don't select immediately, wait for item to arrive - mItemsToSelect.push_back(inv_item->getUUID()); - } - break; - case DAD_LINK: - // DAD_LINK type might mean one of two asset types: AT_LINK or AT_LINK_FOLDER. - // If we have an item of AT_LINK_FOLDER type we should process the linked - // category being dragged or dropped into folder. - if (inv_item && LLAssetType::AT_LINK_FOLDER == inv_item->getActualType()) - { - LLInventoryCategory* linked_category = gInventory.getCategory(inv_item->getLinkedUUID()); - if (linked_category) - { - accepted = dragCategoryIntoFolder(dest_id, (LLInventoryCategory*)linked_category, drop, tooltip_msg, true); - } - } - else - { - accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); - } - if (accepted && drop && inv_item) - { - mItemsToSelect.push_back(inv_item->getUUID()); - } - break; - case DAD_CATEGORY: - if (LLFriendCardsManager::instance().isAnyFriendCategory(dest_id)) - { - accepted = false; - } - else - { - LLInventoryCategory* cat_ptr = (LLInventoryCategory*)cargo_data; - accepted = dragCategoryIntoFolder(dest_id, cat_ptr, drop, tooltip_msg, false); - if (accepted && drop) - { - mItemsToSelect.push_back(cat_ptr->getUUID()); - } + mItemsToSelect.push_back(cat_ptr->getUUID()); } - break; - case DAD_ROOT_CATEGORY: - case DAD_NONE: - break; - default: - LL_WARNS() << "Unhandled cargo type for drag&drop " << cargo_type << LL_ENDL; - break; - } - if (accepted) - { - *accept = ACCEPT_YES_MULTI; - } - else - { - *accept = ACCEPT_NO; + } + break; + case DAD_ROOT_CATEGORY: + case DAD_NONE: + break; + default: + LL_WARNS() << "Unhandled cargo type for drag&drop " << cargo_type << LL_ENDL; + break; } + + *accept = accepted ? ACCEPT_YES_MULTI : ACCEPT_NO; + return accepted; } @@ -3274,16 +3268,20 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, { return false; } - LLInventoryModel* model = &gInventory; - if (!model || !inv_item) return false; + LLInventoryModel* model = &gInventory; + if (!model || !inv_item) + return false; // cannot drag into library - if((gInventory.getRootFolderID() != folder_id) && !model->isObjectDescendentOf(folder_id, gInventory.getRootFolderID())) + if (gInventory.getRootFolderID() != folder_id && + !model->isObjectDescendentOf(folder_id, gInventory.getRootFolderID())) { return false; } - if (!isAgentAvatarValid()) return false; + + if (!isAgentAvatarValid()) + return false; const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); const LLUUID &favorites_id = model->findCategoryUUIDForType(LLFolderType::FT_FAVORITE); @@ -3302,7 +3300,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource(); bool accept = false; LLViewerObject* object = NULL; - if(LLToolDragAndDrop::SOURCE_AGENT == source) + if (LLToolDragAndDrop::SOURCE_AGENT == source) { const LLUUID &trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); @@ -3317,21 +3315,24 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, switch (inv_item->getActualType()) { - case LLAssetType::AT_CATEGORY: - is_movable = !LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)inv_item)->getPreferredType()); - break; - default: - break; + case LLAssetType::AT_CATEGORY: + is_movable = !LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)inv_item)->getPreferredType()); + break; + default: + break; } + // Can't explicitly drag things out of the COF. if (move_is_outof_current_outfit) { is_movable = false; } + if (move_is_into_trash) { is_movable &= inv_item->getIsLinkType() || !get_is_item_worn(inv_item->getUUID()); } + if (is_movable) { // Don't allow creating duplicates in the Calling Card/Friends @@ -3540,7 +3541,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, move_inv->mMoveList.push_back(item_pair); move_inv->mCallback = NULL; move_inv->mUserData = NULL; - if(is_move) + if (is_move) { warn_move_inventory(object, move_inv); } @@ -3555,7 +3556,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, } } } - else if(LLToolDragAndDrop::SOURCE_NOTECARD == source) + else if (LLToolDragAndDrop::SOURCE_NOTECARD == source) { if (move_is_into_marketplacelistings) { @@ -3582,7 +3583,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, inv_item); } } - else if(LLToolDragAndDrop::SOURCE_LIBRARY == source) + else if (LLToolDragAndDrop::SOURCE_LIBRARY == source) { LLViewerInventoryItem* item = (LLViewerInventoryItem*)inv_item; if(item && item->isFinished()) @@ -3665,11 +3666,14 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, return false; } - if (!inv_cat) return false; // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL + if (!inv_cat) // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL + return false; + + if (!isAgentAvatarValid()) + return false; - if (!isAgentAvatarValid()) return false; // cannot drag into library - if((gInventory.getRootFolderID() != dest_id) && !model->isObjectDescendentOf(dest_id, gInventory.getRootFolderID())) + if ((gInventory.getRootFolderID() != dest_id) && !model->isObjectDescendentOf(dest_id, gInventory.getRootFolderID())) { return false; } @@ -3758,7 +3762,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, is_movable = false; } } - else if(dest_cat && dest_cat->getPreferredType() == LLFolderType::FT_NONE) + else if (dest_cat && dest_cat->getPreferredType() == LLFolderType::FT_NONE) { is_movable = ((inv_cat->getPreferredType() == LLFolderType::FT_NONE) || (inv_cat->getPreferredType() == LLFolderType::FT_OUTFIT)); } @@ -3767,7 +3771,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, is_movable = false; } } - if(is_movable && move_is_into_current_outfit && is_link) + if (is_movable && move_is_into_current_outfit && is_link) { is_movable = false; } @@ -3795,7 +3799,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, for (S32 i=0; i < descendent_categories.size(); ++i) { LLInventoryCategory* category = descendent_categories[i]; - if(LLFolderType::lookupIsProtectedType(category->getPreferredType())) + if (LLFolderType::lookupIsProtectedType(category->getPreferredType())) { // Can't move "special folders" (e.g. Textures Folder). is_movable = false; @@ -4000,7 +4004,6 @@ void outfitFolderCreatedCallback(LLUUID cat_source_id, LLUUID cat_dest_id) LLInventoryObject::const_object_list_t link_array; - LLInventoryModel::item_array_t::iterator iter = items->begin(); LLInventoryModel::item_array_t::iterator end = items->end(); while (iter!=end) @@ -4038,4 +4041,3 @@ void dropToMyOutfits(LLInventoryCategory* inv_cat) inventory_func_type func = boost::bind(&outfitFolderCreatedCallback, inv_cat->getUUID(), _1); gInventory.createNewCategory(dest_id, LLFolderType::FT_OUTFIT, inv_cat->getName(), func, inv_cat->getThumbnailUUID()); } - diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 6024a6319c..015d987a2f 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -414,8 +414,10 @@ void LLInventoryPanel::setFilterTypes(U64 types, LLInventoryFilter::EFilterType { getFilter().setFilterObjectTypes(types); } - if (filter_type == LLInventoryFilter::FILTERTYPE_CATEGORY) + else if (filter_type == LLInventoryFilter::FILTERTYPE_CATEGORY) + { getFilter().setFilterCategoryTypes(types); + } } void LLInventoryPanel::setFilterWorn() diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 4eaf69c39d..10a1cd6b71 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -637,18 +637,24 @@ void LLJoystickCameraRotate::drawRotatedImage( LLPointer<LLUIImage> image, S32 r gGL.color4fv(UI_VERTEX_COLOR.mV); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { - gGL.texCoord2fv( uv[ (rotations + 0) % 4]); - gGL.vertex2i(width, height ); + gGL.texCoord2fv(uv[(rotations + 0) % 4]); + gGL.vertex2i(width, height); + + gGL.texCoord2fv(uv[(rotations + 1) % 4]); + gGL.vertex2i(0, 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 + 0) % 4]); + gGL.vertex2i(width, height); - gGL.texCoord2fv( uv[ (rotations + 2) % 4]); + gGL.texCoord2fv(uv[(rotations + 2) % 4]); gGL.vertex2i(0, 0); - gGL.texCoord2fv( uv[ (rotations + 3) % 4]); + gGL.texCoord2fv(uv[(rotations + 3) % 4]); gGL.vertex2i(width, 0); } gGL.end(); @@ -909,7 +915,7 @@ void LLJoystickQuaternion::drawRotatedImage(LLPointer<LLUIImage> image, S32 rota gGL.color4fv(UI_VERTEX_COLOR.mV); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2fv(uv[(rotations + 0) % 4]); gGL.vertex2i(width, height); @@ -920,6 +926,12 @@ void LLJoystickQuaternion::drawRotatedImage(LLPointer<LLUIImage> image, S32 rota gGL.texCoord2fv(uv[(rotations + 2) % 4]); gGL.vertex2i(0, 0); + gGL.texCoord2fv(uv[(rotations + 0) % 4]); + gGL.vertex2i(width, height); + + gGL.texCoord2fv(uv[(rotations + 1) % 4]); + gGL.vertex2i(0, height); + gGL.texCoord2fv(uv[(rotations + 3) % 4]); gGL.vertex2i(width, 0); } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 19868f3c3e..9966a8eedb 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -618,43 +618,22 @@ void LLManipScale::renderFaces( const LLBBox& bbox ) { gGL.color4fv( default_normal_color.mV ); LLGLDepthTest gls_depth(GL_FALSE); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLE_STRIP); { - // Face 0 - gGL.vertex3f(min.mV[VX], max.mV[VY], max.mV[VZ]); - gGL.vertex3f(min.mV[VX], min.mV[VY], max.mV[VZ]); - gGL.vertex3f(max.mV[VX], min.mV[VY], max.mV[VZ]); - gGL.vertex3f(max.mV[VX], max.mV[VY], max.mV[VZ]); - - // Face 1 - gGL.vertex3f(max.mV[VX], min.mV[VY], max.mV[VZ]); + gGL.vertex3f(min.mV[VX], max.mV[VY], min.mV[VZ]); + gGL.vertex3f(max.mV[VX], max.mV[VY], min.mV[VZ]); + gGL.vertex3f(min.mV[VX], min.mV[VY], min.mV[VZ]); gGL.vertex3f(max.mV[VX], min.mV[VY], min.mV[VZ]); + gGL.vertex3f(max.mV[VX], min.mV[VY], max.mV[VZ]); gGL.vertex3f(max.mV[VX], max.mV[VY], min.mV[VZ]); gGL.vertex3f(max.mV[VX], max.mV[VY], max.mV[VZ]); - - // Face 2 gGL.vertex3f(min.mV[VX], max.mV[VY], min.mV[VZ]); gGL.vertex3f(min.mV[VX], max.mV[VY], max.mV[VZ]); - gGL.vertex3f(max.mV[VX], max.mV[VY], max.mV[VZ]); - gGL.vertex3f(max.mV[VX], max.mV[VY], min.mV[VZ]); - - // Face 3 - gGL.vertex3f(min.mV[VX], max.mV[VY], max.mV[VZ]); - gGL.vertex3f(min.mV[VX], max.mV[VY], min.mV[VZ]); gGL.vertex3f(min.mV[VX], min.mV[VY], min.mV[VZ]); gGL.vertex3f(min.mV[VX], min.mV[VY], max.mV[VZ]); - - // Face 4 - gGL.vertex3f(min.mV[VX], min.mV[VY], max.mV[VZ]); - gGL.vertex3f(min.mV[VX], min.mV[VY], min.mV[VZ]); - gGL.vertex3f(max.mV[VX], min.mV[VY], min.mV[VZ]); gGL.vertex3f(max.mV[VX], min.mV[VY], max.mV[VZ]); - - // Face 5 - gGL.vertex3f(min.mV[VX], min.mV[VY], min.mV[VZ]); - gGL.vertex3f(min.mV[VX], max.mV[VY], min.mV[VZ]); - gGL.vertex3f(max.mV[VX], max.mV[VY], min.mV[VZ]); - gGL.vertex3f(max.mV[VX], min.mV[VY], min.mV[VZ]); + gGL.vertex3f(min.mV[VX], max.mV[VY], max.mV[VZ]); + gGL.vertex3f(max.mV[VX], max.mV[VY], max.mV[VZ]); } gGL.end(); } diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index c9c7d26d33..060fe0d600 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1676,9 +1676,9 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal, normal = -normal; } F32 d = -(selection_center * normal); - glh::vec4f plane(normal.mV[0], normal.mV[1], normal.mV[2], d ); + glm::vec4 plane(normal.mV[0], normal.mV[1], normal.mV[2], d ); - gGL.getModelviewMatrix().inverse().mult_vec_matrix(plane); + plane = glm::inverse(gGL.getModelviewMatrix()) * plane; static LLStaticHashedString sClipPlane("clip_plane"); gClipProgram.uniform4fv(sClipPlane, 1, plane.v); diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index b39a976ebd..202008f7f9 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -843,7 +843,7 @@ void LLMediaCtrl::draw() calcOffsetsAndSize(&x_offset, &y_offset, &width, &height); // draw the browser - gGL.begin( LLRender::QUADS ); + gGL.begin(LLRender::TRIANGLES); if (! media_plugin->getTextureCoordsOpenGL()) { // render using web browser reported width and height, instead of trying to invert GL scale @@ -856,6 +856,12 @@ void LLMediaCtrl::draw() gGL.texCoord2f( 0.f, max_v ); gGL.vertex2i( x_offset, y_offset ); + gGL.texCoord2f(max_u, 0.f); + gGL.vertex2i(x_offset + width, y_offset + height); + + gGL.texCoord2f(0.f, max_v); + gGL.vertex2i(x_offset, y_offset); + gGL.texCoord2f( max_u, max_v ); gGL.vertex2i( x_offset + width, y_offset ); } @@ -871,6 +877,12 @@ void LLMediaCtrl::draw() gGL.texCoord2f( 0.f, 0.f ); gGL.vertex2i( x_offset, y_offset ); + gGL.texCoord2f(max_u, max_v); + gGL.vertex2i(x_offset + width, y_offset + height); + + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(x_offset, y_offset); + gGL.texCoord2f( max_u, 0.f ); gGL.vertex2i( x_offset + width, y_offset ); } diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 26e2d8f319..a8585c7f23 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -77,6 +77,8 @@ #include "llinventorypanel.h" #include "lluploaddialog.h" #include "llfloaterreg.h" +#include "llvoavatarself.h" +#include "llskinningutil.h" #include "boost/iostreams/device/array.hpp" #include "boost/iostreams/stream.hpp" @@ -757,7 +759,7 @@ void log_upload_error(LLCore::HttpStatus status, const LLSD& content, << " (" << status.toTerseString() << ")" << LL_ENDL; std::ostringstream details; - typedef std::set<std::string> mav_errors_set_t; + typedef std::unordered_set<std::string> mav_errors_set_t; mav_errors_set_t mav_errors; if (content.has("error")) @@ -828,7 +830,8 @@ LLMeshRepoThread::LLMeshRepoThread() mHttpLargeOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID) + mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mWorkQueue("MeshRepoThread", 1024*1024) { LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); @@ -911,6 +914,10 @@ void LLMeshRepoThread::run() break; } + // run mWorkQueue for up to 8ms + static std::chrono::nanoseconds WorkTimeNanoSec{std::chrono::nanoseconds::rep(8 * 1000000) }; + mWorkQueue.runFor(WorkTimeNanoSec); + if (! mHttpRequestSet.empty()) { // Dispatch all HttpHandler notifications @@ -1322,7 +1329,7 @@ LLCore::HttpHandle LLMeshRepoThread::getByteRange(const std::string & url, bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) { - + LL_PROFILE_ZONE_SCOPED; if (!mHeaderMutex) { return false; @@ -1447,6 +1454,7 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) { + LL_PROFILE_ZONE_SCOPED; if (!mHeaderMutex) { return false; @@ -1554,6 +1562,7 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) { + LL_PROFILE_ZONE_SCOPED; if (!mHeaderMutex) { return false; @@ -1693,6 +1702,7 @@ void LLMeshRepoThread::decActiveHeaderRequests() //return false if failed to get header bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool can_retry) { + LL_PROFILE_ZONE_SCOPED; ++LLMeshRepository::sMeshRequestCount; { @@ -1756,6 +1766,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c //return false if failed to get mesh lod. bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, bool can_retry) { + LL_PROFILE_ZONE_SCOPED; if (!mHeaderMutex) { return false; @@ -1940,6 +1951,18 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes LLMeshRepository::sCacheBytesHeaders += (U32)header_size; } + // immediately request SkinInfo since we'll need it before we can render any LoD if it is present + { + LLMutexLock lock(gMeshRepo.mMeshMutex); + + if (gMeshRepo.mLoadingSkins.find(mesh_id) == gMeshRepo.mLoadingSkins.end()) + { + gMeshRepo.mLoadingSkins[mesh_id] = {}; // add an empty vector to indicate to main thread that we are loading skin info + } + } + + fetchMeshSkinInfo(mesh_id); + LLMutexLock lock(mMutex); // make sure only one thread access mPendingLOD at the same time. //check for pending requests @@ -1971,6 +1994,18 @@ EMeshProcessingResult LLMeshRepoThread::lodReceived(const LLVolumeParams& mesh_p { if (volume->getNumFaces() > 0) { + // if we have a valid SkinInfo, cache per-joint bounding boxes for this LOD + LLMeshSkinInfo* skin_info = mSkinMap[mesh_params.getSculptID()]; + if (skin_info && isAgentAvatarValid()) + { + for (S32 i = 0; i < volume->getNumFaces(); ++i) + { + // NOTE: no need to lock gAgentAvatarp as the state being checked is not changed after initialization + LLVolumeFace& face = volume->getVolumeFace(i); + LLSkinningUtil::updateRiggingInfo(skin_info, gAgentAvatarp, face); + } + } + LoadedMesh mesh(volume, mesh_params, lod); { LLMutexLock lock(mMutex); @@ -2014,18 +2049,19 @@ bool LLMeshRepoThread::skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 dat } { - LLMeshSkinInfo* info = nullptr; - try - { - info = new LLMeshSkinInfo(mesh_id, skin); - } - catch (const std::bad_alloc& ex) - { - LL_WARNS() << "Failed to allocate skin info with exception: " << ex.what() << LL_ENDL; - return false; + LLPointer<LLMeshSkinInfo> info = nullptr; + info = new LLMeshSkinInfo(mesh_id, skin); + + if (isAgentAvatarValid()) + { // joint numbers are consistent inside LLVOAvatar and animations, but inconsistent inside meshes, + // generate a map of mesh joint numbers to LLVOAvatar joint numbers + LLSkinningUtil::initJointNums(info, gAgentAvatarp); } - // LL_DEBUGS(LOG_MESH) << "info pelvis offset" << info.mPelvisOffset << LL_ENDL; + // remember the skin info in the background thread so we can use it + // to calculate per-joint bounding boxes when volumes are loaded + mSkinMap[mesh_id] = info; + { LLMutexLock lock(mMutex); mSkinInfoQ.push_back(info); @@ -2265,10 +2301,10 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures) S32 mesh_num = 0; S32 texture_num = 0; - std::set<LLViewerTexture* > textures; - std::map<LLViewerTexture*,S32> texture_index; + std::unordered_set<LLViewerTexture* > textures; + std::unordered_map<LLViewerTexture*,S32> texture_index; - std::map<LLModel*,S32> mesh_index; + std::unordered_map<LLModel*,S32> mesh_index; std::string model_name; S32 instance_num = 0; @@ -2957,7 +2993,7 @@ void LLMeshRepoThread::notifyLoadedMeshes() { if (mMutex->trylock()) { - std::deque<LLMeshSkinInfo*> skin_info_q; + std::deque<LLPointer<LLMeshSkinInfo>> skin_info_q; std::deque<UUIDBasedRequest> skin_info_unavail_q; std::list<LLModel::Decomposition*> decomp_q; @@ -3080,6 +3116,7 @@ S32 LLMeshRepository::getActualMeshLOD(LLMeshHeader& header, S32 lod) // are cases far off the norm. void LLMeshHandlerBase::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) { + LL_PROFILE_ZONE_SCOPED; mProcessed = true; unsigned int retries(0U); @@ -3356,6 +3393,7 @@ void LLMeshLODHandler::processFailure(LLCore::HttpStatus status) void LLMeshLODHandler::processData(LLCore::BufferArray * /* body */, S32 /* body_offset */, U8 * data, S32 data_size) { + LL_PROFILE_ZONE_SCOPED; if ((!MESH_LOD_PROCESS_FAILED) && ((data != NULL) == (data_size > 0))) // if we have data but no size or have size but no data, something is wrong { @@ -3421,6 +3459,7 @@ void LLMeshSkinInfoHandler::processFailure(LLCore::HttpStatus status) void LLMeshSkinInfoHandler::processData(LLCore::BufferArray * /* body */, S32 /* body_offset */, U8 * data, S32 data_size) { + LL_PROFILE_ZONE_SCOPED; if ((!MESH_SKIN_INFO_PROCESS_FAILED) && ((data != NULL) == (data_size > 0)) // if we have data but no size or have size but no data, something is wrong && gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size)) @@ -3470,6 +3509,7 @@ void LLMeshDecompositionHandler::processFailure(LLCore::HttpStatus status) void LLMeshDecompositionHandler::processData(LLCore::BufferArray * /* body */, S32 /* body_offset */, U8 * data, S32 data_size) { + LL_PROFILE_ZONE_SCOPED; if ((!MESH_DECOMP_PROCESS_FAILED) && ((data != NULL) == (data_size > 0)) // if we have data but no size or have size but no data, something is wrong && gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size)) @@ -3517,6 +3557,7 @@ void LLMeshPhysicsShapeHandler::processFailure(LLCore::HttpStatus status) void LLMeshPhysicsShapeHandler::processData(LLCore::BufferArray * /* body */, S32 /* body_offset */, U8 * data, S32 data_size) { + LL_PROFILE_ZONE_SCOPED; if ((!MESH_PHYS_SHAPE_PROCESS_FAILED) && ((data != NULL) == (data_size > 0)) // if we have data but no size or have size but no data, something is wrong && gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size) == MESH_OK) @@ -3651,20 +3692,63 @@ S32 LLMeshRepository::update() return static_cast<S32>(size); } -void LLMeshRepository::unregisterMesh(LLVOVolume* vobj) +void LLMeshRepository::unregisterMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_params, S32 detail) { - for (auto& lod : mLoadingMeshes) + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + + llassert((mesh_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH); + llassert(mesh_params.getSculptID().notNull()); + auto& lod = mLoadingMeshes[detail]; + auto param_iter = lod.find(mesh_params.getSculptID()); + if (param_iter != lod.end()) + { + vector_replace_with_last(param_iter->second, vobj); + llassert(!vector_replace_with_last(param_iter->second, vobj)); + if (param_iter->second.empty()) + { + lod.erase(param_iter); + } + } +} + +void LLMeshRepository::unregisterSkinInfo(const LLUUID& mesh_id, LLVOVolume* vobj) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + + llassert(mesh_id.notNull()); + auto skin_pair_iter = mLoadingSkins.find(mesh_id); + if (skin_pair_iter != mLoadingSkins.end()) { - for (auto& param : lod) + vector_replace_with_last(skin_pair_iter->second, vobj); + llassert(!vector_replace_with_last(skin_pair_iter->second, vobj)); + if (skin_pair_iter->second.empty()) { - vector_replace_with_last(param.second, vobj); + mLoadingSkins.erase(skin_pair_iter); } } +} + +// Lots of dead objects make expensive calls to +// LLMeshRepository::unregisterMesh which may delay shutdown. Avoid this by +// preemptively unregistering all meshes. +// We can also do this safely if all objects are confirmed dead for some other +// reason. +void LLMeshRepository::unregisterAllMeshes() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; - for (auto& skin_pair : mLoadingSkins) + // The size of mLoadingMeshes and mLoadingSkins may be large and thus + // expensive to iterate over in LLVOVolume::~LLVOVolume. + // This is unnecessary during shutdown, so we ignore the referenced objects in the + // least expensive way which is still safe: by clearing these containers. + // Clear now and not in LLMeshRepository::shutdown because + // LLMeshRepository::notifyLoadedMeshes could (depending on invocation + // order) reference a pointer to an object after it has been deleted. + for (auto& lod : mLoadingMeshes) { - vector_replace_with_last(skin_pair.second, vobj); + lod.clear(); } + mLoadingSkins.clear(); } S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_params, S32 detail, S32 last_lod) @@ -3859,6 +3943,7 @@ void LLMeshRepository::notifyLoadedMeshes() for (auto iter = mSkinMap.begin(), ender = mSkinMap.end(); iter != ender;) { auto copy_iter = iter++; + LLUUID id = copy_iter->first; //skinbytes += U64Bytes(sizeof(LLMeshSkinInfo)); //skinbytes += U64Bytes(copy_iter->second->mJointNames.size() * sizeof(std::string)); @@ -3870,6 +3955,12 @@ void LLMeshRepository::notifyLoadedMeshes() { mSkinMap.erase(copy_iter); } + + // erase from background thread + mThread->mWorkQueue.post([=]() + { + mThread->mSkinMap.erase(id); + }); } //LL_INFOS() << "Skin info cache elements:" << mSkinMap.size() << " Memory: " << U64Kilobytes(skinbytes) << LL_ENDL; } @@ -4206,7 +4297,7 @@ void LLMeshRepository::fetchPhysicsShape(const LLUUID& mesh_id) { LLMutexLock lock(mMeshMutex); //add volume to list of loading meshes - std::set<LLUUID>::iterator iter = mLoadingPhysicsShapes.find(mesh_id); + std::unordered_set<LLUUID>::iterator iter = mLoadingPhysicsShapes.find(mesh_id); if (iter == mLoadingPhysicsShapes.end()) { //no request pending for this skin info // *FIXME: Nothing ever deletes entries, can't be right @@ -4236,7 +4327,7 @@ LLModel::Decomposition* LLMeshRepository::getDecomposition(const LLUUID& mesh_id { LLMutexLock lock(mMeshMutex); //add volume to list of loading meshes - std::set<LLUUID>::iterator iter = mLoadingDecompositions.find(mesh_id); + std::unordered_set<LLUUID>::iterator iter = mLoadingDecompositions.find(mesh_id); if (iter == mLoadingDecompositions.end()) { //no request pending for this skin info mLoadingDecompositions.insert(mesh_id); @@ -4287,6 +4378,8 @@ bool LLMeshRepository::hasPhysicsShape(const LLUUID& mesh_id) bool LLMeshRepository::hasSkinInfo(const LLUUID& mesh_id) { + LL_PROFILE_ZONE_SCOPED; + if (mesh_id.isNull()) { return false; diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index b850ade0bb..d864a07615 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -28,6 +28,7 @@ #define LL_MESH_REPOSITORY_H #include <unordered_map> +#include <unordered_set> #include "llassettype.h" #include "llmodel.h" #include "lluuid.h" @@ -341,7 +342,7 @@ public: std::deque<UUIDBasedRequest> mSkinRequests; // list of completed skin info requests - std::deque<LLMeshSkinInfo*> mSkinInfoQ; + std::deque<LLPointer<LLMeshSkinInfo>> mSkinInfoQ; // list of skin info requests that have failed or are unavailaibe std::deque<UUIDBasedRequest> mSkinUnavailableQ; @@ -368,9 +369,17 @@ public: std::deque<LoadedMesh> mLoadedQ; //map of pending header requests and currently desired LODs - typedef boost::unordered_map<LLUUID, std::vector<S32> > pending_lod_map; + typedef std::unordered_map<LLUUID, std::vector<S32> > pending_lod_map; pending_lod_map mPendingLOD; + // map of mesh ID to skin info (mirrors LLMeshRepository::mSkinMap) + /// NOTE: LLMeshRepository::mSkinMap is accessed very frequently, so maintain a copy here to avoid mutex overhead + typedef std::unordered_map<LLUUID, LLPointer<LLMeshSkinInfo>> skin_map; + skin_map mSkinMap; + + // workqueue for processing generic requests + LL::WorkQueue mWorkQueue; + // llcorehttp library interface objects. LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; @@ -380,7 +389,7 @@ public: LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::policy_t mHttpLargePolicyClass; - typedef std::set<LLCore::HttpHandler::ptr_t> http_request_set; + typedef std::unordered_set<LLCore::HttpHandler::ptr_t> http_request_set; http_request_set mHttpRequestSet; // Outstanding HTTP requests std::string mGetMeshCapability; @@ -632,10 +641,12 @@ public: LLMeshRepository(); void init(); + void unregisterAllMeshes(); void shutdown(); S32 update(); - void unregisterMesh(LLVOVolume* volume); + void unregisterMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_params, S32 detail); + void unregisterSkinInfo(const LLUUID& mesh_id, LLVOVolume* vobj); //mesh management functions S32 loadMesh(LLVOVolume* volume, const LLVolumeParams& mesh_params, S32 detail = 0, S32 last_lod = -1); @@ -696,13 +707,13 @@ public: std::queue<LLUUID> mPendingSkinRequests; //list of mesh ids awaiting decompositions - std::set<LLUUID> mLoadingDecompositions; + std::unordered_set<LLUUID> mLoadingDecompositions; //list of mesh ids that need to send decomposition fetch requests std::queue<LLUUID> mPendingDecompositionRequests; //list of mesh ids awaiting physics shapes - std::set<LLUUID> mLoadingPhysicsShapes; + std::unordered_set<LLUUID> mLoadingPhysicsShapes; //list of mesh ids that need to send physics shape fetch requests std::queue<LLUUID> mPendingPhysicsShapeRequests; diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index e2c29bf241..1e8b7d39cc 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -2829,9 +2829,9 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights) LLMatrix4a mat_normal; if (skinned) { - glh::matrix4f m((F32*)mdl->mSkinInfo.mBindShapeMatrix.getF32ptr()); - m = m.inverse().transpose(); - mat_normal.loadu(m.m); + glm::mat4 m = glm::make_mat4((F32*)mdl->mSkinInfo.mBindShapeMatrix.getF32ptr()); + m = glm::transpose(glm::inverse(m)); + mat_normal.loadu(glm::value_ptr(m)); } S32 num_faces = mdl->getNumVolumeFaces(); diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 3f370b1ab5..af472c4259 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -298,15 +298,22 @@ void LLNetMap::draw() // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(left, top); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); + } gGL.end(); gGL.flush(); @@ -347,15 +354,22 @@ void LLNetMap::draw() F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); + } gGL.end(); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 7b78ad2934..dbf56c2b6d 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -31,6 +31,7 @@ // linden library includes #include "llerror.h" +#include "llfiltereditor.h" #include "llfloaterreg.h" #include "llfontgl.h" #include "llinventorydefines.h" @@ -83,8 +84,14 @@ bool LLPanelContents::postBuild() childSetAction("button new script",&LLPanelContents::onClickNewScript, this); childSetAction("button permissions",&LLPanelContents::onClickPermissions, this); + mFilterEditor = getChild<LLFilterEditor>("contents_filter"); + mFilterEditor->setCommitCallback([&](LLUICtrl*, const LLSD&) { onFilterEdit(); }); + mPanelInventoryObject = getChild<LLPanelObjectInventory>("contents_inventory"); + // update permission filter once UI is fully initialized + mSavedFolderState.setApply(false); + return true; } @@ -129,6 +136,38 @@ void LLPanelContents::getState(LLViewerObject *objectp ) mPanelInventoryObject->setEnabled(!objectp->isPermanentEnforced()); } +void LLPanelContents::onFilterEdit() +{ + const std::string& filter_substring = mFilterEditor->getText(); + if (filter_substring.empty()) + { + if (mPanelInventoryObject->getFilter().getFilterSubString().empty()) + { + // The current filter and the new filter are empty, nothing to do + return; + } + + mSavedFolderState.setApply(true); + mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + + // Add a folder with the current item to the list of previously opened folders + LLOpenFoldersWithSelection opener; + mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(opener); + mPanelInventoryObject->getRootFolder()->scrollToShowSelection(); + } + else if (mPanelInventoryObject->getFilter().getFilterSubString().empty()) + { + // The first letter in search term, save existing folder open state + if (!mPanelInventoryObject->getFilter().isNotDefault()) + { + mSavedFolderState.setApply(false); + mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + } + } + + mPanelInventoryObject->getFilter().setFilterSubString(filter_substring); +} + void LLPanelContents::refresh() { const bool children_ok = true; @@ -149,7 +188,6 @@ void LLPanelContents::clearContents() } } - // // Static functions // @@ -199,7 +237,6 @@ void LLPanelContents::onClickNewScript(void *userdata) } } - // static void LLPanelContents::onClickPermissions(void *userdata) { diff --git a/indra/newview/llpanelcontents.h b/indra/newview/llpanelcontents.h index 748bb76a82..bb6308e8b8 100644 --- a/indra/newview/llpanelcontents.h +++ b/indra/newview/llpanelcontents.h @@ -27,12 +27,13 @@ #ifndef LL_LLPANELCONTENTS_H #define LL_LLPANELCONTENTS_H -#include "v3math.h" -#include "llpanel.h" +#include "llfolderview.h" #include "llinventory.h" +#include "llpanel.h" #include "lluuid.h" #include "llviewerobject.h" #include "llvoinventorylistener.h" +#include "v3math.h" class LLButton; class LLPanelObjectInventory; @@ -66,9 +67,12 @@ public: static const char* PERMS_ANYONE_CONTROL_KEY; protected: - void getState(LLViewerObject *object); + void getState(LLViewerObject *object); + void onFilterEdit(); public: + class LLFilterEditor* mFilterEditor; + LLSaveFolderState mSavedFolderState; LLPanelObjectInventory* mPanelInventoryObject; }; diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index 433db74cda..8032e207cd 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -56,6 +56,7 @@ LLPanelGroupBulkImpl::LLPanelGroupBulkImpl(const LLUUID& group_id) : mGroupID(group_id), mBulkAgentList(NULL), mOKButton(NULL), + mAddButton(nullptr), mRemoveButton(NULL), mGroupName(NULL), mLoadingText(), @@ -79,29 +80,18 @@ LLPanelGroupBulkImpl::~LLPanelGroupBulkImpl() } } -// static -void LLPanelGroupBulkImpl::callbackClickAdd(void* userdata) +void LLPanelGroupBulkImpl::callbackClickAdd(LLPanelGroupBulk* panelp) { - if (LLPanelGroupBulk* panelp = (LLPanelGroupBulk*)userdata) - { - // Right now this is hard coded with some knowledge that it is part - // of a floater since the avatar picker needs to be added as a dependent - // floater to the parent floater. - // Soon the avatar picker will be embedded into this panel - // instead of being it's own separate floater. But that is next week. - // This will do for now. -jwolk May 10, 2006 - LLView* button = panelp->findChild<LLButton>("add_button"); - LLFloater* root_floater = gFloaterView->getParentFloater(panelp); - LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( - [&](const uuid_vec_t& agent_ids, const std::vector<LLAvatarName>&) - { - panelp->mImplementation->addUsers(agent_ids); - }, true, false, false, root_floater->getName(), button); - if (picker) + LLFloater* root_floater = gFloaterView->getParentFloater(panelp); + LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( + [this](const uuid_vec_t& agent_ids, const std::vector<LLAvatarName>&) { - root_floater->addDependentFloater(picker); - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(panelp->mImplementation->mGroupID); - } + addUsers(agent_ids); + }, true, false, false, root_floater->getName(), mAddButton); + if (picker) + { + root_floater->addDependentFloater(picker); + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID); } } diff --git a/indra/newview/llpanelgroupbulkban.cpp b/indra/newview/llpanelgroupbulkban.cpp index 3c764887a6..1d3edad0f3 100644 --- a/indra/newview/llpanelgroupbulkban.cpp +++ b/indra/newview/llpanelgroupbulkban.cpp @@ -68,35 +68,26 @@ bool LLPanelGroupBulkBan::postBuild() mImplementation->mBulkAgentList->setCommitCallback(LLPanelGroupBulkImpl::callbackSelect, mImplementation); } - LLButton* button = getChild<LLButton>("add_button", recurse); - if ( button ) + mImplementation->mAddButton = getChild<LLButton>("add_button", recurse); + // default to opening avatarpicker automatically + mImplementation->mAddButton->setClickedCallback( + [this](LLUICtrl* ctrl, const LLSD& param) { - // default to opening avatarpicker automatically - // (*impl::callbackClickAdd)((void*)this); - button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickAdd, this); - } + mImplementation->callbackClickAdd(this); + }); mImplementation->mRemoveButton = getChild<LLButton>("remove_button", recurse); - if ( mImplementation->mRemoveButton ) - { - mImplementation->mRemoveButton->setClickedCallback(LLPanelGroupBulkImpl::callbackClickRemove, mImplementation); - mImplementation->mRemoveButton->setEnabled(false); - } + mImplementation->mRemoveButton->setClickedCallback(LLPanelGroupBulkImpl::callbackClickRemove, mImplementation); + mImplementation->mRemoveButton->setEnabled(false); mImplementation->mOKButton = getChild<LLButton>("ban_button", recurse); - if ( mImplementation->mOKButton ) - { - mImplementation->mOKButton->setClickedCallback(LLPanelGroupBulkBan::callbackClickSubmit, this); - mImplementation->mOKButton->setEnabled(false); - } + mImplementation->mOKButton->setClickedCallback(LLPanelGroupBulkBan::callbackClickSubmit, this); + mImplementation->mOKButton->setEnabled(false); - button = getChild<LLButton>("cancel_button", recurse); - if ( button ) - { - button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickCancel, mImplementation); - } + LLButton* button = getChild<LLButton>("cancel_button", recurse); + button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickCancel, mImplementation); mImplementation->mTooManySelected = getString("ban_selection_too_large"); mImplementation->mBanNotPermitted = getString("ban_not_permitted"); diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 5a479f8117..5515bd6d9a 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -44,7 +44,7 @@ public: LLPanelGroupBulkImpl(const LLUUID& group_id); ~LLPanelGroupBulkImpl(); - static void callbackClickAdd(void* userdata); + void callbackClickAdd(LLPanelGroupBulk* panelp); static void callbackClickRemove(void* userdata); static void callbackClickCancel(void* userdata); @@ -70,6 +70,7 @@ public: LLNameListCtrl* mBulkAgentList; LLButton* mOKButton; + LLButton* mAddButton; LLButton* mRemoveButton; LLTextBox* mGroupName; diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 2466ee5973..de6358666b 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -78,9 +78,9 @@ static LLPanelInjector<LLPanelMainInventory> t_inventory("panel_main_inventory") class LLFloaterInventoryFinder : public LLFloater { public: - LLFloaterInventoryFinder( LLPanelMainInventory* inventory_view); - virtual void draw(); - /*virtual*/ bool postBuild(); + LLFloaterInventoryFinder(LLPanelMainInventory* inventory_view); + void draw(); + bool postBuild(); void changeFilter(LLInventoryFilter* filter); void updateElementsFromFilter(); bool getCheckShowEmpty(); @@ -90,17 +90,35 @@ public: void onCreatorSelfFilterCommit(); void onCreatorOtherFilterCommit(); - static void onTimeAgo(LLUICtrl*, void *); - static void onCloseBtn(void* user_data); - static void selectAllTypes(void* user_data); - static void selectNoTypes(void* user_data); + void onTimeAgo(); + void onCloseBtn(); + void selectAllTypes(); + void selectNoTypes(); private: - LLPanelMainInventory* mPanelMainInventory; - LLSpinCtrl* mSpinSinceDays; - LLSpinCtrl* mSpinSinceHours; - LLCheckBoxCtrl* mCreatorSelf; - LLCheckBoxCtrl* mCreatorOthers; - LLInventoryFilter* mFilter; + LLPanelMainInventory* mPanelMainInventory{ nullptr }; + LLSpinCtrl* mSpinSinceDays{ nullptr }; + LLSpinCtrl* mSpinSinceHours{ nullptr }; + LLCheckBoxCtrl* mCreatorSelf{ nullptr }; + LLCheckBoxCtrl* mCreatorOthers{ nullptr }; + LLInventoryFilter* mFilter{ nullptr }; + + LLCheckBoxCtrl* mCheckAnimation{ nullptr }; + LLCheckBoxCtrl* mCheckCallingCard{ nullptr }; + LLCheckBoxCtrl* mCheckClothing{ nullptr }; + LLCheckBoxCtrl* mCheckGesture{ nullptr }; + LLCheckBoxCtrl* mCheckLandmark{ nullptr }; + LLCheckBoxCtrl* mCheckMaterial{ nullptr }; + LLCheckBoxCtrl* mCheckNotecard{ nullptr }; + LLCheckBoxCtrl* mCheckObject{ nullptr }; + LLCheckBoxCtrl* mCheckScript{ nullptr }; + LLCheckBoxCtrl* mCheckSounds{ nullptr }; + LLCheckBoxCtrl* mCheckTexture{ nullptr }; + LLCheckBoxCtrl* mCheckSnapshot{ nullptr }; + LLCheckBoxCtrl* mCheckSettings{ nullptr }; + LLCheckBoxCtrl* mCheckShowEmpty{ nullptr }; + LLCheckBoxCtrl* mCheckSinceLogoff{ nullptr }; + + LLRadioGroup* mRadioDateSearchDirection{ nullptr }; }; ///---------------------------------------------------------------------------- @@ -734,7 +752,6 @@ bool LLPanelMainInventory::filtersVisible(void* user_data) void LLPanelMainInventory::onClearSearch() { bool initially_active = false; - LLFloater *finder = getFinder(); if (mActivePanel && (getActivePanel() != mWornItemsPanel)) { initially_active = mActivePanel->getFilter().isNotDefault(); @@ -743,9 +760,9 @@ void LLPanelMainInventory::onClearSearch() mActivePanel->setFilterLinks(LLInventoryFilter::FILTERLINK_INCLUDE_LINKS); } - if (finder) + if (LLFloaterInventoryFinder* finder = getFinder()) { - LLFloaterInventoryFinder::selectAllTypes(finder); + finder->selectAllTypes(); } // re-open folders that were initially open in case filter was active @@ -908,12 +925,12 @@ bool LLPanelMainInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EAcceptance* accept, std::string& tooltip_msg) { - // Check to see if we are auto scrolling from the last frame - LLInventoryPanel* panel = (LLInventoryPanel*)this->getActivePanel(); - bool needsToScroll = panel->getScrollableContainer()->canAutoScroll(x, y); - if(mFilterTabs) + if (mFilterTabs) { - if(needsToScroll) + // Check to see if we are auto scrolling from the last frame + LLInventoryPanel* panel = (LLInventoryPanel*)this->getActivePanel(); + bool needsToScroll = panel->getScrollableContainer()->canAutoScroll(x, y); + if (needsToScroll) { mFilterTabs->startDragAndDropDelayTimer(); } @@ -930,9 +947,9 @@ void LLPanelMainInventory::changed(U32) updateItemcountText(); } -void LLPanelMainInventory::setFocusFilterEditor() +void LLPanelMainInventory::setFocusOnFilterEditor() { - if(mFilterEditor) + if (mFilterEditor) { mFilterEditor->setFocus(true); } @@ -963,59 +980,103 @@ void LLPanelMainInventory::draw() void LLPanelMainInventory::updateItemcountText() { - if(mItemCount != gInventory.getItemCount()) + bool update = false; + if (mSingleFolderMode) { - mItemCount = gInventory.getItemCount(); - mItemCountString = ""; - LLLocale locale(LLLocale::USER_LOCALE); - LLResMgr::getInstance()->getIntegerString(mItemCountString, mItemCount); - } + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; - if(mCategoryCount != gInventory.getCategoryCount()) - { - mCategoryCount = gInventory.getCategoryCount(); - mCategoryCountString = ""; - LLLocale locale(LLLocale::USER_LOCALE); - LLResMgr::getInstance()->getIntegerString(mCategoryCountString, mCategoryCount); + gInventory.getDirectDescendentsOf(getCurrentSFVRoot(), cats, items); + S32 item_count = items ? (S32)items->size() : 0; + S32 cat_count = cats ? (S32)cats->size() : 0; + + if (mItemCount != item_count) + { + mItemCount = item_count; + update = true; + } + if (mCategoryCount != cat_count) + { + mCategoryCount = cat_count; + update = true; + } } + else + { + if (mItemCount != gInventory.getItemCount()) + { + mItemCount = gInventory.getItemCount(); + update = true; + } - LLStringUtil::format_map_t string_args; - string_args["[ITEM_COUNT]"] = mItemCountString; - string_args["[CATEGORY_COUNT]"] = mCategoryCountString; - string_args["[FILTER]"] = getFilterText(); + if (mCategoryCount != gInventory.getCategoryCount()) + { + mCategoryCount = gInventory.getCategoryCount(); + update = true; + } - std::string text = ""; + EFetchState currentFetchState{ EFetchState::Unknown }; + if (LLInventoryModelBackgroundFetch::instance().folderFetchActive()) + { + currentFetchState = EFetchState::Fetching; + } + else if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) + { + currentFetchState = EFetchState::Complete; + } - if (LLInventoryModelBackgroundFetch::instance().folderFetchActive()) - { - text = getString("ItemcountFetching", string_args); - } - else if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) - { - text = getString("ItemcountCompleted", string_args); + if (mLastFetchState != currentFetchState) + { + mLastFetchState = currentFetchState; + update = true; + } } - else + + if (mLastFilterText != getFilterText()) { - text = getString("ItemcountUnknown", string_args); + mLastFilterText = getFilterText(); + update = true; } - if (mSingleFolderMode) + if (update) { - LLInventoryModel::cat_array_t *cats; - LLInventoryModel::item_array_t *items; + mItemCountString = ""; + LLLocale locale(LLLocale::USER_LOCALE); + LLResMgr::getInstance()->getIntegerString(mItemCountString, mItemCount); - gInventory.getDirectDescendentsOf(getCurrentSFVRoot(), cats, items); + mCategoryCountString = ""; + LLResMgr::getInstance()->getIntegerString(mCategoryCountString, mCategoryCount); + + LLStringUtil::format_map_t string_args; + string_args["[ITEM_COUNT]"] = mItemCountString; + string_args["[CATEGORY_COUNT]"] = mCategoryCountString; + string_args["[FILTER]"] = mLastFilterText; - if (items && cats) + std::string text = ""; + + if (mSingleFolderMode) { - string_args["[ITEM_COUNT]"] = llformat("%d", items->size()); - string_args["[CATEGORY_COUNT]"] = llformat("%d", cats->size()); text = getString("ItemcountCompleted", string_args); } - } + else + { + switch (mLastFetchState) + { + case EFetchState::Fetching: + text = getString("ItemcountFetching", string_args); + break; + case EFetchState::Complete: + text = getString("ItemcountCompleted", string_args); + break; + default: + text = getString("ItemcountUnknown", string_args); + break; + } + } - mCounterCtrl->setValue(text); - mCounterCtrl->setToolTip(text); + mCounterCtrl->setValue(text); + mCounterCtrl->setToolTip(text); + } } void LLPanelMainInventory::onFocusReceived() @@ -1101,36 +1162,53 @@ bool LLFloaterInventoryFinder::postBuild() const LLRect& viewrect = mPanelMainInventory->getRect(); setRect(LLRect(viewrect.mLeft - getRect().getWidth(), viewrect.mTop, viewrect.mLeft, viewrect.mTop - getRect().getHeight())); - childSetAction("All", selectAllTypes, this); - childSetAction("None", selectNoTypes, this); + childSetAction("All", [this](LLUICtrl*, const LLSD&) { selectAllTypes(); }); + childSetAction("None", [this](LLUICtrl*, const LLSD&) { selectNoTypes(); }); mSpinSinceHours = getChild<LLSpinCtrl>("spin_hours_ago"); - childSetCommitCallback("spin_hours_ago", onTimeAgo, this); + mSpinSinceHours->setCommitCallback([this](LLUICtrl*, const LLSD&) { onTimeAgo(); }); mSpinSinceDays = getChild<LLSpinCtrl>("spin_days_ago"); - childSetCommitCallback("spin_days_ago", onTimeAgo, this); + mSpinSinceDays->setCommitCallback([this](LLUICtrl*, const LLSD&) { onTimeAgo(); }); mCreatorSelf = getChild<LLCheckBoxCtrl>("check_created_by_me"); mCreatorOthers = getChild<LLCheckBoxCtrl>("check_created_by_others"); mCreatorSelf->setCommitCallback(boost::bind(&LLFloaterInventoryFinder::onCreatorSelfFilterCommit, this)); mCreatorOthers->setCommitCallback(boost::bind(&LLFloaterInventoryFinder::onCreatorOtherFilterCommit, this)); - childSetAction("Close", onCloseBtn, this); + mCheckAnimation = getChild<LLCheckBoxCtrl>("check_animation"); + mCheckCallingCard = getChild<LLCheckBoxCtrl>("check_calling_card"); + mCheckClothing = getChild<LLCheckBoxCtrl>("check_clothing"); + mCheckGesture = getChild<LLCheckBoxCtrl>("check_gesture"); + mCheckLandmark = getChild<LLCheckBoxCtrl>("check_landmark"); + mCheckMaterial = getChild<LLCheckBoxCtrl>("check_material"); + mCheckNotecard = getChild<LLCheckBoxCtrl>("check_notecard"); + mCheckObject = getChild<LLCheckBoxCtrl>("check_object"); + mCheckScript = getChild<LLCheckBoxCtrl>("check_script"); + mCheckSounds = getChild<LLCheckBoxCtrl>("check_sound"); + mCheckTexture = getChild<LLCheckBoxCtrl>("check_texture"); + mCheckSnapshot = getChild<LLCheckBoxCtrl>("check_snapshot"); + mCheckSettings = getChild<LLCheckBoxCtrl>("check_settings"); + mCheckShowEmpty = getChild<LLCheckBoxCtrl>("check_show_empty"); + mCheckSinceLogoff = getChild<LLCheckBoxCtrl>("check_since_logoff"); + + mRadioDateSearchDirection = getChild<LLRadioGroup>("date_search_direction"); + + childSetAction("Close", [this](LLUICtrl*, const LLSD&) { onCloseBtn(); }); updateElementsFromFilter(); + return true; } -void LLFloaterInventoryFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) -{ - LLFloaterInventoryFinder *self = (LLFloaterInventoryFinder *)user_data; - if (!self) return; - if ( self->mSpinSinceDays->get() || self->mSpinSinceHours->get() ) +void LLFloaterInventoryFinder::onTimeAgo() +{ + if (mSpinSinceDays->get() || mSpinSinceHours->get()) { - self->getChild<LLUICtrl>("check_since_logoff")->setValue(false); + mCheckSinceLogoff->setValue(false); - U32 days = (U32)self->mSpinSinceDays->get(); - U32 hours = (U32)self->mSpinSinceHours->get(); + U32 days = (U32)mSpinSinceDays->get(); + U32 hours = (U32)mSpinSinceHours->get(); if (hours >= 24) { // Try to handle both cases of spinner clicking and text input in a sensible fashion as best as possible. @@ -1146,11 +1224,11 @@ void LLFloaterInventoryFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) days = hours / 24; } hours = (U32)hours % 24; - self->mSpinSinceHours->setFocus(false); - self->mSpinSinceDays->setFocus(false); - self->mSpinSinceDays->set((F32)days); - self->mSpinSinceHours->set((F32)hours); - self->mSpinSinceHours->setFocus(true); + mSpinSinceHours->setFocus(false); + mSpinSinceDays->setFocus(false); + mSpinSinceDays->set((F32)days); + mSpinSinceHours->set((F32)hours); + mSpinSinceHours->setFocus(true); } } } @@ -1179,29 +1257,28 @@ void LLFloaterInventoryFinder::updateElementsFromFilter() // update the ui elements setTitle(mFilter->getName()); - getChild<LLUICtrl>("check_animation")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION)); - - getChild<LLUICtrl>("check_calling_card")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD)); - getChild<LLUICtrl>("check_clothing")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE)); - getChild<LLUICtrl>("check_gesture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE)); - getChild<LLUICtrl>("check_landmark")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK)); - getChild<LLUICtrl>("check_material")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_MATERIAL)); - getChild<LLUICtrl>("check_notecard")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD)); - getChild<LLUICtrl>("check_object")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT)); - getChild<LLUICtrl>("check_script")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LSL)); - getChild<LLUICtrl>("check_sound")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND)); - getChild<LLUICtrl>("check_texture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE)); - getChild<LLUICtrl>("check_snapshot")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT)); - getChild<LLUICtrl>("check_settings")->setValue((S32)(filter_types & 0x1 << LLInventoryType::IT_SETTINGS)); - getChild<LLUICtrl>("check_show_empty")->setValue(show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS); - - getChild<LLUICtrl>("check_created_by_me")->setValue(show_created_by_me); - getChild<LLUICtrl>("check_created_by_others")->setValue(show_created_by_others); - - getChild<LLUICtrl>("check_since_logoff")->setValue(mFilter->isSinceLogoff()); + mCheckAnimation->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION)); + mCheckCallingCard->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD)); + mCheckClothing->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE)); + mCheckGesture->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE)); + mCheckLandmark->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK)); + mCheckMaterial->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_MATERIAL)); + mCheckNotecard->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD)); + mCheckObject->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT)); + mCheckScript->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LSL)); + mCheckSounds->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND)); + mCheckTexture->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE)); + mCheckSnapshot->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT)); + mCheckSettings->setValue((S32)(filter_types & 0x1 << LLInventoryType::IT_SETTINGS)); + mCheckShowEmpty->setValue(show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS); + + mCreatorSelf->setValue(show_created_by_me); + mCreatorOthers->setValue(show_created_by_others); + + mCheckSinceLogoff->setValue(mFilter->isSinceLogoff()); mSpinSinceHours->set((F32)(hours % 24)); mSpinSinceDays->set((F32)(hours / 24)); - getChild<LLRadioGroup>("date_search_direction")->setSelectedIndex(date_search_direction); + mRadioDateSearchDirection->setSelectedIndex(date_search_direction); } void LLFloaterInventoryFinder::draw() @@ -1209,83 +1286,80 @@ void LLFloaterInventoryFinder::draw() U64 filter = 0xffffffffffffffffULL; bool filtered_by_all_types = true; - if (!getChild<LLUICtrl>("check_animation")->getValue()) + if (!mCheckAnimation->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_ANIMATION); filtered_by_all_types = false; } - - if (!getChild<LLUICtrl>("check_calling_card")->getValue()) + if (!mCheckCallingCard->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_clothing")->getValue()) + if (!mCheckClothing->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_WEARABLE); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_gesture")->getValue()) + if (!mCheckGesture->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_GESTURE); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_landmark")->getValue()) - - + if (!mCheckLandmark->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_LANDMARK); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_material")->getValue()) + if (!mCheckMaterial->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_MATERIAL); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_notecard")->getValue()) + if (!mCheckNotecard->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_NOTECARD); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_object")->getValue()) + if (!mCheckObject->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_OBJECT); filter &= ~(0x1 << LLInventoryType::IT_ATTACHMENT); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_script")->getValue()) + if (!mCheckScript->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_LSL); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_sound")->getValue()) + if (!mCheckSounds->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_SOUND); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_texture")->getValue()) + if (!mCheckTexture->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_TEXTURE); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_snapshot")->getValue()) + if (!mCheckSnapshot->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_SNAPSHOT); filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_settings")->getValue()) + if (!mCheckSettings->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_SETTINGS); filtered_by_all_types = false; @@ -1297,9 +1371,8 @@ void LLFloaterInventoryFinder::draw() filter &= ~(0x1 << LLInventoryType::IT_CATEGORY); } - bool is_sf_mode = mPanelMainInventory->isSingleFolderMode(); - if(is_sf_mode && mPanelMainInventory->isGalleryViewMode()) + if (is_sf_mode && mPanelMainInventory->isGalleryViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setShowFolderState(getCheckShowEmpty() ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); @@ -1307,7 +1380,7 @@ void LLFloaterInventoryFinder::draw() } else { - if(is_sf_mode && mPanelMainInventory->isCombinationViewMode()) + if (is_sf_mode && mPanelMainInventory->isCombinationViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setShowFolderState(getCheckShowEmpty() ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); @@ -1339,9 +1412,8 @@ void LLFloaterInventoryFinder::draw() } hours += days * 24; - mPanelMainInventory->setFilterTextFromFilter(); - if(is_sf_mode && mPanelMainInventory->isGalleryViewMode()) + if (is_sf_mode && mPanelMainInventory->isGalleryViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setHoursAgo(hours); mPanelMainInventory->mCombinationGalleryPanel->getFilter().setDateRangeLastLogoff(getCheckSinceLogoff()); @@ -1349,7 +1421,7 @@ void LLFloaterInventoryFinder::draw() } else { - if(is_sf_mode && mPanelMainInventory->isCombinationViewMode()) + if (is_sf_mode && mPanelMainInventory->isCombinationViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setHoursAgo(hours); mPanelMainInventory->mCombinationGalleryPanel->getFilter().setDateRangeLastLogoff(getCheckSinceLogoff()); @@ -1405,65 +1477,56 @@ void LLFloaterInventoryFinder::onCreatorOtherFilterCommit() bool LLFloaterInventoryFinder::getCheckShowEmpty() { - return getChild<LLUICtrl>("check_show_empty")->getValue(); + return mCheckShowEmpty->getValue(); } bool LLFloaterInventoryFinder::getCheckSinceLogoff() { - return getChild<LLUICtrl>("check_since_logoff")->getValue(); + return mCheckSinceLogoff->getValue(); } U32 LLFloaterInventoryFinder::getDateSearchDirection() { - return getChild<LLRadioGroup>("date_search_direction")->getSelectedIndex(); + return mRadioDateSearchDirection->getSelectedIndex(); } -void LLFloaterInventoryFinder::onCloseBtn(void* user_data) +void LLFloaterInventoryFinder::onCloseBtn() { - LLFloaterInventoryFinder* finderp = (LLFloaterInventoryFinder*)user_data; - finderp->closeFloater(); + closeFloater(); } -// static -void LLFloaterInventoryFinder::selectAllTypes(void* user_data) -{ - LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data; - if(!self) return; - - self->getChild<LLUICtrl>("check_animation")->setValue(true); - self->getChild<LLUICtrl>("check_calling_card")->setValue(true); - self->getChild<LLUICtrl>("check_clothing")->setValue(true); - self->getChild<LLUICtrl>("check_gesture")->setValue(true); - self->getChild<LLUICtrl>("check_landmark")->setValue(true); - self->getChild<LLUICtrl>("check_material")->setValue(true); - self->getChild<LLUICtrl>("check_notecard")->setValue(true); - self->getChild<LLUICtrl>("check_object")->setValue(true); - self->getChild<LLUICtrl>("check_script")->setValue(true); - self->getChild<LLUICtrl>("check_sound")->setValue(true); - self->getChild<LLUICtrl>("check_texture")->setValue(true); - self->getChild<LLUICtrl>("check_snapshot")->setValue(true); - self->getChild<LLUICtrl>("check_settings")->setValue(true); +void LLFloaterInventoryFinder::selectAllTypes() +{ + mCheckAnimation->setValue(true); + mCheckCallingCard->setValue(true); + mCheckClothing->setValue(true); + mCheckGesture->setValue(true); + mCheckLandmark->setValue(true); + mCheckMaterial->setValue(true); + mCheckNotecard->setValue(true); + mCheckObject->setValue(true); + mCheckScript->setValue(true); + mCheckSounds->setValue(true); + mCheckTexture->setValue(true); + mCheckSnapshot->setValue(true); + mCheckSettings->setValue(true); } -//static -void LLFloaterInventoryFinder::selectNoTypes(void* user_data) -{ - LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data; - if(!self) return; - - self->getChild<LLUICtrl>("check_animation")->setValue(false); - self->getChild<LLUICtrl>("check_calling_card")->setValue(false); - self->getChild<LLUICtrl>("check_clothing")->setValue(false); - self->getChild<LLUICtrl>("check_gesture")->setValue(false); - self->getChild<LLUICtrl>("check_landmark")->setValue(false); - self->getChild<LLUICtrl>("check_material")->setValue(false); - self->getChild<LLUICtrl>("check_notecard")->setValue(false); - self->getChild<LLUICtrl>("check_object")->setValue(false); - self->getChild<LLUICtrl>("check_script")->setValue(false); - self->getChild<LLUICtrl>("check_sound")->setValue(false); - self->getChild<LLUICtrl>("check_texture")->setValue(false); - self->getChild<LLUICtrl>("check_snapshot")->setValue(false); - self->getChild<LLUICtrl>("check_settings")->setValue(false); +void LLFloaterInventoryFinder::selectNoTypes() +{ + mCheckAnimation->setValue(false); + mCheckCallingCard->setValue(false); + mCheckClothing->setValue(false); + mCheckGesture->setValue(false); + mCheckLandmark->setValue(false); + mCheckMaterial->setValue(false); + mCheckNotecard->setValue(false); + mCheckObject->setValue(false); + mCheckScript->setValue(false); + mCheckSounds->setValue(false); + mCheckTexture->setValue(false); + mCheckSnapshot->setValue(false); + mCheckSettings->setValue(false); } ////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index 3347ab904b..a78c0c0fad 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -103,7 +103,7 @@ public: void onFilterEdit(const std::string& search_string ); - void setFocusFilterEditor(); + void setFocusOnFilterEditor(); static LLFloaterSidePanelContainer* newWindow(); static void newFolderWindow(LLUUID folder_id = LLUUID(), LLUUID item_to_select = LLUUID()); @@ -182,6 +182,13 @@ protected: LLSidepanelInventory* getParentSidepanelInventory(); private: + enum class EFetchState + { + Unknown, + Fetching, + Complete + }; + LLFloaterInventoryFinder* getFinder(); LLFilterEditor* mFilterEditor; @@ -196,11 +203,13 @@ private: LLSaveFolderState* mSavedFolderState; std::string mFilterText; std::string mFilterSubString; - S32 mItemCount; + S32 mItemCount = 0; + std::string mLastFilterText; std::string mItemCountString; - S32 mCategoryCount; + S32 mCategoryCount = 0; std::string mCategoryCountString; LLComboBox* mSearchTypeCombo; + EFetchState mLastFetchState{ EFetchState::Unknown }; LLButton* mBackBtn; LLButton* mForwardBtn; diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index d33ccc0216..ef7986603b 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -173,8 +173,7 @@ LLTaskInvFVBridge::LLTaskInvFVBridge( mAssetType(LLAssetType::AT_NONE), mInventoryType(LLInventoryType::IT_NONE) { - const LLInventoryItem *item = findItem(); - if (item) + if (const LLInventoryItem* item = findItem()) { mAssetType = item->getType(); mInventoryType = item->getInventoryType(); @@ -183,15 +182,15 @@ LLTaskInvFVBridge::LLTaskInvFVBridge( LLInventoryObject* LLTaskInvFVBridge::findInvObject() const { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if (object) + const LLUUID& id = mPanel->getTaskUUID(); + if (LLViewerObject* object = gObjectList.findObject(id)) { return object->getInventoryObject(mUUID); } + return NULL; } - LLInventoryItem* LLTaskInvFVBridge::findItem() const { return dynamic_cast<LLInventoryItem*>(findInvObject()); @@ -204,27 +203,24 @@ void LLTaskInvFVBridge::showProperties() S32 LLTaskInvFVBridge::getPrice() { - LLInventoryItem* item = findItem(); - if(item) + if (LLInventoryItem* item = findItem()) { return item->getSaleInfo().getSalePrice(); } - else - { - return -1; - } + + return -1; } +// virtual const std::string& LLTaskInvFVBridge::getName() const { return mName; } +// virtual const std::string& LLTaskInvFVBridge::getDisplayName() const { - LLInventoryItem* item = findItem(); - - if(item) + if (LLInventoryItem* item = findItem()) { mDisplayName.assign(item->getName()); @@ -240,31 +236,32 @@ const std::string& LLTaskInvFVBridge::getDisplayName() const bool mod = gAgent.allowOperation(PERM_MODIFY, perm, GP_OBJECT_MANIPULATE); bool xfer = gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE); - if(!copy) + if (!copy) { mDisplayName.append(LLTrans::getString("no_copy")); } - if(!mod) + if (!mod) { mDisplayName.append(LLTrans::getString("no_modify")); } - if(!xfer) + if (!xfer) { mDisplayName.append(LLTrans::getString("no_transfer")); } } mSearchableName.assign(mDisplayName + getLabelSuffix()); + LLStringUtil::toUpper(mSearchableName); return mDisplayName; } +// virtual const std::string& LLTaskInvFVBridge::getSearchableName() const { return mSearchableName; } - // BUG: No creation dates for task inventory time_t LLTaskInvFVBridge::getCreationDate() const { @@ -272,14 +269,14 @@ time_t LLTaskInvFVBridge::getCreationDate() const } void LLTaskInvFVBridge::setCreationDate(time_t creation_date_utc) -{} - +{ +} LLUIImagePtr LLTaskInvFVBridge::getIcon() const { - const bool item_is_multi = (mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS); + const bool item_is_multi = mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS; - return LLInventoryIcon::getIcon(mAssetType, mInventoryType, 0, item_is_multi ); + return LLInventoryIcon::getIcon(mAssetType, mInventoryType, 0, item_is_multi); } void LLTaskInvFVBridge::openItem() @@ -290,38 +287,38 @@ void LLTaskInvFVBridge::openItem() bool LLTaskInvFVBridge::isItemRenameable() const { - if(gAgent.isGodlike()) return true; - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (gAgent.isGodlike()) + return true; + + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - LLInventoryItem* item = (LLInventoryItem*)(object->getInventoryObject(mUUID)); - if(item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), - GP_OBJECT_MANIPULATE, GOD_LIKE)) + if (LLInventoryItem* item = (LLInventoryItem*)(object->getInventoryObject(mUUID))) { - return true; + if (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE, GOD_LIKE)) + { + return true; + } } } + return false; } bool LLTaskInvFVBridge::renameItem(const std::string& new_name) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - LLViewerInventoryItem* item = NULL; - item = (LLViewerInventoryItem*)object->getInventoryObject(mUUID); - if(item && (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), - GP_OBJECT_MANIPULATE, GOD_LIKE))) + if (LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(mUUID)) { - LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); - new_item->rename(new_name); - object->updateInventory( - new_item, - TASK_INVENTORY_ITEM_KEY, - false); + if (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE, GOD_LIKE)) + { + LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); + new_item->rename(new_name); + object->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, false); + } } } + return true; } @@ -338,33 +335,35 @@ bool LLTaskInvFVBridge::isItemMovable() const bool LLTaskInvFVBridge::isItemRemovable(bool check_worn) const { - const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object - && (object->permModify() || object->permYouOwner())) + if (const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - return true; + return object->permModify() || object->permYouOwner(); } + return false; } bool remove_task_inventory_callback(const LLSD& notification, const LLSD& response, LLPanelObjectInventory* panel) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - LLViewerObject* object = gObjectList.findObject(notification["payload"]["task_id"].asUUID()); - if(option == 0 && object) - { - // yes - LLSD::array_const_iterator list_end = notification["payload"]["inventory_ids"].endArray(); - for (LLSD::array_const_iterator list_it = notification["payload"]["inventory_ids"].beginArray(); - list_it != list_end; - ++list_it) + if (option == 0) + { + if (LLViewerObject* object = gObjectList.findObject(notification["payload"]["task_id"].asUUID())) { - object->removeInventory(list_it->asUUID()); - } + // yes + const LLSD& inventory_ids = notification["payload"]["inventory_ids"]; + LLSD::array_const_iterator list_it = inventory_ids.beginArray(); + LLSD::array_const_iterator list_end = inventory_ids.endArray(); + for (; list_it != list_end; ++list_it) + { + object->removeInventory(list_it->asUUID()); + } - // refresh the UI. - panel->refresh(); + // refresh the UI. + panel->refresh(); + } } + return false; } @@ -374,31 +373,29 @@ typedef std::pair<LLUUID, std::list<LLUUID> > panel_two_uuids_list_t; typedef std::pair<LLPanelObjectInventory*, panel_two_uuids_list_t> remove_data_t; bool LLTaskInvFVBridge::removeItem() { - if(isItemRemovable() && mPanel) + if (isItemRemovable() && mPanel) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - if(object->permModify()) + if (object->permModify()) { // just do it. object->removeInventory(mUUID); return true; } - else - { - LLSD payload; - payload["task_id"] = mPanel->getTaskUUID(); - payload["inventory_ids"].append(mUUID); - LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); - return false; - } + + LLSD payload; + payload["task_id"] = mPanel->getTaskUUID(); + payload["inventory_ids"].append(mUUID); + LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); + return false; } } + return false; } -void LLTaskInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch) +void LLTaskInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch) { if (!mPanel) { @@ -415,24 +412,21 @@ void LLTaskInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch { LLSD payload; payload["task_id"] = mPanel->getTaskUUID(); - for (S32 i = 0; i < (S32)batch.size(); i++) + for (LLFolderViewModelItem* item : batch) { - LLTaskInvFVBridge* itemp = (LLTaskInvFVBridge*)batch[i]; - payload["inventory_ids"].append(itemp->getUUID()); + payload["inventory_ids"].append(((LLTaskInvFVBridge*)item)->getUUID()); } LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); - } else { - for (S32 i = 0; i < (S32)batch.size(); i++) + for (LLFolderViewModelItem* item : batch) { - LLTaskInvFVBridge* itemp = (LLTaskInvFVBridge*)batch[i]; - - if(itemp->isItemRemovable()) + LLTaskInvFVBridge* bridge = (LLTaskInvFVBridge*)item; + if (bridge->isItemRemovable()) { - // just do it. - object->removeInventory(itemp->getUUID()); + // Just do it. + object->removeInventory(bridge->getUUID()); } } } @@ -444,10 +438,12 @@ void LLTaskInvFVBridge::move(LLFolderViewModelItem* parent_listener) bool LLTaskInvFVBridge::isItemCopyable(bool can_link) const { - LLInventoryItem* item = findItem(); - if(!item) return false; - return gAgent.allowOperation(PERM_COPY, item->getPermissions(), - GP_OBJECT_MANIPULATE); + if (LLInventoryItem* item = findItem()) + { + return gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE); + } + + return false; } bool LLTaskInvFVBridge::copyToClipboard() const @@ -476,38 +472,35 @@ void LLTaskInvFVBridge::pasteLinkFromClipboard() bool LLTaskInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const { //LL_INFOS() << "LLTaskInvFVBridge::startDrag()" << LL_ENDL; - if(mPanel) + if (!mPanel) + return false; + + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLInventoryItem* inv = (LLInventoryItem*)object->getInventoryObject(mUUID)) { - LLInventoryItem* inv = NULL; - if((inv = (LLInventoryItem*)object->getInventoryObject(mUUID))) + const LLPermissions& perm = inv->getPermissions(); + bool can_copy = gAgent.allowOperation(PERM_COPY, perm, GP_OBJECT_MANIPULATE); + if (!can_copy && object->isAttachment()) { - const LLPermissions& perm = inv->getPermissions(); - bool can_copy = gAgent.allowOperation(PERM_COPY, perm, - GP_OBJECT_MANIPULATE); - if (object->isAttachment() && !can_copy) - { - //RN: no copy contents of attachments cannot be dragged out - // due to a race condition and possible exploit where - // attached objects do not update their inventory items - // when their contents are manipulated - return false; - } - if((can_copy && perm.allowTransferTo(gAgent.getID())) - || object->permYouOwner()) -// || gAgent.isGodlike()) - - { - *type = LLViewerAssetType::lookupDragAndDropType(inv->getType()); + //RN: no copy contents of attachments cannot be dragged out + // due to a race condition and possible exploit where + // attached objects do not update their inventory items + // when their contents are manipulated + return false; + } - *id = inv->getUUID(); - return true; - } + if ((can_copy && perm.allowTransferTo(gAgent.getID())) + || object->permYouOwner()) +// || gAgent.isGodlike()) + { + *type = LLViewerAssetType::lookupDragAndDropType(inv->getType()); + *id = inv->getUUID(); + return true; } } } + return false; } @@ -554,7 +547,7 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Task Properties")); } - if(isItemRenameable()) + if (isItemRenameable()) { items.push_back(std::string("Task Rename")); if ((flags & FIRST_SELECTED_ITEM) == 0) @@ -562,7 +555,7 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) disabled_items.push_back(std::string("Task Rename")); } } - if(isItemRemovable()) + if (isItemRemovable()) { items.push_back(std::string("Task Remove")); } @@ -585,10 +578,10 @@ public: virtual LLUIImagePtr getIcon() const; virtual const std::string& getDisplayName() const; - virtual bool isItemRenameable() const; + virtual bool isItemRenameable() const { return false; } // virtual bool isItemCopyable() const { return false; } - virtual bool renameItem(const std::string& new_name); - virtual bool isItemRemovable(bool check_worn = true) const; + virtual bool renameItem(const std::string& new_name) { return false; } + virtual bool isItemRemovable(bool check_worn = true) const { return false; } virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual bool hasChildren() const; virtual bool startDrag(EDragAndDropType* type, LLUUID* id) const; @@ -609,6 +602,7 @@ LLTaskCategoryBridge::LLTaskCategoryBridge( { } +// virtual LLUIImagePtr LLTaskCategoryBridge::getIcon() const { return LLUI::getUIImage("Inv_FolderClosed"); @@ -617,9 +611,7 @@ LLUIImagePtr LLTaskCategoryBridge::getIcon() const // virtual const std::string& LLTaskCategoryBridge::getDisplayName() const { - LLInventoryObject* cat = findInvObject(); - - if (cat) + if (LLInventoryObject* cat = findInvObject()) { std::string name = cat->getName(); if (mChildren.size() > 0) @@ -633,26 +625,13 @@ const std::string& LLTaskCategoryBridge::getDisplayName() const name.append(" " + LLTrans::getString("InventoryItemsCount", args)); } mDisplayName.assign(name); + LLStringUtil::toUpper(name); + mSearchableName.assign(name); } return mDisplayName; } -bool LLTaskCategoryBridge::isItemRenameable() const -{ - return false; -} - -bool LLTaskCategoryBridge::renameItem(const std::string& new_name) -{ - return false; -} - -bool LLTaskCategoryBridge::isItemRemovable(bool check_worn) const -{ - return false; -} - void LLTaskCategoryBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { std::vector<std::string> items; @@ -660,6 +639,7 @@ void LLTaskCategoryBridge::buildContextMenu(LLMenuGL& menu, U32 flags) hide_context_entries(menu, items, disabled_items); } +// virtual bool LLTaskCategoryBridge::hasChildren() const { // return true if we have or do know know if we have children. @@ -667,20 +647,21 @@ bool LLTaskCategoryBridge::hasChildren() const return false; } +// virtual void LLTaskCategoryBridge::openItem() { } +// virtual bool LLTaskCategoryBridge::startDrag(EDragAndDropType* type, LLUUID* id) const { //LL_INFOS() << "LLTaskInvFVBridge::startDrag()" << LL_ENDL; - if(mPanel && mUUID.notNull()) + if (mPanel && mUUID.notNull()) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { const LLInventoryObject* cat = object->getInventoryObject(mUUID); - if ( (cat) && (move_inv_category_world_to_agent(mUUID, LLUUID::null, false)) ) + if (cat && move_inv_category_world_to_agent(mUUID, LLUUID::null, false)) { *type = LLViewerAssetType::lookupDragAndDropType(cat->getType()); *id = mUUID; @@ -691,6 +672,7 @@ bool LLTaskCategoryBridge::startDrag(EDragAndDropType* type, LLUUID* id) const return false; } +// virtual bool LLTaskCategoryBridge::dragOrDrop(MASK mask, bool drop, EDragAndDropType cargo_type, void* cargo_data, @@ -775,14 +757,13 @@ public: virtual void openItem(); }; +// virtual void LLTaskTextureBridge::openItem() { LL_INFOS() << "LLTaskTextureBridge::openItem()" << LL_ENDL; - LLPreviewTexture* preview = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(mUUID), TAKE_FOCUS_YES); - if(preview) + if (LLPreviewTexture* preview = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(mUUID), TAKE_FOCUS_YES)) { - LLInventoryItem* item = findItem(); - if(item) + if (LLInventoryItem* item = findItem()) { preview->setAuxItem(item); } @@ -810,11 +791,13 @@ public: static void openSoundPreview(void* data); }; +// virtual void LLTaskSoundBridge::openItem() { openSoundPreview((void*)this); } +// static void LLTaskSoundBridge::openSoundPreview(void* data) { LLTaskSoundBridge* self = (LLTaskSoundBridge*)data; @@ -842,6 +825,7 @@ void LLTaskSoundBridge::performAction(LLInventoryModel* model, std::string actio LLTaskInvFVBridge::performAction(model, action); } +// virtual void LLTaskSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { LLInventoryItem* item = findItem(); @@ -865,18 +849,17 @@ void LLTaskSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Task Properties")); } - if(isItemRenameable()) + if (isItemRenameable()) { items.push_back(std::string("Task Rename")); } - if(isItemRemovable()) + if (isItemRemovable()) { items.push_back(std::string("Task Remove")); } items.push_back(std::string("Task Play")); - hide_context_entries(menu, items, disabled_items); } @@ -905,20 +888,10 @@ public: const std::string& name) : LLTaskInvFVBridge(panel, uuid, name) {} - virtual bool isItemRenameable() const; - virtual bool renameItem(const std::string& new_name); + virtual bool isItemRenameable() const { return false; } + virtual bool renameItem(const std::string& new_name) { return false; } }; -bool LLTaskCallingCardBridge::isItemRenameable() const -{ - return false; -} - -bool LLTaskCallingCardBridge::renameItem(const std::string& new_name) -{ - return false; -} - ///---------------------------------------------------------------------------- /// Class LLTaskScriptBridge @@ -951,6 +924,7 @@ public: //static void copyToInventory(void* userdata); }; +// virtual void LLTaskLSLBridge::openItem() { LL_INFOS() << "LLTaskLSLBridge::openItem() " << mUUID << LL_ENDL; @@ -982,6 +956,7 @@ void LLTaskLSLBridge::openItem() } } +// virtual bool LLTaskLSLBridge::removeItem() { LLFloaterReg::hideInstance("preview_scriptedit", LLSD(mUUID)); @@ -1019,6 +994,7 @@ public: virtual bool removeItem(); }; +// virtual void LLTaskNotecardBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1045,6 +1021,7 @@ void LLTaskNotecardBridge::openItem() } } +// virtual bool LLTaskNotecardBridge::removeItem() { LLFloaterReg::hideInstance("preview_notecard", LLSD(mUUID)); @@ -1068,6 +1045,7 @@ public: virtual bool removeItem(); }; +// virtual void LLTaskGestureBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1078,6 +1056,7 @@ void LLTaskGestureBridge::openItem() LLPreviewGesture::show(mUUID, mPanel->getTaskUUID()); } +// virtual bool LLTaskGestureBridge::removeItem() { // Don't need to deactivate gesture because gestures inside objects can never be active. @@ -1102,10 +1081,12 @@ public: virtual bool removeItem(); }; +// virtual void LLTaskAnimationBridge::openItem() { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(!object || object->isInventoryPending()) + const LLUUID& task_id = mPanel->getTaskUUID(); + LLViewerObject* object = gObjectList.findObject(task_id); + if (!object || object->isInventoryPending()) { return; } @@ -1117,6 +1098,7 @@ void LLTaskAnimationBridge::openItem() } } +// virtual bool LLTaskAnimationBridge::removeItem() { LLFloaterReg::hideInstance("preview_anim", LLSD(mUUID)); @@ -1139,6 +1121,7 @@ public: virtual LLUIImagePtr getIcon() const; }; +// virtual LLUIImagePtr LLTaskWearableBridge::getIcon() const { return LLInventoryIcon::getIcon(mAssetType, mInventoryType, mFlags, false ); @@ -1161,11 +1144,13 @@ public: virtual LLSettingsType::type_e getSettingsType() const; }; +// virtual LLUIImagePtr LLTaskSettingsBridge::getIcon() const { return LLInventoryIcon::getIcon(mAssetType, mInventoryType, mFlags, false); } +// virtual LLSettingsType::type_e LLTaskSettingsBridge::getSettingsType() const { return LLSettingsType::ST_NONE; @@ -1188,6 +1173,7 @@ public: bool removeItem() override; }; +// virtual void LLTaskMaterialBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1216,13 +1202,13 @@ void LLTaskMaterialBridge::openItem() } } +// virtual bool LLTaskMaterialBridge::removeItem() { LLFloaterReg::hideInstance("material_editor", LLSD(mUUID)); return LLTaskInvFVBridge::removeItem(); } - ///---------------------------------------------------------------------------- /// LLTaskInvFVBridge impl //---------------------------------------------------------------------------- @@ -1402,7 +1388,6 @@ void LLPanelObjectInventory::clearContents() } } - void LLPanelObjectInventory::reset() { clearContents(); @@ -1456,12 +1441,13 @@ void LLPanelObjectInventory::inventoryChanged(LLViewerObject* object, S32 serial_num, void* data) { - if(!object) return; + if (!object) + return; //LL_INFOS() << "invetnory arrived: \n" // << " panel UUID: " << panel->mTaskUUID << "\n" // << " task UUID: " << object->mID << LL_ENDL; - if(mTaskUUID == object->mID) + if (mTaskUUID == object->mID) { mInventoryNeedsUpdate = true; } @@ -1473,23 +1459,19 @@ void LLPanelObjectInventory::updateInventory() // << " panel UUID: " << panel->mTaskUUID << "\n" // << " task UUID: " << object->mID << LL_ENDL; // We're still interested in this task's inventory. + bool inventory_has_focus = mHaveInventory && mFolders && gFocusMgr.childHasKeyboardFocus(mFolders); + std::vector<LLUUID> selected_item_ids; - std::set<LLFolderViewItem*> selected_items; - bool inventory_has_focus = false; if (mHaveInventory && mFolders) { - selected_items = mFolders->getSelectionList(); - inventory_has_focus = gFocusMgr.childHasKeyboardFocus(mFolders); - } - for (std::set<LLFolderViewItem*>::iterator it = selected_items.begin(), end_it = selected_items.end(); - it != end_it; - ++it) - { - selected_item_ids.push_back(static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID()); + std::set<LLFolderViewItem*> selected_items = mFolders->getSelectionList(); + for (LLFolderViewItem* item : selected_items) + { + selected_item_ids.push_back(static_cast<LLFolderViewModelItemInventory*>(item->getViewModelItem())->getUUID()); + } } - LLViewerObject* objectp = gObjectList.findObject(mTaskUUID); - if (objectp) + if (LLViewerObject* objectp = gObjectList.findObject(mTaskUUID)) { LLInventoryObject* inventory_root = objectp->getInventoryRoot(); LLInventoryObject::object_list_t contents; @@ -1525,15 +1507,12 @@ void LLPanelObjectInventory::updateInventory() } // restore previous selection - std::vector<LLUUID>::iterator selection_it; bool first_item = true; - for (selection_it = selected_item_ids.begin(); selection_it != selected_item_ids.end(); ++selection_it) + for (const LLUUID& item_id : selected_item_ids) { - LLFolderViewItem* selected_item = getItemByID(*selection_it); - - if (selected_item) + if (LLFolderViewItem* selected_item = getItemByID(item_id)) { - //HACK: "set" first item then "change" each other one to get keyboard focus right + // HACK: "set" first item then "change" each other one to get keyboard focus right if (first_item) { mFolders->setSelection(selected_item, true, inventory_has_focus); @@ -1550,6 +1529,7 @@ void LLPanelObjectInventory::updateInventory() { mFolders->requestArrange(); } + mInventoryNeedsUpdate = false; // Edit menu handler is set in onFocusReceived } @@ -1565,10 +1545,9 @@ void LLPanelObjectInventory::createFolderViews(LLInventoryObject* inventory_root { return; } + // Create a visible root category. - LLTaskInvFVBridge* bridge = NULL; - bridge = LLTaskInvFVBridge::createObjectBridge(this, inventory_root); - if(bridge) + if (LLTaskInvFVBridge* bridge = LLTaskInvFVBridge::createObjectBridge(this, inventory_root)) { LLUIColor item_color = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); @@ -1611,59 +1590,50 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li // Find all in the first pass std::vector<obj_folder_pair*> child_categories; - LLTaskInvFVBridge* bridge; - LLFolderViewItem* view; - - LLInventoryObject::object_list_t::iterator it = inventory->begin(); - LLInventoryObject::object_list_t::iterator end = inventory->end(); - for( ; it != end; ++it) + for (const LLPointer<LLInventoryObject>& obj : *inventory) { - LLInventoryObject* obj = *it; - - if(parent->getUUID() == obj->getParentUUID()) + if (parent->getUUID() == obj->getParentUUID()) { - bridge = LLTaskInvFVBridge::createObjectBridge(this, obj); - if(!bridge) + if (LLTaskInvFVBridge* bridge = LLTaskInvFVBridge::createObjectBridge(this, obj)) { - continue; - } - if(LLAssetType::AT_CATEGORY == obj->getType()) - { - LLFolderViewFolder::Params p; - p.name = obj->getName(); - p.root = mFolders; - p.listener = bridge; - p.tool_tip = p.name; - p.font_color = item_color; - p.font_highlight_color = item_color; - view = LLUICtrlFactory::create<LLFolderViewFolder>(p); - child_categories.push_back(new obj_folder_pair(obj, - (LLFolderViewFolder*)view)); - } - else - { - LLFolderViewItem::Params params; - params.name(obj->getName()); - params.creation_date(bridge->getCreationDate()); - params.root(mFolders); - params.listener(bridge); - params.rect(LLRect()); - params.tool_tip = params.name; - params.font_color = item_color; - params.font_highlight_color = item_color; - view = LLUICtrlFactory::create<LLFolderViewItem> (params); + LLFolderViewItem* view; + if (LLAssetType::AT_CATEGORY == obj->getType()) + { + LLFolderViewFolder::Params params; + params.name = obj->getName(); + params.root = mFolders; + params.listener = bridge; + params.tool_tip = params.name; + params.font_color = item_color; + params.font_highlight_color = item_color; + view = LLUICtrlFactory::create<LLFolderViewFolder>(params); + child_categories.push_back(new obj_folder_pair(obj, (LLFolderViewFolder*)view)); + } + else + { + LLFolderViewItem::Params params; + params.name = obj->getName(); + params.root = mFolders; + params.listener = bridge; + params.creation_date = bridge->getCreationDate(); + params.rect = LLRect(); + params.tool_tip = params.name; + params.font_color = item_color; + params.font_highlight_color = item_color; + view = LLUICtrlFactory::create<LLFolderViewItem>(params); + } + + view->addToFolder(folder); + addItemID(obj->getUUID(), view); } - view->addToFolder(folder); - addItemID(obj->getUUID(), view); } } // now, for each category, do the second pass - for(S32 i = 0; i < child_categories.size(); i++) + for (obj_folder_pair* pair : child_categories) { - createViewsForCategory(inventory, child_categories[i]->first, - child_categories[i]->second ); - delete child_categories[i]; + createViewsForCategory(inventory, pair->first, pair->second); + delete pair; } folder->setChildrenInited(true); } @@ -1675,11 +1645,10 @@ void LLPanelObjectInventory::refresh() const bool non_root_ok = true; LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); LLSelectNode* node = selection->getFirstRootNode(NULL, non_root_ok); - if(node && node->mValid) + if (node && node->mValid) { LLViewerObject* object = node->getObject(); - if(object && ((selection->getRootObjectCount() == 1) - || (selection->getObjectCount() == 1))) + if (object && ((selection->getRootObjectCount() == 1) || (selection->getObjectCount() == 1))) { // determine if we need to make a request. Start with a // default based on if we have inventory at all. @@ -1687,7 +1656,7 @@ void LLPanelObjectInventory::refresh() // If the task id is different than what we've stored, // then make the request. - if(mTaskUUID != object->mID) + if (mTaskUUID != object->mID) { mTaskUUID = object->mID; mAttachmentUUID = object->getAttachmentItemID(); @@ -1713,26 +1682,28 @@ void LLPanelObjectInventory::refresh() // Based on the node information, we may need to dirty the // object inventory and get it again. - if(node->mValid) + if (node->mValid) { - if(node->mInventorySerial != object->getInventorySerial() || object->isInventoryDirty()) + if (node->mInventorySerial != object->getInventorySerial() || object->isInventoryDirty()) { make_request = true; } } // do the request if necessary. - if(make_request) + if (make_request) { requestVOInventory(); } has_inventory = true; } } - if(!has_inventory) + + if (!has_inventory) { clearInventoryTask(); } + mInventoryViewModel.setTaskID(mTaskUUID); //LL_INFOS() << "LLPanelObjectInventory::refresh() " << mTaskUUID << LL_ENDL; } @@ -1747,7 +1718,7 @@ void LLPanelObjectInventory::clearInventoryTask() void LLPanelObjectInventory::removeSelectedItem() { - if(mFolders) + if (mFolders) { mFolders->removeSelectedItems(); } @@ -1755,7 +1726,7 @@ void LLPanelObjectInventory::removeSelectedItem() void LLPanelObjectInventory::startRenamingSelectedItem() { - if(mFolders) + if (mFolders) { mFolders->startRenamingSelectedItem(); } @@ -1765,25 +1736,26 @@ void LLPanelObjectInventory::draw() { LLPanel::draw(); - if(mIsInventoryEmpty) + if (mIsInventoryEmpty) { - if((LLUUID::null != mTaskUUID) && (!mHaveInventory)) + std::string text; + if (!mHaveInventory && mTaskUUID.notNull()) + { + text = LLTrans::getString("LoadingContents"); + } + else if (mHaveInventory) { - LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("LoadingContents"), 0, - (S32)(getRect().getWidth() * 0.5f), - 10, - LLColor4( 1, 1, 1, 1 ), - LLFontGL::HCENTER, - LLFontGL::BOTTOM); + text = LLTrans::getString("NoContents"); } - else if(mHaveInventory) + + if (!text.empty()) { - LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("NoContents"), 0, - (S32)(getRect().getWidth() * 0.5f), - 10, - LLColor4( 1, 1, 1, 1 ), - LLFontGL::HCENTER, - LLFontGL::BOTTOM); + LLFontGL::getFontSansSerif()->renderUTF8(text, 0, + (S32)(getRect().getWidth() * 0.5f), + 10, + LLColor4(1, 1, 1, 1), + LLFontGL::HCENTER, + LLFontGL::BOTTOM); } } } @@ -1797,31 +1769,21 @@ void LLPanelObjectInventory::deleteAllChildren() bool LLPanelObjectInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { - if (mFolders) - { - LLFolderViewItem* folderp = mFolders->getNextFromChild(NULL); - if (!folderp) - { - return false; - } - // Try to pass on unmodified mouse coordinates - S32 local_x = x - mFolders->getRect().mLeft; - S32 local_y = y - mFolders->getRect().mBottom; + LLFolderViewItem* folderp = mFolders ? mFolders->getNextFromChild(NULL) : NULL; + if (!folderp) + return false; - if (mFolders->pointInView(local_x, local_y)) - { - return mFolders->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - } - else - { - //force mouse coordinates to be inside folder rectangle - return mFolders->handleDragAndDrop(5, 1, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - } - } - else + // Try to pass on unmodified mouse coordinates + S32 local_x = x - mFolders->getRect().mLeft; + S32 local_y = y - mFolders->getRect().mBottom; + + if (mFolders->pointInView(local_x, local_y)) { - return false; + return mFolders->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); } + + //force mouse coordinates to be inside folder rectangle + return mFolders->handleDragAndDrop(5, 1, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); } //static @@ -1858,11 +1820,9 @@ void LLPanelObjectInventory::onFocusReceived() LLPanel::onFocusReceived(); } - LLFolderViewItem* LLPanelObjectInventory::getItemByID( const LLUUID& id ) { - std::map<LLUUID, LLFolderViewItem*>::iterator map_it; - map_it = mItemMap.find(id); + std::map<LLUUID, LLFolderViewItem*>::iterator map_it = mItemMap.find(id); if (map_it != mItemMap.end()) { return map_it->second; @@ -1913,21 +1873,21 @@ bool LLPanelObjectInventory::isSelectionRemovable() { return false; } + std::set<LLFolderViewItem*> selection_set = mFolders->getRoot()->getSelectionList(); if (selection_set.empty()) { return false; } - for (std::set<LLFolderViewItem*>::iterator iter = selection_set.begin(); - iter != selection_set.end(); - ++iter) + + for (LLFolderViewItem* item : selection_set) { - LLFolderViewItem *item = *iter; const LLFolderViewModelItemInventory *listener = dynamic_cast<const LLFolderViewModelItemInventory*>(item->getViewModelItem()); if (!listener || !listener->isItemRemovable() || listener->isItemInTrash()) { return false; } } + return true; } diff --git a/indra/newview/llpanelobjectinventory.h b/indra/newview/llpanelobjectinventory.h index c150a841ae..abb48dbeed 100644 --- a/indra/newview/llpanelobjectinventory.h +++ b/indra/newview/llpanelobjectinventory.h @@ -73,6 +73,8 @@ public: void startRenamingSelectedItem(); LLFolderView* getRootFolder() const { return mFolders; } + LLInventoryFilter& getFilter() { return mInventoryViewModel.getFilter(); } + const LLInventoryFilter& getFilter() const { return mInventoryViewModel.getFilter(); } virtual void draw(); virtual void deleteAllChildren(); diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp index 18588514f8..87f05f2028 100644 --- a/indra/newview/llpanelplaceprofile.cpp +++ b/indra/newview/llpanelplaceprofile.cpp @@ -629,6 +629,11 @@ void LLPanelPlaceProfile::updateCovenantText(const std::string &text) mCovenantText->setText(text); } +void LLPanelPlaceProfile::updateCovenant(const LLTextBase* source) +{ + mCovenantText->copyContents(source); +} + void LLPanelPlaceProfile::onForSaleBannerClick() { LLViewerParcelMgr* mgr = LLViewerParcelMgr::getInstance(); diff --git a/indra/newview/llpanelplaceprofile.h b/indra/newview/llpanelplaceprofile.h index 45a20fb86a..f562be0f5d 100644 --- a/indra/newview/llpanelplaceprofile.h +++ b/indra/newview/llpanelplaceprofile.h @@ -31,6 +31,7 @@ class LLAccordionCtrl; class LLIconCtrl; +class LLTextBase; class LLTextEditor; class LLPanelPlaceProfile : public LLPanelPlaceInfo @@ -60,6 +61,7 @@ public: void updateEstateName(const std::string& name); void updateEstateOwnerName(const std::string& name); void updateCovenantText(const std::string &text); + void updateCovenant(const LLTextBase* source); private: void onForSaleBannerClick(); diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 4e905ae0fd..4db0a5b59d 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -63,11 +63,10 @@ #include "llfloatertools.h" // to enable hide if build tools are up #include "llvector4a.h" -// Functions pulled from pipeline.cpp -glh::matrix4f get_current_modelview(); -glh::matrix4f get_current_projection(); +#include <glm/gtx/transform2.hpp> + // Functions pulled from llviewerdisplay.cpp -bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model); +bool get_hud_matrices(glm::mat4 &proj, glm::mat4 &model); // Warning: make sure these two match! const LLPanelPrimMediaControls::EZoomLevel LLPanelPrimMediaControls::kZoomLevels[] = { ZOOM_NONE, ZOOM_MEDIUM }; @@ -646,13 +645,13 @@ void LLPanelPrimMediaControls::updateShape() vert_it = vect_face.begin(); vert_end = vect_face.end(); - glh::matrix4f mat; + glm::mat4 mat; if (!is_hud) { mat = get_current_projection() * get_current_modelview(); } else { - glh::matrix4f proj, modelview; + glm::mat4 proj, modelview; if (get_hud_matrices(proj, modelview)) mat = proj * modelview; } @@ -661,11 +660,11 @@ void LLPanelPrimMediaControls::updateShape() for(; vert_it != vert_end; ++vert_it) { // project silhouette vertices into screen space - glh::vec3f screen_vert = glh::vec3f(vert_it->mV); - mat.mult_matrix_vec(screen_vert); + glm::vec3 screen_vert(glm::make_vec3(vert_it->mV)); + screen_vert = mul_mat4_vec3(mat, screen_vert); // add to screenspace bounding box - update_min_max(min, max, LLVector3(screen_vert.v)); + update_min_max(min, max, LLVector3(glm::value_ptr(screen_vert))); } // convert screenspace bbox to pixels (in screen coords) diff --git a/indra/newview/llpanelprofilepicks.cpp b/indra/newview/llpanelprofilepicks.cpp index 08f3d3af5a..11a10ebd2c 100644 --- a/indra/newview/llpanelprofilepicks.cpp +++ b/indra/newview/llpanelprofilepicks.cpp @@ -246,6 +246,8 @@ void LLPanelProfilePicks::onClickNewBtn() select_tab(true). label(pick_panel->getPickName())); updateButtons(); + + pick_panel->addLocationChangedCallbacks(); } void LLPanelProfilePicks::onClickDelete() @@ -571,10 +573,12 @@ void LLPanelProfilePick::setAvatarId(const LLUUID& avatar_id) { mPickName->setEnabled(true); mPickDescription->setEnabled(true); + mSetCurrentLocationButton->setVisible(true); } else { mSnapshotCtrl->setEnabled(false); + mSetCurrentLocationButton->setVisible(false); } } @@ -585,6 +589,7 @@ bool LLPanelProfilePick::postBuild() mSaveButton = getChild<LLButton>("save_changes_btn"); mCreateButton = getChild<LLButton>("create_changes_btn"); mCancelButton = getChild<LLButton>("cancel_changes_btn"); + mSetCurrentLocationButton = getChild<LLButton>("set_to_curr_location_btn"); mSnapshotCtrl = getChild<LLTextureCtrl>("pick_snapshot"); mSnapshotCtrl->setCommitCallback(boost::bind(&LLPanelProfilePick::onSnapshotChanged, this)); @@ -597,6 +602,7 @@ bool LLPanelProfilePick::postBuild() mSaveButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSave, this)); mCreateButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSave, this)); mCancelButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickCancel, this)); + mSetCurrentLocationButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSetLocation, this)); mPickName->setKeystrokeCallback(boost::bind(&LLPanelProfilePick::onPickChanged, this, _1), NULL); mPickName->setEnabled(false); @@ -759,6 +765,32 @@ bool LLPanelProfilePick::isDirty() const return false; } +void LLPanelProfilePick::onClickSetLocation() +{ + // Save location for later use. + setPosGlobal(gAgent.getPositionGlobal()); + + std::string parcel_name, region_name; + + LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); + if (parcel) + { + mParcelId = parcel->getID(); + parcel_name = parcel->getName(); + } + + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + region_name = region->getName(); + } + + setPickLocation(createLocationText(getLocationNotice(), parcel_name, region_name, getPosGlobal())); + + mLocationChanged = true; + enableSaveButton(true); +} + void LLPanelProfilePick::onClickSave() { if (mRegionCallbackConnection.connected()) @@ -769,6 +801,10 @@ void LLPanelProfilePick::onClickSave() { mParcelCallbackConnection.disconnect(); } + if (mLocationChanged) + { + onClickSetLocation(); + } sendUpdate(); mLocationChanged = false; @@ -816,6 +852,12 @@ void LLPanelProfilePick::processParcelInfo(const LLParcelData& parcel_data) } } +void LLPanelProfilePick::addLocationChangedCallbacks() +{ + mRegionCallbackConnection = gAgent.addRegionChangedCallback([this]() { onClickSetLocation(); }); + mParcelCallbackConnection = gAgent.addParcelChangedCallback([this]() { onClickSetLocation(); }); +} + void LLPanelProfilePick::sendUpdate() { LLPickData pick_data; diff --git a/indra/newview/llpanelprofilepicks.h b/indra/newview/llpanelprofilepicks.h index e3f50f5576..5e5d4ff81e 100644 --- a/indra/newview/llpanelprofilepicks.h +++ b/indra/newview/llpanelprofilepicks.h @@ -138,6 +138,8 @@ public: void setParcelID(const LLUUID& parcel_id) override { mParcelId = parcel_id; } void setErrorStatus(S32 status, const std::string& reason) override {}; + void addLocationChangedCallbacks(); + protected: /** @@ -200,6 +202,11 @@ public: void resetDirty() override; /** + * Callback for "Set Location" button click + */ + void onClickSetLocation(); + + /** * Callback for "Save" and "Create" button click */ void onClickSave(); @@ -221,6 +228,7 @@ protected: LLTextureCtrl* mSnapshotCtrl; LLLineEditor* mPickName; LLTextEditor* mPickDescription; + LLButton* mSetCurrentLocationButton; LLButton* mSaveButton; LLButton* mCreateButton; LLButton* mCancelButton; @@ -236,7 +244,7 @@ protected: bool mLocationChanged; bool mNewPick; - bool mIsEditing; + bool mIsEditing; void onDescriptionFocusReceived(); }; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 8d164b6883..f77d37f821 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -253,23 +253,22 @@ bool LLReflectionMap::getBox(LLMatrix4& box) LLVolume* volume = mViewerObject->getVolume(); if (volume && mViewerObject->getReflectionProbeIsBox()) { - glh::matrix4f mv(gGLModelView); - glh::matrix4f scale; + glm::mat4 mv(get_current_modelview()); LLVector3 s = mViewerObject->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); mRadius = s.magVec(); - scale.set_scale(glh::vec3f(s.mV)); + glm::mat4 scale = glm::scale(glm::make_vec3(s.mV)); if (mViewerObject->mDrawable != nullptr) { // object to agent space (no scale) - glh::matrix4f rm((F32*)mViewerObject->mDrawable->getWorldMatrix().mMatrix); + glm::mat4 rm(glm::make_mat4((F32*)mViewerObject->mDrawable->getWorldMatrix().mMatrix)); // construct object to camera space (with scale) mv = mv * rm * scale; // inverse is camera space to object unit cube - mv = mv.inverse(); + mv = glm::inverse(mv); - box = LLMatrix4(mv.m); + box = LLMatrix4(glm::value_ptr(mv)); return true; } diff --git a/indra/newview/llsecapi.h b/indra/newview/llsecapi.h index ceea11cc34..14dda20225 100644 --- a/indra/newview/llsecapi.h +++ b/indra/newview/llsecapi.h @@ -28,7 +28,7 @@ #ifndef LLSECAPI_H #define LLSECAPI_H #include <vector> -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <openssl/x509.h> #include <ostream> #include "llpointer.h" diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 342048252f..51da051340 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -103,20 +103,12 @@ LLViewerObject* getSelectedParentObject(LLViewerObject *object) ; // Consts // -const F32 SILHOUETTE_UPDATE_THRESHOLD_SQUARED = 0.02f; -const S32 MAX_SILS_PER_FRAME = 50; -const S32 MAX_OBJECTS_PER_PACKET = 254; +constexpr F32 SILHOUETTE_UPDATE_THRESHOLD_SQUARED = 0.02f; +constexpr S32 MAX_SILS_PER_FRAME = 50; +constexpr S32 MAX_OBJECTS_PER_PACKET = 254; // For linked sets -const S32 MAX_CHILDREN_PER_TASK = 255; +constexpr S32 MAX_CHILDREN_PER_TASK = 255; -// -// Globals -// - -//bool gDebugSelectMgr = false; - -//bool gHideSelectedObjects = false; -//bool gAllowSelectAvatar = false; bool LLSelectMgr::sRectSelectInclusive = true; bool LLSelectMgr::sRenderHiddenSelections = true; diff --git a/indra/newview/llsettingspicker.cpp b/indra/newview/llsettingspicker.cpp index 24cf543864..619882dc5e 100644 --- a/indra/newview/llsettingspicker.cpp +++ b/indra/newview/llsettingspicker.cpp @@ -98,7 +98,7 @@ bool LLFloaterSettingsPicker::postBuild() setTitle(prefix + " " + label); mFilterEdit = getChild<LLFilterEditor>(FLT_INVENTORY_SEARCH); - mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param){ onFilterEdit(param.asString()); }); + mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param) { onFilterEdit(param.asString()); }); mInventoryPanel = getChild<LLInventoryPanel>(PNL_INVENTORY); if (mInventoryPanel) @@ -203,7 +203,6 @@ void LLFloaterSettingsPicker::draw() LLFloater::draw(); } - //========================================================================= void LLFloaterSettingsPicker::onFilterEdit(const std::string& search_string) { @@ -224,7 +223,6 @@ void LLFloaterSettingsPicker::onFilterEdit(const std::string& search_string) LLOpenFoldersWithSelection opener; mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener); mInventoryPanel->getRootFolder()->scrollToShowSelection(); - } else if (mInventoryPanel->getFilterSubString().empty()) { @@ -269,6 +267,7 @@ void LLFloaterSettingsPicker::onSelectionChange(const LLFloaterSettingsPicker::i } } } + bool track_picker_enabled = mTrackMode != TRACK_NONE; getChild<LLView>(CMB_TRACK_SELECTION)->setEnabled(is_item && track_picker_enabled && mSettingAssetID == asset_id); @@ -304,13 +303,14 @@ void LLFloaterSettingsPicker::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr LLComboBox* track_selection = getChild<LLComboBox>(CMB_TRACK_SELECTION); track_selection->clear(); track_selection->removeall(); + if (!settings) { LL_WARNS() << "Failed to load asset " << asset_id << LL_ENDL; return; } - LLSettingsDay::ptr_t pday = std::dynamic_pointer_cast<LLSettingsDay>(settings); + LLSettingsDay::ptr_t pday = std::dynamic_pointer_cast<LLSettingsDay>(settings); if (!pday) { LL_WARNS() << "Wrong asset type received by id " << asset_id << LL_ENDL; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index e05b6f3736..34b8535c84 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -549,7 +549,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() return skyp; } -LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() { LLSD settings = cloneSettings(); U32 flags = getFlags(); @@ -684,6 +684,67 @@ void LLSettingsVOSky::updateSettings() gSky.setMoonScale(getMoonScale()); } +void draw_color(LLShaderUniforms* shader, const LLColor3& col, S32 shader_key) +{ + // always identify as a radiance pass if desaturating irradiance is disabled + static LLCachedControl<bool> desaturate_irradiance(gSavedSettings, "RenderDesaturateIrradiance", true); + + LLVector4 vect4(col.mV[0], col.mV[1], col.mV[2]); + + if (desaturate_irradiance && gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass()) + { // maximize and remove tinting if this is an irradiance map render pass and the parameter feeds into the sky background color + auto max_vec = [](LLVector4 col) + { + LLColor3 color(col); + F32 h, s, l; + color.calcHSL(&h, &s, &l); + + col.mV[0] = col.mV[1] = col.mV[2] = l; + return col; + }; + + switch (shader_key) + { + case LLShaderMgr::BLUE_HORIZON: + case LLShaderMgr::BLUE_DENSITY: + vect4 = max_vec(vect4); + break; + } + } + + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; + shader->uniform3fv(shader_key, LLVector3(vect4.mV)); +} + +inline void draw_real(LLShaderUniforms* shader, F32 value, S32 shader_key) +{ + shader->uniform1f(shader_key, value); +} + +void LLSettingsVOSky::applyToUniforms(void* ptarget) +{ + LLShaderUniforms* shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_ANY]; + + draw_color(shader, getAmbientColor(), LLShaderMgr::AMBIENT); + draw_color(shader, getBlueDensity(), LLShaderMgr::BLUE_DENSITY); + draw_color(shader, getBlueHorizon(), LLShaderMgr::BLUE_HORIZON); + draw_real(shader, getHazeDensity(), LLShaderMgr::HAZE_DENSITY); + draw_real(shader, getHazeHorizon(), LLShaderMgr::HAZE_HORIZON); + draw_real(shader, getDensityMultiplier(), LLShaderMgr::DENSITY_MULTIPLIER); + draw_real(shader, getDistanceMultiplier(), LLShaderMgr::DISTANCE_MULTIPLIER); + draw_color(shader, getCloudPosDensity2(), LLShaderMgr::CLOUD_POS_DENSITY2); + draw_real(shader, getCloudScale(), LLShaderMgr::CLOUD_SCALE); + draw_real(shader, getCloudShadow(), LLShaderMgr::CLOUD_SHADOW); + draw_real(shader, getCloudVariance(), LLShaderMgr::CLOUD_VARIANCE); + draw_color(shader, getGlow(), LLShaderMgr::GLOW); + draw_real(shader, getMaxY(), LLShaderMgr::MAX_Y); + draw_real(shader, getMoonBrightness(), LLShaderMgr::MOON_BRIGHTNESS); + draw_real(shader, getSkyMoistureLevel(), LLShaderMgr::MOISTURE_LEVEL); + draw_real(shader, getSkyDropletRadius(), LLShaderMgr::DROPLET_RADIUS); + draw_real(shader, getSkyIceLevel(), LLShaderMgr::ICE_LEVEL); + draw_real(shader, getReflectionProbeAmbiance(), LLShaderMgr::REFLECTION_PROBE_AMBIANCE); +} + void LLSettingsVOSky::applySpecial(void *ptarget, bool force) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; @@ -702,7 +763,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, light_direction); // Legacy? SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate") - LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + LLVector4 vect_c_p_d1(mCloudPosDensity1.mV[0], mCloudPosDensity1.mV[1], mCloudPosDensity1.mV[2]); LLVector4 cloud_scroll( LLEnvironment::instance().getCloudScrollDelta() ); // SL-13084 EEP added support for custom cloud textures -- flip them horizontally to match the preview of Clouds > Cloud Scroll @@ -935,7 +996,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() return waterp; } -LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() { LLSD settings = cloneSettings(); U32 flags = getFlags(); @@ -974,6 +1035,12 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) } //------------------------------------------------------------------------- //------------------------------------------------------------------------- + +void LLSettingsVOWater::applyToUniforms(void*) +{ + +} + void LLSettingsVOWater::applySpecial(void *ptarget, bool force) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; @@ -996,38 +1063,33 @@ void LLSettingsVOWater::applySpecial(void *ptarget, bool force) } //transform water plane to eye space - glh::vec3f norm(0.f, 0.f, 1.f); - glh::vec3f p(0.f, 0.f, water_height); + glm::vec3 norm(0.f, 0.f, 1.f); + glm::vec3 p(0.f, 0.f, water_height); - F32 modelView[16]; - for (U32 i = 0; i < 16; i++) - { - modelView[i] = (F32)gGLModelView[i]; - } + glm::mat4 mat = get_current_modelview(); + glm::mat4 invtrans = glm::transpose(glm::inverse(mat)); + invtrans[0][3] = invtrans[1][3] = invtrans[2][3] = 0.f; - glh::matrix4f mat(modelView); - glh::matrix4f invtrans = mat.inverse().transpose(); - invtrans.m[3] = invtrans.m[7] = invtrans.m[11] = 0.f; - glh::vec3f enorm; - glh::vec3f ep; - invtrans.mult_matrix_vec(norm, enorm); - enorm.normalize(); - mat.mult_matrix_vec(p, ep); + glm::vec3 enorm; + glm::vec3 ep; + enorm = mul_mat4_vec3(invtrans, norm); + enorm = glm::normalize(enorm); + ep = mul_mat4_vec3(mat, p); - LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + LLVector4 waterPlane(enorm.x, enorm.y, enorm.z, -glm::dot(ep, enorm)); - norm = glh::vec3f(gPipeline.mHeroProbeManager.mMirrorNormal.mV); - p = glh::vec3f(gPipeline.mHeroProbeManager.mMirrorPosition.mV); - invtrans.mult_matrix_vec(norm, enorm); - enorm.normalize(); - mat.mult_matrix_vec(p, ep); + norm = glm::make_vec3(gPipeline.mHeroProbeManager.mMirrorNormal.mV); + p = glm::make_vec3(gPipeline.mHeroProbeManager.mMirrorPosition.mV); + enorm = mul_mat4_vec3(invtrans, norm); + enorm = glm::normalize(enorm); + ep = mul_mat4_vec3(mat, p); - LLVector4 mirrorPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + glm::vec4 mirrorPlane(enorm, -glm::dot(ep, enorm)); LLDrawPoolAlpha::sWaterPlane = waterPlane; shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, waterPlane.mV); - shader->uniform4fv(LLShaderMgr::CLIP_PLANE, mirrorPlane.mV); + shader->uniform4fv(LLShaderMgr::CLIP_PLANE, glm::value_ptr(mirrorPlane)); LLVector4 light_direction = env.getClampedLightNorm(); if (gPipeline.mHeroProbeManager.isMirrorPass()) @@ -1373,7 +1435,7 @@ void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsB } -LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); @@ -1398,10 +1460,10 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const return dayp; } -LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const +LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() { // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD - LLSD settings = llsd_clone(mSettings); + LLSD settings = llsd_clone(getSettings()); U32 flags = getFlags(); LLSettingsDay::ptr_t day_clone = std::make_shared<LLSettingsVODay>(settings); diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index c55b3f82b9..92cb8d0704 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -94,7 +94,7 @@ public: static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages); static ptr_t buildDefaultSky(); - virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() SETTINGS_OVERRIDE; static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); @@ -110,6 +110,7 @@ protected: virtual void updateSettings() override; + virtual void applyToUniforms(void*) override; virtual void applySpecial(void *, bool) override; virtual parammapping_t getParameterMap() const override; @@ -128,7 +129,7 @@ public: static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages); static ptr_t buildDefaultWater(); - virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() SETTINGS_OVERRIDE; static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); @@ -138,6 +139,7 @@ protected: LLSettingsVOWater(); virtual void updateSettings() override; + virtual void applyToUniforms(void*) override; virtual void applySpecial(void *, bool) override; virtual parammapping_t getParameterMap() const override; @@ -167,8 +169,8 @@ public: static ptr_t buildDefaultDayCycle(); static ptr_t buildFromEnvironmentMessage(LLSD settings); static void buildFromOtherSetting(LLSettingsBase::ptr_t settings, asset_built_fn cb); - virtual ptr_t buildClone() const SETTINGS_OVERRIDE; - virtual ptr_t buildDeepCloneAndUncompress() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() SETTINGS_OVERRIDE; + virtual ptr_t buildDeepCloneAndUncompress() SETTINGS_OVERRIDE; static LLSD convertToLegacy(const ptr_t &); diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 5693f2808c..b48417bd71 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -387,7 +387,7 @@ void LLSidepanelInventory::onToggleInboxBtn() void LLSidepanelInventory::onOpen(const LLSD& key) { LLFirstUse::newInventory(false); - mPanelMainInventory->setFocusFilterEditor(); + mPanelMainInventory->setFocusOnFilterEditor(); #if AUTO_EXPAND_INBOX // Expand the inbox if we have fresh items LLPanelMarketplaceInbox * inbox = findChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL); diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index 9b4ed4c946..cee43f3cff 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -315,23 +315,18 @@ void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar) } } -static LLTrace::BlockTimerStatHandle FTM_FACE_RIGGING_INFO("Face Rigging Info"); - void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *avatar, LLVolumeFace& vol_face) { - LL_RECORD_BLOCK_TIME(FTM_FACE_RIGGING_INFO); - if (vol_face.mJointRiggingInfoTab.needsUpdate()) { S32 num_verts = vol_face.mNumVertices; S32 num_joints = static_cast<S32>(skin->mJointNames.size()); if (num_verts > 0 && vol_face.mWeights && num_joints > 0) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; initJointNums(const_cast<LLMeshSkinInfo*>(skin), avatar); if (vol_face.mJointRiggingInfoTab.size()==0) { - //std::set<S32> active_joints; - //S32 active_verts = 0; vol_face.mJointRiggingInfoTab.resize(LL_CHARACTER_MAX_ANIMATED_JOINTS); LLJointRiggingInfoTab &rig_info_tab = vol_face.mJointRiggingInfoTab; for (S32 i=0; i<vol_face.mNumVertices; i++) @@ -347,35 +342,22 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a F32 w = weights[k]; idx[k] = llclamp((S32) floorf(w), (S32)0, (S32)LL_CHARACTER_MAX_ANIMATED_JOINTS-1); wght[k] = w - idx[k]; - scale += wght[k]; - } - if (scale > 0.0f) - { - for (U32 k=0; k<4; ++k) - { - wght[k] /= scale; - } } + for (U32 k=0; k<4; ++k) { S32 joint_index = idx[k]; - if (wght[k] > 0.0f && num_joints > joint_index) + if (wght[k] > 0.2f && num_joints > joint_index) { S32 joint_num = skin->mJointNums[joint_index]; if (joint_num >= 0 && joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS) { rig_info_tab[joint_num].setIsRiggedTo(true); - // FIXME could precompute these matMuls. - const LLMatrix4a& bind_shape = skin->mBindShapeMatrix; - const LLMatrix4a& inv_bind = skin->mInvBindMatrix[joint_index]; - LLMatrix4a mat; + const LLMatrix4a& mat = skin->mBindPoseMatrix[joint_index]; LLVector4a pos_joint_space; - matMul(bind_shape, inv_bind, mat); - mat.affineTransform(pos, pos_joint_space); - pos_joint_space.mul(wght[k]); LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents(); update_min_max(extents[0], extents[1], pos_joint_space); @@ -383,28 +365,9 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a } } } - //LL_DEBUGS("RigSpammish") << "built rigging info for vf " << &vol_face - // << " num_verts " << vol_face.mNumVertices - // << " active joints " << active_joints.size() - // << " active verts " << active_verts - // << LL_ENDL; vol_face.mJointRiggingInfoTab.setNeedsUpdate(false); } } - -#if DEBUG_SKINNING - if (vol_face.mJointRiggingInfoTab.size()!=0) - { - LL_DEBUGS("RigSpammish") << "we have rigging info for vf " << &vol_face - << " num_verts " << vol_face.mNumVertices << LL_ENDL; - } - else - { - LL_DEBUGS("RigSpammish") << "no rigging info for vf " << &vol_face - << " num_verts " << vol_face.mNumVertices << LL_ENDL; - } -#endif - } } diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 0b73aa493c..ea95d71b27 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -295,13 +295,20 @@ void LLSnapshotLivePreview::draw() gGL.pushMatrix(); { gGL.translatef((F32)rect.mLeft, (F32)rect.mBottom + TOP_PANEL_HEIGHT, 0.f); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(uv_width, uv_height); - gGL.vertex2i(rect.getWidth(), rect.getHeight() ); + gGL.vertex2i(rect.getWidth(), rect.getHeight()); gGL.texCoord2f(0.f, uv_height); - gGL.vertex2i(0, rect.getHeight() ); + gGL.vertex2i(0, rect.getHeight()); + + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(0, 0); + + + gGL.texCoord2f(uv_width, uv_height); + gGL.vertex2i(rect.getWidth(), rect.getHeight()); gGL.texCoord2f(0.f, 0.f); gGL.vertex2i(0, 0); @@ -357,13 +364,18 @@ void LLSnapshotLivePreview::draw() S32 y2 = gViewerWindow->getWindowHeightScaled() + TOP_PANEL_HEIGHT; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.color4f(1.f, 1.f, 1.f, 0.f); gGL.vertex2i(x1, y1); gGL.vertex2i(x1 + gViewerWindow->getWindowWidthScaled(), y2); gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); gGL.vertex2i(x2 + gViewerWindow->getWindowWidthScaled(), y2); + + gGL.color4f(1.f, 1.f, 1.f, 0.f); + gGL.vertex2i(x1, y1); + gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); + gGL.vertex2i(x2 + gViewerWindow->getWindowWidthScaled(), y2); gGL.vertex2i(x2, y1); gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); @@ -371,6 +383,11 @@ void LLSnapshotLivePreview::draw() gGL.vertex2i(x2 + gViewerWindow->getWindowWidthScaled(), y2); gGL.color4f(1.f, 1.f, 1.f, 0.f); gGL.vertex2i(x3 + gViewerWindow->getWindowWidthScaled(), y2); + + gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); + gGL.vertex2i(x2, y1); + gGL.color4f(1.f, 1.f, 1.f, 0.f); + gGL.vertex2i(x3 + gViewerWindow->getWindowWidthScaled(), y2); gGL.vertex2i(x3, y1); } gGL.end(); @@ -406,13 +423,19 @@ void LLSnapshotLivePreview::draw() LLRect& rect = mImageRect[old_image_index]; gGL.translatef((F32)rect.mLeft, (F32)rect.mBottom - ll_round(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); gGL.rotatef(-45.f * fall_interp, 0.f, 0.f, 1.f); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(uv_width, uv_height); - gGL.vertex2i(rect.getWidth(), rect.getHeight() ); + gGL.vertex2i(rect.getWidth(), rect.getHeight()); gGL.texCoord2f(0.f, uv_height); - gGL.vertex2i(0, rect.getHeight() ); + gGL.vertex2i(0, rect.getHeight()); + + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(0, 0); + + gGL.texCoord2f(uv_width, uv_height); + gGL.vertex2i(rect.getWidth(), rect.getHeight()); gGL.texCoord2f(0.f, 0.f); gGL.vertex2i(0, 0); @@ -667,18 +690,25 @@ bool LLSnapshotLivePreview::onIdle( void* snapshot_preview ) return false; } + static LLCachedControl<bool> auto_snapshot(gSavedSettings, "AutoSnapshot", false); + static LLCachedControl<bool> freeze_time(gSavedSettings, "FreezeTime", false); + static LLCachedControl<bool> use_freeze_frame(gSavedSettings, "UseFreezeFrame", false); + static LLCachedControl<bool> render_ui(gSavedSettings, "RenderUIInSnapshot", false); + static LLCachedControl<bool> render_hud(gSavedSettings, "RenderHUDInSnapshot", false); + static LLCachedControl<bool> render_no_post(gSavedSettings, "RenderSnapshotNoPost", false); + // If we're in freeze-frame and/or auto update mode and camera has moved, update snapshot. LLVector3 new_camera_pos = LLViewerCamera::getInstance()->getOrigin(); LLQuaternion new_camera_rot = LLViewerCamera::getInstance()->getQuaternion(); if (previewp->mForceUpdateSnapshot || - (((gSavedSettings.getBOOL("AutoSnapshot") && LLView::isAvailable(previewp->mViewContainer)) || - (gSavedSettings.getBOOL("FreezeTime") && previewp->mAllowFullScreenPreview)) && + (((auto_snapshot && LLView::isAvailable(previewp->mViewContainer)) || + (freeze_time && previewp->mAllowFullScreenPreview)) && (new_camera_pos != previewp->mCameraPos || dot(new_camera_rot, previewp->mCameraRot) < 0.995f))) { previewp->mCameraPos = new_camera_pos; previewp->mCameraRot = new_camera_rot; // request a new snapshot whenever the camera moves, with a time delay - bool new_snapshot = gSavedSettings.getBOOL("AutoSnapshot") || previewp->mForceUpdateSnapshot; + bool new_snapshot = auto_snapshot || previewp->mForceUpdateSnapshot; LL_DEBUGS("Snapshot") << "camera moved, updating thumbnail" << LL_ENDL; previewp->updateSnapshot( new_snapshot, // whether a new snapshot is needed or merely invalidate the existing one @@ -716,10 +746,10 @@ bool LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->getHeight(), previewp->mKeepAspectRatio,//gSavedSettings.getBOOL("KeepAspectForSnapshot"), previewp->getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE, - previewp->mAllowRenderUI && gSavedSettings.getBOOL("RenderUIInSnapshot"), - gSavedSettings.getBOOL("RenderHUDInSnapshot"), + previewp->mAllowRenderUI && render_ui, + render_hud, false, - gSavedSettings.getBOOL("RenderSnapshotNoPost"), + render_no_post, previewp->mSnapshotBufferType, previewp->getMaxImageSize())) { @@ -731,7 +761,7 @@ bool LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->estimateDataSize(); // Full size preview is set: get the decoded image result and save it for animation - if (gSavedSettings.getBOOL("UseFreezeFrame") && previewp->mAllowFullScreenPreview) + if (use_freeze_frame && previewp->mAllowFullScreenPreview) { previewp->prepareFreezeFrame(); } @@ -744,7 +774,7 @@ bool LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->generateThumbnailImage(true) ; } previewp->getWindow()->decBusyCount(); - previewp->setVisible(gSavedSettings.getBOOL("UseFreezeFrame") && previewp->mAllowFullScreenPreview); // only show fullscreen preview when in freeze frame mode + previewp->setVisible(use_freeze_frame && previewp->mAllowFullScreenPreview); // only show fullscreen preview when in freeze frame mode previewp->mSnapshotActive = false; LL_DEBUGS("Snapshot") << "done creating snapshot" << LL_ENDL; } @@ -864,7 +894,9 @@ LLPointer<LLImageRaw> LLSnapshotLivePreview::getEncodedImage() else { // Update mFormattedImage if necessary - getFormattedImage(); + lock.unlock(); + getFormattedImage(); // will apply filters to mPreviewImage with a lock + lock.lock(); if (getSnapshotFormat() == LLSnapshotModel::SNAPSHOT_FORMAT_BMP) { // BMP hack : copy instead of decode otherwise decode will crash. diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index e517d009f5..a1a67c319c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -300,7 +300,7 @@ bool LLSpatialGroup::addObject(LLDrawable *drawablep) } { drawablep->setGroup(this); - setState(OBJECT_DIRTY | GEOM_DIRTY); + setState(static_cast<U32>(OBJECT_DIRTY) | static_cast<U32>(GEOM_DIRTY)); setOcclusionState(LLSpatialGroup::DISCARD_QUERY, LLSpatialGroup::STATE_MODE_ALL_CAMERAS); gPipeline.markRebuild(this); if (drawablep->isSpatialBridge()) @@ -730,7 +730,7 @@ bool LLSpatialGroup::changeLOD() { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; - if (hasState(ALPHA_DIRTY | OBJECT_DIRTY)) + if (hasState(static_cast<U32>(ALPHA_DIRTY) | static_cast<U32>(OBJECT_DIRTY))) { //a rebuild is going to happen, update distance and LoD return true; diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index c074d6a89a..3aaa3d60e8 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -47,7 +47,7 @@ #include <unordered_map> #define SG_STATE_INHERIT_MASK (OCCLUDED) -#define SG_INITIAL_STATE_MASK (DIRTY | GEOM_DIRTY) +#define SG_INITIAL_STATE_MASK (static_cast<U32>(DIRTY) | static_cast<U32>(GEOM_DIRTY)) class LLViewerOctreePartition; class LLSpatialPartition; diff --git a/indra/newview/llterrainpaintmap.cpp b/indra/newview/llterrainpaintmap.cpp index 4381d14546..8ccde74c93 100644 --- a/indra/newview/llterrainpaintmap.cpp +++ b/indra/newview/llterrainpaintmap.cpp @@ -111,12 +111,12 @@ bool LLTerrainPaintMap::bakeHeightNoiseIntoPBRPaintMapRGB(const LLViewerRegion& const LLRect texture_rect(0, scratch_target.getHeight(), scratch_target.getWidth(), 0); glViewport(texture_rect.mLeft, texture_rect.mBottom, texture_rect.getWidth(), texture_rect.getHeight()); // Manually get modelview matrix from camera orientation. - glh::matrix4f modelview((GLfloat *) OGL_TO_CFR_ROTATION); + glm::mat4 modelview(glm::make_mat4((GLfloat *) OGL_TO_CFR_ROTATION)); GLfloat ogl_matrix[16]; camera.getOpenGLTransform(ogl_matrix); - modelview *= glh::matrix4f(ogl_matrix); + modelview *= glm::make_mat4(ogl_matrix); gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(modelview.m); + gGL.loadMatrix(glm::value_ptr(modelview)); // Override the projection matrix from the camera gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp index 24cfca5eee..8ce9a8b632 100644 --- a/indra/newview/lltoolmorph.cpp +++ b/indra/newview/lltoolmorph.cpp @@ -285,7 +285,7 @@ void LLVisualParamHint::draw(F32 alpha) gGL.color4f(1.f, 1.f, 1.f, alpha); LLGLSUIDefault gls_ui; - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2i(0, 1); gGL.vertex2i(0, mFullHeight); @@ -293,6 +293,11 @@ void LLVisualParamHint::draw(F32 alpha) gGL.vertex2i(0, 0); gGL.texCoord2i(1, 0); gGL.vertex2i(mFullWidth, 0); + + gGL.texCoord2i(0, 1); + gGL.vertex2i(0, mFullHeight); + gGL.texCoord2i(1, 0); + gGL.vertex2i(mFullWidth, 0); gGL.texCoord2i(1, 1); gGL.vertex2i(mFullWidth, mFullHeight); } diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index cc04f9e3fc..3bd459f5b0 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -48,27 +48,24 @@ #include "llvoavatarself.h" #include "llworld.h" -// Globals -//extern bool gAllowSelectAvatar; - -const F32 SELECTION_ROTATION_TRESHOLD = 0.1f; -const F32 SELECTION_SITTING_ROTATION_TRESHOLD = 3.2f; //radian +constexpr F32 SELECTION_ROTATION_TRESHOLD = 0.1f; +constexpr F32 SELECTION_SITTING_ROTATION_TRESHOLD = 3.2f; //radian LLToolSelect::LLToolSelect( LLToolComposite* composite ) : LLTool( std::string("Select"), composite ), mIgnoreGroup( false ) { - } +} // True if you selected an object. bool LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) { // do immediate pick query bool pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick"); - bool pick_transparent = gSavedSettings.getBOOL("SelectInvisibleObjects"); - bool pick_reflection_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); + static LLCachedControl<bool> select_invisible_objects(gSavedSettings, "SelectInvisibleObjects"); + static LLCachedControl<bool> select_reflection_probes(gSavedSettings, "SelectReflectionProbes"); - mPick = gViewerWindow->pickImmediate(x, y, pick_transparent, pick_rigged, false, true, pick_reflection_probe); + mPick = gViewerWindow->pickImmediate(x, y, select_invisible_objects, pick_rigged, false, true, select_reflection_probes); // Pass mousedown to agent LLTool::handleMouseDown(x, y, mask); @@ -76,7 +73,6 @@ bool LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) return mPick.getObject().notNull(); } - // static LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pick, bool ignore_group, bool temp_select, bool select_root) { diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 766280e145..aa43b2dbad 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -60,28 +60,6 @@ LLTrace::CountStatHandle<> LLViewerCamera::sAngularVelocityStat("camera_angular_ LLViewerCamera::eCameraID LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; -//glu pick matrix implementation borrowed from Mesa3D -glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLint* viewport) -{ - GLfloat m[16]; - GLfloat sx, sy; - GLfloat tx, ty; - - sx = viewport[2] / width; - sy = viewport[3] / height; - tx = (viewport[2] + 2.f * (viewport[0] - x)) / width; - ty = (viewport[3] + 2.f * (viewport[1] - y)) / height; - - #define M(row,col) m[col*4+row] - M(0,0) = sx; M(0,1) = 0.f; M(0,2) = 0.f; M(0,3) = tx; - M(1,0) = 0.f; M(1,1) = sy; M(1,2) = 0.f; M(1,3) = ty; - M(2,0) = 0.f; M(2,1) = 0.f; M(2,2) = 1.f; M(2,3) = 0.f; - M(3,0) = 0.f; M(3,1) = 0.f; M(3,2) = 0.f; M(3,3) = 1.f; - #undef M - - return glh::matrix4f(m); -} - LLViewerCamera::LLViewerCamera() : LLCamera() { calcProjection(getFar()); @@ -204,59 +182,52 @@ void LLViewerCamera::calcProjection(const F32 far_distance) const //static void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, bool ortho, bool zflip, bool no_hacks) { - GLint* viewport = (GLint*) gGLViewport; - F64 model[16]; - F64 proj[16]; - - for (U32 i = 0; i < 16; i++) - { - model[i] = (F64) gGLModelView[i]; - proj[i] = (F64) gGLProjection[i]; - } - - GLdouble objX,objY,objZ; + glm::ivec4 viewport = glm::make_vec4((GLint*) gGLViewport); + glm::mat4 model = get_current_modelview(); + glm::mat4 proj = get_current_projection(); LLVector3 frust[8]; + glm::vec3 obj; if (no_hacks) { - gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); - frust[0].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); - frust[1].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); - frust[2].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); - frust[3].setVec((F32)objX,(F32)objY,(F32)objZ); - - gluUnProject(viewport[0],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); - frust[4].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); - frust[5].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); - frust[6].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); - frust[7].setVec((F32)objX,(F32)objY,(F32)objZ); + obj = glm::unProject(glm::vec3(viewport[0], viewport[1], 0), model, proj, viewport); + frust[0].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1],0),model,proj,viewport); + frust[1].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1]+viewport[3],0),model,proj,viewport); + frust[2].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1]+viewport[3],0),model,proj,viewport); + frust[3].setVec(glm::value_ptr(obj)); + + obj = glm::unProject(glm::vec3(viewport[0],viewport[1],1),model,proj,viewport); + frust[4].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1],1),model,proj,viewport); + frust[5].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1]+viewport[3],1),model,proj,viewport); + frust[6].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1]+viewport[3],1),model,proj,viewport); + frust[7].setVec(glm::value_ptr(obj)); } else if (zflip) { - gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); - frust[0].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); - frust[1].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); - frust[2].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); - frust[3].setVec((F32)objX,(F32)objY,(F32)objZ); - - gluUnProject(viewport[0],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); - frust[4].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); - frust[5].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); - frust[6].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); - frust[7].setVec((F32)objX,(F32)objY,(F32)objZ); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1]+viewport[3],0),model,proj,viewport); + frust[0].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1]+viewport[3],0),model,proj,viewport); + frust[1].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1],0),model,proj,viewport); + frust[2].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1],0),model,proj,viewport); + frust[3].setVec(glm::value_ptr(obj)); + + obj = glm::unProject(glm::vec3(viewport[0],viewport[1]+viewport[3],1),model,proj,viewport); + frust[4].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1]+viewport[3],1),model,proj,viewport); + frust[5].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1],1),model,proj,viewport); + frust[6].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1],1),model,proj,viewport); + frust[7].setVec(glm::value_ptr(obj)); for (U32 i = 0; i < 4; i++) { @@ -267,14 +238,14 @@ void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, bool ortho, bool zfli } else { - gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); - frust[0].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); - frust[1].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); - frust[2].setVec((F32)objX,(F32)objY,(F32)objZ); - gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); - frust[3].setVec((F32)objX,(F32)objY,(F32)objZ); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1],0),model,proj,viewport); + frust[0].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1],0),model,proj,viewport); + frust[1].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0]+viewport[2],viewport[1]+viewport[3],0),model,proj,viewport); + frust[2].setVec(glm::value_ptr(obj)); + obj = glm::unProject(glm::vec3(viewport[0],viewport[1]+viewport[3],0),model,proj,viewport); + frust[3].setVec(glm::value_ptr(obj)); if (ortho) { @@ -304,7 +275,7 @@ void LLViewerCamera::setPerspective(bool for_selection, F32 z_near, F32 z_far) { F32 fov_y, aspect; - fov_y = RAD_TO_DEG * getView(); + fov_y = getView(); bool z_default_far = false; if (z_far <= 0) { @@ -321,20 +292,19 @@ void LLViewerCamera::setPerspective(bool for_selection, gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadIdentity(); - glh::matrix4f proj_mat; + glm::mat4 proj_mat = glm::identity<glm::mat4>(); if (for_selection) { // make a tiny little viewport // anything drawn into this viewport will be "selected" - GLint viewport[4]; - viewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; - viewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; - viewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); - viewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); + glm::ivec4 viewport(gViewerWindow->getWorldViewRectRaw().mLeft, + gViewerWindow->getWorldViewRectRaw().mBottom, + gViewerWindow->getWorldViewRectRaw().getWidth(), + gViewerWindow->getWorldViewRectRaw().getHeight()); - proj_mat = gl_pick_matrix(x+width/2.f, y_from_bot+height/2.f, (GLfloat) width, (GLfloat) height, viewport); + proj_mat = glm::pickMatrix(glm::vec2(x + width / 2.f, y_from_bot + height / 2.f), glm::vec2((GLfloat)width, (GLfloat)height), viewport); if (limit_select_distance) { @@ -365,37 +335,35 @@ void LLViewerCamera::setPerspective(bool for_selection, float offset = mZoomFactor - 1.f; int pos_y = mZoomSubregion / llceil(mZoomFactor); int pos_x = mZoomSubregion - (pos_y*llceil(mZoomFactor)); - glh::matrix4f translate; - translate.set_translate(glh::vec3f(offset - (F32)pos_x * 2.f, offset - (F32)pos_y * 2.f, 0.f)); - glh::matrix4f scale; - scale.set_scale(glh::vec3f(mZoomFactor, mZoomFactor, 1.f)); - proj_mat = scale*proj_mat; - proj_mat = translate*proj_mat; + glm::mat4 translate; + translate = glm::translate(glm::vec3(offset - (F32)pos_x * 2.f, offset - (F32)pos_y * 2.f, 0.f)); + glm::mat4 scale; + scale = glm::scale(glm::vec3(mZoomFactor, mZoomFactor, 1.f)); + + proj_mat = scale * proj_mat; + proj_mat = translate * proj_mat; } calcProjection(z_far); // Update the projection matrix cache - proj_mat *= gl_perspective(fov_y,aspect,z_near,z_far); + proj_mat *= glm::perspective(fov_y,aspect,z_near,z_far); - gGL.loadMatrix(proj_mat.m); + gGL.loadMatrix(glm::value_ptr(proj_mat)); - for (U32 i = 0; i < 16; i++) - { - gGLProjection[i] = proj_mat.m[i]; - } + set_current_projection(proj_mat); gGL.matrixMode(LLRender::MM_MODELVIEW); - glh::matrix4f modelview((GLfloat*) OGL_TO_CFR_ROTATION); + glm::mat4 modelview(glm::make_mat4((GLfloat*) OGL_TO_CFR_ROTATION)); GLfloat ogl_matrix[16]; getOpenGLTransform(ogl_matrix); - modelview *= glh::matrix4f(ogl_matrix); + modelview *= glm::make_mat4(ogl_matrix); - gGL.loadMatrix(modelview.m); + gGL.loadMatrix(glm::value_ptr(modelview)); if (for_selection && (width > 1 || height > 1)) { @@ -413,10 +381,7 @@ void LLViewerCamera::setPerspective(bool for_selection, if (!for_selection && mZoomFactor == 1.f) { // Save GL matrices for access elsewhere in code, especially project_world_to_screen - for (U32 i = 0; i < 16; i++) - { - gGLModelView[i] = modelview.m[i]; - } + set_current_modelview(modelview); } updateFrustumPlanes(*this); @@ -427,24 +392,8 @@ void LLViewerCamera::setPerspective(bool for_selection, // screen coordinates to the agent's region. void LLViewerCamera::projectScreenToPosAgent(const S32 screen_x, const S32 screen_y, LLVector3* pos_agent) const { - GLdouble x, y, z; - - F64 mdlv[16]; - F64 proj[16]; - - for (U32 i = 0; i < 16; i++) - { - mdlv[i] = (F64) gGLModelView[i]; - proj[i] = (F64) gGLProjection[i]; - } - - gluUnProject( - GLdouble(screen_x), GLdouble(screen_y), 0.0, - mdlv, proj, (GLint*)gGLViewport, - &x, - &y, - &z ); - pos_agent->setVec( (F32)x, (F32)y, (F32)z ); + glm::vec3 agent_coord = glm::unProject(glm::vec3(screen_x, screen_y, 0.f), get_current_modelview(), get_current_projection(), glm::make_vec4(gGLViewport)); + pos_agent->setVec( (F32)agent_coord.x, (F32)agent_coord.y, (F32)agent_coord.z ); } // Uses the last GL matrices set in set_perspective to project a point from @@ -453,7 +402,6 @@ void LLViewerCamera::projectScreenToPosAgent(const S32 screen_x, const S32 scree bool LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoordGL &out_point, const bool clamp) const { bool in_front = true; - GLdouble x, y, z; // object's window coords, GL-style LLVector3 dir_to_point = pos_agent - getOrigin(); dir_to_point /= dir_to_point.magVec(); @@ -471,35 +419,20 @@ bool LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord } LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); - S32 viewport[4]; - viewport[0] = world_view_rect.mLeft; - viewport[1] = world_view_rect.mBottom; - viewport[2] = world_view_rect.getWidth(); - viewport[3] = world_view_rect.getHeight(); - - F64 mdlv[16]; - F64 proj[16]; - - for (U32 i = 0; i < 16; i++) - { - mdlv[i] = (F64) gGLModelView[i]; - proj[i] = (F64) gGLProjection[i]; - } + glm::ivec4 viewport(world_view_rect.mLeft, world_view_rect.mBottom, world_view_rect.getWidth(), world_view_rect.getHeight()); + glm::vec3 win_coord = glm::project(glm::make_vec3(pos_agent.mV), get_current_modelview(), get_current_projection(), viewport); - if (GL_TRUE == gluProject(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ], - mdlv, proj, (GLint*)viewport, - &x, &y, &z)) { // convert screen coordinates to virtual UI coordinates - x /= gViewerWindow->getDisplayScale().mV[VX]; - y /= gViewerWindow->getDisplayScale().mV[VY]; + win_coord.x /= gViewerWindow->getDisplayScale().mV[VX]; + win_coord.y /= gViewerWindow->getDisplayScale().mV[VY]; // should now have the x,y coords of grab_point in screen space LLRect world_rect = gViewerWindow->getWorldViewRectScaled(); // convert to pixel coordinates - S32 int_x = lltrunc(x); - S32 int_y = lltrunc(y); + S32 int_x = lltrunc(win_coord.x); + S32 int_y = lltrunc(win_coord.y); bool valid = true; @@ -561,10 +494,6 @@ bool LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord return in_front && valid; } } - else - { - return false; - } } // Uses the last GL matrices set in set_perspective to project a point from @@ -583,49 +512,33 @@ bool LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, } LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); - S32 viewport[4]; - viewport[0] = world_view_rect.mLeft; - viewport[1] = world_view_rect.mBottom; - viewport[2] = world_view_rect.getWidth(); - viewport[3] = world_view_rect.getHeight(); - GLdouble x, y, z; // object's window coords, GL-style - F64 mdlv[16]; - F64 proj[16]; - - for (U32 i = 0; i < 16; i++) - { - mdlv[i] = (F64) gGLModelView[i]; - proj[i] = (F64) gGLProjection[i]; - } + glm::ivec4 viewport(world_view_rect.mLeft, world_view_rect.mBottom, world_view_rect.getWidth(), world_view_rect.getHeight()); + glm::vec3 win_coord = glm::project(glm::make_vec3(pos_agent.mV), get_current_modelview(), get_current_projection(), viewport); - if (GL_TRUE == gluProject(pos_agent.mV[VX], pos_agent.mV[VY], - pos_agent.mV[VZ], mdlv, - proj, (GLint*)viewport, - &x, &y, &z)) { - x /= gViewerWindow->getDisplayScale().mV[VX]; - y /= gViewerWindow->getDisplayScale().mV[VY]; + win_coord.x /= gViewerWindow->getDisplayScale().mV[VX]; + win_coord.y /= gViewerWindow->getDisplayScale().mV[VY]; // should now have the x,y coords of grab_point in screen space const LLRect& world_rect = gViewerWindow->getWorldViewRectScaled(); // ...sanity check - S32 int_x = lltrunc(x); - S32 int_y = lltrunc(y); + S32 int_x = lltrunc(win_coord.x); + S32 int_y = lltrunc(win_coord.y); // find the center - GLdouble center_x = (GLdouble)world_rect.getCenterX(); - GLdouble center_y = (GLdouble)world_rect.getCenterY(); + F32 center_x = (F32)world_rect.getCenterX(); + F32 center_y = (F32)world_rect.getCenterY(); - if (x == center_x && y == center_y) + if (win_coord.x == center_x && win_coord.y == center_y) { // can't project to edge from exact center return false; } // find the line from center to local - GLdouble line_x = x - center_x; - GLdouble line_y = y - center_y; + F32 line_x = win_coord.x - center_x; + F32 line_y = win_coord.y - center_y; int_x = lltrunc(center_x); int_y = lltrunc(center_y); @@ -646,11 +559,11 @@ bool LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, else if (0 == world_rect.getWidth()) { // the diagonal slope of the view is undefined - if (y < world_rect.mBottom) + if (win_coord.y < world_rect.mBottom) { int_y = world_rect.mBottom; } - else if ( y > world_rect.mTop) + else if (win_coord.y > world_rect.mTop) { int_y = world_rect.mTop; } @@ -672,7 +585,7 @@ bool LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, // top int_y = world_rect.mTop; } - int_x = lltrunc(((GLdouble)int_y - center_y) / line_slope + center_x); + int_x = lltrunc(((F32)int_y - center_y) / line_slope + center_x); } else if (fabs(line_slope) < rect_slope) { @@ -686,7 +599,7 @@ bool LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, // right int_x = world_rect.mRight; } - int_y = lltrunc(((GLdouble)int_x - center_x) * line_slope + center_y); + int_y = lltrunc(((F32)int_x - center_x) * line_slope + center_y); } else { diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 9bd0973cc0..6278832765 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -28,58 +28,74 @@ #include "llviewerdisplay.h" -#include "llgl.h" -#include "llrender.h" -#include "llglheaders.h" -#include "llgltfmateriallist.h" +#include "fsyspath.h" +#include "hexdump.h" #include "llagent.h" #include "llagentcamera.h" -#include "llviewercontrol.h" +#include "llappviewer.h" #include "llcoord.h" #include "llcriticaldamp.h" +#include "llcubemap.h" #include "lldir.h" -#include "lldynamictexture.h" #include "lldrawpoolalpha.h" +#include "lldrawpoolbump.h" +#include "lldrawpoolwater.h" +#include "lldynamictexture.h" +#include "llenvironment.h" +#include "llfasttimer.h" #include "llfeaturemanager.h" -//#include "llfirstuse.h" +#include "llfloatertools.h" +#include "llfocusmgr.h" +#include "llgl.h" +#include "llglheaders.h" +#include "llgltfmateriallist.h" #include "llhudmanager.h" #include "llimagepng.h" +#include "llmachineid.h" #include "llmemory.h" +#include "llparcel.h" +#include "llperfstats.h" +#include "llpostprocess.h" +#include "llrender.h" +#include "llscenemonitor.h" +#include "llsdjson.h" #include "llselectmgr.h" #include "llsky.h" +#include "llspatialpartition.h" #include "llstartup.h" +#include "llstartup.h" +#include "lltooldraganddrop.h" #include "lltoolfocus.h" #include "lltoolmgr.h" -#include "lltooldraganddrop.h" #include "lltoolpie.h" #include "lltracker.h" #include "lltrans.h" #include "llui.h" +#include "lluuid.h" +#include "llversioninfo.h" #include "llviewercamera.h" +#include "llviewercontrol.h" +#include "llviewernetwork.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" +#include "llviewerregion.h" +#include "llviewershadermgr.h" +#include "llviewertexturelist.h" #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llvograss.h" #include "llworld.h" #include "pipeline.h" -#include "llspatialpartition.h" -#include "llappviewer.h" -#include "llstartup.h" -#include "llviewershadermgr.h" -#include "llfasttimer.h" -#include "llfloatertools.h" -#include "llviewertexturelist.h" -#include "llfocusmgr.h" -#include "llcubemap.h" -#include "llviewerregion.h" -#include "lldrawpoolwater.h" -#include "lldrawpoolbump.h" -#include "llpostprocess.h" -#include "llscenemonitor.h" -#include "llenvironment.h" -#include "llperfstats.h" +#include <boost/json.hpp> + +#include <filesystem> +#include <iomanip> +#include <sstream> + +#include <glm/glm.hpp> +#include <glm/gtc/matrix_transform.hpp> +#include <glm/gtc/type_ptr.hpp> extern LLPointer<LLViewerTexture> gStartTexture; extern bool gShiftFrame; @@ -123,6 +139,9 @@ void render_ui_3d(); void render_ui_2d(); void render_disconnected_background(); +void getProfileStatsContext(boost::json::object& stats); +std::string getProfileStatsFilename(); + void display_startup() { if ( !gViewerWindow @@ -760,8 +779,8 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLGLState::checkStates(); - glh::matrix4f proj = get_current_projection(); - glh::matrix4f mod = get_current_modelview(); + glm::mat4 proj = get_current_projection(); + glm::mat4 mod = get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateImpostors(); @@ -769,9 +788,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) set_current_projection(proj); set_current_modelview(mod); gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadMatrix(proj.m); + gGL.loadMatrix(glm::value_ptr(proj)); gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(mod.m); + gGL.loadMatrix(glm::value_ptr(mod)); gViewerWindow->setup3DViewport(); LLGLState::checkStates(); @@ -1023,8 +1042,87 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) if (gShaderProfileFrame) { gShaderProfileFrame = false; - LLGLSLShader::finishProfile(); + boost::json::value stats{ boost::json::object_kind }; + getProfileStatsContext(stats.as_object()); + LLGLSLShader::finishProfile(stats); + + auto report_name = getProfileStatsFilename(); + std::ofstream outf(report_name); + if (! outf) + { + LL_WARNS() << "Couldn't write to " << std::quoted(report_name) << LL_ENDL; + } + else + { + outf << stats; + LL_INFOS() << "(also dumped to " << std::quoted(report_name) << ")" << LL_ENDL; + } + } +} + +void getProfileStatsContext(boost::json::object& stats) +{ + // populate the context with info from LLFloaterAbout + auto contextit = stats.emplace("context", + LlsdToJson(LLAppViewer::instance()->getViewerInfo())).first; + auto& context = contextit->value().as_object(); + + // then add a few more things + unsigned char unique_id[MAC_ADDRESS_BYTES]{}; + LLMachineID::getUniqueID(unique_id, sizeof(unique_id)); + context.emplace("machine", stringize(LL::hexdump(unique_id, sizeof(unique_id)))); + context.emplace("grid", LLGridManager::instance().getGrid()); + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + context.emplace("regionid", stringize(region->getRegionID())); + } + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (parcel) + { + context.emplace("parcel", parcel->getName()); + context.emplace("parcelid", parcel->getLocalID()); } + context.emplace("time", LLDate::now().toHTTPDateString("%Y-%m-%dT%H:%M:%S")); +} + +std::string getProfileStatsFilename() +{ + std::ostringstream basebuff; + // viewer build + basebuff << "profile.v" << LLVersionInfo::instance().getBuild(); + // machine ID: zero-initialize unique_id in case LLMachineID fails + unsigned char unique_id[MAC_ADDRESS_BYTES]{}; + LLMachineID::getUniqueID(unique_id, sizeof(unique_id)); + basebuff << ".m" << LL::hexdump(unique_id, sizeof(unique_id)); + // region ID + LLViewerRegion *region = gAgent.getRegion(); + basebuff << ".r" << (region? region->getRegionID() : LLUUID()); + // local parcel ID + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + basebuff << ".p" << (parcel? parcel->getLocalID() : 0); + // date/time -- omit seconds for now + auto now = LLDate::now(); + basebuff << ".t" << LLDate::now().toHTTPDateString("%Y-%m-%dT%H-%M-"); + // put this candidate file in our logs directory + auto base = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, basebuff.str()); + S32 sec; + now.split(nullptr, nullptr, nullptr, nullptr, nullptr, &sec); + // Loop over finished filename, incrementing sec until we find one that + // doesn't yet exist. Should rarely loop (only if successive calls within + // same second), may produce (e.g.) sec==61, but avoids collisions and + // preserves chronological filename sort order. + std::string name; + std::error_code ec; + do + { + // base + missing 2-digit seconds, append ".json" + // post-increment sec in case we have to try again + name = stringize(base, std::setw(2), std::setfill('0'), sec++, ".json"); + } while (std::filesystem::exists(fsyspath(name), ec)); + // Ignoring ec means we might potentially return a name that does already + // exist -- but if we can't check its existence, what more can we do? + return name; } // WIP simplified copy of display() that does minimal work @@ -1148,8 +1246,8 @@ void render_hud_attachments() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glh::matrix4f current_proj = get_current_projection(); - glh::matrix4f current_mod = get_current_modelview(); + glm::mat4 current_proj = get_current_projection(); + glm::mat4 current_mod = get_current_modelview(); // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); @@ -1273,7 +1371,7 @@ LLRect get_whole_screen_region() return whole_screen; } -bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model) +bool get_hud_matrices(const LLRect& screen_region, glm::mat4 &proj, glm::mat4&model) { if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment()) { @@ -1281,28 +1379,29 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat LLBBox hud_bbox = gAgentAvatarp->getHUDBBox(); F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); - proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); - proj.element(2,2) = -0.01f; + proj = glm::ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); + proj[2][2] = -0.01f; F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect(); - glh::matrix4f mat; F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth(); F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight(); - mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f)); - mat.set_translate( - glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), - clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y), - 0.f)); - proj *= mat; - - glh::matrix4f tmp_model((GLfloat*) OGL_TO_CFR_ROTATION); - mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level)); - mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); + glm::mat4 mat = glm::identity<glm::mat4>(); + mat = glm::translate(mat, + glm::vec3(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), + clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y), + 0.f)); + mat = glm::scale(mat, glm::vec3(scale_x, scale_y, 1.f)); + proj *= mat; + glm::mat4 tmp_model = glm::make_mat4(OGL_TO_CFR_ROTATION); + mat = glm::identity<glm::mat4>(); + mat = glm::translate(mat, glm::vec3(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); + mat = glm::scale(mat, glm::vec3(zoom_level)); tmp_model *= mat; model = tmp_model; + return true; } else @@ -1311,7 +1410,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat } } -bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model) +bool get_hud_matrices(glm::mat4 &proj, glm::mat4&model) { LLRect whole_screen = get_whole_screen_region(); return get_hud_matrices(whole_screen, proj, model); @@ -1325,17 +1424,17 @@ bool setup_hud_matrices() bool setup_hud_matrices(const LLRect& screen_region) { - glh::matrix4f proj, model; + glm::mat4 proj, model; bool result = get_hud_matrices(screen_region, proj, model); if (!result) return result; // set up transform to keep HUD objects in front of camera gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadMatrix(proj.m); + gGL.loadMatrix(glm::value_ptr(proj)); set_current_projection(proj); gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(model.m); + gGL.loadMatrix(glm::value_ptr(model)); set_current_modelview(model); return true; } @@ -1347,13 +1446,13 @@ void render_ui(F32 zoom_factor, int subfield) LL_PROFILE_GPU_ZONE("ui"); LLGLState::checkStates(); - glh::matrix4f saved_view = get_current_modelview(); + glm::mat4 saved_view = get_current_modelview(); if (!gSnapshot) { gGL.pushMatrix(); gGL.loadMatrix(gGLLastModelView); - set_current_modelview(copy_matrix(gGLLastModelView)); + set_current_modelview(glm::make_mat4(gGLLastModelView)); } if(LLSceneMonitor::getInstance()->needsUpdate()) @@ -1526,7 +1625,8 @@ void render_ui_3d() gGL.color4f(1, 1, 1, 1); // Coordinate axes - if (gSavedSettings.getBOOL("ShowAxes")) + LLCachedControl<bool> show_axes(gSavedSettings, "ShowAxes"); + if (show_axes()) { draw_axes(); } diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 9bdd246129..ef68609182 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -242,7 +242,7 @@ public: "avatar_picker", "camera", "camera_presets", - "change_item_thumbnail" + "change_item_thumbnail", "classified", "add_landmark", "delete_pref_preset", diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp index e733dafcae..511fac9788 100644 --- a/indra/newview/llviewerjointattachment.cpp +++ b/indra/newview/llviewerjointattachment.cpp @@ -86,13 +86,17 @@ U32 LLViewerJointAttachment::drawShape( F32 pixelArea, bool first_pass, bool is_ LLGLDisable cull_face(GL_CULL_FACE); gGL.color4f(1.f, 1.f, 1.f, 1.f); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); { gGL.vertex3f(-0.1f, 0.1f, 0.f); gGL.vertex3f(-0.1f, -0.1f, 0.f); gGL.vertex3f(0.1f, -0.1f, 0.f); + + gGL.vertex3f(-0.1f, 0.1f, 0.f); + gGL.vertex3f(0.1f, -0.1f, 0.f); gGL.vertex3f(0.1f, 0.1f, 0.f); - }gGL.end(); + } + gGL.end(); } return 0; } diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index d76c033ef3..73097a0e1c 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -688,10 +688,10 @@ void LLViewerMedia::updateMedia(void *dummy_arg) static LLCachedControl<bool> inworld_media_enabled(gSavedSettings, "AudioStreamingMedia", true); static LLCachedControl<bool> inworld_audio_enabled(gSavedSettings, "AudioStreamingMusic", true); - U32 max_instances = gSavedSettings.getU32("PluginInstancesTotal"); - U32 max_normal = gSavedSettings.getU32("PluginInstancesNormal"); - U32 max_low = gSavedSettings.getU32("PluginInstancesLow"); - F32 max_cpu = gSavedSettings.getF32("PluginInstancesCPULimit"); + static LLCachedControl<U32> max_instances(gSavedSettings, "PluginInstancesTotal", 8); + static LLCachedControl<U32> max_normal(gSavedSettings, "PluginInstancesNormal", 2); + static LLCachedControl<U32> max_low(gSavedSettings, "PluginInstancesLow", 4); + static LLCachedControl<F32> max_cpu(gSavedSettings, "PluginInstancesCPULimit", 0.9); // Setting max_cpu to 0.0 disables CPU usage checking. bool check_cpu_usage = (max_cpu != 0.0f); @@ -829,7 +829,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } else { - if(gAudiop && LLViewerMedia::hasParcelAudio() && restore_parcel_audio && gSavedSettings.getBOOL("MediaTentativeAutoPlay")) + static LLCachedControl<bool> auto_play(gSavedSettings, "MediaTentativeAutoPlay", true); + if(gAudiop && LLViewerMedia::hasParcelAudio() && restore_parcel_audio && auto_play()) { LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL()); restore_parcel_audio = false; @@ -880,7 +881,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } } - if(gSavedSettings.getBOOL("MediaPerformanceManagerDebug")) + static LLCachedControl<bool> perf_debug(gSavedSettings, "MediaPerformanceManagerDebug", false); + if(perf_debug()) { // Give impls the same ordering as the priority list // they're already in the right order for this. diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 344a9737b1..df60130c9f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -154,27 +154,18 @@ typedef LLPointer<LLViewerObject> LLViewerObjectPtr; static boost::unordered_map<std::string, LLStringExplicit> sDefaultItemLabels; -bool enable_land_build(void*); -bool enable_object_build(void*); +LLVOAvatar* find_avatar_from_object(LLViewerObject* object); +LLVOAvatar* find_avatar_from_object(const LLUUID& object_id); -LLVOAvatar* find_avatar_from_object( LLViewerObject* object ); -LLVOAvatar* find_avatar_from_object( const LLUUID& object_id ); - -void handle_test_load_url(void*); +void handle_test_load_url(); // // Evil hackish imported globals -//extern bool gHideSelectedObjects; -//extern bool gAllowSelectAvatar; -//extern bool gDebugAvatarRotation; extern bool gDebugClicks; extern bool gDebugWindowProc; extern bool gShaderProfileFrame; -//extern bool gDebugTextEditorTips; -//extern bool gDebugSelectMgr; - // // Globals // @@ -214,24 +205,22 @@ LLContextMenu* gDetachBodyPartPieMenus[9]; // Local prototypes // File Menu -void handle_compress_image(void*); -void handle_compress_file_test(void*); +void handle_compress_image(); +void handle_compress_file_test(); // Edit menu -void handle_dump_group_info(void *); -void handle_dump_capabilities_info(void *); +void handle_dump_group_info(); +void handle_dump_capabilities_info(); // Advanced->Consoles menu -void handle_region_dump_settings(void*); -void handle_region_dump_temp_asset_data(void*); -void handle_region_clear_temp_asset_data(void*); +void handle_region_dump_settings(); +void handle_region_dump_temp_asset_data(); +void handle_region_clear_temp_asset_data(); // Object pie menu bool sitting_on_selection(); -void near_sit_object(); -//void label_sit_or_stand(std::string& label, void*); // buy and take alias into the same UI positions, so these // declarations handle this mess. bool is_selection_buy_not_take(); @@ -246,107 +235,99 @@ void handle_buy_object(LLSaleInfo sale_info); void handle_buy_contents(LLSaleInfo sale_info); // Land pie menu -void near_sit_down_point(bool success, void *); - -// Avatar pie menu +void near_sit_down_point(bool success, void*); // Debug menu - - -void velocity_interpolate( void* ); -void handle_visual_leak_detector_toggle(void*); -void handle_rebake_textures(void*); -bool check_admin_override(void*); -void handle_admin_override_toggle(void*); +void handle_visual_leak_detector_toggle(); +void handle_rebake_textures(); +bool check_admin_override(); +void handle_admin_override_toggle(); #ifdef TOGGLE_HACKED_GODLIKE_VIEWER -void handle_toggle_hacked_godmode(void*); -bool check_toggle_hacked_godmode(void*); -bool enable_toggle_hacked_godmode(void*); +void handle_toggle_hacked_godmode(); +bool check_toggle_hacked_godmode(); +bool enable_toggle_hacked_godmode(); #endif -void toggle_show_xui_names(void *); -bool check_show_xui_names(void *); +void toggle_show_xui_names(); +bool check_show_xui_names(); // Debug UI -void handle_buy_currency_test(void*); +void handle_buy_currency_test(); -void handle_god_mode(void*); +void handle_god_mode(); // God menu -void handle_leave_god_mode(void*); +void handle_leave_god_mode(); void handle_reset_view(); -void handle_duplicate_in_place(void*); - -void handle_object_owner_self(void*); -void handle_object_owner_permissive(void*); -void handle_object_lock(void*); -void handle_object_asset_ids(void*); -void force_take_copy(void*); - -void handle_force_parcel_owner_to_me(void*); -void handle_force_parcel_to_content(void*); -void handle_claim_public_land(void*); - -void handle_god_request_avatar_geometry(void *); // Hack for easy testing of new avatar geometry -void reload_vertex_shader(void *); -void handle_disconnect_viewer(void *); - -void force_error_breakpoint(void *); -void force_error_llerror(void *); -void force_error_llerror_msg(void*); -void force_error_bad_memory_access(void *); -void force_error_infinite_loop(void *); -void force_error_software_exception(void *); -void force_error_os_exception(void*); -void force_error_driver_crash(void *); -void force_error_coroutine_crash(void *); -void force_error_thread_crash(void *); - -void handle_force_delete(void*); -void print_object_info(void*); -void print_agent_nvpairs(void*); -void toggle_debug_menus(void*); +void handle_object_owner_self(); +void handle_object_owner_permissive(); +void handle_object_lock(); +void handle_object_asset_ids(); +void force_take_copy(); + +void handle_force_parcel_owner_to_me(); +void handle_force_parcel_to_content(); +void handle_claim_public_land(); + +void handle_god_request_avatar_geometry(); // Hack for easy testing of new avatar geometry +void reload_vertex_shader(); +void handle_disconnect_viewer(); + +void force_error_breakpoint(); +void force_error_llerror(); +void force_error_llerror_msg(); +void force_error_bad_memory_access(); +void force_error_infinite_loop(); +void force_error_software_exception(); +void force_error_os_exception(); +void force_error_driver_crash(); +void force_error_coroutine_crash(); +void force_error_thread_crash(); + +void handle_force_delete(); +void print_object_info(); +void print_agent_nvpairs(); void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status); -void dump_select_mgr(void*); +void dump_select_mgr(); -void dump_inventory(void*); -void toggle_visibility(void*); -bool get_visibility(void*); +void dump_inventory(); +void toggle_visibility(LLView* viewp); +bool get_visibility(LLView* viewp); // Avatar Pie menu void request_friendship(const LLUUID& agent_id); // Tools menu -void handle_selected_texture_info(void*); +void handle_selected_texture_info(); void handle_selected_material_info(); -void handle_dump_followcam(void*); -void handle_viewer_enable_message_log(void*); -void handle_viewer_disable_message_log(void*); +void handle_dump_followcam(); +void handle_viewer_enable_message_log(); +void handle_viewer_disable_message_log(); -bool enable_buy_land(void*); +bool enable_buy_land(); // Help menu -void handle_test_male(void *); -void handle_test_female(void *); -void handle_dump_attachments(void *); -void handle_dump_avatar_local_textures(void*); -void handle_debug_avatar_textures(void*); -void handle_grab_baked_texture(void*); -bool enable_grab_baked_texture(void*); -void handle_dump_region_object_cache(void*); -void handle_reset_interest_lists(void *); +void handle_test_male(); +void handle_test_female(); +void handle_dump_attachments(); +void handle_dump_avatar_local_textures(); +void handle_debug_avatar_textures(); +void handle_grab_baked_texture(EBakedTextureIndex baked_tex_index); +bool enable_grab_baked_texture(EBakedTextureIndex baked_tex_index); +void handle_dump_region_object_cache(); +void handle_reset_interest_lists(); -bool enable_save_into_task_inventory(void*); +bool enable_save_into_task_inventory(); bool enable_detach(const LLSD& = LLSD()); -void menu_toggle_attached_lights(void* user_data); -void menu_toggle_attached_particles(void* user_data); +void menu_toggle_attached_lights(); +void menu_toggle_attached_particles(); class LLMenuParcelObserver : public LLParcelObserver { @@ -383,12 +364,12 @@ void LLMenuParcelObserver::changed() if (!mLandBuyPassHandle.isDead()) { LLParcel *parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); - static_cast<LLMenuItemCallGL*>(mLandBuyPassHandle.get())->setEnabled(LLPanelLandGeneral::enableBuyPass(NULL) && !(parcel->getOwnerID() == gAgent.getID())); + static_cast<LLMenuItemCallGL*>(mLandBuyPassHandle.get())->setEnabled(LLPanelLandGeneral::enableBuyPass(nullptr) && parcel->getOwnerID() != gAgentID); } if (!mLandBuyHandle.isDead()) { - bool buyable = enable_buy_land(NULL); + bool buyable = enable_buy_land(); static_cast<LLMenuItemCallGL*>(mLandBuyHandle.get())->setEnabled(buyable); } } @@ -444,7 +425,7 @@ void LLSLMMenuUpdater::setMerchantMenu() if (marketplacelistings_id.isNull()) { U32 mkt_status = LLMarketplaceData::instance().getSLMStatus(); - bool is_merchant = (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MERCHANT) || (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MIGRATED_MERCHANT); + bool is_merchant = mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MERCHANT || mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MIGRATED_MERCHANT; if (is_merchant) { gInventory.ensureCategoryForTypeExists(LLFolderType::FT_MARKETPLACE_LISTINGS); @@ -476,12 +457,14 @@ void LLSLMMenuUpdater::checkMerchantStatus(bool force) void set_merchant_SLM_menu() { - if(gSLMMenuUpdater) gSLMMenuUpdater->setMerchantMenu(); + if (gSLMMenuUpdater) + gSLMMenuUpdater->setMerchantMenu(); } void check_merchant_status(bool force) { - if(gSLMMenuUpdater) gSLMMenuUpdater->checkMerchantStatus(force); + if (gSLMMenuUpdater) + gSLMMenuUpdater->checkMerchantStatus(force); } void init_menus() @@ -623,11 +606,11 @@ class LLAdvancedToggleConsole : public view_listener_t std::string console_type = userdata.asString(); if ("texture" == console_type) { - toggle_visibility( (void*)gTextureView ); + toggle_visibility(gTextureView); } else if ("debug" == console_type) { - toggle_visibility( (void*)static_cast<LLUICtrl*>(gDebugView->mDebugConsolep)); + toggle_visibility(gDebugView->mDebugConsolep); } else if ("fast timers" == console_type) { @@ -635,11 +618,11 @@ class LLAdvancedToggleConsole : public view_listener_t } else if ("scene view" == console_type) { - toggle_visibility( (void*)gSceneView); + toggle_visibility(gSceneView); } else if ("scene monitor" == console_type) { - toggle_visibility( (void*)gSceneMonitorView); + toggle_visibility(gSceneMonitorView); } return true; @@ -653,11 +636,11 @@ class LLAdvancedCheckConsole : public view_listener_t bool new_value = false; if ("texture" == console_type) { - new_value = get_visibility( (void*)gTextureView ); + new_value = get_visibility(gTextureView); } else if ("debug" == console_type) { - new_value = get_visibility( (void*)((LLView*)gDebugView->mDebugConsolep) ); + new_value = get_visibility(gDebugView->mDebugConsolep); } else if ("fast timers" == console_type) { @@ -665,11 +648,11 @@ class LLAdvancedCheckConsole : public view_listener_t } else if ("scene view" == console_type) { - new_value = get_visibility( (void*) gSceneView); + new_value = get_visibility(gSceneView); } else if ("scene monitor" == console_type) { - new_value = get_visibility( (void*) gSceneMonitorView); + new_value = get_visibility(gSceneMonitorView); } return new_value; @@ -690,15 +673,15 @@ class LLAdvancedDumpInfoToConsole : public view_listener_t std::string info_type = userdata.asString(); if ("region" == info_type) { - handle_region_dump_settings(NULL); + handle_region_dump_settings(); } else if ("group" == info_type) { - handle_dump_group_info(NULL); + handle_dump_group_info(); } else if ("capabilities" == info_type) { - handle_dump_capabilities_info(NULL); + handle_dump_capabilities_info(); } return true; } @@ -771,7 +754,7 @@ class LLAdvancedClearGroupCache : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLGroupMgr::debugClearAllGroups(NULL); + LLGroupMgr::debugClearAllGroups(nullptr); return true; } }; @@ -782,7 +765,7 @@ class LLAdvancedClearGroupCache : public view_listener_t ///////////////// // RENDER TYPE // ///////////////// -U32 render_type_from_string(std::string render_type) +U32 render_type_from_string(std::string_view render_type) { if ("simple" == render_type) { @@ -901,7 +884,7 @@ class LLAdvancedCheckRenderType : public view_listener_t ///////////// // FEATURE // ///////////// -U32 feature_from_string(std::string feature) +U32 feature_from_string(std::string_view feature) { if ("ui" == feature) { @@ -1042,7 +1025,7 @@ class LLAdvancedSetDisplayTextureDensity : public view_listener_t ////////////////// // INFO DISPLAY // ////////////////// -U64 info_display_from_string(std::string info_display) +U64 info_display_from_string(std::string_view info_display) { if ("verify" == info_display) { @@ -1271,7 +1254,7 @@ class LLAdvancedSelectedTextureInfo : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_selected_texture_info(NULL); + handle_selected_texture_info(); return true; } }; @@ -1307,7 +1290,7 @@ class LLAdvancedDumpScriptedCamera : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_dump_followcam(NULL); + handle_dump_followcam(); return true; } }; @@ -1323,7 +1306,7 @@ class LLAdvancedDumpRegionObjectCache : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_dump_region_object_cache(NULL); + handle_dump_region_object_cache(); return true; } }; @@ -1382,7 +1365,7 @@ class LLAdvancedResetInterestLists : public view_listener_t { bool handleEvent(const LLSD &userdata) { // Reset all region interest lists - handle_reset_interest_lists(NULL); + handle_reset_interest_lists(); return true; } }; @@ -1451,7 +1434,7 @@ class LLAdvancedBuyCurrencyTest : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_buy_currency_test(NULL); + handle_buy_currency_test(); return true; } }; @@ -1466,7 +1449,7 @@ class LLAdvancedDumpSelectMgr : public view_listener_t { bool handleEvent(const LLSD& userdata) { - dump_select_mgr(NULL); + dump_select_mgr(); return true; } }; @@ -1482,7 +1465,7 @@ class LLAdvancedDumpInventory : public view_listener_t { bool handleEvent(const LLSD& userdata) { - dump_inventory(NULL); + dump_inventory(); return true; } }; @@ -1498,7 +1481,7 @@ class LLAdvancedPrintSelectedObjectInfo : public view_listener_t { bool handleEvent(const LLSD& userdata) { - print_object_info(NULL); + print_object_info(); return true; } }; @@ -1514,7 +1497,7 @@ class LLAdvancedPrintAgentInfo : public view_listener_t { bool handleEvent(const LLSD& userdata) { - print_agent_nvpairs(NULL); + print_agent_nvpairs(); return true; } }; @@ -1627,7 +1610,7 @@ class LLAdvancedToggleXUINameTooltips : public view_listener_t { bool handleEvent(const LLSD& userdata) { - toggle_show_xui_names(NULL); + toggle_show_xui_names(); return true; } }; @@ -1636,7 +1619,7 @@ class LLAdvancedCheckXUINameTooltips : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = check_show_xui_names(NULL); + bool new_value = check_show_xui_names(); return new_value; } }; @@ -1737,7 +1720,7 @@ class LLAdvancedToggleXUINames : public view_listener_t { bool handleEvent(const LLSD& userdata) { - toggle_show_xui_names(NULL); + toggle_show_xui_names(); return true; } }; @@ -1746,7 +1729,7 @@ class LLAdvancedCheckXUINames : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = check_show_xui_names(NULL); + bool new_value = check_show_xui_names(); return new_value; } }; @@ -1764,27 +1747,27 @@ class LLAdvancedGrabBakedTexture : public view_listener_t std::string texture_type = userdata.asString(); if ("iris" == texture_type) { - handle_grab_baked_texture( (void*)BAKED_EYES ); + handle_grab_baked_texture(BAKED_EYES); } else if ("head" == texture_type) { - handle_grab_baked_texture( (void*)BAKED_HEAD ); + handle_grab_baked_texture(BAKED_HEAD); } else if ("upper" == texture_type) { - handle_grab_baked_texture( (void*)BAKED_UPPER ); + handle_grab_baked_texture(BAKED_UPPER); } else if ("lower" == texture_type) { - handle_grab_baked_texture( (void*)BAKED_LOWER ); + handle_grab_baked_texture(BAKED_LOWER); } else if ("skirt" == texture_type) { - handle_grab_baked_texture( (void*)BAKED_SKIRT ); + handle_grab_baked_texture(BAKED_SKIRT); } else if ("hair" == texture_type) { - handle_grab_baked_texture( (void*)BAKED_HAIR ); + handle_grab_baked_texture(BAKED_HAIR); } return true; @@ -1800,27 +1783,27 @@ class LLAdvancedEnableGrabBakedTexture : public view_listener_t if ("iris" == texture_type) { - new_value = enable_grab_baked_texture( (void*)BAKED_EYES ); + new_value = enable_grab_baked_texture(BAKED_EYES); } else if ("head" == texture_type) { - new_value = enable_grab_baked_texture( (void*)BAKED_HEAD ); + new_value = enable_grab_baked_texture(BAKED_HEAD); } else if ("upper" == texture_type) { - new_value = enable_grab_baked_texture( (void*)BAKED_UPPER ); + new_value = enable_grab_baked_texture(BAKED_UPPER); } else if ("lower" == texture_type) { - new_value = enable_grab_baked_texture( (void*)BAKED_LOWER ); + new_value = enable_grab_baked_texture(BAKED_LOWER); } else if ("skirt" == texture_type) { - new_value = enable_grab_baked_texture( (void*)BAKED_SKIRT ); + new_value = enable_grab_baked_texture(BAKED_SKIRT); } else if ("hair" == texture_type) { - new_value = enable_grab_baked_texture( (void*)BAKED_HAIR ); + new_value = enable_grab_baked_texture(BAKED_HAIR); } return new_value; @@ -1905,7 +1888,7 @@ class LLAdvancedToggleCharacterGeometry : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_god_request_avatar_geometry(NULL); + handle_god_request_avatar_geometry(); return true; } }; @@ -1919,7 +1902,7 @@ class LLAdvancedTestMale : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_test_male(NULL); + handle_test_male(); return true; } }; @@ -1929,7 +1912,7 @@ class LLAdvancedTestFemale : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_test_female(NULL); + handle_test_female(); return true; } }; @@ -1938,7 +1921,7 @@ class LLAdvancedForceParamsToDefault : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLAgent::clearVisualParams(NULL); + LLAgent::clearVisualParams(nullptr); return true; } }; @@ -2001,7 +1984,7 @@ class LLAdvancedReloadVertexShader : public view_listener_t { bool handleEvent(const LLSD& userdata) { - reload_vertex_shader(NULL); + reload_vertex_shader(); return true; } }; @@ -2165,7 +2148,7 @@ class LLAdvancedDumpAttachments : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_dump_attachments(NULL); + handle_dump_attachments(); return true; } }; @@ -2181,7 +2164,7 @@ class LLAdvancedRebakeTextures : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_rebake_textures(NULL); + handle_rebake_textures(); return true; } }; @@ -2199,7 +2182,7 @@ class LLAdvancedDebugAvatarTextures : public view_listener_t { if (gAgent.isGodlike()) { - handle_debug_avatar_textures(NULL); + handle_debug_avatar_textures(); } return true; } @@ -2215,7 +2198,7 @@ class LLAdvancedDumpAvatarLocalTextures : public view_listener_t bool handleEvent(const LLSD& userdata) { #ifndef LL_RELEASE_FOR_DOWNLOAD - handle_dump_avatar_local_textures(NULL); + handle_dump_avatar_local_textures(); #endif return true; } @@ -2232,7 +2215,7 @@ class LLAdvancedEnableMessageLog : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_viewer_enable_message_log(NULL); + handle_viewer_enable_message_log(); return true; } }; @@ -2241,7 +2224,7 @@ class LLAdvancedDisableMessageLog : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_viewer_disable_message_log(NULL); + handle_viewer_disable_message_log(); return true; } }; @@ -2432,7 +2415,7 @@ class LLAdvancedCompressImage : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_compress_image(NULL); + handle_compress_image(); return true; } }; @@ -2447,7 +2430,7 @@ class LLAdvancedCompressFileTest : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_compress_file_test(NULL); + handle_compress_file_test(); return true; } }; @@ -2488,7 +2471,7 @@ class LLAdvancedToggleViewAdminOptions : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_admin_override_toggle(NULL); + handle_admin_override_toggle(); return true; } }; @@ -2497,7 +2480,7 @@ class LLAdvancedToggleVisualLeakDetector : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_visual_leak_detector_toggle(NULL); + handle_visual_leak_detector_toggle(); return true; } }; @@ -2506,7 +2489,7 @@ class LLAdvancedCheckViewAdminOptions : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = check_admin_override(NULL) || gAgent.isGodlike(); + bool new_value = check_admin_override() || gAgent.isGodlike(); return new_value; } }; @@ -2520,7 +2503,7 @@ class LLAdvancedRequestAdminStatus : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_god_mode(NULL); + handle_god_mode(); return true; } }; @@ -2529,7 +2512,7 @@ class LLAdvancedLeaveAdminStatus : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_leave_god_mode(NULL); + handle_leave_god_mode(); return true; } }; @@ -2542,7 +2525,7 @@ class LLAdvancedForceErrorBreakpoint : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_breakpoint(NULL); + force_error_breakpoint(); return true; } }; @@ -2551,7 +2534,7 @@ class LLAdvancedForceErrorLlerror : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_llerror(NULL); + force_error_llerror(); return true; } }; @@ -2560,7 +2543,7 @@ class LLAdvancedForceErrorLlerrorMsg: public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_llerror_msg(NULL); + force_error_llerror_msg(); return true; } }; @@ -2569,7 +2552,7 @@ class LLAdvancedForceErrorBadMemoryAccess : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_bad_memory_access(NULL); + force_error_bad_memory_access(); return true; } }; @@ -2584,7 +2567,7 @@ class LLAdvancedForceErrorBadMemoryAccessCoro : public view_listener_t // Wait for one mainloop() iteration, letting the enclosing // handleEvent() method return. llcoro::suspend(); - force_error_bad_memory_access(NULL); + force_error_bad_memory_access(); }); return true; } @@ -2594,7 +2577,7 @@ class LLAdvancedForceErrorInfiniteLoop : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_infinite_loop(NULL); + force_error_infinite_loop(); return true; } }; @@ -2603,7 +2586,7 @@ class LLAdvancedForceErrorSoftwareException : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_software_exception(NULL); + force_error_software_exception(); return true; } }; @@ -2612,7 +2595,7 @@ class LLAdvancedForceOSException: public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_os_exception(NULL); + force_error_os_exception(); return true; } }; @@ -2627,7 +2610,7 @@ class LLAdvancedForceErrorSoftwareExceptionCoro : public view_listener_t // Wait for one mainloop() iteration, letting the enclosing // handleEvent() method return. llcoro::suspend(); - force_error_software_exception(NULL); + force_error_software_exception(); }); return true; } @@ -2637,7 +2620,7 @@ class LLAdvancedForceErrorDriverCrash : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_driver_crash(NULL); + force_error_driver_crash(); return true; } }; @@ -2646,7 +2629,7 @@ class LLAdvancedForceErrorCoroutineCrash : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_coroutine_crash(NULL); + force_error_coroutine_crash(); return true; } }; @@ -2655,7 +2638,7 @@ class LLAdvancedForceErrorThreadCrash : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_error_thread_crash(NULL); + force_error_thread_crash(); return true; } }; @@ -2664,7 +2647,7 @@ class LLAdvancedForceErrorDisconnectViewer : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_disconnect_viewer(NULL); + handle_disconnect_viewer(); return true; } }; @@ -2676,7 +2659,7 @@ class LLAdvancedHandleToggleHackedGodmode : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_toggle_hacked_godmode(NULL); + handle_toggle_hacked_godmode(); return true; } }; @@ -2685,7 +2668,7 @@ class LLAdvancedCheckToggleHackedGodmode : public view_listener_t { bool handleEvent(const LLSD& userdata) { - check_toggle_hacked_godmode(NULL); + check_toggle_hacked_godmode(); return true; } }; @@ -2694,7 +2677,7 @@ class LLAdvancedEnableToggleHackedGodmode : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = enable_toggle_hacked_godmode(NULL); + bool new_value = enable_toggle_hacked_godmode(); return new_value; } }; @@ -2739,7 +2722,7 @@ class LLAdminForceTakeCopy : public view_listener_t { bool handleEvent(const LLSD& userdata) { - force_take_copy(NULL); + force_take_copy(); return true; } }; @@ -2748,7 +2731,7 @@ class LLAdminHandleObjectOwnerSelf : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_object_owner_self(NULL); + handle_object_owner_self(); return true; } }; @@ -2756,7 +2739,7 @@ class LLAdminHandleObjectOwnerPermissive : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_object_owner_permissive(NULL); + handle_object_owner_permissive(); return true; } }; @@ -2765,7 +2748,7 @@ class LLAdminHandleForceDelete : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_force_delete(NULL); + handle_force_delete(); return true; } }; @@ -2774,7 +2757,7 @@ class LLAdminHandleObjectLock : public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_object_lock(NULL); + handle_object_lock(); return true; } }; @@ -2783,7 +2766,7 @@ class LLAdminHandleObjectAssetIDs: public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_object_asset_ids(NULL); + handle_object_asset_ids(); return true; } }; @@ -2793,7 +2776,7 @@ class LLAdminHandleForceParcelOwnerToMe: public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_force_parcel_owner_to_me(NULL); + handle_force_parcel_owner_to_me(); return true; } }; @@ -2801,7 +2784,7 @@ class LLAdminHandleForceParcelToContent: public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_force_parcel_to_content(NULL); + handle_force_parcel_to_content(); return true; } }; @@ -2809,7 +2792,7 @@ class LLAdminHandleClaimPublicLand: public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_claim_public_land(NULL); + handle_claim_public_land(); return true; } }; @@ -2819,7 +2802,7 @@ class LLAdminHandleRegionDumpTempAssetData: public view_listener_t { bool handleEvent(const LLSD& userdata) { - handle_region_dump_temp_asset_data(NULL); + handle_region_dump_temp_asset_data(); return true; } }; @@ -2829,7 +2812,7 @@ class LLAdminOnSaveState: public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLPanelRegionTools::onSaveState(NULL); + LLPanelRegionTools::onSaveState(nullptr); return true; } }; @@ -3315,41 +3298,11 @@ class LLLandEnableBuyPass : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = LLPanelLandGeneral::enableBuyPass(NULL); + bool new_value = LLPanelLandGeneral::enableBuyPass(nullptr); return new_value; } }; -// BUG: Should really check if CLICK POINT is in a parcel where you can build. -bool enable_land_build(void*) -{ - if (gAgent.isGodlike()) return true; - if (gAgent.inPrelude()) return false; - - bool can_build = false; - LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (agent_parcel) - { - can_build = agent_parcel->getAllowModify(); - } - return can_build; -} - -// BUG: Should really check if OBJECT is in a parcel where you can build. -bool enable_object_build(void*) -{ - if (gAgent.isGodlike()) return true; - if (gAgent.inPrelude()) return false; - - bool can_build = false; - LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (agent_parcel) - { - can_build = agent_parcel->getAllowModify(); - } - return can_build; -} - bool enable_object_edit() { if (!isAgentAvatarValid()) return false; @@ -3380,12 +3333,6 @@ bool enable_mute_particle() return pick.mParticleOwnerID != LLUUID::null && pick.mParticleOwnerID != gAgent.getID(); } -// mutually exclusive - show either edit option or build in menu -bool enable_object_build() -{ - return !enable_object_edit(); -} - bool enable_object_select_in_pathfinding_linksets() { return LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion() && LLSelectMgr::getInstance()->selectGetEditableLinksets(); @@ -3484,9 +3431,8 @@ class LLSelfEnableRemoveAllAttachments : public view_listener_t } }; -bool enable_has_attachments(void*) +bool enable_has_attachments() { - return false; } @@ -4092,7 +4038,7 @@ void handle_buy_contents(LLSaleInfo sale_info) LLFloaterBuyContents::show(sale_info); } -void handle_region_dump_temp_asset_data(void*) +void handle_region_dump_temp_asset_data() { LL_INFOS() << "Dumping temporary asset data to simulator logs" << LL_ENDL; std::vector<std::string> strings; @@ -4100,7 +4046,7 @@ void handle_region_dump_temp_asset_data(void*) send_generic_message("dumptempassetdata", strings, invoice); } -void handle_region_clear_temp_asset_data(void*) +void handle_region_clear_temp_asset_data() { LL_INFOS() << "Clearing temporary asset data" << LL_ENDL; std::vector<std::string> strings; @@ -4108,7 +4054,7 @@ void handle_region_clear_temp_asset_data(void*) send_generic_message("cleartempassetdata", strings, invoice); } -void handle_region_dump_settings(void*) +void handle_region_dump_settings() { LLViewerRegion* regionp = gAgent.getRegion(); if (regionp) @@ -4124,12 +4070,12 @@ void handle_region_dump_settings(void*) } } -void handle_dump_group_info(void *) +void handle_dump_group_info() { gAgent.dumpGroupInfo(); } -void handle_dump_capabilities_info(void *) +void handle_dump_capabilities_info() { LLViewerRegion* regionp = gAgent.getRegion(); if (regionp) @@ -4138,7 +4084,7 @@ void handle_dump_capabilities_info(void *) } } -void handle_dump_region_object_cache(void*) +void handle_dump_region_object_cache() { LLViewerRegion* regionp = gAgent.getRegion(); if (regionp) @@ -4147,7 +4093,7 @@ void handle_dump_region_object_cache(void*) } } -void handle_reset_interest_lists(void *) +void handle_reset_interest_lists() { // Check all regions and reset their interest list for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); @@ -4290,12 +4236,12 @@ class LLTogglePanelPeopleTab : public view_listener_t } }; -bool check_admin_override(void*) +bool check_admin_override() { return gAgent.getAdminOverride(); } -void handle_admin_override_toggle(void*) +void handle_admin_override_toggle() { gAgent.setAdminOverride(!gAgent.getAdminOverride()); @@ -4303,7 +4249,7 @@ void handle_admin_override_toggle(void*) show_debug_menus(); } -void handle_visual_leak_detector_toggle(void*) +void handle_visual_leak_detector_toggle() { static bool vld_enabled = false; @@ -4332,12 +4278,12 @@ void handle_visual_leak_detector_toggle(void*) }; } -void handle_god_mode(void*) +void handle_god_mode() { gAgent.requestEnterGodMode(); } -void handle_leave_god_mode(void*) +void handle_leave_god_mode() { gAgent.requestLeaveGodMode(); } @@ -4384,18 +4330,18 @@ void set_god_level(U8 god_level) } #ifdef TOGGLE_HACKED_GODLIKE_VIEWER -void handle_toggle_hacked_godmode(void*) +void handle_toggle_hacked_godmode() { gHackGodmode = !gHackGodmode; set_god_level(gHackGodmode ? GOD_MAINTENANCE : GOD_NOT); } -bool check_toggle_hacked_godmode(void*) +bool check_toggle_hacked_godmode() { return gHackGodmode; } -bool enable_toggle_hacked_godmode(void*) +bool enable_toggle_hacked_godmode() { return !LLGridManager::getInstance()->isInProductionGrid(); } @@ -4419,41 +4365,6 @@ void process_grant_godlike_powers(LLMessageSystem* msg, void**) } } -/* -class LLHaveCallingcard : public LLInventoryCollectFunctor -{ -public: - LLHaveCallingcard(const LLUUID& agent_id); - virtual ~LLHaveCallingcard() {} - virtual bool operator()(LLInventoryCategory* cat, - LLInventoryItem* item); - bool isThere() const { return mIsThere;} -protected: - LLUUID mID; - bool mIsThere; -}; - -LLHaveCallingcard::LLHaveCallingcard(const LLUUID& agent_id) : - mID(agent_id), - mIsThere(false) -{ -} - -bool LLHaveCallingcard::operator()(LLInventoryCategory* cat, - LLInventoryItem* item) -{ - if(item) - { - if((item->getType() == LLAssetType::AT_CALLINGCARD) - && (item->getCreatorUUID() == mID)) - { - mIsThere = true; - } - } - return false; -} -*/ - bool is_agent_mappable(const LLUUID& agent_id) { const LLRelationship* buddy_info = NULL; @@ -4554,7 +4465,7 @@ bool is_object_sittable() } // only works on pie menu -void handle_object_sit(LLViewerObject *object, const LLVector3 &offset) +void handle_object_sit(LLViewerObject* object, const LLVector3& offset) { // get object selection offset @@ -4603,7 +4514,7 @@ void handle_object_sit(const LLUUID& object_id) handle_object_sit(obj, offset); } -void near_sit_down_point(bool success, void *) +void near_sit_down_point(bool success, void*) { if (success) { @@ -4653,7 +4564,7 @@ class LLLandCanSit : public view_listener_t // // Major mode switching // -void reset_view_final( bool proceed ); +void reset_view_final(bool proceed); void handle_reset_view() { @@ -4663,7 +4574,7 @@ void handle_reset_view() LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "my_outfits")); } gAgentCamera.setFocusOnAvatar(true, false, false); - reset_view_final( true ); + reset_view_final(true); LLFloaterCamera::resetCameraMode(); } @@ -4677,7 +4588,7 @@ class LLViewResetView : public view_listener_t }; // Note: extra parameters allow this function to be called from dialog. -void reset_view_final( bool proceed ) +void reset_view_final(bool proceed) { if( !proceed ) { @@ -4765,54 +4676,7 @@ class LLViewToggleUI : public view_listener_t } }; -void handle_duplicate_in_place(void*) -{ - LL_INFOS() << "handle_duplicate_in_place" << LL_ENDL; - - LLVector3 offset(0.f, 0.f, 0.f); - LLSelectMgr::getInstance()->selectDuplicate(offset, true); -} - - - -/* - * No longer able to support viewer side manipulations in this way - * -void god_force_inv_owner_permissive(LLViewerObject* object, - LLInventoryObject::object_list_t* inventory, - S32 serial_num, - void*) -{ - typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t; - item_array_t items; - - LLInventoryObject::object_list_t::const_iterator inv_it = inventory->begin(); - LLInventoryObject::object_list_t::const_iterator inv_end = inventory->end(); - for ( ; inv_it != inv_end; ++inv_it) - { - if(((*inv_it)->getType() != LLAssetType::AT_CATEGORY)) - { - LLInventoryObject* obj = *inv_it; - LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem((LLViewerInventoryItem*)obj); - LLPermissions perm(new_item->getPermissions()); - perm.setMaskBase(PERM_ALL); - perm.setMaskOwner(PERM_ALL); - new_item->setPermissions(perm); - items.push_back(new_item); - } - } - item_array_t::iterator end = items.end(); - item_array_t::iterator it; - for(it = items.begin(); it != end; ++it) - { - // since we have the inventory item in the callback, it should not - // invalidate iteration through the selection manager. - object->updateInventory((*it), TASK_INVENTORY_ITEM_KEY, false); - } -} -*/ - -void handle_object_owner_permissive(void*) +void handle_object_owner_permissive() { // only send this if they're a god. if(gAgent.isGodlike()) @@ -4823,7 +4687,7 @@ void handle_object_owner_permissive(void*) } } -void handle_object_owner_self(void*) +void handle_object_owner_self() { // only send this if they're a god. if(gAgent.isGodlike()) @@ -4833,12 +4697,12 @@ void handle_object_owner_self(void*) } // Shortcut to set owner permissions to not editable. -void handle_object_lock(void*) +void handle_object_lock() { LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_OWNER, false, PERM_MODIFY); } -void handle_object_asset_ids(void*) +void handle_object_asset_ids() { // only send this if they're a god. if (gAgent.isGodlike()) @@ -4847,17 +4711,17 @@ void handle_object_asset_ids(void*) } } -void handle_force_parcel_owner_to_me(void*) +void handle_force_parcel_owner_to_me() { LLViewerParcelMgr::getInstance()->sendParcelGodForceOwner( gAgent.getID() ); } -void handle_force_parcel_to_content(void*) +void handle_force_parcel_to_content() { LLViewerParcelMgr::getInstance()->sendParcelGodForceToContent(); } -void handle_claim_public_land(void*) +void handle_claim_public_land() { if (LLViewerParcelMgr::getInstance()->getSelectionRegion() != gAgent.getRegion()) { @@ -4899,7 +4763,7 @@ void handle_claim_public_land(void*) // HACK for easily testing new avatar geometry -void handle_god_request_avatar_geometry(void *) +void handle_god_request_avatar_geometry() { if (gAgent.isGodlike()) { @@ -5169,7 +5033,7 @@ void handle_link_objects() class LLObjectReturn : public view_listener_t { public: - LLObjectReturn() : mFirstRegion(NULL) {} + LLObjectReturn() : mFirstRegion() {} private: bool handleEvent(const LLSD& userdata) @@ -5239,7 +5103,7 @@ class LLObjectEnableReturn : public view_listener_t } }; -void force_take_copy(void*) +void force_take_copy() { if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return; const LLUUID category_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); @@ -5347,7 +5211,7 @@ void handle_take(bool take_separate) } }); - if(locked_but_takeable_object || + if (locked_but_takeable_object || !you_own_everything) { if(locked_but_takeable_object && you_own_everything) @@ -5930,7 +5794,7 @@ class LLToolsSelectNextPartFace : public view_listener_t { if (gFocusMgr.childHasKeyboardFocus(gFloaterTools)) { - gFocusMgr.setKeyboardFocus(NULL); // force edit toolbox to commit any changes + gFocusMgr.setKeyboardFocus(nullptr); // force edit toolbox to commit any changes } if (fwd || prev) { @@ -6003,7 +5867,7 @@ class LLEditCut : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if( LLEditMenuHandler::gEditMenuHandler ) + if (LLEditMenuHandler::gEditMenuHandler) { LLEditMenuHandler::gEditMenuHandler->cut(); } @@ -6024,7 +5888,7 @@ class LLEditCopy : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if( LLEditMenuHandler::gEditMenuHandler ) + if (LLEditMenuHandler::gEditMenuHandler) { LLEditMenuHandler::gEditMenuHandler->copy(); } @@ -6045,7 +5909,7 @@ class LLEditPaste : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if( LLEditMenuHandler::gEditMenuHandler ) + if (LLEditMenuHandler::gEditMenuHandler) { LLEditMenuHandler::gEditMenuHandler->paste(); } @@ -6068,7 +5932,7 @@ class LLEditDelete : public view_listener_t { // If a text field can do a deletion, it gets precedence over deleting // an object in the world. - if( LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canDoDelete()) + if (LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canDoDelete()) { LLEditMenuHandler::gEditMenuHandler->doDelete(); } @@ -6179,7 +6043,7 @@ bool enable_object_delete() class LLObjectsReturnPackage { public: - LLObjectsReturnPackage() : mObjectSelection(), mReturnableObjects(), mError(), mFirstRegion(NULL) {}; + LLObjectsReturnPackage() : mObjectSelection(), mReturnableObjects(), mError(), mFirstRegion(nullptr) {}; ~LLObjectsReturnPackage() { mObjectSelection.clear(); @@ -6236,7 +6100,7 @@ void handle_object_delete() return; } -void handle_force_delete(void*) +void handle_force_delete() { LLSelectMgr::getInstance()->selectForceDelete(); } @@ -6348,12 +6212,12 @@ class LLEditRedo : public view_listener_t -void print_object_info(void*) +void print_object_info() { LLSelectMgr::getInstance()->selectionDump(); } -void print_agent_nvpairs(void*) +void print_agent_nvpairs() { LLViewerObject *objectp; @@ -6402,53 +6266,13 @@ void show_debug_menus() } } -void toggle_debug_menus(void*) +void toggle_debug_menus() { bool visible = ! gSavedSettings.getBOOL("UseDebugMenus"); gSavedSettings.setBOOL("UseDebugMenus", visible); show_debug_menus(); } - -// LLUUID gExporterRequestID; -// std::string gExportDirectory; - -// LLUploadDialog *gExportDialog = NULL; - -// void handle_export_selected( void * ) -// { -// LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); -// if (selection->isEmpty()) -// { -// return; -// } -// LL_INFOS() << "Exporting selected objects:" << LL_ENDL; - -// gExporterRequestID.generate(); -// gExportDirectory = ""; - -// LLMessageSystem* msg = gMessageSystem; -// msg->newMessageFast(_PREHASH_ObjectExportSelected); -// msg->nextBlockFast(_PREHASH_AgentData); -// msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); -// msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID); -// msg->addS16Fast(_PREHASH_VolumeDetail, 4); - -// for (LLObjectSelection::root_iterator iter = selection->root_begin(); -// iter != selection->root_end(); iter++) -// { -// LLSelectNode* node = *iter; -// LLViewerObject* object = node->getObject(); -// msg->nextBlockFast(_PREHASH_ObjectData); -// msg->addUUIDFast(_PREHASH_ObjectID, object->getID()); -// LL_INFOS() << "Object: " << object->getID() << LL_ENDL; -// } -// msg->sendReliable(gAgent.getRegion()->getHost()); - -// gExportDialog = LLUploadDialog::modalUploadDialog("Exporting selected objects..."); -// } -// - class LLCommunicateNearbyChat : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -6626,7 +6450,7 @@ void handle_look_at_selection(const LLSD& param) } } -void handle_zoom_to_object(LLUUID object_id) +void handle_zoom_to_object(const LLUUID& object_id) { const F32 PADDING_FACTOR = 2.f; @@ -6937,28 +6761,28 @@ bool enable_object_sit(LLUICtrl* ctrl) return !sitting_on_sel && is_object_sittable(); } -void dump_select_mgr(void*) +void dump_select_mgr() { LLSelectMgr::getInstance()->dump(); } -void dump_inventory(void*) +void dump_inventory() { gInventory.dumpInventory(); } -void handle_dump_followcam(void*) +void handle_dump_followcam() { LLFollowCamMgr::getInstance()->dump(); } -void handle_viewer_enable_message_log(void*) +void handle_viewer_enable_message_log() { gMessageSystem->startLogging(); } -void handle_viewer_disable_message_log(void*) +void handle_viewer_disable_message_log() { gMessageSystem->stopLogging(); } @@ -7325,7 +7149,7 @@ class LLWorldEnableBuyLand : public view_listener_t } }; -bool enable_buy_land(void*) +bool enable_buy_land() { return LLViewerParcelMgr::getInstance()->canAgentBuyParcel( LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(), false); @@ -7411,7 +7235,7 @@ void LLObjectAttachToAvatar::onNearAttachObject(bool success, void *user_data) } LLSelectMgr::getInstance()->sendAttach(cb_data->getSelection(), attachment_id, cb_data->mReplace); } - LLObjectAttachToAvatar::setObjectSelection(NULL); + LLObjectAttachToAvatar::setObjectSelection(nullptr); delete cb_data; } @@ -7990,7 +7814,7 @@ class LLToolsSelectedScriptAction : public view_listener_t } }; -void handle_selected_texture_info(void*) +void handle_selected_texture_info() { for (LLObjectSelection::valid_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_begin(); iter != LLSelectMgr::getInstance()->getSelection()->valid_end(); iter++) @@ -8078,21 +7902,22 @@ void handle_selected_material_info() } } -void handle_test_male(void*) +void handle_test_male() { LLAppearanceMgr::instance().wearOutfitByName("Male Shape & Outfit"); //gGestureList.requestResetFromServer( true ); } -void handle_test_female(void*) +void handle_test_female() { LLAppearanceMgr::instance().wearOutfitByName("Female Shape & Outfit"); //gGestureList.requestResetFromServer( false ); } -void handle_dump_attachments(void*) +void handle_dump_attachments() { - if(!isAgentAvatarValid()) return; + if (!isAgentAvatarValid()) + return; for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); iter != gAgentAvatarp->mAttachmentPoints.end(); ) @@ -8294,12 +8119,12 @@ class LLToggleShaderControl : public view_listener_t } }; -void menu_toggle_attached_lights(void* user_data) +void menu_toggle_attached_lights() { LLPipeline::sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); } -void menu_toggle_attached_particles(void* user_data) +void menu_toggle_attached_particles() { LLPipeline::sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); } @@ -8317,11 +8142,11 @@ class LLAdvancedHandleAttachedLightParticles: public view_listener_t // update internal flags if (control_name == "RenderAttachedLights") { - menu_toggle_attached_lights(NULL); + menu_toggle_attached_lights(); } else if (control_name == "RenderAttachedParticles") { - menu_toggle_attached_particles(NULL); + menu_toggle_attached_particles(); } return true; } @@ -8436,7 +8261,7 @@ bool LLHasAsset::operator()(LLInventoryCategory* cat, } -bool enable_save_into_task_inventory(void*) +bool enable_save_into_task_inventory() { LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); if(node && (node->mValid) && (!node->mFromTaskID.isNull())) @@ -8455,7 +8280,7 @@ class LLToolsEnableSaveToObjectInventory : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = enable_save_into_task_inventory(NULL); + bool new_value = enable_save_into_task_inventory(); return new_value; } }; @@ -8518,12 +8343,12 @@ class LLWorldEnableTeleportHome : public view_listener_t } }; -bool enable_god_full(void*) +bool enable_god_full() { return gAgent.getGodLevel() >= GOD_FULL; } -bool enable_god_liaison(void*) +bool enable_god_liaison() { return gAgent.getGodLevel() >= GOD_LIAISON; } @@ -8533,18 +8358,18 @@ bool is_god_customer_service() return gAgent.getGodLevel() >= GOD_CUSTOMER_SERVICE; } -bool enable_god_basic(void*) +bool enable_god_basic() { return gAgent.getGodLevel() > GOD_NOT; } -void toggle_show_xui_names(void *) +void toggle_show_xui_names() { gSavedSettings.setBOOL("DebugShowXUINames", !gSavedSettings.getBOOL("DebugShowXUINames")); } -bool check_show_xui_names(void *) +bool check_show_xui_names() { return gSavedSettings.getBOOL("DebugShowXUINames"); } @@ -8650,12 +8475,12 @@ class LLToolsEditLinkedParts : public view_listener_t } }; -void reload_vertex_shader(void *) +void reload_vertex_shader() { //THIS WOULD BE AN AWESOME PLACE TO RELOAD SHADERS... just a thought - DaveP } -void handle_dump_avatar_local_textures(void*) +void handle_dump_avatar_local_textures() { gAgentAvatarp->dumpLocalTextures(); } @@ -8665,7 +8490,7 @@ void handle_dump_timers() LLTrace::BlockTimer::dumpCurTimes(); } -void handle_debug_avatar_textures(void*) +void handle_debug_avatar_textures() { LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); if (objectp) @@ -8674,10 +8499,10 @@ void handle_debug_avatar_textures(void*) } } -void handle_grab_baked_texture(void* data) +void handle_grab_baked_texture(EBakedTextureIndex baked_tex_index) { - EBakedTextureIndex baked_tex_index = (EBakedTextureIndex)((intptr_t)data); - if (!isAgentAvatarValid()) return; + if (!isAgentAvatarValid()) + return; const LLUUID& asset_id = gAgentAvatarp->grabBakedTexture(baked_tex_index); LL_INFOS("texture") << "Adding baked texture " << asset_id << " to inventory." << LL_ENDL; @@ -8740,19 +8565,18 @@ void handle_grab_baked_texture(void* data) } } -bool enable_grab_baked_texture(void* data) +bool enable_grab_baked_texture(EBakedTextureIndex baked_tex_index) { - EBakedTextureIndex index = (EBakedTextureIndex)((intptr_t)data); if (isAgentAvatarValid()) { - return gAgentAvatarp->canGrabBakedTexture(index); + return gAgentAvatarp->canGrabBakedTexture(baked_tex_index); } return false; } // Returns a pointer to the avatar give the UUID of the avatar OR of an attachment the avatar is wearing. // Returns NULL on failure. -LLVOAvatar* find_avatar_from_object( LLViewerObject* object ) +LLVOAvatar* find_avatar_from_object(LLViewerObject* object) { if (object) { @@ -8776,63 +8600,63 @@ LLVOAvatar* find_avatar_from_object( LLViewerObject* object ) // Returns a pointer to the avatar give the UUID of the avatar OR of an attachment the avatar is wearing. // Returns NULL on failure. -LLVOAvatar* find_avatar_from_object( const LLUUID& object_id ) +LLVOAvatar* find_avatar_from_object(const LLUUID& object_id) { return find_avatar_from_object( gObjectList.findObject(object_id) ); } -void handle_disconnect_viewer(void *) +void handle_disconnect_viewer() { LLAppViewer::instance()->forceDisconnect(LLTrans::getString("TestingDisconnect")); } -void force_error_breakpoint(void *) +void force_error_breakpoint() { LLAppViewer::instance()->forceErrorBreakpoint(); } -void force_error_llerror(void *) +void force_error_llerror() { LLAppViewer::instance()->forceErrorLLError(); } -void force_error_llerror_msg(void*) +void force_error_llerror_msg() { LLAppViewer::instance()->forceErrorLLErrorMsg(); } -void force_error_bad_memory_access(void *) +void force_error_bad_memory_access() { LLAppViewer::instance()->forceErrorBadMemoryAccess(); } -void force_error_infinite_loop(void *) +void force_error_infinite_loop() { LLAppViewer::instance()->forceErrorInfiniteLoop(); } -void force_error_software_exception(void *) +void force_error_software_exception() { LLAppViewer::instance()->forceErrorSoftwareException(); } -void force_error_os_exception(void*) +void force_error_os_exception() { LLAppViewer::instance()->forceErrorOSSpecificException(); } -void force_error_driver_crash(void *) +void force_error_driver_crash() { LLAppViewer::instance()->forceErrorDriverCrash(); } -void force_error_coroutine_crash(void *) +void force_error_coroutine_crash() { LLAppViewer::instance()->forceErrorCoroutineCrash(); } -void force_error_thread_crash(void *) +void force_error_thread_crash() { LLAppViewer::instance()->forceErrorThreadCrash(); } @@ -8857,7 +8681,7 @@ class LLToolsUseSelectionForGrid : public view_listener_t } }; -void handle_test_load_url(void*) +void handle_test_load_url() { LLWeb::loadURL(""); LLWeb::loadURL("hacker://www.google.com/"); @@ -8965,7 +8789,7 @@ void handle_report_bug(const LLSD& param) LLWeb::loadURLExternal(url); } -void handle_buy_currency_test(void*) +void handle_buy_currency_test() { std::string url = "http://sarahd-sl-13041.webdev.lindenlab.com/app/lindex/index.php?agent_id=[AGENT_ID]&secure_session_id=[SESSION_ID]&lang=[LANGUAGE]"; @@ -8982,7 +8806,7 @@ void handle_buy_currency_test(void*) } // SUNSHINE CLEANUP - is only the request update at the end needed now? -void handle_rebake_textures(void*) +void handle_rebake_textures() { if (!isAgentAvatarValid()) return; @@ -8995,15 +8819,13 @@ void handle_rebake_textures(void*) } } -void toggle_visibility(void* user_data) +void toggle_visibility(LLView* viewp) { - LLView* viewp = (LLView*)user_data; viewp->setVisible(!viewp->getVisible()); } -bool get_visibility(void* user_data) +bool get_visibility(LLView* viewp) { - LLView* viewp = (LLView*)user_data; return viewp->getVisible(); } @@ -9757,6 +9579,8 @@ void initialize_menus() commit.add("Agent.ToggleMicrophone", boost::bind(&LLAgent::toggleMicrophone, _2)); enable.add("Agent.IsMicrophoneOn", boost::bind(&LLAgent::isMicrophoneOn, _2)); enable.add("Agent.IsActionAllowed", boost::bind(&LLAgent::isActionAllowed, _2)); + commit.add("Agent.ToggleHearMediaSoundFromAvatar", boost::bind(&LLAgent::toggleHearMediaSoundFromAvatar)); + commit.add("Agent.ToggleHearVoiceFromAvatar", boost::bind(&LLAgent::toggleHearVoiceFromAvatar)); // File menu init_menu_file(); @@ -10219,7 +10043,6 @@ void initialize_menus() enable.add("EnablePayAvatar", boost::bind(&enable_pay_avatar)); enable.add("EnableEdit", boost::bind(&enable_object_edit)); enable.add("EnableMuteParticle", boost::bind(&enable_mute_particle)); - enable.add("VisibleBuild", boost::bind(&enable_object_build)); commit.add("Pathfinding.Linksets.Select", boost::bind(&LLFloaterPathfindingLinksets::openLinksetsWithSelectedObjects)); enable.add("EnableSelectInPathfindingLinksets", boost::bind(&enable_object_select_in_pathfinding_linksets)); enable.add("VisibleSelectInPathfindingLinksets", boost::bind(&visible_object_select_in_pathfinding_linksets)); diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h index 8c5e0705d0..68c3dbc126 100644 --- a/indra/newview/llviewermenu.h +++ b/indra/newview/llviewermenu.h @@ -44,54 +44,21 @@ void init_menus(); void cleanup_menus(); void show_debug_menus(); // checks for if menus should be shown first. -void toggle_debug_menus(void*); -void show_context_menu( S32 x, S32 y, MASK mask ); -void show_build_mode_context_menu(S32 x, S32 y, MASK mask); +void toggle_debug_menus(); void show_navbar_context_menu(LLView* ctrl, S32 x, S32 y); void show_topinfobar_context_menu(LLView* ctrl, S32 x, S32 y); void handle_reset_view(); -void handle_cut(void*); -void handle_copy(void*); -void handle_paste(void*); -void handle_delete(void*); -void handle_redo(void*); -void handle_undo(void*); -void handle_select_all(void*); -void handle_deselect(void*); -void handle_delete_object(); -void handle_duplicate(void*); -void handle_duplicate_in_place(void*); -bool enable_not_have_card(void *userdata); void process_grant_godlike_powers(LLMessageSystem* msg, void**); -bool enable_cut(void*); -bool enable_copy(void*); -bool enable_paste(void*); -bool enable_select_all(void*); -bool enable_deselect(void*); -bool enable_undo(void*); -bool enable_redo(void*); - bool is_agent_mappable(const LLUUID& agent_id); -void confirm_replace_attachment(S32 option, void* user_data); -void handle_detach_from_avatar(const LLSD& user_data); -void attach_label(std::string& label, const LLSD&); -void detach_label(std::string& label, const LLSD&); -void handle_detach(void*); -bool enable_god_full(void* user_data); -bool enable_god_liaison(void* user_data); -bool enable_god_basic(void* user_data); +bool enable_god_full(); +bool enable_god_liaison(); +bool enable_god_basic(); void check_merchant_status(bool force = false); -void exchange_callingcard(const LLUUID& dest_id); - -void handle_gestures(void*); -void handle_sit_down(void*); -void handle_object_build(void*); void handle_object_touch(); bool enable_object_edit_gltf_material(); -bool enable_object_save_gltf_material(); bool enable_object_open(); void handle_object_open(); @@ -106,12 +73,11 @@ void handle_buy(); void handle_take(bool take_separate = false); void handle_take_copy(); void handle_look_at_selection(const LLSD& param); -void handle_zoom_to_object(LLUUID object_id); +void handle_zoom_to_object(const LLUUID& object_id); void handle_object_return(); void handle_object_delete(); void handle_object_edit(); void handle_object_edit_gltf_material(); -void handle_object_save_gltf_material(); void handle_attachment_edit(const LLUUID& inv_item_id); void handle_attachment_touch(const LLUUID& inv_item_id); @@ -144,13 +110,10 @@ bool enable_pay_object(); bool enable_buy_object(); bool handle_go_to(); -// Export to XML or Collada -void handle_export_selected( void * ); - // Convert strings to internal types -U32 render_type_from_string(std::string render_type); -U32 feature_from_string(std::string feature); -U64 info_display_from_string(std::string info_display); +U32 render_type_from_string(std::string_view render_type); +U32 feature_from_string(std::string_view feature); +U64 info_display_from_string(std::string_view info_display); class LLViewerMenuHolderGL : public LLMenuHolderGL { diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 83f8e96f9a..ce66dbc03f 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -990,7 +990,7 @@ class LLFileQuit : public view_listener_t }; -void handle_compress_image(void*) +void handle_compress_image() { LLFilePicker& picker = LLFilePicker::instance(); if (picker.getMultipleOpenFiles(LLFilePicker::FFLOAD_IMAGE)) @@ -1040,7 +1040,7 @@ size_t get_file_size(std::string &filename) return file_length; } -void handle_compress_file_test(void*) +void handle_compress_file_test() { LLFilePicker& picker = LLFilePicker::instance(); if (picker.getOpenFile()) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 872a9a1581..1d4828fd33 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3139,14 +3139,9 @@ void process_crossed_region(LLMessageSystem* msg, void**) } - -// Sends avatar and camera information to simulator. -// Sent roughly once per frame, or 20 times per second, whichever is less often - -const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f; // ~= 2.5 degrees -- if its less than this we need to update head_rot -const F32 MAX_HEAD_ROT_QDOT = 0.99999f; // ~= 0.5 degrees -- if its greater than this then no need to update head_rot - // between these values we delay the updates (but no more than one second) - +// sends an AgentUpdate message to the server... or not: +// only when force_send is 'true' OR +// something changed AND the update is not being throttled void send_agent_update(bool force_send, bool send_reliable) { LL_PROFILE_ZONE_SCOPED; @@ -3154,72 +3149,46 @@ void send_agent_update(bool force_send, bool send_reliable) if (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE) { - // We don't care if they want to send an agent update, they're not allowed to until the simulator - // that's the target is ready to receive them (after avatar_init_complete is received) + // We don't care if they want to send an agent update, they're not allowed + // until the target simulator is ready to receive them + // (e.g. after avatar_init_complete is received) return; } - // We have already requested to log out. Don't send agent updates. - if(LLAppViewer::instance()->logoutRequestSent()) + if (LLAppViewer::instance()->logoutRequestSent()) { + // We have already requested to log out. Don't send agent updates. return; } - // no region to send update to - if(gAgent.getRegion() == NULL) + if (gAgent.getRegion() == nullptr || gDisconnected) { + // no region to send update to return; } - const F32 TRANSLATE_THRESHOLD = 0.01f; - - // NOTA BENE: This is (intentionally?) using the small angle sine approximation to test for rotation - // Plus, there is an extra 0.5 in the mix since the perpendicular between last_camera_at and getAtAxis() bisects cam_rot_change - // Thus, we're actually testing against 0.2 degrees - const F32 ROTATION_THRESHOLD = 0.1f * 2.f*F_PI/360.f; // Rotation thresh 0.2 deg, see note above - - const U8 DUP_MSGS = 1; // HACK! number of times to repeat data on motionless agent - - // Store data on last sent update so that if no changes, no send - static LLVector3 last_camera_pos_agent, - last_camera_at, - last_camera_left, - last_camera_up; - - static LLVector3 cam_center_chg, - cam_rot_chg; - - static LLQuaternion last_head_rot; - static U32 last_control_flags = 0; - static U8 last_render_state; - static U8 duplicate_count = 0; - static F32 head_rot_chg = 1.0; - static U8 last_flags; - - LLMessageSystem *msg = gMessageSystem; - LLVector3 camera_pos_agent; // local to avatar's region - U8 render_state; - - LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion(); - LLQuaternion head_rotation = gAgent.getHeadRotation(); - - camera_pos_agent = gAgentCamera.getCameraPositionAgent(); - - render_state = gAgent.getRenderState(); - - U32 control_flag_change = 0; - U8 flag_change = 0; + static F64 last_send_time = 0.0; + static U32 last_control_flags = 0; + static U8 last_render_state = 0; + static U8 last_flags = AU_FLAGS_NONE; + static LLQuaternion last_body_rot, + last_head_rot; + static LLVector3 last_camera_pos_agent, + last_camera_at; - cam_center_chg = last_camera_pos_agent - camera_pos_agent; - cam_rot_chg = last_camera_at - LLViewerCamera::getInstance()->getAtAxis(); + // compute sec_since_last_send + constexpr F64 MAX_AGENT_UPDATES_PER_SECOND = 125.0; // Value derived experimentally to avoid Input Delays with latest PBR-Capable Viewers when viewer FPS is highly volatile. + constexpr F64 MIN_AGENT_UPDATES_PER_SECOND = 1.0; // keep-alive rate + constexpr F64 MIN_AGENT_UPDATE_PERIOD = 1.0 / MAX_AGENT_UPDATES_PER_SECOND; + constexpr F64 MAX_AGENT_UPDATE_PERIOD = 1.0 / MIN_AGENT_UPDATES_PER_SECOND; + F64 now = LLFrameTimer::getTotalSeconds(); + F64 sec_since_last_send = now - last_send_time; // If a modifier key is held down, turn off // LBUTTON and ML_LBUTTON so that using the camera (alt-key) doesn't // trigger a control event. U32 control_flags = gAgent.getControlFlags(); - - MASK key_mask = gKeyboard->currentMask(true); - + MASK key_mask = gKeyboard->currentMask(true); if (key_mask & MASK_ALT || key_mask & MASK_CONTROL) { control_flags &= ~( AGENT_CONTROL_LBUTTON_DOWN | @@ -3228,7 +3197,22 @@ void send_agent_update(bool force_send, bool send_reliable) AGENT_CONTROL_ML_LBUTTON_UP ; } - control_flag_change = last_control_flags ^ control_flags; + // any change in control_flags should be sent ASAP, so we fold that into force_send + force_send = force_send || (control_flags != last_control_flags); + + if (! force_send && sec_since_last_send < MIN_AGENT_UPDATE_PERIOD) + { + // throttle less-important AgentUpdates + return; + } + + bool send_update = force_send || sec_since_last_send > MAX_AGENT_UPDATE_PERIOD; + + LLVector3 camera_pos_agent = gAgentCamera.getCameraPositionAgent(); // local to avatar's region + LLVector3 camera_at = LLViewerCamera::getInstance()->getAtAxis(); + LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion(); + LLQuaternion head_rotation = gAgent.getHeadRotation(); + U8 render_state = gAgent.getRenderState(); U8 flags = AU_FLAGS_NONE; if (gAgent.isGroupTitleHidden()) @@ -3240,159 +3224,140 @@ void send_agent_update(bool force_send, bool send_reliable) flags |= AU_FLAGS_CLIENT_AUTOPILOT; } - flag_change = last_flags ^ flags; - - head_rot_chg = dot(last_head_rot, head_rotation); - - //static S32 msg_number = 0; // Used for diagnostic log messages - - if (force_send || - (cam_center_chg.magVec() > TRANSLATE_THRESHOLD) || - (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT) || - (last_render_state != render_state) || - (cam_rot_chg.magVec() > ROTATION_THRESHOLD) || - control_flag_change != 0 || - flag_change != 0) + if (!send_update) { - /* Diagnotics to show why we send the AgentUpdate message. Also un-commment the msg_number code above and below this block - msg_number += 1; - if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT) - { - //LL_INFOS("Messaging") << "head rot " << head_rotation << LL_ENDL; - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", head_rot_chg " << head_rot_chg << LL_ENDL; - } - if (cam_rot_chg.magVec() > ROTATION_THRESHOLD) + // check to see if anything changed + // use a do-while-false to provide easy way to break out as soon as we find something changed + do { - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", cam rot " << cam_rot_chg.magVec() << LL_ENDL; - } - if (cam_center_chg.magVec() > TRANSLATE_THRESHOLD) - { - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", cam center " << cam_center_chg.magVec() << LL_ENDL; - } -// if (drag_delta_chg.magVec() > TRANSLATE_THRESHOLD) -// { -// LL_INFOS("Messaging") << "drag delta " << drag_delta_chg.magVec() << LL_ENDL; -// } - if (control_flag_change) - { - LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", dcf = " << control_flag_change << LL_ENDL; - } -*/ - - duplicate_count = 0; - } - else - { - duplicate_count++; + // start with the easy evaluations and progress to more complicated - if (head_rot_chg < MAX_HEAD_ROT_QDOT && duplicate_count < AGENT_UPDATES_PER_SECOND) - { - // The head_rotation is sent for updating things like attached guns. - // We only trigger a new update when head_rotation deviates beyond - // some threshold from the last update, however this can break fine - // adjustments when trying to aim an attached gun, so what we do here - // (where we would normally skip sending an update when nothing has changed) - // is gradually reduce the threshold to allow a better update to - // eventually get sent... should update to within 0.5 degrees in less - // than a second. - if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT + (MAX_HEAD_ROT_QDOT - THRESHOLD_HEAD_ROT_QDOT) * duplicate_count / AGENT_UPDATES_PER_SECOND) + // check render_state + if (last_render_state != render_state) { - duplicate_count = 0; + send_update = true; + break; } - else + + // check flags + if (last_flags != flags) { - return; + send_update = true; + break; } - } - else - { - return; - } - } - if (duplicate_count < DUP_MSGS && !gDisconnected) - { - /* More diagnostics to count AgentUpdate messages - static S32 update_sec = 0; - static S32 update_count = 0; - static S32 max_update_count = 0; - S32 cur_sec = lltrunc( LLTimer::getTotalSeconds() ); - update_count += 1; - if (cur_sec != update_sec) - { - if (update_sec != 0) + // check translation + constexpr F32 TRANSLATE_THRESHOLD = 0.01f; + if ((last_camera_pos_agent - camera_pos_agent).magVec() > TRANSLATE_THRESHOLD) { - update_sec = cur_sec; - //msg_number = 0; - max_update_count = llmax(max_update_count, update_count); - LL_INFOS() << "Sent " << update_count << " AgentUpdate messages per second, max is " << max_update_count << LL_ENDL; + send_update = true; + break; } - update_sec = cur_sec; - update_count = 0; - } - */ - // Build the message - msg->newMessageFast(_PREHASH_AgentUpdate); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->addQuatFast(_PREHASH_BodyRotation, body_rotation); - msg->addQuatFast(_PREHASH_HeadRotation, head_rotation); - msg->addU8Fast(_PREHASH_State, render_state); - msg->addU8Fast(_PREHASH_Flags, flags); - -// if (camera_pos_agent.mV[VY] > 255.f) -// { -// LL_INFOS("Messaging") << "Sending camera center " << camera_pos_agent << LL_ENDL; -// } - - msg->addVector3Fast(_PREHASH_CameraCenter, camera_pos_agent); - msg->addVector3Fast(_PREHASH_CameraAtAxis, LLViewerCamera::getInstance()->getAtAxis()); - msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis()); - msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis()); - msg->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance); + // check camera rotation + // Note: we are using the sine small angle approximation trick here + constexpr F32 RADIANS_PER_DEGREE = F_PI / 360.f; + constexpr F32 CAMERA_AT_THRESHOLD = 0.2f * RADIANS_PER_DEGREE; + if ((last_camera_at - camera_at).magVec() > CAMERA_AT_THRESHOLD) + { + send_update = true; + break; + } - msg->addU32Fast(_PREHASH_ControlFlags, control_flags); + // check head rotation + constexpr F64 MIN_HEAD_ROT_QDOT = 0.9997; // ~= 2.5 degrees -- if its less than this we need to update head_rot + constexpr F64 MAX_HEAD_ROT_QDOT = 0.99999; // ~= 0.5 degrees -- if its greater than this then we consider it close enough - if (gDebugClicks) - { - if (control_flags & AGENT_CONTROL_LBUTTON_DOWN) + if (fabs((F64)(dot(last_body_rot, body_rotation))) < MIN_HEAD_ROT_QDOT) { - LL_INFOS("Messaging") << "AgentUpdate left button down" << LL_ENDL; + send_update = true; + break; } - if (control_flags & AGENT_CONTROL_LBUTTON_UP) + F64 head_rot_qdot = fabs((F64)(dot(last_head_rot, head_rotation))); + if (head_rot_qdot > MAX_HEAD_ROT_QDOT) { - LL_INFOS("Messaging") << "AgentUpdate left button up" << LL_ENDL; + // close enough + return; } - } + else if (head_rot_qdot < MIN_HEAD_ROT_QDOT) + { + // way off + send_update = true; + break; + } + + // Finally, if we get here then head_rot_qdot is somewhere between MIN_ and MAX_HEAD_ROT_QDOT - gAgent.enableControlFlagReset(); + // The head_rotation is sent for updating things like attached guns. + // We only trigger a new update when head_rotation deviates beyond + // some threshold from the last update, however this can break fine + // adjustments when trying to aim an attached gun, so what we do here + // (where we would normally skip sending an update when nothing has changed) + // is linearly increase the min threshold until an update is sent. + // Min threshold should update to MAX_HEAD_ROT_QDOT within THRESHOLD_GROWTH_PERIOD. + constexpr F64 THRESHOLD_GROWTH_PERIOD = 0.5; + constexpr F64 threshold_growth_per_sec = (MAX_HEAD_ROT_QDOT - MIN_HEAD_ROT_QDOT) / THRESHOLD_GROWTH_PERIOD; + send_update = head_rot_qdot < MIN_HEAD_ROT_QDOT + sec_since_last_send * threshold_growth_per_sec; + } while (false); + } + + if (!send_update) + { + return; + } + + // Build the message + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_AgentUpdate); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->addQuatFast(_PREHASH_BodyRotation, body_rotation); + msg->addQuatFast(_PREHASH_HeadRotation, head_rotation); + msg->addU8Fast(_PREHASH_State, render_state); + msg->addU8Fast(_PREHASH_Flags, flags); - if (!send_reliable) + msg->addVector3Fast(_PREHASH_CameraCenter, camera_pos_agent); + msg->addVector3Fast(_PREHASH_CameraAtAxis, camera_at); + msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis()); + msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis()); + msg->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance); + + msg->addU32Fast(_PREHASH_ControlFlags, control_flags); + + if (gDebugClicks) + { + if (control_flags & AGENT_CONTROL_LBUTTON_DOWN) { - gAgent.sendMessage(); + LL_INFOS("Messaging") << "AgentUpdate left button down" << LL_ENDL; } - else + + if (control_flags & AGENT_CONTROL_LBUTTON_UP) { - gAgent.sendReliableMessage(); + LL_INFOS("Messaging") << "AgentUpdate left button up" << LL_ENDL; } + } -// LL_DEBUGS("Messaging") << "agent " << avatar_pos_agent << " cam " << camera_pos_agent << LL_ENDL; - - // Copy the old data - last_head_rot = head_rotation; - last_render_state = render_state; - last_camera_pos_agent = camera_pos_agent; - last_camera_at = LLViewerCamera::getInstance()->getAtAxis(); - last_camera_left = LLViewerCamera::getInstance()->getLeftAxis(); - last_camera_up = LLViewerCamera::getInstance()->getUpAxis(); - last_control_flags = control_flags; - last_flags = flags; + if (send_reliable) + { + gAgent.sendReliableMessage(); + } + else + { + gAgent.sendMessage(); } -} + // remember last update data + last_send_time = now; + last_control_flags = control_flags; + last_render_state = render_state; + last_flags = flags; + last_body_rot = body_rotation; + last_head_rot = head_rotation; + last_camera_pos_agent = camera_pos_agent; + last_camera_at = camera_at; +} // sounds can arrive before objects, store them for a short time // Note: this is a workaround for MAINT-4743, real fix would be to make @@ -6774,7 +6739,8 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid, { LL_DEBUGS("Messaging") << "onCovenantLoadComplete()" << LL_ENDL; std::string covenant_text; - if(0 == status) + std::unique_ptr<LLViewerTextEditor> editorp; + if (0 == status) { LLFileSystem file(asset_uuid, type, LLFileSystem::READ); @@ -6795,13 +6761,13 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid, { LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL; covenant_text = "Problem importing estate covenant."; + delete editor; } else { // Version 0 (just text, doesn't include version number) - covenant_text = editor->getText(); + editorp.reset(editor); // Use covenant from editorp; } - delete editor; } else { @@ -6827,17 +6793,32 @@ void onCovenantLoadComplete(const LLUUID& asset_uuid, LL_WARNS("Messaging") << "Problem loading notecard: " << status << LL_ENDL; } - LLPanelEstateCovenant::updateCovenantText(covenant_text, asset_uuid); - LLPanelLandCovenant::updateCovenantText(covenant_text); - LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid); - LLPanelPlaceProfile* panel = LLFloaterSidePanelContainer::getPanel<LLPanelPlaceProfile>("places", "panel_place_profile"); - if (panel) + if (editorp) { - panel->updateCovenantText(covenant_text); + LLPanelEstateCovenant::updateCovenant(editorp.get(), asset_uuid); + LLPanelLandCovenant::updateCovenant(editorp.get()); + LLFloaterBuyLand::updateCovenant(editorp.get(), asset_uuid); + } + else + { + LLPanelEstateCovenant::updateCovenantText(covenant_text, asset_uuid); + LLPanelLandCovenant::updateCovenantText(covenant_text); + LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid); } -} + if (LLPanelPlaceProfile* panel = LLFloaterSidePanelContainer::getPanel<LLPanelPlaceProfile>("places", "panel_place_profile")) + { + if (editorp) + { + panel->updateCovenant(editorp.get()); + } + else + { + panel->updateCovenantText(covenant_text); + } + } +} void process_feature_disabled_message(LLMessageSystem* msg, void**) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index bc6e13ff8e..41b2c4b44b 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -7418,6 +7418,7 @@ const std::string& LLViewerObject::getAttachmentItemName() const //virtual LLVOAvatar* LLViewerObject::getAvatar() const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (getControlAvatar()) { return getControlAvatar(); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 9e1d86faac..6167129077 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -65,6 +65,7 @@ #include "lltoolmgr.h" #include "lltoolpie.h" #include "llkeyboard.h" +#include "llmeshrepository.h" #include "u64.h" #include "llviewertexturelist.h" #include "lldatapacker.h" @@ -1419,6 +1420,10 @@ void LLViewerObjectList::cleanDeadObjects(bool use_timer) // No dead objects, don't need to scan object list. return; } + if ((LLApp::isExiting()) || (mNumDeadObjects == (S32)mObjects.size())) + { + gMeshRepo.unregisterAllMeshes(); + } LL_PROFILE_ZONE_SCOPED; diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 7dfa94b99f..dc31995eb1 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -259,15 +259,16 @@ extern LLViewerObjectList gObjectList; */ inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) { + if (id.isNull()) + return NULL; + auto iter = mUUIDObjectMap.find(id); - if(iter != mUUIDObjectMap.end()) + if (iter != mUUIDObjectMap.end()) { return iter->second; } - else - { - return NULL; - } + + return NULL; } inline LLViewerObject *LLViewerObjectList::getObject(const S32 index) diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index d315183ad0..03d5563c65 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -345,11 +345,10 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) impl = regionp->getRegionImplNC(); - ++(impl->mSeedCapAttempts); - if (!result.isMap() || result.has("error")) { LL_WARNS("AppInit", "Capabilities") << "Malformed response" << LL_ENDL; + ++(impl->mSeedCapAttempts); // setup for retry. continue; } @@ -359,6 +358,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) if (!status) { LL_WARNS("AppInit", "Capabilities") << "HttpStatus error " << LL_ENDL; + ++(impl->mSeedCapAttempts); // setup for retry. continue; } @@ -369,6 +369,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) if (id != impl->mHttpResponderID) // region is no longer referring to this request { LL_WARNS("AppInit", "Capabilities") << "Received results for a stale capabilities request!" << LL_ENDL; + ++(impl->mSeedCapAttempts); // setup for retry. continue; } diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 14228b469f..210cd62d6f 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -179,6 +179,16 @@ public: mToolTip = inv_item->getName() + '\n' + inv_item->getDescription(); } + /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const + { + LLTextEditor* editor = dynamic_cast<LLTextEditor*>(&target); + llassert(editor); + if (!editor) + return nullptr; + + return new LLEmbeddedItemSegment(mStart, mImage, mItem, *editor); + } + /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { if (num_chars == 0) @@ -503,7 +513,7 @@ S32 LLEmbeddedItems::getIndexFromEmbeddedChar(llwchar wch) } else { - LL_WARNS() << "Embedded char " << wch << " not found, using 0" << LL_ENDL; + LL_WARNS() << "Embedded char " << (int)wch << " not found, using 0" << LL_ENDL; return 0; } } diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 012ef5924a..9e1cb84bd1 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -541,7 +541,7 @@ void LLViewerTexture::updateClass() if (sEvaluationTimer.getElapsedTimeF32() > MEMORY_CHECK_WAIT_TIME) { static LLCachedControl<F32> low_mem_min_discard_increment(gSavedSettings, "RenderLowMemMinDiscardIncrement", .1f); - sDesiredDiscardBias += (F32)low_mem_min_discard_increment * (F32)gFrameIntervalSeconds; + sDesiredDiscardBias += (F32) low_mem_min_discard_increment * (F32) gFrameIntervalSeconds; sEvaluationTimer.reset(); } } @@ -1361,51 +1361,6 @@ void LLViewerFetchedTexture::addToCreateTexture() } else { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; -#if 1 - // - //if mRequestedDiscardLevel > mDesiredDiscardLevel, we assume the required image res keep going up, - //so do not scale down the over qualified image. - //Note: scaling down image is expensensive. Do it only when very necessary. - // - if(mRequestedDiscardLevel <= mDesiredDiscardLevel && !mForceToSaveRawImage) - { - U32 w = mFullWidth >> mRawDiscardLevel; - U32 h = mFullHeight >> mRawDiscardLevel; - - //if big image, do not load extra data - //scale it down to size >= LLViewerTexture::sMinLargeImageSize - if(w * h > LLViewerTexture::sMinLargeImageSize) - { - S32 d_level = llmin(mRequestedDiscardLevel, (S32)mDesiredDiscardLevel) - mRawDiscardLevel; - - if(d_level > 0) - { - S32 i = 0; - while((d_level > 0) && ((w >> i) * (h >> i) > LLViewerTexture::sMinLargeImageSize)) - { - i++; - d_level--; - } - if(i > 0) - { - mRawDiscardLevel += i; - if(mRawDiscardLevel >= getDiscardLevel() && getDiscardLevel() > 0) - { - mNeedsCreateTexture = false; - destroyRawImage(); - return; - } - - { - //make a duplicate in case somebody else is using this raw image - mRawImage = mRawImage->scaled(w >> i, h >> i); - } - } - } - } - } -#endif scheduleCreateTexture(); } return; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8ea8fbf905..3bc76bbb67 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3776,19 +3776,21 @@ void LLViewerWindow::updateUI() void LLViewerWindow::updateLayout() { - LLTool* tool = LLToolMgr::getInstance()->getCurrentTool(); + LLToolMgr* tool_mgr = LLToolMgr::getInstance(); + LLTool* tool = tool_mgr->getCurrentTool(); + LLCachedControl<bool> freeze_time(gSavedSettings, "FreezeTime"); if (gFloaterTools != NULL && tool != NULL && tool != gToolNull && tool != LLToolCompInspect::getInstance() && tool != LLToolDragAndDrop::getInstance() - && !gSavedSettings.getBOOL("FreezeTime")) + && !freeze_time()) { // Suppress the toolbox view if our source tool was the pie tool, // and we've overridden to something else. bool suppress_toolbox = - (LLToolMgr::getInstance()->getBaseTool() == LLToolPie::getInstance()) && - (LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance()); + (tool_mgr->getBaseTool() == LLToolPie::getInstance()) && + (tool_mgr->getCurrentTool() != LLToolPie::getInstance()); LLMouseHandler *captor = gFocusMgr.getMouseCapture(); // With the null, inspect, or drag and drop tool, don't muck @@ -3798,7 +3800,7 @@ void LLViewerWindow::updateLayout() || (tool != LLToolPie::getInstance() // not default tool && tool != LLToolCompGun::getInstance() // not coming out of mouselook && !suppress_toolbox // not override in third person - && LLToolMgr::getInstance()->getCurrentToolset()->isShowFloaterTools() + && tool_mgr->getCurrentToolset()->isShowFloaterTools() && (!captor || dynamic_cast<LLView*>(captor) != NULL))) // not dragging { // Force floater tools to be visible (unless minimized) @@ -3888,7 +3890,9 @@ void LLViewerWindow::updateKeyboardFocus() LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus()); if (cur_focus) { - if (!cur_focus->isInVisibleChain() || !cur_focus->isInEnabledChain()) + bool is_in_visible_chain = cur_focus->isInVisibleChain(); + bool is_in_enabled_chain = cur_focus->isInEnabledChain(); + if (!is_in_visible_chain || !is_in_enabled_chain) { // don't release focus, just reassign so that if being given // to a sibling won't call onFocusLost on all the ancestors @@ -3899,11 +3903,19 @@ void LLViewerWindow::updateKeyboardFocus() bool new_focus_found = false; while(parent) { + if (!is_in_visible_chain) + { + is_in_visible_chain = parent->isInVisibleChain(); + } + if (!is_in_enabled_chain) + { + is_in_enabled_chain = parent->isInEnabledChain(); + } if (parent->isCtrl() && (parent->hasTabStop() || parent == focus_root) && !parent->getIsChrome() - && parent->isInVisibleChain() - && parent->isInEnabledChain()) + && is_in_visible_chain + && is_in_enabled_chain) { if (!parent->focusFirstItem()) { @@ -4245,15 +4257,15 @@ void LLViewerWindow::pickAsync( S32 x, bool pick_unselectable, bool pick_reflection_probes) { + static LLCachedControl<bool> select_invisible_objects(gSavedSettings, "SelectInvisibleObjects"); // "Show Debug Alpha" means no object actually transparent bool in_build_mode = LLFloaterReg::instanceVisible("build"); - if (LLDrawPoolAlpha::sShowDebugAlpha - || (in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects"))) + if (LLDrawPoolAlpha::sShowDebugAlpha || (in_build_mode && select_invisible_objects)) { pick_transparent = true; } - LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, false, pick_reflection_probes, pick_unselectable, true, callback); + LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, false, pick_reflection_probes, true, pick_unselectable, callback); schedulePick(pick_info); } @@ -4277,7 +4289,6 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) mWindow->delayInputProcessing(); } - void LLViewerWindow::performPick() { if (!mPicks.empty()) @@ -4311,8 +4322,9 @@ void LLViewerWindow::returnEmptyPicks() // Performs the GL object/land pick. LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, bool pick_transparent, bool pick_rigged, bool pick_particle, bool pick_unselectable, bool pick_reflection_probe) { + static LLCachedControl<bool> select_invisible_objects(gSavedSettings, "SelectInvisibleObjects"); bool in_build_mode = LLFloaterReg::instanceVisible("build"); - if ((in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects")) || LLDrawPoolAlpha::sShowDebugAlpha) + if ((in_build_mode && select_invisible_objects) || LLDrawPoolAlpha::sShowDebugAlpha) { // build mode allows interaction with all transparent objects // "Show Debug Alpha" means no object actually transparent @@ -4320,7 +4332,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, bool pick_transp } // shortcut queueing in mPicks and just update mLastPick in place - MASK key_mask = gKeyboard->currentMask(true); + MASK key_mask = gKeyboard->currentMask(true); mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), key_mask, pick_transparent, pick_rigged, pick_particle, pick_reflection_probe, true, false, NULL); mLastPick.fetchResults(); @@ -5358,8 +5370,8 @@ bool LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea LLViewerCamera* camera = LLViewerCamera::getInstance(); LLViewerCamera saved_camera = LLViewerCamera::instance(); - glh::matrix4f saved_proj = get_current_projection(); - glh::matrix4f saved_mod = get_current_modelview(); + glm::mat4 saved_proj = get_current_projection(); + glm::mat4 saved_mod = get_current_modelview(); // camera constants for the square, cube map capture image camera->setAspect(1.0); // must set aspect ratio first to avoid undesirable clamping of vertical FoV @@ -6040,14 +6052,14 @@ LLPickInfo::LLPickInfo(const LLCoordGL& mouse_pos, bool pick_rigged, bool pick_particle, bool pick_reflection_probe, - bool pick_uv_coords, + bool pick_surface_info, bool pick_unselectable, void (*pick_callback)(const LLPickInfo& pick_info)) : mMousePt(mouse_pos), mKeyMask(keyboard_mask), mPickCallback(pick_callback), mPickType(PICK_INVALID), - mWantSurfaceInfo(pick_uv_coords), + mWantSurfaceInfo(pick_surface_info), mObjectFace(-1), mUVCoords(-1.f, -1.f), mSTCoords(-1.f, -1.f), diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e638e5b8c3..7bc9d06f9a 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -616,7 +616,6 @@ bool LLVOAvatar::sVisibleInFirstPerson = false; F32 LLVOAvatar::sLODFactor = 1.f; F32 LLVOAvatar::sPhysicsLODFactor = 1.f; bool LLVOAvatar::sJointDebug = false; -bool LLVOAvatar::sLipSyncEnabled = false; F32 LLVOAvatar::sUnbakedTime = 0.f; F32 LLVOAvatar::sUnbakedUpdateTime = 0.f; F32 LLVOAvatar::sGreyTime = 0.f; @@ -1177,7 +1176,6 @@ void LLVOAvatar::initClass() LLControlAvatar::sRegionChangedSlot = gAgent.addRegionChangedCallback(&LLControlAvatar::onRegionChanged); sCloudTexture = LLViewerTextureManager::getFetchedTextureFromFile("cloud-particle.j2c"); - gSavedSettings.getControl("LipSyncEnabled")->getSignal()->connect(boost::bind(&LLVOAvatar::handleVOAvatarPrefsChanged, _2)); } @@ -1185,12 +1183,6 @@ void LLVOAvatar::cleanupClass() { } -bool LLVOAvatar::handleVOAvatarPrefsChanged(const LLSD &newvalue) -{ - sLipSyncEnabled = gSavedSettings.getBOOL("LipSyncEnabled"); - return true; -} - // virtual void LLVOAvatar::initInstance() { @@ -1554,7 +1546,8 @@ void LLVOAvatar::calculateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) size.setSub(newMax,newMin); size.mul(0.5f); - mPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance()); + F32 pixel_area = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance()); + setCorrectedPixelArea(pixel_area); } void render_sphere_and_line(const LLVector3& begin_pos, const LLVector3& end_pos, F32 sphere_scale, const LLVector3& occ_color, const LLVector3& visible_color) @@ -1653,6 +1646,9 @@ void LLVOAvatar::renderCollisionVolumes() } } +// defined in llspatialpartition.cpp -- draw a box outline in the current GL context from given center and half-size +void drawBoxOutline(const LLVector4a& pos, const LLVector4a& size); + void LLVOAvatar::renderBones(const std::string &selected_joint) { LLGLEnable blend(GL_BLEND); @@ -1729,6 +1725,88 @@ void LLVOAvatar::renderBones(const std::string &selected_joint) gGL.popMatrix(); } + + + // draw joint space bounding boxes of rigged attachments in yellow + gGL.color3f(1.f, 1.f, 0.f); + for (S32 joint_num = 0; joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS; joint_num++) + { + LLJoint* joint = getJoint(joint_num); + LLJointRiggingInfo* rig_info = NULL; + if (joint_num < mJointRiggingInfoTab.size()) + { + rig_info = &mJointRiggingInfoTab[joint_num]; + } + + if (joint && rig_info && rig_info->isRiggedTo()) + { + LLViewerJointAttachment* as_joint_attach = dynamic_cast<LLViewerJointAttachment*>(joint); + if (as_joint_attach && as_joint_attach->getIsHUDAttachment()) + { + // Ignore bounding box of HUD joints + continue; + } + gGL.pushMatrix(); + gGL.multMatrix(&joint->getXform()->getWorldMatrix().mMatrix[0][0]); + + LLVector4a pos; + LLVector4a size; + + const LLVector4a* extents = rig_info->getRiggedExtents(); + + pos.setAdd(extents[0], extents[1]); + pos.mul(0.5f); + size.setSub(extents[1], extents[0]); + size.mul(0.5f); + + drawBoxOutline(pos, size); + + gGL.popMatrix(); + } + } + + // draw world space attachment rigged bounding boxes in cyan + gGL.color3f(0.f, 1.f, 1.f); + for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); + iter != mAttachmentPoints.end(); + ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + + if (attachment->getValid()) + { + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && !attached_object->isHUDAttachment()) + { + LLDrawable* drawable = attached_object->mDrawable; + if (drawable && drawable->isState(LLDrawable::RIGGED | LLDrawable::RIGGED_CHILD)) + { + // get face rigged extents + for (S32 i = 0; i < drawable->getNumFaces(); ++i) + { + LLFace* facep = drawable->getFace(i); + if (facep && facep->isState(LLFace::RIGGED)) + { + LLVector4a center, size; + + LLVector4a* extents = facep->mRiggedExtents; + + center.setAdd(extents[0], extents[1]); + center.mul(0.5f); + size.setSub(extents[1], extents[0]); + size.mul(0.5f); + drawBoxOutline(center, size); + } + } + } + } + } + } + } } @@ -1846,36 +1924,36 @@ bool LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& { mCollisionVolumes[i].updateWorldMatrix(); - glh::matrix4f mat((F32*) mCollisionVolumes[i].getXform()->getWorldMatrix().mMatrix); - glh::matrix4f inverse = mat.inverse(); - glh::matrix4f norm_mat = inverse.transpose(); + glm::mat4 mat(glm::make_mat4((F32*) mCollisionVolumes[i].getXform()->getWorldMatrix().mMatrix)); + glm::mat4 inverse = glm::inverse(mat); + glm::mat4 norm_mat = glm::transpose(inverse); - glh::vec3f p1(start.getF32ptr()); - glh::vec3f p2(end.getF32ptr()); + glm::vec3 p1(glm::make_vec3(start.getF32ptr())); + glm::vec3 p2(glm::make_vec3(end.getF32ptr())); - inverse.mult_matrix_vec(p1); - inverse.mult_matrix_vec(p2); + p1 = mul_mat4_vec3(inverse, p1); + p2 = mul_mat4_vec3(inverse, p2); LLVector3 position; LLVector3 norm; - if (linesegment_sphere(LLVector3(p1.v), LLVector3(p2.v), LLVector3(0,0,0), 1.f, position, norm)) + if (linesegment_sphere(LLVector3(glm::value_ptr(p1)), LLVector3(glm::value_ptr(p2)), LLVector3(0,0,0), 1.f, position, norm)) { - glh::vec3f res_pos(position.mV); - mat.mult_matrix_vec(res_pos); + glm::vec3 res_pos(glm::make_vec3(position.mV)); + res_pos = mul_mat4_vec3(mat, res_pos); - norm.normalize(); - glh::vec3f res_norm(norm.mV); - norm_mat.mult_matrix_dir(res_norm); + glm::vec3 res_norm(glm::make_vec3(norm.mV)); + res_norm = glm::normalize(res_norm); + res_norm = glm::mat3(norm_mat) * res_norm; if (intersection) { - intersection->load3(res_pos.v); + intersection->load3(glm::value_ptr(res_pos)); } if (normal) { - normal->load3(res_norm.v); + normal->load3(glm::value_ptr(res_norm)); } return true; @@ -2328,8 +2406,6 @@ void LLVOAvatar::updateMeshData() { if (mDrawable.notNull()) { - stop_glerror(); - S32 f_num = 0 ; const U32 VERTEX_NUMBER_THRESHOLD = 128 ;//small number of this means each part of an avatar has its own vertex buffer. const auto num_parts = mMeshLOD.size(); @@ -2456,7 +2532,6 @@ void LLVOAvatar::updateMeshData() } } - stop_glerror(); buff->unmapBuffer(); if(!f_num) @@ -2880,7 +2955,7 @@ static void override_bbox(LLDrawable* drawable, LLVector4a* extents) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; drawable->setSpatialExtents(extents[0], extents[1]); - drawable->setPositionGroup(LLVector4a(0, 0, 0)); + drawable->setPositionGroup(LLVector4a(0.f, 0.f, 0.f)); drawable->movePartition(); } @@ -2901,19 +2976,12 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update) if (detailed_update) { U32 draw_order = 0; - S32 attachment_selected = LLSelectMgr::getInstance()->getSelection()->getObjectCount() && LLSelectMgr::getInstance()->getSelection()->isAttachment(); - for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); - iter != mAttachmentPoints.end(); - ++iter) + bool attachment_selected = LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 0 && LLSelectMgr::getInstance()->getSelection()->isAttachment(); + for (const auto& [attachment_point_id, attachment] : mAttachmentPoints) { - LLViewerJointAttachment* attachment = iter->second; - - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) + for (auto& attached_object : attachment->mAttachedObjects) { - LLViewerObject* attached_object = attachment_iter->get(); - if (!attached_object + if (attached_object.isNull() || attached_object->isDead() || !attachment->getValid() || attached_object->mDrawable.isNull()) @@ -3118,7 +3186,7 @@ void LLVOAvatar::idleUpdateLipSync(bool voice_enabled) // Use the Lipsync_Ooh and Lipsync_Aah morphs for lip sync if ( voice_enabled && mLastRezzedStatus > 0 // no point updating lip-sync for clouds - && sLipSyncEnabled + && LLVoiceVisualizer::getLipSyncEnabled() && LLVoiceClient::getInstance()->getIsSpeaking( mID ) ) { F32 ooh_morph_amount = 0.0f; @@ -3695,21 +3763,22 @@ LLVector3 LLVOAvatar::idleCalcNameTagPosition(const LLVector3 &root_pos_last) name_position += (local_camera_up * root_rot) - (projected_vec(local_camera_at * root_rot, camera_to_av)); name_position += pixel_up_vec * NAMETAG_VERTICAL_SCREEN_OFFSET; - const F32 water_height = getRegion()->getWaterHeight(); - static const F32 WATER_HEIGHT_DELTA = 0.25f; - if (name_position[VZ] < water_height + WATER_HEIGHT_DELTA) + // Avoid of crossing the name tag by the water surface + if (mNameText) { - if (LLViewerCamera::getInstance()->getOrigin()[VZ] >= water_height) + F32 water_height = getRegion()->getWaterHeight(); + static const F32 WATER_HEIGHT_ABOVE_DELTA = 0.25; + if (name_position[VZ] < water_height + WATER_HEIGHT_ABOVE_DELTA) { - name_position[VZ] = water_height; - } - else if (mNameText) // both camera and HUD are below watermark - { - F32 name_world_height = mNameText->getWorldHeight(); - F32 max_z_position = water_height - name_world_height; - if (name_position[VZ] > max_z_position) + F32 camera_height = LLViewerCamera::getInstance()->getOrigin()[VZ]; + if (camera_height >= water_height) { - name_position[VZ] = max_z_position; + F32 name_world_height = mNameText->getWorldHeight(); + static const F32 WATER_HEIGHT_BELOW_DELTA = 0.5; + if (name_position[VZ] + name_world_height > water_height - WATER_HEIGHT_BELOW_DELTA) + { + name_position[VZ] = water_height + WATER_HEIGHT_ABOVE_DELTA; + } } } } @@ -4935,27 +5004,22 @@ void LLVOAvatar::updateVisibility() { visible = true; } - else - { - visible = false; - } - if(isSelf()) + if (isSelf()) { if (!gAgentWearables.areWearablesLoaded()) { visible = false; } } - else if( !mFirstAppearanceMessageReceived ) + else if (!mFirstAppearanceMessageReceived) { visible = false; } if (sDebugInvisible) { - LLNameValue* firstname = getNVPair("FirstName"); - if (firstname) + if (LLNameValue* firstname = getNVPair("FirstName")) { LL_DEBUGS("Avatar") << avString() << " updating visibility" << LL_ENDL; } @@ -5044,11 +5108,14 @@ void LLVOAvatar::updateVisibility() } } - if ( visible != mVisible ) + if (visible != mVisible) { LL_DEBUGS("AvatarRender") << "visible was " << mVisible << " now " << visible << LL_ENDL; } + mVisible = visible; + + mVisibilityPreference = visible ? getPixelArea() : 0; } // private @@ -5357,14 +5424,6 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel) gGL.setSceneBlendType(LLRender::BT_ADD); gGL.getTexUnit(diffuse_channel)->unbind(LLTexUnit::TT_TEXTURE); - // gGL.begin(LLRender::QUADS); - // gGL.vertex3fv((pos+left-up).mV); - // gGL.vertex3fv((pos-left-up).mV); - // gGL.vertex3fv((pos-left+up).mV); - // gGL.vertex3fv((pos+left+up).mV); - // gGL.end(); - - gGL.begin(LLRender::LINES); gGL.color4f(1.f,1.f,1.f,1.f); F32 thickness = llmax(F32(5.0f-5.0f*(gFrameTimeSeconds-mLastImpostorUpdateFrameTime)),1.0f); @@ -5385,15 +5444,22 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel) gGL.color4ubv(color.mV); gGL.getTexUnit(diffuse_channel)->bind(&mImpostor); - gGL.begin(LLRender::QUADS); - gGL.texCoord2f(0,0); - gGL.vertex3fv((pos+left-up).mV); - gGL.texCoord2f(1,0); - gGL.vertex3fv((pos-left-up).mV); - gGL.texCoord2f(1,1); - gGL.vertex3fv((pos-left+up).mV); - gGL.texCoord2f(0,1); - gGL.vertex3fv((pos+left+up).mV); + gGL.begin(LLRender::TRIANGLES); + { + gGL.texCoord2f(0.f, 0.f); + gGL.vertex3fv((pos + left - up).mV); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3fv((pos - left - up).mV); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex3fv((pos - left + up).mV); + + gGL.texCoord2f(0.f, 0.f); + gGL.vertex3fv((pos + left - up).mV); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex3fv((pos - left + up).mV); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3fv((pos + left + up).mV); + } gGL.end(); gGL.flush(); } @@ -7110,6 +7176,18 @@ void LLVOAvatar::updateVisualParams() dirtyMesh(); updateHeadOffset(); } + +void LLVOAvatar::setCorrectedPixelArea(F32 area) +{ + // We always want to look good to ourselves + if (isSelf()) + { + area = llmax(area, F32(getTexImageSize() / 16)); + } + + setPixelArea(area); +} + //----------------------------------------------------------------------------- // isActive() //----------------------------------------------------------------------------- @@ -7137,7 +7215,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) size.mul(0.5f); mImpostorPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance()); - mPixelArea = mImpostorPixelArea; + setCorrectedPixelArea(mImpostorPixelArea); F32 range = mDrawable->mDistanceWRTCamera; @@ -7150,12 +7228,6 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) F32 radius = size.getLength3().getF32(); mAppAngle = (F32) atan2( radius, range) * RAD_TO_DEG; } - - // We always want to look good to ourselves - if( isSelf() ) - { - mPixelArea = llmax( mPixelArea, F32(getTexImageSize() / 16) ); - } } //----------------------------------------------------------------------------- @@ -8444,14 +8516,14 @@ bool LLVOAvatar::isFullyLoaded() const bool LLVOAvatar::isTooComplex() const { bool too_complex; - static LLCachedControl<S32> compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); - bool render_friend = (isBuddy() && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY); + static LLCachedControl<S32> complexity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); + bool render_friend = (isBuddy() && complexity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY); if (isSelf() || render_friend || mVisuallyMuteSetting == AV_ALWAYS_RENDER) { too_complex = false; } - else if (compelxity_render_mode == AV_RENDER_ONLY_SHOW_FRIENDS && !mIsControlAvatar) + else if (complexity_render_mode == AV_RENDER_ONLY_SHOW_FRIENDS && !mIsControlAvatar) { too_complex = true; } @@ -8479,16 +8551,16 @@ bool LLVOAvatar::isTooSlow() const return mTooSlow; } - static LLCachedControl<S32> compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); + static LLCachedControl<S32> complexity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); static LLCachedControl<bool> friends_only(gSavedSettings, "RenderAvatarFriendsOnly", false); bool is_friend = isBuddy(); - bool render_friend = is_friend && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; + bool render_friend = is_friend && complexity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; if (render_friend || mVisuallyMuteSetting == AV_ALWAYS_RENDER) { return false; } - else if (compelxity_render_mode == AV_RENDER_ONLY_SHOW_FRIENDS) + else if (complexity_render_mode == AV_RENDER_ONLY_SHOW_FRIENDS) { return true; } @@ -8504,7 +8576,7 @@ bool LLVOAvatar::isTooSlow() const void LLVOAvatar::updateTooSlow() { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; - static LLCachedControl<S32> compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); + static LLCachedControl<S32> complexity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); static LLCachedControl<bool> allowSelfImpostor(gSavedSettings, "AllowSelfImpostor"); const auto id = getID(); @@ -8537,14 +8609,14 @@ void LLVOAvatar::updateTooSlow() if(!mTooSlowWithoutShadows) // if we were not previously above the full impostor cap { - bool always_render_friends = compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; + bool always_render_friends = complexity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; bool render_friend_or_exception = (always_render_friends && isBuddy()) || ( getVisualMuteSettings() == LLVOAvatar::AV_ALWAYS_RENDER ); if( (!isSelf() || allowSelfImpostor) && !render_friend_or_exception) { // Note: slow rendering Friends still get their shadows zapped. mTooSlowWithoutShadows = (getGPURenderTime()*2.f >= max_art_ms) // NOTE: assumes shadow rendering doubles render time - || (compelxity_render_mode == AV_RENDER_ONLY_SHOW_FRIENDS && !mIsControlAvatar); + || (complexity_render_mode == AV_RENDER_ONLY_SHOW_FRIENDS && !mIsControlAvatar); } } } @@ -8610,60 +8682,53 @@ void LLVOAvatar::updateMeshVisibility() if (getOverallAppearance() == AOA_NORMAL) { - for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); - iter != mAttachmentPoints.end(); - ++iter) + for (const auto& [attachment_point_id, attachment] : mAttachmentPoints) { - LLViewerJointAttachment* attachment = iter->second; - if (attachment) + if (!attachment) + continue; + + for (const auto& objectp : attachment->mAttachedObjects) { - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) + if (objectp.isNull()) + continue; + + for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++) { - LLViewerObject *objectp = attachment_iter->get(); - if (objectp) - { - for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++) - { - LLTextureEntry* tex_entry = objectp->getTE(face_index); - bake_flag[BAKED_HEAD] |= (tex_entry->getID() == IMG_USE_BAKED_HEAD); - bake_flag[BAKED_EYES] |= (tex_entry->getID() == IMG_USE_BAKED_EYES); - bake_flag[BAKED_HAIR] |= (tex_entry->getID() == IMG_USE_BAKED_HAIR); - bake_flag[BAKED_LOWER] |= (tex_entry->getID() == IMG_USE_BAKED_LOWER); - bake_flag[BAKED_UPPER] |= (tex_entry->getID() == IMG_USE_BAKED_UPPER); - bake_flag[BAKED_SKIRT] |= (tex_entry->getID() == IMG_USE_BAKED_SKIRT); - bake_flag[BAKED_LEFT_ARM] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTARM); - bake_flag[BAKED_LEFT_LEG] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTLEG); - bake_flag[BAKED_AUX1] |= (tex_entry->getID() == IMG_USE_BAKED_AUX1); - bake_flag[BAKED_AUX2] |= (tex_entry->getID() == IMG_USE_BAKED_AUX2); - bake_flag[BAKED_AUX3] |= (tex_entry->getID() == IMG_USE_BAKED_AUX3); - } - } + LLTextureEntry* tex_entry = objectp->getTE(face_index); + const auto& tex_id = tex_entry->getID(); + bake_flag[BAKED_HEAD] |= (tex_id == IMG_USE_BAKED_HEAD); + bake_flag[BAKED_EYES] |= (tex_id == IMG_USE_BAKED_EYES); + bake_flag[BAKED_HAIR] |= (tex_id == IMG_USE_BAKED_HAIR); + bake_flag[BAKED_LOWER] |= (tex_id == IMG_USE_BAKED_LOWER); + bake_flag[BAKED_UPPER] |= (tex_id == IMG_USE_BAKED_UPPER); + bake_flag[BAKED_SKIRT] |= (tex_id == IMG_USE_BAKED_SKIRT); + bake_flag[BAKED_LEFT_ARM] |= (tex_id == IMG_USE_BAKED_LEFTARM); + bake_flag[BAKED_LEFT_LEG] |= (tex_id == IMG_USE_BAKED_LEFTLEG); + bake_flag[BAKED_AUX1] |= (tex_id == IMG_USE_BAKED_AUX1); + bake_flag[BAKED_AUX2] |= (tex_id == IMG_USE_BAKED_AUX2); + bake_flag[BAKED_AUX3] |= (tex_id == IMG_USE_BAKED_AUX3); + } - LLViewerObject::const_child_list_t& child_list = objectp->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter1 = child_list.begin(); - iter1 != child_list.end(); ++iter1) + for (const auto& objectchild : objectp->getChildren()) + { + if (objectchild.isNull()) + continue; + + for (int face_index = 0; face_index < objectchild->getNumTEs(); face_index++) { - LLViewerObject* objectchild = *iter1; - if (objectchild) - { - for (int face_index = 0; face_index < objectchild->getNumTEs(); face_index++) - { - LLTextureEntry* tex_entry = objectchild->getTE(face_index); - bake_flag[BAKED_HEAD] |= (tex_entry->getID() == IMG_USE_BAKED_HEAD); - bake_flag[BAKED_EYES] |= (tex_entry->getID() == IMG_USE_BAKED_EYES); - bake_flag[BAKED_HAIR] |= (tex_entry->getID() == IMG_USE_BAKED_HAIR); - bake_flag[BAKED_LOWER] |= (tex_entry->getID() == IMG_USE_BAKED_LOWER); - bake_flag[BAKED_UPPER] |= (tex_entry->getID() == IMG_USE_BAKED_UPPER); - bake_flag[BAKED_SKIRT] |= (tex_entry->getID() == IMG_USE_BAKED_SKIRT); - bake_flag[BAKED_LEFT_ARM] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTARM); - bake_flag[BAKED_LEFT_LEG] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTLEG); - bake_flag[BAKED_AUX1] |= (tex_entry->getID() == IMG_USE_BAKED_AUX1); - bake_flag[BAKED_AUX2] |= (tex_entry->getID() == IMG_USE_BAKED_AUX2); - bake_flag[BAKED_AUX3] |= (tex_entry->getID() == IMG_USE_BAKED_AUX3); - } - } + LLTextureEntry* tex_entry = objectchild->getTE(face_index); + const auto& tex_id = tex_entry->getID(); + bake_flag[BAKED_HEAD] |= (tex_id == IMG_USE_BAKED_HEAD); + bake_flag[BAKED_EYES] |= (tex_id == IMG_USE_BAKED_EYES); + bake_flag[BAKED_HAIR] |= (tex_id == IMG_USE_BAKED_HAIR); + bake_flag[BAKED_LOWER] |= (tex_id == IMG_USE_BAKED_LOWER); + bake_flag[BAKED_UPPER] |= (tex_id == IMG_USE_BAKED_UPPER); + bake_flag[BAKED_SKIRT] |= (tex_id == IMG_USE_BAKED_SKIRT); + bake_flag[BAKED_LEFT_ARM] |= (tex_id == IMG_USE_BAKED_LEFTARM); + bake_flag[BAKED_LEFT_LEG] |= (tex_id == IMG_USE_BAKED_LEFTLEG); + bake_flag[BAKED_AUX1] |= (tex_id == IMG_USE_BAKED_AUX1); + bake_flag[BAKED_AUX2] |= (tex_id == IMG_USE_BAKED_AUX2); + bake_flag[BAKED_AUX3] |= (tex_id == IMG_USE_BAKED_AUX3); } } } @@ -9787,7 +9852,7 @@ void LLVOAvatar::applyParsedAppearanceMessage(LLAppearanceMessageContents& conte setCompositeUpdatesEnabled( true ); // If all of the avatars are completely baked, release the global image caches to conserve memory. - LLVOAvatar::cullAvatarsByPixelArea(); + cullAvatarsByPixelArea(); if (isSelf()) { @@ -10419,12 +10484,10 @@ void LLVOAvatar::dumpArchetypeXML(const std::string& prefix, bool group_by_weara void LLVOAvatar::setVisibilityRank(U32 rank) { - if (mDrawable.isNull() || mDrawable->isDead()) + if (mDrawable.notNull() && !mDrawable->isDead()) { - // do nothing - return; + mVisibilityRank = rank; } - mVisibilityRank = rank; } // Assumes LLVOAvatar::sInstances has already been sorted. @@ -10455,32 +10518,34 @@ void LLVOAvatar::cullAvatarsByPixelArea() { LLCharacter::sInstances.sort([](LLCharacter* lhs, LLCharacter* rhs) { - return lhs->getPixelArea() > rhs->getPixelArea(); + return ((LLVOAvatar*)lhs)->mVisibilityPreference > ((LLVOAvatar*)rhs)->mVisibilityPreference; }); // Update the avatars that have changed status + U32 rank = 2; // Rank 1 is reserved for self. + for (LLCharacter* character : LLCharacter::sInstances) { - U32 rank = 2; //1 is reserved for self. - for (LLCharacter* character : LLCharacter::sInstances) - { - LLVOAvatar* inst = (LLVOAvatar*)character; - bool culled = !inst->isSelf() && !inst->isFullyBaked(); + LLVOAvatar* inst = (LLVOAvatar*)character; + bool culled = !inst->isSelf() && !inst->isFullyBaked(); - if (inst->mCulled != culled) - { - inst->mCulled = culled; - LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL; - inst->updateMeshTextures(); - } + if (inst->mCulled != culled) + { + inst->mCulled = culled; + LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL; + inst->updateMeshTextures(); + } - if (inst->isSelf()) - { - inst->setVisibilityRank(1); - } - else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) - { - inst->setVisibilityRank(rank++); - } + if (inst->isSelf()) + { + inst->setVisibilityRank(1); + } + else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) + { + inst->setVisibilityRank(rank++); + } + else + { + inst->setVisibilityRank(sMaxNonImpostors * 5); } } @@ -10678,31 +10743,39 @@ void LLVOAvatar::updateRiggingInfo() LL_DEBUGS("RigSpammish") << getFullname() << " updating rig tab" << LL_ENDL; - std::vector<LLVOVolume*> volumes; + // use a local static for scratch space to avoid reallocation here + static std::vector<LLVOVolume*> volumes; + volumes.resize(0); getAssociatedVolumes(volumes); - std::map<LLUUID, S32> curr_rigging_info_key; - - // Get current rigging info key - for (LLVOVolume* vol : volumes) { - if (vol->isMesh() && vol->getVolume()) + LL_PROFILE_ZONE_NAMED_CATEGORY_AVATAR("update rig info - get key"); + size_t hash = 0; + // Get current rigging info key + for (LLVOVolume* vol : volumes) + { + if (vol->isRiggedMesh()) + { + const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); + S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); + + boost::hash_combine(hash, mesh_id); + boost::hash_combine(hash, max_lod); + } + } + + // Check for key change, which indicates some change in volume composition or LOD. + if (hash == mLastRiggingInfoKey) { - const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); - S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); - curr_rigging_info_key[mesh_id] = max_lod; + return; } - } - // Check for key change, which indicates some change in volume composition or LOD. - if (curr_rigging_info_key == mLastRiggingInfoKey) - { - return; + + // Something changed. Update. + mLastRiggingInfoKey = hash; } - // Something changed. Update. - mLastRiggingInfoKey = curr_rigging_info_key; mJointRiggingInfoTab.clear(); for (LLVOVolume* vol : volumes) { diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index aa6aee0de5..dd1725c322 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -109,7 +109,6 @@ public: virtual void initInstance(); // Called after construction to initialize the class. protected: virtual ~LLVOAvatar(); - static bool handleVOAvatarPrefsChanged(const LLSD &newvalue); /** Initialization ** ** @@ -127,17 +126,18 @@ public: /*virtual*/ void updateGL(); /*virtual*/ LLVOAvatar* asAvatar(); - virtual U32 processUpdateMessage(LLMessageSystem *mesgsys, + virtual U32 processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, const EObjectUpdateType update_type, LLDataPacker *dp); - virtual void idleUpdate(LLAgent &agent, const F64 &time); + virtual void idleUpdate(LLAgent &agent, const F64 &time); /*virtual*/ bool updateLOD(); - bool updateJointLODs(); - void updateLODRiggedAttachments( void ); + bool updateJointLODs(); + void updateLODRiggedAttachments(void); + void setCorrectedPixelArea(F32 area); /*virtual*/ bool isActive() const; // Whether this object needs to do an idleUpdate. - S32Bytes totalTextureMemForUUIDS(std::set<LLUUID>& ids); + S32Bytes totalTextureMemForUUIDS(std::set<LLUUID>& ids); bool allTexturesCompletelyDownloaded(std::set<LLUUID>& ids) const; bool allLocalTexturesCompletelyDownloaded() const; bool allBakedTexturesCompletelyDownloaded() const; @@ -226,7 +226,7 @@ public: // virtual void updateRiggingInfo(); // This encodes mesh id and LOD, so we can see whether display is up-to-date. - std::map<LLUUID,S32> mLastRiggingInfoKey; + size_t mLastRiggingInfoKey; std::set<LLUUID> mActiveOverrideMeshes; virtual void onActiveOverrideMeshesChanged(); @@ -368,7 +368,6 @@ public: static F32 sLODFactor; // user-settable LOD factor static F32 sPhysicsLODFactor; // user-settable physics LOD factor static bool sJointDebug; // output total number of joints being touched for each avatar - static bool sLipSyncEnabled; static LLPointer<LLViewerTexture> sCloudTexture; @@ -620,6 +619,7 @@ public: protected: void updateVisibility(); private: + F32 mVisibilityPreference; U32 mVisibilityRank; bool mVisible; diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 6903af2619..fdd39a0e30 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -596,7 +596,7 @@ U32 LLVOGrass::getPartitionType() const } LLGrassPartition::LLGrassPartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, true, regionp) +: LLSpatialPartition(static_cast<U32>(LLDrawPoolAlpha::VERTEX_DATA_MASK) | static_cast<U32>(LLVertexBuffer::MAP_TEXTURE_INDEX), true, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_GRASS; mPartitionType = LLViewerRegion::PARTITION_GRASS; @@ -729,7 +729,6 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group) } } - buffer->unmapBuffer(); mFaceList.clear(); } diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 5af7528ada..1a35a71706 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -256,8 +256,8 @@ void LLVoiceClient::setSpatialVoiceModule(const std::string &voice_server_type) if (inProximalChannel()) { mSpatialVoiceModule->processChannels(false); + module->processChannels(true); } - module->processChannels(true); mSpatialVoiceModule = module; mSpatialVoiceModule->updateSettings(); } diff --git a/indra/newview/llvoicevisualizer.cpp b/indra/newview/llvoicevisualizer.cpp index 9412136272..7691ac54f3 100644 --- a/indra/newview/llvoicevisualizer.cpp +++ b/indra/newview/llvoicevisualizer.cpp @@ -337,7 +337,8 @@ void LLVoiceVisualizer::lipSyncOohAah( F32& ooh, F32& aah ) //--------------------------------------------------- void LLVoiceVisualizer::render() { - if ( ! mVoiceEnabled ) + static LLCachedControl<bool> show_visualizer(gSavedSettings, "VoiceVisualizerEnabled", false); + if (!mVoiceEnabled || !show_visualizer) { return; } diff --git a/indra/newview/llvoicevisualizer.h b/indra/newview/llvoicevisualizer.h index a44f60bd16..b788691a4f 100644 --- a/indra/newview/llvoicevisualizer.h +++ b/indra/newview/llvoicevisualizer.h @@ -100,6 +100,8 @@ class LLVoiceVisualizer : public LLHUDEffect void setMaxGesticulationAmplitude(); void setMinGesticulationAmplitude(); + static bool getLipSyncEnabled() { return sLipSyncEnabled; } + //--------------------------------------------------- // private members //--------------------------------------------------- @@ -135,7 +137,7 @@ class LLVoiceVisualizer : public LLHUDEffect // private static members //--------------------------------------------------- - static bool sLipSyncEnabled; // 0 disabled, 1 babble loop + static bool sLipSyncEnabled; // false: disabled, true: babble loop static bool sPrefsInitialized; // the first instance will initialize the static members static F32* sOoh; // the babble loop of amplitudes for the ooh morph static F32* sAah; // the babble loop of amplitudes for the ooh morph diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index f3b624e968..4659fa5f71 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -5012,8 +5012,7 @@ bool LLVivoxVoiceClient::isVoiceWorking() const //Added stateSessionTerminated state to avoid problems with call in parcels with disabled voice (EXT-4758) // Condition with joining spatial num was added to take into account possible problems with connection to voice // server(EXT-4313). See bug descriptions and comments for MAX_NORMAL_JOINING_SPATIAL_NUM for more info. - return (mSpatialJoiningNum < MAX_NORMAL_JOINING_SPATIAL_NUM) && mIsProcessingChannels; -// return (mSpatialJoiningNum < MAX_NORMAL_JOINING_SPATIAL_NUM) && (stateLoggedIn <= mState) && (mState <= stateSessionTerminated); + return (mSpatialJoiningNum < MAX_NORMAL_JOINING_SPATIAL_NUM) && mIsLoggedIn; } // Returns true if the indicated participant in the current audio session is really an SL avatar. diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index fdb7b3c3b9..32803c6117 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -87,6 +87,8 @@ namespace { const F32 SPEAKING_AUDIO_LEVEL = 0.30; + const uint32_t PEER_GAIN_CONVERSION_FACTOR = 220; + static const std::string REPORTED_VOICE_SERVER_TYPE = "Secondlife WebRTC Gateway"; // Don't send positional updates more frequently than this: @@ -420,7 +422,7 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt status != LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL && status != LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED) { - bool voice_status = LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking(); + bool voice_status = LLVoiceClient::getInstance()->voiceEnabled() && mIsProcessingChannels; gAgent.setVoiceConnected(voice_status); @@ -1335,7 +1337,10 @@ bool LLWebRTCVoiceClient::startAdHocSession(const LLSD& channelInfo, bool notify bool LLWebRTCVoiceClient::isVoiceWorking() const { - return mIsProcessingChannels; + // webrtc is working if the coroutine is active in the case of + // webrtc. WebRTC doesn't need to connect to a secondary process + // or a login server to become active. + return mIsCoroutineActive; } // Returns true if calling back the session URI after the session has closed is possible. @@ -2012,7 +2017,10 @@ bool LLWebRTCVoiceClient::estateSessionState::processConnectionStates() // shut down connections to neighbors that are too far away. spatialConnection.get()->shutDown(); } - neighbor_ids.erase(regionID); + if (!spatialConnection.get()->isShuttingDown()) + { + neighbor_ids.erase(regionID); + } } // add new connections for new neighbors @@ -2437,7 +2445,7 @@ void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume) void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) { - boost::json::object root = {{"ug", {id.asString(), (uint32_t) (volume * 200)}}}; + boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { @@ -2447,7 +2455,7 @@ void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) void LLVoiceWebRTCConnection::setUserMute(const LLUUID& id, bool mute) { - boost::json::object root = {{"m", {id.asString(), mute}}}; + boost::json::object root = { { "m", { { id.asString(), mute } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { @@ -2512,8 +2520,6 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio httpOpts->setWantHeaders(true); - connection->mOutstandingRequests++; - // tell the server to shut down the connection as a courtesy. // shutdownConnection will drop the WebRTC connection which will // also shut things down. @@ -2544,6 +2550,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() // try again. setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION); + mOutstandingRequests--; return; } @@ -2551,6 +2558,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() if (url.empty()) { setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); + mOutstandingRequests--; return; } @@ -2575,7 +2583,6 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); - mOutstandingRequests++; LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -2663,7 +2670,10 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; - processIceUpdates(); + if (!mShutDown) + { + processIceUpdates(); + } switch (getVoiceConnectionState()) { @@ -2707,6 +2717,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() // a given voice channel. On completion, we'll move on to the // VOICE_STATE_SESSION_ESTABLISHED via a callback on a webrtc thread. setVoiceConnectionState(VOICE_STATE_CONNECTION_WAIT); + mOutstandingRequests++; LLCoros::getInstance()->launch("LLVoiceWebRTCConnection::requestVoiceConnectionCoro", boost::bind(&LLVoiceWebRTCConnection::requestVoiceConnectionCoro, this->shared_from_this())); break; @@ -2775,6 +2786,18 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { setVoiceConnectionState(VOICE_STATE_DISCONNECT); } + else + { + if (isSpatial() && gAgent.getRegion()) + { + bool primary = (mRegionID == gAgent.getRegion()->getRegionID()); + if (primary != mPrimary) + { + mPrimary = primary; + sendJoin(); + } + } + } break; } @@ -2799,6 +2822,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() case VOICE_STATE_DISCONNECT: if (!LLWebRTCVoiceClient::isShuttingDown()) { + mOutstandingRequests++; setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT); LLCoros::instance().launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro", boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this->shared_from_this())); @@ -2807,7 +2831,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { // llwebrtc::terminate() is already shuting down the connection. setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE); - mOutstandingRequests++; } break; @@ -2976,7 +2999,9 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b // we got a 'power' update. if (participant_obj.contains("p") && participant_obj["p"].is_number()) { - participant->mLevel = (F32)participant_obj["p"].as_int64(); + // server sends up power as an integer which is level * 128 to save + // character count. + participant->mLevel = (F32)participant_obj["p"].as_int64()/128.0f; } if (participant_obj.contains("v") && participant_obj["v"].is_bool()) @@ -2984,10 +3009,9 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b participant->mIsSpeaking = participant_obj["v"].as_bool(); } - if (participant_obj.contains("v") && participant_obj["m"].is_bool()) + if (participant_obj.contains("m") && participant_obj["m"].is_bool()) { participant->mIsModeratorMuted = participant_obj["m"].as_bool(); - ; } } } @@ -3051,7 +3075,6 @@ void LLVoiceWebRTCConnection::sendJoin() boost::json::object root; boost::json::object join_obj; - LLUUID regionID = gAgent.getRegion()->getRegionID(); if (mPrimary) { join_obj["p"] = true; @@ -3134,6 +3157,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() LL_DEBUGS("Voice") << "no capabilities for voice provisioning; retrying " << LL_ENDL; // try again. setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION); + mOutstandingRequests--; return; } @@ -3141,6 +3165,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() if (url.empty()) { setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); + mOutstandingRequests--; return; } @@ -3164,7 +3189,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); - mOutstandingRequests++; + LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index 32127f9b17..ff82d2739d 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -631,6 +631,11 @@ class LLVoiceWebRTCConnection : mShutDown = true; } + bool isShuttingDown() + { + return mShutDown; + } + void OnVoiceConnectionRequestSuccess(const LLSD &body); protected: diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 81f16cf8cb..ec32a79829 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -54,63 +54,6 @@ void LLVOPartGroup::initClass() void LLVOPartGroup::restoreGL() { - //TODO: optimize out binormal mask here. Specular and normal coords as well. -#if 0 - sVB = new LLVertexBuffer(VERTEX_DATA_MASK | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2); - U32 count = LL_MAX_PARTICLE_COUNT; - if (!sVB->allocateBuffer(count*4, count*6)) - { - LL_WARNS() << "Failed to allocate Vertex Buffer to " - << count*4 << " vertices and " - << count * 6 << " indices" << LL_ENDL; - // we are likelly to crash at following getTexCoord0Strider(), so unref and return - sVB = NULL; - return; - } - - //indices and texcoords are always the same, set once - LLStrider<U16> indicesp; - - LLStrider<LLVector4a> verticesp; - - sVB->getIndexStrider(indicesp); - sVB->getVertexStrider(verticesp); - - LLVector4a v; - v.set(0,0,0,0); - - - U16 vert_offset = 0; - - for (U32 i = 0; i < LL_MAX_PARTICLE_COUNT; i++) - { - *indicesp++ = vert_offset + 0; - *indicesp++ = vert_offset + 1; - *indicesp++ = vert_offset + 2; - - *indicesp++ = vert_offset + 1; - *indicesp++ = vert_offset + 3; - *indicesp++ = vert_offset + 2; - - *verticesp++ = v; - - vert_offset += 4; - } - - LLStrider<LLVector2> texcoordsp; - sVB->getTexCoord0Strider(texcoordsp); - - for (U32 i = 0; i < LL_MAX_PARTICLE_COUNT; i++) - { - *texcoordsp++ = LLVector2(0.f, 1.f); - *texcoordsp++ = LLVector2(0.f, 0.f); - *texcoordsp++ = LLVector2(1.f, 1.f); - *texcoordsp++ = LLVector2(1.f, 0.f); - } - - sVB->unmapBuffer(); -#endif - } //static @@ -702,7 +645,7 @@ U32 LLVOPartGroup::getPartitionType() const } LLParticlePartition::LLParticlePartition(LLViewerRegion* regionp) -: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, true, regionp) +: LLSpatialPartition(static_cast<U32>(LLDrawPoolAlpha::VERTEX_DATA_MASK) | static_cast<U32>(LLVertexBuffer::MAP_TEXTURE_INDEX), true, regionp) { mRenderPass = LLRenderPass::PASS_ALPHA; mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; @@ -955,7 +898,6 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) } } - buffer->unmapBuffer(); mFaceList.clear(); } diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index fdccf34e6a..294d36b0a9 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -1078,7 +1078,6 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) gen_terrain_tangents(index_offset, indices_index, vertices, normals, tangents, indices, region_width); } - buffer->unmapBuffer(); mFaceList.clear(); } diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index d982592ee7..14b4273b02 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -1047,10 +1047,9 @@ void LLVOTree::genBranchPipeline(LLStrider<LLVector3>& vertices, scale_mat.mMatrix[2][2] = scale*length; scale_mat *= matrix; - glh::matrix4f norm((F32*) scale_mat.mMatrix); - LLMatrix4 norm_mat = LLMatrix4(norm.inverse().transpose().m); + glm::mat4 norm(glm::make_mat4((F32*) scale_mat.mMatrix)); + LLMatrix4 norm_mat = LLMatrix4(glm::value_ptr(glm::transpose(glm::inverse(norm)))); - norm_mat.invert(); appendMesh(vertices, normals, tex_coords, colors, indices, index_offset, scale_mat, norm_mat, sLODVertexOffset[trunk_LOD], sLODVertexCount[trunk_LOD], sLODIndexCount[trunk_LOD], sLODIndexOffset[trunk_LOD]); } @@ -1097,8 +1096,8 @@ void LLVOTree::genBranchPipeline(LLStrider<LLVector3>& vertices, scale_mat *= matrix; - glh::matrix4f norm((F32*) scale_mat.mMatrix); - LLMatrix4 norm_mat = LLMatrix4(norm.inverse().transpose().m); + glm::mat4 norm(glm::make_mat4((F32*)scale_mat.mMatrix)); + LLMatrix4 norm_mat = LLMatrix4(glm::value_ptr(glm::transpose(glm::inverse(norm)))); appendMesh(vertices, normals, tex_coords, colors, indices, index_offset, scale_mat, norm_mat, 0, LEAF_VERTICES, LEAF_INDICES, 0); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 28a7be6569..31f1bbcc21 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -250,10 +250,12 @@ LLVOVolume::~LLVOVolume() delete mVolumeImpl; mVolumeImpl = NULL; - gMeshRepo.unregisterMesh(this); + unregisterOldMeshAndSkin(); if(!mMediaImplList.empty()) { + LL_PROFILE_ZONE_NAMED_CATEGORY_MEDIA("delete volume media list"); + for(U32 i = 0 ; i < mMediaImplList.size() ; i++) { if(mMediaImplList[i].notNull()) @@ -998,6 +1000,28 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) return mDrawable; } +// Inverse of gMeshRepo.loadMesh and gMeshRepo.getSkinInfo, combined into one function +// Assume a Collada mesh never changes after being set. +void LLVOVolume::unregisterOldMeshAndSkin() +{ + if (mVolumep) + { + const LLVolumeParams& params = mVolumep->getParams(); + if ((params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH) + { + // object is being deleted, so it will no longer need to request + // meshes. + for (S32 lod = 0; lod != LLVolumeLODGroup::NUM_LODS; ++lod) + { + gMeshRepo.unregisterMesh(this, params, lod); + } + // This volume may or may not have a skin + gMeshRepo.unregisterSkinInfo(params.getSculptID(), this); + } + } +} + + bool LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bool unique_volume) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; @@ -3657,7 +3681,7 @@ const LLMeshSkinInfo* LLVOVolume::getSkinInfo() const // virtual bool LLVOVolume::isRiggedMesh() const { - return isMesh() && getSkinInfo(); + return getSkinInfo() != nullptr; } //---------------------------------------------------------------------------- @@ -3818,7 +3842,6 @@ void LLVOVolume::updateRiggingInfo() LLVolume *volume = getVolume(); if (skin && avatar && volume) { - LL_DEBUGS("RigSpammish") << "starting, vovol " << this << " lod " << getLOD() << " last " << mLastRiggingInfoLOD << LL_ENDL; if (getLOD()>mLastRiggingInfoLOD || getLOD()==3) { // Rigging info may need update @@ -3834,9 +3857,6 @@ void LLVOVolume::updateRiggingInfo() } // Keep the highest LOD info available. mLastRiggingInfoLOD = getLOD(); - LL_DEBUGS("RigSpammish") << "updated rigging info for LLVOVolume " - << this << " lod " << mLastRiggingInfoLOD - << LL_ENDL; } } } @@ -6027,8 +6047,8 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) group->mBuilt = 1.f; - const U32 MAX_BUFFER_COUNT = 4096; - LLVertexBuffer* locked_buffer[MAX_BUFFER_COUNT]; + static std::vector<LLVertexBuffer*> locked_buffer; + locked_buffer.resize(0); U32 buffer_count = 0; @@ -6073,8 +6093,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) group->dirtyGeom(); gPipeline.markRebuild(group); } - - buff->unmapBuffer(); } } } @@ -6090,17 +6108,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) { LL_PROFILE_ZONE_NAMED("rebuildMesh - flush"); - for (LLVertexBuffer** iter = locked_buffer, ** end_iter = locked_buffer+buffer_count; iter != end_iter; ++iter) - { - (*iter)->unmapBuffer(); - } - - // don't forget alpha - if(group != NULL && - !group->mVertexBuffer.isNull()) - { - group->mVertexBuffer->unmapBuffer(); - } + LLVertexBuffer::flushBuffers(); } group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); @@ -6782,11 +6790,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace ++face_iter; } - - if (buffer) - { - buffer->unmapBuffer(); - } } group->mBufferMap[mask].clear(); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 97a5131260..10dbf1349f 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -227,6 +227,7 @@ public: void setTexture(const S32 face); S32 getIndexInTex(U32 ch) const {return mIndexInTex[ch];} + void unregisterOldMeshAndSkin(); /*virtual*/ bool setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false) override; void updateSculptTexture(); void setIndexInTex(U32 ch, S32 index) { mIndexInTex[ch] = index ;} diff --git a/indra/newview/llwindebug.h b/indra/newview/llwindebug.h index 770584c88d..11b50e3327 100644 --- a/indra/newview/llwindebug.h +++ b/indra/newview/llwindebug.h @@ -28,7 +28,7 @@ #define LL_LLWINDEBUG_H #include "stdtypes.h" -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <dbghelp.h> diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 4757bd42e0..6b2bd3e6fb 100755 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -186,6 +186,7 @@ LLWorldMapView::LLWorldMapView() : mMouseDownY(0), mSelectIDStart(0), mMapScale(0.f), + mMapRatio(0.5), mTargetMapScale(0.f), mMapIterpTime(MAP_ITERP_TIME_CONSTANT) { @@ -285,7 +286,9 @@ void LLWorldMapView::setScale(F32 scale, bool snap) { mMapScale = 0.1f; } + mMapRatio = mMapScale / REGION_WIDTH_METERS; mMapIterpTime = MAP_ITERP_TIME_CONSTANT; + F32 ratio = (scale / old_scale); mPanX *= ratio; mPanY *= ratio; @@ -359,6 +362,7 @@ bool is_agent_in_region(LLViewerRegion* region, LLSimInfo* info) void LLWorldMapView::draw() { + LL_PROFILE_ZONE_SCOPED; static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white); LLTextureView::clearDebugImages(); @@ -412,8 +416,9 @@ void LLWorldMapView::draw() drawMipmap(width, height); // Draw per sim overlayed information (names, mature, offline...) - for (LLWorldMap::sim_info_map_t::const_iterator it = LLWorldMap::getInstance()->getRegionMap().begin(); - it != LLWorldMap::getInstance()->getRegionMap().end(); ++it) + static LLCachedControl<bool> show_for_sale(gSavedSettings, "MapShowLandForSale"); + LLWorldMap::sim_info_map_t::const_iterator end = LLWorldMap::instance().getRegionMap().end(); + for (LLWorldMap::sim_info_map_t::const_iterator it = LLWorldMap::getInstance()->getRegionMap().begin(); it != end; ++it) { U64 handle = it->first; LLSimInfo* info = it->second; @@ -422,8 +427,8 @@ void LLWorldMapView::draw() // Find x and y position relative to camera's center. LLVector3d rel_region_pos = origin_global - camera_global; - F32 relative_x = (F32)(rel_region_pos.mdV[0] / REGION_WIDTH_METERS) * mMapScale; - F32 relative_y = (F32)(rel_region_pos.mdV[1] / REGION_WIDTH_METERS) * mMapScale; + F32 relative_x = (F32)(rel_region_pos.mdV[0] * mMapRatio); + F32 relative_y = (F32)(rel_region_pos.mdV[1] * mMapRatio); // Coordinates of the sim in pixels in the UI panel // When the view isn't panned, 0,0 = center of rectangle @@ -457,14 +462,19 @@ void LLWorldMapView::draw() gGL.color4f(0.2f, 0.0f, 0.0f, 0.4f); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { gGL.vertex2f(left, top); gGL.vertex2f(left, bottom); gGL.vertex2f(right, bottom); + + gGL.vertex2f(left, top); + gGL.vertex2f(right, bottom); gGL.vertex2f(right, top); + } gGL.end(); } - else if (gSavedSettings.getBOOL("MapShowLandForSale") && (level <= DRAW_LANDFORSALE_THRESHOLD)) + else if (show_for_sale && (level <= DRAW_LANDFORSALE_THRESHOLD)) { // Draw the overlay image "Land for Sale / Land for Auction" LLViewerFetchedTexture* overlayimage = info->getLandForSaleImage(); @@ -478,15 +488,22 @@ void LLWorldMapView::draw() { gGL.getTexUnit(0)->bind(overlayimage); gGL.color4f(1.f, 1.f, 1.f, 1.f); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { gGL.texCoord2f(0.f, 1.f); gGL.vertex3f(left, top, -0.5f); gGL.texCoord2f(0.f, 0.f); gGL.vertex3f(left, bottom, -0.5f); gGL.texCoord2f(1.f, 0.f); gGL.vertex3f(right, bottom, -0.5f); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3f(left, top, -0.5f); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3f(right, bottom, -0.5f); gGL.texCoord2f(1.f, 1.f); gGL.vertex3f(right, top, -0.5f); + } gGL.end(); } } @@ -500,7 +517,6 @@ void LLWorldMapView::draw() // Draw the region name in the lower left corner if (mMapScale >= DRAW_TEXT_THRESHOLD) { - LLFontGL* font = LLFontGL::getFont(LLFontDescriptor("SansSerif", "Small", LLFontGL::BOLD)); std::string mesg; if (info->isDown()) { @@ -512,7 +528,7 @@ void LLWorldMapView::draw() } if (!mesg.empty()) { - font->renderUTF8( + LLFontGL::getFontSansSerifSmallBold()->renderUTF8( mesg, 0, (F32)llfloor(left + 3), (F32)llfloor(bottom + 2), LLColor4::white, @@ -525,13 +541,19 @@ void LLWorldMapView::draw() } } + static LLCachedControl<bool> show_infohubs(gSavedSettings, "MapShowInfohubs"); + static LLCachedControl<bool> show_telehubs(gSavedSettings, "MapShowTelehubs"); + static LLCachedControl<bool> show_events(gSavedSettings, "MapShowEvents"); + static LLCachedControl<bool> show_mature_events(gSavedSettings, "ShowMatureEvents"); + static LLCachedControl<bool> show_adult_events(gSavedSettings, "ShowAdultEvents"); + // Draw item infos if we're not zoomed out too much and there's something to draw - if ((level <= DRAW_SIMINFO_THRESHOLD) && (gSavedSettings.getBOOL("MapShowInfohubs") || - gSavedSettings.getBOOL("MapShowTelehubs") || - gSavedSettings.getBOOL("MapShowLandForSale") || - gSavedSettings.getBOOL("MapShowEvents") || - gSavedSettings.getBOOL("ShowMatureEvents") || - gSavedSettings.getBOOL("ShowAdultEvents"))) + if ((level <= DRAW_SIMINFO_THRESHOLD) && (show_infohubs || + show_telehubs || + show_for_sale || + show_events || + show_mature_events || + show_adult_events)) { drawItems(); } @@ -727,15 +749,22 @@ bool LLWorldMapView::drawMipmapLevel(S32 width, S32 height, S32 level, bool load gGL.color4f(1.f, 1.0f, 1.0f, 1.0f); - gGL.begin(LLRender::QUADS); + gGL.begin(LLRender::TRIANGLES); + { gGL.texCoord2f(0.f, 1.f); gGL.vertex3f(left, top, 0.f); gGL.texCoord2f(0.f, 0.f); gGL.vertex3f(left, bottom, 0.f); gGL.texCoord2f(1.f, 0.f); gGL.vertex3f(right, bottom, 0.f); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3f(left, top, 0.f); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3f(right, bottom, 0.f); gGL.texCoord2f(1.f, 1.f); gGL.vertex3f(right, top, 0.f); + } gGL.end(); #if DEBUG_DRAW_TILE drawTileOutline(level, top, left, bottom, right); @@ -828,11 +857,12 @@ void LLWorldMapView::drawImageStack(const LLVector3d& global_pos, LLUIImagePtr i void LLWorldMapView::drawItems() { - bool mature_enabled = gAgent.canAccessMature(); - bool adult_enabled = gAgent.canAccessAdult(); - - bool show_mature = mature_enabled && gSavedSettings.getBOOL("ShowMatureEvents"); - bool show_adult = adult_enabled && gSavedSettings.getBOOL("ShowAdultEvents"); + static LLCachedControl<bool> show_infohubs(gSavedSettings, "MapShowInfohubs"); + static LLCachedControl<bool> show_telehubs(gSavedSettings, "MapShowTelehubs"); + static LLCachedControl<bool> show_events(gSavedSettings, "MapShowEvents"); + static LLCachedControl<bool> show_mature_events(gSavedSettings, "ShowMatureEvents"); + static LLCachedControl<bool> show_adult_events(gSavedSettings, "ShowAdultEvents"); + static LLCachedControl<bool> show_for_sale(gSavedSettings, "MapShowLandForSale"); for (handle_list_t::iterator iter = mVisibleRegions.begin(); iter != mVisibleRegions.end(); ++iter) { @@ -843,17 +873,17 @@ void LLWorldMapView::drawItems() continue; } // Infohubs - if (gSavedSettings.getBOOL("MapShowInfohubs")) + if (show_infohubs) { drawGenericItems(info->getInfoHub(), sInfohubImage); } // Telehubs - if (gSavedSettings.getBOOL("MapShowTelehubs")) + if (show_telehubs) { drawGenericItems(info->getTeleHub(), sTelehubImage); } // Land for sale - if (gSavedSettings.getBOOL("MapShowLandForSale")) + if (show_for_sale) { drawGenericItems(info->getLandForSale(), sForSaleImage); // for 1.23, we're showing normal land and adult land in the same UI; you don't @@ -865,17 +895,17 @@ void LLWorldMapView::drawItems() } } // PG Events - if (gSavedSettings.getBOOL("MapShowEvents")) + if (show_events) { drawGenericItems(info->getPGEvent(), sEventImage); } // Mature Events - if (show_mature) + if (show_mature_events && gAgent.canAccessMature()) { drawGenericItems(info->getMatureEvent(), sEventMatureImage); } // Adult Events - if (show_adult) + if (show_adult_events && gAgent.canAccessAdult()) { drawGenericItems(info->getAdultEvent(), sEventAdultImage); } @@ -910,14 +940,12 @@ void LLWorldMapView::drawAgents() void LLWorldMapView::drawFrustum() { // Draw frustum - F32 meters_to_pixels = mMapScale/ REGION_WIDTH_METERS; - F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); - F32 far_clip_pixels = far_clip_meters * meters_to_pixels; + F32 far_clip_pixels = far_clip_meters * mMapRatio; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); - F32 half_width_pixels = half_width_meters * meters_to_pixels; + F32 half_width_pixels = half_width_meters * mMapRatio; // Compute the frustum coordinates. Take the UI scale into account. F32 ctr_x = ((getLocalRect().getWidth() * 0.5f + mPanX) * LLUI::getScaleFactor().mV[VX]); @@ -978,8 +1006,8 @@ LLVector3 LLWorldMapView::globalPosToView( const LLVector3d& global_pos ) LLVector3 pos_local; pos_local.setVec(relative_pos_global); // convert to floats from doubles - pos_local.mV[VX] *= mMapScale / REGION_WIDTH_METERS; - pos_local.mV[VY] *= mMapScale / REGION_WIDTH_METERS; + pos_local.mV[VX] *= mMapRatio; + pos_local.mV[VY] *= mMapRatio; // leave Z component in meters diff --git a/indra/newview/llworldmapview.h b/indra/newview/llworldmapview.h index ebc9c6d738..d4857113f2 100644 --- a/indra/newview/llworldmapview.h +++ b/indra/newview/llworldmapview.h @@ -210,6 +210,7 @@ private: F32 mMapScale; F32 mTargetMapScale; + F32 mMapRatio; static F32 sMapScaleSetting; static LLVector2 sZoomPivot; static LLFrameTimer sZoomTimer; diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 48461241a2..07e2b118d3 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -26,7 +26,7 @@ #include "llviewerprecompiledheaders.h" // include this to get winsock2 because openssl attempts to include winsock1 -#include "llwin32headerslean.h" +#include "llwin32headers.h" #include <openssl/x509_vfy.h> #include <openssl/ssl.h> #include "llsecapi.h" diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3d083ee794..3a811f893e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -219,7 +219,7 @@ S32 LLPipeline::RenderHeroProbeUpdateRate; S32 LLPipeline::RenderHeroProbeConservativeUpdateMultiplier; LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize"); -const U32 LLPipeline::MAX_BAKE_WIDTH = 512; +const U32 LLPipeline::MAX_PREVIEW_WIDTH = 512; const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f; const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f; @@ -228,7 +228,6 @@ const F32 DEFERRED_LIGHT_FALLOFF = 0.5f; const U32 DEFERRED_VB_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1; extern S32 gBoxFrame; -//extern bool gHideSelectedObjects; extern bool gDisplaySwapBuffers; extern bool gDebugGL; extern bool gCubeSnapshot; @@ -879,6 +878,8 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) // used to scale down textures // See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown mDownResMap.allocate(4, 4, GL_RGBA); + + mBakeMap.allocate(LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH, LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT, GL_RGBA); } //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) @@ -1139,6 +1140,8 @@ void LLPipeline::releaseGLBuffers() mDownResMap.release(); + mBakeMap.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -2110,9 +2113,9 @@ F32 LLPipeline::calcPixelArea(const LLVector4a& center, const LLVector4a& size, } //get area of circle around node - F32 app_angle = atanf(size.getLength3().getF32()/dist); - F32 radius = app_angle*LLDrawable::sCurPixelAngle; - return radius*radius * F_PI; + F32 app_angle = atanf(size.getLength3().getF32() / dist); + F32 radius = app_angle * LLDrawable::sCurPixelAngle; + return radius * radius * F_PI; } void LLPipeline::grabReferences(LLCullResult& result) @@ -3728,6 +3731,7 @@ void LLPipeline::postSort(LLCamera &camera) } } + LLVertexBuffer::flushBuffers(); // LLSpatialGroup::sNoDelete = false; LL_PUSH_CALLSTACKS(); } @@ -3895,20 +3899,17 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) if (&camera == LLViewerCamera::getInstance()) { // a bit hacky, this is the start of the main render frame, figure out delta between last modelview matrix and // current modelview matrix - glh::matrix4f last_modelview(gGLLastModelView); - glh::matrix4f cur_modelview(gGLModelView); + glm::mat4 last_modelview = get_last_modelview(); + glm::mat4 cur_modelview = get_current_modelview(); // goal is to have a matrix here that goes from the last frame's camera space to the current frame's camera space - glh::matrix4f m = last_modelview.inverse(); // last camera space to world space - m.mult_left(cur_modelview); // world space to camera space + glm::mat4 m = glm::inverse(last_modelview); // last camera space to world space + m = cur_modelview * m; // world space to camera space - glh::matrix4f n = m.inverse(); + glm::mat4 n = glm::inverse(m); - for (U32 i = 0; i < 16; ++i) - { - gGLDeltaModelView[i] = m.m[i]; - gGLInverseDeltaModelView[i] = n.m[i]; - } + gGLDeltaModelView = m; + gGLInverseDeltaModelView = n; } bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion && !LLGLSLShader::sProfileEnabled; @@ -7069,7 +7070,7 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst) LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - bool no_post = gSnapshotNoPost || (buildNoPost && gFloaterTools->isAvailable()); + bool no_post = gSnapshotNoPost || psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f || (buildNoPost && gFloaterTools->isAvailable()); LLGLSLShader& shader = no_post ? gNoPostTonemapProgram : gDeferredPostTonemapProgram; shader.bind(); @@ -7919,6 +7920,8 @@ void LLPipeline::renderFinalize() gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, finalBuffer); gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + gDeferredPostNoDoFNoiseProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)finalBuffer->getWidth(), (GLfloat)finalBuffer->getHeight()); + { LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); mScreenTriangleVB->setBuffer(); @@ -8075,7 +8078,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ if (sReflectionRender && !shader.getUniformLocation(LLShaderMgr::MODELVIEW_MATRIX)) { - shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_MATRIX, 1, false, mReflectionModelView.m); + shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_MATRIX, 1, false, glm::value_ptr(mReflectionModelView)); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE); @@ -8112,12 +8115,12 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ F32 mat[16*6]; for (U32 i = 0; i < 16; i++) { - mat[i] = mSunShadowMatrix[0].m[i]; - mat[i+16] = mSunShadowMatrix[1].m[i]; - mat[i+32] = mSunShadowMatrix[2].m[i]; - mat[i+48] = mSunShadowMatrix[3].m[i]; - mat[i+64] = mSunShadowMatrix[4].m[i]; - mat[i+80] = mSunShadowMatrix[5].m[i]; + mat[i] = glm::value_ptr(mSunShadowMatrix[0])[i]; + mat[i+16] = glm::value_ptr(mSunShadowMatrix[1])[i]; + mat[i+32] = glm::value_ptr(mSunShadowMatrix[2])[i]; + mat[i+48] = glm::value_ptr(mSunShadowMatrix[3])[i]; + mat[i+64] = glm::value_ptr(mSunShadowMatrix[4])[i]; + mat[i+80] = glm::value_ptr(mSunShadowMatrix[5])[i]; } shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_SHADOW_MATRIX, 6, false, mat); @@ -8223,15 +8226,15 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, gGLDeltaModelView); - shader.uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, gGLInverseDeltaModelView); + shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, glm::value_ptr(gGLDeltaModelView)); + shader.uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_DELTA_MATRIX, 1, GL_FALSE, glm::value_ptr(gGLInverseDeltaModelView)); shader.uniform1i(LLShaderMgr::CUBE_SNAPSHOT, gCubeSnapshot ? 1 : 0); if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) { - glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); - shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, false, norm_mat.m); + glm::mat4 norm_mat = glm::transpose(glm::inverse(get_current_modelview())); + shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, false, glm::value_ptr(norm_mat)); } // auto adjust legacy sun color if needed @@ -8305,17 +8308,17 @@ void LLPipeline::renderDeferredLighting() LLGLEnable cull(GL_CULL_FACE); LLGLEnable blend(GL_BLEND); - glh::matrix4f mat = copy_matrix(gGLModelView); + glm::mat4 mat = get_current_modelview(); setupHWLights(); // to set mSun/MoonDir; - glh::vec4f tc(mSunDir.mV); - mat.mult_matrix_vec(tc); - mTransformedSunDir.set(tc.v); + glm::vec4 tc(glm::make_vec4(mSunDir.mV)); + tc = mat * tc; + mTransformedSunDir.set(glm::value_ptr(tc)); - glh::vec4f tc_moon(mMoonDir.mV); - mat.mult_matrix_vec(tc_moon); - mTransformedMoonDir.set(tc_moon.v); + glm::vec4 tc_moon(glm::make_vec4(mMoonDir.mV)); + tc_moon = mat * tc_moon; + mTransformedMoonDir.set(glm::value_ptr(tc_moon)); if ((RenderDeferredSSAO && !gCubeSnapshot) || RenderShadowDetail > 0) { @@ -8331,26 +8334,6 @@ void LLPipeline::renderDeferredLighting() deferred_light_target->clear(GL_COLOR_BUFFER_BIT); glClearColor(0, 0, 0, 0); - glh::matrix4f inv_trans = get_current_modelview().inverse().transpose(); - - const U32 slice = 32; - F32 offset[slice * 3]; - for (U32 i = 0; i < 4; i++) - { - for (U32 j = 0; j < 8; j++) - { - glh::vec3f v; - v.set_value(sinf(6.284f / 8 * j), cosf(6.284f / 8 * j), -(F32) i); - v.normalize(); - inv_trans.mult_matrix_vec(v); - v.normalize(); - offset[(i * 8 + j) * 3 + 0] = v.v[0]; - offset[(i * 8 + j) * 3 + 1] = v.v[2]; - offset[(i * 8 + j) * 3 + 2] = v.v[1]; - } - } - - sun_shader.uniform3fv(sOffset, slice, offset); sun_shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)deferred_light_target->getWidth(), (GLfloat)deferred_light_target->getHeight()); @@ -8583,10 +8566,10 @@ void LLPipeline::renderDeferredLighting() continue; } - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); + glm::vec3 tc(glm::make_vec3(c)); + tc = mul_mat4_vec3(mat, tc); - fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); + fullscreen_lights.push_back(LLVector4(tc.x, tc.y, tc.z, s)); light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF))); } } @@ -8693,15 +8676,15 @@ void LLPipeline::renderDeferredLighting() sVisibleLightCount++; - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); + glm::vec3 tc(glm::make_vec3(c)); + tc = mul_mat4_vec3(mat, tc); setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space LLColor3 col = volume->getLightLinearColor() * light_scale; - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, glm::value_ptr(tc)); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, light_falloff_final); @@ -8944,10 +8927,10 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) //matrix from volume space to agent space LLMatrix4 light_mat(quat, LLVector4(origin,1.f)); - glh::matrix4f light_to_agent((F32*) light_mat.mMatrix); - glh::matrix4f light_to_screen = get_current_modelview() * light_to_agent; + glm::mat4 light_to_agent(glm::make_mat4((F32*) light_mat.mMatrix)); + glm::mat4 light_to_screen = get_current_modelview() * light_to_agent; - glh::matrix4f screen_to_light = light_to_screen.inverse(); + glm::mat4 screen_to_light = glm::inverse(light_to_screen); F32 s = volume->getLightRadius()*1.5f; F32 near_clip = dist; @@ -8955,34 +8938,34 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) F32 height = scale.mV[VY]; F32 far_clip = s+dist-scale.mV[VZ]; - F32 fovy = fov * RAD_TO_DEG; + F32 fovy = fov; // radians F32 aspect = width/height; - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + glm::mat4 trans(0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f); - glh::vec3f p1(0, 0, -(near_clip+0.01f)); - glh::vec3f p2(0, 0, -(near_clip+1.f)); + glm::vec3 p1(0, 0, -(near_clip+0.01f)); + glm::vec3 p2(0, 0, -(near_clip+1.f)); - glh::vec3f screen_origin(0, 0, 0); + glm::vec3 screen_origin(0, 0, 0); - light_to_screen.mult_matrix_vec(p1); - light_to_screen.mult_matrix_vec(p2); - light_to_screen.mult_matrix_vec(screen_origin); + p1 = mul_mat4_vec3(light_to_screen, p1); + p2 = mul_mat4_vec3(light_to_screen, p2); + screen_origin = mul_mat4_vec3(light_to_screen, screen_origin); - glh::vec3f n = p2-p1; - n.normalize(); + glm::vec3 n = p2-p1; + n = glm::normalize(n); F32 proj_range = far_clip - near_clip; - glh::matrix4f light_proj = gl_perspective(fovy, aspect, near_clip, far_clip); + glm::mat4 light_proj = glm::perspective(fovy, aspect, near_clip, far_clip); screen_to_light = trans * light_proj * screen_to_light; - shader.uniformMatrix4fv(LLShaderMgr::PROJECTOR_MATRIX, 1, false, screen_to_light.m); + shader.uniformMatrix4fv(LLShaderMgr::PROJECTOR_MATRIX, 1, false, glm::value_ptr(screen_to_light)); shader.uniform1f(LLShaderMgr::PROJECTOR_NEAR, near_clip); - shader.uniform3fv(LLShaderMgr::PROJECTOR_P, 1, p1.v); - shader.uniform3fv(LLShaderMgr::PROJECTOR_N, 1, n.v); - shader.uniform3fv(LLShaderMgr::PROJECTOR_ORIGIN, 1, screen_origin.v); + shader.uniform3fv(LLShaderMgr::PROJECTOR_P, 1, glm::value_ptr(p1)); + shader.uniform3fv(LLShaderMgr::PROJECTOR_N, 1, glm::value_ptr(n)); + shader.uniform3fv(LLShaderMgr::PROJECTOR_ORIGIN, 1, glm::value_ptr(screen_origin)); shader.uniform1f(LLShaderMgr::PROJECTOR_RANGE, proj_range); shader.uniform1f(LLShaderMgr::PROJECTOR_AMBIANCE, params.mV[2]); S32 s_idx = -1; @@ -9220,10 +9203,8 @@ inline float sgn(float a) return (0.0F); } -glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) +glm::mat4 look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) { - glh::matrix4f ret; - LLVector3 dirN; LLVector3 upN; LLVector3 lftN; @@ -9237,53 +9218,28 @@ glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) dirN = dir; dirN.normVec(); - ret.m[ 0] = lftN[0]; - ret.m[ 1] = upN[0]; - ret.m[ 2] = -dirN[0]; - ret.m[ 3] = 0.f; + F32 ret[16]; + ret[ 0] = lftN[0]; + ret[ 1] = upN[0]; + ret[ 2] = -dirN[0]; + ret[ 3] = 0.f; - ret.m[ 4] = lftN[1]; - ret.m[ 5] = upN[1]; - ret.m[ 6] = -dirN[1]; - ret.m[ 7] = 0.f; + ret[ 4] = lftN[1]; + ret[ 5] = upN[1]; + ret[ 6] = -dirN[1]; + ret[ 7] = 0.f; - ret.m[ 8] = lftN[2]; - ret.m[ 9] = upN[2]; - ret.m[10] = -dirN[2]; - ret.m[11] = 0.f; + ret[ 8] = lftN[2]; + ret[ 9] = upN[2]; + ret[10] = -dirN[2]; + ret[11] = 0.f; - ret.m[12] = -(lftN*pos); - ret.m[13] = -(upN*pos); - ret.m[14] = dirN*pos; - ret.m[15] = 1.f; + ret[12] = -(lftN*pos); + ret[13] = -(upN*pos); + ret[14] = dirN*pos; + ret[15] = 1.f; - return ret; -} - -glh::matrix4f scale_translate_to_fit(const LLVector3 min, const LLVector3 max) -{ - glh::matrix4f ret; - ret.m[ 0] = 2/(max[0]-min[0]); - ret.m[ 4] = 0; - ret.m[ 8] = 0; - ret.m[12] = -(max[0]+min[0])/(max[0]-min[0]); - - ret.m[ 1] = 0; - ret.m[ 5] = 2/(max[1]-min[1]); - ret.m[ 9] = 0; - ret.m[13] = -(max[1]+min[1])/(max[1]-min[1]); - - ret.m[ 2] = 0; - ret.m[ 6] = 0; - ret.m[10] = 2/(max[2]-min[2]); - ret.m[14] = -(max[2]+min[2])/(max[2]-min[2]); - - ret.m[ 3] = 0; - ret.m[ 7] = 0; - ret.m[11] = 0; - ret.m[15] = 1; - - return ret; + return glm::make_mat4(ret); } static LLTrace::BlockTimerStatHandle FTM_SHADOW_RENDER("Render Shadows"); @@ -9297,7 +9253,7 @@ static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_TREE("Alpha Tree"); static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_GRASS("Alpha Grass"); static LLTrace::BlockTimerStatHandle FTM_SHADOW_FULLBRIGHT_ALPHA_MASKED("Fullbright Alpha Masked"); -void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult& result, bool depth_clamp) +void LLPipeline::renderShadow(const glm::mat4& view, const glm::mat4& proj, LLCamera& shadow_cam, LLCullResult& result, bool depth_clamp) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; //LL_RECORD_BLOCK_TIME(FTM_SHADOW_RENDER); LL_PROFILE_GPU_ZONE("renderShadow"); @@ -9340,10 +9296,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera //generate shadow map gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); - gGL.loadMatrix(proj.m); + gGL.loadMatrix(glm::value_ptr(proj)); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - gGL.loadMatrix(view.m); + gGL.loadMatrix(glm::value_ptr(view)); stop_glerror(); gGLLastMatrix = NULL; @@ -9753,13 +9709,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON); } - F64 last_modelview[16]; - F64 last_projection[16]; - for (U32 i = 0; i < 16; i++) - { //store last_modelview of world camera - last_modelview[i] = gGLLastModelView[i]; - last_projection[i] = gGLLastProjection[i]; - } + glm::mat4 last_modelview = get_last_modelview(); + glm::mat4 last_projection = get_last_projection(); pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE, @@ -9838,12 +9789,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //get sun view matrix //store current projection/modelview matrix - glh::matrix4f saved_proj = get_current_projection(); - glh::matrix4f saved_view = get_current_modelview(); - glh::matrix4f inv_view = saved_view.inverse(); + glm::mat4 saved_proj = get_current_projection(); + glm::mat4 saved_view = get_current_modelview(); + glm::mat4 inv_view = glm::inverse(saved_view); - glh::matrix4f view[6]; - glh::matrix4f proj[6]; + glm::mat4 view[6]; + glm::mat4 proj[6]; LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir); @@ -9858,7 +9809,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLVector3 lightDir = -caster_dir; lightDir.normVec(); - glh::vec3f light_dir(lightDir.mV); + glm::vec3 light_dir(glm::make_vec3(lightDir.mV)); //create light space camera matrix @@ -9913,9 +9864,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //get good split distances for frustum for (U32 i = 0; i < fp.size(); ++i) { - glh::vec3f v(fp[i].mV); - saved_view.mult_matrix_vec(v); - fp[i].setVec(v.v); + glm::vec3 v(glm::make_vec3(fp[i].mV)); + v = mul_mat4_vec3(saved_view, v); + fp[i].setVec(glm::value_ptr(v)); } min = fp[0]; @@ -10064,9 +10015,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) for (U32 i = 0; i < fp.size(); i++) { - glh::vec3f p = glh::vec3f(fp[i].mV); - view[j].mult_matrix_vec(p); - wpf.push_back(LLVector3(p.v)); + glm::vec3 p = glm::make_vec3(fp[i].mV); + p = mul_mat4_vec3(view[j], p); + wpf.push_back(LLVector3(glm::value_ptr(p))); } min = wpf[0]; @@ -10166,7 +10117,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { //just use ortho projection mShadowFOV.mV[j] = -1.f; origin.clearVec(); - proj[j] = gl_ortho(min.mV[0], max.mV[0], + proj[j] = glm::ortho(min.mV[0], max.mV[0], min.mV[1], max.mV[1], -max.mV[2], -min.mV[2]); } @@ -10257,37 +10208,37 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { //just use ortho projection origin.clearVec(); mShadowError.mV[j] = -1.f; - proj[j] = gl_ortho(min.mV[0], max.mV[0], + proj[j] = glm::ortho(min.mV[0], max.mV[0], min.mV[1], max.mV[1], -max.mV[2], -min.mV[2]); } else { //get perspective projection - view[j] = view[j].inverse(); + view[j] = glm::inverse(view[j]); //llassert(origin.isFinite()); - glh::vec3f origin_agent(origin.mV); + glm::vec3 origin_agent(glm::make_vec3(origin.mV)); //translate view to origin - view[j].mult_matrix_vec(origin_agent); + origin_agent = mul_mat4_vec3(view[j], origin_agent); - eye = LLVector3(origin_agent.v); + eye = LLVector3(glm::value_ptr(origin_agent)); //llassert(eye.isFinite()); if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { mShadowFrustOrigin[j] = eye; } - view[j] = look(LLVector3(origin_agent.v), lightDir, -up); + view[j] = look(LLVector3(glm::value_ptr(origin_agent)), lightDir, -up); F32 fx = 1.f/tanf(fovx); F32 fz = 1.f/tanf(fovz); - proj[j] = glh::matrix4f(-fx, 0, 0, 0, - 0, (yfar+ynear)/(ynear-yfar), 0, (2.f*yfar*ynear)/(ynear-yfar), - 0, 0, -fz, 0, - 0, -1.f, 0, 0); + proj[j] = glm::mat4(-fx, 0, 0, 0, + 0, (yfar + ynear) / (ynear - yfar), 0, -1.0f, + 0, 0, -fz, 0, + 0, (2.f * yfar * ynear) / (ynear - yfar), 0, 0); } } } @@ -10306,19 +10257,16 @@ void LLPipeline::generateSunShadow(LLCamera& camera) shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip); //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + glm::mat4 trans(0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f); set_current_modelview(view[j]); set_current_projection(proj[j]); - for (U32 i = 0; i < 16; i++) - { - gGLLastModelView[i] = mShadowModelview[j].m[i]; - gGLLastProjection[i] = mShadowProjection[j].m[i]; - } + set_last_modelview(mShadowModelview[j]); + set_last_projection(mShadowProjection[j]); mShadowModelview[j] = view[j]; mShadowProjection[j] = proj[j]; @@ -10433,9 +10381,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); + view[i + 4] = glm::make_mat4((F32*)mat.mMatrix); - view[i + 4] = view[i + 4].inverse(); + view[i + 4] = glm::inverse(view[i + 4]); //get perspective matrix F32 near_clip = dist + 0.01f; @@ -10443,27 +10391,24 @@ void LLPipeline::generateSunShadow(LLCamera& camera) F32 height = scale.mV[VY]; F32 far_clip = dist + volume->getLightRadius() * 1.5f; - F32 fovy = fov * RAD_TO_DEG; + F32 fovy = fov; // radians F32 aspect = width / height; - proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); + proj[i + 4] = glm::perspective(fovy, aspect, near_clip, far_clip); //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + glm::mat4 trans(0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f); set_current_modelview(view[i + 4]); set_current_projection(proj[i + 4]); mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; - gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; - } + set_last_modelview(mShadowModelview[i + 4]); + set_last_projection(mShadowProjection[i + 4]); mShadowModelview[i + 4] = view[i + 4]; mShadowProjection[i + 4] = proj[i + 4]; @@ -10511,18 +10456,15 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { set_current_modelview(view[1]); set_current_projection(proj[1]); - gGL.loadMatrix(view[1].m); + gGL.loadMatrix(glm::value_ptr(view[1])); gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadMatrix(proj[1].m); + gGL.loadMatrix(glm::value_ptr(proj[1])); gGL.matrixMode(LLRender::MM_MODELVIEW); } gGL.setColorMask(true, true); - for (U32 i = 0; i < 16; i++) - { - gGLLastModelView[i] = (F32)last_modelview[i]; - gGLLastProjection[i] = (F32)last_projection[i]; - } + set_last_modelview(last_modelview); + set_last_projection(last_projection); popRenderTypeMask(); @@ -10822,18 +10764,18 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool F32 distance = (pos-camera.getOrigin()).length(); F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG; F32 aspect = tdim.mV[0]/tdim.mV[1]; - glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f); + glm::mat4 persp = glm::perspective(glm::radians(fov), aspect, 1.f, 256.f); set_current_projection(persp); - gGL.loadMatrix(persp.m); + gGL.loadMatrix(glm::value_ptr(persp)); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glh::matrix4f mat; - camera.getOpenGLTransform(mat.m); - mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat; + F32 ogl_mat[16]; + camera.getOpenGLTransform(ogl_mat); + glm::mat4 mat = glm::make_mat4((GLfloat*) OGL_TO_CFR_ROTATION) * glm::make_mat4(ogl_mat); - gGL.loadMatrix(mat.m); + gGL.loadMatrix(glm::value_ptr(mat)); set_current_modelview(mat); glClearColor(0.0f,0.0f,0.0f,0.0f); @@ -10955,11 +10897,16 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool gGL.diffuseColor4fv(LLColor4::pink.mV ); } - gGL.begin(LLRender::QUADS); - gGL.vertex3f(-1, -1, clip_plane); - gGL.vertex3f(1, -1, clip_plane); - gGL.vertex3f(1, 1, clip_plane); - gGL.vertex3f(-1, 1, clip_plane); + gGL.begin(LLRender::TRIANGLES); + { + gGL.vertex3f(-1.f, -1.f, clip_plane); + gGL.vertex3f(1.f, -1.f, clip_plane); + gGL.vertex3f(1.f, 1.f, clip_plane); + + gGL.vertex3f(-1.f, -1.f, clip_plane); + gGL.vertex3f(1.f, 1.f, clip_plane); + gGL.vertex3f(-1.f, 1.f, clip_plane); + } gGL.end(); gGL.flush(); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 3687ab32fa..5c9b95ef4a 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -345,7 +345,7 @@ public: void renderHighlight(const LLViewerObject* obj, F32 fade); - void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, LLCullResult& result, bool depth_clamp); + void renderShadow(const glm::mat4& view, const glm::mat4& proj, LLCamera& camera, LLCullResult& result, bool depth_clamp); void renderSelectedFaces(const LLColor4& color); void renderHighlights(); void renderDebug(); @@ -737,6 +737,9 @@ public: // downres scratch space for GPU downscaling of textures LLRenderTarget mDownResMap; + // 2k bom scratch target + LLRenderTarget mBakeMap; + LLCullResult mSky; LLCullResult mReflectedObjects; LLCullResult mRefractedObjects; @@ -760,10 +763,10 @@ public: LLCamera mShadowCamera[8]; LLVector3 mShadowExtents[4][2]; // TODO : separate Sun Shadow and Spot Shadow matrices - glh::matrix4f mSunShadowMatrix[6]; - glh::matrix4f mShadowModelview[6]; - glh::matrix4f mShadowProjection[6]; - glh::matrix4f mReflectionModelView; + glm::mat4 mSunShadowMatrix[6]; + glm::mat4 mShadowModelview[6]; + glm::mat4 mShadowProjection[6]; + glm::mat4 mReflectionModelView; LLPointer<LLDrawable> mShadowSpotLight[2]; F32 mSpotLightFade[2]; @@ -776,7 +779,7 @@ public: //water distortion texture (refraction) LLRenderTarget mWaterDis; - static const U32 MAX_BAKE_WIDTH; + static const U32 MAX_PREVIEW_WIDTH; //texture for making the glow LLRenderTarget mGlow[3]; diff --git a/indra/newview/skins/default/textures/map_avatar_you_32.tga b/indra/newview/skins/default/textures/map_avatar_you_32.tga Binary files differindex 782207efd6..84b57aceaf 100644 --- a/indra/newview/skins/default/textures/map_avatar_you_32.tga +++ b/indra/newview/skins/default/textures/map_avatar_you_32.tga diff --git a/indra/newview/skins/default/xui/da/language_settings.xml b/indra/newview/skins/default/xui/da/language_settings.xml index 0e3cbfd2d2..d31afb320a 100644 --- a/indra/newview/skins/default/xui/da/language_settings.xml +++ b/indra/newview/skins/default/xui/da/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">danish</string> <string name="MacLocale">da_DK.UTF-8</string> + <string name="macOSLocale">da_DK.UTF-8</string> <string name="DarwinLocale">da_DK.UTF-8</string> <string name="LinuxLocale">da_DK.UTF-8</string> diff --git a/indra/newview/skins/default/xui/de/language_settings.xml b/indra/newview/skins/default/xui/de/language_settings.xml index f9346eef7d..57a327b345 100644 --- a/indra/newview/skins/default/xui/de/language_settings.xml +++ b/indra/newview/skins/default/xui/de/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">german</string> <string name="MacLocale">de_DE.UTF-8</string> + <string name="macOSLocale">de_DE.UTF-8</string> <string name="DarwinLocale">de_DE.UTF-8</string> <string name="LinuxLocale">de_DE.UTF-8</string> diff --git a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml index b17d0aa5b6..025d537804 100644 --- a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml @@ -11,10 +11,10 @@ name="gltf asset editor" title="[OBJECT_NAME]"> <floater.string name="floater_title" value="GLTF Scene Editor"/> - <floater.string name="scene_tittle" value="Scene"/> - <floater.string name="node_tittle" value="Node"/> - <floater.string name="mesh_tittle" value="Mesh"/> - <floater.string name="skin_tittle" value="Skin"/> + <floater.string name="scene_title" value="Scene"/> + <floater.string name="node_title" value="Node"/> + <floater.string name="mesh_title" value="Mesh"/> + <floater.string name="skin_title" value="Skin"/> <layout_stack name="main_layout" diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index e43143c8c3..d3a872c9d5 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2774,7 +2774,7 @@ even though the user gets a free copy. label="New Script" label_selected="New Script" layout="topleft" - left="10" + left="8" name="button new script" top="10" width="134" /> @@ -2786,16 +2786,28 @@ even though the user gets a free copy. left_pad="8" name="button permissions" width="134" /> - <panel_inventory_object + <filter_editor + follows="left|top|right" + label="Enter filter text" + layout="topleft" + top="40" + left="10" + text_pad_left="10" + max_length_chars="300" + highlight_text_field="true" + name="contents_filter" + height="23" + width="275" /> + <panel_inventory_object border="true" border_visible="true" bevel_style="in" follows="left|top|right" - height="387" + height="367" layout="topleft" left="10" name="contents_inventory" - top="50" + top="70" width="275" /> </panel> </tab_container> diff --git a/indra/newview/skins/default/xui/en/language_settings.xml b/indra/newview/skins/default/xui/en/language_settings.xml index dd521c09d0..12a1b52a84 100644 --- a/indra/newview/skins/default/xui/en/language_settings.xml +++ b/indra/newview/skins/default/xui/en/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">english</string> <string name="MacLocale">C</string> + <string name="macOSLocale">C</string> <string name="DarwinLocale">C</string> <string name="LinuxLocale">C</string> diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index fb556a6587..13ce886fb9 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -465,6 +465,24 @@ <menu_item_check.on_click function="World.AlwaysRun" /> </menu_item_check> + <menu_item_check + label="Hear Media and Sound from Avatar" + name="Hear Media and Sound from Avatar"> + <menu_item_check.on_check + control="MediaSoundsEarLocation" /> + <menu_item_check.on_click + function="Agent.ToggleHearMediaSoundFromAvatar" /> + </menu_item_check> + <menu_item_check + label="Hear Voice from Avatar" + name="Hear Voice from Avatar"> + <menu_item_check.on_check + control="VoiceEarLocation" /> + <menu_item_check.on_click + function="Agent.ToggleHearVoiceFromAvatar" /> + <menu_item_call.on_enable + control="EnableVoiceChat" /> + </menu_item_check> <menu_item_separator/> <menu_item_check label="Gestures..." diff --git a/indra/newview/skins/default/xui/en/panel_group_roles.xml b/indra/newview/skins/default/xui/en/panel_group_roles.xml index 02e135a2c7..868d54401e 100644 --- a/indra/newview/skins/default/xui/en/panel_group_roles.xml +++ b/indra/newview/skins/default/xui/en/panel_group_roles.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel - height="750" + height="770" label="Members & Roles" layout="topleft" left="0" @@ -18,9 +18,9 @@ <panel.string name="help_text" /> <tab_container - border="false" + border="false" follows="left|top|right" - height="552" + height="770" halign="center" layout="topleft" left="0" @@ -29,16 +29,10 @@ tab_position="top" tab_height="22" tab_min_width="90" - top="0" - width="304"> + top="0"> <panel border="false" - follows="all" - height="303" label="MEMBERS" - layout="topleft" - left="0" - right="-1" help_topic="roles_members_tab" name="members_sub_tab" tool_tip="Members" @@ -65,16 +59,16 @@ clicking on their names. name="power_partial_icon" translate="false"> Checkbox_Off </panel.string> - <filter_editor - layout="topleft" - top="5" - left="5" - right="-5" - height="22" - search_button_visible="false" - follows="left|top|right" - label="Filter Members" - name="filter_input" /> + <filter_editor + layout="topleft" + top="5" + left="5" + right="-5" + height="22" + search_button_visible="false" + follows="left|top|right" + label="Filter Members" + name="filter_input" /> <name_list column_padding="2" draw_heading="true" @@ -90,11 +84,11 @@ clicking on their names. <name_list.columns label="Member" name="name" - relative_width="0.44" /> + relative_width="0.44" /> <name_list.columns label="Donation" name="donated" - relative_width="0.2" /> + relative_width="0.2" /> <name_list.columns label="Status" name="online" @@ -118,25 +112,21 @@ clicking on their names. left_pad="10" name="member_eject" width="100" /> - <button - height="23" - label="Ban Member(s)" - follows="top|left" - left_pad="10" - name="member_ban" - width="100" /> + <button + height="23" + label="Ban Member(s)" + follows="top|left" + left_pad="10" + name="member_ban" + width="100" /> </panel> <panel border="false" - height="303" label="ROLES" - layout="topleft" - left="0" - right="-1" help_topic="roles_roles_tab" name="roles_sub_tab" class="panel_group_roles_subtab"> - <!-- <button + <!--<button enabled="false" height="20" label="Show All" @@ -145,411 +135,393 @@ clicking on their names. right="-5" name="show_all_button" width="100" />--> - <panel.string - name="help_text"> - Roles have a title and an allowed list of Abilities - that Members can perform. Members can belong to - one or more Roles. A group can have up to 10 Roles, - including the Everyone and Owner Roles. - </panel.string> - <panel.string - name="cant_delete_role"> - The 'Everyone' and 'Owners' Roles are special and can't be deleted. - </panel.string> - <panel.string - name="power_folder_icon" translate="false"> - Inv_FolderClosed - </panel.string> - <panel.string - name="power_all_have_icon" translate="false"> - Checkbox_On - </panel.string> - <panel.string - name="power_partial_icon" translate="false"> - Checkbox_Off - </panel.string> - <filter_editor - layout="topleft" - top="5" - left="5" - right="-5" - height="22" - search_button_visible="false" - follows="left|top|right" - label="Filter Roles" - name="filter_input" /> - <scroll_list - column_padding="0" - draw_heading="true" - draw_stripes="false" - heading_height="23" - height="132" - layout="topleft" - search_column="1" - left="0" - follows="left|top|right" - right="-1" - name="role_list" - top_pad="2" - width="310"> - <scroll_list.columns - label="Role" - name="name" - relative_width="0.45" /> - <scroll_list.columns - label="Title" - name="title" - relative_width="0.45" /> - <scroll_list.columns - label="#" - name="members" - relative_width="0.15" /> - </scroll_list> - <button - follows="top|left" - height="23" - label="New Role" - layout="topleft" - left="0" - name="role_create" - width="100" /> - <button - follows="top|left" - height="23" - label="Copy Role" - layout="topleft" - left_pad="10" - name="role_copy" - width="100" /> - <button - height="23" - follows="top|left" - label="Delete Role" - layout="topleft" - left_pad="10" - name="role_delete" - width="100" /> - </panel> + <panel.string + name="help_text"> + Roles have a title and an allowed list of Abilities +that Members can perform. Members can belong to +one or more Roles. A group can have up to 10 Roles, +including the Everyone and Owner Roles. + </panel.string> + <panel.string + name="cant_delete_role"> + The 'Everyone' and 'Owners' Roles are special and can't be deleted. + </panel.string> + <panel.string + name="power_folder_icon" translate="false"> + Inv_FolderClosed + </panel.string> + <panel.string + name="power_all_have_icon" translate="false"> + Checkbox_On + </panel.string> + <panel.string + name="power_partial_icon" translate="false"> + Checkbox_Off + </panel.string> + <filter_editor + layout="topleft" + top="5" + left="5" + right="-5" + height="22" + search_button_visible="false" + follows="left|top|right" + label="Filter Roles" + name="filter_input" /> + <scroll_list + column_padding="0" + draw_heading="true" + draw_stripes="false" + heading_height="23" + height="138" + layout="topleft" + search_column="1" + left="0" + follows="left|top|right" + right="-1" + name="role_list" + top_pad="2"> + <scroll_list.columns + label="Role" + name="name" + relative_width="0.45" /> + <scroll_list.columns + label="Title" + name="title" + relative_width="0.45" /> + <scroll_list.columns + label="#" + name="members" + relative_width="0.15" /> + </scroll_list> + <button + follows="top|left" + height="23" + label="New Role" + layout="topleft" + left="0" + name="role_create" + width="100" /> + <button + follows="top|left" + height="23" + label="Copy Role" + layout="topleft" + left_pad="10" + name="role_copy" + width="100" /> + <button + height="23" + follows="top|left" + label="Delete Role" + layout="topleft" + left_pad="10" + name="role_delete" + width="100" /> + </panel> + <panel + border="false" + label="ABILITIES" + help_topic="roles_actions_tab" + name="actions_sub_tab" + class="panel_group_actions_subtab" + tool_tip="You can view an Ability's Description and which Roles and Members can execute the Ability."> + <panel.string + name="help_text"> + Abilities allow Members in Roles to do specific +things in this group. There's a broad variety of Abilities. + </panel.string> + <panel.string + name="power_folder_icon" translate="false"> + Inv_FolderClosed + </panel.string> + <panel.string + name="power_all_have_icon" translate="false"> + Checkbox_On + </panel.string> + <panel.string + name="power_partial_icon" translate="false"> + Checkbox_Off + </panel.string> + <filter_editor + layout="topleft" + top="5" + left="5" + right="-5" + height="22" + search_button_visible="false" + follows="left|top|right" + label="Filter Abilities" + name="filter_input" /> + <scroll_list + column_padding="0" + draw_stripes="true" + height="200" + follows="left|top|right" + layout="topleft" + left="0" + right="-1" + name="action_list" + search_column="2" + tool_tip="Select an Ability to view more details" + top_pad="5"> + <scroll_list.columns + label="" + name="icon" + width="2" /> + <scroll_list.columns + label="" + name="checkbox" + width="20" /> + <scroll_list.columns + label="" + name="action" /> + </scroll_list> + </panel> + <panel + border="false" + label="BANNED RESIDENTS" + help_topic="roles_banlist_tab" + name="banlist_sub_tab" + class="panel_group_banlist_subtab" + tool_tip="View the banned residents from this group."> + <panel.string + name="help_text"> + Any resident on the ban list will be unable to join the group. + </panel.string> + <panel.string + name="ban_count_template"> + Ban count: [COUNT]/[LIMIT] + </panel.string> + <name_list + column_padding="0" + draw_heading="true" + height="714" + follows="left|top|right" + layout="topleft" + left="0" + right="-1" + multi_select="true" + name="ban_list" + short_names="false" + top_pad="5"> + <name_list.columns + label="Resident" + name="name" + font.name="SANSSERIF_SMALL" + font.style="NORMAL" + relative_width="0.7" /> + <name_list.columns + label="Date Banned" + name="ban_date" + relative_width="0.3" /> + </name_list> + <button + follows="top|left" + height="23" + label="Ban Resident(s)" + layout="topleft" + left="3" + name="ban_create" + tool_tip="Ban residents from your group" + width="120" /> + <button + follows="top|left" + height="23" + label="Remove Ban(s)" + layout="topleft" + left_pad="5" + name="ban_delete" + tool_tip="Unban selected residents from your group" + width="120" /> + <button + follows="top|left" + height="23" + width="23" + image_overlay="Refresh_Off" + layout="topleft" + left_pad="5" + name="ban_refresh" + tool_tip="Refresh the ban list" /> + <text + type="string" + height="18" + left_pad="5" + follows="top|left" + layout="topleft" + name="ban_count" + width="100"> + </text> + </panel> + </tab_container> <panel - border="false" - height="303" - label="ABILITIES" + height="350" + background_visible="false" + bg_alpha_color="FloaterUnfocusBorderColor" layout="topleft" + follows="top|left|right" left="0" right="-1" - help_topic="roles_actions_tab" - name="actions_sub_tab" - class="panel_group_actions_subtab" - tool_tip="You can view an Ability's Description and which Roles and Members can execute the Ability." - width="310"> - <panel.string - name="help_text"> - Abilities allow Members in Roles to do specific - things in this group. There's a broad variety of Abilities. - </panel.string> - <panel.string - name="power_folder_icon" translate="false"> - Inv_FolderClosed - </panel.string> - <panel.string - name="power_all_have_icon" translate="false"> - Checkbox_On - </panel.string> - <panel.string - name="power_partial_icon" translate="false"> - Checkbox_Off - </panel.string> - <filter_editor - layout="topleft" - top="5" - left="5" - right="-5" - height="22" - search_button_visible="false" - follows="left|top|right" - label="Filter Abilities" - name="filter_input" /> - <scroll_list - column_padding="0" - draw_stripes="true" - height="200" - follows="left|top|right" - layout="topleft" - left="0" - right="-1" - name="action_list" - search_column="2" - tool_tip="Select an Ability to view more details" - top_pad="5" - width="300"> - <scroll_list.columns - label="" - name="icon" - width="2" /> - <scroll_list.columns - label="" - name="checkbox" - width="20" /> - <scroll_list.columns - label="" - name="action" /> - </scroll_list> + mouse_opaque="false" + name="members_footer" + top="325" + visible="false"> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + top="8" + text_color="EmphasisColor" + name="static" + width="300"> + Assigned Roles + </text> + <scroll_list + draw_stripes="true" + follows="left|top|right" + height="150" + layout="topleft" + left="0" + right="-1" + name="member_assigned_roles" + top_pad="0"> + <scroll_list.columns + label="" + name="checkbox" + width="20" /> + <scroll_list.columns + label="" + name="role" + width="270" /> + </scroll_list> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + top_pad="5" + text_color="EmphasisColor" + name="static2" + width="285"> + Allowed Abilities + </text> + <scroll_list + draw_stripes="true" + follows="left|top|right" + height="150" + layout="topleft" + left="0" + right="-1" + name="member_allowed_actions" + search_column="2" + tool_tip="For details of each allowed ability see the abilities tab" + top_pad="0"> + <scroll_list.columns + label="" + name="icon" + width="2" /> + <scroll_list.columns + label="" + name="checkbox" + width="20" /> + <scroll_list.columns + label="" + name="action" + width="270" /> + </scroll_list> </panel> <panel - border="false" - height="303" - label="BANNED RESIDENTS" + height="90" + background_visible="false" + bg_alpha_color="FloaterUnfocusBorderColor" layout="topleft" + follows="top|left|right" left="0" right="-1" - help_topic="roles_banlist_tab" - name="banlist_sub_tab" - class="panel_group_banlist_subtab" - tool_tip="View the banned residents from this group." - width="310"> - <panel.string - name="help_text"> - Any resident on the ban list will be unable to join the group. - </panel.string> - <panel.string - name="ban_count_template"> - Ban count: [COUNT]/[LIMIT] - </panel.string> - <name_list - column_padding="0" - draw_heading="true" - height="400" - follows="left|top|right" - layout="topleft" - left="0" - right="-1" - multi_select="true" - name="ban_list" - short_names="false" - top_pad="5"> - <name_list.columns - label="Resident" - name="name" - font.name="SANSSERIF_SMALL" - font.style="NORMAL" - relative_width="0.7" /> - <name_list.columns - label="Date Banned" - name="ban_date" - relative_width="0.3" /> - </name_list> - <button - follows="top|left" - height="23" - label="Ban Resident(s)" - layout="topleft" - left="3" - name="ban_create" - tool_tip="Ban residents from your group" - width="120" /> - <button - follows="top|left" - height="23" - label="Remove Ban(s)" - layout="topleft" - left_pad="5" - name="ban_delete" - tool_tip="Unban selected residents from your group" - width="120" /> - <button - follows="top|left" - height="23" - width="23" - image_overlay="Refresh_Off" - layout="topleft" - left_pad="5" - name="ban_refresh" - tool_tip="Refresh the ban list" - /> - <text - type="string" - height="18" - left_pad="5" - follows="top|left" - layout="topleft" - name="ban_count" - width="100"> - </text> + mouse_opaque="false" + name="members_header" + top_pad="3" + visible="false"> + <text_editor + bg_readonly_color="Transparent" + text_readonly_color="EmphasisColor" + font="SansSerifSmall" + type="string" + enabled="false" + halign="left" + layout="topleft" + top_pad="0" + follows="left|top|right" + left="0" + right="-1" + height="90" + max_length="512" + name="member_action_description" + word_wrap="true"> + This Ability is 'Eject Members from this Group'. Only an Owner can eject another Owner. + </text_editor> </panel> - </tab_container> - <panel - height="350" - background_visible="false" - bg_alpha_color="FloaterUnfocusBorderColor" - layout="topleft" - follows="top|left|right" - left="0" - right="-1" - width="313" - mouse_opaque="false" - name="members_footer" - top="325" - visible="false"> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - top="8" - text_color="EmphasisColor" - name="static" - width="300"> - Assigned Roles - </text> - <scroll_list - draw_stripes="true" - follows="left|top|right" - height="150" + <panel + height="460" + background_visible="false" + bg_alpha_color="FloaterUnfocusBorderColor" layout="topleft" + follows="top|left|right" left="0" right="-1" - name="member_assigned_roles" - top_pad="0"> - <scroll_list.columns - label="" - name="checkbox" - width="20" /> - <scroll_list.columns - label="" - name="role" - width="270" /> - </scroll_list> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - top_pad="5" - text_color="EmphasisColor" - name="static2" - width="285"> - Allowed Abilities - </text> - <scroll_list - draw_stripes="true" + mouse_opaque="false" + name="roles_footer" + top_delta="0" + top="215" + visible="false"> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + top="5" + name="static" + width="300"> + Role Name + </text> + <line_editor + type="string" + height="20" + layout="topleft" + left="0" follows="left|top|right" - height="150" - layout="topleft" - left="0" - right="-1" - name="member_allowed_actions" - search_column="2" - tool_tip="For details of each allowed ability see the abilities tab" - top_pad="0"> - <scroll_list.columns - label="" - name="icon" - width="2" /> - <scroll_list.columns - label="" - name="checkbox" - width="20" /> - <scroll_list.columns - label="" - name="action" - width="270" /> - </scroll_list> - </panel> - <panel - height="90" - background_visible="false" - bg_alpha_color="FloaterUnfocusBorderColor" - layout="topleft" - follows="top|left|right" - left="0" - right="-1" - width="313" - mouse_opaque="false" - name="members_header" - top_pad="3" - visible="false"> - <text_editor - bg_readonly_color="Transparent" - text_readonly_color="EmphasisColor" - font="SansSerifSmall" - type="string" - enabled="false" - halign="left" - layout="topleft" - top_pad="0" - follows="left|top|right" - left="0" - right="-1" - height="90" - max_length="512" - name="member_action_description" - word_wrap="true"> - This Ability is 'Eject Members from this Group'. Only an Owner can eject another Owner. - </text_editor> - </panel> - <panel - height="460" - background_visible="false" - bg_alpha_color="FloaterUnfocusBorderColor" - layout="topleft" - follows="top|left|right" - left="0" - right="-1" - width="313" - mouse_opaque="false" - name="roles_footer" - top_delta="0" - top="209" - visible="false"> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - top="5" - name="static" - width="300"> - Role Name - </text> - <line_editor - type="string" - height="20" - layout="topleft" - left="0" - follows="left|top|right" - right="-1" - max_length_bytes="20" - name="role_name" - top_pad="0" - width="300"> - </line_editor> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - name="static3" - top_pad="5" - width="300"> - Role Title - </text> - <line_editor - type="string" - height="20" - layout="topleft" - left="0" - follows="left|top|right" - right="-1" - max_length_bytes="20" - name="role_title" - top_pad="0" - width="300"> - </line_editor> - <text + right="-1" + max_length_bytes="20" + name="role_name" + top_pad="0"> + </line_editor> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + name="static3" + top_pad="5" + width="300"> + Role Title + </text> + <line_editor + type="string" + height="20" + layout="topleft" + left="0" + follows="left|top|right" + right="-1" + max_length_bytes="20" + name="role_title" + top_pad="0"> + </line_editor> + <text type="string" height="16" layout="topleft" @@ -558,192 +530,185 @@ clicking on their names. name="static2" top_pad="5" width="200"> - Description - </text> - <text_editor - type="string" - layout="topleft" - left="0" - follows="left|top|right" - right="-1" - max_length="295" - height="35" - name="role_description" - top_pad="0" - width="300" - word_wrap="true"> - </text_editor> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - text_color="EmphasisColor" - name="static4" - top_pad="5" - width="300"> - Assigned Members - </text> - <name_list - draw_stripes="true" - height="128" - layout="topleft" - left="0" - follows="left|top|right" - right="-1" - name="role_assigned_members" - top_pad="0" - width="300" /> - <check_box - height="15" - label="Reveal members" - left="5" - layout="topleft" - name="role_visible_in_list" - tool_tip="Sets whether members of this role are visible in the General tab to people outside of the group." - top_pad="4" - width="300" /> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - text_color="EmphasisColor" - name="static5" - top_pad="2" - width="300"> - Allowed Abilities - </text> - <scroll_list - draw_stripes="true" - height="140" - layout="topleft" - left="0" - follows="left|top|right" - right="-1" - name="role_allowed_actions" - search_column="2" - tool_tip="For details of each allowed ability see the abilities tab" - top_pad="0" - width="300"> - <scroll_list.columns - label="" - name="icon" - width="2" /> - <scroll_list.columns - label="" - name="checkbox" - width="20" /> - <scroll_list.columns - label="" - name="action" /> - </scroll_list> - </panel> - <panel - height="90" - background_visible="false" - bg_alpha_color="FloaterUnfocusBorderColor" - layout="topleft" - follows="top|left|right" - left="0" - right="-1" - width="313" - mouse_opaque="false" - name="roles_header" - top_pad="3" - visible="false"> - <text_editor - bg_readonly_color="Transparent" - text_readonly_color="EmphasisColor" - font="SansSerifSmall" - type="string" - enabled="false" - halign="left" - layout="topleft" - top_pad="0" - follows="left|top|right" - left="0" - right="-1" + Description + </text> + <text_editor + type="string" + layout="topleft" + left="0" + follows="left|top|right" + right="-1" + max_length="295" + height="35" + name="role_description" + top_pad="0" + word_wrap="true"> + </text_editor> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + text_color="EmphasisColor" + name="static4" + top_pad="5" + width="300"> + Assigned Members + </text> + <name_list + draw_stripes="true" + height="128" + layout="topleft" + left="0" + follows="left|top|right" + right="-1" + name="role_assigned_members" + top_pad="0" /> + <check_box + height="15" + label="Reveal members" + left="5" + layout="topleft" + name="role_visible_in_list" + tool_tip="Sets whether members of this role are visible in the General tab to people outside of the group." + top_pad="4" + width="300" /> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + text_color="EmphasisColor" + name="static5" + top_pad="2" + width="300"> + Allowed Abilities + </text> + <scroll_list + draw_stripes="true" + height="140" + layout="topleft" + left="0" + follows="left|top|right" + right="-1" + name="role_allowed_actions" + search_column="2" + tool_tip="For details of each allowed ability see the abilities tab" + top_pad="0"> + <scroll_list.columns + label="" + name="icon" + width="2" /> + <scroll_list.columns + label="" + name="checkbox" + width="20" /> + <scroll_list.columns + label="" + name="action" /> + </scroll_list> + </panel> + <panel height="90" - max_length="512" - name="role_action_description" - word_wrap="true"> - This Ability is 'Eject Members from this Group'. Only an Owner can eject another Owner. - </text_editor> - </panel> - <panel - height="424" - background_visible="false" - bg_alpha_color="FloaterUnfocusBorderColor" - layout="topleft" - follows="top|left|right" - left="0" - right="-1" - width="313" - mouse_opaque="false" - name="actions_footer" - top_delta="0" - top="255" - visible="false"> - <text_editor - bg_readonly_color="Transparent" - text_readonly_color="EmphasisColor" - font="SansSerifSmall" - type="string" - enabled="false" - halign="left" + background_visible="false" + bg_alpha_color="FloaterUnfocusBorderColor" layout="topleft" - follows="left|top|right" + follows="top|left|right" left="0" right="-1" - height="90" - max_length="512" - name="action_description" - top="0" - word_wrap="true"> - This Ability is 'Eject Members from this Group'. Only an Owner can eject another Owner. - </text_editor> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - name="static2" - top_pad="1" - width="300"> - Roles with this ability - </text> - <scroll_list - height="172" - layout="topleft" - follows="left|top|right" - left="5" - right="-1" - name="action_roles" - top_pad="0" - width="300" /> - <text - type="string" - height="16" - layout="topleft" - follows="left|top" - left="5" - name="static3" - top_pad="5" - width="300"> - Members with this ability - </text> - <name_list - height="122" - follows="left|top|right" + mouse_opaque="false" + name="roles_header" + top_pad="3" + visible="false"> + <text_editor + bg_readonly_color="Transparent" + text_readonly_color="EmphasisColor" + font="SansSerifSmall" + type="string" + enabled="false" + halign="left" + layout="topleft" + top_pad="0" + follows="left|top|right" + left="0" + right="-1" + height="90" + max_length="512" + name="role_action_description" + word_wrap="true"> + This Ability is 'Eject Members from this Group'. Only an Owner can eject another Owner. + </text_editor> + </panel> + <panel + height="513" + background_visible="false" + bg_alpha_color="FloaterUnfocusBorderColor" layout="topleft" - left="5" + follows="top|left|right" + left="0" right="-1" - name="action_members" - top_pad="0" - width="300" /> - </panel> + mouse_opaque="false" + name="actions_footer" + top_delta="0" + top="255" + visible="false"> + <text_editor + bg_readonly_color="Transparent" + text_readonly_color="EmphasisColor" + font="SansSerifSmall" + type="string" + enabled="false" + halign="left" + layout="topleft" + follows="left|top|right" + left="0" + right="-1" + height="90" + max_length="512" + name="action_description" + top="0" + word_wrap="true"> + This Ability is 'Eject Members from this Group'. Only an Owner can eject another Owner. + </text_editor> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + name="static2" + top_pad="1" + width="300"> + Roles with this ability + </text> + <scroll_list + height="216" + layout="topleft" + follows="left|top|right" + left="5" + right="-1" + name="action_roles" + top_pad="0" /> + <text + type="string" + height="16" + layout="topleft" + follows="left|top" + left="5" + name="static3" + top_pad="5" + width="300"> + Members with this ability + </text> + <name_list + height="167" + follows="left|top|right" + layout="topleft" + left="5" + right="-1" + name="action_members" + top_pad="0" /> + </panel> </panel> diff --git a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml index eb38f8bff3..d909a56733 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml @@ -407,6 +407,44 @@ value="2"/> </combo_box> <text + layout="topleft" + height="15" + left="260" + top_pad="-18" + width="100" + name="noise_suppression_label"> + Noise Suppression + </text> + <combo_box + control_name="VoiceNoiseSuppressionLevel" + layout="topleft" + height="23" + left_pad="10" + top_pad="-20" + name="noise_suppression_combo" + width="80"> + <item + label="Off" + name="noise_suppression_none" + value="0"/> + <item + label="Low" + name="noise_suppression_low" + value="1"/> + <item + label="Moderate" + name="noise_suppression_moderate" + value="2"/> + <item + label="High" + name="noise_suppression_high" + value="3"/> + <item + label="Max" + name="noise_suppression_max" + value="4"/> + </combo_box> + <text type="string" length="1" follows="left|top" @@ -497,44 +535,16 @@ label="Play sounds from gestures" top_pad="5" left="20"/> - <text - layout="topleft" + <check_box + control_name="VoiceVisualizerEnabled" height="15" + tool_tip="Check to show voice dot indicator above avatars" + label="Show voice dot above avatars" + layout="topleft" + name="voice_dot_visualizer" left="260" - top_pad="-12" - width="100" - name="noise_suppression_label"> - Noise Suppression - </text> - <combo_box - control_name="VoiceNoiseSuppressionLevel" - layout="topleft" - height="23" - left_pad="10" - top_pad="-18" - name="noise_suppression_combo" - width="80"> - <item - label="Off" - name="noise_suppression_none" - value="0"/> - <item - label="Low" - name="noise_suppression_low" - value="1"/> - <item - label="Moderate" - name="noise_suppression_moderate" - value="2"/> - <item - label="High" - name="noise_suppression_high" - value="3"/> - <item - label="Max" - name="noise_suppression_max" - value="4"/> - </combo_box> + top_pad="-15" + width="200"/> <button control_name="ShowDeviceSettings" follows="left|top" diff --git a/indra/newview/skins/default/xui/en/panel_profile_pick.xml b/indra/newview/skins/default/xui/en/panel_profile_pick.xml index 024120931f..4f441b9b49 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_pick.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_pick.xml @@ -200,6 +200,26 @@ <layout_panel follows="all" + layout="bottomleft" + left_pad="2" + name="set_to_curr_location_btn_lp" + auto_resize="false" + width="100"> + <button + name="set_to_curr_location_btn" + label="Set Location" + tool_tip="Set to Current Location" + left="0" + top="0" + height="23" + width="100" + follows="left|top" + layout="topleft" + /> + </layout_panel> + + <layout_panel + follows="all" layout="topleft" name="util_resizer_right" auto_resize="true" diff --git a/indra/newview/skins/default/xui/es/language_settings.xml b/indra/newview/skins/default/xui/es/language_settings.xml index 997293a741..7a52f7cdae 100644 --- a/indra/newview/skins/default/xui/es/language_settings.xml +++ b/indra/newview/skins/default/xui/es/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">spanish</string> <string name="MacLocale">es_ES.UTF-8</string> + <string name="macOSLocale">es_ES.UTF-8</string> <string name="DarwinLocale">es_ES.UTF-8</string> <string name="LinuxLocale">es_ES.UTF-8</string> diff --git a/indra/newview/skins/default/xui/fr/language_settings.xml b/indra/newview/skins/default/xui/fr/language_settings.xml index fdac9d65a7..fdb119ec69 100644 --- a/indra/newview/skins/default/xui/fr/language_settings.xml +++ b/indra/newview/skins/default/xui/fr/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">french</string> <string name="MacLocale">fr_FR.UTF-8</string> + <string name="macOSLocale">fr_FR.UTF-8</string> <string name="DarwinLocale">fr_FR.UTF-8</string> <string name="LinuxLocale">fr_FR.UTF-8</string> diff --git a/indra/newview/skins/default/xui/it/language_settings.xml b/indra/newview/skins/default/xui/it/language_settings.xml index 5f448fa828..7eb1b560bd 100644 --- a/indra/newview/skins/default/xui/it/language_settings.xml +++ b/indra/newview/skins/default/xui/it/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">italian</string> <string name="MacLocale">it_IT.UTF-8</string> + <string name="macOSLocale">it_IT.UTF-8</string> <string name="DarwinLocale">it_IT.UTF-8</string> <string name="LinuxLocale">it_IT.UTF-8</string> diff --git a/indra/newview/skins/default/xui/ja/language_settings.xml b/indra/newview/skins/default/xui/ja/language_settings.xml index facae22acf..c94a16cee0 100644 --- a/indra/newview/skins/default/xui/ja/language_settings.xml +++ b/indra/newview/skins/default/xui/ja/language_settings.xml @@ -6,6 +6,9 @@ <string name="MacLocale"> ja_JP.UTF-8 </string> + <string name="macOSLocale"> + ja_JP.UTF-8 + </string> <string name="DarwinLocale"> ja_JP.UTF-8 </string> diff --git a/indra/newview/skins/default/xui/pl/language_settings.xml b/indra/newview/skins/default/xui/pl/language_settings.xml index 0057ca530c..9993062487 100644 --- a/indra/newview/skins/default/xui/pl/language_settings.xml +++ b/indra/newview/skins/default/xui/pl/language_settings.xml @@ -2,6 +2,7 @@ <strings> <string name="MicrosoftLocale">polish</string> <string name="MacLocale">pl_PL.UTF-8</string> + <string name="macOSLocale">pl_PL.UTF-8</string> <string name="DarwinLocale">pl_PL.UTF-8</string> <string name="LinuxLocale">pl_PL.UTF-8</string> <string name="TimeHour">hour,datetime,slt</string> diff --git a/indra/newview/skins/default/xui/pt/language_settings.xml b/indra/newview/skins/default/xui/pt/language_settings.xml index 8799475ace..d5be208eb3 100644 --- a/indra/newview/skins/default/xui/pt/language_settings.xml +++ b/indra/newview/skins/default/xui/pt/language_settings.xml @@ -5,6 +5,7 @@ <!-- Locale Information --> <string name="MicrosoftLocale">portuguese</string> <string name="MacLocale">pt_PT.UTF-8</string> + <string name="macOSLocale">pt_PT.UTF-8</string> <string name="DarwinLocale">pt_PT.UTF-8</string> <string name="LinuxLocale">pt_PT.UTF-8</string> diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index 151aadfd4b..acbf019034 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -57,12 +57,12 @@ std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUt return {}; } -std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) +std::string LLTrans::getCountString(std::string_view language, std::string_view xml_desc, S32 count) { count_string_t key(xml_desc, count); if (gCountString.find(key) == gCountString.end()) { - return std::string("Couldn't find ") + xml_desc; + return std::string("Couldn't find ") + static_cast<std::string>(xml_desc); } return gCountString[ count_string_t(xml_desc, count) ]; } diff --git a/scripts/perf/logsdir.py b/scripts/perf/logsdir.py new file mode 100644 index 0000000000..5ab45a28b6 --- /dev/null +++ b/scripts/perf/logsdir.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +"""\ +@file logsdir.py +@author Nat Goodspeed +@date 2024-09-12 +@brief Locate the Second Life logs directory for the current user on the + current platform. + +$LicenseInfo:firstyear=2024&license=viewerlgpl$ +Copyright (c) 2024, Linden Research, Inc. +$/LicenseInfo$ +""" + +import os +from pathlib import Path +import platform + +class Error(Exception): + pass + +# logic used by SLVersionChecker +def logsdir(): + app = 'SecondLife' + system = platform.system() + if (system == 'Darwin'): + base_dir = os.path.join(os.path.expanduser('~'), + 'Library','Application Support',app) + elif (system == 'Linux'): + base_dir = os.path.join(os.path.expanduser('~'), + '.' + app.lower()) + elif (system == 'Windows'): + appdata = os.getenv('APPDATA') + base_dir = os.path.join(appdata, app) + else: + raise ValueError("Unsupported platform '%s'" % system) + + return os.path.join(base_dir, 'logs') + +def latest_file(dirpath, pattern): + files = Path(dirpath).glob(pattern) + sort = [(p.stat().st_mtime, p) for p in files if p.is_file()] + sort.sort(reverse=True) + try: + return sort[0][1] + except IndexError: + raise Error(f'No {pattern} files in {dirpath}') diff --git a/scripts/perf/profile_cmp.py b/scripts/perf/profile_cmp.py new file mode 100644 index 0000000000..34281b8d01 --- /dev/null +++ b/scripts/perf/profile_cmp.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +"""\ +@file profile_cmp.py +@author Nat Goodspeed +@date 2024-09-13 +@brief Compare a frame profile stats file with a similar baseline file. + +$LicenseInfo:firstyear=2024&license=viewerlgpl$ +Copyright (c) 2024, Linden Research, Inc. +$/LicenseInfo$ +""" + +from datetime import datetime +import json +from logsdir import Error, latest_file, logsdir +from pathlib import Path +import sys + +# variance that's ignorable +DEFAULT_EPSILON = 0.03 # 3% + +def compare(baseline, test, epsilon=DEFAULT_EPSILON): + if Path(baseline).samefile(test): + print(f'{baseline} same as\n{test}\nAnalysis moot.') + return + + with open(baseline) as inf: + bdata = json.load(inf) + with open(test) as inf: + tdata = json.load(inf) + print(f'baseline {baseline}\ntestfile {test}') + + for k, tv in tdata['context'].items(): + bv = bdata['context'].get(k) + if bv != tv: + print(f'baseline {k}={bv} vs.\ntestfile {k}={tv}') + + btime = bdata['context'].get('time') + ttime = tdata['context'].get('time') + if btime and ttime: + print('testfile newer by', + datetime.fromisoformat(ttime) - datetime.fromisoformat(btime)) + + # The following ignores totals and unused shaders, except to the extent + # that some shaders were used in the baseline but not in the recent test + # or vice-versa. While the viewer considers that a shader has been used if + # 'binds' is nonzero, we exclude any whose 'time' is zero to avoid zero + # division. + bshaders = {s['name']: s for s in bdata['shaders'] if s['time'] and s['samples']} + tshaders = {s['name']: s for s in tdata['shaders'] if s['time']} + + bothshaders = set(bshaders).intersection(tshaders) + deltas = [] + for shader in bothshaders: + bshader = bshaders[shader] + tshader = tshaders[shader] + bthruput = bshader['samples']/bshader['time'] + tthruput = tshader['samples']/tshader['time'] + delta = (tthruput - bthruput)/bthruput + if abs(delta) > epsilon: + deltas.append((delta, shader, bthruput, tthruput)) + + # ascending order of performance gain: put the most egregious performance + # hits at the top of the list + deltas.sort() + print(f'{len(deltas)} shaders showed nontrivial performance differences ' + '(millon samples/sec):') + namelen = max(len(s[1]) for s in deltas) if deltas else 0 + for delta, shader, bthruput, tthruput in deltas: + print(f' {shader.rjust(namelen)} {delta*100:6.1f}% ' + f'{bthruput/1000000:8.2f} -> {tthruput/1000000:8.2f}') + + tunused = set(bshaders).difference(tshaders) + print(f'{len(tunused)} baseline shaders not used in test:') + for s in tunused: + print(f' {s}') + bunused = set(tshaders).difference(bshaders) + print(f'{len(bunused)} shaders newly used in test:') + for s in bunused: + print(f' {s}') + +def main(*raw_args): + from argparse import ArgumentParser + parser = ArgumentParser(description=""" +%(prog)s compares a baseline JSON file from Develop -> Render Tests -> Frame +Profile to another such file from a more recent test. It identifies shaders +that have gained and lost in throughput. +""") + parser.add_argument('-e', '--epsilon', type=float, default=int(DEFAULT_EPSILON*100), + help="""percent variance considered ignorable (default %(default)s%%)""") + parser.add_argument('baseline', + help="""baseline profile filename to compare against""") + parser.add_argument('test', nargs='?', + help="""test profile filename to compare + (default is most recent)""") + args = parser.parse_args(raw_args) + compare(args.baseline, + args.test or latest_file(logsdir(), 'profile.*.json'), + epsilon=(args.epsilon / 100.)) + +if __name__ == "__main__": + try: + sys.exit(main(*sys.argv[1:])) + except (Error, OSError, json.JSONDecodeError) as err: + sys.exit(str(err)) diff --git a/scripts/perf/profile_csv.py b/scripts/perf/profile_csv.py new file mode 100644 index 0000000000..7a6b2b338e --- /dev/null +++ b/scripts/perf/profile_csv.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +"""\ +@file profile_csv.py +@author Nat Goodspeed +@date 2024-09-12 +@brief Convert a JSON file from Develop -> Render Tests -> Frame Profile to CSV + +$LicenseInfo:firstyear=2024&license=viewerlgpl$ +Copyright (c) 2024, Linden Research, Inc. +$/LicenseInfo$ +""" + +import json +from logsdir import Error, latest_file, logsdir +import sys + +def convert(path, totals=True, unused=True, file=sys.stdout): + with open(path) as inf: + data = json.load(inf) + # print path to sys.stderr in case user is redirecting stdout + print(path, file=sys.stderr) + + print('"name", "file1", "file2", "time", "binds", "samples", "triangles"', file=file) + + if totals: + t = data['totals'] + print(f'"totals", "", "", {t["time"]}, {t["binds"]}, {t["samples"]}, {t["triangles"]}', + file=file) + + for sh in data['shaders']: + print(f'"{sh["name"]}", "{sh["files"][0]}", "{sh["files"][1]}", ' + f'{sh["time"]}, {sh["binds"]}, {sh["samples"]}, {sh["triangles"]}', file=file) + + if unused: + for u in data['unused']: + print(f'"{u}", "", "", 0, 0, 0, 0', file=file) + +def main(*raw_args): + from argparse import ArgumentParser + parser = ArgumentParser(description=""" +%(prog)s converts a JSON file from Develop -> Render Tests -> Frame Profile to +a more-or-less equivalent CSV file. It expands the totals stats and unused +shaders list to full shaders lines. +""") + parser.add_argument('-t', '--totals', action='store_false', default=True, + help="""omit totals from CSV file""") + parser.add_argument('-u', '--unused', action='store_false', default=True, + help="""omit unused shaders from CSV file""") + parser.add_argument('path', nargs='?', + help="""profile filename to convert (default is most recent)""") + + args = parser.parse_args(raw_args) + convert(args.path or latest_file(logsdir(), 'profile.*.json'), + totals=args.totals, unused=args.unused) + +if __name__ == "__main__": + try: + sys.exit(main(*sys.argv[1:])) + except (Error, OSError, json.JSONDecodeError) as err: + sys.exit(str(err)) diff --git a/scripts/perf/profile_pretty.py b/scripts/perf/profile_pretty.py new file mode 100644 index 0000000000..405b14b373 --- /dev/null +++ b/scripts/perf/profile_pretty.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""\ +@file profile_pretty.py +@author Nat Goodspeed +@date 2024-09-12 +@brief Pretty-print a JSON file from Develop -> Render Tests -> Frame Profile + +$LicenseInfo:firstyear=2024&license=viewerlgpl$ +Copyright (c) 2024, Linden Research, Inc. +$/LicenseInfo$ +""" + +import json +from logsdir import Error, latest_file, logsdir +import sys + +def pretty(path): + with open(path) as inf: + data = json.load(inf) + # print path to sys.stderr in case user is redirecting stdout + print(path, file=sys.stderr) + json.dump(data, sys.stdout, indent=4) + +def main(*raw_args): + from argparse import ArgumentParser + parser = ArgumentParser(description=""" +%(prog)s pretty-prints a JSON file from Develop -> Render Tests -> Frame Profile. +The file produced by the viewer is a single dense line of JSON. +""") + parser.add_argument('path', nargs='?', + help="""profile filename to pretty-print (default is most recent)""") + + args = parser.parse_args(raw_args) + pretty(args.path or latest_file(logsdir(), 'profile.*.json')) + +if __name__ == "__main__": + try: + sys.exit(main(*sys.argv[1:])) + except (Error, OSError, json.JSONDecodeError) as err: + sys.exit(str(err)) |