summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMonroe Linden <monroe@lindenlab.com>2009-11-16 16:52:43 -0800
committerMonroe Linden <monroe@lindenlab.com>2009-11-16 16:52:43 -0800
commitd504efe3018bd0ce616e67c30b0bb31f5637973a (patch)
tree24b1db24d8f0165e0b058f74f8b4c0c033914b0a /indra
parent39efc3de51443bf8a0e6167e9f92833f8480968e (diff)
Made nearby media list sort on distance from avatar instead of priority.
When the MediaPerformanceManagerDebug debug setting is enabled, the list will sort by priority the way it used to.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llviewermedia.cpp62
-rw-r--r--indra/newview/llviewermedia.h2
2 files changed, 44 insertions, 20 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 70490d3a6e..4663e9c8e6 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -32,6 +32,7 @@
#include "llviewerprecompiledheaders.h"
+#include "llagent.h"
#include "llviewermedia.h"
#include "llviewermediafocus.h"
#include "llmimetypes.h"
@@ -571,6 +572,11 @@ bool LLViewerMedia::priorityComparitor(const LLViewerMediaImpl* i1, const LLView
// Playable items sort above ones that wouldn't play even if they got high enough priority
return false;
}
+ else if(i1->getInterest() == i2->getInterest())
+ {
+ // Generally this will mean both objects have zero interest. In this case, sort on distance.
+ return (i1->getProximityDistance() < i2->getProximityDistance());
+ }
else
{
// The object with the larger interest value should be earlier in the list, so we reverse the sense of the comparison here.
@@ -578,6 +584,11 @@ bool LLViewerMedia::priorityComparitor(const LLViewerMediaImpl* i1, const LLView
}
}
+static bool proximity_comparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2)
+{
+ return (i1->getProximityDistance() < i2->getProximityDistance());
+}
+
//////////////////////////////////////////////////////////////////////////////////////////
// static
void LLViewerMedia::updateMedia()
@@ -603,12 +614,9 @@ void LLViewerMedia::updateMedia()
int impl_count_total = 0;
int impl_count_interest_low = 0;
int impl_count_interest_normal = 0;
- int i = 0;
-
-#if 0
- LL_DEBUGS("PluginPriority") << "Sorted impls:" << llendl;
-#endif
-
+
+ std::vector<LLViewerMediaImpl*> proximity_order;
+
U32 max_instances = gSavedSettings.getU32("PluginInstancesTotal");
U32 max_normal = gSavedSettings.getU32("PluginInstancesNormal");
U32 max_low = gSavedSettings.getU32("PluginInstancesLow");
@@ -714,23 +722,27 @@ void LLViewerMedia::updateMedia()
}
else
{
- // Other impls just get the same ordering as the priority list (for now).
- pimpl->mProximity = i;
+ proximity_order.push_back(pimpl);
}
-#if 0
- LL_DEBUGS("PluginPriority") << " " << pimpl
- << ", setting priority to " << new_priority
- << (pimpl->hasFocus()?", HAS FOCUS":"")
- << (pimpl->getUsedInUI()?", is UI":"")
- << ", cpu " << pimpl->getCPUUsage()
- << ", interest " << pimpl->getInterest()
- << ", media url " << pimpl->getMediaURL() << llendl;
-#endif
-
total_cpu += pimpl->getCPUUsage();
-
- i++;
+ }
+
+ if(gSavedSettings.getBOOL("MediaPerformanceManagerDebug"))
+ {
+ // Give impls the same ordering as the priority list
+ // they're already in the right order for this.
+ }
+ else
+ {
+ // Use a distance-based sort for proximity values.
+ std::stable_sort(proximity_order.begin(), proximity_order.end(), proximity_comparitor);
+ }
+
+ // Transfer the proximity order to the proximity fields in the objects.
+ for(int i = 0; i < proximity_order.size(); i++)
+ {
+ proximity_order[i]->mProximity = i;
}
LL_DEBUGS("PluginPriority") << "Total reported CPU usage is " << total_cpu << llendl;
@@ -782,6 +794,7 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id,
mIsDisabled(false),
mIsParcelMedia(false),
mProximity(-1),
+ mProximityDistance(0.0f),
mMimeTypeProbe(NULL),
mIsUpdated(false)
{
@@ -2109,6 +2122,15 @@ void LLViewerMediaImpl::calculateInterest()
mInterest = 0.0f;
}
+ // Calculate distance from the avatar, for use in the proximity calculation.
+ mProximityDistance = 0.0f;
+ if(!mObjectList.empty())
+ {
+ // Just use the first object in the list. We could go through the list and find the closest object, but this should work well enough.
+ LLVector3d global_delta = gAgent.getPositionGlobal() - (*mObjectList.begin())->getPositionGlobal();
+ mProximityDistance = global_delta.magVecSquared(); // use distance-squared because it's cheaper and sorts the same.
+ }
+
if(mNeedsMuteCheck)
{
// Check all objects this instance is associated with, and those objects' owners, against the mute list
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index a06079786e..f4afce6c4c 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -270,6 +270,7 @@ public:
F64 getInterest() const { return mInterest; };
F64 getApproximateTextureInterest();
S32 getProximity() const { return mProximity; };
+ F64 getProximityDistance() const { return mProximityDistance; };
// Mark this object as being used in a UI panel instead of on a prim
// This will be used as part of the interest sorting algorithm.
@@ -339,6 +340,7 @@ public:
bool mIsDisabled;
bool mIsParcelMedia;
S32 mProximity;
+ F64 mProximityDistance;
LLMimeDiscoveryResponder *mMimeTypeProbe;
private: