[Radar] Reroute some code, optimize silly stuff away.

No more dead state, death is instant when you disappear
No more dependency on frame or life time, updates come from the sims.
No need to rate control anymore, ui removed.

RIP: My headphones, you were shortlived, but you served my ears well.
This commit is contained in:
Inusaito Sayori
2015-06-25 02:57:48 -04:00
parent fdab6d0efb
commit b3b2da1428
9 changed files with 44 additions and 182 deletions

View File

@@ -7768,17 +7768,6 @@ This should be as low as possible, but too low may break functionality</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>RadarUpdateRate</key>
<map>
<key>Comment</key>
<string>Radar update rate (0 = high, 1 = medium, 2 = low)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>RadarAlertShowDist</key>
<map>
<key>Comment</key>

View File

@@ -559,12 +559,9 @@ LLUUID cmdline_partial_name2key(std::string partial_name)
std::string av_name;
LLStringUtil::toLower(partial_name);
LLWorld::getInstance()->getAvatars(&avatars);
bool has_avatarlist = LLFloaterAvatarList::instanceExists();
if (has_avatarlist)
LLFloaterAvatarList::getInstance()->updateAvatarList();
for(std::vector<LLUUID>::const_iterator i = avatars.begin(); i != avatars.end(); ++i)
{
if (LLAvatarListEntry* entry = has_avatarlist ? LLFloaterAvatarList::instance().getAvatarEntry(*i) : NULL)
if (LLAvatarListEntry* entry = LLFloaterAvatarList::instanceExists() ? LLFloaterAvatarList::instance().getAvatarEntry(*i) : NULL)
av_name = entry->getName();
else if (gCacheName->getFullName(*i, av_name));
else if (LLVOAvatar* avatarp = gObjectList.findAvatar(*i))

View File

@@ -35,7 +35,6 @@
#include "llagent.h"
#include "llagentcamera.h"
#include "llavataractions.h"
#include "llcallbacklist.h"
#include "llfloaterchat.h"
#include "llfloaterregioninfo.h"
#include "llfloaterreporter.h"
@@ -59,10 +58,7 @@
#include "rlvhandler.h"
// [/RLVa:KB]
/**
* @brief How long to keep people who are gone in the list and in memory.
*/
const F32 DEAD_KEEP_TIME = 0.5f;
LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& origin);
extern U32 gFrameCount;
@@ -138,7 +134,7 @@ namespace
LLAvatarListEntry::LLAvatarListEntry(const LLUUID& id, const std::string& name, const LLVector3d& position) :
mID(id), mName(name), mPosition(position), mMarked(false), mFocused(false),
mUpdateTimer(), mFrame(gFrameCount), mStats(),
mStats(),
mActivityType(ACTIVITY_NEW), mActivityTimer(),
mIsInList(false), mAge(-1), mTime(time(NULL))
{
@@ -190,7 +186,6 @@ void LLAvatarListEntry::processProperties(void* data, EAvatarProcessorType type)
void LLAvatarListEntry::setPosition(const LLVector3d& position, const F32& dist, bool drawn)
{
mPosition = position;
mFrame = gFrameCount;
bool here(dist != F32_MIN); // F32_MIN only if dead
bool this_sim(here && (gAgent.getRegion()->pointInRegionGlobal(position) || !(LLWorld::getInstance()->positionRegionValidGlobal(position))));
if (this_sim != mStats[STAT_TYPE_SIM]) chat_avatar_status(mName, mID, STAT_TYPE_SIM, mStats[STAT_TYPE_SIM] = this_sim, dist);
@@ -199,22 +194,6 @@ void LLAvatarListEntry::setPosition(const LLVector3d& position, const F32& dist,
if (shoutrange != mStats[STAT_TYPE_SHOUTRANGE]) chat_avatar_status(mName, mID, STAT_TYPE_SHOUTRANGE, mStats[STAT_TYPE_SHOUTRANGE] = shoutrange, dist);
bool chatrange(here && dist < LFSimFeatureHandler::getInstance()->sayRange());
if (chatrange != mStats[STAT_TYPE_CHATRANGE]) chat_avatar_status(mName, mID, STAT_TYPE_CHATRANGE, mStats[STAT_TYPE_CHATRANGE] = chatrange, dist);
mUpdateTimer.start();
}
bool LLAvatarListEntry::getAlive() const
{
return ((gFrameCount - mFrame) <= 2);
}
F32 LLAvatarListEntry::getEntryAgeSeconds() const
{
return mUpdateTimer.getElapsedTimeF32();
}
bool LLAvatarListEntry::isDead() const
{
return getEntryAgeSeconds() > DEAD_KEEP_TIME;
}
void LLAvatarListEntry::resetName(const bool& hide_tags, const bool& anon_names, const std::string& hidden)
@@ -244,7 +223,6 @@ const LLAvatarListEntry::ACTIVITY_TYPE LLAvatarListEntry::getActivity()
{
mActivityType = ACTIVITY_NONE;
}
if (isDead()) return ACTIVITY_DEAD;
return mActivityType;
}
@@ -253,7 +231,6 @@ LLFloaterAvatarList::LLFloaterAvatarList() : LLFloater(std::string("radar")),
mTracking(false),
mUpdate("RadarUpdateEnabled"),
mDirtyAvatarSorting(false),
mUpdateRate(gSavedSettings.getU32("RadarUpdateRate") * 3 + 3),
mAvatarList(NULL)
{
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_radar.xml");
@@ -261,7 +238,6 @@ LLFloaterAvatarList::LLFloaterAvatarList() : LLFloater(std::string("radar")),
LLFloaterAvatarList::~LLFloaterAvatarList()
{
gIdleCallbacks.deleteFunction(LLFloaterAvatarList::callbackIdle);
}
//static
@@ -423,9 +399,6 @@ BOOL LLFloaterAvatarList::postBuild()
childSetAction("send_keys_btn", boost::bind(&LLFloaterAvatarList::sendKeys, this));
getChild<LLRadioGroup>("update_rate")->setSelectedIndex(gSavedSettings.getU32("RadarUpdateRate"));
getChild<LLRadioGroup>("update_rate")->setCommitCallback(boost::bind(&LLFloaterAvatarList::onCommitUpdateRate, this));
gSavedSettings.getControl("RadarColumnMarkHidden")->getSignal()->connect(boost::bind(&LLFloaterAvatarList::assessColumns, this));
gSavedSettings.getControl("RadarColumnPositionHidden")->getSignal()->connect(boost::bind(&LLFloaterAvatarList::assessColumns, this));
gSavedSettings.getControl("RadarColumnAltitudeHidden")->getSignal()->connect(boost::bind(&LLFloaterAvatarList::assessColumns, this));
@@ -443,8 +416,6 @@ BOOL LLFloaterAvatarList::postBuild()
mAvatarList->setSortChangedCallback(boost::bind(&LLFloaterAvatarList::onAvatarSortingChanged,this));
refreshAvatarList();
gIdleCallbacks.addFunction(LLFloaterAvatarList::callbackIdle);
assessColumns();
if(gHippoGridManager->getConnectedGrid()->isSecondLife())
@@ -538,10 +509,8 @@ void updateParticleActivity(LLDrawable *drawablep)
}
}
void LLFloaterAvatarList::updateAvatarList()
void LLFloaterAvatarList::updateAvatarList(const LLViewerRegion* region)
{
//LL_INFOS() << "radar refresh: updating map" << LL_ENDL;
// Check whether updates are enabled
if (!mUpdate)
{
@@ -550,10 +519,12 @@ void LLFloaterAvatarList::updateAvatarList()
}
{
LLWorld::pos_map_t avs;
LLVector3d mypos = gAgent.getPositionGlobal();
const std::vector<U32>& map_avs(region->mMapAvatars);
const std::vector<LLUUID>& map_avids(region->mMapAvatarIDs);
const LLVector3d& mypos(gAgent.getPositionGlobal());
const LLVector3d& origin(region->getOriginGlobal());
static const LLCachedControl<F32> radar_range_radius("RadarRangeRadius", 0);
LLWorld::instance().getAvatars(&avs, mypos, radar_range_radius ? radar_range_radius : F32_MAX);
const F32 max_range(radar_range_radius * radar_range_radius);
static LLCachedControl<bool> announce(gSavedSettings, "RadarChatKeys");
std::queue<LLUUID> announce_keys;
@@ -561,19 +532,21 @@ void LLFloaterAvatarList::updateAvatarList()
bool no_names(gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMETAGS));
bool anon_names(!no_names && gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES));
const std::string& rlv_hidden(RlvStrings::getString(RLV_STRING_HIDDEN));
for (LLWorld::pos_map_t::const_iterator i = avs.cbegin(), end = avs.cend(); i != end; ++i)
for (size_t i = 0, size = map_avs.size(); i < size; ++i)
{
const LLUUID& avid = i->first;
const LLUUID& avid = map_avids[i];
LLVector3d position(unpackLocalToGlobalPosition(map_avs[i], origin));
LLVOAvatar* avatarp = gObjectList.findAvatar(avid);
if (avatarp) position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition());
if (max_range && dist_vec_squared(position, mypos) > max_range) continue; // Out of desired range
std::string name;
if (no_names) name = rlv_hidden;
else if (!LLAvatarNameCache::getNSName(avid, name, radar_namesystem())) continue; //prevent (Loading...)
else if (anon_names) name = RlvStrings::getAnonym(name);
LLVector3d position = i->second;
LLVOAvatar* avatarp = gObjectList.findAvatar(avid);
if (avatarp) position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition());
LLAvatarListEntry* entry = getAvatarEntry(avid);
if (!entry)
{
@@ -617,10 +590,20 @@ void LLFloaterAvatarList::updateAvatarList()
if (num_ids) send_keys_message(transact_num, num_ids, ids.str());
}
}
}
// LL_INFOS() << "radar refresh: done" << LL_ENDL;
expireAvatarList();
void LLFloaterAvatarList::expireAvatarList(const std::list<LLUUID>& ids)
{
BOOST_FOREACH(const LLUUID& id, ids)
{
av_list_t::iterator it(std::find_if(mAvatars.begin(), mAvatars.end(), LLAvatarListEntry::uuidMatch(id)));
if (it != mAvatars.end())
{
LLAvatarListEntry* entry = it->get();
entry->setPosition(entry->getPosition(), F32_MIN, false); // Dead and gone
mAvatars.erase(it);
}
}
if (mAvatars.empty())
setTitle(getString("Title"));
@@ -637,24 +620,6 @@ void LLFloaterAvatarList::updateAvatarList()
refreshTracker();
}
void LLFloaterAvatarList::expireAvatarList()
{
// LL_INFOS() << "radar: expiring" << LL_ENDL;
for(av_list_t::iterator it = mAvatars.begin(); it != mAvatars.end();)
{
LLAvatarListEntry* entry = it->get();
if (entry->getAlive() && !entry->isDead())
{
++it;
}
else
{
entry->setPosition(entry->getPosition(), F32_MIN, false); // Dead and gone
it = mAvatars.erase(it);
}
}
}
void LLFloaterAvatarList::updateAvatarSorting()
{
if (mDirtyAvatarSorting)
@@ -707,9 +672,6 @@ void LLFloaterAvatarList::refreshAvatarList()
bool name_restricted(gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMETAGS) || gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES));
BOOST_FOREACH(av_list_t::value_type& entry, mAvatars)
{
// Skip if avatar hasn't been around
if (entry->isDead()) continue;
LLVector3d position = entry->getPosition();
LLVector3d delta = position - mypos;
bool UnknownAltitude = position.mdV[VZ] == (gHippoGridManager->getConnectedGrid()->isSecondLife() ? 1020.f : 0.f);
@@ -1510,19 +1472,6 @@ void LLFloaterAvatarList::callbackBanFromEstate(const LLSD& notification, const
}
}
//static
void LLFloaterAvatarList::callbackIdle(void*)
{
if (instanceExists())
{
LLFloaterAvatarList& inst(instance());
const U32& rate = inst.mUpdateRate;
// Do not update at every frame: this would be insane!
if (rate == 0 || (gFrameCount % rate == 0))
inst.updateAvatarList();
}
}
void LLFloaterAvatarList::onClickFreeze()
{
LLSD args;
@@ -1580,8 +1529,3 @@ void LLFloaterAvatarList::onSelectName()
}
}
}
void LLFloaterAvatarList::onCommitUpdateRate()
{
mUpdateRate = gSavedSettings.getU32("RadarUpdateRate") * 3 + 3;
}

