diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-07-31 20:42:38 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-07-31 20:48:39 +0800 |
commit | b81c1c4e871be0ff5e5dbbfa235571350cd477fe (patch) | |
tree | 2a3e599e3db36bd42628fcb681a67b7b956a6ab1 /indra/newview/llavatarlist.cpp | |
parent | 0146a8b3119e2c6c652dd7b608de9efcdbd3fd50 (diff) |
Optimise nearby tab distance & arrival time impl
by not having extra calls to getAvatars, by avoiding unnecessary
function overhead which actually make it possible to share some
iterative code, and by piggybacking updateNearbyList and
updateArrivalTime which is already done periodically though the
range had to be lengthened to match nearby list range which is
MPVNearMeRange instead of SLv's NearMeRange. Minimise differences
from SLv too (arrival time really doesn't need to be updated
*every* second.. every 5 seconds is just okay).
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r-- | indra/newview/llavatarlist.cpp | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 5f9d03ca66..834288a93e 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -48,12 +48,11 @@ #include "llvoiceclient.h" #include "llviewercontrol.h" // for gSavedSettings #include "lltooldraganddrop.h" -#include "llworld.h" static LLDefaultChildRegistry::Register<LLAvatarList> r("avatar_list"); // Last interaction time update period. -static const F32 LIT_UPDATE_PERIOD = 1; +static const F32 LIT_UPDATE_PERIOD = 5; // Maximum number of avatars that can be added to a list in one pass. // Used to limit time spent for avatar list update per frame. @@ -187,6 +186,12 @@ std::string LLAvatarList::getAvatarName(LLAvatarName av_name) return mShowCompleteName? av_name.getCompleteName(false, mForceCompleteName) : av_name.getDisplayName(); } +void LLAvatarList::setAvatarsPositions(const std::map<LLUUID, LLVector3d>& avatarsPositions) +{ + mAvatarsPositions.clear(); + mAvatarsPositions = avatarsPositions; +} + // virtual void LLAvatarList::draw() { @@ -205,13 +210,22 @@ void LLAvatarList::draw() if ((mShowLastInteractionTime || mAvatarDistance || mAvatarArrivalTime) && mLITUpdateTimer->hasExpired()) { - if (mAvatarArrivalTime) + if (mAvatarArrivalTime || mAvatarDistance) { - updateAvatarArrivalTime(); - } - if (mAvatarDistance) - { - updateAvatarDistance(); + std::vector<LLPanel*> items; + getItems(items); + for (auto it = items.begin(); it != items.end(); it++) + { + auto item = static_cast<LLAvatarListItem*>(*it); + if (mAvatarArrivalTime) + { + auto secs_since = LLDate::now().secondsSinceEpoch() - LLRecentPeople::instance().getArrivalTimeByID(item->getAvatarId()); + if (secs_since >= 0) + item->setAvatarArrivalTime(secs_since); + } + if (mAvatarDistance) + item->setAvatarDistance(dist_vec(mAvatarsPositions[item->getAvatarId()], gAgent.getPositionGlobal())); + } } if (mShowLastInteractionTime) { @@ -554,46 +568,6 @@ void LLAvatarList::computeDifference( LLCommonUtils::computeDifference(vnew_unsorted, vcur, vadded, vremoved); } -void LLAvatarList::updateAvatarArrivalTime() -{ - std::vector<LLPanel*> items; - getItems(items); - auto uuids = getIDs(); - std::vector<LLVector3d> positions; - auto me_pos = gAgent.getPositionGlobal(); - LLWorld::getInstance()->getAvatars(&uuids, &positions, me_pos, gSavedSettings.getF32("MPVNearMeRange")); - LLRecentPeople::instance().updateAvatarsArrivalTime(uuids); - for (auto it = items.begin(); it != items.end(); it++) - { - auto item = static_cast<LLAvatarListItem*>(*it); - auto secs_since = LLDate::now().secondsSinceEpoch() - LLRecentPeople::instance().getArrivalTimeByID(item->getAvatarId()); - if (secs_since >= 0) - item->setAvatarArrivalTime(secs_since); - } -} - - void LLAvatarList::updateAvatarDistance() -{ - std::vector<LLPanel*> items; - getItems(items); - auto uuids = getIDs(); - std::vector<LLVector3d> positions; - auto me_pos = gAgent.getPositionGlobal(); - LLWorld::getInstance()->getAvatars(&uuids, &positions, me_pos, gSavedSettings.getF32("MPVNearMeRange")); - std::map <LLUUID, LLVector3d> avatarsPositions; - auto pos_it = positions.begin(); - auto id_it = uuids.begin(); - for (;pos_it != positions.end() && id_it != uuids.end(); ++pos_it, ++id_it) - { - avatarsPositions[*id_it] = *pos_it; - } - for (auto it = items.begin(); it != items.end(); it++) - { - auto item = static_cast<LLAvatarListItem*>(*it); - item->setAvatarDistance(dist_vec(avatarsPositions[item->getAvatarId()], me_pos)); - } -} - // Refresh shown time of our last interaction with all listed avatars. void LLAvatarList::updateLastInteractionTimes() { |