From e4a0dda457039b1a04c74024d9fbcf02e071b13d Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 28 Jun 2012 14:24:04 -0400
Subject: [PATCH] SH-3228 WIP - always respond to processAppearance for self,
 convert baked textures to checkerboards

---
 indra/llcommon/imageids.cpp       |  3 +++
 indra/llcommon/imageids.h         |  1 +
 indra/llprimitive/llprimitive.cpp | 17 +++++++++++++----
 indra/llprimitive/llprimitive.h   |  4 ++--
 indra/newview/llvoavatar.cpp      |  4 ++--
 indra/newview/llvoavatarself.cpp  |  2 +-
 indra/newview/llvovolume.cpp      |  2 +-
 7 files changed, 23 insertions(+), 10 deletions(-)
 mode change 100644 => 100755 indra/llcommon/imageids.cpp
 mode change 100644 => 100755 indra/llcommon/imageids.h
 mode change 100644 => 100755 indra/llprimitive/llprimitive.h

diff --git a/indra/llcommon/imageids.cpp b/indra/llcommon/imageids.cpp
old mode 100644
new mode 100755
index fe114652210..7d647e5c364
--- a/indra/llcommon/imageids.cpp
+++ b/indra/llcommon/imageids.cpp
@@ -68,3 +68,6 @@ const LLUUID TERRAIN_MOUNTAIN_DETAIL	("303cd381-8560-7579-23f1-f0a880799740"); /
 const LLUUID TERRAIN_ROCK_DETAIL		("53a2f406-4895-1d13-d541-d2e3b86bc19c"); // VIEWER
 
 const LLUUID DEFAULT_WATER_NORMAL		("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); // VIEWER
+
+const LLUUID IMG_CHECKERBOARD_RGBA     ("2585a0f3-4163-6dd1-0f34-ad48cb909e25"); // dataserver
+
diff --git a/indra/llcommon/imageids.h b/indra/llcommon/imageids.h
old mode 100644
new mode 100755
index e0c2683fdc3..18c8ecb0743
--- a/indra/llcommon/imageids.h
+++ b/indra/llcommon/imageids.h
@@ -66,4 +66,5 @@ LL_COMMON_API extern const LLUUID TERRAIN_ROCK_DETAIL;
 
 LL_COMMON_API extern const LLUUID DEFAULT_WATER_NORMAL;
 
+LL_COMMON_API extern const LLUUID IMG_CHECKERBOARD_RGBA;
 #endif
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index 30532247ac1..c766d8a43c0 100755
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -39,6 +39,7 @@
 #include "lldatapacker.h"
 #include "llsdutil_math.h"
 #include "llprimtexturelist.h"
+#include "imageids.h"
 
 /**
  * exported constants
@@ -1227,12 +1228,12 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
 	return FALSE;
 }
 
-S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name)
+S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, bool fake_images)
 {
-	return(unpackTEMessage(mesgsys,block_name,-1));
+	return(unpackTEMessage(mesgsys,block_name,-1,fake_images));
 }
 
-S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num)
+S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images)
 {
 	// use a negative block_num to indicate a single-block read (a non-variable block)
 	S32 retval = 0;
@@ -1307,7 +1308,15 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam
 	LLColor4U coloru;
 	for (U32 i = 0; i < face_count; i++)
 	{
-		retval |= setTETexture(i, ((LLUUID*)image_data)[i]);
+		LLUUID& req_id = ((LLUUID*)image_data)[i];
+		if (fake_images & (req_id != IMG_DEFAULT) && (req_id != IMG_DEFAULT_AVATAR) && (req_id != IMG_INVISIBLE))
+		{
+			retval |= setTETexture(i, IMG_CHECKERBOARD_RGBA);
+		}
+		else
+		{
+			retval |= setTETexture(i, req_id);
+		}
 		retval |= setTEScale(i, scale_s[i], scale_t[i]);
 		retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF);
 		retval |= setTERotation(i, ((F32)image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI);
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
old mode 100644
new mode 100755
index 998016f8f6a..1e985221c02
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -360,8 +360,8 @@ class LLPrimitive : public LLXform
 	S32 unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type);
 	BOOL packTEMessage(LLMessageSystem *mesgsys) const;
 	BOOL packTEMessage(LLDataPacker &dp) const;
-	S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name);
-	S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks
+	S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, bool fake_images = false);
+	S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images = false); // Variable num of blocks
 	BOOL unpackTEMessage(LLDataPacker &dp);
 	
 #ifdef CHECK_FOR_FINITE
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index d2247ed5cbb..531d3b49405 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -7283,7 +7283,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 	if( isSelf() )
 	{
 		llwarns << avString() << "Received AvatarAppearance for self" << llendl;
-		if( mFirstTEMessageReceived )
+		if( mFirstTEMessageReceived && !LLAppearanceMgr::instance().useServerTextureBaking())
 		{
 //			llinfos << "processAvatarAppearance end  " << mID << llendl;
 			return;
@@ -7294,7 +7294,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 
 //	llinfos << "LLVOAvatar::processAvatarAppearance()" << llendl;
 //	dumpAvatarTEs( "PRE  processAvatarAppearance()" );
-	unpackTEMessage(mesgsys, _PREHASH_ObjectData);
+	unpackTEMessage(mesgsys, _PREHASH_ObjectData, LLAppearanceMgr::instance().useServerTextureBaking());
 //	dumpAvatarTEs( "POST processAvatarAppearance()" );
 
 	// prevent the overwriting of valid baked textures with invalid baked textures
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 0bfd0df769b..585a116acb2 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -814,7 +814,7 @@ U32  LLVOAvatarSelf::processUpdateMessage(LLMessageSystem *mesgsys,
 		updateMeshTextures();
 
 		// unpack the texture UUIDs to the texture slots
-		retval = unpackTEMessage(mesgsys, _PREHASH_ObjectData, block_num);
+		retval = unpackTEMessage(mesgsys, _PREHASH_ObjectData, (S32) block_num);
 
 		// need to trigger a few operations to get the avatar to use the new bakes
 		for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index b5d173346e8..4999f680dfa 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -370,7 +370,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 		// Unpack texture entry data
 		//
 
-		S32 result = unpackTEMessage(mesgsys, _PREHASH_ObjectData, block_num);
+		S32 result = unpackTEMessage(mesgsys, _PREHASH_ObjectData, (S32) block_num);
 		if (result & teDirtyBits)
 		{
 			updateTEData();
-- 
GitLab