diff options
Diffstat (limited to 'indra/newview/llvoavatarself.cpp')
-rw-r--r-- | indra/newview/llvoavatarself.cpp | 187 |
1 files changed, 77 insertions, 110 deletions
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 4a80882c89..4a6bb6facb 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -156,11 +156,6 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id, gAgentWearables.setAvatarObject(this); lldebugs << "Marking avatar as self " << id << llendl; - - for (U32 i = 0; i < TEX_NUM_INDICES; i++) - { - mLocalTextureDatas[(ETextureIndex)i].push_back(new LocalTextureData); - } } void LLVOAvatarSelf::initInstance() @@ -536,19 +531,6 @@ LLVOAvatarSelf::~LLVOAvatarSelf() gAgentWearables.setAvatarObject(NULL); delete mScreenp; mScreenp = NULL; - - for (localtexture_map_t::iterator iter = mLocalTextureDatas.begin(); - iter != mLocalTextureDatas.end(); - iter++) - { - localtexture_vec_t &local_textures = iter->second; - for (U32 i = 0; i < local_textures.size(); i++) - { - LocalTextureData* loc_tex_data = local_textures[i]; - delete loc_tex_data; - local_textures[i] = NULL; - } - } } /** @@ -1008,6 +990,12 @@ LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *viewer_obj return attachment; } +U32 LLVOAvatarSelf::getNumWearables(LLVOAvatarDefines::ETextureIndex i) const +{ + EWearableType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i); + return gAgentWearables.getWearableCount(type); +} + // virtual void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src_raw, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) { @@ -1015,17 +1003,17 @@ void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *sr const LLUUID& src_id = src_vi->getID(); LLAvatarTexData *data = (LLAvatarTexData *)userdata; + ETextureIndex index = data->mIndex; + if (!isIndexLocalTexture(index)) return; + LLLocalTextureObject *local_tex_obj = getLocalTextureObject(index, 0); if (success) { - ETextureIndex index = data->mIndex; - if (!isIndexLocalTexture(index)) return; - LocalTextureData *local_tex_data = getLocalTextureData(index,0); - if (!local_tex_data->mIsBakedReady && - local_tex_data->mImage.notNull() && - (local_tex_data->mImage->getID() == src_id) && - discard_level < local_tex_data->mDiscard) + if (!local_tex_obj->getBakedReady() && + local_tex_obj->getImage() != NULL && + (local_tex_obj->getID() == src_id) && + discard_level < local_tex_obj->getDiscard()) { - local_tex_data->mDiscard = discard_level; + local_tex_obj->setDiscard(discard_level); if (!gAgent.cameraCustomizeAvatar()) { requestLayerSetUpdate(index); @@ -1039,15 +1027,12 @@ void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *sr } else if (final) { - ETextureIndex index = data->mIndex; - if (!isIndexLocalTexture(index)) return; - LocalTextureData *local_tex_data = getLocalTextureData(index,0); // Failed: asset is missing - if (!local_tex_data->mIsBakedReady && - local_tex_data->mImage.notNull() && - local_tex_data->mImage->getID() == src_id) + if (!local_tex_obj->getBakedReady() && + local_tex_obj->getImage() != NULL && + local_tex_obj->getImage()->getID() == src_id) { - local_tex_data->mDiscard = 0; + local_tex_obj->setDiscard(0); requestLayerSetUpdate(index); updateMeshTextures(); } @@ -1082,12 +1067,12 @@ BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLViewerTexture** tex if (!isIndexLocalTexture(type)) return FALSE; if (getLocalTextureID(type, index) == IMG_DEFAULT_AVATAR) return TRUE; - const LocalTextureData *local_tex_data = getLocalTextureData(type, index); - if (!local_tex_data) + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, index); + if (!local_tex_obj) { return FALSE; } - *tex_pp = local_tex_data->mImage; + *tex_pp = local_tex_obj->getImage(); return TRUE; } @@ -1095,10 +1080,10 @@ const LLUUID& LLVOAvatarSelf::getLocalTextureID(ETextureIndex type, U32 index) c { if (!isIndexLocalTexture(type)) return IMG_DEFAULT_AVATAR; - const LocalTextureData *local_tex_data = getLocalTextureData(type,index); - if (local_tex_data && local_tex_data->mImage.notNull()) + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, index); + if (local_tex_obj && local_tex_obj->getImage() != NULL) { - return local_tex_data->mImage->getID(); + return local_tex_obj->getImage()->getID(); } return IMG_DEFAULT_AVATAR; } @@ -1288,14 +1273,14 @@ S32 LLVOAvatarSelf::getLocalDiscardLevel(ETextureIndex type, U32 index) const { if (!isIndexLocalTexture(type)) return FALSE; - const LocalTextureData *local_tex_data = getLocalTextureData(type,index); - if (local_tex_data) + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, index); + if (local_tex_obj) { if (type >= 0 && getLocalTextureID(type,index) != IMG_DEFAULT_AVATAR - && !local_tex_data->mImage->isMissingAsset()) + && !local_tex_obj->getImage()->isMissingAsset()) { - return local_tex_data->mImage->getDiscardLevel(); + return local_tex_obj->getImage()->getDiscardLevel(); } else { @@ -1314,13 +1299,13 @@ void LLVOAvatarSelf::getLocalTextureByteCount(S32* gl_bytes) const for (S32 type = 0; type < TEX_NUM_INDICES; type++) { if (!isIndexLocalTexture((ETextureIndex)type)) continue; - const localtexture_vec_t & local_tex_vec = getLocalTextureData((ETextureIndex)type); - for (U32 num = 0; num < local_tex_vec.size(); num++) + U32 max_tex = getNumWearables((ETextureIndex) type); + for (U32 num = 0; num < max_tex; num++) { - const LocalTextureData *local_tex_data = local_tex_vec[num]; - if (local_tex_data) + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject((ETextureIndex) type, num); + if (local_tex_obj) { - const LLViewerFetchedTexture* image_gl = local_tex_data->mImage; + const LLViewerFetchedTexture* image_gl = local_tex_obj->getImage(); if (image_gl) { S32 bytes = (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents(); @@ -1347,21 +1332,42 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te } S32 desired_discard = isSelf() ? 0 : 2; - LocalTextureData *local_tex_data = getLocalTextureData(type,index); + LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type,index); + if (!local_tex_obj) + { + if (type >= TEX_NUM_INDICES) + { + llerrs << "Tried to set local texture with invalid type: (" << (U32) type << ", " << index << ")" << llendl; + return; + } + EWearableType wearable_type = LLVOAvatarDictionary::getInstance()->getTEWearableType(type); + if (!gAgentWearables.getWearable(wearable_type,0)) + { + // no wearable is loaded, cannot set the texture. + return; + } + gAgentWearables.addLocalTextureObject(wearable_type,type,index); + local_tex_obj = getLocalTextureObject(type,index); + if (!local_tex_obj) + { + llerrs << "Unable to create LocalTextureObject for wearable type & index: (" << (U32) wearable_type << ", " << index << ")" << llendl; + return; + } + } if (!baked_version_ready) { - if (tex != local_tex_data->mImage || local_tex_data->mIsBakedReady) + if (tex != local_tex_obj->getImage() || local_tex_obj->getBakedReady()) { - local_tex_data->mDiscard = MAX_DISCARD_LEVEL+1; + local_tex_obj->setDiscard(MAX_DISCARD_LEVEL+1); } if (tex->getID() != IMG_DEFAULT_AVATAR) { - if (local_tex_data->mDiscard > desired_discard) + if (local_tex_obj->getDiscard() > desired_discard) { S32 tex_discard = tex->getDiscardLevel(); if (tex_discard >= 0 && tex_discard <= desired_discard) { - local_tex_data->mDiscard = tex_discard; + local_tex_obj->setDiscard(tex_discard); if (isSelf() && !gAgent.cameraCustomizeAvatar()) { requestLayerSetUpdate(type); @@ -1379,8 +1385,8 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te tex->setMinDiscardLevel(desired_discard); } } - local_tex_data->mIsBakedReady = baked_version_ready; - local_tex_data->mImage = tex; + local_tex_obj->setBakedReady( baked_version_ready ); + local_tex_obj->setImage(tex); } // virtual @@ -1403,7 +1409,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const const ETextureIndex baked_equiv = LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index)->mTextureIndex; const std::string &name = texture_dict->mName; - const LocalTextureData *local_tex_data = getLocalTextureData(iter->first,0); + const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(iter->first, 0); if (isTextureDefined(baked_equiv)) { #if LL_RELEASE_FOR_DOWNLOAD @@ -1414,15 +1420,15 @@ void LLVOAvatarSelf::dumpLocalTextures() const llinfos << "LocTex " << name << ": Baked " << getTEImage(baked_equiv)->getID() << llendl; #endif } - else if (local_tex_data->mImage.notNull()) + else if (local_tex_obj->getImage() != NULL) { - if (local_tex_data->mImage->getID() == IMG_DEFAULT_AVATAR) + if (local_tex_obj->getImage()->getID() == IMG_DEFAULT_AVATAR) { llinfos << "LocTex " << name << ": None" << llendl; } else { - const LLViewerFetchedTexture* image = local_tex_data->mImage; + const LLViewerFetchedTexture* image = local_tex_obj->getImage(); llinfos << "LocTex " << name << ": " << "Discard " << image->getDiscardLevel() << ", " @@ -1464,57 +1470,6 @@ void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture * } } - -const LLVOAvatarSelf::localtexture_vec_t &LLVOAvatarSelf::getLocalTextureData(LLVOAvatarDefines::ETextureIndex type) const -{ - localtexture_map_t::const_iterator found_localtexture = mLocalTextureDatas.find(type); - if (found_localtexture != mLocalTextureDatas.end()) - { - const localtexture_vec_t &local_tex_data = found_localtexture->second; - return local_tex_data; - } - llassert(0); - static localtexture_vec_t ret; - return ret; -} - -const LocalTextureData* LLVOAvatarSelf::getLocalTextureData(LLVOAvatarDefines::ETextureIndex type, U32 index ) const -{ - const localtexture_vec_t &local_tex_array = getLocalTextureData(type); - - if (index >= local_tex_array.size()) - { - return NULL; - } - - return local_tex_array[index]; -} - -LLVOAvatarSelf::localtexture_vec_t &LLVOAvatarSelf::getLocalTextureData(LLVOAvatarDefines::ETextureIndex type) -{ - localtexture_map_t::iterator found_localtexture = mLocalTextureDatas.find(type); - if (found_localtexture != mLocalTextureDatas.end()) - { - localtexture_vec_t &local_tex_data = found_localtexture->second; - return local_tex_data; - } - llassert(0); - static localtexture_vec_t ret; - return ret; -} - -LocalTextureData* LLVOAvatarSelf::getLocalTextureData(LLVOAvatarDefines::ETextureIndex type, U32 index ) -{ - localtexture_vec_t &local_tex_array = getLocalTextureData(type); - - if (index >= local_tex_array.size()) - { - return NULL; - } - - return local_tex_array[index]; -} - // static void LLVOAvatarSelf::dumpTotalLocalTextureByteCount() { @@ -1679,6 +1634,18 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe } } +LLLocalTextureObject* LLVOAvatarSelf::getLocalTextureObject(LLVOAvatarDefines::ETextureIndex i, U32 wearable_index) const +{ + EWearableType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i); + LLWearable* wearable = gAgentWearables.getWearable(type, wearable_index); + if (wearable) + { + return wearable->getLocalTextureObject(i); + } + + return NULL; +} + //----------------------------------------------------------------------------- // getBakedTE() // Used by the LayerSet. (Layer sets don't in general know what textures depend on them.) |