MAINT-3161 : Clean up avatar muting code and prototype feature

master
simon 2013-09-17 17:01:52 -07:00
parent 9c4d4242f6
commit 33e70236f0
10 changed files with 176 additions and 116 deletions

View File

@ -57,7 +57,7 @@ class LLDragDropWin32
#include <windows.h>
#include <ole2.h>
// imposter class that does nothing
// impostor class that does nothing
class LLDragDropWin32
{
public:

View File

@ -9735,10 +9735,11 @@
<key>Value</key>
<integer>1</integer>
</map>
<key>RenderAutoMuteByteLimit</key>
<map>
<key>Comment</key>
<string>Maximum bytes of attachments before an avatar is rendered as a simple imposter (0 for no limit).</string>
<string>Maximum bytes of attachments before an avatar is rendered as a simple impostor (0 for no limit).</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -9746,10 +9747,10 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>RenderAutoMuteRenderCostLimit</key>
<key>RenderAutoMuteRenderWeightLimit</key>
<map>
<key>Comment</key>
<string>Maximum render weight before an avatar is rendered as a simple imposter (0 to not use this limit).</string>
<string>Maximum render weight before an avatar is rendered as a simple impostor (0 to not use this limit).</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -9760,7 +9761,7 @@
<key>RenderAutoMuteSurfaceAreaLimit</key>
<map>
<key>Comment</key>
<string>Maximum surface area of attachments before an avatar is rendered as a simple imposter (0 to not use this limit).</string>
<string>Maximum surface area of attachments before an avatar is rendered as a simple impostor (0 to not use this limit).</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -9768,16 +9769,16 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>RenderAutoMuteThreshold</key>
<key>RenderAutoMuteFunctions</key>
<map>
<key>Comment</key>
<string>Threshold on the Avatar Detail slider where simple imposter mode is enabled. (less than 0 is always on, greather than 1 always off)</string>
<string>Developing feature to render some avatars using simple impostors or colored silhouettes. (Set to 7 for all functionality)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<string>U32</string>
<key>Value</key>
<real>0.25</real>
<real>0</real>
</map>
<key>RenderAutoMuteLogging</key>
<map>

View File

@ -38,6 +38,7 @@
#include "llhttpclient.h"
#include "lltimer.h"
#include "llviewercontrol.h"
#include "llviewermenu.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
#include "llvoavatar.h"
@ -92,7 +93,7 @@ public:
{
if (LLAvatarRenderInfoAccountant::logRenderInfo())
{
llinfos << "Result for avatar weights request for region " << regionp->getName() << ":" << llendl;
llinfos << "LRI: Result for avatar weights request for region " << regionp->getName() << ":" << llendl;
}
if (content.isMap())
@ -115,7 +116,7 @@ public:
if (LLAvatarRenderInfoAccountant::logRenderInfo())
{
llinfos << " Agent " << target_agent_id
llinfos << "LRI: Agent " << target_agent_id
<< ": " << agent_info_map << llendl;
}
@ -186,7 +187,7 @@ public:
{
if (LLAvatarRenderInfoAccountant::logRenderInfo())
{
llinfos << "Result for avatar weights POST for region " << regionp->getName()
llinfos << "LRI: Result for avatar weights POST for region " << regionp->getName()
<< ": " << content << llendl;
}
@ -224,7 +225,7 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio
{
if (logRenderInfo())
{
llinfos << "Sending avatar render info to region "
llinfos << "LRI: Sending avatar render info to region "
<< regionp->getName()
<< " from " << url
<< llendl;
@ -253,7 +254,7 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio
if (logRenderInfo())
{
llinfos << "Sending avatar render info for " << avatar->getID()
llinfos << "LRI: Sending avatar render info for " << avatar->getID()
<< ": " << info << llendl;
}
}
@ -281,7 +282,7 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi
{
if (logRenderInfo())
{
llinfos << "Requesting avatar render info for region "
llinfos << "LRI: Requesting avatar render info for region "
<< regionp->getName()
<< " from " << url
<< llendl;
@ -304,6 +305,12 @@ void LLAvatarRenderInfoAccountant::idle()
S32 num_avs = LLCharacter::sInstances.size();
if (logRenderInfo())
{
llinfos << "LRI: Scanning all regions and checking for render info updates"
<< llendl;
}
// Check all regions and see if it's time to fetch/send data
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
@ -325,6 +332,35 @@ void LLAvatarRenderInfoAccountant::idle()
// We scanned all the regions, reset the request timer.
sRenderInfoReportTimer.resetWithExpiry(SECS_BETWEEN_REGION_SCANS);
}
static LLCachedControl<U32> render_auto_mute_functions(gSavedSettings, "RenderAutoMuteFunctions");
static U32 prev_render_auto_mute_functions = (U32) -1;
if (prev_render_auto_mute_functions != render_auto_mute_functions)
{
prev_render_auto_mute_functions = render_auto_mute_functions;
// Adjust menus
BOOL show_items = (BOOL)(render_auto_mute_functions & 0x04);
gMenuAvatarOther->setItemVisible( std::string("Normal"), show_items);
gMenuAvatarOther->setItemVisible( std::string("Always use impostor"), show_items);
gMenuAvatarOther->setItemVisible( std::string("Never use impostor"), show_items);
gMenuAvatarOther->setItemVisible( std::string("Impostor seperator"), show_items);
gMenuAttachmentOther->setItemVisible( std::string("Normal"), show_items);
gMenuAttachmentOther->setItemVisible( std::string("Always use impostor"), show_items);
gMenuAttachmentOther->setItemVisible( std::string("Never use impostor"), show_items);
gMenuAttachmentOther->setItemVisible( std::string("Impostor seperator"), show_items);
if (!show_items)
{ // Turning off visual muting
for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
iter != LLCharacter::sInstances.end(); ++iter)
{ // Make sure all AVs have the setting cleared
LLVOAvatar* inst = (LLVOAvatar*) *iter;
inst->setCachedVisualMute(false);
}
}
}
}
@ -332,14 +368,23 @@ void LLAvatarRenderInfoAccountant::idle()
// Make sRenderInfoReportTimer expire so the next call to idle() will scan and query a new region
// called via LLViewerRegion::setCapabilitiesReceived() boost signals when the capabilities
// are returned for a new LLViewerRegion, and is the earliest time to get render info
void LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer()
void LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer(const LLUUID& region_id)
{
if (logRenderInfo())
{
llinfos << "Viewer has new region capabilities" << llendl;
llinfos << "LRI: Viewer has new region capabilities, clearing global render info timer"
<< " and timer for region " << region_id
<< llendl;
}
sRenderInfoReportTimer.resetWithExpiry(0.f);
// Reset the global timer so it will scan regions immediately
sRenderInfoReportTimer.reset();
LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id);
if (regionp)
{ // Reset the region's timer so it will request data immediately
regionp->getRenderInfoRequestTimer().reset();
}
}
// static

View File

@ -42,7 +42,7 @@ public:
static void sendRenderInfoToRegion(LLViewerRegion * regionp);
static void getRenderInfoFromRegion(LLViewerRegion * regionp);
static void expireRenderInfoReportTimer();
static void expireRenderInfoReportTimer(const LLUUID& region_id);
static void idle();

View File

@ -2930,7 +2930,7 @@ bool enable_object_unmute()
// 0 = normal, 1 = always, 2 = never
class LLAvatarCheckImposterMode : public view_listener_t
class LLAvatarCheckImpostorMode : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
@ -2956,7 +2956,7 @@ class LLAvatarCheckImposterMode : public view_listener_t
};
// 0 = normal, 1 = always, 2 = never
class LLAvatarSetImposterMode : public view_listener_t
class LLAvatarSetImpostorMode : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
@ -2971,16 +2971,20 @@ class LLAvatarSetImposterMode : public view_listener_t
{
case 0:
avatar->setVisualMuteSettings(LLVOAvatar::VISUAL_MUTE_NOT_SET);
return true;
break;
case 1:
avatar->setVisualMuteSettings(LLVOAvatar::ALWAYS_VISUAL_MUTE);
return true;
break;
case 2:
avatar->setVisualMuteSettings(LLVOAvatar::NEVER_VISUAL_MUTE);
return true;
break;
default:
return false;
}
avatar->forceUpdateVisualMuteSettings();
LLVOAvatar::cullAvatarsByPixelArea();
return true;
} // handleEvent()
};
@ -8736,8 +8740,8 @@ void initialize_menus()
view_listener_t::addMenu( new LLCheckPanelPeopleTab(), "SideTray.CheckPanelPeopleTab");
// Avatar pie menu
view_listener_t::addMenu(new LLAvatarCheckImposterMode(), "Avatar.CheckImposterMode");
view_listener_t::addMenu(new LLAvatarSetImposterMode(), "Avatar.SetImposterMode");
view_listener_t::addMenu(new LLAvatarCheckImpostorMode(), "Avatar.CheckImpostorMode");
view_listener_t::addMenu(new LLAvatarSetImpostorMode(), "Avatar.SetImpostorMode");
view_listener_t::addMenu(new LLObjectMute(), "Avatar.Mute");
view_listener_t::addMenu(new LLAvatarAddFriend(), "Avatar.AddFriend");
view_listener_t::addMenu(new LLAvatarAddContact(), "Avatar.AddContact");

