diff options
Diffstat (limited to 'indra/newview/llvoavatarself.cpp')
-rw-r--r-- | indra/newview/llvoavatarself.cpp | 253 |
1 files changed, 212 insertions, 41 deletions
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 999a39efd1..99e358f409 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -600,7 +600,7 @@ BOOL LLVOAvatarSelf::loadLayersets() morph_iter++) { LLMaskedMorph *morph = *morph_iter; - LLTexLayer * layer = layer_set->findLayerByName(morph->mLayer); + LLTexLayerInterface* layer = layer_set->findLayerByName(morph->mLayer); if (layer) { layer->setHasMorph(TRUE); @@ -642,6 +642,71 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return LLVOAvatar::getJoint(name); } +/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL set_by_user ) +{ + if (!which_param) + { + return FALSE; + } + LLViewerVisualParam *param = (LLViewerVisualParam*) LLCharacter::getVisualParam(which_param->getID()); + return setParamWeight(param,weight,set_by_user); +} + +/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL set_by_user ) +{ + if (!param_name) + { + return FALSE; + } + LLViewerVisualParam *param = (LLViewerVisualParam*) LLCharacter::getVisualParam(param_name); + return setParamWeight(param,weight,set_by_user); +} + +/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL set_by_user ) +{ + LLViewerVisualParam *param = (LLViewerVisualParam*) LLCharacter::getVisualParam(index); + return setParamWeight(param,weight,set_by_user); +} + +BOOL LLVOAvatarSelf::setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL set_by_user ) +{ + if (!param) + { + return FALSE; + } + + if (param->getCrossWearable()) + { + EWearableType type = (EWearableType)param->getWearableType(); + U32 size = gAgentWearables.getWearableCount(type); + for (U32 count = 0; count < size; ++count) + { + LLWearable *wearable = gAgentWearables.getWearable(type,count); + if (wearable) + { + wearable->setVisualParamWeight(param->getID(), weight, set_by_user); + } + } + } + + return LLCharacter::setVisualParamWeight(param,weight,set_by_user); +} + +/*virtual*/ +void LLVOAvatarSelf::updateVisualParams() +{ + for (U32 type = 0; type < WT_COUNT; type++) + { + LLWearable *wearable = gAgentWearables.getTopWearable((EWearableType)type); + if (wearable) + { + wearable->writeToAvatar(FALSE, FALSE); + } + } + + LLVOAvatar::updateVisualParams(); +} + // virtual void LLVOAvatarSelf::requestStopMotion(LLMotion* motion) { @@ -872,6 +937,11 @@ void LLVOAvatarSelf::updateAttachmentVisibility(U32 camera_mode) } } +/*virtual*/ BOOL LLVOAvatarSelf::isWearingWearableType(EWearableType type ) const +{ + return gAgentWearables.getWearableCount(type) > 0; +} + //----------------------------------------------------------------------------- // updatedWearable( EWearableType type ) // forces an update to any baked textures relevant to type. @@ -917,7 +987,7 @@ BOOL LLVOAvatarSelf::isWearingAttachment( const LLUUID& inv_item_id , BOOL inclu { attachment_map_t::const_iterator curiter = iter++; const LLViewerJointAttachment* attachment = curiter->second; - if( attachment->getItemID() == inv_item_id ) + if (attachment->getAttachedObject(inv_item_id)) { return TRUE; } @@ -938,7 +1008,7 @@ BOOL LLVOAvatarSelf::isWearingAttachment( const LLUUID& inv_item_id , BOOL inclu { attachment_map_t::const_iterator curiter = iter++; const LLViewerJointAttachment* attachment = curiter->second; - if( attachment->getItemID() == item_id ) + if (attachment->getAttachedObject(item_id)) { return TRUE; } @@ -952,16 +1022,16 @@ BOOL LLVOAvatarSelf::isWearingAttachment( const LLUUID& inv_item_id , BOOL inclu //----------------------------------------------------------------------------- // getWornAttachment() //----------------------------------------------------------------------------- -LLViewerObject* LLVOAvatarSelf::getWornAttachment( const LLUUID& inv_item_id ) const +LLViewerObject* LLVOAvatarSelf::getWornAttachment( const LLUUID& inv_item_id ) { - for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); + for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ) { - attachment_map_t::const_iterator curiter = iter++; - const LLViewerJointAttachment* attachment = curiter->second; - if( attachment->getItemID() == inv_item_id ) + attachment_map_t::iterator curiter = iter++; + LLViewerJointAttachment* attachment = curiter->second; + if (LLViewerObject *attached_object = attachment->getAttachedObject(inv_item_id)) { - return attachment->getObject(); + return attached_object; } } return NULL; @@ -974,7 +1044,7 @@ const std::string LLVOAvatarSelf::getAttachedPointName(const LLUUID& inv_item_id { attachment_map_t::const_iterator curiter = iter++; const LLViewerJointAttachment* attachment = curiter->second; - if( attachment->getItemID() == inv_item_id ) + if (attachment->getAttachedObject(inv_item_id)) { return attachment->getName(); } @@ -984,9 +1054,9 @@ const std::string LLVOAvatarSelf::getAttachedPointName(const LLUUID& inv_item_id } //virtual -LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *viewer_object) +const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *viewer_object) { - LLViewerJointAttachment *attachment = LLVOAvatar::attachObject(viewer_object); + const LLViewerJointAttachment *attachment = LLVOAvatar::attachObject(viewer_object); if (!attachment) { return 0; @@ -995,14 +1065,20 @@ LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *viewer_obj updateAttachmentVisibility(gAgent.getCameraMode()); // Then make sure the inventory is in sync with the avatar. - LLViewerInventoryItem *item = gInventory.getItem(attachment->getItemID()); - if (item) - { - LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Adding attachment link:"); - LLAppearanceManager::wearItem(item,false); // Add COF link for item. + // Should just be the last object added + if (attachment->isObjectAttached(viewer_object)) + { + const LLUUID& attachment_id = viewer_object->getItemID(); + LLViewerInventoryItem *item = gInventory.getItem(attachment_id); + if (item) + { + LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Adding attachment link:"); + LLAppearanceManager::wearItem(item,false); // Add COF link for item. + gInventory.addChangedMask(LLInventoryObserver::LABEL, attachment_id); + } } - gInventory.addChangedMask(LLInventoryObserver::LABEL, attachment->getItemID()); + gInventory.notifyObservers(); return attachment; @@ -1116,6 +1192,25 @@ BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLViewerTexture** tex return TRUE; } +LLViewerFetchedTexture* LLVOAvatarSelf::getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, U32 index) const +{ + if (!isIndexLocalTexture(type)) + { + return NULL; + } + + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, index); + if (!local_tex_obj) + { + return NULL; + } + if (local_tex_obj->getID() == IMG_DEFAULT_AVATAR) + { + return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR); + } + return local_tex_obj->getImage(); +} + const LLUUID& LLVOAvatarSelf::getLocalTextureID(ETextureIndex type, U32 index) const { if (!isIndexLocalTexture(type)) return IMG_DEFAULT_AVATAR; @@ -1126,7 +1221,8 @@ const LLUUID& LLVOAvatarSelf::getLocalTextureID(ETextureIndex type, U32 index) c return local_tex_obj->getImage()->getID(); } return IMG_DEFAULT_AVATAR; -} +} + //----------------------------------------------------------------------------- // isLocalTextureDataAvailable() @@ -1151,7 +1247,12 @@ BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset) local_tex_iter++) { const ETextureIndex tex_index = *local_tex_iter; - ret &= (getLocalDiscardLevel(tex_index) >= 0); + const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index); + const U32 wearable_count = gAgentWearables.getWearableCount(wearable_type); + for (U32 wearable_index = 0; wearable_index < wearable_count; wearable_index++) + { + ret &= (getLocalDiscardLevel(tex_index, wearable_index) >= 0); + } } return ret; } @@ -1177,9 +1278,15 @@ BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) cons local_tex_iter != baked_dict->mLocalTextures.end(); local_tex_iter++) { - if (getLocalDiscardLevel(*local_tex_iter) != 0) + const ETextureIndex tex_index = *local_tex_iter; + const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index); + const U32 wearable_count = gAgentWearables.getWearableCount(wearable_type); + for (U32 wearable_index = 0; wearable_index < wearable_count; wearable_index++) { - return FALSE; + if (getLocalDiscardLevel(*local_tex_iter, wearable_index) != 0) + { + return FALSE; + } } } return TRUE; @@ -1192,17 +1299,33 @@ BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) cons BOOL LLVOAvatarSelf::isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index) const { LLUUID id; + BOOL isDefined = TRUE; if (isIndexLocalTexture(type)) { - id = getLocalTextureID(type, index); + const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(type); + const U32 wearable_count = gAgentWearables.getWearableCount(wearable_type); + if (index >= wearable_count) + { + // invalid index passed in. check all textures of a given type + for (U32 wearable_index = 0; wearable_index < wearable_count; wearable_index++) + { + id = getLocalTextureID(type, wearable_index); + isDefined &= (id != IMG_DEFAULT_AVATAR && id != IMG_DEFAULT); + } + } + else + { + id = getLocalTextureID(type, index); + isDefined &= (id != IMG_DEFAULT_AVATAR && id != IMG_DEFAULT); + } } else { id = getTEImage(type)->getID(); + isDefined &= (id != IMG_DEFAULT_AVATAR && id != IMG_DEFAULT); } - - return (id != IMG_DEFAULT_AVATAR && - id != IMG_DEFAULT); + + return isDefined; } //----------------------------------------------------------------------------- @@ -1213,7 +1336,8 @@ void LLVOAvatarSelf::requestLayerSetUploads() { for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - BOOL layer_baked = isTextureDefined(mBakedTextureDatas[i].mTextureIndex); + ETextureIndex tex_index = mBakedTextureDatas[i].mTextureIndex; + BOOL layer_baked = isTextureDefined(tex_index, gAgentWearables.getWearableCount(tex_index)); if (!layer_baked && mBakedTextureDatas[i].mTexLayerSet) { mBakedTextureDatas[i].mTexLayerSet->requestUpload(); @@ -1288,7 +1412,8 @@ void LLVOAvatarSelf::setupComposites() { for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - BOOL layer_baked = isTextureDefined(mBakedTextureDatas[i].mTextureIndex); + ETextureIndex tex_index = mBakedTextureDatas[i].mTextureIndex; + BOOL layer_baked = isTextureDefined(tex_index, gAgentWearables.getWearableCount(tex_index)); if (mBakedTextureDatas[i].mTexLayerSet) { mBakedTextureDatas[i].mTexLayerSet->setUpdatesEnabled(!layer_baked); @@ -1309,15 +1434,15 @@ void LLVOAvatarSelf::updateComposites() } // virtual -S32 LLVOAvatarSelf::getLocalDiscardLevel(ETextureIndex type, U32 index) const +S32 LLVOAvatarSelf::getLocalDiscardLevel(ETextureIndex type, U32 wearable_index) const { if (!isIndexLocalTexture(type)) return FALSE; - const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, index); + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, wearable_index); if (local_tex_obj) { if (type >= 0 - && getLocalTextureID(type,index) != IMG_DEFAULT_AVATAR + && local_tex_obj->getID() != IMG_DEFAULT_AVATAR && !local_tex_obj->getImage()->isMissingAsset()) { return local_tex_obj->getImage()->getDiscardLevel(); @@ -1381,7 +1506,7 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te return; } EWearableType wearable_type = LLVOAvatarDictionary::getInstance()->getTEWearableType(type); - if (!gAgentWearables.getWearable(wearable_type,0)) + if (!gAgentWearables.getWearable(wearable_type,index)) { // no wearable is loaded, cannot set the texture. return; @@ -1393,6 +1518,13 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te llerrs << "Unable to create LocalTextureObject for wearable type & index: (" << (U32) wearable_type << ", " << index << ")" << llendl; return; } + + LLTexLayerSet *layer_set = getLayerSet(type); + if (layer_set) + { + layer_set->cloneTemplates(local_tex_obj, type, gAgentWearables.getWearable(wearable_type,index)); + } + } if (!baked_version_ready) { @@ -1425,10 +1557,22 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te tex->setMinDiscardLevel(desired_discard); } } - local_tex_obj->setBakedReady( baked_version_ready ); local_tex_obj->setImage(tex); + local_tex_obj->setID(tex->getID()); + setBakedReady(type,baked_version_ready,index); +} +//virtual +void LLVOAvatarSelf::setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index) +{ + if (!isIndexLocalTexture(type)) return; + LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type,index); + if (local_tex_obj) + { + local_tex_obj->setBakedReady( baked_version_exists ); + } } + // virtual void LLVOAvatarSelf::dumpLocalTextures() const { @@ -1450,7 +1594,8 @@ void LLVOAvatarSelf::dumpLocalTextures() const const std::string &name = texture_dict->mName; const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(iter->first, 0); - if (isTextureDefined(baked_equiv)) + // index is baked texture - index is not relevant. putting in 0 as placeholder + if (isTextureDefined(baked_equiv, 0)) { #if LL_RELEASE_FOR_DOWNLOAD // End users don't get to trivially see avatar texture IDs, makes textures @@ -1510,6 +1655,31 @@ void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture * } } +/*virtual*/ void LLVOAvatarSelf::setImage(const U8 te, LLViewerTexture *imagep, const U32 index) +{ + if (isIndexLocalTexture((ETextureIndex)te)) + { + setLocalTexture((ETextureIndex)te, imagep, FALSE ,index); + } + else + { + setTEImage(te,imagep); + } +} + +/*virtual*/ LLViewerTexture* LLVOAvatarSelf::getImage(const U8 te, const U32 index) const +{ + if (isIndexLocalTexture((ETextureIndex)te)) + { + return getLocalTextureGL((ETextureIndex)te,index); + } + else + { + return getTEImage(te); + } +} + + // static void LLVOAvatarSelf::dumpTotalLocalTextureByteCount() { @@ -1528,7 +1698,7 @@ BOOL LLVOAvatarSelf::updateIsFullyLoaded() loading = TRUE; } - if (!isTextureDefined(TEX_HAIR)) + if (!isTextureDefined(TEX_HAIR, 0)) { loading = TRUE; } @@ -1536,13 +1706,13 @@ BOOL LLVOAvatarSelf::updateIsFullyLoaded() if (!mPreviousFullyLoaded) { if (!isLocalTextureDataAvailable(mBakedTextureDatas[BAKED_LOWER].mTexLayerSet) && - (!isTextureDefined(TEX_LOWER_BAKED))) + (!isTextureDefined(TEX_LOWER_BAKED, 0))) { loading = TRUE; } if (!isLocalTextureDataAvailable(mBakedTextureDatas[BAKED_UPPER].mTexLayerSet) && - (!isTextureDefined(TEX_UPPER_BAKED))) + (!isTextureDefined(TEX_UPPER_BAKED, 0))) { loading = TRUE; } @@ -1553,11 +1723,11 @@ BOOL LLVOAvatarSelf::updateIsFullyLoaded() continue; BakedTextureData& texture_data = mBakedTextureDatas[i]; - if (!isTextureDefined(texture_data.mTextureIndex)) + if (!isTextureDefined(texture_data.mTextureIndex, 0)) continue; // Check for the case that texture is defined but not sufficiently loaded to display anything. - LLViewerTexture* baked_img = getImage( texture_data.mTextureIndex ); + LLViewerTexture* baked_img = getImage( texture_data.mTextureIndex, 0 ); if (!baked_img || !baked_img->hasGLTexture()) { loading = TRUE; @@ -1581,9 +1751,9 @@ const LLUUID& LLVOAvatarSelf::grabLocalTexture(ETextureIndex type, U32 index) co BOOL LLVOAvatarSelf::canGrabLocalTexture(ETextureIndex type, U32 index) const { // Check if the texture hasn't been baked yet. - if (!isTextureDefined(type)) + if (!isTextureDefined(type, index)) { - lldebugs << "getTEImage( " << (U32) type << " )->getID() == IMG_DEFAULT_AVATAR" << llendl; + lldebugs << "getTEImage( " << (U32) type << ", " << index << " )->getID() == IMG_DEFAULT_AVATAR" << llendl; return FALSE; } @@ -1607,6 +1777,7 @@ BOOL LLVOAvatarSelf::canGrabLocalTexture(ETextureIndex type, U32 index) const { const ETextureIndex t_index = (*iter); lldebugs << "Checking index " << (U32) t_index << llendl; + // MULTI-WEARABLE: old method. replace. const LLUUID& texture_id = getTEImage( t_index )->getID(); if (texture_id != IMG_DEFAULT_AVATAR) { |