diff options
author | Bryan O'Sullivan <bos@lindenlab.com> | 2009-06-11 11:14:45 -0700 |
---|---|---|
committer | Bryan O'Sullivan <bos@lindenlab.com> | 2009-06-11 11:14:45 -0700 |
commit | 02c86086acceb83fcddad763123b532c70641688 (patch) | |
tree | a7a220131b5b491d5c0823df1c07ee86a97e2a77 /indra/newview/llvoavatar.cpp | |
parent | 5748a14f5d7e85230e74c330a7c2b058856be9cd (diff) | |
parent | 9c94b76ec10cb5a323f5f8c5c1e8340f40c3b175 (diff) |
Merge with Sabin
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r-- | indra/newview/llvoavatar.cpp | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index b06652a5dc..168b0056e5 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -769,6 +769,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mBakedTextureData[i].mLastTextureIndex = IMG_DEFAULT_AVATAR; mBakedTextureData[i].mTexLayerSet = NULL; mBakedTextureData[i].mIsLoaded = false; + mBakedTextureData[i].mIsUsed = false; mBakedTextureData[i].mMaskTexName = 0; mBakedTextureData[i].mTextureIndex = getTextureIndex((EBakedTextureIndex)i); } @@ -1451,6 +1452,7 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax) LLVector3 pos = getRenderPosition(); newMin = pos - buffer; newMax = pos + buffer; + float max_attachment_span = DEFAULT_MAX_PRIM_SCALE * 5.0f; //stretch bounding box by joint positions for (polymesh_map_t::iterator i = mMeshes.begin(); i != mMeshes.end(); ++i) @@ -1487,8 +1489,18 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax) if (bridge) { const LLVector3* ext = bridge->getSpatialExtents(); - update_min_max(newMin,newMax,ext[0]); - update_min_max(newMin,newMax,ext[1]); + LLVector3 distance = (ext[1] - ext[0]); + + // Only add the prim to spatial extents calculations if it isn't a megaprim. + // max_attachment_span calculated at the start of the function + // (currently 5 times our max prim size) + if (distance.mV[0] < max_attachment_span + && distance.mV[1] < max_attachment_span + && distance.mV[2] < max_attachment_span) + { + update_min_max(newMin,newMax,ext[0]); + update_min_max(newMin,newMax,ext[1]); + } } } } @@ -4140,9 +4152,13 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) if (pass == AVATAR_RENDER_PASS_SINGLE) { const bool should_alpha_mask = mHasBakedHair && isTextureDefined(TEX_HEAD_BAKED) && isTextureDefined(TEX_UPPER_BAKED) - && isTextureDefined(TEX_LOWER_BAKED) && mBakedTextureData[BAKED_HEAD].mIsLoaded + && isTextureDefined(TEX_LOWER_BAKED) + && mBakedTextureData[BAKED_HEAD].mIsLoaded && mBakedTextureData[BAKED_UPPER].mIsLoaded && mBakedTextureData[BAKED_LOWER].mIsLoaded - && !LLDrawPoolAlpha::sShowDebugAlpha; // Don't alpha mask if "Highlight Transparent" checked + && mBakedTextureData[BAKED_HEAD].mIsUsed + && mBakedTextureData[BAKED_UPPER].mIsUsed && mBakedTextureData[BAKED_LOWER].mIsUsed + && !LLDrawPoolAlpha::sShowDebugAlpha // Don't alpha mask if "Highlight Transparent" checked + && !(isSelf() && gAgent.cameraCustomizeAvatar()); // don't alpha mask if in customize mode LLGLState test(GL_ALPHA_TEST, should_alpha_mask); @@ -4179,11 +4195,8 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) if (!LLDrawPoolAvatar::sSkipTransparent || LLPipeline::sImpostorRender) { - if (!mIsDummy) - { - LLGLEnable blend(GL_BLEND); - LLGLEnable test(GL_ALPHA_TEST); - } + LLGLState blend(GL_BLEND, !mIsDummy); + LLGLState test(GL_ALPHA_TEST, !mIsDummy); num_indices += renderTransparent(first_pass); } } @@ -4261,7 +4274,11 @@ U32 LLVOAvatar::renderRigid() if (isTextureVisible(TEX_EYES_BAKED) || mIsDummy) { // If the meshes need to be drawn, enable alpha masking but not blending - bool should_alpha_mask = mHasBakedHair && mBakedTextureData[BAKED_EYES].mIsLoaded; + bool should_alpha_mask = mHasBakedHair + && mBakedTextureData[BAKED_EYES].mIsLoaded + && mBakedTextureData[BAKED_EYES].mIsUsed + && !(isSelf() && gAgent.cameraCustomizeAvatar()); + LLGLState test(GL_ALPHA_TEST, should_alpha_mask); if (should_alpha_mask) @@ -6896,6 +6913,7 @@ void LLVOAvatar::updateMeshTextures() if (use_lkg_baked_layer[i] && !self_customizing ) { LLViewerImage* baked_img = gImageList.getImageFromHost( mBakedTextureData[i].mLastTextureIndex, target_host ); + mBakedTextureData[i].mIsUsed = TRUE; for (U32 k=0; k < mBakedTextureData[i].mMeshes.size(); k++) { mBakedTextureData[i].mMeshes[k]->setTexture( baked_img ); @@ -6925,6 +6943,7 @@ void LLVOAvatar::updateMeshTextures() { mBakedTextureData[i].mTexLayerSet->createComposite(); mBakedTextureData[i].mTexLayerSet->setUpdatesEnabled( TRUE ); + mBakedTextureData[i].mIsUsed = FALSE; for (U32 k=0; k < mBakedTextureData[i].mMeshes.size(); k++) { mBakedTextureData[i].mMeshes[k]->setLayerSet( mBakedTextureData[i].mTexLayerSet ); @@ -6935,7 +6954,7 @@ void LLVOAvatar::updateMeshTextures() // ! BACKWARDS COMPATIBILITY ! // Workaround for viewing avatars from old viewers that haven't baked hair textures. // if (!isTextureDefined(mBakedTextureData[BAKED_HAIR].mTextureIndex)) - if (!is_layer_baked[BAKED_HAIR]) + if (!is_layer_baked[BAKED_HAIR] || self_customizing) { const LLColor4 color = mTexHairColor ? mTexHairColor->getColor() : LLColor4(1,1,1,1); LLViewerImage* hair_img = getTEImage( TEX_HAIR ); @@ -6948,10 +6967,6 @@ void LLVOAvatar::updateMeshTextures() } else { - for (U32 i = 0; i < mBakedTextureData[BAKED_HAIR].mMeshes.size(); i++) - { - mBakedTextureData[BAKED_HAIR].mMeshes[i]->setColor( 1.f, 1.f, 1.f, 1.f ); - } mHasBakedHair = TRUE; } @@ -7761,7 +7776,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) } LLMemType mt(LLMemType::MTYPE_AVATAR); - + // llinfos << "processAvatarAppearance start " << mID << llendl; BOOL is_first_appearance_message = !mFirstAppearanceMessageReceived; @@ -7789,6 +7804,18 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) unpackTEMessage(mesgsys, _PREHASH_ObjectData); // dumpAvatarTEs( "POST processAvatarAppearance()" ); + // prevent the overwriting of valid baked textures with invalid baked textures + for (U8 baked_index = 0; baked_index < mBakedTextureData.size(); baked_index++) + { + if (!isTextureDefined(mBakedTextureData[baked_index].mTextureIndex) + && mBakedTextureData[baked_index].mLastTextureIndex != IMG_DEFAULT + && baked_index != BAKED_SKIRT) + { + setTEImage(mBakedTextureData[baked_index].mTextureIndex, gImageList.getImage(mBakedTextureData[baked_index].mLastTextureIndex)); + } + } + + //llinfos << "Received AvatarAppearance: " << (mIsSelf ? "(self): " : "(other): ") << std::endl << // (isTextureDefined(TEX_HEAD_BAKED) ? "HEAD " : "head " ) << (getTEImage(TEX_HEAD_BAKED)->getID()) << std::endl << // (isTextureDefined(TEX_UPPER_BAKED) ? "UPPER " : "upper " ) << (getTEImage(TEX_UPPER_BAKED)->getID()) << std::endl << @@ -8079,6 +8106,7 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id ) if (id == image_baked->getID()) { mBakedTextureData[i].mIsLoaded = true; + mBakedTextureData[i].mIsUsed = true; mBakedTextureData[i].mLastTextureIndex = id; for (U32 k = 0; k < mBakedTextureData[i].mMeshes.size(); k++) { @@ -8095,6 +8123,17 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id ) { setLocalTexture(*local_tex_iter, getTEImage(*local_tex_iter), TRUE); } + + // ! BACKWARDS COMPATIBILITY ! + // Workaround for viewing avatars from old viewers that haven't baked hair textures. + // This is paired with similar code in updateMeshTextures that sets hair mesh color. + if (i == BAKED_HAIR) + { + for (U32 i = 0; i < mBakedTextureData[BAKED_HAIR].mMeshes.size(); i++) + { + mBakedTextureData[BAKED_HAIR].mMeshes[i]->setColor( 1.f, 1.f, 1.f, 1.f ); + } + } } } |