From 04caf8c8764c0a433121acef6c7b7396c43550b2 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Tue, 21 Feb 2012 17:40:40 -0500
Subject: SH-2689 WIP - move first_fully_visible static into avatar class,
 bake-related logging

---
 indra/newview/llagent.cpp          |  6 +++---
 indra/newview/llagentwearables.cpp |  2 +-
 indra/newview/llappearancemgr.cpp  |  7 +------
 indra/newview/llvoavatar.cpp       | 22 ++++++++++------------
 indra/newview/llvoavatar.h         |  2 ++
 5 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index ab9b5ff436..af3a409944 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -3779,7 +3779,7 @@ void LLAgent::sendAgentSetAppearance()
 		return;
 	}
 
-	llinfos << "TAT: Sent AgentSetAppearance: " << gAgentAvatarp->getBakedStatusForPrintout() << llendl;
+	llinfos << gAgentAvatarp->avString() << "TAT: Sent AgentSetAppearance: " << gAgentAvatarp->getBakedStatusForPrintout() << llendl;
 	//dumpAvatarTEs( "sendAgentSetAppearance()" );
 
 	LLMessageSystem* msg = gMessageSystem;
@@ -3826,14 +3826,14 @@ void LLAgent::sendAgentSetAppearance()
 	// only update cache entries if we have all our baked textures
 	if (textures_current)
 	{
-		llinfos << "TAT: Sending cached texture data" << llendl;
+		llinfos << gAgentAvatarp->avString() << "TAT: Sending cached texture data" << llendl;
 		for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
 		{
 			BOOL generate_valid_hash = TRUE;
 			if (isAgentAvatarValid() && !gAgentAvatarp->isBakedTextureFinal((LLVOAvatarDefines::EBakedTextureIndex)baked_index))
 			{
 				generate_valid_hash = FALSE;
-				llinfos << "Not caching baked texture upload for " << (U32)baked_index << " due to being uploaded at low resolution." << llendl;
+				llinfos << gAgentAvatarp->avString() << "Not caching baked texture upload for " << (U32)baked_index << " due to being uploaded at low resolution." << llendl;
 			}
 
 			const LLUUID hash = gAgentWearables.computeBakedTextureHash((EBakedTextureIndex) baked_index, generate_valid_hash);
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 09305a5b4d..53ca0a214a 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1630,7 +1630,7 @@ void LLAgentWearables::queryWearableCache()
 			gAgentAvatarp->outputRezTiming("Fetching textures from cache");
 		}
 
-		llinfos << "Requesting texture cache entry for " << num_queries << " baked textures" << llendl;
+		llinfos << gAgentAvatarp->avString() << "Requesting texture cache entry for " << num_queries << " baked textures" << llendl;
 		gMessageSystem->sendReliable(gAgent.getRegion()->getHost());
 		gAgentQueryManager.mNumPendingQueries++;
 		gAgentQueryManager.mWearablesCacheQueryID++;
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index fe2a7bcb2d..e37a577460 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -52,12 +52,7 @@
 
 std::string self_av_string()
 {
-	static std::string av_name_string = "";
-	if (av_name_string.empty() && gAgentAvatarp)
-	{
-		av_name_string =  " Avatar '" + gAgentAvatarp->getFullname() + "' ";
-	}
-	return av_name_string;
+	return gAgentAvatarp->avString();
 }
 
 // RAII thingy to guarantee that a variable gets reset when the Setter
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 6a372eb5b3..317cdca090 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -687,6 +687,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 	mNeedsSkin(FALSE),
 	mLastSkinTime(0.f),
 	mUpdatePeriod(1),
+	mFirstFullyVisible(TRUE),
 	mFullyLoaded(FALSE),
 	mPreviousFullyLoaded(FALSE),
 	mFullyLoadedInitialized(FALSE),
@@ -2776,20 +2777,16 @@ void LLVOAvatar::idleUpdateLoadingEffect()
 	// update visibility when avatar is partially loaded
 	if (updateIsFullyLoaded()) // changed?
 	{
-		if (isFullyLoaded() && isSelf())
+		if (isFullyLoaded() && mFirstFullyVisible && isSelf())
 		{
-			static bool first_fully_visible = true;
-			if (first_fully_visible)
-			{
-				llinfos << avString() << "self isFullyLoaded, first_fully_visible" << llendl;
-
-				first_fully_visible = false;
-				LLAppearanceMgr::instance().onFirstFullyVisible();
-			}
+			llinfos << avString() << "self isFullyLoaded, mFirstFullyVisible" << llendl;
+			mFirstFullyVisible = FALSE;
+			LLAppearanceMgr::instance().onFirstFullyVisible();
 		}
-		if (isFullyLoaded() && !isSelf())
+		if (isFullyLoaded() && mFirstFullyVisible && !isSelf())
 		{
-			llinfos << avString() << "other isFullyLoaded" << llendl;
+			llinfos << avString() << "other isFullyLoaded, mFirstFullyVisible" << llendl;
+			mFirstFullyVisible = FALSE;
 		}
 		if (isFullyLoaded())
 		{
@@ -6435,7 +6432,8 @@ void LLVOAvatar::updateRuthTimer(bool loading)
 	const F32 LOADING_TIMEOUT__SECONDS = 120.f;
 	if (mRuthTimer.getElapsedTimeF32() > LOADING_TIMEOUT__SECONDS)
 	{
-		llinfos << "Ruth Timer timeout: Missing texture data for '" << getFullname() << "' "
+		llinfos << avString()
+				<< "Ruth Timer timeout: Missing texture data for '" << getFullname() << "' "
 				<< "( Params loaded : " << !visualParamWeightsAreDefault() << " ) "
 				<< "( Lower : " << isTextureDefined(TEX_LOWER_BAKED) << " ) "
 				<< "( Upper : " << isTextureDefined(TEX_UPPER_BAKED) << " ) "
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 1ed43f7ed9..e0202c38cd 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -285,6 +285,8 @@ protected:
 	void			updateRuthTimer(bool loading);
 	F32 			calcMorphAmount();
 private:
+	// runway state-machine spaghetti
+	BOOL			mFirstFullyVisible;
 	BOOL			mFullyLoaded;
 	BOOL			mPreviousFullyLoaded;
 	BOOL			mFullyLoadedInitialized;
-- 
cgit v1.2.3