diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llviewertexlayer.cpp | 280 | ||||
-rw-r--r-- | indra/newview/llviewertexlayer.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewerwearable.cpp | 134 | ||||
-rw-r--r-- | indra/newview/llviewerwearable.h | 14 | ||||
-rwxr-xr-x | indra/newview/llvoavatar.cpp | 1 | ||||
-rwxr-xr-x | indra/newview/llvoavatar.h | 3 |
6 files changed, 231 insertions, 203 deletions
diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index f805083aaa..3a3cae4047 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -26,19 +26,19 @@ #include "llviewerprecompiledheaders.h" +#include "llviewertexlayer.h" + #include "llagent.h" -#include "llassetuploadresponders.h" -#include "llavatarappearance.h" -#include "llglslshader.h" #include "llimagej2c.h" #include "llnotificationsutil.h" -#include "llviewercontrol.h" -#include "llviewerregion.h" -#include "llviewertexlayer.h" #include "llvfile.h" #include "llvfs.h" +#include "llviewerregion.h" +#include "llglslshader.h" #include "llvoavatarself.h" #include "pipeline.h" +#include "llassetuploadresponders.h" +#include "llviewercontrol.h" static const S32 BAKE_UPLOAD_ATTEMPTS = 7; static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power of 2 each attempt @@ -46,126 +46,6 @@ static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power o // runway consolidate extern std::string self_av_string(); -LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : - LLTexLayerSet(appearance), - mComposite( NULL ), - mUpdatesEnabled( FALSE ) -{ -} - -// virtual -LLViewerTexLayerSet::~LLViewerTexLayerSet() -{ -} - -void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) -{ - memset(data, 255, width * height); - - for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height); - } - - // Set alpha back to that of our alpha masks. - renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true); -} - -LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() -{ - if (!mComposite) - { - createComposite(); - } - return mComposite; -} - -const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const -{ - return mComposite; -} - -// virtual -void LLViewerTexLayerSet::requestUpdate() -{ - if( mUpdatesEnabled ) - { - createComposite(); - mComposite->requestUpdate(); - } -} - -void LLViewerTexLayerSet::requestUpload() -{ - createComposite(); - mComposite->requestUpload(); -} - -void LLViewerTexLayerSet::cancelUpload() -{ - if(mComposite) - { - mComposite->cancelUpload(); - } -} - - -void LLViewerTexLayerSet::createComposite() -{ - if(!mComposite) - { - S32 width = mInfo->getWidth(); - S32 height = mInfo->getHeight(); - // Composite other avatars at reduced resolution - if( !mAvatarAppearance->isSelf() ) - { - llerrs << "composites should not be created for non-self avatars!" << llendl; - } - mComposite = new LLTexLayerSetBuffer( this, width, height ); - } -} - -void LLViewerTexLayerSet::updateComposite() -{ - createComposite(); - mComposite->requestUpdateImmediate(); -} - -// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on. -BOOL LLViewerTexLayerSet::isLocalTextureDataAvailable() const -{ - if (!mAvatarAppearance->isSelf()) return FALSE; - LLVOAvatarSelf* self = dynamic_cast<LLVOAvatarSelf *>(mAvatarAppearance); - return self->isLocalTextureDataAvailable(this); -} - - -// Returns TRUE if all of the data for the textures that this layerset depends on have arrived. -BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const -{ - if (!mAvatarAppearance->isSelf()) return FALSE; - LLVOAvatarSelf* self = dynamic_cast<LLVOAvatarSelf *>(mAvatarAppearance); - return self->isLocalTextureDataFinal(this); -} - -void LLViewerTexLayerSet::destroyComposite() -{ - if( mComposite ) - { - mComposite = NULL; - } -} - -void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) -{ - mUpdatesEnabled = b; -} - -LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const -{ - return dynamic_cast<LLVOAvatarSelf*> (mAvatarAppearance); -} //----------------------------------------------------------------------------- // LLBakedUploadData() @@ -693,7 +573,7 @@ void LLTexLayerSetBuffer::doUpdate() // need to switch to using this layerset if this is the first update // after getting the lowest LOD - mTexLayerSet->getAvatarAppearance()->updateMeshTextures(); + mTexLayerSet->getAvatar()->updateMeshTextures(); // Print out notification that we updated this texture. if (gSavedSettings.getBOOL("DebugAvatarRezTime")) @@ -701,7 +581,7 @@ void LLTexLayerSetBuffer::doUpdate() const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal(); const std::string lod_str = highest_lod ? "HighRes" : "LowRes"; LLSD args; - args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatarAppearance()->debugGetExistenceTimeElapsedF32()); + args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32()); args["TIME"] = llformat("%d",(U32)mNeedsUpdateTimer.getElapsedTimeF32()); args["BODYREGION"] = mTexLayerSet->getBodyRegionName(); args["RESOLUTION"] = lod_str; @@ -786,6 +666,150 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, delete baked_upload_data; } +//----------------------------------------------------------------------------- +// LLViewerTexLayerSet +// An ordered set of texture layers that get composited into a single texture. +//----------------------------------------------------------------------------- + +LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : + LLTexLayerSet(appearance), + mComposite( NULL ), + mUpdatesEnabled( FALSE ) +{ +} + +// virtual +LLViewerTexLayerSet::~LLViewerTexLayerSet() +{ +} + +// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on. +BOOL LLViewerTexLayerSet::isLocalTextureDataAvailable() const +{ + if (!mAvatarAppearance->isSelf()) return FALSE; + return getAvatar()->isLocalTextureDataAvailable(this); +} + + +// Returns TRUE if all of the data for the textures that this layerset depends on have arrived. +BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const +{ + if (!mAvatarAppearance->isSelf()) return FALSE; + return getAvatar()->isLocalTextureDataFinal(this); +} + +// virtual +void LLViewerTexLayerSet::requestUpdate() +{ + if( mUpdatesEnabled ) + { + createComposite(); + mComposite->requestUpdate(); + } +} + +void LLViewerTexLayerSet::requestUpload() +{ + createComposite(); + mComposite->requestUpload(); +} + +void LLViewerTexLayerSet::cancelUpload() +{ + if(mComposite) + { + mComposite->cancelUpload(); + } +} + +void LLViewerTexLayerSet::createComposite() +{ + if(!mComposite) + { + S32 width = mInfo->getWidth(); + S32 height = mInfo->getHeight(); + // Composite other avatars at reduced resolution + if( !mAvatarAppearance->isSelf() ) + { + llerrs << "composites should not be created for non-self avatars!" << llendl; + } + mComposite = new LLTexLayerSetBuffer( this, width, height ); + } +} + +void LLViewerTexLayerSet::destroyComposite() +{ + if( mComposite ) + { + mComposite = NULL; + } +} + +void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) +{ + mUpdatesEnabled = b; +} + +void LLViewerTexLayerSet::updateComposite() +{ + createComposite(); + mComposite->requestUpdateImmediate(); +} +LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() +{ + if (!mComposite) + { + createComposite(); + } + return mComposite; +} +const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const +{ + return mComposite; +} + +void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) +{ + memset(data, 255, width * height); + + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height); + } + + // Set alpha back to that of our alpha masks. + renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true); +} + + +LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const +{ + return dynamic_cast<LLVOAvatarSelf*> (mAvatarAppearance); +} + + + +const std::string LLTexLayerSetBuffer::dumpTextureInfo() const +{ + if (!isAgentAvatarValid()) return ""; + + const BOOL is_high_res = !mNeedsUpload; + const U32 num_low_res = mNumLowresUploads; + const U32 upload_time = (U32)mNeedsUploadTimer.getElapsedTimeF32(); + const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(mTexLayerSet); + + std::string status = "CREATING "; + if (!uploadNeeded()) status = "DONE "; + if (uploadInProgress()) status = "UPLOADING"; + + std::string text = llformat("[%s] [HiRes:%d LoRes:%d] [Elapsed:%d] %s", + status.c_str(), + is_high_res, num_low_res, + upload_time, + local_texture_info.c_str()); + return text; +} diff --git a/indra/newview/llviewertexlayer.h b/indra/newview/llviewertexlayer.h index ff3def5a82..125bf82adf 100644 --- a/indra/newview/llviewertexlayer.h +++ b/indra/newview/llviewertexlayer.h @@ -30,8 +30,8 @@ #include "lldynamictexture.h" #include "lltexlayer.h" -class LLTexLayerSetBuffer; class LLVOAvatarSelf; +class LLTexLayerSetBuffer; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLViewerTexLayerSet diff --git a/indra/newview/llviewerwearable.cpp b/indra/newview/llviewerwearable.cpp index b63f1f57cb..2b6649a7ec 100644 --- a/indra/newview/llviewerwearable.cpp +++ b/indra/newview/llviewerwearable.cpp @@ -33,11 +33,11 @@ #include "llnotificationsutil.h" #include "llsidepanelappearance.h" #include "lltextureentry.h" -#include "llviewercontrol.h" #include "llviewertexlayer.h" -#include "llviewerwearable.h" #include "llvoavatarself.h" #include "llvoavatardefines.h" +#include "llviewerwearable.h" +#include "llviewercontrol.h" using namespace LLVOAvatarDefines; @@ -89,11 +89,6 @@ LLViewerWearable::~LLViewerWearable() { } -void LLViewerWearable::setItemID(const LLUUID& item_id) -{ - mItemID = item_id; -} - // virtual BOOL LLViewerWearable::exportFile(LLFILE* file) const { @@ -107,6 +102,40 @@ BOOL LLViewerWearable::exportFile(LLFILE* file) const return LLWearable::exportFile(file); } + +void LLViewerWearable::createVisualParams() +{ + for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); + param; + param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam()) + { + if (param->getWearableType() == mType) + { + addVisualParam(param->cloneParam(this)); + } + } + + // resync driver parameters to point to the newly cloned driven parameters + for (visual_param_index_map_t::iterator param_iter = mVisualParamIndexMap.begin(); + param_iter != mVisualParamIndexMap.end(); + ++param_iter) + { + LLVisualParam* param = param_iter->second; + LLVisualParam*(LLWearable::*wearable_function)(S32)const = &LLWearable::getVisualParam; + // need this line to disambiguate between versions of LLCharacter::getVisualParam() + LLVisualParam*(LLAvatarAppearance::*param_function)(S32)const = &LLAvatarAppearance::getVisualParam; + param->resetDrivenParams(); + if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false)) + { + if( !param->linkDrivenParams(boost::bind(param_function,gAgentAvatarp.get(),_1 ), true)) + { + llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl; + continue; + } + } + } +} + // virtual LLWearable::EImportResult LLViewerWearable::importFile( LLFILE* file ) { @@ -159,6 +188,7 @@ LLWearable::EImportResult LLViewerWearable::importFile( LLFILE* file ) return result; } + // Avatar parameter and texture definitions can change over time. // This function returns true if parameters or textures have been added or removed // since this wearable was created. @@ -492,6 +522,11 @@ void LLViewerWearable::copyDataFrom(const LLViewerWearable* src) revertValues(); } +void LLViewerWearable::setItemID(const LLUUID& item_id) +{ + mItemID = item_id; +} + LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index) { @@ -538,6 +573,17 @@ void LLViewerWearable::setLocalTextureObject(S32 index, LLLocalTextureObject < mTEMap[index] = new LLLocalTextureObject(lto); } +void LLViewerWearable::setVisualParams() +{ + for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++) + { + S32 id = iter->first; + LLVisualParam *wearable_param = iter->second; + F32 value = wearable_param->getWeight(); + gAgentAvatarp->setVisualParamWeight(id, value, FALSE); + } +} + void LLViewerWearable::revertValues() { //update saved settings so wearable is no longer dirty @@ -591,6 +637,19 @@ BOOL LLViewerWearable::isOnTop() const return (this == gAgentWearables.getTopWearable(mType)); } +void LLViewerWearable::createLayers(S32 te) +{ + LLViewerTexLayerSet *layer_set = gAgentAvatarp->getLayerSet((ETextureIndex)te); + if (layer_set) + { + layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this); + } + else + { + llerrs << "could not find layerset for LTO in wearable!" << llendl; + } +} + void LLViewerWearable::saveValues() { //update saved settings so wearable is no longer dirty @@ -702,7 +761,6 @@ void LLViewerWearable::setLabelUpdated() const gInventory.addChangedMask(LLInventoryObserver::LABEL, getItemID()); } - void LLViewerWearable::refreshName() { LLUUID item_id = getItemID(); @@ -802,65 +860,6 @@ void LLViewerWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* } -void LLViewerWearable::createLayers(S32 te) -{ - LLViewerTexLayerSet *layer_set = gAgentAvatarp->getLayerSet((ETextureIndex)te); - if (layer_set) - { - layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this); - } - else - { - llerrs << "could not find layerset for LTO in wearable!" << llendl; - } -} - -void LLViewerWearable::createVisualParams() -{ - for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); - param; - param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam()) - { - if (param->getWearableType() == mType) - { - addVisualParam(param->cloneParam(this)); - } - } - - // resync driver parameters to point to the newly cloned driven parameters - for (visual_param_index_map_t::iterator param_iter = mVisualParamIndexMap.begin(); - param_iter != mVisualParamIndexMap.end(); - ++param_iter) - { - LLVisualParam* param = param_iter->second; - LLVisualParam*(LLWearable::*wearable_function)(S32)const = &LLWearable::getVisualParam; - // need this line to disambiguate between versions of LLCharacter::getVisualParam() - LLVisualParam*(LLAvatarAppearance::*param_function)(S32)const = &LLAvatarAppearance::getVisualParam; - param->resetDrivenParams(); - if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false)) - { - if( !param->linkDrivenParams(boost::bind(param_function,gAgentAvatarp.get(),_1 ), true)) - { - llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl; - continue; - } - } - } -} - -void LLViewerWearable::setVisualParams() -{ - for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++) - { - S32 id = iter->first; - LLVisualParam *wearable_param = iter->second; - F32 value = wearable_param->getWeight(); - gAgentAvatarp->setVisualParamWeight(id, value, FALSE); - } -} - - - std::ostream& operator<<(std::ostream &s, const LLViewerWearable &w) { s << "wearable " << LLWearableType::getTypeName(w.mType) << "\n"; @@ -897,4 +896,3 @@ std::string asset_id_to_filename(const LLUUID &asset_id) std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id_string) + ".wbl"; return filename; } - diff --git a/indra/newview/llviewerwearable.h b/indra/newview/llviewerwearable.h index 857900f583..a921f82e7d 100644 --- a/indra/newview/llviewerwearable.h +++ b/indra/newview/llviewerwearable.h @@ -54,8 +54,6 @@ public: void setItemID(const LLUUID& item_id); public: - /*virtual*/ BOOL exportFile(LLFILE* file) const; - /*virtual*/ EImportResult importFile(LLFILE* file); BOOL isDirty() const; BOOL isOldVersion() const; @@ -64,6 +62,9 @@ public: void removeFromAvatar( BOOL upload_bake ) { LLViewerWearable::removeFromAvatar( mType, upload_bake ); } static void removeFromAvatar( LLWearableType::EType type, BOOL upload_bake ); + /*virtual*/ BOOL exportFile(LLFILE* file) const; + /*virtual*/ EImportResult importFile(LLFILE* file); + void setParamsToDefaults(); void setTexturesToDefaults(); @@ -81,6 +82,7 @@ public: const LLLocalTextureObject* getLocalTextureObject(S32 index) const; std::vector<LLLocalTextureObject*> getLocalTextureListSeq(); void setLocalTextureObject(S32 index, LLLocalTextureObject <o); + void setVisualParams(); void revertValues(); void saveValues(); @@ -96,19 +98,19 @@ public: void refreshName(); protected: + typedef std::map<S32, LLLocalTextureObject*> te_map_t; + void createLayers(S32 te); /*virtual*/void createVisualParams(); - void setVisualParams(); - typedef std::map<S32, LLLocalTextureObject*> te_map_t; void syncImages(te_map_t &src, te_map_t &dst); void destroyTextures(); - LLTransactionID mTransactionID; LLAssetID mAssetID; - LLUUID mItemID; // ID of the inventory item in the agent's inventory + LLTransactionID mTransactionID; te_map_t mTEMap; // maps TE to LocalTextureObject te_map_t mSavedTEMap; // last saved version of TEMap + LLUUID mItemID; // ID of the inventory item in the agent's inventory }; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index dac479b2e0..e3d8f9135e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -764,6 +764,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mRuthTimer.reset(); mRuthDebugTimer.reset(); + mDebugExistenceTimer.reset(); mPelvisOffset = LLVector3(0.0f,0.0f,0.0f); mLastPelvisToFoot = 0.0f; mPelvisFixup = 0.0f; diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 023711d81b..512522803a 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -1038,9 +1038,12 @@ private: //-------------------------------------------------------------------- public: void debugAvatarRezTime(std::string notification_name, std::string comment = ""); + F32 debugGetExistenceTimeElapsedF32() const { return mDebugExistenceTimer.getElapsedTimeF32(); } + protected: LLFrameTimer mRuthDebugTimer; // For tracking how long it takes for av to rez + LLFrameTimer mDebugExistenceTimer; // Debugging for how long the avatar has been in memory. /** Diagnostics ** ** |