diff options
Diffstat (limited to 'indra/newview/llvoavatarself.cpp')
-rw-r--r-- | indra/newview/llvoavatarself.cpp | 773 |
1 files changed, 591 insertions, 182 deletions
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index ecd6b05ded..ec5c95469e 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2,31 +2,25 @@ * @file llvoavatar.cpp * @brief Implementation of LLVOAvatar class which is a derivation fo LLViewerObject * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -44,15 +38,20 @@ #include "pipeline.h" #include "llagent.h" // Get state values from here +#include "llagentcamera.h" #include "llagentwearables.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" +#include "llinventoryfunctions.h" +#include "llmenugl.h" +#include "llnotificationsutil.h" #include "llselectmgr.h" #include "lltoolgrab.h" // for needsRenderBeam #include "lltoolmgr.h" // for needsRenderBeam #include "lltoolmorph.h" #include "lltrans.h" #include "llviewercamera.h" +#include "llviewercontrol.h" #include "llviewermenu.h" #include "llviewerobjectlist.h" #include "llviewerstats.h" @@ -66,6 +65,14 @@ #include <boost/lexical_cast.hpp> +LLVOAvatarSelf *gAgentAvatarp = NULL; +BOOL isAgentAvatarValid() +{ + return (gAgentAvatarp && + (gAgentAvatarp->getRegion() != NULL) && + (!gAgentAvatarp->isDead())); +} + using namespace LLVOAvatarDefines; /********************************************************************************* @@ -77,14 +84,14 @@ using namespace LLVOAvatarDefines; struct LocalTextureData { LocalTextureData() : - mIsBakedReady(FALSE), + mIsBakedReady(false), mDiscard(MAX_DISCARD_LEVEL+1), mImage(NULL), mWearableID(IMG_DEFAULT_AVATAR), mTexEntry(NULL) {} LLPointer<LLViewerFetchedTexture> mImage; - BOOL mIsBakedReady; + bool mIsBakedReady; S32 mDiscard; LLUUID mWearableID; // UUID of the wearable that this texture belongs to, not of the image itself LLTextureEntry *mTexEntry; @@ -93,15 +100,7 @@ struct LocalTextureData //----------------------------------------------------------------------------- // Callback data //----------------------------------------------------------------------------- -struct LLAvatarTexData -{ - LLAvatarTexData(const LLUUID& id, ETextureIndex index) : - mAvatarID(id), - mIndex(index) - {} - LLUUID mAvatarID; - ETextureIndex mIndex; -}; + /** ** @@ -132,9 +131,10 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id, mLastRegionHandle(0), mRegionCrossingCount(0) { - gAgent.setAvatarObject(this); gAgentWearables.setAvatarObject(this); - + + mMotionController.mIsSelf = TRUE; + lldebugs << "Marking avatar as self " << id << llendl; } @@ -147,6 +147,23 @@ void LLVOAvatarSelf::initInstance() // adds attachment points to mScreen among other things LLVOAvatar::initInstance(); + llinfos << "Self avatar object created. Starting timer." << llendl; + mDebugSelfLoadTimer.reset(); + // clear all times to -1 for debugging + for (U32 i =0; i < LLVOAvatarDefines::TEX_NUM_INDICES; ++i) + { + for (U32 j = 0; j <= MAX_DISCARD_LEVEL; ++j) + { + mDebugTextureLoadTimes[i][j] = -1.0f; + } + } + + for (U32 i =0; i < LLVOAvatarDefines::BAKED_NUM_INDICES; ++i) + { + mDebugBakedTextureTimes[i][0] = -1.0f; + mDebugBakedTextureTimes[i][1] = -1.0f; + } + status &= buildMenus(); if (!status) { @@ -174,7 +191,7 @@ void LLVOAvatarSelf::markDead() param; param = (LLViewerVisualParam*) getNextVisualParam()) { - if (param->getWearableType() != WT_INVALID) + if (param->getWearableType() != LLWearableType::WT_INVALID) { param->setIsDummy(TRUE); } @@ -211,6 +228,8 @@ BOOL LLVOAvatarSelf::buildSkeletonSelf(const LLVOAvatarSkeletonInfo *info) LLVector3 scale(1.f, aspect, 1.f); mScreenp->setScale(scale); mScreenp->setWorldPosition(LLVector3::zero); + // need to update screen agressively when sidebar opens/closes, for example + mScreenp->mUpdateXform = TRUE; return TRUE; } @@ -222,58 +241,58 @@ BOOL LLVOAvatarSelf::buildMenus() gAttachBodyPartPieMenus[0] = NULL; LLContextMenu::Params params; - params.label(LLTrans::getString("BodyPartsRightArm") + " >"); + params.label(LLTrans::getString("BodyPartsRightArm") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); params.visible(false); gAttachBodyPartPieMenus[1] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsHead") + " >"); + params.label(LLTrans::getString("BodyPartsHead") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gAttachBodyPartPieMenus[2] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsLeftArm") + " >"); + params.label(LLTrans::getString("BodyPartsLeftArm") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gAttachBodyPartPieMenus[3] = LLUICtrlFactory::create<LLContextMenu> (params); gAttachBodyPartPieMenus[4] = NULL; - params.label(LLTrans::getString("BodyPartsLeftLeg") + " >"); + params.label(LLTrans::getString("BodyPartsLeftLeg") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gAttachBodyPartPieMenus[5] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsTorso") + " >"); + params.label(LLTrans::getString("BodyPartsTorso") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gAttachBodyPartPieMenus[6] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsRightLeg") + " >"); + params.label(LLTrans::getString("BodyPartsRightLeg") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gAttachBodyPartPieMenus[7] = LLUICtrlFactory::create<LLContextMenu> (params); gDetachBodyPartPieMenus[0] = NULL; - params.label(LLTrans::getString("BodyPartsRightArm") + " >"); + params.label(LLTrans::getString("BodyPartsRightArm") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gDetachBodyPartPieMenus[1] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsHead") + " >"); + params.label(LLTrans::getString("BodyPartsHead") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gDetachBodyPartPieMenus[2] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsLeftArm") + " >"); + params.label(LLTrans::getString("BodyPartsLeftArm") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gDetachBodyPartPieMenus[3] = LLUICtrlFactory::create<LLContextMenu> (params); gDetachBodyPartPieMenus[4] = NULL; - params.label(LLTrans::getString("BodyPartsLeftLeg") + " >"); + params.label(LLTrans::getString("BodyPartsLeftLeg") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gDetachBodyPartPieMenus[5] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsTorso") + " >"); + params.label(LLTrans::getString("BodyPartsTorso") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gDetachBodyPartPieMenus[6] = LLUICtrlFactory::create<LLContextMenu> (params); - params.label(LLTrans::getString("BodyPartsRightLeg") + " >"); + params.label(LLTrans::getString("BodyPartsRightLeg") + " " + LLMenuGL::BRANCH_SUFFIX); params.name(params.label); gDetachBodyPartPieMenus[7] = LLUICtrlFactory::create<LLContextMenu> (params); @@ -487,7 +506,7 @@ BOOL LLVOAvatarSelf::buildMenus() { LLMenuItemCallGL::Params item_params; item_params.name = attachment->getName(); - item_params.label = attachment->getName(); + item_params.label = LLTrans::getString(attachment->getName()); item_params.on_click.function_name = "Object.AttachToAvatar"; item_params.on_click.parameter = attach_index; item_params.on_enable.function_name = "Object.EnableWear"; @@ -508,12 +527,17 @@ BOOL LLVOAvatarSelf::buildMenus() return TRUE; } +void LLVOAvatarSelf::cleanup() +{ + markDead(); + delete mScreenp; + mScreenp = NULL; + mRegionp = NULL; +} + LLVOAvatarSelf::~LLVOAvatarSelf() { - gAgent.setAvatarObject(NULL); - gAgentWearables.setAvatarObject(NULL); - delete mScreenp; - mScreenp = NULL; + cleanup(); } /** @@ -604,6 +628,18 @@ BOOL LLVOAvatarSelf::updateCharacter(LLAgent &agent) } // virtual +BOOL LLVOAvatarSelf::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) +{ + if (!isAgentAvatarValid()) + { + return TRUE; + } + LLVOAvatar::idleUpdate(agent, world, time); + idleUpdateTractorBeam(); + return TRUE; +} + +// virtual LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) { if (mScreenp) @@ -614,7 +650,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return LLVOAvatar::getJoint(name); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) { if (!which_param) { @@ -624,7 +661,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return setParamWeight(param,weight,upload_bake); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake ) { if (!param_name) { @@ -634,7 +672,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return setParamWeight(param,weight,upload_bake); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake ) { LLViewerVisualParam *param = (LLViewerVisualParam*) LLCharacter::getVisualParam(index); return setParamWeight(param,weight,upload_bake); @@ -649,7 +688,7 @@ BOOL LLVOAvatarSelf::setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL if (param->getCrossWearable()) { - EWearableType type = (EWearableType)param->getWearableType(); + LLWearableType::EType type = (LLWearableType::EType)param->getWearableType(); U32 size = gAgentWearables.getWearableCount(type); for (U32 count = 0; count < size; ++count) { @@ -667,15 +706,6 @@ BOOL LLVOAvatarSelf::setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL /*virtual*/ void LLVOAvatarSelf::updateVisualParams() { - for (U32 type = 0; type < WT_COUNT; type++) - { - LLWearable *wearable = gAgentWearables.getTopWearable((EWearableType)type); - if (wearable) - { - wearable->writeToAvatar(); - } - } - LLVOAvatar::updateVisualParams(); } @@ -686,7 +716,14 @@ void LLVOAvatarSelf::idleUpdateAppearanceAnimation() gAgentWearables.animateAllWearableParams(calcMorphAmount(), FALSE); // apply wearable visual params to avatar - updateVisualParams(); + for (U32 type = 0; type < LLWearableType::WT_COUNT; type++) + { + LLWearable *wearable = gAgentWearables.getTopWearable((LLWearableType::EType)type); + if (wearable) + { + wearable->writeToAvatar(); + } + } //allow avatar to process updates LLVOAvatar::idleUpdateAppearanceAnimation(); @@ -759,6 +796,7 @@ void LLVOAvatarSelf::removeMissingBakedTextures() { for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { + mBakedTextureDatas[i].mTexLayerSet->setUpdatesEnabled(TRUE); invalidateComposite(mBakedTextureDatas[i].mTexLayerSet, FALSE); } updateMeshTextures(); @@ -769,7 +807,8 @@ void LLVOAvatarSelf::removeMissingBakedTextures() //virtual void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp) { - if (regionp->getHandle() != mLastRegionHandle) + setRegion(regionp); + if (!regionp || (regionp->getHandle() != mLastRegionHandle)) { if (mLastRegionHandle != 0) { @@ -783,7 +822,10 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp) max = llmax(delta, max); LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max); } - mLastRegionHandle = regionp->getHandle(); + if (regionp) + { + mLastRegionHandle = regionp->getHandle(); + } } mRegionCrossingTimer.reset(); } @@ -812,10 +854,10 @@ void LLVOAvatarSelf::idleUpdateTractorBeam() { LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (gAgent.mPointAt.notNull()) + if (gAgentCamera.mPointAt.notNull()) { // get point from pointat effect - mBeam->setPositionGlobal(gAgent.mPointAt->getPointAtPosGlobal()); + mBeam->setPositionGlobal(gAgentCamera.mPointAt->getPointAtPosGlobal()); mBeam->triggerLocal(); } else if (selection->getFirstRootObject() && @@ -866,7 +908,7 @@ void LLVOAvatarSelf::restoreMeshData() //llinfos << "Restoring" << llendl; mMeshValid = TRUE; updateJointLODs(); - updateAttachmentVisibility(gAgent.getCameraMode()); + updateAttachmentVisibility(gAgentCamera.getCameraMode()); // force mesh update as LOD might not have changed to trigger this gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); @@ -910,17 +952,17 @@ void LLVOAvatarSelf::updateAttachmentVisibility(U32 camera_mode) } } -/*virtual*/ BOOL LLVOAvatarSelf::isWearingWearableType(EWearableType type ) const +/*virtual*/ BOOL LLVOAvatarSelf::isWearingWearableType(LLWearableType::EType type ) const { return gAgentWearables.getWearableCount(type) > 0; } //----------------------------------------------------------------------------- -// updatedWearable( EWearableType type ) +// updatedWearable( LLWearableType::EType type ) // forces an update to any baked textures relevant to type. // will force an upload of the resulting bake if the second parameter is TRUE //----------------------------------------------------------------------------- -void LLVOAvatarSelf::wearableUpdated( EWearableType type, BOOL upload_result ) +void LLVOAvatarSelf::wearableUpdated( LLWearableType::EType type, BOOL upload_result ) { for (LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDictionary::getInstance()->getBakedTextures().begin(); baked_iter != LLVOAvatarDictionary::getInstance()->getBakedTextures().end(); @@ -928,17 +970,19 @@ void LLVOAvatarSelf::wearableUpdated( EWearableType type, BOOL upload_result ) { const LLVOAvatarDictionary::BakedEntry *baked_dict = baked_iter->second; const LLVOAvatarDefines::EBakedTextureIndex index = baked_iter->first; + if (baked_dict) { for (LLVOAvatarDefines::wearables_vec_t::const_iterator type_iter = baked_dict->mWearables.begin(); type_iter != baked_dict->mWearables.end(); ++type_iter) { - const EWearableType comp_type = *type_iter; + const LLWearableType::EType comp_type = *type_iter; if (comp_type == type) { if (mBakedTextureDatas[index].mTexLayerSet) { + mBakedTextureDatas[index].mTexLayerSet->setUpdatesEnabled(true); invalidateComposite(mBakedTextureDatas[index].mTexLayerSet, upload_result); } break; @@ -968,6 +1012,44 @@ BOOL LLVOAvatarSelf::isWearingAttachment(const LLUUID& inv_item_id) const } //----------------------------------------------------------------------------- +BOOL LLVOAvatarSelf::attachmentWasRequested(const LLUUID& inv_item_id) const +{ + const F32 REQUEST_EXPIRATION_SECONDS = 5.0; // any request older than this is ignored/removed. + std::map<LLUUID,LLTimer>::iterator it = mAttachmentRequests.find(inv_item_id); + if (it != mAttachmentRequests.end()) + { + const LLTimer& request_time = it->second; + F32 request_time_elapsed = request_time.getElapsedTimeF32(); + if (request_time_elapsed > REQUEST_EXPIRATION_SECONDS) + { + mAttachmentRequests.erase(it); + return FALSE; + } + else + { + return TRUE; + } + } + else + { + return FALSE; + } +} + +//----------------------------------------------------------------------------- +void LLVOAvatarSelf::addAttachmentRequest(const LLUUID& inv_item_id) +{ + LLTimer current_time; + mAttachmentRequests[inv_item_id] = current_time; +} + +//----------------------------------------------------------------------------- +void LLVOAvatarSelf::removeAttachmentRequest(const LLUUID& inv_item_id) +{ + mAttachmentRequests.erase(inv_item_id); +} + +//----------------------------------------------------------------------------- // getWornAttachment() //----------------------------------------------------------------------------- LLViewerObject* LLVOAvatarSelf::getWornAttachment(const LLUUID& inv_item_id) @@ -1012,15 +1094,17 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view return 0; } - updateAttachmentVisibility(gAgent.getCameraMode()); + updateAttachmentVisibility(gAgentCamera.getCameraMode()); // Then make sure the inventory is in sync with the avatar. // Should just be the last object added if (attachment->isObjectAttached(viewer_object)) { - const LLUUID& attachment_id = viewer_object->getItemID(); - LLAppearanceManager::instance().registerAttachment(attachment_id); + const LLUUID& attachment_id = viewer_object->getAttachmentItemID(); + LLAppearanceMgr::instance().registerAttachment(attachment_id); + // Clear any pending requests once the attachment arrives. + removeAttachmentRequest(attachment_id); } return attachment; @@ -1029,7 +1113,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view //virtual BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) { - const LLUUID attachment_id = viewer_object->getItemID(); + const LLUUID attachment_id = viewer_object->getAttachmentItemID(); if (LLVOAvatar::detachObject(viewer_object)) { // the simulator should automatically handle permission revocation @@ -1053,13 +1137,13 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) // Make sure the inventory is in sync with the avatar. // Update COF contents, don't trigger appearance update. - if (gAgent.getAvatarObject() == NULL) + if (!isAgentAvatarValid()) { llinfos << "removeItemLinks skipped, avatar is under destruction" << llendl; } else { - LLAppearanceManager::instance().unregisterAttachment(attachment_id); + LLAppearanceMgr::instance().unregisterAttachment(attachment_id); } return TRUE; @@ -1067,21 +1151,56 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) return FALSE; } +// static +BOOL LLVOAvatarSelf::detachAttachmentIntoInventory(const LLUUID &item_id) +{ + LLInventoryItem* item = gInventory.getItem(item_id); + if (item) + { + gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv); + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_ItemID, item_id); + gMessageSystem->sendReliable(gAgent.getRegion()->getHost()); + + // This object might have been selected, so let the selection manager know it's gone now + LLViewerObject *found_obj = gObjectList.findObject(item_id); + if (found_obj) + { + LLSelectMgr::getInstance()->remove(found_obj); + } + + // Error checking in case this object was attached to an invalid point + // In that case, just remove the item from COF preemptively since detach + // will fail. + if (isAgentAvatarValid()) + { + const LLViewerObject *attached_obj = gAgentAvatarp->getWornAttachment(item_id); + if (!attached_obj) + { + LLAppearanceMgr::instance().removeCOFItemLinks(item_id, false); + } + } + return TRUE; + } + return FALSE; +} + U32 LLVOAvatarSelf::getNumWearables(LLVOAvatarDefines::ETextureIndex i) const { - EWearableType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i); + LLWearableType::EType 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) { - //llinfos << "onLocalTextureLoaded: " << src_vi->getID() << llendl; 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); // fix for EXT-268. Preventing using of NULL pointer @@ -1100,11 +1219,11 @@ void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *sr discard_level < local_tex_obj->getDiscard()) { local_tex_obj->setDiscard(discard_level); - if (!gAgent.cameraCustomizeAvatar()) + if (isUsingBakedTextures()) { requestLayerSetUpdate(index); } - else if (gAgent.cameraCustomizeAvatar()) + else { LLVisualParamHint::requestHintUpdates(); } @@ -1197,7 +1316,7 @@ BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset) ++local_tex_iter) { const ETextureIndex tex_index = *local_tex_iter; - const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index); + const LLWearableType::EType 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++) { @@ -1219,6 +1338,9 @@ BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset) //----------------------------------------------------------------------------- BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) const { + const U32 desired_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + // const U32 desired_tex_discard_level = 0; // hack to not bake textures on lower discard levels. + for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { if (layerset == mBakedTextureDatas[i].mTexLayerSet) @@ -1229,11 +1351,11 @@ BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) cons ++local_tex_iter) { const ETextureIndex tex_index = *local_tex_iter; - const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index); + const LLWearableType::EType 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++) { - if (getLocalDiscardLevel(*local_tex_iter, wearable_index) != 0) + if (getLocalDiscardLevel(*local_tex_iter, wearable_index) > (S32)(desired_tex_discard_level)) { return FALSE; } @@ -1246,13 +1368,49 @@ BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) cons return FALSE; } +BOOL LLVOAvatarSelf::isAllLocalTextureDataFinal() const +{ + const U32 desired_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + // const U32 desired_tex_discard_level = 0; // hack to not bake textures on lower discard levels + + for (U32 i = 0; i < mBakedTextureDatas.size(); i++) + { + const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex)i); + for (texture_vec_t::const_iterator local_tex_iter = baked_dict->mLocalTextures.begin(); + local_tex_iter != baked_dict->mLocalTextures.end(); + ++local_tex_iter) + { + const ETextureIndex tex_index = *local_tex_iter; + const LLWearableType::EType 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++) + { + if (getLocalDiscardLevel(*local_tex_iter, wearable_index) > (S32)(desired_tex_discard_level)) + { + return FALSE; + } + } + } + } + return TRUE; +} + +BOOL LLVOAvatarSelf::isBakedTextureFinal(const LLVOAvatarDefines::EBakedTextureIndex index) const +{ + const LLTexLayerSet *layerset = mBakedTextureDatas[index].mTexLayerSet; + if (!layerset) return FALSE; + const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite(); + if (!layerset_buffer) return FALSE; + return !layerset_buffer->uploadNeeded(); +} + BOOL LLVOAvatarSelf::isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index) const { LLUUID id; BOOL isDefined = TRUE; if (isIndexLocalTexture(type)) { - const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(type); + const LLWearableType::EType wearable_type = LLVOAvatarDictionary::getTEWearableType(type); const U32 wearable_count = gAgentWearables.getWearableCount(wearable_type); if (index >= wearable_count) { @@ -1278,20 +1436,50 @@ BOOL LLVOAvatarSelf::isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 return isDefined; } +//virtual +BOOL LLVOAvatarSelf::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index) const +{ + if (isIndexBakedTexture(type)) + { + return LLVOAvatar::isTextureVisible(type, (U32)0); + } + + LLUUID tex_id = getLocalTextureID(type,index); + return (tex_id != IMG_INVISIBLE) + || (LLDrawPoolAlpha::sShowDebugAlpha); +} + +//virtual +BOOL LLVOAvatarSelf::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const +{ + if (isIndexBakedTexture(type)) + { + return LLVOAvatar::isTextureVisible(type); + } + + U32 index = gAgentWearables.getWearableIndex(wearable); + return isTextureVisible(type,index); +} + + //----------------------------------------------------------------------------- -// virtual // requestLayerSetUploads() //----------------------------------------------------------------------------- void LLVOAvatarSelf::requestLayerSetUploads() { for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - 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(); - } + requestLayerSetUpload((EBakedTextureIndex)i); + } +} + +void LLVOAvatarSelf::requestLayerSetUpload(LLVOAvatarDefines::EBakedTextureIndex i) +{ + ETextureIndex tex_index = mBakedTextureDatas[i].mTextureIndex; + const BOOL layer_baked = isTextureDefined(tex_index, gAgentWearables.getWearableCount(tex_index)); + if (!layer_baked && mBakedTextureDatas[i].mTexLayerSet) + { + mBakedTextureDatas[i].mTexLayerSet->requestUpload(); } } @@ -1305,8 +1493,8 @@ bool LLVOAvatarSelf::hasPendingBakedUploads() const { for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - BOOL upload_pending = (mBakedTextureDatas[i].mTexLayerSet && mBakedTextureDatas[i].mTexLayerSet->getComposite()->uploadPending()); - if (upload_pending) + LLTexLayerSet* layerset = mBakedTextureDatas[i].mTexLayerSet; + if (layerset && layerset->getComposite() && layerset->getComposite()->uploadPending()) { return true; } @@ -1320,7 +1508,7 @@ void LLVOAvatarSelf::invalidateComposite( LLTexLayerSet* layerset, BOOL upload_r { return; } - // llinfos << "LLVOAvatar::invalidComposite() " << layerset->getBodyRegion() << llendl; + // llinfos << "LLVOAvatar::invalidComposite() " << layerset->getBodyRegionName() << llendl; layerset->requestUpdate(); layerset->invalidateMorphMasks(); @@ -1342,20 +1530,35 @@ void LLVOAvatarSelf::invalidateAll() { invalidateComposite(mBakedTextureDatas[i].mTexLayerSet, TRUE); } + mDebugSelfLoadTimer.reset(); } //----------------------------------------------------------------------------- // setCompositeUpdatesEnabled() //----------------------------------------------------------------------------- -void LLVOAvatarSelf::setCompositeUpdatesEnabled( BOOL b ) +void LLVOAvatarSelf::setCompositeUpdatesEnabled( bool b ) { for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - if (mBakedTextureDatas[i].mTexLayerSet ) - { - mBakedTextureDatas[i].mTexLayerSet->setUpdatesEnabled( b ); - } + setCompositeUpdatesEnabled(i, b); + } +} + +void LLVOAvatarSelf::setCompositeUpdatesEnabled(U32 index, bool b) +{ + if (mBakedTextureDatas[index].mTexLayerSet ) + { + mBakedTextureDatas[index].mTexLayerSet->setUpdatesEnabled( b ); + } +} + +bool LLVOAvatarSelf::isCompositeUpdateEnabled(U32 index) +{ + if (mBakedTextureDatas[index].mTexLayerSet) + { + return mBakedTextureDatas[index].mTexLayerSet->getUpdatesEnabled(); } + return false; } void LLVOAvatarSelf::setupComposites() @@ -1376,7 +1579,7 @@ void LLVOAvatarSelf::updateComposites() for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { if (mBakedTextureDatas[i].mTexLayerSet - && ((i != BAKED_SKIRT) || isWearingWearableType(WT_SKIRT))) + && ((i != BAKED_SKIRT) || isWearingWearableType(LLWearableType::WT_SKIRT))) { mBakedTextureDatas[i].mTexLayerSet->updateComposite(); } @@ -1455,7 +1658,7 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te llerrs << "Tried to set local texture with invalid type: (" << (U32) type << ", " << index << ")" << llendl; return; } - EWearableType wearable_type = LLVOAvatarDictionary::getInstance()->getTEWearableType(type); + LLWearableType::EType wearable_type = LLVOAvatarDictionary::getInstance()->getTEWearableType(type); if (!gAgentWearables.getWearable(wearable_type,index)) { // no wearable is loaded, cannot set the texture. @@ -1490,18 +1693,21 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te if (tex_discard >= 0 && tex_discard <= desired_discard) { local_tex_obj->setDiscard(tex_discard); - if (isSelf() && !gAgent.cameraCustomizeAvatar()) + if (isSelf()) + { + if (gAgentAvatarp->isUsingBakedTextures()) { requestLayerSetUpdate(type); } - else if (isSelf() && gAgent.cameraCustomizeAvatar()) + else { LLVisualParamHint::requestHintUpdates(); } } + } else - { - tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type)); + { + tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type), NULL); } } tex->setMinDiscardLevel(desired_discard); @@ -1634,23 +1840,24 @@ void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture * void LLVOAvatarSelf::dumpTotalLocalTextureByteCount() { S32 gl_bytes = 0; - gAgent.getAvatarObject()->getLocalTextureByteCount(&gl_bytes); + gAgentAvatarp->getLocalTextureByteCount(&gl_bytes); llinfos << "Total Avatar LocTex GL:" << (gl_bytes/1024) << "KB" << llendl; } -BOOL LLVOAvatarSelf::updateIsFullyLoaded() +BOOL LLVOAvatarSelf::getIsCloud() { - BOOL loading = FALSE; - - // do we have a shape? - if (visualParamWeightsAreDefault()) + // do we have our body parts? + if (gAgentWearables.getWearableCount(LLWearableType::WT_SHAPE) == 0 || + gAgentWearables.getWearableCount(LLWearableType::WT_HAIR) == 0 || + gAgentWearables.getWearableCount(LLWearableType::WT_EYES) == 0 || + gAgentWearables.getWearableCount(LLWearableType::WT_SKIN) == 0) { - loading = TRUE; + return TRUE; } if (!isTextureDefined(TEX_HAIR, 0)) { - loading = TRUE; + return TRUE; } if (!mPreviousFullyLoaded) @@ -1658,111 +1865,227 @@ BOOL LLVOAvatarSelf::updateIsFullyLoaded() if (!isLocalTextureDataAvailable(mBakedTextureDatas[BAKED_LOWER].mTexLayerSet) && (!isTextureDefined(TEX_LOWER_BAKED, 0))) { - loading = TRUE; + return TRUE; } if (!isLocalTextureDataAvailable(mBakedTextureDatas[BAKED_UPPER].mTexLayerSet) && (!isTextureDefined(TEX_UPPER_BAKED, 0))) { - loading = TRUE; + return TRUE; } for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - if (i == BAKED_SKIRT && !isWearingWearableType(WT_SKIRT)) + if (i == BAKED_SKIRT && !isWearingWearableType(LLWearableType::WT_SKIRT)) continue; - BakedTextureData& texture_data = mBakedTextureDatas[i]; + const BakedTextureData& texture_data = mBakedTextureDatas[i]; 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, 0 ); + const LLViewerTexture* baked_img = getImage( texture_data.mTextureIndex, 0 ); if (!baked_img || !baked_img->hasGLTexture()) { - loading = TRUE; + return TRUE; } + } + + } + return FALSE; +} + +/*static*/ +void LLVOAvatarSelf::debugOnTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) +{ + gAgentAvatarp->debugTimingLocalTexLoaded(success, src_vi, src, aux_src, discard_level, final, userdata); +} + +void LLVOAvatarSelf::debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) +{ + LLAvatarTexData *data = (LLAvatarTexData *)userdata; + if (!data) + { + return; + } + + ETextureIndex index = data->mIndex; + + if (index < 0 || index >= TEX_NUM_INDICES) + { + return; + } + + if (discard_level >=0 && discard_level <= MAX_DISCARD_LEVEL) // ignore discard level -1, as it means we have no data. + { + mDebugTextureLoadTimes[(U32)index][(U32)discard_level] = mDebugSelfLoadTimer.getElapsedTimeF32(); + } + if (final) + { + delete data; + } +} +void LLVOAvatarSelf::debugBakedTextureUpload(EBakedTextureIndex index, BOOL finished) +{ + U32 done = 0; + if (finished) + { + done = 1; + } + mDebugBakedTextureTimes[index][done] = mDebugSelfLoadTimer.getElapsedTimeF32(); +} + +const std::string LLVOAvatarSelf::debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const +{ + std::string text=""; + + text = llformat("[Final:%d Avail:%d] ",isLocalTextureDataFinal(layerset), isLocalTextureDataAvailable(layerset)); + + /* if (layerset == mBakedTextureDatas[BAKED_HEAD].mTexLayerSet) + return getLocalDiscardLevel(TEX_HEAD_BODYPAINT) >= 0; */ + for (LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDictionary::getInstance()->getBakedTextures().begin(); + baked_iter != LLVOAvatarDictionary::getInstance()->getBakedTextures().end(); + ++baked_iter) + { + const EBakedTextureIndex baked_index = baked_iter->first; + if (layerset == mBakedTextureDatas[baked_index].mTexLayerSet) + { + const LLVOAvatarDictionary::BakedEntry *baked_dict = baked_iter->second; + text += llformat("%d-%s ( ",baked_index, baked_dict->mName.c_str()); + for (texture_vec_t::const_iterator local_tex_iter = baked_dict->mLocalTextures.begin(); + local_tex_iter != baked_dict->mLocalTextures.end(); + ++local_tex_iter) + { + const ETextureIndex tex_index = *local_tex_iter; + const LLWearableType::EType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index); + const U32 wearable_count = gAgentWearables.getWearableCount(wearable_type); + if (wearable_count > 0) + { + text += LLWearableType::getTypeName(wearable_type) + ":"; + for (U32 wearable_index = 0; wearable_index < wearable_count; wearable_index++) + { + const U32 discard_level = getLocalDiscardLevel(tex_index, wearable_index); + std::string discard_str = llformat("%d ",discard_level); + text += llformat("%d ",discard_level); + } + } + } + text += ")"; + break; } + } + return text; +} +const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const +{ + std::string text; + const U32 override_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + + for (U32 i = 0; i < mBakedTextureDatas.size(); i++) + { + const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex)i); + BOOL is_texture_final = TRUE; + for (texture_vec_t::const_iterator local_tex_iter = baked_dict->mLocalTextures.begin(); + local_tex_iter != baked_dict->mLocalTextures.end(); + ++local_tex_iter) + { + const ETextureIndex tex_index = *local_tex_iter; + const LLWearableType::EType 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++) + { + is_texture_final &= (getLocalDiscardLevel(*local_tex_iter, wearable_index) <= (S32)(override_tex_discard_level)); + } + } + text += llformat("%s:%d ",baked_dict->mName.c_str(),is_texture_final); } - return processFullyLoadedChange(loading); + return text; } -const LLUUID& LLVOAvatarSelf::grabLocalTexture(ETextureIndex type, U32 index) const +const LLUUID& LLVOAvatarSelf::grabBakedTexture(EBakedTextureIndex baked_index) const { - if (canGrabLocalTexture(type, index)) + if (canGrabBakedTexture(baked_index)) { - return getTEImage( type )->getID(); + ETextureIndex tex_index = LLVOAvatarDictionary::bakedToLocalTextureIndex(baked_index); + if (tex_index == TEX_NUM_INDICES) + { + return LLUUID::null; + } + return getTEImage( tex_index )->getID(); } return LLUUID::null; } -BOOL LLVOAvatarSelf::canGrabLocalTexture(ETextureIndex type, U32 index) const +BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const { + ETextureIndex tex_index = LLVOAvatarDictionary::bakedToLocalTextureIndex(baked_index); + if (tex_index == TEX_NUM_INDICES) + { + return FALSE; + } // Check if the texture hasn't been baked yet. - if (!isTextureDefined(type, index)) + if (!isTextureDefined(tex_index, 0)) { - lldebugs << "getTEImage( " << (U32) type << ", " << index << " )->getID() == IMG_DEFAULT_AVATAR" << llendl; + lldebugs << "getTEImage( " << (U32) tex_index << " )->getID() == IMG_DEFAULT_AVATAR" << llendl; return FALSE; } - if (gAgent.isGodlike()) + if (gAgent.isGodlikeWithoutAdminMenuFakery()) return TRUE; // Check permissions of textures that show up in the // baked texture. We don't want people copying people's // work via baked textures. - /* switch(type) - case TEX_EYES_BAKED: - textures.push_back(TEX_EYES_IRIS); */ - const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(type); - if (!texture_dict->mIsUsedByBakedTexture) return FALSE; - const EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex; const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index); for (texture_vec_t::const_iterator iter = baked_dict->mLocalTextures.begin(); iter != baked_dict->mLocalTextures.end(); ++iter) { 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) - { - // Search inventory for this texture. - LLViewerInventoryCategory::cat_array_t cats; - LLViewerInventoryItem::item_array_t items; - LLAssetIDMatches asset_id_matches(texture_id); - gInventory.collectDescendentsIf(LLUUID::null, - cats, - items, - LLInventoryModel::INCLUDE_TRASH, - asset_id_matches); - - BOOL can_grab = FALSE; - lldebugs << "item count for asset " << texture_id << ": " << items.count() << llendl; - if (items.count()) + LLWearableType::EType wearable_type = LLVOAvatarDictionary::getTEWearableType(t_index); + U32 count = gAgentWearables.getWearableCount(wearable_type); + lldebugs << "Checking index " << (U32) t_index << " count: " << count << llendl; + + for (U32 wearable_index = 0; wearable_index < count; ++wearable_index) + { + LLWearable *wearable = gAgentWearables.getWearable(wearable_type, wearable_index); + if (wearable) { - // search for full permissions version - for (S32 i = 0; i < items.count(); i++) + const LLLocalTextureObject *texture = wearable->getLocalTextureObject((S32)t_index); + const LLUUID& texture_id = texture->getID(); + if (texture_id != IMG_DEFAULT_AVATAR) { - LLInventoryItem* itemp = items[i]; - LLPermissions item_permissions = itemp->getPermissions(); - if ( item_permissions.allowOperationBy( - PERM_MODIFY, gAgent.getID(), gAgent.getGroupID()) && - item_permissions.allowOperationBy( - PERM_COPY, gAgent.getID(), gAgent.getGroupID()) && - item_permissions.allowOperationBy( - PERM_TRANSFER, gAgent.getID(), gAgent.getGroupID()) ) + // Search inventory for this texture. + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(texture_id); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + + BOOL can_grab = FALSE; + lldebugs << "item count for asset " << texture_id << ": " << items.count() << llendl; + if (items.count()) { - can_grab = TRUE; - break; + // search for full permissions version + for (S32 i = 0; i < items.count(); i++) + { + LLViewerInventoryItem* itemp = items[i]; + if (itemp->getIsFullPerm()) + { + can_grab = TRUE; + break; + } + } } + if (!can_grab) return FALSE; } } - if (!can_grab) return FALSE; } } @@ -1781,7 +2104,11 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe F32 desired_pixels; desired_pixels = llmin(mPixelArea, (F32)getTexImageArea()); imagep->setBoostLevel(getAvatarBoostLevel()); + + imagep->resetTextureStats(); + imagep->setMaxVirtualSizeResetInterval(MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL); imagep->addTextureStats( desired_pixels / texel_area_ratio ); + imagep->setAdditionalDecodePriority(SELF_ADDITIONAL_PRI) ; imagep->forceUpdateBindStats() ; if (imagep->getDiscardLevel() < 0) { @@ -1798,7 +2125,7 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe LLLocalTextureObject* LLVOAvatarSelf::getLocalTextureObject(LLVOAvatarDefines::ETextureIndex i, U32 wearable_index) const { - EWearableType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i); + LLWearableType::EType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i); LLWearable* wearable = gAgentWearables.getWearable(type, wearable_index); if (wearable) { @@ -1853,6 +2180,7 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid ) const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(te); if (texture_dict->mIsBakedTexture) { + debugBakedTextureUpload(texture_dict->mBakedTextureIndex, TRUE); // FALSE for start of upload, TRUE for finish. llinfos << "New baked texture: " << texture_dict->mName << " UUID: " << uuid <<llendl; } else @@ -1865,6 +2193,81 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid ) if (!hasPendingBakedUploads()) { gAgent.sendAgentSetAppearance(); + + if (gSavedSettings.getBOOL("DebugAvatarRezTime")) + { + LLSD args; + args["EXISTENCE"] = llformat("%d",(U32)mDebugExistenceTimer.getElapsedTimeF32()); + args["TIME"] = llformat("%d",(U32)mDebugSelfLoadTimer.getElapsedTimeF32()); + if (isAllLocalTextureDataFinal()) + { + LLNotificationsUtil::add("AvatarRezSelfBakedDoneNotification",args); + } + else + { + args["STATUS"] = debugDumpAllLocalTextureDataInfo(); + LLNotificationsUtil::add("AvatarRezSelfBakedUpdateNotification",args); + } + } + + outputRezDiagnostics(); + } +} + +void LLVOAvatarSelf::outputRezDiagnostics() const +{ + if(!gSavedSettings.getBOOL("DebugAvatarLocalTexLoadedTime")) + { + return ; + } + + const F32 final_time = mDebugSelfLoadTimer.getElapsedTimeF32(); + llinfos << "REZTIME: Myself rez stats:" << llendl; + llinfos << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << llendl; + llinfos << "\t Time from avatar creation to de-cloud: " << (S32)mDebugTimeAvatarVisible << llendl; + llinfos << "\t Time from avatar creation to de-cloud for others: " << (S32)final_time << llendl; + llinfos << "\t Load time for each texture: " << llendl; + for (U32 i = 0; i < LLVOAvatarDefines::TEX_NUM_INDICES; ++i) + { + std::stringstream out; + out << "\t\t (" << i << ") "; + U32 j=0; + for (j=0; j <= MAX_DISCARD_LEVEL; j++) + { + out << "\t"; + S32 load_time = (S32)mDebugTextureLoadTimes[i][j]; + if (load_time == -1) + { + out << "*"; + if (j == 0) + break; + } + else + { + out << load_time; + } + } + + // Don't print out non-existent textures. + if (j != 0) + llinfos << out.str() << llendl; + } + llinfos << "\t Time points for each upload (start / finish)" << llendl; + for (U32 i = 0; i < LLVOAvatarDefines::BAKED_NUM_INDICES; ++i) + { + llinfos << "\t\t (" << i << ") \t" << (S32)mDebugBakedTextureTimes[i][0] << " / " << (S32)mDebugBakedTextureTimes[i][1] << llendl; + } + + for (LLVOAvatarDefines::LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDefines::LLVOAvatarDictionary::getInstance()->getBakedTextures().begin(); + baked_iter != LLVOAvatarDefines::LLVOAvatarDictionary::getInstance()->getBakedTextures().end(); + ++baked_iter) + { + const LLVOAvatarDefines::EBakedTextureIndex baked_index = baked_iter->first; + const LLTexLayerSet *layerset = debugGetLayerSet(baked_index); + if (!layerset) continue; + const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite(); + if (!layerset_buffer) continue; + llinfos << layerset_buffer->dumpTextureInfo() << llendl; } } @@ -1894,9 +2297,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) { LLUUID texture_id; msg->getUUID("TextureData", "TextureID", texture_id); - - LLVOAvatarSelf* self = gAgent.getAvatarObject(); - if (!self) return; + if (!isAgentAvatarValid()) return; // If this is a texture corresponding to one of our baked entries, // just rebake that layer set. @@ -1913,13 +2314,13 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; if (texture_dict->mIsBakedTexture) { - if (texture_id == self->getTEImage(index)->getID()) + if (texture_id == gAgentAvatarp->getTEImage(index)->getID()) { - LLTexLayerSet* layer_set = self->getLayerSet(index); + LLTexLayerSet* layer_set = gAgentAvatarp->getLayerSet(index); if (layer_set) { llinfos << "TAT: rebake - matched entry " << (S32)index << llendl; - self->invalidateComposite(layer_set, TRUE); + gAgentAvatarp->invalidateComposite(layer_set, TRUE); found = TRUE; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } @@ -1930,15 +2331,25 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) // If texture not found, rebake all entries. if (!found) { - self->forceBakeAllTextures(); + gAgentAvatarp->forceBakeAllTextures(); } else { // Not sure if this is necessary, but forceBakeAllTextures() does it. - self->updateMeshTextures(); + gAgentAvatarp->updateMeshTextures(); } } +BOOL LLVOAvatarSelf::isUsingBakedTextures() const +{ + // Composite textures are used during appearance mode. + if (gAgentCamera.cameraCustomizeAvatar()) + return FALSE; + + return TRUE; +} + + void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug) { llinfos << "TAT: forced full rebake. " << llendl; @@ -2014,10 +2425,9 @@ void LLVOAvatarSelf::onCustomizeStart() // static void LLVOAvatarSelf::onCustomizeEnd() { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->invalidateAll(); + gAgentAvatarp->invalidateAll(); } } @@ -2186,7 +2596,6 @@ LLGLuint LLVOAvatarSelf::getScratchTexName( LLGLenum format, S32& components, U3 { case GL_LUMINANCE: components = 1; internal_format = GL_LUMINANCE8; break; case GL_ALPHA: components = 1; internal_format = GL_ALPHA8; break; - case GL_COLOR_INDEX: components = 1; internal_format = GL_COLOR_INDEX8_EXT; break; case GL_LUMINANCE_ALPHA: components = 2; internal_format = GL_LUMINANCE8_ALPHA8; break; case GL_RGB: components = 3; internal_format = GL_RGB8; break; case GL_RGBA: components = 4; internal_format = GL_RGBA8; break; |