summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2025-07-31 20:42:38 +0800
committerErik Kundiman <erik@megapahit.org>2025-07-31 20:48:39 +0800
commitb81c1c4e871be0ff5e5dbbfa235571350cd477fe (patch)
tree2a3e599e3db36bd42628fcb681a67b7b956a6ab1
parent0146a8b3119e2c6c652dd7b608de9efcdbd3fd50 (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).
-rw-r--r--indra/newview/llavatarlist.cpp70
-rw-r--r--indra/newview/llavatarlist.h4
-rw-r--r--indra/newview/llpanelpeople.cpp4
3 files changed, 27 insertions, 51 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()
{
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index 97b4f05985..5ef7eeb041 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -74,6 +74,7 @@ public:
uuid_vec_t& getIDs() { return mIDs; }
bool contains(const LLUUID& id);
+ void setAvatarsPositions(const std::map<LLUUID, LLVector3d>& avatarsPositions);
void setContextMenu(LLListContextMenu* menu) { mContextMenu = menu; }
void setSessionID(const LLUUID& session_id) { mSessionID = session_id; }
const LLUUID& getSessionID() { return mSessionID; }
@@ -114,8 +115,6 @@ protected:
const uuid_vec_t& vnew,
uuid_vec_t& vadded,
uuid_vec_t& vremoved);
- void updateAvatarArrivalTime();
- void updateAvatarDistance();
void updateLastInteractionTimes();
void rebuildNames();
void onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask);
@@ -144,6 +143,7 @@ private:
uuid_vec_t mIDs;
LLUUID mSessionID;
+ std::map<LLUUID, LLVector3d> mAvatarsPositions;
LLListContextMenu* mContextMenu;
commit_signal_t mRefreshCompleteSignal;
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index bf2462d7d9..6d1c71b893 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -160,6 +160,7 @@ public:
mAvatarsPositions[*id_it] = *pos_it;
}
};
+ const id_to_pos_map_t& getAvatarsPositions() const { return mAvatarsPositions; }
protected:
virtual bool doCompare(const LLAvatarListItem* item1, const LLAvatarListItem* item2) const
@@ -849,6 +850,7 @@ void LLPanelPeople::updateNearbyList()
#endif
DISTANCE_COMPARATOR.updateAvatarsPositions(positions, mNearbyList->getIDs());
+ mNearbyList->setAvatarsPositions(DISTANCE_COMPARATOR.getAvatarsPositions());
LLActiveSpeakerMgr::instance().update(true);
}
@@ -1569,7 +1571,7 @@ bool LLPanelPeople::updateNearbyArrivalTime()
{
std::vector<LLVector3d> positions;
std::vector<LLUUID> uuids;
- static LLCachedControl<F32> range(gSavedSettings, "NearMeRange");
+ static LLCachedControl<F32> range(gSavedSettings, "MPVNearMeRange");
LLWorld::getInstance()->getAvatars(&uuids, &positions, gAgent.getPositionGlobal(), range);
LLRecentPeople::instance().updateAvatarsArrivalTime(uuids);
return LLApp::isExiting();