View File

@@ -62,7 +62,6 @@ enum ACTIVITY_TYPE
ACTIVITY_TYPING, /** Typing */
ACTIVITY_NEW, /** Avatar just appeared */
ACTIVITY_SOUND, /** Playing a sound */
ACTIVITY_DEAD /** Avatar isn't around anymore, and will be removed soon from the list */
};
/**
* @brief Initializes a list entry
@@ -84,19 +83,6 @@ enum ACTIVITY_TYPE
const LLVector3d& getPosition() const { return mPosition; }
/**
* @brief Returns the age of this entry in frames
*
* This is only used for determining whether the avatar is still around.
* @see getEntryAgeSeconds
*/
bool getAlive() const;
/**
* @brief Returns the age of this entry in seconds
*/
F32 getEntryAgeSeconds() const;
/*
* @brief resets the name accordance with RLVa
*/
@@ -137,11 +123,6 @@ enum ACTIVITY_TYPE
void setInList() { mIsInList = true; }
bool isInList() const { return mIsInList; }
/**
* @brief Returns whether the item is dead and shouldn't appear in the list
* @returns true if dead
*/
bool isDead() const;
void toggleMark() { mMarked = !mMarked; }
@@ -169,20 +150,9 @@ private:
*/
std::bitset<STAT_TYPE_SIZE> mStats;
/**
* @brief Timer to keep track of whether avatars are still there
*/
LLTimer mUpdateTimer;
ACTIVITY_TYPE mActivityType;
LLTimer mActivityTimer;
/**
* @brief Last frame when this avatar was updated
*/
U32 mFrame;
};
@@ -232,7 +202,7 @@ public:
/**
* @brief Updates the internal avatar list with the currently present avatars.
*/
void updateAvatarList();
void updateAvatarList(const class LLViewerRegion* region);
/**
* @brief Refresh avatar list (display)
@@ -327,7 +297,6 @@ public:
void onClickGetKey();
void onSelectName();
void onCommitUpdateRate();
/**
* @brief These callbacks fire off notifications, which THEN fire the related callback* functions.
@@ -359,7 +328,7 @@ public:
* to keep people passing by in the list long enough that it's possible
* to do something to them.
*/
void expireAvatarList();
void expireAvatarList(const std::list<LLUUID>& ids);
void updateAvatarSorting();
private:
@@ -375,11 +344,6 @@ private:
*/
const LLCachedControl<bool> mUpdate;
/**
* @brief Update rate (if min frames per update)
*/
U32 mUpdateRate;
// tracking data
bool mTracking; // Tracking ?
LLUUID mTrackedAvatar; // Who we are tracking

