diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-07-31 23:39:09 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-07-31 23:39:09 +0800 |
commit | 3c464b4d8bb9bed58edc0418a8c91e8a609b5160 (patch) | |
tree | d67b823eefa09b3bb4c1be8182f79367e5f9fb72 /indra/newview/llvoavatar.cpp | |
parent | b81c1c4e871be0ff5e5dbbfa235571350cd477fe (diff) |
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.
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r-- | indra/newview/llvoavatar.cpp | 41 |
1 files changed, 16 insertions, 25 deletions
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<bool> 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<bool> show_arrival_departures(gSavedSettings, "IMShowArrivalsDepartures", false); + if (show_arrival_departures) { - uuid_vec_t uuids; - std::vector<LLVector3d> 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); } } } |