diff options
Diffstat (limited to 'indra')
140 files changed, 2980 insertions, 2698 deletions
diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 0138a1426e..04ce9f1333 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -26,6 +26,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/llcommon/hexdump.h b/indra/llcommon/hexdump.h index ab5ba2b16d..4b734426a3 100755 --- a/indra/llcommon/hexdump.h +++ b/indra/llcommon/hexdump.h @@ -25,7 +25,7 @@ namespace LL class hexdump { public: - hexdump(const std::string_view& data): + hexdump(std::string_view data): hexdump(data.data(), data.length()) {} @@ -66,7 +66,7 @@ private: class hexmix { public: - hexmix(const std::string_view& data): + hexmix(std::string_view data): mData(data) {} diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 820ba05f30..eca611ad6c 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -226,7 +226,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; diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h index 2fbb26dc1a..d4b063f88c 100644 --- a/indra/llcommon/lldefs.h +++ b/indra/llcommon/lldefs.h @@ -28,6 +28,7 @@ #define LL_LLDEFS_H #include "stdtypes.h" +#include <cassert> #include <type_traits> // Often used array indices @@ -169,6 +170,38 @@ constexpr U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 + // llclampb(a) // clamps a to [0 .. 255] // +// llless(d0, d1) safely compares d0 < d1 even if one is signed and the other +// is unsigned. A simple (d0 < d1) expression converts the signed operand to +// unsigned before comparing. If the signed operand is negative, that flips +// the negative value to a huge positive value, producing the wrong answer! +// llless() specifically addresses that case. +template <typename T0, typename T1> +inline bool llless(T0 d0, T1 d1) +{ + if constexpr (std::is_signed_v<T0> && ! std::is_signed_v<T1>) + { + // T0 signed, T1 unsigned: negative d0 is less than any unsigned d1 + if (d0 < 0) + return true; + // both are non-negative: explicitly cast to avoid C4018 + return std::make_unsigned_t<T0>(d0) < d1; + } + else if constexpr (! std::is_signed_v<T0> && std::is_signed_v<T1>) + { + // T0 unsigned, T1 signed: any unsigned d0 is greater than negative d1 + if (d1 < 0) + return false; + // both are non-negative: explicitly cast to avoid C4018 + return d0 < std::make_unsigned_t<T1>(d1); + } + else + { + // both T0 and T1 are signed, or both are unsigned: + // straightforward comparison works + return d0 < d1; + } +} + // recursion tail template <typename T> inline auto llmax(T data) @@ -180,7 +213,7 @@ template <typename T0, typename T1, typename... Ts> inline auto llmax(T0 d0, T1 d1, Ts... rest) { auto maxrest = llmax(d1, rest...); - return (d0 > maxrest)? d0 : maxrest; + return llless(maxrest, d0)? d0 : maxrest; } // recursion tail @@ -194,12 +227,28 @@ template <typename T0, typename T1, typename... Ts> inline auto llmin(T0 d0, T1 d1, Ts... rest) { auto minrest = llmin(d1, rest...); - return (d0 < minrest) ? d0 : minrest; + return llless(d0, minrest) ? d0 : minrest; } template <typename A, typename MIN, typename MAX> inline A llclamp(A a, MIN minval, MAX maxval) { + // The only troublesome case is if A is unsigned and either minval or + // maxval is both signed and negative. Casting a negative number to + // unsigned flips it to a huge positive number, making this llclamp() call + // ineffective. + if constexpr (! std::is_signed_v<A>) + { + if constexpr (std::is_signed_v<MIN>) + { + assert(minval >= 0); + } + if constexpr (std::is_signed_v<MAX>) + { + assert(maxval >= 0); + } + } + A aminval{ static_cast<A>(minval) }, amaxval{ static_cast<A>(maxval) }; if ( a < aminval ) { diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 03418e9bad..b5c681e60a 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -41,6 +41,7 @@ #include <boost/iterator/indirect_iterator.hpp> #include <boost/iterator/filter_iterator.hpp> +#include "llprofiler.h" #include "lockstatic.h" #include "stringize.h" diff --git a/indra/llcommon/llleaplistener.cpp b/indra/llcommon/llleaplistener.cpp index b81ee66ba9..9742c9e9de 100644 --- a/indra/llcommon/llleaplistener.cpp +++ b/indra/llcommon/llleaplistener.cpp @@ -54,7 +54,7 @@ return features; } -LLLeapListener::LLLeapListener(const std::string_view& caller, const Callback& callback): +LLLeapListener::LLLeapListener(std::string_view caller, const Callback& callback): // Each LEAP plugin has an instance of this listener. Make the command // pump name difficult for other such plugins to guess. LLEventAPI(LLUUID::generateNewID().asString(), diff --git a/indra/llcommon/llleaplistener.h b/indra/llcommon/llleaplistener.h index d36d2ff8db..d38a6f4ace 100644 --- a/indra/llcommon/llleaplistener.h +++ b/indra/llcommon/llleaplistener.h @@ -28,7 +28,7 @@ public: * event is received. */ using Callback = std::function<bool(const std::string& pump, const LLSD& data)>; - LLLeapListener(const std::string_view& caller, const Callback& callback); + LLLeapListener(std::string_view caller, const Callback& callback); ~LLLeapListener(); LLEventPump& getReplyPump() { return mReplyPump; } 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/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..005864a843 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -31,6 +31,7 @@ #include "llfasttimer.h" #include "llsd.h" #include <vector> +#include <sstream> #if LL_WINDOWS #include "llwin32headerslean.h" @@ -141,10 +142,10 @@ std::string rawstr_to_utf8(const std::string& raw) return wstring_to_utf8str(wstr); } -std::ptrdiff_t wchar_to_utf8chars(llwchar in_char, char* outchars) +std::string wchar_to_utf8chars(llwchar in_char) { - U32 cur_char = (U32)in_char; - char* base = outchars; + U32 cur_char(in_char); + char buff[8], *outchars = buff; if (cur_char < 0x80) { *outchars++ = (U8)cur_char; @@ -189,7 +190,7 @@ std::ptrdiff_t wchar_to_utf8chars(llwchar in_char, char* outchars) LL_WARNS() << "Invalid Unicode character " << cur_char << "!" << LL_ENDL; *outchars++ = LL_UNKNOWN_CHAR; } - return outchars - base; + return { buff, std::string::size_type(outchars - buff) }; } auto utf16chars_to_wchar(const U16* inchars, llwchar* outchar) @@ -214,7 +215,8 @@ auto utf16chars_to_wchar(const U16* inchars, llwchar* outchar) llutf16string wstring_to_utf16str(const llwchar* utf32str, size_t len) { - llutf16string out; + // ostringstream for llutf16string + std::basic_ostringstream<U16> out; S32 i = 0; while (i < len) @@ -222,16 +224,16 @@ llutf16string wstring_to_utf16str(const llwchar* utf32str, size_t len) U32 cur_char = utf32str[i]; if (cur_char > 0xFFFF) { - out += (0xD7C0 + (cur_char >> 10)); - out += (0xDC00 | (cur_char & 0x3FF)); + out.put(U16(0xD7C0 + (cur_char >> 10))); + out.put(U16(0xDC00 | (cur_char & 0x3FF))); } else { - out += cur_char; + out.put(U16(cur_char)); } i++; } - return out; + return out.str(); } llutf16string utf8str_to_utf16str( const char* utf8str, size_t len ) @@ -242,8 +244,16 @@ llutf16string utf8str_to_utf16str( const char* utf8str, size_t len ) LLWString utf16str_to_wstring(const U16* utf16str, size_t len) { - LLWString wout; - if (len == 0) return wout; + if (len == 0) return {}; + + // MS doesn't support std::basic_ostringstream<llwchar>; have to work + // around it. + std::vector<llwchar> wout; + // We want to minimize allocations. We don't know how many llwchars we'll + // generate from this utf16str, but we do know the length should be at + // most len. So if we reserve 'len' llwchars, we shouldn't need to expand + // wout incrementally. + wout.reserve(len); S32 i = 0; const U16* chars16 = utf16str; @@ -251,9 +261,9 @@ LLWString utf16str_to_wstring(const U16* utf16str, size_t len) { llwchar cur_char; i += (S32)utf16chars_to_wchar(chars16+i, &cur_char); - wout += cur_char; + wout.push_back(cur_char); } - return wout; + return { wout.begin(), wout.end() }; } // Length in llwchar (UTF-32) of the first len units (16 bits) of the given UTF-16 string. @@ -367,13 +377,12 @@ std::string wchar_utf8_preview(const llwchar wc) std::ostringstream oss; oss << std::hex << std::uppercase << (U32)wc; - U8 out_bytes[8]; - U32 size = (U32)wchar_to_utf8chars(wc, (char*)out_bytes); + auto out_bytes = wchar_to_utf8chars(wc); - if (size > 1) + if (out_bytes.length() > 1) { oss << " ["; - for (U32 i = 0; i < size; ++i) + for (U32 i = 0; i < out_bytes.length(); ++i) { if (i) { @@ -399,7 +408,14 @@ S32 wstring_utf8_length(const LLWString& wstr) LLWString utf8str_to_wstring(const char* utf8str, size_t len) { - LLWString wout; + // MS doesn't support std::basic_ostringstream<llwchar>; have to work + // around it. + std::vector<llwchar> wout; + // We want to minimize allocations. We don't know how many llwchars we'll + // generate from this utf8str, but we do know the length should be at most + // len. So if we reserve 'len' llwchars, we shouldn't need to expand wout + // incrementally. + wout.reserve(len); S32 i = 0; while (i < len) @@ -442,7 +458,7 @@ LLWString utf8str_to_wstring(const char* utf8str, size_t len) } else { - wout += LL_UNKNOWN_CHAR; + wout.push_back(LL_UNKNOWN_CHAR); ++i; continue; } @@ -479,26 +495,21 @@ LLWString utf8str_to_wstring(const char* utf8str, size_t len) } } - wout += unichar; + wout.push_back(unichar); ++i; } - return wout; + return { wout.begin(), wout.end() }; } std::string wstring_to_utf8str(const llwchar* utf32str, size_t len) { - std::string out; + std::ostringstream out; - S32 i = 0; - while (i < len) + for (size_t i = 0; i < len; ++i) { - char tchars[8]; /* Flawfinder: ignore */ - auto n = wchar_to_utf8chars(utf32str[i], tchars); - tchars[n] = 0; - out += tchars; - i++; + out << wchar_to_utf8chars(utf32str[i]); } - return out; + return out.str(); } std::string utf16str_to_utf8str(const U16* utf16str, size_t len) @@ -686,7 +697,21 @@ llwchar utf8str_to_wchar(const std::string& utf8str, size_t offset, size_t lengt std::string utf8str_showBytesUTF8(const std::string& utf8str) { - std::string result; + std::ostringstream result; + char lastchar = '\0'; + auto append = [&result, &lastchar](char c) + { + lastchar = c; + result << c; + }; + auto appends = [&result, &lastchar](const std::string& s) + { + if (! s.empty()) + { + lastchar = s.back(); + result << s; + } + }; bool in_sequence = false; size_t sequence_size = 0; @@ -695,9 +720,9 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str) auto open_sequence = [&]() { - if (!result.empty() && result.back() != '\n') - result += '\n'; // Use LF as a separator before new UTF-8 sequence - result += '['; + if (lastchar != '\0' && lastchar != '\n') + append('\n'); // Use LF as a separator before new UTF-8 sequence + append('['); in_sequence = true; }; @@ -706,9 +731,9 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str) llwchar unicode = utf8str_to_wchar(utf8str, byte_index - sequence_size, sequence_size); if (unicode != LL_UNKNOWN_CHAR) { - result += llformat("+%04X", unicode); + appends(llformat("+%04X", unicode)); } - result += ']'; + append(']'); in_sequence = false; sequence_size = 0; }; @@ -729,9 +754,9 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str) } else // Continue the same UTF-8 sequence { - result += '.'; + append('.'); } - result += llformat("%02X", byte); // The byte is represented in hexadecimal form + appends(llformat("%02X", byte)); // The byte is represented in hexadecimal form ++sequence_size; } else // ASCII symbol is represented as a character @@ -741,10 +766,10 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str) close_sequence(); if (byte != '\n') { - result += '\n'; // Use LF as a separator between UTF-8 and ASCII + append('\n'); // Use LF as a separator between UTF-8 and ASCII } } - result += byte; + append(byte); } ++byte_index; } @@ -754,7 +779,7 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str) close_sequence(); } - return result; + return result.str(); } // Search for any emoji symbol, return true if found @@ -1587,7 +1612,7 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) LL_PROFILE_ZONE_SCOPED_CATEGORY_STRING; S32 res = 0; - std::string output; + std::ostringstream output; std::vector<std::string> tokens; std::string::size_type start = 0; @@ -1595,7 +1620,7 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) std::string::size_type key_start = 0; while ((key_start = getSubstitution(s, start, tokens)) != std::string::npos) { - output += std::string(s, prev_start, key_start-prev_start); + output << std::string(s, prev_start, key_start-prev_start); prev_start = start; bool found_replacement = false; @@ -1636,20 +1661,20 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) if (found_replacement) { - output += replacement; + output << replacement; res++; } else { // we had no replacement, use the string as is // e.g. "hello [MISSING_REPLACEMENT]" or "-=[Stylized Name]=-" - output += std::string(s, key_start, start-key_start); + output << std::string(s, key_start, start-key_start); } tokens.clear(); } // send the remainder of the string (with no further matches for bracketed names) - output += std::string(s, start); - s = output; + output << std::string(s, start); + s = output.str(); return res; } @@ -1665,7 +1690,7 @@ S32 LLStringUtil::format(std::string& s, const LLSD& substitutions) return res; } - std::string output; + std::ostringstream output; std::vector<std::string> tokens; std::string::size_type start = 0; @@ -1673,7 +1698,7 @@ S32 LLStringUtil::format(std::string& s, const LLSD& substitutions) std::string::size_type key_start = 0; while ((key_start = getSubstitution(s, start, tokens)) != std::string::npos) { - output += std::string(s, prev_start, key_start-prev_start); + output << std::string(s, prev_start, key_start-prev_start); prev_start = start; bool found_replacement = false; @@ -1706,20 +1731,20 @@ S32 LLStringUtil::format(std::string& s, const LLSD& substitutions) if (found_replacement) { - output += replacement; + output << replacement; res++; } else { // we had no replacement, use the string as is // e.g. "hello [MISSING_REPLACEMENT]" or "-=[Stylized Name]=-" - output += std::string(s, key_start, start-key_start); + output << std::string(s, key_start, start-key_start); } tokens.clear(); } // send the remainder of the string (with no further matches for bracketed names) - output += std::string(s, start); - s = output; + output << std::string(s, start); + s = output.str(); return res; } diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index e4be1efaed..b552aede82 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -707,7 +707,11 @@ ll_convert_forms(ll_convert_alias, LLWString, std::string, utf8str_to_ // Same function, better name. JC inline LLWString utf8string_to_wstring(const std::string& utf8_string) { return utf8str_to_wstring(utf8_string); } -LL_COMMON_API std::ptrdiff_t wchar_to_utf8chars(llwchar inchar, char* outchars); +// return a UTF-8 string representation of a single llwchar, which we +// occasionally require: +// cheaper than ll_convert_to<std::string>(LLWString(1, inchar)) +LL_COMMON_API std::string wchar_to_utf8chars(llwchar inchar); +ll_convert_alias(std::string, llwchar, wchar_to_utf8chars(in)); ll_convert_forms(ll_convert_alias, std::string, LLWString, wstring_to_utf8str); ll_convert_forms(ll_convert_u16_alias, std::string, llutf16string, utf16str_to_utf8str); diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp index f7876e4aaf..2557fd0cc9 100644 --- a/indra/llcommon/lua_function.cpp +++ b/indra/llcommon/lua_function.cpp @@ -24,6 +24,7 @@ #include <unordered_map> // external library headers // other Linden headers +#include "commoncontrol.h" #include "fsyspath.h" #include "hexdump.h" #include "llcoros.h" @@ -529,9 +530,35 @@ int lua_metaipair(lua_State* L); } // anonymous namespace LuaState::LuaState(script_finished_fn cb): - mCallback(cb), - mState(luaL_newstate()) + mCallback(cb) { + /*---------------------------- feature flag ----------------------------*/ + try + { + mFeature = LL::CommonControl::get("Global", "LuaFeature").asBoolean(); + } + catch (const LL::CommonControl::NoListener&) + { + // If this program doesn't have an LLViewerControlListener, + // it's probably a test program; go ahead. + mFeature = true; + } + catch (const LL::CommonControl::ParamError&) + { + // We found LLViewerControlListener, but its settings do not include + // "LuaFeature". Hmm, fishy: that feature flag was introduced at the + // same time as this code. + mFeature = false; + } + // None of the rest of this is necessary if we're not going to run anything. + if (! mFeature) + { + mError = "Lua feature disabled"; + return; + } + /*---------------------------- feature flag ----------------------------*/ + + mState = luaL_newstate(); // Ensure that we can always find this LuaState instance, given the // lua_State we just created or any of its coroutines. sLuaStateMap.emplace(mState, this); @@ -682,75 +709,86 @@ int lua_metaipair(lua_State* L) LuaState::~LuaState() { - // We're just about to destroy this lua_State mState. Did this Lua chunk - // register any atexit() functions? - lluau_checkstack(mState, 3); - // look up Registry.atexit - lua_getfield(mState, LUA_REGISTRYINDEX, "atexit"); - // stack contains Registry.atexit - if (lua_istable(mState, -1)) + // If we're unwinding the stack due to an exception, don't bother trying + // to call any callbacks -- either Lua or C++. + if (std::uncaught_exceptions() != 0) + return; + + /*---------------------------- feature flag ----------------------------*/ + if (mFeature) + /*---------------------------- feature flag ----------------------------*/ { - // We happen to know that Registry.atexit is built by appending array - // entries using table.insert(). That's important because it means - // there are no holes, and therefore lua_objlen() should be correct. - // That's important because we walk the atexit table backwards, to - // destroy last the things we created (passed to LL.atexit()) first. - int len(lua_objlen(mState, -1)); - LL_DEBUGS("Lua") << LLCoros::getName() << ": Registry.atexit is a table with " - << len << " entries" << LL_ENDL; - - // Push debug.traceback() onto the stack as lua_pcall()'s error - // handler function. On error, lua_pcall() calls the specified error - // handler function with the original error message; the message - // returned by the error handler is then returned by lua_pcall(). - // Luau's debug.traceback() is called with a message to prepend to the - // returned traceback string. Almost as if they'd been designed to - // work together... - lua_getglobal(mState, "debug"); - lua_getfield(mState, -1, "traceback"); - // ditch "debug" - lua_remove(mState, -2); - // stack now contains atexit, debug.traceback() - - for (int i(len); i >= 1; --i) + // We're just about to destroy this lua_State mState. Did this Lua chunk + // register any atexit() functions? + lluau_checkstack(mState, 3); + // look up Registry.atexit + lua_getfield(mState, LUA_REGISTRYINDEX, "atexit"); + // stack contains Registry.atexit + if (lua_istable(mState, -1)) { - lua_pushinteger(mState, i); - // stack contains Registry.atexit, debug.traceback(), i - lua_gettable(mState, -3); - // stack contains Registry.atexit, debug.traceback(), atexit[i] - // Call atexit[i](), no args, no return values. - // Use lua_pcall() because errors in any one atexit() function - // shouldn't cancel the rest of them. Pass debug.traceback() as - // the error handler function. - LL_DEBUGS("Lua") << LLCoros::getName() - << ": calling atexit(" << i << ")" << LL_ENDL; - if (lua_pcall(mState, 0, 0, -2) != LUA_OK) + // We happen to know that Registry.atexit is built by appending array + // entries using table.insert(). That's important because it means + // there are no holes, and therefore lua_objlen() should be correct. + // That's important because we walk the atexit table backwards, to + // destroy last the things we created (passed to LL.atexit()) first. + int len(lua_objlen(mState, -1)); + LL_DEBUGS("Lua") << LLCoros::getName() << ": Registry.atexit is a table with " + << len << " entries" << LL_ENDL; + + // Push debug.traceback() onto the stack as lua_pcall()'s error + // handler function. On error, lua_pcall() calls the specified error + // handler function with the original error message; the message + // returned by the error handler is then returned by lua_pcall(). + // Luau's debug.traceback() is called with a message to prepend to the + // returned traceback string. Almost as if they'd been designed to + // work together... + lua_getglobal(mState, "debug"); + lua_getfield(mState, -1, "traceback"); + // ditch "debug" + lua_remove(mState, -2); + // stack now contains atexit, debug.traceback() + + for (int i(len); i >= 1; --i) { - auto error{ lua_tostdstring(mState, -1) }; - LL_WARNS("Lua") << LLCoros::getName() - << ": atexit(" << i << ") error: " << error << LL_ENDL; - // pop error message - lua_pop(mState, 1); + lua_pushinteger(mState, i); + // stack contains Registry.atexit, debug.traceback(), i + lua_gettable(mState, -3); + // stack contains Registry.atexit, debug.traceback(), atexit[i] + // Call atexit[i](), no args, no return values. + // Use lua_pcall() because errors in any one atexit() function + // shouldn't cancel the rest of them. Pass debug.traceback() as + // the error handler function. + LL_DEBUGS("Lua") << LLCoros::getName() + << ": calling atexit(" << i << ")" << LL_ENDL; + if (lua_pcall(mState, 0, 0, -2) != LUA_OK) + { + auto error{ lua_tostdstring(mState, -1) }; + LL_WARNS("Lua") << LLCoros::getName() + << ": atexit(" << i << ") error: " << error << LL_ENDL; + // pop error message + lua_pop(mState, 1); + } + LL_DEBUGS("Lua") << LLCoros::getName() << ": atexit(" << i << ") done" << LL_ENDL; + // lua_pcall() has already popped atexit[i]: + // stack contains atexit, debug.traceback() } - LL_DEBUGS("Lua") << LLCoros::getName() << ": atexit(" << i << ") done" << LL_ENDL; - // lua_pcall() has already popped atexit[i]: - // stack contains atexit, debug.traceback() + // pop debug.traceback() + lua_pop(mState, 1); } - // pop debug.traceback() + // pop Registry.atexit (either table or nil) lua_pop(mState, 1); - } - // pop Registry.atexit (either table or nil) - lua_pop(mState, 1); - lua_close(mState); + // with the demise of this LuaState, remove sLuaStateMap entry + sLuaStateMap.erase(mState); + + lua_close(mState); + } if (mCallback) { // mError potentially set by previous checkLua() call(s) mCallback(mError); } - // with the demise of this LuaState, remove sLuaStateMap entry - sLuaStateMap.erase(mState); } bool LuaState::checkLua(const std::string& desc, int r) @@ -768,6 +806,14 @@ bool LuaState::checkLua(const std::string& desc, int r) std::pair<int, LLSD> LuaState::expr(const std::string& desc, const std::string& text) { + /*---------------------------- feature flag ----------------------------*/ + if (! mFeature) + { + // fake an error + return { -1, stringize("Not running ", desc) }; + } + /*---------------------------- feature flag ----------------------------*/ + set_interrupts_counter(0); lua_callbacks(mState)->interrupt = [](lua_State *L, int gc) @@ -843,6 +889,9 @@ std::pair<int, LLSD> LuaState::expr(const std::string& desc, const std::string& return result; } +// We think we don't need mFeature tests in the rest of these LuaState methods +// because, if expr() isn't running code, nobody should be calling any of them. + LuaListener& LuaState::obtainListener(lua_State* L) { lluau_checkstack(L, 2); @@ -946,7 +995,8 @@ lua_function(atexit, "atexit(function): " *****************************************************************************/ LuaPopper::~LuaPopper() { - if (mCount) + // If we're unwinding the C++ stack due to an exception, don't pop! + if (std::uncaught_exceptions() == 0 && mCount) { lua_pop(mState, mCount); } @@ -955,8 +1005,8 @@ LuaPopper::~LuaPopper() /***************************************************************************** * LuaFunction class *****************************************************************************/ -LuaFunction::LuaFunction(const std::string_view& name, lua_CFunction function, - const std::string_view& helptext) +LuaFunction::LuaFunction(std::string_view name, lua_CFunction function, + std::string_view helptext) { const auto& [registry, lookup] = getState(); registry.emplace(name, Registry::mapped_type{ function, helptext }); diff --git a/indra/llcommon/lua_function.h b/indra/llcommon/lua_function.h index e28656c03b..10c201c234 100644 --- a/indra/llcommon/lua_function.h +++ b/indra/llcommon/lua_function.h @@ -115,8 +115,11 @@ public: void check_interrupts_counter(); private: + /*---------------------------- feature flag ----------------------------*/ + bool mFeature{ false }; + /*---------------------------- feature flag ----------------------------*/ script_finished_fn mCallback; - lua_State* mState; + lua_State* mState{ nullptr }; std::string mError; S32 mInterrupts{ 0 }; }; @@ -169,7 +172,10 @@ public: LuaRemover& operator=(const LuaRemover&) = delete; ~LuaRemover() { - lua_remove(mState, mIndex); + // If we're unwinding the C++ stack due to an exception, don't mess + // with the Lua stack! + if (std::uncaught_exceptions() == 0) + lua_remove(mState, mIndex); } private: @@ -348,7 +354,7 @@ auto lua_setfieldv(lua_State* L, int index, const char* k, const T& value) // return to C++, from table at index, the value of field k (without metamethods) template <typename T> -auto lua_rawgetfield(lua_State* L, int index, const std::string_view& k) +auto lua_rawgetfield(lua_State* L, int index, std::string_view k) { index = lua_absindex(L, index); lua_checkdelta(L); @@ -361,7 +367,7 @@ auto lua_rawgetfield(lua_State* L, int index, const std::string_view& k) // set in table at index, as field k, the specified C++ value (without metamethods) template <typename T> -void lua_rawsetfield(lua_State* L, int index, const std::string_view& k, const T& value) +void lua_rawsetfield(lua_State* L, int index, std::string_view k, const T& value) { index = lua_absindex(L, index); lua_checkdelta(L); @@ -386,8 +392,8 @@ void lua_rawsetfield(lua_State* L, int index, const std::string_view& k, const T class LuaFunction { public: - LuaFunction(const std::string_view& name, lua_CFunction function, - const std::string_view& helptext); + LuaFunction(std::string_view name, lua_CFunction function, + std::string_view helptext); static void init(lua_State* L); diff --git a/indra/llcommon/tests/llcond_test.cpp b/indra/llcommon/tests/llcond_test.cpp index f2a302ed13..7d1ac6edb9 100644 --- a/indra/llcommon/tests/llcond_test.cpp +++ b/indra/llcommon/tests/llcond_test.cpp @@ -19,6 +19,7 @@ // other Linden headers #include "../test/lltut.h" #include "llcoros.h" +#include "lldefs.h" // llless() /***************************************************************************** * TUT @@ -64,4 +65,78 @@ namespace tut cond.set_all(2); cond.wait_equal(3); } + + template <typename T0, typename T1> + struct compare + { + const char* desc; + T0 lhs; + T1 rhs; + bool expect; + + void test() const + { + // fails +// ensure_equals(desc, (lhs < rhs), expect); + ensure_equals(desc, llless(lhs, rhs), expect); + } + }; + + template<> template<> + void object::test<3>() + { + set_test_name("comparison"); + // Try to construct signed and unsigned variables such that the + // compiler can't optimize away the code to compare at runtime. + std::istringstream input("-1 10 20 10 20"); + int minus1, s10, s20; + input >> minus1 >> s10 >> s20; + unsigned u10, u20; + input >> u10 >> u20; + ensure_equals("minus1 wrong", minus1, -1); + ensure_equals("s10 wrong", s10, 10); + ensure_equals("s20 wrong", s20, 20); + ensure_equals("u10 wrong", u10, 10); + ensure_equals("u20 wrong", u20, 20); + // signed < signed should always work! + compare<int, int> ss[] = + { {"minus1 < s10", minus1, s10, true}, + {"s10 < s10", s10, s10, false}, + {"s20 < s10", s20, s20, false} + }; + for (const auto& cmp : ss) + { + cmp.test(); + } + // unsigned < unsigned should always work! + compare<unsigned, unsigned> uu[] = + { {"u10 < u20", u10, u20, true}, + {"u20 < u20", u20, u20, false}, + {"u20 < u10", u20, u10, false} + }; + for (const auto& cmp : uu) + { + cmp.test(); + } + // signed < unsigned ?? + compare<int, unsigned> su[] = + { {"minus1 < u10", minus1, u10, true}, + {"s10 < u10", s10, u10, false}, + {"s20 < u10", s20, u10, false} + }; + for (const auto& cmp : su) + { + cmp.test(); + } + // unsigned < signed ?? + compare<unsigned, int> us[] = + { {"u10 < minus1", u10, minus1, false}, + {"u10 < s10", u10, s10, false}, + {"u10 < s20", u10, s20, true} + }; + for (const auto& cmp : us) + { + cmp.test(); + } + } } // namespace tut diff --git a/indra/llcommon/tests/llrand_test.cpp b/indra/llcommon/tests/llrand_test.cpp index a0dd4ef576..85dd53ce96 100644 --- a/indra/llcommon/tests/llrand_test.cpp +++ b/indra/llcommon/tests/llrand_test.cpp @@ -38,7 +38,7 @@ // testing extent < 0, negate the return value and the extent before passing // into ensure_in_range(). template <typename NUMBER> -void ensure_in_range(const std::string_view& name, +void ensure_in_range(std::string_view name, NUMBER value, NUMBER low, NUMBER high) { auto failmsg{ stringize(name, " >= ", low, " (", value, ')') }; 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/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/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 7339454367..9d62a72188 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -57,7 +57,7 @@ void LLMeshOptimizer::generateShadowIndexBufferU32(U32 *destination, S32 index = 0; if (vertex_positions) { - streams[index].data = (const float*)vertex_positions; + streams[index].data = vertex_positions->getF32ptr(); // Despite being LLVector4a, only x, y and z are in use streams[index].size = sizeof(F32) * 3; streams[index].stride = sizeof(F32) * 4; @@ -65,14 +65,14 @@ void LLMeshOptimizer::generateShadowIndexBufferU32(U32 *destination, } if (normals) { - streams[index].data = (const float*)normals; + streams[index].data = normals->getF32ptr(); streams[index].size = sizeof(F32) * 3; streams[index].stride = sizeof(F32) * 4; index++; } if (text_coords) { - streams[index].data = (const float*)text_coords; + streams[index].data = text_coords->mV; streams[index].size = sizeof(F32) * 2; streams[index].stride = sizeof(F32) * 2; index++; @@ -108,21 +108,21 @@ void LLMeshOptimizer::generateShadowIndexBufferU16(U16 *destination, S32 index = 0; if (vertex_positions) { - streams[index].data = (const float*)vertex_positions; + streams[index].data = vertex_positions->getF32ptr(); streams[index].size = sizeof(F32) * 3; streams[index].stride = sizeof(F32) * 4; index++; } if (normals) { - streams[index].data = (const float*)normals; + streams[index].data = normals->getF32ptr(); streams[index].size = sizeof(F32) * 3; streams[index].stride = sizeof(F32) * 4; index++; } if (text_coords) { - streams[index].data = (const float*)text_coords; + streams[index].data = text_coords->mV; streams[index].size = sizeof(F32) * 2; streams[index].stride = sizeof(F32) * 2; index++; @@ -162,9 +162,9 @@ size_t LLMeshOptimizer::generateRemapMultiU32( U64 vertex_count) { meshopt_Stream streams[] = { - {(const float*)vertex_positions, sizeof(F32) * 3, sizeof(F32) * 4}, - {(const float*)normals, sizeof(F32) * 3, sizeof(F32) * 4}, - {(const float*)text_coords, sizeof(F32) * 2, sizeof(F32) * 2}, + {vertex_positions->getF32ptr(), sizeof(F32) * 3, sizeof(F32) * 4}, + {normals->getF32ptr(), sizeof(F32) * 3, sizeof(F32) * 4}, + {text_coords->mV, sizeof(F32) * 2, sizeof(F32) * 2}, }; // Remap can function without indices, @@ -236,7 +236,7 @@ void LLMeshOptimizer::remapPositionsBuffer(LLVector4a * destination_vertices, U64 vertex_count, const unsigned int* remap) { - meshopt_remapVertexBuffer((float*)destination_vertices, (const float*)vertex_positions, vertex_count, sizeof(LLVector4a), remap); + meshopt_remapVertexBuffer(destination_vertices->getF32ptr(), vertex_positions->getF32ptr(), vertex_count, sizeof(LLVector4a), remap); } void LLMeshOptimizer::remapNormalsBuffer(LLVector4a * destination_normalss, @@ -244,7 +244,7 @@ void LLMeshOptimizer::remapNormalsBuffer(LLVector4a * destination_normalss, U64 mormals_count, const unsigned int* remap) { - meshopt_remapVertexBuffer((float*)destination_normalss, (const float*)normals, mormals_count, sizeof(LLVector4a), remap); + meshopt_remapVertexBuffer(destination_normalss->getF32ptr(), normals->getF32ptr(), mormals_count, sizeof(LLVector4a), remap); } void LLMeshOptimizer::remapUVBuffer(LLVector2 * destination_uvs, @@ -252,7 +252,7 @@ void LLMeshOptimizer::remapUVBuffer(LLVector2 * destination_uvs, U64 uv_count, const unsigned int* remap) { - meshopt_remapVertexBuffer((float*)destination_uvs, (const float*)uv_positions, uv_count, sizeof(LLVector2), remap); + meshopt_remapVertexBuffer(destination_uvs->mV, uv_positions->mV, uv_count, sizeof(LLVector2), remap); } //static @@ -273,7 +273,7 @@ U64 LLMeshOptimizer::simplifyU32(U32 *destination, return meshopt_simplifySloppy<unsigned int>(destination, indices, index_count, - (const float*)vertex_positions, + vertex_positions->getF32ptr(), vertex_count, vertex_positions_stride, target_index_count, @@ -286,7 +286,7 @@ U64 LLMeshOptimizer::simplifyU32(U32 *destination, return meshopt_simplify<unsigned int>(destination, indices, index_count, - (const float*)vertex_positions, + vertex_positions->getF32ptr(), vertex_count, vertex_positions_stride, target_index_count, @@ -315,7 +315,7 @@ U64 LLMeshOptimizer::simplify(U16 *destination, return meshopt_simplifySloppy<unsigned short>(destination, indices, index_count, - (const float*)vertex_positions, + vertex_positions->getF32ptr(), vertex_count, vertex_positions_stride, target_index_count, @@ -328,7 +328,7 @@ U64 LLMeshOptimizer::simplify(U16 *destination, return meshopt_simplify<unsigned short>(destination, indices, index_count, - (const float*)vertex_positions, + vertex_positions->getF32ptr(), vertex_count, vertex_positions_stride, target_index_count, 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 4f47f16e33..f286bff353 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> @@ -1218,9 +1219,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/llmodelloader.cpp b/indra/llprimitive/llmodelloader.cpp index 9a194567d2..ae69c4f8ab 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/llgl.cpp b/indra/llrender/llgl.cpp index 0db1e27b01..c62cacdce6 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 @@ -2694,7 +2698,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; @@ -2721,13 +2725,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; @@ -2735,13 +2738,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); } @@ -2838,31 +2841,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..17f825bd71 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; @@ -317,7 +317,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 +326,8 @@ public: private: bool mApply; - glh::matrix4f mProjection; - glh::matrix4f mModelview; + glm::mat4 mProjection; + glm::mat4 mModelview; }; /* @@ -341,9 +341,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/llglslshader.cpp b/indra/llrender/llglslshader.cpp index a157bfee21..56f1533708 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -41,6 +41,8 @@ #include "OpenGL/OpenGL.h" #endif +#include <fstream> + // Print-print list of shader included source files that are linked together via glAttachShader() // i.e. On macOS / OSX the AMD GLSL linker will display an error if a varying is left in an undefined state. #define DEBUG_SHADER_INCLUDES 0 @@ -63,6 +65,7 @@ U64 LLGLSLShader::sTotalTimeElapsed = 0; U32 LLGLSLShader::sTotalTrianglesDrawn = 0; U64 LLGLSLShader::sTotalSamplesDrawn = 0; U32 LLGLSLShader::sTotalBinds = 0; +std::string LLGLSLShader::sDefaultReportName; //UI shader -- declared here so llui_libtest will link properly LLGLSLShader gUIProgram; @@ -101,9 +104,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,48 +120,71 @@ struct LLGLSLShaderCompareTimeElapsed }; //static -void LLGLSLShader::finishProfile(bool emit_report) +void LLGLSLShader::finishProfile(const std::string& report_name) { sProfileEnabled = false; - if (emit_report) + if (! report_name.empty()) { - 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()); + boost::json::object stats; + 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); } } } + + 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; + } } } @@ -170,36 +196,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..a9b9bfafa8 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(const std::string& report_name=sDefaultReportName); 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 report_name parameter to a + // temporary std::string, that temporary must be destroyed when the stack + // is unwound, which __try forbids. + static std::string sDefaultReportName; }; //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..16a8309a9a 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,13 +791,13 @@ 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() @@ -830,6 +831,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 +996,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 +1011,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 +1028,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 +1046,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 +1059,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 +1101,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 +1115,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 +1134,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 +1144,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 +1154,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 +1164,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 +1206,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 +1215,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 +1258,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]]; } @@ -2214,85 +2189,90 @@ void LLRender::debugTexUnits(void) LL_INFOS("TextureUnit") << "Active TexUnit Enabled : " << active_enabled << LL_ENDL; } - - -glh::matrix4f copy_matrix(F32* src) -{ - glh::matrix4f ret; - ret.set_value(src); - return ret; -} - -glh::matrix4f get_current_modelview() +glm::mat4 get_current_modelview() { - return copy_matrix(gGLModelView); + return glm::make_mat4(gGLModelView); } -glh::matrix4f get_current_projection() +glm::mat4 get_current_projection() { - return copy_matrix(gGLProjection); + return glm::make_mat4(gGLProjection); } -glh::matrix4f get_last_modelview() +glm::mat4 get_last_modelview() { - return copy_matrix(gGLLastModelView); + return glm::make_mat4(gGLLastModelView); } -glh::matrix4f get_last_projection() +glm::mat4 get_last_projection() { - return copy_matrix(gGLLastProjection); + return glm::make_mat4(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..2645597b1a 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> @@ -401,8 +401,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(); @@ -502,7 +502,7 @@ 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; @@ -536,8 +536,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 +548,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/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 156e300853..8524b470de 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 @@ -590,13 +591,13 @@ 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(); @@ -954,6 +955,25 @@ 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 + llassert(LLCoros::on_main_thread_main_coro()); + 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 +1017,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,6 +1224,7 @@ 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) { @@ -1233,6 +1260,7 @@ 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) { @@ -1289,11 +1317,11 @@ void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8 LL_PROFILE_ZONE_NUM(end); LL_PROFILE_ZONE_NUM(end-start); - constexpr U32 block_size = 8192; + constexpr U32 block_size = 65536; for (U32 i = start; i <= end; i += block_size) { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData block"); + //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; @@ -1305,7 +1333,28 @@ void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8 void LLVertexBuffer::unmapBuffer() { + flushBuffers(); +} + +void LLVertexBuffer::_mapBuffer() +{ + // must only be called from main thread + llassert(LLCoros::on_main_thread_main_coro()); + 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) @@ -1549,6 +1598,13 @@ void LLVertexBuffer::setBuffer() return; } #endif + + if (mMapped) + { + LL_WARNS_ONCE() << "Missing call to unmapBuffer or flushBuffers" << LL_ENDL; + _unmapBuffer(); + } + // 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/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index e4f5664908..73803786a6 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -307,6 +307,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() @@ -320,6 +321,7 @@ void LLFolderViewItem::refresh() // Can do a number of expensive checks, like checking active motions, wearables or friend list mLabelStyle = vmi.getLabelStyle(); mLabelSuffix = utf8str_to_wstring(vmi.getLabelSuffix()); + mSuffixFontBuffer.reset(); } // Dirty the filter flag of the model from the view (CHUI-849) @@ -775,8 +777,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 +787,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 +795,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 +803,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 +892,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); } @@ -907,7 +909,7 @@ void LLFolderViewItem::draw() getViewModelItem()->update(); - if(!mSingleFolderMode) + if (!mSingleFolderMode) { drawOpenFolderArrow(default_params, sFgColor); } @@ -940,7 +942,7 @@ 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 text_left = (F32)getLabelXPos(); @@ -999,9 +1001,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(suffix_font, mLabelSuffix, 0, right_x, y, isFadeItem() ? color : sSuffixColor.get(), + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + S32_MAX, S32_MAX, &right_x); } //--------------------------------------------------------------------------------// diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 60cdac3ab9..7ac28b1a8e 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; @@ -297,8 +298,8 @@ 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 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,9 @@ public: private: static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts + + LLFontVertexBuffer mLabelFontBuffer; + LLFontVertexBuffer mSuffixFontBuffer; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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/llmenugl.cpp b/indra/llui/llmenugl.cpp index 69ffa9a94f..cc770ca90a 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -2625,7 +2625,9 @@ void LLMenuGL::insert( S32 position, LLView * ctrl, bool arrange /*= true*/ ) { LLMenuItemGL * item = dynamic_cast<LLMenuItemGL *>(ctrl); - if (NULL == item || position < 0 || position >= mItems.size()) + // If position == size(), std::advance() will return end() -- which is + // okay, because insert(end()) is the same as append(). + if (NULL == item || position < 0 || position > mItems.size()) { return; } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 3aad8f5fe6..32fafe3c52 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -3342,7 +3342,6 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele const LLWString& text = getWText(); S32 text_gen = mEditor.getTextGeneration(); - bool is_text_read_only = mEditor.getReadOnly(); if (text_gen != mLastGeneration) { @@ -3354,8 +3353,8 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele } const LLFontGL* font = mStyle->getFont(); - - LLColor4 color = (is_text_read_only ? mStyle->getReadOnlyColor() : mStyle->getColor()) % (alpha * mStyle->getAlpha()); + LLColor4 color = (mEditor.getReadOnly() ? mStyle->getReadOnlyColor() : mStyle->getColor()) % (alpha * mStyle->getAlpha()); + bool use_font_buffers = useFontBuffers(); if( selection_start > seg_start ) { @@ -3363,7 +3362,7 @@ 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; - if (is_text_read_only) + if (use_font_buffers) { mFontBufferPreSelection.render( font, @@ -3407,7 +3406,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele S32 end = llmin( selection_end, seg_end ); S32 length = end - start; - if (is_text_read_only) + if (use_font_buffers) { mFontBufferSelection.render( font, @@ -3444,7 +3443,7 @@ 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; - if (is_text_read_only) + if (use_font_buffers) { mFontBufferPostSelection.render( font, diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index e2981c2637..eb4697da15 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -151,6 +151,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; @@ -484,7 +485,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; } diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 013417ae47..765c88a933 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -274,6 +274,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/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/llviewereventrecorder.cpp b/indra/llui/llviewereventrecorder.cpp index e5e0545dad..0a4fe5234b 100644 --- a/indra/llui/llviewereventrecorder.cpp +++ b/indra/llui/llviewereventrecorder.cpp @@ -24,9 +24,10 @@ */ -#include "llviewereventrecorder.h" -#include "llui.h" #include "llleap.h" +#include "llstring.h" +#include "llui.h" +#include "llviewereventrecorder.h" LLViewerEventRecorder::LLViewerEventRecorder() { @@ -247,11 +248,9 @@ void LLViewerEventRecorder::logKeyUnicodeEvent(llwchar uni_char) { // keycode...or // char - LL_DEBUGS() << "Wrapped in conversion to wstring " << wstring_to_utf8str(LLWString( 1, uni_char)) << "\n" << LL_ENDL; + LL_DEBUGS() << "Wrapped in conversion to wstring " << ll_convert_to<std::string>(uni_char) << "\n" << LL_ENDL; - event.insert("char", - LLSD( wstring_to_utf8str(LLWString( 1,uni_char)) ) - ); + event.insert("char", LLSD(ll_convert_to<std::string>(uni_char))); // path (optional) - for now we are not recording path for key events during record - should not be needed for full record and playback of recorded steps // as a vita script - it does become useful if you edit the resulting vita script and wish to remove some steps leading to a key event - that sort of edit might @@ -261,7 +260,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/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 7b1430c67c..2996f58fe0 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/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 8a2168893c..01edbb53af 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4649,6 +4649,12 @@ void LLWindowWin32::LLWindowWin32Thread::checkDXMem() { if (!mGLReady || mGotGLBuffer) { return; } + if ((gGLManager.mHasAMDAssociations || gGLManager.mHasNVXGpuMemoryInfo) && gGLManager.mVRAM != 0) + { // OpenGL already told us the memory budget, don't ask DX + mGotGLBuffer = true; + return; + } + IDXGIFactory4* p_factory = nullptr; HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&p_factory); @@ -4745,7 +4751,7 @@ void LLWindowWin32::LLWindowWin32Thread::run() { LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; - // Check memory budget using DirectX + // Check memory budget using DirectX if OpenGL doesn't have the means to tell us checkDXMem(); if (mWindowHandleThrd != 0) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7d5b6fa2a4..106fe81682 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) @@ -1923,6 +1924,7 @@ target_link_libraries(${VIEWER_BINARY_NAME} ll::lualibs ll::ndof ll::tracy + ll::openxr ) if( TARGET ll::intel_memops ) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 248992fd07..c717e62a95 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -3999,6 +3999,17 @@ <string>scripts/lua</string> </array> </map> + <key>LuaFeature</key> + <map> + <key>Comment</key> + <string>Enable viewer's Lua script engine.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>LuaRequirePath</key> <map> <key>Comment</key> @@ -13483,6 +13494,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/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index e55d630940..ce54fa4c12 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -807,10 +807,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..7c37cc1c00 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. diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 8f892025c9..7c7f7aa91d 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: diff --git a/indra/newview/llappviewerlistener.cpp b/indra/newview/llappviewerlistener.cpp index d02b1b4a79..4690c91b61 100644 --- a/indra/newview/llappviewerlistener.cpp +++ b/indra/newview/llappviewerlistener.cpp @@ -35,6 +35,7 @@ // external library headers // other Linden headers #include "llappviewer.h" +#include "workqueue.h" LLAppViewerListener::LLAppViewerListener(const LLAppViewerGetter& getter): LLEventAPI("LLAppViewer", @@ -56,17 +57,23 @@ LLAppViewerListener::LLAppViewerListener(const LLAppViewerGetter& getter): void LLAppViewerListener::userQuit(const LLSD& event) { LL_INFOS() << "Listener requested user quit" << LL_ENDL; - mAppViewerGetter()->userQuit(); + // Trying to engage this from (e.g.) a Lua-hosting C++ coroutine runs + // afoul of an assert in the logging machinery that LLMutex must be locked + // only from the main coroutine. + LL::WorkQueue::getInstance("mainloop")->post( + [appviewer=mAppViewerGetter()]{ appviewer->userQuit(); }); } void LLAppViewerListener::requestQuit(const LLSD& event) { LL_INFOS() << "Listener requested quit" << LL_ENDL; - mAppViewerGetter()->requestQuit(); + LL::WorkQueue::getInstance("mainloop")->post( + [appviewer=mAppViewerGetter()]{ appviewer->requestQuit(); }); } void LLAppViewerListener::forceQuit(const LLSD& event) { LL_INFOS() << "Listener requested force quit" << LL_ENDL; - mAppViewerGetter()->forceQuit(); + LL::WorkQueue::getInstance("mainloop")->post( + [appviewer=mAppViewerGetter()]{ appviewer->forceQuit(); }); } 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/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/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/llface.cpp b/indra/newview/llface.cpp index ccfef09b09..48fddc32db 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1487,9 +1487,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 { @@ -1741,7 +1741,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 @@ -1803,49 +1803,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); diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index aa04221f4b..dded4d1e92 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -393,7 +393,7 @@ F32 logExceptionBenchmark() __except (msc_exception_filter(GetExceptionCode(), GetExceptionInformation())) { // HACK - ensure that profiling is disabled - LLGLSLShader::finishProfile(false); + LLGLSLShader::finishProfile(); // convert to C++ styled exception char integer_string[32]; diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index f68980b23c..1e2d790cfc 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 4f6f96e37e..b2f2984c65 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/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index bd6778c3f9..dda7266220 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 930a8c28d9..fc02220808 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -923,7 +923,7 @@ struct ShaderProfileHelper } ~ShaderProfileHelper() { - LLGLSLShader::finishProfile(false); + LLGLSLShader::finishProfile(); } }; @@ -1121,57 +1121,6 @@ F32 gpu_benchmark() LLGLSLShader::unbind(); - F32 time_passed = 0; // seconds - - { //run CPU timer benchmark - glFinish(); - gBenchmarkProgram.bind(); - for (S32 c = -1; c < samples && time_passed < time_limit; ++c) - { - LLTimer timer; - timer.start(); - - for (U32 i = 0; i < count; ++i) - { - dest[i].bindTarget(); - texHolder.bind(i); - buff->setBuffer(); - buff->drawArrays(LLRender::TRIANGLES, 0, 3); - dest[i].flush(); - } - - //wait for current batch of copies to finish - glFinish(); - - F32 time = timer.getElapsedTimeF32(); - time_passed += time; - - if (c >= 0) // <-- ignore the first sample as it tends to be artificially slow - { - //store result in gigabytes per second - F32 gb = (F32)((F64)(res * res * 8 * count)) / (1000000000); - F32 gbps = gb / time; - results.push_back(gbps); - } - } - gBenchmarkProgram.unbind(); - } - - std::sort(results.begin(), results.end()); - - F32 gbps = results[results.size()/2]; - - LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to CPU timers, " << (F32)results.size() << " tests took " << time_passed << " seconds" << LL_ENDL; - -#if LL_DARWIN - if (gbps > 512.f) - { - LL_WARNS("Benchmark") << "Memory bandwidth is improbably high and likely incorrect; discarding result." << LL_ENDL; - //OSX is probably lying, discard result - return -1.f; - } -#endif - // run GPU timer benchmark { ShaderProfileHelper initProfile; @@ -1196,7 +1145,7 @@ F32 gpu_benchmark() F64 samples_drawn = (F64)gBenchmarkProgram.mSamplesDrawn; F64 gpixels_drawn = samples_drawn / 1000000000.0; F32 samples_sec = (F32)(gpixels_drawn/seconds); - gbps = samples_sec*4; // 4 bytes per sample + F32 gbps = samples_sec*4; // 4 bytes per sample LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to ARB_timer_query, total time " << seconds << " seconds" << LL_ENDL; diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index e38ba8762a..294b445694 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.cpp +++ b/indra/newview/llgltfmaterialpreviewmgr.cpp @@ -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/llhudrender.cpp b/indra/newview/llhudrender.cpp index f027aa5552..4180e49e94 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, @@ -102,26 +105,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 +120,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/llimview.cpp b/indra/newview/llimview.cpp index 136b59f3a6..06cf9919b6 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 @@ -4178,11 +4178,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 c86492f005..2e8b1b94fe 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..5c0905af3c 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) { @@ -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() { - 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..7e64a03e73 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; @@ -341,6 +342,7 @@ public: private: bool areDateLimitsSet(); + 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 dc35c834bf..fdf77ab8df 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 949ce2558f..d08cd91382 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/llluamanager.cpp b/indra/newview/llluamanager.cpp index 6a725e785f..0bd21516bc 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -65,7 +65,7 @@ lua_function(sleep, "sleep(seconds): pause the running coroutine") // This function consumes ALL Lua stack arguments and returns concatenated // message string -std::string lua_print_msg(lua_State* L, const std::string_view& level) +std::string lua_print_msg(lua_State* L, std::string_view level) { // On top of existing Lua arguments, we're going to push tostring() and // duplicate each existing stack entry so we can stringize each one. 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/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index df573bd785..ef09cfa55b 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -2828,9 +2828,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/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/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index cb89a5910e..7f72677e34 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -280,8 +280,7 @@ void LLPanelEmojiComplete::onCommit() { if (mCurSelected < mTotalEmojis) { - LLSD value(wstring_to_utf8str(LLWString(1, mEmojis[mCurSelected].Character))); - setValue(value); + setValue(ll_convert_to<std::string>(mEmojis[mCurSelected].Character)); LLUICtrl::onCommit(); } } diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index e4503a69d2..8bc5989b89 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -910,12 +910,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(); } @@ -932,9 +932,9 @@ void LLPanelMainInventory::changed(U32) updateItemcountText(); } -void LLPanelMainInventory::setFocusFilterEditor() +void LLPanelMainInventory::setFocusOnFilterEditor() { - if(mFilterEditor) + if (mFilterEditor) { mFilterEditor->setFocus(true); } @@ -999,6 +999,22 @@ void LLPanelMainInventory::updateItemcountText() mCategoryCount = gInventory.getCategoryCount(); update = true; } + + EFetchState currentFetchState{ EFetchState::Unknown }; + if (LLInventoryModelBackgroundFetch::instance().folderFetchActive()) + { + currentFetchState = EFetchState::Fetching; + } + else if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) + { + currentFetchState = EFetchState::Complete; + } + + if (mLastFetchState != currentFetchState) + { + mLastFetchState = currentFetchState; + update = true; + } } if (mLastFilterText != getFilterText()) @@ -1029,17 +1045,17 @@ void LLPanelMainInventory::updateItemcountText() } else { - if (LLInventoryModelBackgroundFetch::instance().folderFetchActive()) + switch (mLastFetchState) { + case EFetchState::Fetching: text = getString("ItemcountFetching", string_args); - } - else if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) - { + break; + case EFetchState::Complete: text = getString("ItemcountCompleted", string_args); - } - else - { + break; + default: text = getString("ItemcountUnknown", string_args); + break; } } @@ -1245,7 +1261,6 @@ void LLFloaterInventoryFinder::draw() filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_calling_card")->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD); @@ -1265,8 +1280,6 @@ void LLFloaterInventoryFinder::draw() } if (!getChild<LLUICtrl>("check_landmark")->getValue()) - - { filter &= ~(0x1 << LLInventoryType::IT_LANDMARK); filtered_by_all_types = false; @@ -1327,9 +1340,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); @@ -1337,7 +1349,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); @@ -1369,9 +1381,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()); @@ -1379,7 +1390,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()); diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index d28daddd73..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; @@ -202,6 +209,7 @@ private: 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 395e9eca82..dcd7fdf30d 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 //---------------------------------------------------------------------------- @@ -1404,7 +1390,6 @@ void LLPanelObjectInventory::clearContents() } } - void LLPanelObjectInventory::reset() { clearContents(); @@ -1458,12 +1443,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; } @@ -1475,23 +1461,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; @@ -1527,15 +1509,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); @@ -1552,6 +1531,7 @@ void LLPanelObjectInventory::updateInventory() { mFolders->requestArrange(); } + mInventoryNeedsUpdate = false; // Edit menu handler is set in onFocusReceived } @@ -1567,10 +1547,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); @@ -1613,59 +1592,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); } @@ -1677,11 +1647,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. @@ -1689,7 +1658,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(); @@ -1715,26 +1684,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; } @@ -1749,7 +1720,7 @@ void LLPanelObjectInventory::clearInventoryTask() void LLPanelObjectInventory::removeSelectedItem() { - if(mFolders) + if (mFolders) { mFolders->removeSelectedItems(); } @@ -1757,7 +1728,7 @@ void LLPanelObjectInventory::removeSelectedItem() void LLPanelObjectInventory::startRenamingSelectedItem() { - if(mFolders) + if (mFolders) { mFolders->startRenamingSelectedItem(); } @@ -1767,25 +1738,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); } } } @@ -1799,31 +1771,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 @@ -1860,11 +1822,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; @@ -1915,21 +1875,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/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 9bef09527b..1af585708e 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/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/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..6f9de57d2a 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -996,38 +996,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()) 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..1c92e06700 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -315,11 +315,9 @@ 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); + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (vol_face.mJointRiggingInfoTab.needsUpdate()) { 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/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index cc04f9e3fc..5ccda7d4eb 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -48,11 +48,8 @@ #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 ), diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index c389d04443..44eb8461f1 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -90,12 +90,14 @@ LLUIListener::LLUIListener(): add("addMenuItem", "Add new menu item [\"name\"] with displayed [\"label\"]\n" "and call-on-click UI function [\"func\"] with optional [\"param\"]\n" - "to the [\"parent_menu\"] within the Top menu.", + "to the [\"parent_menu\"] within the Top menu.\n" + "If [\"pos\"] is present, insert at specified 0-relative position.", &LLUIListener::addMenuItem, required_args.with("func", LLSD())); add("addMenuSeparator", - "Add menu separator to the [\"parent_menu\"] within the Top menu.", + "Add menu separator to the [\"parent_menu\"] within the Top menu.\n" + "If [\"pos\"] is present, insert at specified 0-relative position.", &LLUIListener::addMenuSeparator, llsd::map("parent_menu", LLSD(), "reply", LLSD())); @@ -264,6 +266,13 @@ LLMenuGL* get_parent_menu(LLEventAPI::Response& response, const LLSD&event) return parent_menu; } +// Return event["pos"].asInteger() if passed, but clamp (0 <= pos <= size). +// Reserve -1 return to mean event has no "pos" key. +S32 get_pos(const LLSD& event, U32 size) +{ + return event["pos"].isInteger()? llclamp(event["pos"].asInteger(), 0, size) : -1; +} + void LLUIListener::addMenu(const LLSD&event) const { Response response(LLSD(), event); @@ -302,9 +311,19 @@ void LLUIListener::addMenuItem(const LLSD&event) const item_params.on_click = item_func; if(LLMenuGL* parent_menu = get_parent_menu(response, event)) { - if(!parent_menu->append(LLUICtrlFactory::create<LLMenuItemCallGL>(item_params))) + auto item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params); + // Clamp pos to getItemCount(), meaning append. If pos exceeds that, + // insert() will silently ignore the request. + auto pos = get_pos(event, parent_menu->getItemCount()); + if (pos >= 0) { - response.error(stringize("Menu item ", std::quoted(event["name"].asString()), " was not added")); + // insert() returns void: we just have to assume it worked. + parent_menu->insert(pos, item); + } + else if (! parent_menu->append(item)) + { + response.error(stringize("Menu item ", std::quoted(event["name"].asString()), + " was not added")); } } } @@ -314,7 +333,19 @@ void LLUIListener::addMenuSeparator(const LLSD&event) const Response response(LLSD(), event); if(LLMenuGL* parent_menu = get_parent_menu(response, event)) { - if(!parent_menu->addSeparator()) + // Clamp pos to getItemCount(), meaning append. If pos exceeds that, + // insert() will silently ignore the request. + auto pos = get_pos(event, parent_menu->getItemCount()); + if (pos >= 0) + { + // Even though addSeparator() does not accept a position, + // LLMenuItemSeparatorGL isa LLMenuItemGL, so we can use insert(). + LLMenuItemSeparatorGL::Params p; + LLMenuItemGL* separator = LLUICtrlFactory::create<LLMenuItemSeparatorGL>(p); + // insert() returns void: we just have to assume it worked. + parent_menu->insert(pos, separator); + } + else if (! parent_menu->addSeparator()) { response.error("Separator was not added"); } diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp index 39a9f0f8bc..166542324d 100644 --- a/indra/newview/llurldispatcher.cpp +++ b/indra/newview/llurldispatcher.cpp @@ -289,6 +289,8 @@ public: LLEventAPI::add("teleport", "Teleport to specified [\"regionname\"] at\n" "specified region-relative [\"x\"], [\"y\"], [\"z\"].\n" + "If [\"regionname\"] is \"home\", ignore [\"x\"], [\"y\"], [\"z\"]\n" + "and teleport home.\n" "If [\"regionname\"] omitted, teleport to GLOBAL\n" "coordinates [\"x\"], [\"y\"], [\"z\"].", &LLTeleportHandler::from_event); @@ -328,7 +330,12 @@ public: void from_event(const LLSD& params) const { Response response(LLSD(), params); - if (params.has("regionname")) + if (params["regionname"].asString() == "home") + { + gAgent.teleportHome(); + response["message"] = "Teleporting home"; + } + else if (params.has("regionname")) { // region specified, coordinates (if any) are region-local LLVector3 local_pos( 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..fdfe477a6c 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -28,58 +28,73 @@ #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 "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 +138,8 @@ void render_ui_3d(); void render_ui_2d(); void render_disconnected_background(); +std::string getProfileStatsFilename(); + void display_startup() { if ( !gViewerWindow @@ -760,8 +777,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 +786,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,10 +1040,49 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) if (gShaderProfileFrame) { gShaderProfileFrame = false; - LLGLSLShader::finishProfile(); + LLGLSLShader::finishProfile(getProfileStatsFilename()); } } +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 void display_cube_face() { @@ -1148,8 +1204,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 +1329,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 +1337,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 +1368,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 +1382,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 +1404,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()) diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 9739cac311..1c8f1a32b9 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2766,7 +2766,8 @@ bool LLViewerMediaImpl::handleUnicodeCharHere(llwchar uni_char) { LLSD native_key_data = gViewerWindow->getWindow()->getNativeKeyData(); - mMediaSource->textInput(wstring_to_utf8str(LLWString(1, uni_char)), gKeyboard->currentMask(false), native_key_data); + mMediaSource->textInput(ll_convert_to<std::string>(uni_char), + gKeyboard->currentMask(false), native_key_data); } } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index df9f99c360..af719293e6 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 // @@ -216,24 +207,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(); @@ -248,107 +237,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(); } @@ -9768,6 +9590,8 @@ void initialize_menus() registrar.add("Agent.ToggleMicrophone", boost::bind(&LLAgent::toggleMicrophone, _2), cb_info::UNTRUSTED_BLOCK); enable.add("Agent.IsMicrophoneOn", boost::bind(&LLAgent::isMicrophoneOn, _2)); enable.add("Agent.IsActionAllowed", boost::bind(&LLAgent::isActionAllowed, _2)); + registrar.add("Agent.ToggleHearMediaSoundFromAvatar", boost::bind(&LLAgent::toggleHearMediaSoundFromAvatar), cb_info::UNTRUSTED_BLOCK); + registrar.add("Agent.ToggleHearVoiceFromAvatar", boost::bind(&LLAgent::toggleHearVoiceFromAvatar), cb_info::UNTRUSTED_BLOCK); // File menu init_menu_file(); @@ -10231,7 +10055,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)); registrar.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 b5e387207a..5e4b24c7e8 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); @@ -145,13 +111,10 @@ bool enable_buy_object(); bool handle_go_to(); bool handle_env_setting_event(std::string event_name); -// 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 935f112955..2a871a24af 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -996,7 +996,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)) @@ -1046,7 +1046,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/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 115db57a06..d59dfb88a8 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; } @@ -2488,7 +2489,16 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features) if (features.has("GLTFEnabled")) { bool enabled = features["GLTFEnabled"]; - gSavedSettings.setBOOL("GLTFEnabled", enabled); + + // call setShaders the first time GLTFEnabled is received as true (causes GLTF specific shaders to be loaded) + if (enabled != gSavedSettings.getBOOL("GLTFEnabled")) + { + gSavedSettings.setBOOL("GLTFEnabled", enabled); + if (enabled) + { + LLViewerShaderMgr::instance()->setShaders(); + } + } } else { diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index a446be8b58..58b541b19b 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -439,13 +439,20 @@ void LLViewerShaderMgr::finalizeShaderList() mShaderList.push_back(&gDeferredDiffuseProgram); mShaderList.push_back(&gDeferredBumpProgram); mShaderList.push_back(&gDeferredPBROpaqueProgram); - mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram); + + if (gSavedSettings.getBOOL("GLTFEnabled")) + { + mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram); + } + mShaderList.push_back(&gDeferredAvatarProgram); mShaderList.push_back(&gDeferredTerrainProgram); + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) { mShaderList.push_back(&gDeferredPBRTerrainProgram[paint_type]); } + mShaderList.push_back(&gDeferredDiffuseAlphaMaskProgram); mShaderList.push_back(&gDeferredNonIndexedDiffuseAlphaMaskProgram); mShaderList.push_back(&gDeferredTreeProgram); @@ -1340,26 +1347,29 @@ bool LLViewerShaderMgr::loadShadersDeferred() llassert(success); } - if (success) + if (gSavedSettings.getBOOL("GLTFEnabled")) { - gGLTFPBRMetallicRoughnessProgram.mName = "GLTF PBR Metallic Roughness Shader"; - gGLTFPBRMetallicRoughnessProgram.mFeatures.hasSrgb = true; + if (success) + { + gGLTFPBRMetallicRoughnessProgram.mName = "GLTF PBR Metallic Roughness Shader"; + gGLTFPBRMetallicRoughnessProgram.mFeatures.hasSrgb = true; - gGLTFPBRMetallicRoughnessProgram.mShaderFiles.clear(); - gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessV.glsl", GL_VERTEX_SHADER)); - gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessF.glsl", GL_FRAGMENT_SHADER)); - gGLTFPBRMetallicRoughnessProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - gGLTFPBRMetallicRoughnessProgram.clearPermutations(); + gGLTFPBRMetallicRoughnessProgram.mShaderFiles.clear(); + gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessV.glsl", GL_VERTEX_SHADER)); + gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessF.glsl", GL_FRAGMENT_SHADER)); + gGLTFPBRMetallicRoughnessProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gGLTFPBRMetallicRoughnessProgram.clearPermutations(); - success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow); + success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow); - //llassert(success); - if (!success) - { - LL_WARNS() << "Failed to create GLTF PBR Metallic Roughness Shader, disabling!" << LL_ENDL; - gSavedSettings.setBOOL("RenderCanUseGLTFPBROpaqueShaders", false); - // continue as if this shader never happened - success = true; + //llassert(success); + if (!success) + { + LL_WARNS() << "Failed to create GLTF PBR Metallic Roughness Shader, disabling!" << LL_ENDL; + gSavedSettings.setBOOL("RenderCanUseGLTFPBROpaqueShaders", false); + // continue as if this shader never happened + success = true; + } } } @@ -3140,29 +3150,32 @@ bool LLViewerShaderMgr::loadShadersInterface() success = gCopyDepthProgram.createShader(); } - if (success) + if (gSavedSettings.getBOOL("LocalTerrainPaintEnabled")) { - LLGLSLShader* shader = &gPBRTerrainBakeProgram; - U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth"); - // LLTerrainPaintMap currently uses an RGB8 texture internally - bit_depth = llclamp(bit_depth, 1, 8); - shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth); - shader->mFeatures.isPBRTerrain = true; - - shader->mShaderFiles.clear(); - shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER)); - shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER)); - shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE]; - const U32 value_range = (1 << bit_depth) - 1; - shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range)); - success = success && shader->createShader(); - //llassert(success); - if (!success) + if (success) { - LL_WARNS() << "Failed to create shader '" << shader->mName << "', disabling!" << LL_ENDL; - gSavedSettings.setBOOL("RenderCanUseTerrainBakeShaders", false); - // continue as if this shader never happened - success = true; + LLGLSLShader* shader = &gPBRTerrainBakeProgram; + U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth"); + // LLTerrainPaintMap currently uses an RGB8 texture internally + bit_depth = llclamp(bit_depth, 1, 8); + shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth); + shader->mFeatures.isPBRTerrain = true; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER)); + shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE]; + const U32 value_range = (1 << bit_depth) - 1; + shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range)); + success = success && shader->createShader(); + //llassert(success); + if (!success) + { + LL_WARNS() << "Failed to create shader '" << shader->mName << "', disabling!" << LL_ENDL; + gSavedSettings.setBOOL("RenderCanUseTerrainBakeShaders", false); + // continue as if this shader never happened + success = true; + } } } diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 14228b469f..5793a28b80 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -503,7 +503,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 d16656abfc..9e1cb84bd1 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -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; @@ -1553,6 +1508,17 @@ void LLViewerFetchedTexture::postCreateTexture() setActive(); + // rebuild any volumes that are using this texture for sculpts in case their LoD has changed + for (U32 i = 0; i < mNumVolumes[LLRender::SCULPT_TEX]; ++i) + { + LLVOVolume* volume = mVolumeList[LLRender::SCULPT_TEX][i]; + if (volume) + { + volume->mSculptChanged = true; + gPipeline.markRebuild(volume->mDrawable); + } + } + if (!needsToSaveRawImage()) { mNeedsAux = false; @@ -2647,7 +2613,7 @@ void LLViewerFetchedTexture::destroyRawImage() if (mAuxRawImage.notNull() && !needsToSaveRawImage()) { sAuxCount--; - mAuxRawImage = NULL; + mAuxRawImage = nullptr; } if (mRawImage.notNull()) @@ -2662,7 +2628,7 @@ void LLViewerFetchedTexture::destroyRawImage() } } - mRawImage = NULL; + mRawImage = nullptr; mIsRawImageValid = false; mRawDiscardLevel = INVALID_DISCARD_LEVEL; @@ -2774,7 +2740,9 @@ void LLViewerFetchedTexture::readbackRawImage() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && mRawImage.isNull()) + // readback the raw image from vram if the current raw image is null or smaller than the texture + if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && + (mRawImage.isNull() || mRawImage->getWidth() < mGLTexturep->getWidth() || mRawImage->getHeight() < mGLTexturep->getHeight() )) { mRawImage = new LLImageRaw(); if (!mGLTexturep->readBackRaw(-1, mRawImage, false)) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 19cf613939..5628fd1231 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5358,8 +5358,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 diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 09ab501743..7a3f6a6bcb 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -617,7 +617,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; @@ -1178,7 +1177,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)); } @@ -1186,12 +1184,6 @@ void LLVOAvatar::cleanupClass() { } -bool LLVOAvatar::handleVOAvatarPrefsChanged(const LLSD &newvalue) -{ - sLipSyncEnabled = gSavedSettings.getBOOL("LipSyncEnabled"); - return true; -} - // virtual void LLVOAvatar::initInstance() { @@ -1555,7 +1547,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) @@ -1847,36 +1840,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; @@ -2881,7 +2874,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(); } @@ -2902,19 +2895,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()) @@ -3119,7 +3105,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; @@ -3696,21 +3682,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; + } } } } @@ -4936,27 +4923,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; } @@ -5045,11 +5027,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 @@ -7111,6 +7096,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() //----------------------------------------------------------------------------- @@ -7138,7 +7135,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; @@ -7151,12 +7148,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) ); - } } //----------------------------------------------------------------------------- @@ -8445,14 +8436,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; } @@ -8480,16 +8471,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; } @@ -8505,7 +8496,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(); @@ -8538,14 +8529,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); } } } @@ -8611,60 +8602,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); } } } @@ -9788,7 +9772,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()) { @@ -10420,12 +10404,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. @@ -10456,32 +10438,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); } } @@ -10685,14 +10669,18 @@ void LLVOAvatar::updateRiggingInfo() 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") + + // Get current rigging info key + for (LLVOVolume* vol : volumes) { - const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); - S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); - curr_rigging_info_key[mesh_id] = max_lod; + if (vol->isMesh() && vol->getVolume()) + { + const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); + S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); + curr_rigging_info_key[mesh_id] = max_lod; + } } } diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index aa6aee0de5..a93ccf46bf 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; @@ -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..67adcbb244 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; 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 d2a8b4e5cf..1e934ade59 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -5011,8 +5011,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 22b53c0b85..3d684e5a1b 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -420,7 +420,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 +1335,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 +2015,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 @@ -2512,8 +2518,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 +2548,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() // try again. setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION); + mOutstandingRequests--; return; } @@ -2551,6 +2556,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() if (url.empty()) { setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); + mOutstandingRequests--; return; } @@ -2575,7 +2581,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 +2668,10 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; - processIceUpdates(); + if (!mShutDown) + { + processIceUpdates(); + } switch (getVoiceConnectionState()) { @@ -2707,6 +2715,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; @@ -2757,24 +2766,25 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() case VOICE_STATE_SESSION_UP: { mRetryWaitPeriod = 0; - mRetryWaitSecs = (F32)((F32) rand() / (RAND_MAX)) + 0.5f; - LLUUID agentRegionID; - if (isSpatial() && gAgent.getRegion()) - { - - bool primary = (mRegionID == gAgent.getRegion()->getRegionID()); - if (primary != mPrimary) - { - mPrimary = primary; - sendJoin(); - } - } + mRetryWaitSecs = (F32)((F32)rand() / (RAND_MAX)) + 0.5f; // we'll stay here as long as the session remains up. if (mShutDown) { setVoiceConnectionState(VOICE_STATE_DISCONNECT); } + else + { + if (isSpatial() && gAgent.getRegion()) + { + bool primary = (mRegionID == gAgent.getRegion()->getRegionID()); + if (primary != mPrimary) + { + mPrimary = primary; + sendJoin(); + } + } + } break; } @@ -2799,6 +2809,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 +2818,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { // llwebrtc::terminate() is already shuting down the connection. setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE); - mOutstandingRequests++; } break; @@ -2976,7 +2986,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 +2996,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 +3062,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 +3144,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 +3152,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() if (url.empty()) { setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); + mOutstandingRequests--; return; } @@ -3164,7 +3176,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..8f792c1042 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -702,7 +702,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; 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 7da4358f86..4f48a070e3 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1149,7 +1149,7 @@ void LLVOVolume::updateSculptTexture() { mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, true, LLGLTexture::BOOST_SCULPTED, LLViewerTexture::LOD_TEXTURE); mSculptTexture->forceToSaveRawImage(0, F32_MAX); - mSculptTexture->addTextureStats(256.f*256.f); + mSculptTexture->setKnownDrawSize(256, 256); } mSkinInfoUnavaliable = false; @@ -1251,7 +1251,7 @@ void LLVOVolume::sculpt() discard_level = mSculptTexture->getSavedRawImageLevel(); } - if (!raw_image) + if (!raw_image || raw_image->getWidth() < mSculptTexture->getWidth() || raw_image->getHeight() < mSculptTexture->getHeight()) { // last resort, read back from GL mSculptTexture->readbackRawImage(); @@ -1338,17 +1338,8 @@ void LLVOVolume::sculpt() mSculptTexture->updateBindStatsForTester() ; } } - getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level, mSculptTexture->isMissingAsset()); - //notify rebuild any other VOVolumes that reference this sculpty volume - for (S32 i = 0; i < mSculptTexture->getNumVolumes(LLRender::SCULPT_TEX); ++i) - { - LLVOVolume* volume = (*(mSculptTexture->getVolumeList(LLRender::SCULPT_TEX)))[i]; - if (volume != this && volume->getVolume() == getVolume()) - { - gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY); - } - } + getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level, mSculptTexture->isMissingAsset()); } } @@ -6037,8 +6028,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; @@ -6083,8 +6074,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) group->dirtyGeom(); gPipeline.markRebuild(group); } - - buff->unmapBuffer(); } } } @@ -6100,17 +6089,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); @@ -6792,11 +6771,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 6241bf42d6..97a5131260 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -451,6 +451,7 @@ public: private: friend class LLDrawable; friend class LLFace; + friend class LLViewerFetchedTexture; bool mFaceMappingChanged; LLFrameTimer mTextureUpdateTimer; diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 76348d4ea1..2d59712142 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -36,6 +36,7 @@ #include "llnotificationsutil.h" #include "llinventorymodel.h" #include "lltrans.h" +#include "llappviewer.h" // Callback struct struct LLWearableArrivedData @@ -97,6 +98,22 @@ void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& weara // static void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID& uuid, void* userdata, S32 status, LLExtStat ext_status ) { + if (!LLCoros::on_main_coro()) + { + // if triggered from a coroutine, dispatch to main thread before accessing app state + std::string filename_in = filename; + LLUUID uuid_in = uuid; + + LLAppViewer::instance()->postToMainCoro([=]() + { + processGetAssetReply(filename_in.c_str(), uuid_in, userdata, status, ext_status); + }); + + return; + } + + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + bool isNewWearable = false; LLWearableArrivedData* data = (LLWearableArrivedData*) userdata; LLViewerWearable* wearable = NULL; // NULL indicates failure diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 4757bd42e0..ca854ac7f7 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 @@ -464,7 +469,7 @@ void LLWorldMapView::draw() 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(); @@ -500,7 +505,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 +516,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 +529,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(); } @@ -828,11 +838,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 +854,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 +876,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 +921,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 +987,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/pipeline.cpp b/indra/newview/pipeline.cpp index 7b8739c7df..081f4a3564 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -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; @@ -2110,9 +2109,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) @@ -3895,20 +3894,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; @@ -8075,7 +8071,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 +8108,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 +8219,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 +8301,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 +8327,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 +8559,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 +8669,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 +8920,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 +8931,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 +9196,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 +9211,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 +9246,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 +9289,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 +9702,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 +9782,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 +9802,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 +9857,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 +10008,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 +10110,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 +10201,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 +10250,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 +10374,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 +10384,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 +10449,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 +10757,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); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 3687ab32fa..a3ecab3208 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(); @@ -760,10 +760,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]; diff --git a/indra/newview/scripts/lua/auto/menus.lua b/indra/newview/scripts/lua/auto/menus.lua new file mode 100644 index 0000000000..b2f54d83df --- /dev/null +++ b/indra/newview/scripts/lua/auto/menus.lua @@ -0,0 +1,51 @@ +-- Inject Lua-related menus into the top menu structure. Run this as a Lua +-- script so that turning off the Lua feature also disables these menus. + +-- Under Develop -> Consoles, want to present the equivalent of: +-- <menu_item_separator/> +-- <menu_item_check +-- label="LUA Debug Console" +-- name="LUA Debug Console"> +-- <menu_item_check.on_check +-- function="Floater.Visible" +-- parameter="lua_debug" /> +-- <menu_item_check.on_click +-- function="Floater.Toggle" +-- parameter="lua_debug" /> +-- </menu_item_check> +-- <menu_item_check +-- label="LUA Scripts Info" +-- name="LUA Scripts"> +-- <menu_item_check.on_check +-- function="Floater.Visible" +-- parameter="lua_scripts" /> +-- <menu_item_check.on_click +-- function="Floater.Toggle" +-- parameter="lua_scripts" /> +-- </menu_item_check> + +local startup = require 'startup' +local UI = require 'UI' + +-- Don't mess with the viewer's menu structure until we've logged in. +startup.wait('STATE_STARTED') + +-- Add LUA Debug Console to Develop->Consoles +local pos = 9 +UI.addMenuSeparator{ + parent_menu='Consoles', pos=pos, +} +pos += 1 +UI.addMenuItem{ + parent_menu='Consoles', pos=pos, + name='lua_debug', label='LUA Debug Console', + func='Floater.ToggleOrBringToFront', param='lua_debug', +} +pos += 1 + +-- Add LUA Scripts Info to Develop->Consoles +UI.addMenuItem{ + parent_menu='Consoles', pos=pos, + name='lua_scripts', label='LUA Scripts Info', + func='Floater.ToggleOrBringToFront', param='lua_scripts', +} diff --git a/indra/newview/scripts/lua/frame_profile.lua b/indra/newview/scripts/lua/frame_profile.lua new file mode 100644 index 0000000000..3c6353ff68 --- /dev/null +++ b/indra/newview/scripts/lua/frame_profile.lua @@ -0,0 +1,24 @@ +-- Trigger Develop -> Render Tests -> Frame Profile + +LLAgent = require 'LLAgent' +startup = require 'startup' +Timer = (require 'timers').Timer +UI = require 'UI' + +startup.wait('STATE_STARTED') + +-- teleport to http://maps.secondlife.com/secondlife/Bug%20Island/220/224/27 +print(LLAgent.teleport{regionname='Bug Island', x=220, y=224, z=27}) +Timer(10, 'wait') +LLAgent.setCamera{camera_pos={220, 224, 26}, camera_locked=true, + focus_pos ={228, 232, 26}, focus_locked=true} +Timer(1, 'wait') +-- This freezes the viewer for perceptible realtime +UI.popup:tip('starting Render Tests -> Frame Profile') +UI.call("Advanced.ClickRenderProfile") +Timer(1, 'wait') +LLAgent.removeCamParams() +LLAgent.setFollowCamActive(false) + +-- Home, James! +print(LLAgent.teleport('home')) diff --git a/indra/newview/scripts/lua/frame_profile_quit.lua b/indra/newview/scripts/lua/frame_profile_quit.lua new file mode 100644 index 0000000000..e3177a3f67 --- /dev/null +++ b/indra/newview/scripts/lua/frame_profile_quit.lua @@ -0,0 +1,25 @@ +-- Trigger Develop -> Render Tests -> Frame Profile and quit + +LLAgent = require 'LLAgent' +logout = require 'logout' +startup = require 'startup' +Timer = (require 'timers').Timer +UI = require 'UI' + +startup.wait('STATE_STARTED') + +-- Assume we logged into http://maps.secondlife.com/secondlife/Bug%20Island/220/224/27 +-- (see frame_profile bash script) +Timer(10, 'wait') +LLAgent.setCamera{camera_pos={220, 224, 26}, camera_locked=true, + focus_pos ={228, 232, 26}, focus_locked=true} +Timer(1, 'wait') +-- This freezes the viewer for perceptible realtime +UI.popup:tip('starting Render Tests -> Frame Profile') +UI.call("Advanced.ClickRenderProfile") +Timer(1, 'wait') +LLAgent.removeCamParams() +LLAgent.setFollowCamActive(false) + +-- done +logout() diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua index 07ef1e0b0b..5cee998fcd 100644 --- a/indra/newview/scripts/lua/require/LLAgent.lua +++ b/indra/newview/scripts/lua/require/LLAgent.lua @@ -71,4 +71,13 @@ function LLAgent.getAnimationInfo(item_id) return leap.request('LLAgent', {op = 'getAnimationInfo', item_id=item_id}).anim_info end +-- Teleport to specified "regionname" at specified region-relative "x", "y", "z". +-- If "regionname" is "home", ignore "x", "y", "z" and teleport home. +-- If "regionname" omitted, teleport to GLOBAL coordinates "x", "y", "z". +function LLAgent.teleport(...) + local args = mapargs('regionname,x,y,z', ...) + args.op = 'teleport' + return leap.request('LLTeleportHandler', args).message +end + return LLAgent diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua index 73a76fa6b8..cf2695917e 100644 --- a/indra/newview/scripts/lua/require/UI.lua +++ b/indra/newview/scripts/lua/require/UI.lua @@ -170,13 +170,13 @@ end -- see UI.callables() for valid values of 'func' function UI.addMenuItem(...) - local args = mapargs('name,label,parent_menu,func,param', ...) + local args = mapargs('name,label,parent_menu,func,param,pos', ...) args.op = 'addMenuItem' return leap.request('UI', args) end function UI.addMenuSeparator(...) - local args = mapargs('parent_menu', ...) + local args = mapargs('parent_menu,pos', ...) args.op = 'addMenuSeparator' return leap.request('UI', args) end diff --git a/indra/newview/scripts/lua/test_animation.lua b/indra/newview/scripts/lua/test_animation.lua index c16fef4918..37e7254a6c 100644 --- a/indra/newview/scripts/lua/test_animation.lua +++ b/indra/newview/scripts/lua/test_animation.lua @@ -11,18 +11,22 @@ for key in pairs(anims) do table.insert(anim_ids, key) end --- Start playing a random animation -math.randomseed(os.time()) -local random_id = anim_ids[math.random(#anim_ids)] -local anim_info = LLAgent.getAnimationInfo(random_id) +if #anim_ids == 0 then + print("No animations found") +else + -- Start playing a random animation + math.randomseed(os.time()) + local random_id = anim_ids[math.random(#anim_ids)] + local anim_info = LLAgent.getAnimationInfo(random_id) -print("Starting animation locally: " .. anims[random_id].name) -print("Loop: " .. anim_info.is_loop .. " Joints: " .. anim_info.num_joints .. " Duration " .. tonumber(string.format("%.2f", anim_info.duration))) -LLAgent.playAnimation{item_id=random_id} + print("Starting animation locally: " .. anims[random_id].name) + print("Loop: " .. anim_info.is_loop .. " Joints: " .. anim_info.num_joints .. " Duration " .. tonumber(string.format("%.2f", anim_info.duration))) + LLAgent.playAnimation{item_id=random_id} --- Stop animation after 3 sec if it's looped or longer than 3 sec -if anim_info.is_loop == 1 or anim_info.duration > 3 then - LL.sleep(3) - print("Stop animation.") - LLAgent.stopAnimation(random_id) + -- Stop animation after 3 sec if it's looped or longer than 3 sec + if anim_info.is_loop == 1 or anim_info.duration > 3 then + LL.sleep(3) + print("Stop animation.") + LLAgent.stopAnimation(random_id) + end end 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/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 8999797049..324e868bd5 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..." @@ -2565,27 +2583,6 @@ function="World.EnvPreset" parameter="scene monitor" /> </menu_item_check> <menu_item_separator/> - <menu_item_check - label="LUA Debug Console" - name="LUA Debug Console"> - <menu_item_check.on_check - function="Floater.Visible" - parameter="lua_debug" /> - <menu_item_check.on_click - function="Floater.Toggle" - parameter="lua_debug" /> - </menu_item_check> - <menu_item_check - label="LUA Scripts Info" - name="LUA Scripts"> - <menu_item_check.on_check - function="Floater.Visible" - parameter="lua_scripts" /> - <menu_item_check.on_click - function="Floater.Toggle" - parameter="lua_scripts" /> - </menu_item_check> - <menu_item_separator/> <menu_item_call label="Region Info to Debug Console" 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/tests/cppfeatures_test.cpp b/indra/newview/tests/cppfeatures_test.cpp index f5ea3a522b..ca94dcfc95 100644 --- a/indra/newview/tests/cppfeatures_test.cpp +++ b/indra/newview/tests/cppfeatures_test.cpp @@ -283,7 +283,7 @@ void cpp_features_test_object_t::test<8>() ensure("init member inline 1", ii.mFoo==10); InitInlineWithConstructor iici; - ensure("init member inline 2", iici.mFoo=10); + ensure("init member inline 2", iici.mFoo==10); ensure("init member inline 3", iici.mBar==25); } diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp index 8d1333815b..f0a1b32eed 100644 --- a/indra/newview/tests/llluamanager_test.cpp +++ b/indra/newview/tests/llluamanager_test.cpp @@ -123,7 +123,7 @@ namespace tut } } - void from_lua(const std::string& desc, const std::string_view& construct, const LLSD& expect) + void from_lua(const std::string& desc, std::string_view construct, const LLSD& expect) { LLSD fromlua; LLStreamListener pump("testpump", diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index aa2b0b0e25..9f77dba3bc 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -166,11 +166,7 @@ class ViewerManifest(LLManifest): self.path("*/*/*/*.js") self.path("*/*/*.html") - with self.prefix(src_dst="scripts/lua"): - self.path("*.lua") - self.path("*.xml") - with self.prefix(src_dst='require'): - self.path("*.lua") + self.path('scripts/lua') #build_data.json. Standard with exception handling is fine. If we can't open a new file for writing, we have worse problems #platform is computed above with other arg parsing diff --git a/indra/test/namedtempfile.h b/indra/test/namedtempfile.h index 8027f95728..96b19523ab 100644 --- a/indra/test/namedtempfile.h +++ b/indra/test/namedtempfile.h @@ -32,18 +32,18 @@ class NamedTempFile: public boost::noncopyable { LOG_CLASS(NamedTempFile); public: - NamedTempFile(const std::string_view& pfx, - const std::string_view& content, - const std::string_view& sfx=std::string_view("")) + NamedTempFile(std::string_view pfx, + std::string_view content, + std::string_view sfx=std::string_view("")) { createFile(pfx, [&content](std::ostream& out){ out << content; }, sfx); } // Disambiguate when passing string literal -- unclear why a string // literal should be ambiguous wrt std::string_view and Streamer - NamedTempFile(const std::string_view& pfx, + NamedTempFile(std::string_view pfx, const char* content, - const std::string_view& sfx=std::string_view("")) + std::string_view sfx=std::string_view("")) { createFile(pfx, [&content](std::ostream& out){ out << content; }, sfx); } @@ -53,9 +53,9 @@ public: // (boost::phoenix::placeholders::arg1 << "the value is " << 17 << '\n') typedef std::function<void(std::ostream&)> Streamer; - NamedTempFile(const std::string_view& pfx, + NamedTempFile(std::string_view pfx, const Streamer& func, - const std::string_view& sfx=std::string_view("")) + std::string_view sfx=std::string_view("")) { createFile(pfx, func, sfx); } @@ -94,8 +94,8 @@ public: return out; } - static boost::filesystem::path temp_path(const std::string_view& pfx="", - const std::string_view& sfx="") + static boost::filesystem::path temp_path(std::string_view pfx="", + std::string_view sfx="") { // This variable is set by GitHub actions and is the recommended place // to put temp files belonging to an actions job. @@ -114,9 +114,9 @@ public: } protected: - void createFile(const std::string_view& pfx, + void createFile(std::string_view pfx, const Streamer& func, - const std::string_view& sfx) + std::string_view sfx) { // Create file in a temporary place. mPath = temp_path(pfx, sfx); @@ -137,7 +137,7 @@ class NamedExtTempFile: public NamedTempFile { LOG_CLASS(NamedExtTempFile); public: - NamedExtTempFile(const std::string& ext, const std::string_view& content): + NamedExtTempFile(const std::string& ext, std::string_view content): NamedTempFile(remove_dot(ext), content, ensure_dot(ext)) {} |