View File

@@ -57,6 +57,7 @@
#include "llcommandhandler.h"
#include "lldir.h"
#include "lleventpoll.h"
#include "llfloateravatarlist.h"
#include "llfloatergodtools.h"
#include "llfloaterperms.h"
#include "llfloaterreporter.h"
@@ -1250,6 +1251,7 @@ LLHTTPRegistration<CoarseLocationUpdate>
void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
{
//LL_INFOS() << "CoarseLocationUpdate" << LL_ENDL;
std::list<LLUUID> map_avids(mMapAvatarIDs.begin(), mMapAvatarIDs.end());
mMapAvatars.reset();
mMapAvatarIDs.reset(); // only matters in a rare case but it's good to be safe.
@@ -1304,9 +1306,16 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
if(has_agent_data)
{
mMapAvatarIDs.put(agent_id);
map_avids.remove(agent_id);
}
}
}
if (LLFloaterAvatarList::instanceExists())
{
LLFloaterAvatarList& inst(LLFloaterAvatarList::instance());
inst.updateAvatarList(this);
inst.expireAvatarList(map_avids);
}
}
void LLViewerRegion::getInfo(LLSD& info)

View File

@@ -1530,7 +1530,7 @@ void send_agent_resume()
LLAppViewer::instance()->resumeMainloopTimeout();
}
static LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin)
LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin)
{
LLVector3d pos_local;

View File

@@ -65,12 +65,6 @@
<panel label="Optionen" name="options_tab">
<check_box label="Aktualisieren" name="update_enabled_cb" tool_tip="Einstellen ob die Avatarliste sich aktualisieren soll"/>
<text name="rate">Intervall:</text>
<radio_group name="update_rate" tool_tip="Intervall für Radar-Aktualisierung (verbraucht mehr FPS wenn höher)">
<radio_item name="high">Hoch</radio_item>
<radio_item name="medium">Mittel</radio_item>
<radio_item name="low">Niedrig</radio_item>
</radio_group>
<check_box label="Ansagen auch wenn geschlossen" name="keep_open" tool_tip="Fenster verbergen aber Ansagen in Chat weiterführen"/>
<check_box label="IDs an HUD senden" name="radar_chat_keys" tool_tip="Avatar IDs an LSL scripte senden"/>
<button name="send_keys_btn" label="Jetzt anzeigen" tool_tip="Alle IDs jetzt an HUD senden"/>

View File

@@ -296,29 +296,8 @@
hidden="false" mouse_opaque="true" font="SansSerifSmall"
initial_value="true" enabled="true" radio_style="false"
tool_tip="Set whether the avatar list should update" />
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
bottom_delta="-24" drop_shadow_visible="true" enabled="true" font="SansSerifSmall" height="18" left="24"
mouse_opaque="false" name="rate" width="30">
Rate:
</text>
<radio_group draw_border="true" bottom_delta="2" left_delta="44" follows="bottom|left" width="196" height="20"
mouse_opaque="true" name="update_rate" control_name="RadarUpdateRate" enabled="true"
tool_tip="Rate of the radar updates (eats up more FPS when higher)">
<radio_item type="string" length="1" bottom_delta="0" height="16" left_delta="4" mouse_opaque="true"
name="high" width="20" follows="bottom|left">
High
</radio_item>
<radio_item type="string" length="1" bottom_delta="0" height="16" left_delta="30" mouse_opaque="true"
name="medium" width="25" follows="bottom|left">
Medium
</radio_item>
<radio_item type="string" length="1" bottom_delta="0" height="16" left_delta="35" mouse_opaque="true"
name="low" width="20" follows="bottom|left">
Low
</radio_item>
</radio_group>
<check_box height="16" label="Announce even when closed"
left="10" bottom_delta="-24" name="keep_open"
left="10" bottom_delta="-20" name="keep_open"
width="200" follows="bottom|left"
hidden="false" mouse_opaque="true" font="SansSerifSmall"
initial_value="true" enabled="true" radio_style="false"

View File

@@ -58,20 +58,6 @@
<!-- =============================== -->
<panel label="Opciones" name="options_tab">
<check_box label="Actualizar" name="update_enabled_cb" tool_tip="Definir cuando debe ser actualizada la lista de avatares"/>
<text name="rate">
Frec.:
</text>
<radio_group name="update_rate" tool_tip="Frecuencia de actualización del radar (consume mas FPS cuando es alta)">
<radio_item name="high">
Alta
</radio_item>
<radio_item name="medium">
Media
</radio_item>
<radio_item name="low">
Baja
</radio_item>
</radio_group>
<check_box label="Anunciar aún estando cerrado" name="keep_open" tool_tip="Oculta el radar en vez de cerrarlo para seguir enviando los avisos al chat" />
<check_box label="Anunciar keys al HUD" name="radar_chat_keys" tool_tip="Definir cuando enviar las keys de los avarares a los scritps LSL" />
<button name="send_keys_btn" label="Anunciar Ahora" tool_tip="Envia todas las keys al HUD ahora"/>