summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2025-07-31 23:39:09 +0800
committerErik Kundiman <erik@megapahit.org>2025-07-31 23:39:09 +0800
commit3c464b4d8bb9bed58edc0418a8c91e8a609b5160 (patch)
treed67b823eefa09b3bb4c1be8182f79367e5f9fb72
parentb81c1c4e871be0ff5e5dbbfa235571350cd477fe (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.
-rw-r--r--indra/newview/llagent.cpp6
-rw-r--r--indra/newview/llagent.h3
-rw-r--r--indra/newview/llavatarlist.cpp11
-rw-r--r--indra/newview/llavatarlist.h2
-rw-r--r--indra/newview/llpanelpeople.cpp2
-rw-r--r--indra/newview/llvoavatar.cpp41
6 files changed, 30 insertions, 35 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index f7b48d25f2..0cd343b46e 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1305,6 +1305,12 @@ const LLVector3 &LLAgent::getPositionAgent()
return mFrameAgent.getOrigin();
}
+void LLAgent::setAvatarsPositions(const std::map<LLUUID, LLVector3d>& avatarsPositions)
+{
+ mAvatarsPositions.clear();
+ mAvatarsPositions = avatarsPositions;
+}
+
boost::signals2::connection LLAgent::whenPositionChanged(position_signal_t::slot_type fn)
{
return mOnPositionChanged.connect(fn);
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index b475782946..a2d2ecea9f 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -195,6 +195,8 @@ public:
// Call once per frame to update position, angles (radians).
void updateAgentPosition(const F32 dt, const F32 yaw, const S32 mouse_x, const S32 mouse_y);
void setPositionAgent(const LLVector3 &center);
+ void setAvatarsPositions(const std::map<LLUUID, LLVector3d>& avatarsPositions);
+ const std::map<LLUUID, LLVector3d>& getAvatarsPositions() const { return mAvatarsPositions;}
boost::signals2::connection whenPositionChanged(position_signal_t::slot_type fn);
@@ -205,6 +207,7 @@ private:
position_signal_t mOnPositionChanged;
LLVector3d mLastTestGlobal;
+ std::map<LLUUID, LLVector3d> mAvatarsPositions;
//--------------------------------------------------------------------
// Velocity
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 834288a93e..e29be0c757 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -186,12 +186,6 @@ 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()
{
@@ -224,7 +218,10 @@ void LLAvatarList::draw()
item->setAvatarArrivalTime(secs_since);
}
if (mAvatarDistance)
- item->setAvatarDistance(dist_vec(mAvatarsPositions[item->getAvatarId()], gAgent.getPositionGlobal()));
+ {
+ auto avatarsPositions = gAgent.getAvatarsPositions();
+ item->setAvatarDistance(dist_vec(avatarsPositions[item->getAvatarId()], gAgent.getPositionGlobal()));
+ }
}
}
if (mShowLastInteractionTime)
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index 5ef7eeb041..e6e0728a3f 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -74,7 +74,6 @@ 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; }
@@ -143,7 +142,6 @@ 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 6d1c71b893..aca8cf189b 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -850,7 +850,7 @@ void LLPanelPeople::updateNearbyList()
#endif
DISTANCE_COMPARATOR.updateAvatarsPositions(positions, mNearbyList->getIDs());
- mNearbyList->setAvatarsPositions(DISTANCE_COMPARATOR.getAvatarsPositions());
+ gAgent.setAvatarsPositions(DISTANCE_COMPARATOR.getAvatarsPositions());
LLActiveSpeakerMgr::instance().update(true);
}
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);
}
}
}