summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2012-07-12 18:24:23 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2012-07-12 18:24:23 -0400
commit27c7b259b417d5843422e8bd4e8e480a186e44f4 (patch)
tree9902c463f76c35ad8049ad467739536ea43482b0
parent5e40435201e21a3b4b6f4a172937d3efe8ad15c0 (diff)
SH-3267 WIP
-rwxr-xr-xindra/llprimitive/llprimitive.cpp107
-rwxr-xr-xindra/llprimitive/llprimitive.h31
-rwxr-xr-xindra/newview/llappearancemgr.cpp8
-rwxr-xr-xindra/newview/llappearancemgr.h2
-rwxr-xr-xindra/newview/llvoavatar.cpp20
5 files changed, 162 insertions, 6 deletions
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index c766d8a43c..0388e2c020 100755
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -1228,11 +1228,113 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
return FALSE;
}
-S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, bool fake_images)
+S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images,
+ LLTEContents& tec)
{
- return(unpackTEMessage(mesgsys,block_name,-1,fake_images));
+ tec.fake_images = fake_images;
+
+ S32 retval = 0;
+
+ if (block_num < 0)
+ {
+ tec.size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry);
+ }
+ else
+ {
+ tec.size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry);
+ }
+
+ if (tec.size == 0)
+ {
+ return retval;
+ }
+
+ if (block_num < 0)
+ {
+ mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, 0, LLTEContents::MAX_TE_BUFFER);
+ }
+ else
+ {
+ mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, block_num, LLTEContents::MAX_TE_BUFFER);
+ }
+
+ tec.face_count = getNumTEs();
+
+ U8 *cur_ptr = tec.packed_buffer;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_data, 16, tec.face_count, MVT_LLUUID);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.colors, 4, tec.face_count, MVT_U8);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_s, 4, tec.face_count, MVT_F32);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_t, 4, tec.face_count, MVT_F32);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_s, 2, tec.face_count, MVT_S16Array);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_t, 2, tec.face_count, MVT_S16Array);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_rot, 2, tec.face_count, MVT_S16Array);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.bump, 1, tec.face_count, MVT_U8);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.media_flags, 1, tec.face_count, MVT_U8);
+ cur_ptr++;
+ cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.glow, 1, tec.face_count, MVT_U8);
+
+ retval = 1;
+ return retval;
+}
+
+S32 LLPrimitive::unpackParsedTEMessage(LLTEContents& tec)
+{
+ S32 retval = 0;
+
+ LLColor4 color;
+ LLColor4U coloru;
+ for (U32 i = 0; i < tec.face_count; i++)
+ {
+ LLUUID& req_id = ((LLUUID*)tec.image_data)[i];
+ if (tec.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, tec.scale_s[i], tec.scale_t[i]);
+ retval |= setTEOffset(i, (F32)tec.offset_s[i] / (F32)0x7FFF, (F32) tec.offset_t[i] / (F32) 0x7FFF);
+ retval |= setTERotation(i, ((F32)tec.image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI);
+ retval |= setTEBumpShinyFullbright(i, tec.bump[i]);
+ retval |= setTEMediaTexGen(i, tec.media_flags[i]);
+ retval |= setTEGlow(i, (F32)tec.glow[i] / (F32)0xFF);
+ coloru = LLColor4U(tec.colors + 4*i);
+
+ // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f)
+ // as all zeros. However, the subtraction and addition must be done in unsigned
+ // byte space, not in float space, otherwise off-by-one errors occur. JC
+ color.mV[VRED] = F32(255 - coloru.mV[VRED]) / 255.f;
+ color.mV[VGREEN] = F32(255 - coloru.mV[VGREEN]) / 255.f;
+ color.mV[VBLUE] = F32(255 - coloru.mV[VBLUE]) / 255.f;
+ color.mV[VALPHA] = F32(255 - coloru.mV[VALPHA]) / 255.f;
+
+ retval |= setTEColor(i, color);
+
+ }
+
+ return retval;
+}
+
+S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images)
+{
+ LLTEContents tec;
+ S32 retval = parseTEMessage(mesgsys, block_name, block_num, fake_images, tec);
+ if (!retval)
+ return retval;
+ return unpackParsedTEMessage(tec);
}
+#if 0
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)
@@ -1339,6 +1441,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam
return retval;
}
+#endif
S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
{
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 1e985221c0..19ef3faf3f 100755
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -289,6 +289,34 @@ public:
};
+struct LLTEContents
+{
+ LLTEContents()
+ {
+ }
+
+ static const U32 MAX_TES = 32;
+
+ U8 image_data[MAX_TES*16];
+ U8 colors[MAX_TES*4];
+ F32 scale_s[MAX_TES];
+ F32 scale_t[MAX_TES];
+ S16 offset_s[MAX_TES];
+ S16 offset_t[MAX_TES];
+ S16 image_rot[MAX_TES];
+ U8 bump[MAX_TES];
+ U8 media_flags[MAX_TES];
+ U8 glow[MAX_TES];
+
+ static const U32 MAX_TE_BUFFER = 4096;
+ U8 packed_buffer[MAX_TE_BUFFER];
+
+ U32 size;
+ U32 face_count;
+
+ bool fake_images;
+};
+
class LLPrimitive : public LLXform
{
public:
@@ -360,9 +388,10 @@ public:
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, 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);
+ S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images,LLTEContents& tec);
+ S32 unpackParsedTEMessage(LLTEContents& tec);
#ifdef CHECK_FOR_FINITE
inline void setPosition(const LLVector3& pos);
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 04c4220afd..eb31358000 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2623,8 +2623,11 @@ void LLAppearanceMgr::requestServerAppearanceUpdate()
if (!url.empty())
{
LLSD body;
- body["cof_version"] = getCOFVersion();
+ S32 cof_version = getCOFVersion();
+ body["cof_version"] = cof_version;
LLHTTPClient::post(url, body, new RequestAgentUpdateAppearanceResponder);
+ llassert(cof_version >= mLastUpdateRequestCOFVersion);
+ mLastUpdateRequestCOFVersion = cof_version;
}
else
{
@@ -2842,7 +2845,8 @@ LLAppearanceMgr::LLAppearanceMgr():
mAttachmentInvLinkEnabled(false),
mOutfitIsDirty(false),
mOutfitLocked(false),
- mIsInUpdateAppearanceFromCOF(false)
+ mIsInUpdateAppearanceFromCOF(false),
+ mLastUpdateRequestCOFVersion(LLViewerInventoryCategory::VERSION_UNKNOWN)
{
LLOutfitObserver& outfit_observer = LLOutfitObserver::instance();
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 954820c154..45291419c7 100755
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -95,6 +95,8 @@ public:
const LLUUID getCOF() const;
S32 getCOFVersion() const;
+ S32 mLastUpdateRequestCOFVersion;
+
// Finds the folder link to the currently worn outfit
const LLViewerInventoryItem *getBaseOutfitLink();
bool getBaseOutfitName(std::string &name);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 6bcb0c6882..f85b59b8c6 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -7309,9 +7309,27 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
// llinfos << "LLVOAvatar::processAvatarAppearance()" << llendl;
// dumpAvatarTEs( "PRE processAvatarAppearance()" );
- unpackTEMessage(mesgsys, _PREHASH_ObjectData, FALSE);
+ LLTEContents tec;
+ parseTEMessage(mesgsys, _PREHASH_ObjectData, -1, FALSE, tec);
// dumpAvatarTEs( "POST processAvatarAppearance()" );
+ // Check for stale update.
+ if (isSelf() && LLAppearanceMgr::instance().useServerTextureBaking())
+ {
+ // Extract COF Version field hacked into local texture id.
+ LLUUID texture_id = ((LLUUID*)tec.image_data)[0];
+ S32 last_update_request_cof_version = LLAppearanceMgr::instance().mLastUpdateRequestCOFVersion;
+ S32 *s_words = (S32*) texture_id.mData;
+ S32 this_update_cof_version = s_words[0];
+ if (this_update_cof_version < last_update_request_cof_version)
+ {
+ llwarns << "Stale appearance update, wanted version " << last_update_request_cof_version
+ << ", got " << this_update_cof_version << llendl;
+ return;
+ }
+ }
+ unpackParsedTEMessage(tec);
+
// prevent the overwriting of valid baked textures with invalid baked textures
for (U8 baked_index = 0; baked_index < mBakedTextureDatas.size(); baked_index++)
{