View File

@ -400,7 +400,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE
mRenderInfoRequestTimer.resetWithExpiry(0.f); // Set timer to be expired
setCapabilitiesReceivedCallback(boost::bind(&LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer));
setCapabilitiesReceivedCallback(boost::bind(&LLAvatarRenderInfoAccountant::expireRenderInfoReportTimer, _1));
}

View File

@ -2987,81 +2987,90 @@ bool LLVOAvatar::isVisuallyMuted()
{
bool muted = false;
// Priority order (highest priority first)
// * own avatar is never visually muted
// * if on the "always draw normally" list, draw them normally
// * if on the "always visually mute" list, mute them
// * draw them normally if they meet the following criteria:
// - within the closest N avatars OR on friends list OR in an IM chat
// - AND aren't over the thresholds
// * otherwise visually mute all other avatars
if (!isSelf())
{
static LLCachedControl<F32> render_mute_threshold(gSavedSettings, "RenderAutoMuteThreshold");
static LLCachedControl<U32> max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit");
static LLCachedControl<F32> max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit");
static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit");
if (mVisuallyMuteSetting == ALWAYS_VISUAL_MUTE)
{ // Always want to see this AV as an imposter
muted = true;
}
else if (mVisuallyMuteSetting == NEVER_VISUAL_MUTE)
{ // Never show as imposter
muted = false;
}
else if (LLVOAvatar::sLODFactor <= render_mute_threshold)
static LLCachedControl<U32> render_auto_mute_functions(gSavedSettings, "RenderAutoMuteFunctions");
if (render_auto_mute_functions) // Hacky debug switch for developing feature
{
F64 now = LLFrameTimer::getTotalSeconds();
// Priority order (highest priority first)
// * own avatar is never visually muted
// * if on the "always draw normally" list, draw them normally
// * if on the "always visually mute" list, mute them
// * draw them normally if they meet the following criteria:
// - within the closest N avatars OR on friends list OR in an IM chat
// - AND aren't over the thresholds
// * otherwise visually mute all other avatars
if (now < mCachedVisualMuteUpdateTime)
{ // Use cached mute value
muted = mCachedVisualMute;
static LLCachedControl<U32> max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit");
static LLCachedControl<F32> max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit");
static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAutoMuteRenderWeightLimit");
if (mVisuallyMuteSetting == ALWAYS_VISUAL_MUTE)
{ // Always want to see this AV as an impostor
muted = true;
}
else
{ // Determine if visually muted or not
else if (mVisuallyMuteSetting == NEVER_VISUAL_MUTE)
{ // Never show as impostor
muted = false;
}
else
{
F64 now = LLFrameTimer::getTotalSeconds();
U32 max_cost = (U32) (max_render_cost*(LLVOAvatar::sLODFactor+0.5));
if (now < mCachedVisualMuteUpdateTime)
{ // Use cached mute value
muted = mCachedVisualMute;
}
else
{ // Determine if visually muted or not
muted = LLMuteList::getInstance()->isMuted(getID()) ||
(mAttachmentGeometryBytes > max_attachment_bytes && max_attachment_bytes > 0) ||
(mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f) ||
(mVisualComplexity > max_cost && max_render_cost > 0);
U32 max_cost = (U32) (max_render_cost*(LLVOAvatar::sLODFactor+0.5));
// Could be part of the grand || collection above, but yanked out to make the logic visible
if (!muted)
{
if (sMaxVisible > 0)
{ // They are above the visibilty rank - mute them
muted = (mVisibilityRank > sMaxVisible);
}
/* Not used - always draw friends or those in IMs. Works nicely, needs UI?
if (muted || // Don't mute friends or IMs
sMaxVisible == 0)
muted = LLMuteList::getInstance()->isMuted(getID()) ||
(mAttachmentGeometryBytes > max_attachment_bytes && max_attachment_bytes > 0) ||
(mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f) ||
(mVisualComplexity > max_cost && max_render_cost > 0);
// Could be part of the grand || collection above, but yanked out to make the logic visible
if (!muted)
{
muted = !(LLAvatarTracker::instance().isBuddy(getID()));
if (muted)
{ // Not a friend, so they are muted ... are they in an IM?
LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL,getID());
muted = !gIMMgr->hasSession(session_id);
if (sMaxVisible > 0)
{ // They are above the visibilty rank - mute them
muted = (mVisibilityRank > sMaxVisible);
}
// Always draw friends or those in IMs. Needs UI?
if ((render_auto_mute_functions & 0x02) &&
(muted || sMaxVisible == 0)) // Don't mute friends or IMs
{
muted = !(LLAvatarTracker::instance().isBuddy(getID()));
if (muted)
{ // Not a friend, so they are muted ... are they in an IM?
LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL,getID());
muted = !gIMMgr->hasSession(session_id);
}
}
}
*/
}
// Save visual mute state and set interval for updating
const F64 SECONDS_BETWEEN_RENDER_AUTO_MUTE_UPDATES = 1.5;
mCachedVisualMuteUpdateTime = now + SECONDS_BETWEEN_RENDER_AUTO_MUTE_UPDATES;
mCachedVisualMute = muted;
}
// Save visual mute state and set interval for updating
const F64 SECONDS_BETWEEN_RENDER_AUTO_MUTE_UPDATES = 1.5;
mCachedVisualMuteUpdateTime = now + SECONDS_BETWEEN_RENDER_AUTO_MUTE_UPDATES;
mCachedVisualMute = muted;
}
}
}
}
return muted;
}
void LLVOAvatar::forceUpdateVisualMuteSettings()
{
// Set the cache time so it's updated ASAP
mCachedVisualMuteUpdateTime = LLFrameTimer::getTotalSeconds() - 1.0;
}
//------------------------------------------------------------------------
// updateCharacter()
// called on both your avatar and other avatars
@ -3806,11 +3815,11 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
{ //LOD changed or new mesh created, allocate new vertex buffer if needed
if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
{
updateMeshData();
updateMeshData();
mDirtyMesh = 0;
mNeedsSkin = TRUE;
mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
}
mNeedsSkin = TRUE;
mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
}
}
if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
@ -7868,8 +7877,7 @@ void LLVOAvatar::getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& d
void LLVOAvatar::idleUpdateRenderCost()
{
static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAutoMuteRenderCostLimit");
static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAutoMuteRenderWeightLimit");
static const U32 ARC_LIMIT = 20000;
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_ATTACHMENT_BYTES))
@ -8033,7 +8041,7 @@ LLColor4 LLVOAvatar::calcMutedAVColor(F32 value, S32 range_low, S32 range_high)
LLColor4 new_color = lerp(*spectrum_color[spectrum_index_1], *spectrum_color[spectrum_index_2], fractBetween);
new_color.normalize();
new_color *= 0.9f;
new_color *= 0.7f; // Tone it down a bit
//llinfos << "From value " << std::setprecision(3) << value << " returning color " << new_color
// << " using indexes " << spectrum_index_1 << ", " << spectrum_index_2

