From 3c464b4d8bb9bed58edc0418a8c91e8a609b5160 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Thu, 31 Jul 2025 23:39:09 +0800 Subject: Optimise arrival & departure notifications by not having extra calls to getAvatars. The avatars' positions member had to be moved to an object that is accessible from VOAvatar too, and that would be the global Agent. It makes sense too, that it's the object that keeps the positions of other agents. It even has a section for positions too. --- indra/newview/llvoavatar.cpp | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'indra/newview/llvoavatar.cpp') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 53832422d8..082b1349cf 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -818,7 +818,8 @@ LLVOAvatar::~LLVOAvatar() { sInstances.remove(this); - if (gSavedSettings.getBOOL("IMShowArrivalsDepartures")) + static LLCachedControl show_arrival_departures(gSavedSettings, "IMShowArrivalsDepartures", false); + if (show_arrival_departures) { LLAvatarName av_name; LLAvatarNameCache::get(getID(), &av_name); @@ -2583,31 +2584,21 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys, { mDebugExistenceTimer.reset(); debugAvatarRezTime("AvatarRezArrivedNotification", "avatar arrived"); - if (gSavedSettings.getBOOL("IMShowArrivalsDepartures")) + static LLCachedControl show_arrival_departures(gSavedSettings, "IMShowArrivalsDepartures", false); + if (show_arrival_departures) { - uuid_vec_t uuids; - std::vector positions; - LLWorld::getInstance()->getAvatars(&uuids, &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("MPVNearMeRange")); - auto pos_it = positions.begin(); - auto id_it = uuids.begin(); - for (;pos_it != positions.end() && id_it != uuids.end(); ++pos_it, ++id_it) - { - if (*id_it == getID() && !isSelf()) - { - LLAvatarName av_name; - LLAvatarNameCache::get(getID(), &av_name); - auto display_name = av_name.getDisplayName(); - if (!display_name.empty()) - { - LLChat chat{llformat("%s arrived (%.1f m).", display_name.c_str(), dist_vec(*pos_it, gAgent.getPositionGlobal()))}; - chat.mFromName = display_name; - chat.mFromID = getID(); - LLSD args; - args["COLOR"] = "ChatHistoryTextColor"; - LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); - } - break; - } + LLAvatarName av_name; + LLAvatarNameCache::get(getID(), &av_name); + auto display_name = av_name.getDisplayName(); + if (!display_name.empty()) + { + auto avatarsPositions = gAgent.getAvatarsPositions(); + LLChat chat{llformat("%s arrived (%.1f m).", display_name.c_str(), dist_vec(avatarsPositions[getID()], gAgent.getPositionGlobal()))}; + chat.mFromName = display_name; + chat.mFromID = getID(); + LLSD args; + args["COLOR"] = "ChatHistoryTextColor"; + LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); } } } -- cgit v1.2.3 From 7588afc86a016c00e6263284bc0db6d684c43895 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Fri, 1 Aug 2025 18:25:28 +0800 Subject: Increase chance of arrival notification, correctly Full (user) name should suffice for the chat log, as it's the one that is more of a reference anyway instead of display name. The other avatar's display name is still displayed on the header anyway. Seems like display names have higher chance of being empty, that we would miss it being logged/notified because of that. Also, now that we've optimised the avatars' positions' retrieval, the numbers can come later after some avatar arrives, that getting the position using the avatar's ID as the key would result in zero. In that case, rather than reporting wrong distances (like 403996.2), it's better to just skip distance information (it shouldn't matter that much anyway). --- indra/newview/llvoavatar.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'indra/newview/llvoavatar.cpp') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 082b1349cf..f52d45b4b9 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -821,13 +821,11 @@ LLVOAvatar::~LLVOAvatar() static LLCachedControl show_arrival_departures(gSavedSettings, "IMShowArrivalsDepartures", false); if (show_arrival_departures) { - LLAvatarName av_name; - LLAvatarNameCache::get(getID(), &av_name); - auto display_name = av_name.getDisplayName(); - if (!display_name.empty()) + auto full_name = getFullname(); + if (!full_name.empty()) { - LLChat chat{llformat("%s left.", display_name.c_str())}; - chat.mFromName = display_name; + LLChat chat{llformat("%s left.", full_name.c_str())}; + chat.mFromName = full_name; chat.mFromID = getID(); LLSD args; args["COLOR"] = "ChatHistoryTextColor"; @@ -2587,15 +2585,15 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys, static LLCachedControl show_arrival_departures(gSavedSettings, "IMShowArrivalsDepartures", false); if (show_arrival_departures) { - LLAvatarName av_name; - LLAvatarNameCache::get(getID(), &av_name); - auto display_name = av_name.getDisplayName(); - if (!display_name.empty()) + auto full_name = getFullname(); + if (!full_name.empty()) { auto avatarsPositions = gAgent.getAvatarsPositions(); - LLChat chat{llformat("%s arrived (%.1f m).", display_name.c_str(), dist_vec(avatarsPositions[getID()], gAgent.getPositionGlobal()))}; - chat.mFromName = display_name; - chat.mFromID = getID(); + auto id = getID(); + auto avatarPosition = avatarsPositions[id]; + LLChat chat{std::string{full_name + " arrived" + (avatarPosition.isExactlyZero() ? "" : llformat(" (%.1f m)", dist_vec(avatarPosition, gAgent.getPositionGlobal()))) + "."}}; + chat.mFromName = full_name; + chat.mFromID = id; LLSD args; args["COLOR"] = "ChatHistoryTextColor"; LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); -- cgit v1.2.3