summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2012-09-06 03:04:10 +0000
committerDon Kjer <don@lindenlab.com>2012-09-06 03:04:10 +0000
commit2e933100bb6bf27c0307dc6831142dcc0860fb7b (patch)
tree27de2cf2d447b693ae2b20560d1432ca8324defd /indra/newview/llvoavatar.cpp
parent85d0bcc0630bfbf8b50be3a47a113c4f8d6ec9df (diff)
parentb146490e1b46799ccb35e156b4751eddea3a23ce (diff)
Merge
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rwxr-xr-xindra/newview/llvoavatar.cpp139
1 files changed, 75 insertions, 64 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 2309ea3488..f6cac6d2d6 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -703,17 +703,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mPelvisp = NULL;
- mBakedTextureDatas.resize(BAKED_NUM_INDICES);
- for (U32 i = 0; i < mBakedTextureDatas.size(); i++ )
- {
- mBakedTextureDatas[i].mLastTextureIndex = IMG_DEFAULT_AVATAR;
- mBakedTextureDatas[i].mTexLayerSet = NULL;
- mBakedTextureDatas[i].mIsLoaded = false;
- mBakedTextureDatas[i].mIsUsed = false;
- mBakedTextureDatas[i].mMaskTexName = 0;
- mBakedTextureDatas[i].mTextureIndex = LLAvatarAppearanceDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)i);
- }
-
mDirtyMesh = 2; // Dirty geometry, need to regenerate.
mMeshTexturesDirty = FALSE;
mHeadp = NULL;
@@ -821,19 +810,6 @@ LLVOAvatar::~LLVOAvatar()
mNumJoints = 0;
- for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
- {
- deleteAndClear(mBakedTextureDatas[i].mTexLayerSet);
- mBakedTextureDatas[i].mMeshes.clear();
-
- for (morph_list_t::iterator iter2 = mBakedTextureDatas[i].mMaskedMorphs.begin();
- iter2 != mBakedTextureDatas[i].mMaskedMorphs.end(); iter2++)
- {
- LLMaskedMorph* masked_morph = (*iter2);
- delete masked_morph;
- }
- }
-
std::for_each(mAttachmentPoints.begin(), mAttachmentPoints.end(), DeletePairedPointer());
mAttachmentPoints.clear();
@@ -1102,7 +1078,7 @@ void LLVOAvatar::restoreGL()
gAgentAvatarp->setCompositeUpdatesEnabled(TRUE);
for (U32 i = 0; i < gAgentAvatarp->mBakedTextureDatas.size(); i++)
{
- gAgentAvatarp->invalidateComposite(gAgentAvatarp->mBakedTextureDatas[i].mTexLayerSet, FALSE);
+ gAgentAvatarp->invalidateComposite(gAgentAvatarp->getTexLayerSet(i), FALSE);
}
gAgentAvatarp->updateMeshTextures();
}
@@ -5518,9 +5494,9 @@ BOOL LLVOAvatar::loadAvatar()
EBakedTextureIndex baked = LLAvatarAppearanceDictionary::findBakedByRegionName(info->mRegion);
if (baked != BAKED_NUM_INDICES)
{
- LLPolyMorphTarget *morph_param;
+ LLVisualParam* morph_param;
const std::string *name = &info->mName;
- morph_param = (LLPolyMorphTarget *)(getVisualParam(name->c_str()));
+ morph_param = getVisualParam(name->c_str());
if (morph_param)
{
BOOL invert = info->mInvert;
@@ -6480,7 +6456,11 @@ void LLVOAvatar::onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL
LLColor4 color = mTexHairColor->getColor();
for (U32 i = 0; i < mBakedTextureDatas[BAKED_HAIR].mMeshes.size(); i++)
{
- mBakedTextureDatas[BAKED_HAIR].mMeshes[i]->setColor( color.mV[VX], color.mV[VY], color.mV[VZ], color.mV[VW] );
+ LLViewerJointMesh* mesh = dynamic_cast<LLViewerJointMesh*>(mBakedTextureDatas[BAKED_HAIR].mMeshes[i]);
+ if (mesh)
+ {
+ mesh->setColor( color.mV[VX], color.mV[VY], color.mV[VZ], color.mV[VW] );
+ }
}
}
}
@@ -6697,15 +6677,16 @@ void LLVOAvatar::updateMeshTextures()
// When an avatar is changing clothes and not in Appearance mode,
// use the last-known good baked texture until it finish the first
// render of the new layerset.
- const BOOL layerset_invalid = mBakedTextureDatas[i].mTexLayerSet
- && ( !mBakedTextureDatas[i].mTexLayerSet->getViewerComposite()->isInitialized()
- || !mBakedTextureDatas[i].mTexLayerSet->isLocalTextureDataAvailable() );
+ LLViewerTexLayerSet* layerset = getTexLayerSet(i);
+ const BOOL layerset_invalid = layerset
+ && ( !layerset->getViewerComposite()->isInitialized()
+ || !layerset->isLocalTextureDataAvailable() );
use_lkg_baked_layer[i] = (!is_layer_baked[i]
&& (mBakedTextureDatas[i].mLastTextureIndex != IMG_DEFAULT_AVATAR)
&& layerset_invalid);
if (use_lkg_baked_layer[i])
{
- mBakedTextureDatas[i].mTexLayerSet->setUpdatesEnabled(TRUE);
+ layerset->setUpdatesEnabled(TRUE);
}
}
else
@@ -6718,6 +6699,7 @@ void LLVOAvatar::updateMeshTextures()
for (U32 i=0; i < mBakedTextureDatas.size(); i++)
{
+ LLViewerTexLayerSet* layerset = getTexLayerSet(i);
if (use_lkg_baked_layer[i] && !mUseLocalAppearance )
{
LLViewerFetchedTexture* baked_img;
@@ -6741,7 +6723,11 @@ void LLVOAvatar::updateMeshTextures()
mBakedTextureDatas[i].mIsUsed = TRUE;
for (U32 k=0; k < mBakedTextureDatas[i].mMeshes.size(); k++)
{
- mBakedTextureDatas[i].mMeshes[k]->setTexture( baked_img );
+ LLViewerJointMesh* mesh = dynamic_cast<LLViewerJointMesh*>(mBakedTextureDatas[i].mMeshes[k]);
+ if (mesh)
+ {
+ mesh->setTexture( baked_img );
+ }
}
}
else if (!mUseLocalAppearance && is_layer_baked[i])
@@ -6764,14 +6750,18 @@ void LLVOAvatar::updateMeshTextures()
src_callback_list, paused );
}
}
- else if (mBakedTextureDatas[i].mTexLayerSet && mUseLocalAppearance)
+ else if (layerset && mUseLocalAppearance)
{
- mBakedTextureDatas[i].mTexLayerSet->createComposite();
- mBakedTextureDatas[i].mTexLayerSet->setUpdatesEnabled( TRUE );
+ layerset->createComposite();
+ layerset->setUpdatesEnabled( TRUE );
mBakedTextureDatas[i].mIsUsed = FALSE;
for (U32 k=0; k < mBakedTextureDatas[i].mMeshes.size(); k++)
{
- mBakedTextureDatas[i].mMeshes[k]->setLayerSet( mBakedTextureDatas[i].mTexLayerSet );
+ LLViewerJointMesh* mesh = dynamic_cast<LLViewerJointMesh*>(mBakedTextureDatas[i].mMeshes[k]);
+ if (mesh)
+ {
+ mesh->setLayerSet( layerset );
+ }
}
}
}
@@ -6785,8 +6775,12 @@ void LLVOAvatar::updateMeshTextures()
LLViewerTexture* hair_img = getImage( TEX_HAIR, 0 );
for (U32 i = 0; i < mBakedTextureDatas[BAKED_HAIR].mMeshes.size(); i++)
{
- mBakedTextureDatas[BAKED_HAIR].mMeshes[i]->setColor( color.mV[VX], color.mV[VY], color.mV[VZ], color.mV[VW] );
- mBakedTextureDatas[BAKED_HAIR].mMeshes[i]->setTexture( hair_img );
+ LLViewerJointMesh* mesh = dynamic_cast<LLViewerJointMesh*>(mBakedTextureDatas[BAKED_HAIR].mMeshes[i]);
+ if (mesh)
+ {
+ mesh->setColor( color.mV[VX], color.mV[VY], color.mV[VZ], color.mV[VW] );
+ mesh->setTexture( hair_img );
+ }
}
}
@@ -6859,16 +6853,28 @@ void LLVOAvatar::clearChat()
mChats.clear();
}
-// adds a morph mask to the appropriate baked texture structure
-void LLVOAvatar::addMaskedMorph(EBakedTextureIndex index, LLPolyMorphTarget* morph_target, BOOL invert, std::string layer)
+
+void LLVOAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index)
{
- if (index < BAKED_NUM_INDICES)
+ if (index >= BAKED_NUM_INDICES)
{
- LLMaskedMorph *morph = new LLMaskedMorph(morph_target, invert, layer);
- mBakedTextureDatas[index].mMaskedMorphs.push_front(morph);
+ llwarns << "invalid baked texture index passed to applyMorphMask" << llendl;
+ return;
+ }
+
+ for (morph_list_t::const_iterator iter = mBakedTextureDatas[index].mMaskedMorphs.begin();
+ iter != mBakedTextureDatas[index].mMaskedMorphs.end(); ++iter)
+ {
+ const LLMaskedMorph* maskedMorph = (*iter);
+ LLPolyMorphTarget* morph_target = dynamic_cast<LLPolyMorphTarget*>(maskedMorph->mMorphTarget);
+ if (morph_target)
+ {
+ morph_target->applyMask(tex_data, width, height, num_components, maskedMorph->mInvert);
+ }
}
}
+
// returns TRUE if morph masks are present and not valid for a given baked texture, FALSE otherwise
BOOL LLVOAvatar::morphMaskNeedsUpdate(LLAvatarAppearanceDefines::EBakedTextureIndex index)
{
@@ -6881,7 +6887,7 @@ BOOL LLVOAvatar::morphMaskNeedsUpdate(LLAvatarAppearanceDefines::EBakedTextureIn
{
if (isSelf())
{
- LLViewerTexLayerSet *layer_set = mBakedTextureDatas[index].mTexLayerSet;
+ LLViewerTexLayerSet *layer_set = getTexLayerSet(index);
if (layer_set)
{
return !layer_set->isMorphValid();
@@ -6896,23 +6902,6 @@ BOOL LLVOAvatar::morphMaskNeedsUpdate(LLAvatarAppearanceDefines::EBakedTextureIn
return FALSE;
}
-void LLVOAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index)
-{
- if (index >= BAKED_NUM_INDICES)
- {
- llwarns << "invalid baked texture index passed to applyMorphMask" << llendl;
- return;
- }
-
- for (morph_list_t::const_iterator iter = mBakedTextureDatas[index].mMaskedMorphs.begin();
- iter != mBakedTextureDatas[index].mMaskedMorphs.end(); ++iter)
- {
- const LLMaskedMorph* maskedMorph = (*iter);
- maskedMorph->mMorphTarget->applyMask(tex_data, width, height, num_components, maskedMorph->mInvert);
- }
-}
-
-
//-----------------------------------------------------------------------------
// releaseComponentTextures()
// release any component texture UUIDs for which we have a baked texture
@@ -7550,7 +7539,11 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id )
mBakedTextureDatas[i].mIsUsed = true;
for (U32 k = 0; k < mBakedTextureDatas[i].mMeshes.size(); k++)
{
- mBakedTextureDatas[i].mMeshes[k]->setTexture( image_baked );
+ LLViewerJointMesh* mesh = dynamic_cast<LLViewerJointMesh*>(mBakedTextureDatas[i].mMeshes[k]);
+ if (mesh)
+ {
+ mesh->setTexture( image_baked );
+ }
}
if (mBakedTextureDatas[i].mTexLayerSet)
{
@@ -7571,7 +7564,11 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id )
{
for (U32 i = 0; i < mBakedTextureDatas[BAKED_HAIR].mMeshes.size(); i++)
{
- mBakedTextureDatas[BAKED_HAIR].mMeshes[i]->setColor( 1.f, 1.f, 1.f, 1.f );
+ LLViewerJointMesh* mesh = dynamic_cast<LLViewerJointMesh*>(mBakedTextureDatas[BAKED_HAIR].mMeshes[i]);
+ if (mesh)
+ {
+ mesh->setColor( 1.f, 1.f, 1.f, 1.f );
+ }
}
}
}
@@ -8623,3 +8620,17 @@ BOOL LLVOAvatar::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type,
return FALSE;
}
+//virtual
+LLAvatarAppearance::LLMaskedMorph::LLMaskedMorph(LLVisualParam *morph_target, BOOL invert, std::string layer) :
+ mMorphTarget(morph_target),
+ mInvert(invert),
+ mLayer(layer)
+{
+ LLPolyMorphTarget *target = dynamic_cast<LLPolyMorphTarget*>(morph_target);
+ if (target)
+ {
+ target->addPendingMorphMask();
+ }
+}
+
+