View File

@ -389,6 +389,8 @@ public:
public:
U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
bool isVisuallyMuted();
void setCachedVisualMute(bool muted) { mCachedVisualMute = muted; };
void forceUpdateVisualMuteSettings();
enum VisualMuteSettings
{

View File

@ -117,37 +117,37 @@
<menu_item_check
name="Normal"
label="Normal">
label="Normal Rendering">
<menu_item_check.on_check
function="Avatar.CheckImposterMode"
function="Avatar.CheckImpostorMode"
parameter="0" />
<menu_item_check.on_click
function="Avatar.SetImposterMode"
function="Avatar.SetImpostorMode"
parameter="0" />
</menu_item_check>
<menu_item_check
name="Always use imposter"
label="Always use imposter">
name="Always use impostor"
label="Always use impostor">
<menu_item_check.on_check
function="Avatar.CheckImposterMode"
function="Avatar.CheckImpostorMode"
parameter="1" />
<menu_item_check.on_click
function="Avatar.SetImposterMode"
function="Avatar.SetImpostorMode"
parameter="1" />
</menu_item_check>
<menu_item_check
name="Never use imposter"
label="Never use imposter">
name="Never use impostor"
label="Never use impostor">
<menu_item_check.on_check
function="Avatar.CheckImposterMode"
function="Avatar.CheckImpostorMode"
parameter="2" />
<menu_item_check.on_click
function="Avatar.SetImposterMode"
function="Avatar.SetImpostorMode"
parameter="2" />
</menu_item_check>
<menu_item_separator
layout="topleft" />
layout="topleft" name="Impostor seperator"/>
<menu_item_call
enabled="false"

View File

@ -110,37 +110,37 @@
<menu_item_check
name="Normal"
label="Normal">
label="Normal Rendering">
<menu_item_check.on_check
function="Avatar.CheckImposterMode"
function="Avatar.CheckImpostorMode"
parameter="0" />
<menu_item_check.on_click
function="Avatar.SetImposterMode"
function="Avatar.SetImpostorMode"
parameter="0" />
</menu_item_check>
<menu_item_check
name="Always use imposter"
label="Always use imposter">
name="Always use impostor"
label="Always use impostor">
<menu_item_check.on_check
function="Avatar.CheckImposterMode"
function="Avatar.CheckImpostorMode"
parameter="1" />
<menu_item_check.on_click
function="Avatar.SetImposterMode"
function="Avatar.SetImpostorMode"
parameter="1" />
</menu_item_check>
<menu_item_check
name="Never use imposter"
label="Never use imposter">
name="Never use impostor"
label="Never use impostor">
<menu_item_check.on_check
function="Avatar.CheckImposterMode"
function="Avatar.CheckImpostorMode"
parameter="2" />
<menu_item_check.on_click
function="Avatar.SetImposterMode"
function="Avatar.SetImpostorMode"
parameter="2" />
</menu_item_check>
<menu_item_separator
layout="topleft" />
<menu_item_separator
layout="topleft" name="Impostor seperator"/>
<menu_item_call
enabled="false"