diff --git a/indra/llappearance/CMakeLists.txt b/indra/llappearance/CMakeLists.txt index 89375f1d4..747c3bf01 100644 --- a/indra/llappearance/CMakeLists.txt +++ b/indra/llappearance/CMakeLists.txt @@ -28,11 +28,11 @@ include_directories( ) set(llappearance_SOURCE_FILES - #llavatarappearance.cpp + llavatarappearance.cpp llavatarjoint.cpp llavatarjointmesh.cpp - #lldriverparam.cpp - #lllocaltextureobject.cpp + lldriverparam.cpp + lllocaltextureobject.cpp llpolyskeletaldistortion.cpp llpolymesh.cpp llpolymorph.cpp @@ -41,7 +41,7 @@ set(llappearance_SOURCE_FILES lltexlayerparams.cpp lltexturemanagerbridge.cpp #llwearable.cpp - #llwearabledata.cpp + llwearabledata.cpp llwearabletype.cpp llviewervisualparam.cpp llavatarappearancedefines.cpp @@ -53,9 +53,9 @@ set(llappearance_HEADER_FILES llavatarappearance.h llavatarjoint.h llavatarjointmesh.h - #lldriverparam.h + lldriverparam.h lljointpickname.h - #lllocaltextureobject.h + lllocaltextureobject.h llpolyskeletaldistortion.h llpolymesh.h llpolymorph.h @@ -64,7 +64,7 @@ set(llappearance_HEADER_FILES lltexlayerparams.h lltexturemanagerbridge.h #llwearable.h - #llwearabledata.h + llwearabledata.h llwearabletype.h llviewervisualparam.h llavatarappearancedefines.h diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp new file mode 100644 index 000000000..254c2f8a9 --- /dev/null +++ b/indra/llappearance/llavatarappearance.cpp @@ -0,0 +1,9 @@ +#include "linden_common.h" +#include "llavatarappearance.h" + +const LLColor4 DUMMY_COLOR = LLColor4(0.5,0.5,0.5,1.0); +// static +LLColor4 LLAvatarAppearance::getDummyColor() +{ + return DUMMY_COLOR; +} \ No newline at end of file diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h index c7b9d0b8c..ef44ffe63 100644 --- a/indra/llappearance/llavatarappearance.h +++ b/indra/llappearance/llavatarappearance.h @@ -30,7 +30,7 @@ #include "llcharacter.h" #include "llavatarappearancedefines.h" #include "llavatarjointmesh.h" -//#include "lldriverparam.h" +#include "lldriverparam.h" #include "lltexlayer.h" #include "llviewervisualparam.h" #include "llxmltree.h" @@ -61,12 +61,12 @@ protected: ** ** ** INITIALIZATION **/ -public: +private: // Hide default constructor. LLAvatarAppearance() {} -//public: -// LLAvatarAppearance(LLWearableData* wearable_data) {}; +public: + LLAvatarAppearance(LLWearableData* wearable_data) : mIsDummy(FALSE), mWearableData(wearable_data) {}; virtual ~LLAvatarAppearance() {} virtual BOOL loadSkeletonNode() = 0; @@ -209,7 +209,7 @@ protected: ** RENDERING **/ public: - //BOOL mIsDummy; // for special views + BOOL mIsDummy; // for special views //-------------------------------------------------------------------- // Morph masks @@ -281,7 +281,7 @@ protected: // Visibility //-------------------------------------------------------------------- public: - //static LLColor4 getDummyColor(); + static LLColor4 getDummyColor(); /** Appearance ** ** *******************************************************************************/ @@ -292,13 +292,13 @@ public: **/ public: - //LLWearableData* getWearableData() { return mWearableData; } - //const LLWearableData* getWearableData() const { return mWearableData; } + LLWearableData* getWearableData() { return mWearableData; } + const LLWearableData* getWearableData() const { return mWearableData; } virtual BOOL isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex te, U32 index = 0 ) const = 0; virtual BOOL isWearingWearableType(LLWearableType::EType type ) const = 0; private: - //LLWearableData* mWearableData; + LLWearableData* mWearableData; /******************************************************************************** ** ** diff --git a/indra/llappearance/llavatarappearancedefines.cpp b/indra/llappearance/llavatarappearancedefines.cpp index 8efc93495..f1c78946a 100644 --- a/indra/llappearance/llavatarappearancedefines.cpp +++ b/indra/llappearance/llavatarappearancedefines.cpp @@ -1,6 +1,6 @@ /** - * @file llvoavatar.cpp - * @brief Implementation of LLVOAvatar class which is a derivation fo LLViewerObject + * @file llavatarappearancedefines.cpp + * @brief Implementation of LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code @@ -35,7 +35,6 @@ using namespace LLAvatarAppearanceDefines; /********************************************************************************* * Edit this function to add/remove/change textures and mesh definitions for avatars. - * If these are changed, they MUST be changed in floater_avatar_textures.xml as well! */ LLAvatarAppearanceDictionary::Textures::Textures() @@ -160,11 +159,11 @@ void LLAvatarAppearanceDictionary::createAssociations() } -LLAvatarAppearanceDictionary::TextureEntry::TextureEntry(const std::string &name, - bool is_local_texture, - EBakedTextureIndex baked_texture_index, - const std::string &default_image_name, - LLWearableType::EType wearable_type) : +LLAvatarAppearanceDictionary::TextureEntry::TextureEntry(const std::string &name, + bool is_local_texture, + EBakedTextureIndex baked_texture_index, + const std::string &default_image_name, + LLWearableType::EType wearable_type) : LLDictionaryEntry(name), mIsLocalTexture(is_local_texture), mIsBakedTexture(!is_local_texture), @@ -221,7 +220,7 @@ ETextureIndex LLAvatarAppearanceDictionary::bakedToLocalTextureIndex(EBakedTextu return LLAvatarAppearanceDictionary::getInstance()->getBakedTexture(index)->mTextureIndex; } -//static +// static EBakedTextureIndex LLAvatarAppearanceDictionary::findBakedByRegionName(std::string name) { U8 index = 0; @@ -266,3 +265,4 @@ LLWearableType::EType LLAvatarAppearanceDictionary::getTEWearableType(ETextureIn { return getInstance()->getTexture(index)->mWearableType; } + diff --git a/indra/llappearance/llavatarappearancedefines.h b/indra/llappearance/llavatarappearancedefines.h index a61acea3d..496f85c10 100644 --- a/indra/llappearance/llavatarappearancedefines.h +++ b/indra/llappearance/llavatarappearancedefines.h @@ -1,6 +1,6 @@ /** - * @file llvoavatar.h - * @brief Declaration of LLVOAvatar class which is a derivation fo + * @file llavatarappearancedefines.h + * @brief Various LLAvatarAppearance related definitions * LLViewerObject * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ @@ -42,7 +42,7 @@ extern const S32 SCRATCH_TEX_HEIGHT; extern const S32 IMPOSTOR_PERIOD; //-------------------------------------------------------------------- -// texture entry assignment +// Enums //-------------------------------------------------------------------- enum ETextureIndex { @@ -55,9 +55,9 @@ enum ETextureIndex TEX_UPPER_BODYPAINT, TEX_LOWER_BODYPAINT, TEX_LOWER_SHOES, - TEX_HEAD_BAKED, // Pre-composited - TEX_UPPER_BAKED, // Pre-composited - TEX_LOWER_BAKED, // Pre-composited + TEX_HEAD_BAKED, // Pre-composited + TEX_UPPER_BAKED, // Pre-composited + TEX_LOWER_BAKED, // Pre-composited TEX_EYES_BAKED, // Pre-composited TEX_LOWER_SOCKS, TEX_UPPER_JACKET, @@ -66,7 +66,7 @@ enum ETextureIndex TEX_UPPER_UNDERSHIRT, TEX_LOWER_UNDERPANTS, TEX_SKIRT, - TEX_SKIRT_BAKED, // Pre-composited + TEX_SKIRT_BAKED, // Pre-composited TEX_HAIR_BAKED, // Pre-composited TEX_LOWER_ALPHA, TEX_UPPER_ALPHA, @@ -77,7 +77,7 @@ enum ETextureIndex TEX_UPPER_TATTOO, TEX_LOWER_TATTOO, TEX_NUM_INDICES -}; +}; enum EBakedTextureIndex { @@ -137,19 +137,19 @@ private: public: struct TextureEntry : public LLDictionaryEntry { - TextureEntry(const std::string &name, - bool is_local_texture, - EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES, - const std::string &default_image_name = "", + TextureEntry(const std::string &name, // this must match the xml name used by LLTexLayerInfo::parseXml + bool is_local_texture, + EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES, + const std::string& default_image_name = "", LLWearableType::EType wearable_type = LLWearableType::WT_INVALID); - const std::string mDefaultImageName; + const std::string mDefaultImageName; const LLWearableType::EType mWearableType; // It's either a local texture xor baked - BOOL mIsLocalTexture; - BOOL mIsBakedTexture; + BOOL mIsLocalTexture; + BOOL mIsBakedTexture; // If it's a local texture, it may be used by a baked texture - BOOL mIsUsedByBakedTexture; - EBakedTextureIndex mBakedTextureIndex; + BOOL mIsUsedByBakedTexture; + EBakedTextureIndex mBakedTextureIndex; }; struct Textures : public LLDictionary @@ -200,7 +200,7 @@ public: const LLUUID mWearablesHashID; wearables_vec_t mWearables; }; - + struct BakedTextures: public LLDictionary { BakedTextures(); diff --git a/indra/llappearance/llavatarjoint.cpp b/indra/llappearance/llavatarjoint.cpp index 1b8978a49..6ab341af6 100644 --- a/indra/llappearance/llavatarjoint.cpp +++ b/indra/llappearance/llavatarjoint.cpp @@ -223,7 +223,7 @@ void LLAvatarJoint::setMeshesToChildren() for (avatar_joint_mesh_list_t::iterator iter = mMeshParts.begin(); iter != mMeshParts.end(); iter++) { - addChild((LLJoint*)(*iter)); + addChild((*iter)); } } //----------------------------------------------------------------------------- diff --git a/indra/newview/lldriverparam.cpp b/indra/llappearance/lldriverparam.cpp similarity index 88% rename from indra/newview/lldriverparam.cpp rename to indra/llappearance/lldriverparam.cpp index a1cba861c..a6d3e28d0 100644 --- a/indra/newview/lldriverparam.cpp +++ b/indra/llappearance/lldriverparam.cpp @@ -24,22 +24,20 @@ * $/LicenseInfo$ */ -#include "llviewerprecompiledheaders.h" +#include "linden_common.h" #include "lldriverparam.h" -#include "llfasttimer.h" -#include "llvoavatar.h" -#include "llvoavatarself.h" -#include "llagent.h" +#include "llavatarappearance.h" #include "llwearable.h" -#include "llagentwearables.h" +#include "llwearabledata.h" //----------------------------------------------------------------------------- // LLDriverParamInfo //----------------------------------------------------------------------------- -LLDriverParamInfo::LLDriverParamInfo() +LLDriverParamInfo::LLDriverParamInfo() : + mDriverParam(NULL) { } @@ -112,12 +110,14 @@ void LLDriverParamInfo::toStream(std::ostream &out) out << std::endl; - if(isAgentAvatarValid()) + if(mDriverParam && mDriverParam->getAvatarAppearance()->isSelf() && + mDriverParam->getAvatarAppearance()->isAgent()) { for (entry_info_list_t::iterator iter = mDrivenInfoList.begin(); iter != mDrivenInfoList.end(); iter++) { LLDrivenEntryInfo driven = *iter; - LLViewerVisualParam *param = (LLViewerVisualParam*)gAgentAvatarp->getVisualParam(driven.mDrivenID); + LLViewerVisualParam *param = + (LLViewerVisualParam*)mDriverParam->getAvatarAppearance()->getVisualParam(driven.mDrivenID); if (param) { param->getInfo()->toStream(out); @@ -139,7 +139,9 @@ void LLDriverParamInfo::toStream(std::ostream &out) } else { - llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatarp.get() << " for driver parameter " << getID() << llendl; + llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " + << mDriverParam->getAvatarAppearance() + << " for driver parameter " << getID() << llendl; } out << std::endl; } @@ -150,19 +152,16 @@ void LLDriverParamInfo::toStream(std::ostream &out) // LLDriverParam //----------------------------------------------------------------------------- -LLDriverParam::LLDriverParam(LLVOAvatar *avatarp) : +LLDriverParam::LLDriverParam(LLAvatarAppearance *appearance, LLWearable* wearable /* = NULL */) : mCurrentDistortionParam( NULL ), - mAvatarp(avatarp), - mWearablep(NULL) -{ - mDefaultVec.clear(); -} - -LLDriverParam::LLDriverParam(LLWearable *wearablep) : - mCurrentDistortionParam( NULL ), - mAvatarp(NULL), - mWearablep(wearablep) + mAvatarAppearance(appearance), + mWearablep(wearable) { + llassert(mAvatarAppearance); + if (mWearablep) + { + llassert(mAvatarAppearance->isSelf()); + } mDefaultVec.clear(); } @@ -177,49 +176,22 @@ BOOL LLDriverParam::setInfo(LLDriverParamInfo *info) return FALSE; mInfo = info; mID = info->mID; + info->mDriverParam = this; setWeight(getDefaultWeight(), FALSE ); return TRUE; } -void LLDriverParam::setWearable(LLWearable *wearablep) -{ - if (wearablep) - { - mWearablep = wearablep; - mAvatarp = NULL; - } -} - -void LLDriverParam::setAvatar(LLVOAvatar *avatarp) -{ - if (avatarp) - { - mWearablep = NULL; - mAvatarp = avatarp; - } -} - /*virtual*/ LLViewerVisualParam* LLDriverParam::cloneParam(LLWearable* wearable) const { - LLDriverParam *new_param; - if (wearable) - { - new_param = new LLDriverParam(wearable); - } - else - { - if (mWearablep) - { - new_param = new LLDriverParam(mWearablep); - } - else - { - new_param = new LLDriverParam(mAvatarp); - } - } + llassert(wearable); + LLDriverParam *new_param = new LLDriverParam(mAvatarAppearance, wearable); + // FIXME DRANO this clobbers mWearablep, which means any code + // currently using mWearablep is wrong, or at least untested. *new_param = *this; + //new_param->mWearablep = wearable; +// new_param->mDriven.clear(); // clear driven list to avoid overwriting avatar driven params from wearables. return new_param; } @@ -456,6 +428,20 @@ const LLVector4a* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly return v; }; +S32 LLDriverParam::getDrivenParamsCount() const +{ + return mDriven.size(); +} + +const LLViewerVisualParam* LLDriverParam::getDrivenParam(S32 index) const +{ + if (0 > index || index >= (S32)mDriven.size()) + { + return NULL; + } + return mDriven[index].mParam; +} + //----------------------------------------------------------------------------- // setAnimationTarget() //----------------------------------------------------------------------------- @@ -511,6 +497,7 @@ BOOL LLDriverParam::linkDrivenParams(visual_param_mapper mapper, BOOL only_cross if (!found) { LLViewerVisualParam* param = (LLViewerVisualParam*)mapper(driven_id); + if (param) param->setParamLocation(this->getParamLocation()); bool push = param && (!only_cross_params || param->getCrossWearable()); if (push) { @@ -555,7 +542,7 @@ void LLDriverParam::updateCrossDrivenParams(LLWearableType::EType driven_type) // Thus this wearable needs to get updates from the driver wearable. // The call to setVisualParamWeight seems redundant, but is necessary // as the number of driven wearables has changed since the last update. -Nyx - LLWearable *wearable = gAgentWearables.getTopWearable(driver_type); + LLWearable *wearable = mAvatarAppearance->getWearableData()->getTopWearable(driver_type); if (wearable) { wearable->setVisualParamWeight(mID, wearable->getVisualParamWeight(mID), false); @@ -623,13 +610,22 @@ F32 LLDriverParam::getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake) { - if(isAgentAvatarValid() && - mWearablep && - driven->mParam->getCrossWearable() && - mWearablep->isOnTop()) + bool use_self = false; + if(mWearablep && + mAvatarAppearance->isAgent() && + driven->mParam->getCrossWearable()) + { + LLWearable* wearable = dynamic_cast (mWearablep); + if (mAvatarAppearance->getWearableData()->isOnTop(wearable)) + { + use_self = true; + } + } + + if (use_self) { // call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values - gAgentAvatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); + mAvatarAppearance->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); } else { diff --git a/indra/newview/lldriverparam.h b/indra/llappearance/lldriverparam.h similarity index 87% rename from indra/newview/lldriverparam.h rename to indra/llappearance/lldriverparam.h index c0976d1d4..1a24cefa1 100644 --- a/indra/newview/lldriverparam.h +++ b/indra/llappearance/lldriverparam.h @@ -30,8 +30,8 @@ #include "llviewervisualparam.h" #include "llwearabletype.h" -class LLPhysicsMotion; -class LLVOAvatar; +class LLAvatarAppearance; +class LLDriverParam; class LLWearable; //----------------------------------------------------------------------------- @@ -71,16 +71,19 @@ public: protected: typedef std::deque entry_info_list_t; entry_info_list_t mDrivenInfoList; + LLDriverParam* mDriverParam; // backpointer }; //----------------------------------------------------------------------------- class LLDriverParam : public LLViewerVisualParam { - friend class LLPhysicsMotion; // physics motion needs to access driven params directly. + friend class LLPhysicsMotion; +private: + // Hide the default constructor. Force construction with LLAvatarAppearance. + LLDriverParam() {} public: - LLDriverParam(LLVOAvatar *avatarp); - LLDriverParam(LLWearable *wearablep); + LLDriverParam(LLAvatarAppearance *appearance, LLWearable* wearable = NULL); ~LLDriverParam(); void* operator new(size_t size) @@ -98,8 +101,9 @@ public: // This sets mInfo and calls initialization functions BOOL setInfo(LLDriverParamInfo *info); - void setWearable(LLWearable *wearablep); - void setAvatar(LLVOAvatar *avatarp); + LLAvatarAppearance* getAvatarAppearance() { return mAvatarAppearance; } + const LLAvatarAppearance* getAvatarAppearance() const { return mAvatarAppearance; } + void updateCrossDrivenParams(LLWearableType::EType driven_type); /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const; @@ -121,6 +125,9 @@ public: /*virtual*/ const LLVector4a* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh); /*virtual*/ const LLVector4a* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh); + S32 getDrivenParamsCount() const; + const LLViewerVisualParam* getDrivenParam(S32 index) const; + protected: F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight); void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake); @@ -131,7 +138,7 @@ protected: entry_list_t mDriven; LLViewerVisualParam* mCurrentDistortionParam; // Backlink only; don't make this an LLPointer. - LLVOAvatar* mAvatarp; + LLAvatarAppearance* mAvatarAppearance; LLWearable* mWearablep; }; diff --git a/indra/newview/lllocaltextureobject.cpp b/indra/llappearance/lllocaltextureobject.cpp similarity index 92% rename from indra/newview/lllocaltextureobject.cpp rename to indra/llappearance/lllocaltextureobject.cpp index 5ceb57c27..7e36a0679 100644 --- a/indra/newview/lllocaltextureobject.cpp +++ b/indra/llappearance/lllocaltextureobject.cpp @@ -23,13 +23,14 @@ * $/LicenseInfo$ */ -#include "llviewerprecompiledheaders.h" +#include "linden_common.h" #include "lllocaltextureobject.h" -#include "llviewertexlayer.h" -#include "llviewertexture.h" -#include "lltextureentry.h" +#include "llimage.h" +#include "llrender.h" +#include "lltexlayer.h" +#include "llgltexture.h" #include "lluuid.h" #include "llwearable.h" @@ -41,7 +42,7 @@ LLLocalTextureObject::LLLocalTextureObject() : mImage = NULL; } -LLLocalTextureObject::LLLocalTextureObject(LLViewerFetchedTexture* image, const LLUUID& id) : +LLLocalTextureObject::LLLocalTextureObject(LLGLTexture* image, const LLUUID& id) : mIsBakedReady(FALSE), mDiscard(MAX_DISCARD_LEVEL+1) { @@ -77,7 +78,7 @@ LLLocalTextureObject::~LLLocalTextureObject() { } -LLViewerFetchedTexture* LLLocalTextureObject::getImage() const +LLGLTexture* LLLocalTextureObject::getImage() const { return mImage; } @@ -126,7 +127,7 @@ BOOL LLLocalTextureObject::getBakedReady() const return mIsBakedReady; } -void LLLocalTextureObject::setImage(LLViewerFetchedTexture* new_image) +void LLLocalTextureObject::setImage(LLGLTexture* new_image) { mImage = new_image; } diff --git a/indra/newview/lllocaltextureobject.h b/indra/llappearance/lllocaltextureobject.h similarity index 89% rename from indra/newview/lllocaltextureobject.h rename to indra/llappearance/lllocaltextureobject.h index b9bfc5472..9b9f41fd1 100644 --- a/indra/newview/lllocaltextureobject.h +++ b/indra/llappearance/lllocaltextureobject.h @@ -29,11 +29,10 @@ #include -#include "llviewertexture.h" +#include "llpointer.h" +#include "llgltexture.h" -class LLUUID; class LLTexLayer; -class LLTextureEntry; class LLTexLayerTemplate; class LLWearable; @@ -44,11 +43,11 @@ class LLLocalTextureObject { public: LLLocalTextureObject(); - LLLocalTextureObject(LLViewerFetchedTexture* image, const LLUUID& id); + LLLocalTextureObject(LLGLTexture* image, const LLUUID& id); LLLocalTextureObject(const LLLocalTextureObject& lto); ~LLLocalTextureObject(); - LLViewerFetchedTexture* getImage() const; + LLGLTexture* getImage() const; LLTexLayer* getTexLayer(U32 index) const; LLTexLayer* getTexLayer(const std::string &name); U32 getNumTexLayers() const; @@ -56,7 +55,7 @@ public: S32 getDiscard() const; BOOL getBakedReady() const; - void setImage(LLViewerFetchedTexture* new_image); + void setImage(LLGLTexture* new_image); BOOL setTexLayer(LLTexLayer *new_tex_layer, U32 index); BOOL addTexLayer(LLTexLayer *new_tex_layer, LLWearable *wearable); BOOL addTexLayer(LLTexLayerTemplate *new_tex_layer, LLWearable *wearable); @@ -70,7 +69,7 @@ protected: private: - LLPointer mImage; + LLPointer mImage; // NOTE: LLLocalTextureObject should be the exclusive owner of mTexEntry and mTexLayer // using shared pointers here only for smart assignment & cleanup // do NOT create new shared pointers to these objects, or keep pointers to them around diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp index 79e04b4d4..1d0d2fadf 100644 --- a/indra/llappearance/lltexlayer.cpp +++ b/indra/llappearance/lltexlayer.cpp @@ -39,8 +39,8 @@ #include "lltexlayerparams.h" #include "lltexturemanagerbridge.h" //#include "llrender2dutils.h" -//#include "llwearable.h" -//#include "llwearabledata.h" +#include "llwearable.h" +#include "llwearabledata.h" #include "llvertexbuffer.h" #include "llviewervisualparam.h" @@ -48,6 +48,215 @@ using namespace LLAvatarAppearanceDefines; +// runway consolidate +extern std::string self_av_string(); + +class LLTexLayerInfo +{ + friend class LLTexLayer; + friend class LLTexLayerTemplate; + friend class LLTexLayerInterface; +public: + LLTexLayerInfo(); + ~LLTexLayerInfo(); + + BOOL parseXml(LLXmlTreeNode* node); + BOOL createVisualParams(LLAvatarAppearance *appearance); + BOOL isUserSettable() { return mLocalTexture != -1; } + S32 getLocalTexture() const { return mLocalTexture; } + BOOL getOnlyAlpha() const { return mUseLocalTextureAlphaOnly; } + std::string getName() const { return mName; } + +private: + std::string mName; + + BOOL mWriteAllChannels; // Don't use masking. Just write RGBA into buffer, + LLTexLayerInterface::ERenderPass mRenderPass; + + std::string mGlobalColor; + LLColor4 mFixedColor; + + S32 mLocalTexture; + std::string mStaticImageFileName; + BOOL mStaticImageIsMask; + BOOL mUseLocalTextureAlphaOnly; // Ignore RGB channels from the input texture. Use alpha as a mask + BOOL mIsVisibilityMask; + + typedef std::vector< std::pair< std::string,BOOL > > morph_name_list_t; + morph_name_list_t mMorphNameList; + param_color_info_list_t mParamColorInfoList; + param_alpha_info_list_t mParamAlphaInfoList; +}; + +//----------------------------------------------------------------------------- +// LLTexLayerSetBuffer +// The composite image that a LLViewerTexLayerSet writes to. Each LLViewerTexLayerSet has one. +//----------------------------------------------------------------------------- + +LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLTexLayerSet* const owner) : + mTexLayerSet(owner) +{ +} + +LLTexLayerSetBuffer::~LLTexLayerSetBuffer() +{ +} + +void LLTexLayerSetBuffer::pushProjection() const +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.ortho(0.0f, getCompositeWidth(), 0.0f, getCompositeHeight(), -1.0f, 1.0f); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); +} + +void LLTexLayerSetBuffer::popProjection() const +{ + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); +} + +// virtual +void LLTexLayerSetBuffer::preRenderTexLayerSet() +{ + // Set up an ortho projection + pushProjection(); +} + +// virtual +void LLTexLayerSetBuffer::postRenderTexLayerSet(BOOL success) +{ + popProjection(); +} + +BOOL LLTexLayerSetBuffer::renderTexLayerSet() +{ + // Default color mask for tex layer render + gGL.setColorMask(true, true); + + BOOL success = TRUE; + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + if (use_shaders) + { + gAlphaMaskProgram.bind(); + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + + LLVertexBuffer::unbind(); + + // Composite the color data + LLGLSUIDefault gls_ui; + success &= mTexLayerSet->render( getCompositeOriginX(), getCompositeOriginY(), + getCompositeWidth(), getCompositeHeight() ); + gGL.flush(); + + midRenderTexLayerSet(success); + + if (use_shaders) + { + gAlphaMaskProgram.unbind(); + } + + LLVertexBuffer::unbind(); + + // reset GL state + gGL.setColorMask(true, true); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + return success; +} + +//----------------------------------------------------------------------------- +// LLTexLayerSetInfo +// An ordered set of texture layers that get composited into a single texture. +//----------------------------------------------------------------------------- + +LLTexLayerSetInfo::LLTexLayerSetInfo() : + mBodyRegion( "" ), + mWidth( 512 ), + mHeight( 512 ), + mClearAlpha( TRUE ) +{ +} + +LLTexLayerSetInfo::~LLTexLayerSetInfo( ) +{ + std::for_each(mLayerInfoList.begin(), mLayerInfoList.end(), DeletePointer()); +} + +BOOL LLTexLayerSetInfo::parseXml(LLXmlTreeNode* node) +{ + llassert( node->hasName( "layer_set" ) ); + if( !node->hasName( "layer_set" ) ) + { + return FALSE; + } + + // body_region + static LLStdStringHandle body_region_string = LLXmlTree::addAttributeString("body_region"); + if( !node->getFastAttributeString( body_region_string, mBodyRegion ) ) + { + llwarns << " is missing body_region attribute" << llendl; + return FALSE; + } + + // width, height + static LLStdStringHandle width_string = LLXmlTree::addAttributeString("width"); + if( !node->getFastAttributeS32( width_string, mWidth ) ) + { + return FALSE; + } + + static LLStdStringHandle height_string = LLXmlTree::addAttributeString("height"); + if( !node->getFastAttributeS32( height_string, mHeight ) ) + { + return FALSE; + } + + // Optional alpha component to apply after all compositing is complete. + static LLStdStringHandle alpha_tga_file_string = LLXmlTree::addAttributeString("alpha_tga_file"); + node->getFastAttributeString( alpha_tga_file_string, mStaticAlphaFileName ); + + static LLStdStringHandle clear_alpha_string = LLXmlTree::addAttributeString("clear_alpha"); + node->getFastAttributeBOOL( clear_alpha_string, mClearAlpha ); + + // + for (LLXmlTreeNode* child = node->getChildByName( "layer" ); + child; + child = node->getNextNamedChild()) + { + LLTexLayerInfo* info = new LLTexLayerInfo(); + if( !info->parseXml( child )) + { + delete info; + return FALSE; + } + mLayerInfoList.push_back( info ); + } + return TRUE; +} + +// creates visual params without generating layersets or layers +void LLTexLayerSetInfo::createVisualParams(LLAvatarAppearance *appearance) +{ + //layer_info_list_t mLayerInfoList; + for (layer_info_list_t::iterator layer_iter = mLayerInfoList.begin(); + layer_iter != mLayerInfoList.end(); + layer_iter++) + { + LLTexLayerInfo *layer_info = *layer_iter; + layer_info->createVisualParams(appearance); + } +} //----------------------------------------------------------------------------- // LLTexLayerSet @@ -57,9 +266,1557 @@ using namespace LLAvatarAppearanceDefines; BOOL LLTexLayerSet::sHasCaches = FALSE; LLTexLayerSet::LLTexLayerSet(LLAvatarAppearance* const appearance) : + mAvatarAppearance( appearance ), + mIsVisible( TRUE ), + mBakedTexIndex(LLAvatarAppearanceDefines::BAKED_HEAD), + mInfo( NULL ) +{ +} + +// virtual +LLTexLayerSet::~LLTexLayerSet() +{ + deleteCaches(); + std::for_each(mLayerList.begin(), mLayerList.end(), DeletePointer()); + std::for_each(mMaskLayerList.begin(), mMaskLayerList.end(), DeletePointer()); +} + +//----------------------------------------------------------------------------- +// setInfo +//----------------------------------------------------------------------------- + +BOOL LLTexLayerSet::setInfo(const LLTexLayerSetInfo *info) +{ + llassert(mInfo == NULL); + mInfo = info; + //mID = info->mID; // No ID + + mLayerList.reserve(info->mLayerInfoList.size()); + for (LLTexLayerSetInfo::layer_info_list_t::const_iterator iter = info->mLayerInfoList.begin(); + iter != info->mLayerInfoList.end(); + iter++) + { + LLTexLayerInterface *layer = NULL; + if ( (*iter)->isUserSettable() ) + { + layer = new LLTexLayerTemplate( this, getAvatarAppearance() ); + } + else + { + layer = new LLTexLayer(this); + } + // this is the first time this layer (of either type) is being created - make sure you add the parameters to the avatar appearance + if (!layer->setInfo(*iter, NULL)) + { + mInfo = NULL; + return FALSE; + } + if (!layer->isVisibilityMask()) + { + mLayerList.push_back( layer ); + } + else + { + mMaskLayerList.push_back(layer); + } + } + + requestUpdate(); + + stop_glerror(); + + return TRUE; +} + +#if 0 // obsolete +//----------------------------------------------------------------------------- +// parseData +//----------------------------------------------------------------------------- + +BOOL LLTexLayerSet::parseData(LLXmlTreeNode* node) +{ + LLTexLayerSetInfo *info = new LLTexLayerSetInfo; + + if (!info->parseXml(node)) + { + delete info; + return FALSE; + } + if (!setInfo(info)) + { + delete info; + return FALSE; + } + return TRUE; +} +#endif + +void LLTexLayerSet::deleteCaches() +{ + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + layer->deleteCaches(); + } + for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++) + { + LLTexLayerInterface* layer = *iter; + layer->deleteCaches(); + } +} + + +BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) +{ + BOOL success = TRUE; + mIsVisible = TRUE; + + if (mMaskLayerList.size() > 0) + { + for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++) + { + LLTexLayerInterface* layer = *iter; + if (layer->isInvisibleAlphaMask()) + { + mIsVisible = FALSE; + } + } + } + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + LLGLSUIDefault gls_ui; + LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE); + gGL.setColorMask(true, true); + + // clear buffer area to ensure we don't pick up UI elements + { + gGL.flush(); + LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.0f); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f( 0.f, 0.f, 0.f, 1.f ); + + gl_rect_2d_simple( width, height ); + + gGL.flush(); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + + if (mIsVisible) + { + // composite color layers + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + if (layer->getRenderPass() == LLTexLayer::RP_COLOR) + { + gGL.flush(); + success &= layer->render(x, y, width, height); + gGL.flush(); + } + } + + renderAlphaMaskTextures(x, y, width, height, false); + + stop_glerror(); + } + else + { + gGL.flush(); + + gGL.setSceneBlendType(LLRender::BT_REPLACE); + LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f( 0.f, 0.f, 0.f, 0.f ); + + gl_rect_2d_simple( width, height ); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gGL.flush(); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + + return success; +} + + +BOOL LLTexLayerSet::isBodyRegion(const std::string& region) const +{ + return mInfo->mBodyRegion == region; +} + +const std::string LLTexLayerSet::getBodyRegionName() const +{ + return mInfo->mBodyRegion; +} + + +// virtual +void LLTexLayerSet::asLLSD(LLSD& sd) const +{ + sd["visible"] = LLSD::Boolean(isVisible()); + LLSD layer_list_sd; + layer_list_t::const_iterator layer_iter = mLayerList.begin(); + layer_list_t::const_iterator layer_end = mLayerList.end(); + for(; layer_iter != layer_end; ++layer_iter); + { + LLSD layer_sd; + //LLTexLayerInterface* layer = (*layer_iter); + //if (layer) + //{ + // layer->asLLSD(layer_sd); + //} + layer_list_sd.append(layer_sd); + } + LLSD mask_list_sd; + LLSD info_sd; + sd["layers"] = layer_list_sd; + sd["masks"] = mask_list_sd; + sd["info"] = info_sd; +} + + +void LLTexLayerSet::destroyComposite() +{ + if( mComposite ) + { + mComposite = NULL; + } +} + +LLTexLayerSetBuffer* LLTexLayerSet::getComposite() +{ + if (!mComposite) + { + createComposite(); + } + return mComposite; +} + +const LLTexLayerSetBuffer* LLTexLayerSet::getComposite() const +{ + return mComposite; +} + +static LLFastTimer::DeclareTimer FTM_GATHER_MORPH_MASK_ALPHA("gatherMorphMaskAlpha"); +void LLTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 origin_x, S32 origin_y, S32 width, S32 height) +{ + LLFastTimer t(FTM_GATHER_MORPH_MASK_ALPHA); + memset(data, 255, width * height); + + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + layer->gatherAlphaMasks(data, origin_x, origin_y, width, height); + } + + // Set alpha back to that of our alpha masks. + renderAlphaMaskTextures(origin_x, origin_y, width, height, true); +} + +static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_MASK_TEXTURES("renderAlphaMaskTextures"); +void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear) +{ + LLFastTimer t(FTM_RENDER_ALPHA_MASK_TEXTURES); + const LLTexLayerSetInfo *info = getInfo(); + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + gGL.setColorMask(false, true); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + + // (Optionally) replace alpha with a single component image from a tga file. + if (!info->mStaticAlphaFileName.empty()) + { + gGL.flush(); + { + LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(info->mStaticAlphaFileName, TRUE); + if( tex ) + { + LLGLSUIDefault gls_ui; + gGL.getTexUnit(0)->bind(tex); + gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE ); + gl_rect_2d_simple_tex( width, height ); + } + } + gGL.flush(); + } + else if (forceClear || info->mClearAlpha || (mMaskLayerList.size() > 0)) + { + // Set the alpha channel to one (clean up after previous blending) + gGL.flush(); + LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f( 0.f, 0.f, 0.f, 1.f ); + + gl_rect_2d_simple( width, height ); + + gGL.flush(); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + + // (Optional) Mask out part of the baked texture with alpha masks + // will still have an effect even if mClearAlpha is set or the alpha component was replaced + if (mMaskLayerList.size() > 0) + { + gGL.setSceneBlendType(LLRender::BT_MULT_ALPHA); + gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE ); + for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++) + { + LLTexLayerInterface* layer = *iter; + gGL.flush(); + layer->blendAlphaTexture(x,y,width, height); + gGL.flush(); + } + + } + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.setColorMask(true, true); + gGL.setSceneBlendType(LLRender::BT_ALPHA); +} + +void LLTexLayerSet::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components) +{ + mAvatarAppearance->applyMorphMask(tex_data, width, height, num_components, mBakedTexIndex); +} + +BOOL LLTexLayerSet::isMorphValid() const +{ + for(layer_list_t::const_iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + const LLTexLayerInterface* layer = *iter; + if (layer && !layer->isMorphValid()) + { + return FALSE; + } + } + return TRUE; +} + +void LLTexLayerSet::invalidateMorphMasks() +{ + for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + if (layer) + { + layer->invalidateMorphMasks(); + } + } +} + + +//----------------------------------------------------------------------------- +// LLTexLayerInfo +//----------------------------------------------------------------------------- +LLTexLayerInfo::LLTexLayerInfo() : + mWriteAllChannels( FALSE ), + mRenderPass(LLTexLayer::RP_COLOR), + mFixedColor( 0.f, 0.f, 0.f, 0.f ), + mLocalTexture( -1 ), + mStaticImageIsMask( FALSE ), + mUseLocalTextureAlphaOnly(FALSE), + mIsVisibilityMask(FALSE) +{ +} + +LLTexLayerInfo::~LLTexLayerInfo( ) +{ + std::for_each(mParamColorInfoList.begin(), mParamColorInfoList.end(), DeletePointer()); + std::for_each(mParamAlphaInfoList.begin(), mParamAlphaInfoList.end(), DeletePointer()); +} + +BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node) +{ + llassert( node->hasName( "layer" ) ); + + // name attribute + static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); + if( !node->getFastAttributeString( name_string, mName ) ) + { + return FALSE; + } + + static LLStdStringHandle write_all_channels_string = LLXmlTree::addAttributeString("write_all_channels"); + node->getFastAttributeBOOL( write_all_channels_string, mWriteAllChannels ); + + std::string render_pass_name; + static LLStdStringHandle render_pass_string = LLXmlTree::addAttributeString("render_pass"); + if( node->getFastAttributeString( render_pass_string, render_pass_name ) ) + { + if( render_pass_name == "bump" ) + { + mRenderPass = LLTexLayer::RP_BUMP; + } + } + + // Note: layers can have either a "global_color" attrib, a "fixed_color" attrib, or a child. + // global color attribute (optional) + static LLStdStringHandle global_color_string = LLXmlTree::addAttributeString("global_color"); + node->getFastAttributeString( global_color_string, mGlobalColor ); + + // Visibility mask (optional) + BOOL is_visibility; + static LLStdStringHandle visibility_mask_string = LLXmlTree::addAttributeString("visibility_mask"); + if (node->getFastAttributeBOOL(visibility_mask_string, is_visibility)) + { + mIsVisibilityMask = is_visibility; + } + + // color attribute (optional) + LLColor4U color4u; + static LLStdStringHandle fixed_color_string = LLXmlTree::addAttributeString("fixed_color"); + if( node->getFastAttributeColor4U( fixed_color_string, color4u ) ) + { + mFixedColor.setVec( color4u ); + } + + // optional sub-element + for (LLXmlTreeNode* texture_node = node->getChildByName( "texture" ); + texture_node; + texture_node = node->getNextNamedChild()) + { + std::string local_texture_name; + static LLStdStringHandle tga_file_string = LLXmlTree::addAttributeString("tga_file"); + static LLStdStringHandle local_texture_string = LLXmlTree::addAttributeString("local_texture"); + static LLStdStringHandle file_is_mask_string = LLXmlTree::addAttributeString("file_is_mask"); + static LLStdStringHandle local_texture_alpha_only_string = LLXmlTree::addAttributeString("local_texture_alpha_only"); + if( texture_node->getFastAttributeString( tga_file_string, mStaticImageFileName ) ) + { + texture_node->getFastAttributeBOOL( file_is_mask_string, mStaticImageIsMask ); + } + else if (texture_node->getFastAttributeString(local_texture_string, local_texture_name)) + { + texture_node->getFastAttributeBOOL( local_texture_alpha_only_string, mUseLocalTextureAlphaOnly ); + + /* if ("upper_shirt" == local_texture_name) + mLocalTexture = TEX_UPPER_SHIRT; */ + mLocalTexture = TEX_NUM_INDICES; + for (LLAvatarAppearanceDictionary::Textures::const_iterator iter = LLAvatarAppearanceDictionary::getInstance()->getTextures().begin(); + iter != LLAvatarAppearanceDictionary::getInstance()->getTextures().end(); + iter++) + { + const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = iter->second; + if (local_texture_name == texture_dict->mName) + { + mLocalTexture = iter->first; + break; + } + } + if (mLocalTexture == TEX_NUM_INDICES) + { + llwarns << " element has invalid local_texture attribute: " << mName << " " << local_texture_name << llendl; + return FALSE; + } + } + else + { + llwarns << " element is missing a required attribute. " << mName << llendl; + return FALSE; + } + } + + for (LLXmlTreeNode* maskNode = node->getChildByName( "morph_mask" ); + maskNode; + maskNode = node->getNextNamedChild()) + { + std::string morph_name; + static LLStdStringHandle morph_name_string = LLXmlTree::addAttributeString("morph_name"); + if (maskNode->getFastAttributeString(morph_name_string, morph_name)) + { + BOOL invert = FALSE; + static LLStdStringHandle invert_string = LLXmlTree::addAttributeString("invert"); + maskNode->getFastAttributeBOOL(invert_string, invert); + mMorphNameList.push_back(std::pair(morph_name,invert)); + } + } + + // optional sub-element (color or alpha params) + for (LLXmlTreeNode* child = node->getChildByName( "param" ); + child; + child = node->getNextNamedChild()) + { + if( child->getChildByName( "param_color" ) ) + { + // + LLTexLayerParamColorInfo* info = new LLTexLayerParamColorInfo(); + if (!info->parseXml(child)) + { + delete info; + return FALSE; + } + mParamColorInfoList.push_back(info); + } + else if( child->getChildByName( "param_alpha" ) ) + { + // + LLTexLayerParamAlphaInfo* info = new LLTexLayerParamAlphaInfo( ); + if (!info->parseXml(child)) + { + delete info; + return FALSE; + } + mParamAlphaInfoList.push_back(info); + } + } + + return TRUE; +} + +BOOL LLTexLayerInfo::createVisualParams(LLAvatarAppearance *appearance) +{ + BOOL success = TRUE; + for (param_color_info_list_t::iterator color_info_iter = mParamColorInfoList.begin(); + color_info_iter != mParamColorInfoList.end(); + color_info_iter++) + { + LLTexLayerParamColorInfo * color_info = *color_info_iter; + LLTexLayerParamColor* param_color = new LLTexLayerParamColor(appearance); + if (!param_color->setInfo(color_info, TRUE)) + { + llwarns << "NULL TexLayer Color Param could not be added to visual param list. Deleting." << llendl; + delete param_color; + success = FALSE; + } + } + + for (param_alpha_info_list_t::iterator alpha_info_iter = mParamAlphaInfoList.begin(); + alpha_info_iter != mParamAlphaInfoList.end(); + alpha_info_iter++) + { + LLTexLayerParamAlphaInfo * alpha_info = *alpha_info_iter; + LLTexLayerParamAlpha* param_alpha = new LLTexLayerParamAlpha(appearance); + if (!param_alpha->setInfo(alpha_info, TRUE)) + { + llwarns << "NULL TexLayer Alpha Param could not be added to visual param list. Deleting." << llendl; + delete param_alpha; + success = FALSE; + } + } + + return success; +} + +LLTexLayerInterface::LLTexLayerInterface(LLTexLayerSet* const layer_set): + mTexLayerSet( layer_set ), + mMorphMasksValid( FALSE ), + mInfo(NULL), + mHasMorph(FALSE) +{ +} + +LLTexLayerInterface::LLTexLayerInterface(const LLTexLayerInterface &layer, LLWearable *wearable): + mTexLayerSet( layer.mTexLayerSet ), + mInfo(NULL) +{ + // don't add visual params for cloned layers + setInfo(layer.getInfo(), wearable); + + mHasMorph = layer.mHasMorph; +} + +BOOL LLTexLayerInterface::setInfo(const LLTexLayerInfo *info, LLWearable* wearable ) // This sets mInfo and calls initialization functions +{ + // setInfo should only be called once. Code is not robust enough to handle redefinition of a texlayer. + // Not a critical warning, but could be useful for debugging later issues. -Nyx + if (mInfo != NULL) + { + llwarns << "mInfo != NULL" << llendl; + } + mInfo = info; + //mID = info->mID; // No ID + + mParamColorList.reserve(mInfo->mParamColorInfoList.size()); + for (param_color_info_list_t::const_iterator iter = mInfo->mParamColorInfoList.begin(); + iter != mInfo->mParamColorInfoList.end(); + iter++) + { + LLTexLayerParamColor* param_color; + if (!wearable) + { + param_color = new LLTexLayerParamColor(this); + if (!param_color->setInfo(*iter, TRUE)) + { + mInfo = NULL; + return FALSE; + } + } + else + { + param_color = (LLTexLayerParamColor*)wearable->getVisualParam((*iter)->getID()); + if (!param_color) + { + mInfo = NULL; + return FALSE; + } + } + mParamColorList.push_back( param_color ); + } + + mParamAlphaList.reserve(mInfo->mParamAlphaInfoList.size()); + for (param_alpha_info_list_t::const_iterator iter = mInfo->mParamAlphaInfoList.begin(); + iter != mInfo->mParamAlphaInfoList.end(); + iter++) + { + LLTexLayerParamAlpha* param_alpha; + if (!wearable) + { + param_alpha = new LLTexLayerParamAlpha( this ); + if (!param_alpha->setInfo(*iter, TRUE)) + { + mInfo = NULL; + return FALSE; + } + } + else + { + param_alpha = (LLTexLayerParamAlpha*) wearable->getVisualParam((*iter)->getID()); + if (!param_alpha) + { + mInfo = NULL; + return FALSE; + } + } + mParamAlphaList.push_back( param_alpha ); + } + + return TRUE; +} + +/*virtual*/ void LLTexLayerInterface::requestUpdate() +{ + mTexLayerSet->requestUpdate(); +} + +const std::string& LLTexLayerInterface::getName() const +{ + return mInfo->mName; +} + +ETextureIndex LLTexLayerInterface::getLocalTextureIndex() const +{ + return (ETextureIndex) mInfo->mLocalTexture; +} + +LLWearableType::EType LLTexLayerInterface::getWearableType() const +{ + ETextureIndex te = getLocalTextureIndex(); + if (TEX_INVALID == te) + { + return LLWearableType::WT_INVALID; + } + return LLAvatarAppearanceDictionary::getTEWearableType(te); +} + +LLTexLayerInterface::ERenderPass LLTexLayerInterface::getRenderPass() const +{ + return mInfo->mRenderPass; +} + +const std::string& LLTexLayerInterface::getGlobalColor() const +{ + return mInfo->mGlobalColor; +} + +BOOL LLTexLayerInterface::isVisibilityMask() const +{ + return mInfo->mIsVisibilityMask; +} + +void LLTexLayerInterface::invalidateMorphMasks() +{ + mMorphMasksValid = FALSE; +} + +LLViewerVisualParam* LLTexLayerInterface::getVisualParamPtr(S32 index) const +{ + LLViewerVisualParam *result = NULL; + for (param_color_list_t::const_iterator color_iter = mParamColorList.begin(); color_iter != mParamColorList.end() && !result; ++color_iter) + { + if ((*color_iter)->getID() == index) + { + result = *color_iter; + } + } + for (param_alpha_list_t::const_iterator alpha_iter = mParamAlphaList.begin(); alpha_iter != mParamAlphaList.end() && !result; ++alpha_iter) + { + if ((*alpha_iter)->getID() == index) + { + result = *alpha_iter; + } + } + + return result; +} + +//----------------------------------------------------------------------------- +// LLTexLayer +// A single texture layer, consisting of: +// * color, consisting of either +// * one or more color parameters (weighted colors) +// * a reference to a global color +// * a fixed color with non-zero alpha +// * opaque white (the default) +// * (optional) a texture defined by either +// * a GUID +// * a texture entry index (TE) +// * (optional) one or more alpha parameters (weighted alpha textures) +//----------------------------------------------------------------------------- +LLTexLayer::LLTexLayer(LLTexLayerSet* const layer_set) : + LLTexLayerInterface( layer_set ), + mLocalTextureObject(NULL) +{ +} + +LLTexLayer::LLTexLayer(const LLTexLayer &layer, LLWearable *wearable) : + LLTexLayerInterface( layer, wearable ), + mLocalTextureObject(NULL) +{ +} + +LLTexLayer::LLTexLayer(const LLTexLayerTemplate &layer_template, LLLocalTextureObject *lto, LLWearable *wearable) : + LLTexLayerInterface( layer_template, wearable ), + mLocalTextureObject(lto) +{ +} + +LLTexLayer::~LLTexLayer() +{ + // mParamAlphaList and mParamColorList are LLViewerVisualParam's and get + // deleted with ~LLCharacter() + //std::for_each(mParamAlphaList.begin(), mParamAlphaList.end(), DeletePointer()); + //std::for_each(mParamColorList.begin(), mParamColorList.end(), DeletePointer()); + + for( alpha_cache_t::iterator iter = mAlphaCache.begin(); + iter != mAlphaCache.end(); iter++ ) + { + U8* alpha_data = iter->second; + delete [] alpha_data; + } + +} + +void LLTexLayer::asLLSD(LLSD& sd) const +{ + // *TODO: Finish + sd["id"] = getUUID(); +} + +//----------------------------------------------------------------------------- +// setInfo +//----------------------------------------------------------------------------- + +BOOL LLTexLayer::setInfo(const LLTexLayerInfo* info, LLWearable* wearable ) +{ + return LLTexLayerInterface::setInfo(info, wearable); +} + +//static +void LLTexLayer::calculateTexLayerColor(const param_color_list_t ¶m_list, LLColor4 &net_color) +{ + for (param_color_list_t::const_iterator iter = param_list.begin(); + iter != param_list.end(); iter++) + { + const LLTexLayerParamColor* param = *iter; + LLColor4 param_net = param->getNetColor(); + const LLTexLayerParamColorInfo *info = (LLTexLayerParamColorInfo *)param->getInfo(); + switch(info->getOperation()) + { + case LLTexLayerParamColor::OP_ADD: + net_color += param_net; + break; + case LLTexLayerParamColor::OP_MULTIPLY: + net_color = net_color * param_net; + break; + case LLTexLayerParamColor::OP_BLEND: + net_color = lerp(net_color, param_net, param->getWeight()); + break; + default: + llassert(0); + break; + } + } + net_color.clamp(); +} + +/*virtual*/ void LLTexLayer::deleteCaches() +{ + // Only need to delete caches for alpha params. Color params don't hold extra memory + for (param_alpha_list_t::iterator iter = mParamAlphaList.begin(); + iter != mParamAlphaList.end(); iter++ ) + { + LLTexLayerParamAlpha* param = *iter; + param->deleteCaches(); + } +} + +BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) +{ + LLGLEnable color_mat(GL_COLOR_MATERIAL); + // *TODO: Is this correct? + //gPipeline.disableLights(); + stop_glerror(); + glDisable(GL_LIGHTING); + stop_glerror(); + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + LLColor4 net_color; + BOOL color_specified = findNetColor(&net_color); + + if (mTexLayerSet->getAvatarAppearance()->mIsDummy) + { + color_specified = true; + net_color = LLAvatarAppearance::getDummyColor(); + } + + BOOL success = TRUE; + + // If you can't see the layer, don't render it. + if( is_approx_zero( net_color.mV[VW] ) ) + { + return success; + } + + BOOL alpha_mask_specified = FALSE; + param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); + if( iter != mParamAlphaList.end() ) + { + // If we have alpha masks, but we're skipping all of them, skip the whole layer. + // However, we can't do this optimization if we have morph masks that need updating. +/* if (!mHasMorph) + { + BOOL skip_layer = TRUE; + + while( iter != mParamAlphaList.end() ) + { + const LLTexLayerParamAlpha* param = *iter; + + if( !param->getSkip() ) + { + skip_layer = FALSE; + break; + } + + iter++; + } + + if( skip_layer ) + { + return success; + } + }//*/ + + renderMorphMasks(x, y, width, height, net_color); + alpha_mask_specified = TRUE; + gGL.flush(); + gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_ONE_MINUS_DEST_ALPHA); + } + + gGL.color4fv( net_color.mV); + + if( getInfo()->mWriteAllChannels ) + { + gGL.flush(); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + } + + if( (getInfo()->mLocalTexture != -1) && !getInfo()->mUseLocalTextureAlphaOnly ) + { + { + LLGLTexture* tex = NULL; + if (mLocalTextureObject && mLocalTextureObject->getImage()) + { + tex = mLocalTextureObject->getImage(); + if (mLocalTextureObject->getID() == IMG_DEFAULT_AVATAR) + { + tex = NULL; + } + } + else + { + llinfos << "lto not defined or image not defined: " << getInfo()->getLocalTexture() << " lto: " << mLocalTextureObject << llendl; + } +// if( mTexLayerSet->getAvatarAppearance()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) ) + { + if( tex ) + { + bool no_alpha_test = getInfo()->mWriteAllChannels; + LLGLDisable alpha_test(no_alpha_test ? GL_ALPHA_TEST : 0); + if (no_alpha_test) + { + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + } + + LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); + + gGL.getTexUnit(0)->bind(tex, TRUE); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + + gl_rect_2d_simple_tex( width, height ); + + gGL.getTexUnit(0)->setTextureAddressMode(old_mode); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + if (no_alpha_test) + { + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + } + } +// else +// { +// success = FALSE; +// } + } + } + + if( !getInfo()->mStaticImageFileName.empty() ) + { + { + LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); + if( tex ) + { + gGL.getTexUnit(0)->bind(tex, TRUE); + gl_rect_2d_simple_tex( width, height ); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + else + { + success = FALSE; + } + } + } + + if(((-1 == getInfo()->mLocalTexture) || + getInfo()->mUseLocalTextureAlphaOnly) && + getInfo()->mStaticImageFileName.empty() && + color_specified ) + { + LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.000f); + } + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4fv( net_color.mV ); + gl_rect_2d_simple( width, height ); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + + if( alpha_mask_specified || getInfo()->mWriteAllChannels ) + { + // Restore standard blend func value + gGL.flush(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + stop_glerror(); + } + + if( !success ) + { + llinfos << "LLTexLayer::render() partial: " << getInfo()->mName << llendl; + } + return success; +} + +const U8* LLTexLayer::getAlphaData() const +{ + LLCRC alpha_mask_crc; + const LLUUID& uuid = getUUID(); + alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES); + + for (param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++) + { + const LLTexLayerParamAlpha* param = *iter; + // MULTI-WEARABLE: verify visual parameters used here + F32 param_weight = param->getWeight(); + alpha_mask_crc.update((U8*)¶m_weight, sizeof(F32)); + } + + U32 cache_index = alpha_mask_crc.getCRC(); + + alpha_cache_t::const_iterator iter2 = mAlphaCache.find(cache_index); + return (iter2 == mAlphaCache.end()) ? 0 : iter2->second; +} + +BOOL LLTexLayer::findNetColor(LLColor4* net_color) const +{ + // Color is either: + // * one or more color parameters (weighted colors) (which may make use of a global color or fixed color) + // * a reference to a global color + // * a fixed color with non-zero alpha + // * opaque white (the default) + + if( !mParamColorList.empty() ) + { + if( !getGlobalColor().empty() ) + { + net_color->setVec( mTexLayerSet->getAvatarAppearance()->getGlobalColor( getInfo()->mGlobalColor ) ); + } + else if (getInfo()->mFixedColor.mV[VW]) + { + net_color->setVec( getInfo()->mFixedColor ); + } + else + { + net_color->setVec( 0.f, 0.f, 0.f, 0.f ); + } + + calculateTexLayerColor(mParamColorList, *net_color); + return TRUE; + } + + if( !getGlobalColor().empty() ) + { + net_color->setVec( mTexLayerSet->getAvatarAppearance()->getGlobalColor( getGlobalColor() ) ); + return TRUE; + } + + if( getInfo()->mFixedColor.mV[VW] ) + { + net_color->setVec( getInfo()->mFixedColor ); + return TRUE; + } + + net_color->setToWhite(); + + return FALSE; // No need to draw a separate colored polygon +} + +BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) +{ + BOOL success = TRUE; + + gGL.flush(); + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + if( !getInfo()->mStaticImageFileName.empty() ) + { + LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask ); + if( tex ) + { + LLGLSNoAlphaTest gls_no_alpha_test; + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + gGL.getTexUnit(0)->bind(tex, TRUE); + gl_rect_2d_simple_tex( width, height ); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + else + { + success = FALSE; + } + } + else + { + if (getInfo()->mLocalTexture >=0 && getInfo()->mLocalTexture < TEX_NUM_INDICES) + { + LLGLTexture* tex = mLocalTextureObject->getImage(); + if (tex) + { + LLGLSNoAlphaTest gls_no_alpha_test; + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + gGL.getTexUnit(0)->bind(tex); + gl_rect_2d_simple_tex( width, height ); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + success = TRUE; + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + } + } + } + + return success; +} + +/*virtual*/ void LLTexLayer::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) +{ + addAlphaMask(data, originX, originY, width, height); +} + +static LLFastTimer::DeclareTimer FTM_RENDER_MORPH_MASKS("renderMorphMasks"); +BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLColor4 &layer_color) +{ + LLFastTimer t(FTM_RENDER_MORPH_MASKS); + BOOL success = TRUE; + + llassert( !mParamAlphaList.empty() ); + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + + gGL.setColorMask(false, true); + + LLTexLayerParamAlpha* first_param = *mParamAlphaList.begin(); + // Note: if the first param is a mulitply, multiply against the current buffer's alpha + if( !first_param || !first_param->getMultiplyBlend() ) + { + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + // Clear the alpha + gGL.flush(); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + + gGL.color4f( 0.f, 0.f, 0.f, 0.f ); + gl_rect_2d_simple( width, height ); + } + + // Accumulate alphas + LLGLSNoAlphaTest gls_no_alpha_test; + gGL.color4f( 1.f, 1.f, 1.f, 1.f ); + for (param_alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++) + { + LLTexLayerParamAlpha* param = *iter; + success &= param->render( x, y, width, height ); + } + + // Approximates a min() function + gGL.flush(); + gGL.setSceneBlendType(LLRender::BT_MULT_ALPHA); + + // Accumulate the alpha component of the texture + if( getInfo()->mLocalTexture != -1 ) + { + LLGLTexture* tex = mLocalTextureObject->getImage(); + if( tex && (tex->getComponents() == 4) ) + { + LLGLSNoAlphaTest gls_no_alpha_test; + LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); + + gGL.getTexUnit(0)->bind(tex, TRUE); + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + + gl_rect_2d_simple_tex( width, height ); + + gGL.getTexUnit(0)->setTextureAddressMode(old_mode); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + } + + if( !getInfo()->mStaticImageFileName.empty() ) + { + LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); + if( tex ) + { + if( (tex->getComponents() == 4) || + ( (tex->getComponents() == 1) && getInfo()->mStaticImageIsMask ) ) + { + LLGLSNoAlphaTest gls_no_alpha_test; + gGL.getTexUnit(0)->bind(tex, TRUE); + gl_rect_2d_simple_tex( width, height ); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + } + } + + // Draw a rectangle with the layer color to multiply the alpha by that color's alpha. + // Note: we're still using gGL.blendFunc( GL_DST_ALPHA, GL_ZERO ); + if (layer_color.mV[VW] != 1.f) + { + LLGLDisable no_alpha(GL_ALPHA_TEST); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4fv(layer_color.mV); + gl_rect_2d_simple( width, height ); + } + + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + + LLGLSUIDefault gls_ui; + + gGL.setColorMask(true, true); + + if (hasMorph() && success) + { + LLCRC alpha_mask_crc; + const LLUUID& uuid = getUUID(); + alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES); + + for (param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++) + { + const LLTexLayerParamAlpha* param = *iter; + F32 param_weight = param->getWeight(); + alpha_mask_crc.update((U8*)¶m_weight, sizeof(F32)); + } + + U32 cache_index = alpha_mask_crc.getCRC(); + U8* alpha_data = get_if_there(mAlphaCache,cache_index,(U8*)NULL); + if (!alpha_data) + { + // clear out a slot if we have filled our cache + S32 max_cache_entries = getTexLayerSet()->getAvatarAppearance()->isSelf() ? 4 : 1; + while ((S32)mAlphaCache.size() >= max_cache_entries) + { + alpha_cache_t::iterator iter2 = mAlphaCache.begin(); // arbitrarily grab the first entry + alpha_data = iter2->second; + delete [] alpha_data; + mAlphaCache.erase(iter2); + } + alpha_data = new U8[width * height]; + mAlphaCache[cache_index] = alpha_data; + glReadPixels(x, y, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_data); + } + + getTexLayerSet()->getAvatarAppearance()->dirtyMesh(); + + mMorphMasksValid = TRUE; + getTexLayerSet()->applyMorphMask(alpha_data, width, height, 1); + } + + return success; +} + +static LLFastTimer::DeclareTimer FTM_ADD_ALPHA_MASK("addAlphaMask"); +void LLTexLayer::addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height) +{ + LLFastTimer t(FTM_ADD_ALPHA_MASK); + S32 size = width * height; + const U8* alphaData = getAlphaData(); + if (!alphaData && hasAlphaParams()) + { + LLColor4 net_color; + findNetColor( &net_color ); + // TODO: eliminate need for layer morph mask valid flag + invalidateMorphMasks(); + renderMorphMasks(originX, originY, width, height, net_color); + alphaData = getAlphaData(); + } + if (alphaData) + { + for( S32 i = 0; i < size; i++ ) + { + U8 curAlpha = data[i]; + U16 resultAlpha = curAlpha; + resultAlpha *= (alphaData[i] + 1); + resultAlpha = resultAlpha >> 8; + data[i] = (U8)resultAlpha; + } + } +} + +/*virtual*/ BOOL LLTexLayer::isInvisibleAlphaMask() const +{ + if (mLocalTextureObject) + { + if (mLocalTextureObject->getID() == IMG_INVISIBLE) + { + return TRUE; + } + } + + return FALSE; +} + +LLUUID LLTexLayer::getUUID() const +{ + LLUUID uuid; + if( getInfo()->mLocalTexture != -1 ) + { + LLGLTexture* tex = mLocalTextureObject->getImage(); + if (tex) + { + uuid = mLocalTextureObject->getID(); + } + } + if( !getInfo()->mStaticImageFileName.empty() ) + { + LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); + if( tex ) + { + uuid = tex->getID(); + } + } + return uuid; +} + + +//----------------------------------------------------------------------------- +// LLTexLayerTemplate +// A single texture layer, consisting of: +// * color, consisting of either +// * one or more color parameters (weighted colors) +// * a reference to a global color +// * a fixed color with non-zero alpha +// * opaque white (the default) +// * (optional) a texture defined by either +// * a GUID +// * a texture entry index (TE) +// * (optional) one or more alpha parameters (weighted alpha textures) +//----------------------------------------------------------------------------- +LLTexLayerTemplate::LLTexLayerTemplate(LLTexLayerSet* layer_set, LLAvatarAppearance* const appearance) : + LLTexLayerInterface(layer_set), mAvatarAppearance( appearance ) { } + +LLTexLayerTemplate::LLTexLayerTemplate(const LLTexLayerTemplate &layer) : + LLTexLayerInterface(layer), + mAvatarAppearance(layer.getAvatarAppearance()) +{ +} + +LLTexLayerTemplate::~LLTexLayerTemplate() +{ +} + +//----------------------------------------------------------------------------- +// setInfo +//----------------------------------------------------------------------------- + +/*virtual*/ BOOL LLTexLayerTemplate::setInfo(const LLTexLayerInfo* info, LLWearable* wearable ) +{ + return LLTexLayerInterface::setInfo(info, wearable); +} + +U32 LLTexLayerTemplate::updateWearableCache() const +{ + mWearableCache.clear(); + + LLWearableType::EType wearable_type = getWearableType(); + if (LLWearableType::WT_INVALID == wearable_type) + { + //this isn't a cloneable layer + return 0; + } + U32 num_wearables = getAvatarAppearance()->getWearableData()->getWearableCount(wearable_type); + U32 added = 0; + for (U32 i = 0; i < num_wearables; i++) + { + LLWearable* wearable = getAvatarAppearance()->getWearableData()->getWearable(wearable_type, i); + if (!wearable) + { + continue; + } + mWearableCache.push_back(wearable); + added++; + } + return added; +} +LLTexLayer* LLTexLayerTemplate::getLayer(U32 i) const +{ + if (mWearableCache.size() <= i) + { + return NULL; + } + LLWearable *wearable = mWearableCache[i]; + LLLocalTextureObject *lto = NULL; + LLTexLayer *layer = NULL; + if (wearable) + { + lto = wearable->getLocalTextureObject(mInfo->mLocalTexture); + } + if (lto) + { + layer = lto->getTexLayer(getName()); + } + return layer; +} + +/*virtual*/ BOOL LLTexLayerTemplate::render(S32 x, S32 y, S32 width, S32 height) +{ + if(!mInfo) + { + return FALSE ; + } + + BOOL success = TRUE; + updateWearableCache(); + for (wearable_cache_t::const_iterator iter = mWearableCache.begin(); iter!= mWearableCache.end(); iter++) + { + LLWearable* wearable = NULL; + LLLocalTextureObject *lto = NULL; + LLTexLayer *layer = NULL; + wearable = *iter; + if (wearable) + { + lto = wearable->getLocalTextureObject(mInfo->mLocalTexture); + } + if (lto) + { + layer = lto->getTexLayer(getName()); + } + if (layer) + { + wearable->writeToAvatar(mAvatarAppearance); + layer->setLTO(lto); + success &= layer->render(x,y,width,height); + } + } + + return success; +} + +/*virtual*/ BOOL LLTexLayerTemplate::blendAlphaTexture( S32 x, S32 y, S32 width, S32 height) // Multiplies a single alpha texture against the frame buffer +{ + BOOL success = TRUE; + U32 num_wearables = updateWearableCache(); + for (U32 i = 0; i < num_wearables; i++) + { + LLTexLayer *layer = getLayer(i); + if (layer) + { + success &= layer->blendAlphaTexture(x,y,width,height); + } + } + return success; +} + +/*virtual*/ void LLTexLayerTemplate::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) +{ + U32 num_wearables = updateWearableCache(); + for (U32 i = 0; i < num_wearables; i++) + { + LLTexLayer *layer = getLayer(i); + if (layer) + { + layer->addAlphaMask(data, originX, originY, width, height); + } + } +} + +/*virtual*/ void LLTexLayerTemplate::setHasMorph(BOOL newval) +{ + mHasMorph = newval; + U32 num_wearables = updateWearableCache(); + for (U32 i = 0; i < num_wearables; i++) + { + LLTexLayer *layer = getLayer(i); + if (layer) + { + layer->setHasMorph(newval); + } + } +} + +/*virtual*/ void LLTexLayerTemplate::deleteCaches() +{ + U32 num_wearables = updateWearableCache(); + for (U32 i = 0; i < num_wearables; i++) + { + LLTexLayer *layer = getLayer(i); + if (layer) + { + layer->deleteCaches(); + } + } +} + +/*virtual*/ BOOL LLTexLayerTemplate::isInvisibleAlphaMask() const +{ + U32 num_wearables = updateWearableCache(); + for (U32 i = 0; i < num_wearables; i++) + { + LLTexLayer *layer = getLayer(i); + if (layer) + { + if (layer->isInvisibleAlphaMask()) + { + return TRUE; + } + } + } + + return FALSE; +} + + +//----------------------------------------------------------------------------- +// finds a specific layer based on a passed in name +//----------------------------------------------------------------------------- +LLTexLayerInterface* LLTexLayerSet::findLayerByName(const std::string& name) +{ + for (layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + if (layer->getName() == name) + { + return layer; + } + } + for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ ) + { + LLTexLayerInterface* layer = *iter; + if (layer->getName() == name) + { + return layer; + } + } + return NULL; +} + +void LLTexLayerSet::cloneTemplates(LLLocalTextureObject *lto, LLAvatarAppearanceDefines::ETextureIndex tex_index, LLWearable *wearable) +{ + // initialize all texlayers with this texture type for this LTO + for( LLTexLayerSet::layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) + { + LLTexLayerTemplate* layer = (LLTexLayerTemplate*)*iter; + if (layer->getInfo()->getLocalTexture() == (S32) tex_index) + { + lto->addTexLayer(layer, wearable); + } + } + for( LLTexLayerSet::layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ ) + { + LLTexLayerTemplate* layer = (LLTexLayerTemplate*)*iter; + if (layer->getInfo()->getLocalTexture() == (S32) tex_index) + { + lto->addTexLayer(layer, wearable); + } + } +} //----------------------------------------------------------------------------- // LLTexLayerStaticImageList //----------------------------------------------------------------------------- diff --git a/indra/llappearance/lltexlayer.h b/indra/llappearance/lltexlayer.h index 1e26dc488..f267753f2 100644 --- a/indra/llappearance/lltexlayer.h +++ b/indra/llappearance/lltexlayer.h @@ -44,7 +44,138 @@ class LLTexLayerInfo; class LLTexLayerSetBuffer; class LLWearable; class LLViewerVisualParam; -class LLLocalTextureObject; + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// LLTexLayerInterface +// +// Interface class to generalize functionality shared by LLTexLayer +// and LLTexLayerTemplate. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLTexLayerInterface +{ +public: + enum ERenderPass + { + RP_COLOR, + RP_BUMP, + RP_SHINE + }; + + LLTexLayerInterface(LLTexLayerSet* const layer_set); + LLTexLayerInterface(const LLTexLayerInterface &layer, LLWearable *wearable); + virtual ~LLTexLayerInterface() {} + + virtual BOOL render(S32 x, S32 y, S32 width, S32 height) = 0; + virtual void deleteCaches() = 0; + virtual BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) = 0; + virtual BOOL isInvisibleAlphaMask() const = 0; + + const LLTexLayerInfo* getInfo() const { return mInfo; } + virtual BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // sets mInfo, calls initialization functions + LLWearableType::EType getWearableType() const; + LLAvatarAppearanceDefines::ETextureIndex getLocalTextureIndex() const; + + const std::string& getName() const; + const LLTexLayerSet* const getTexLayerSet() const { return mTexLayerSet; } + LLTexLayerSet* const getTexLayerSet() { return mTexLayerSet; } + + void invalidateMorphMasks(); + virtual void setHasMorph(BOOL newval) { mHasMorph = newval; } + BOOL hasMorph() const { return mHasMorph; } + BOOL isMorphValid() const { return mMorphMasksValid; } + + void requestUpdate(); + virtual void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) = 0; + BOOL hasAlphaParams() const { return !mParamAlphaList.empty(); } + + ERenderPass getRenderPass() const; + BOOL isVisibilityMask() const; + + virtual void asLLSD(LLSD& sd) const {} + +protected: + const std::string& getGlobalColor() const; + LLViewerVisualParam* getVisualParamPtr(S32 index) const; + +protected: + LLTexLayerSet* const mTexLayerSet; + const LLTexLayerInfo* mInfo; + BOOL mMorphMasksValid; + BOOL mHasMorph; + + // Layers can have either mParamColorList, mGlobalColor, or mFixedColor. They are looked for in that order. + param_color_list_t mParamColorList; + param_alpha_list_t mParamAlphaList; + // mGlobalColor name stored in mInfo + // mFixedColor value stored in mInfo +}; + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// LLTexLayerTemplate +// +// Only exists for llvoavatarself. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLTexLayerTemplate : public LLTexLayerInterface +{ +public: + LLTexLayerTemplate(LLTexLayerSet* const layer_set, LLAvatarAppearance* const appearance); + LLTexLayerTemplate(const LLTexLayerTemplate &layer); + /*virtual*/ ~LLTexLayerTemplate(); + /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height); + /*virtual*/ BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // This sets mInfo and calls initialization functions + /*virtual*/ BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height); // Multiplies a single alpha texture against the frame buffer + /*virtual*/ void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height); + /*virtual*/ void setHasMorph(BOOL newval); + /*virtual*/ void deleteCaches(); + /*virtual*/ BOOL isInvisibleAlphaMask() const; +protected: + U32 updateWearableCache() const; + LLTexLayer* getLayer(U32 i) const; + LLAvatarAppearance* getAvatarAppearance() const { return mAvatarAppearance; } +private: + LLAvatarAppearance* const mAvatarAppearance; // note: backlink only; don't make this an LLPointer. + typedef std::vector wearable_cache_t; + mutable wearable_cache_t mWearableCache; // mutable b/c most get- require updating this cache +}; + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// LLTexLayer +// +// A single texture layer. Only exists for llvoavatarself. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLTexLayer : public LLTexLayerInterface +{ +public: + LLTexLayer(LLTexLayerSet* const layer_set); + LLTexLayer(const LLTexLayer &layer, LLWearable *wearable); + LLTexLayer(const LLTexLayerTemplate &layer_template, LLLocalTextureObject *lto, LLWearable *wearable); + /*virtual*/ ~LLTexLayer(); + + /*virtual*/ BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // This sets mInfo and calls initialization functions + /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height); + + /*virtual*/ void deleteCaches(); + const U8* getAlphaData() const; + + BOOL findNetColor(LLColor4* color) const; + /*virtual*/ BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height); // Multiplies a single alpha texture against the frame buffer + /*virtual*/ void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height); + BOOL renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLColor4 &layer_color); + void addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height); + /*virtual*/ BOOL isInvisibleAlphaMask() const; + + void setLTO(LLLocalTextureObject *lto) { mLocalTextureObject = lto; } + LLLocalTextureObject* getLTO() { return mLocalTextureObject; } + + /*virtual*/ void asLLSD(LLSD& sd) const; + + static void calculateTexLayerColor(const param_color_list_t ¶m_list, LLColor4 &net_color); +protected: + LLUUID getUUID() const; + typedef std::map alpha_cache_t; + alpha_cache_t mAlphaCache; + LLLocalTextureObject* mLocalTextureObject; +}; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLTexLayerSet @@ -57,41 +188,76 @@ class LLTexLayerSet friend class LLTexLayerSetBuffer; public: LLTexLayerSet(LLAvatarAppearance* const appearance); - virtual ~LLTexLayerSet() {}; + virtual ~LLTexLayerSet(); - virtual LLTexLayerSetBuffer* getComposite() = 0; - virtual const LLTexLayerSetBuffer* getComposite() const = 0; + LLTexLayerSetBuffer* getComposite(); + const LLTexLayerSetBuffer* getComposite() const; // Do not create one if it doesn't exist. virtual void createComposite() = 0; - virtual void destroyComposite() = 0; - virtual void gatherMorphMaskAlpha(U8 *data, S32 width, S32 height) = 0; + void destroyComposite(); + void gatherMorphMaskAlpha(U8 *data, S32 origin_x, S32 origin_y, S32 width, S32 height); - virtual const LLTexLayerSetInfo* getInfo() const = 0; - virtual BOOL setInfo(const LLTexLayerSetInfo *info) = 0; + const LLTexLayerSetInfo* getInfo() const { return mInfo; } + BOOL setInfo(const LLTexLayerSetInfo *info); // This sets mInfo and calls initialization functions - virtual BOOL render(S32 x, S32 y, S32 width, S32 height) = 0; - virtual void renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear = false) = 0; - - virtual BOOL isBodyRegion(const std::string& region) const = 0; - virtual void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components) = 0; - virtual BOOL isMorphValid() const = 0; - virtual void requestUpdate() = 0; - virtual void invalidateMorphMasks() = 0; - virtual void deleteCaches() = 0; - virtual LLTexLayerInterface* findLayerByName(const std::string& name) = 0; - virtual void cloneTemplates(LLLocalTextureObject *lto, LLAvatarAppearanceDefines::ETextureIndex tex_index, LLWearable* wearable) = 0; + BOOL render(S32 x, S32 y, S32 width, S32 height); + void renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear = false); + BOOL isBodyRegion(const std::string& region) const; + void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components); + BOOL isMorphValid() const; + virtual void requestUpdate() = 0; + void invalidateMorphMasks(); + void deleteCaches(); + LLTexLayerInterface* findLayerByName(const std::string& name); + void cloneTemplates(LLLocalTextureObject *lto, LLAvatarAppearanceDefines::ETextureIndex tex_index, LLWearable* wearable); + LLAvatarAppearance* getAvatarAppearance() const { return mAvatarAppearance; } - virtual const std::string getBodyRegionName() const = 0; - virtual BOOL hasComposite() const = 0; - virtual LLAvatarAppearanceDefines::EBakedTextureIndex getBakedTexIndex() const = 0; - virtual void setBakedTexIndex(LLAvatarAppearanceDefines::EBakedTextureIndex index) = 0; - virtual BOOL isVisible() const = 0; + const std::string getBodyRegionName() const; + BOOL hasComposite() const { return (mComposite.notNull()); } + LLAvatarAppearanceDefines::EBakedTextureIndex getBakedTexIndex() const { return mBakedTexIndex; } + void setBakedTexIndex(LLAvatarAppearanceDefines::EBakedTextureIndex index) { mBakedTexIndex = index; } + BOOL isVisible() const { return mIsVisible; } static BOOL sHasCaches; + virtual void asLLSD(LLSD& sd) const; + +protected: + typedef std::vector layer_list_t; + layer_list_t mLayerList; + layer_list_t mMaskLayerList; + LLPointer mComposite; LLAvatarAppearance* const mAvatarAppearance; // note: backlink only; don't make this an LLPointer. + BOOL mIsVisible; + + LLAvatarAppearanceDefines::EBakedTextureIndex mBakedTexIndex; + const LLTexLayerSetInfo* mInfo; }; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// LLTexLayerSetInfo +// +// Contains shared layer set data. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLTexLayerSetInfo +{ + friend class LLTexLayerSet; +public: + LLTexLayerSetInfo(); + ~LLTexLayerSetInfo(); + BOOL parseXml(LLXmlTreeNode* node); + void createVisualParams(LLAvatarAppearance *appearance); + S32 getWidth() const { return mWidth; } + S32 getHeight() const { return mHeight; } +protected: + std::string mBodyRegion; + S32 mWidth; + S32 mHeight; + std::string mStaticAlphaFileName; + BOOL mClearAlpha; // Set alpha to 1 for this layerset (if there is no mStaticAlphaFileName) + typedef std::vector layer_info_list_t; + layer_info_list_t mLayerInfoList; +}; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLTexLayerSetBuffer @@ -103,8 +269,21 @@ class LLTexLayerSetBuffer : public virtual LLRefCount LOG_CLASS(LLTexLayerSetBuffer); public: - LLTexLayerSetBuffer(LLTexLayerSet* const owner) : mTexLayerSet(owner) {}; - virtual ~LLTexLayerSetBuffer() {} + LLTexLayerSetBuffer(LLTexLayerSet* const owner); + virtual ~LLTexLayerSetBuffer(); + +protected: + void pushProjection() const; + void popProjection() const; + virtual void preRenderTexLayerSet(); + virtual void midRenderTexLayerSet(BOOL success) {} + virtual void postRenderTexLayerSet(BOOL success); + virtual S32 getCompositeOriginX() const = 0; + virtual S32 getCompositeOriginY() const = 0; + virtual S32 getCompositeWidth() const = 0; + virtual S32 getCompositeHeight() const = 0; + BOOL renderTexLayerSet(); + LLTexLayerSet* const mTexLayerSet; }; diff --git a/indra/llappearance/lltexlayerparams.cpp b/indra/llappearance/lltexlayerparams.cpp index d36b00429..dfbdc3207 100644 --- a/indra/llappearance/lltexlayerparams.cpp +++ b/indra/llappearance/lltexlayerparams.cpp @@ -33,14 +33,12 @@ #include "llquantize.h" #include "lltexlayer.h" #include "lltexturemanagerbridge.h" -//#include "llui.h" -//#include "llwearable.h" -#include "llgltexture.h" +#include "llwearable.h" //----------------------------------------------------------------------------- // LLTexLayerParam //----------------------------------------------------------------------------- -LLTexLayerParam::LLTexLayerParam(LLTexLayerInterfaceTMP *layer) : +LLTexLayerParam::LLTexLayerParam(LLTexLayerInterface *layer) : mTexLayer(layer), mAvatarAppearance(NULL) { @@ -68,6 +66,7 @@ BOOL LLTexLayerParam::setInfo(LLViewerVisualParamInfo *info, BOOL add_to_appeara if (add_to_appearance) { mAvatarAppearance->addVisualParam( this); + this->setParamLocation(mAvatarAppearance->isSelf() ? LOC_AV_SELF : LOC_AV_OTHER); } return TRUE; @@ -111,7 +110,7 @@ void LLTexLayerParamAlpha::getCacheByteCount(S32* gl_bytes) } } -LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLTexLayerInterfaceTMP* layer) : +LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLTexLayerInterface* layer) : LLTexLayerParam(layer), mCachedProcessedTexture(NULL), mNeedsCreateTexture(FALSE), @@ -240,8 +239,7 @@ BOOL LLTexLayerParamAlpha::getSkip() const return FALSE; } -void gl_rect_2d_simple_tex( S32 width, S32 height ); -void gl_rect_2d_simple( S32 width, S32 height ); + static LLFastTimer::DeclareTimer FTM_TEX_LAYER_PARAM_ALPHA("alpha render"); BOOL LLTexLayerParamAlpha::render(S32 x, S32 y, S32 width, S32 height) @@ -403,7 +401,7 @@ BOOL LLTexLayerParamAlphaInfo::parseXml(LLXmlTreeNode* node) -LLTexLayerParamColor::LLTexLayerParamColor(LLTexLayerInterfaceTMP* layer) : +LLTexLayerParamColor::LLTexLayerParamColor(LLTexLayerInterface* layer) : LLTexLayerParam(layer), mAvgDistortionVec(1.f, 1.f, 1.f) { diff --git a/indra/llappearance/lltexlayerparams.h b/indra/llappearance/lltexlayerparams.h index fcbcea232..0a16b6d07 100644 --- a/indra/llappearance/lltexlayerparams.h +++ b/indra/llappearance/lltexlayerparams.h @@ -38,15 +38,11 @@ class LLTexLayer; class LLTexLayerInterface; class LLGLTexture; class LLWearable; -class LLTexLayerSet; -class LLTexLayerInterfaceTMP -{ -public: - virtual const LLTexLayerSet* const getTexLayerSet() const = 0; - virtual LLTexLayerSet* const getTexLayerSet() = 0; - virtual void invalidateMorphMasks() = 0; -}; +//Temporary externs +void gl_rect_2d_simple_tex( S32 width, S32 height ); +void gl_rect_2d_simple( S32 width, S32 height ); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLTexLayerParam // @@ -54,13 +50,13 @@ public: class LLTexLayerParam : public LLViewerVisualParam { public: - LLTexLayerParam(LLTexLayerInterfaceTMP *layer); + LLTexLayerParam(LLTexLayerInterface *layer); LLTexLayerParam(LLAvatarAppearance *appearance); /*virtual*/ BOOL setInfo(LLViewerVisualParamInfo *info, BOOL add_to_appearance); /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const = 0; protected: - LLTexLayerInterfaceTMP* mTexLayer; + LLTexLayerInterface* mTexLayer; LLAvatarAppearance* mAvatarAppearance; }; @@ -71,7 +67,7 @@ protected: class LLTexLayerParamAlpha : public LLTexLayerParam { public: - LLTexLayerParamAlpha( LLTexLayerInterfaceTMP* layer ); + LLTexLayerParamAlpha( LLTexLayerInterface* layer ); LLTexLayerParamAlpha( LLAvatarAppearance* appearance ); /*virtual*/ ~LLTexLayerParamAlpha(); @@ -159,7 +155,7 @@ public: OP_COUNT = 3 // Number of operations }; - LLTexLayerParamColor( LLTexLayerInterfaceTMP* layer ); + LLTexLayerParamColor( LLTexLayerInterface* layer ); LLTexLayerParamColor( LLAvatarAppearance* appearance ); /* virtual */ ~LLTexLayerParamColor(); diff --git a/indra/llappearance/llviewervisualparam.cpp b/indra/llappearance/llviewervisualparam.cpp index 0c3d1fef8..dd5331207 100644 --- a/indra/llappearance/llviewervisualparam.cpp +++ b/indra/llappearance/llviewervisualparam.cpp @@ -31,8 +31,7 @@ #include "llviewervisualparam.h" #include "llxmltree.h" -//#include "llui.h" -#include "llwearabletype.h" +#include "llwearable.h" //----------------------------------------------------------------------------- // LLViewerVisualParamInfo() diff --git a/indra/llappearance/llwearable.h b/indra/llappearance/llwearable.h new file mode 100644 index 000000000..ccd4c2057 --- /dev/null +++ b/indra/llappearance/llwearable.h @@ -0,0 +1,71 @@ +/** + * @file llwearable.h + * @brief LLWearable class header file + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * 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. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLWEARABLE_H +#define LL_LLWEARABLE_H + +#include "llavatarappearancedefines.h" +#include "llextendedstatus.h" +#include "llpermissions.h" +#include "llsaleinfo.h" +#include "llwearabletype.h" +#include "lllocaltextureobject.h" + +class LLMD5; +class LLVisualParam; +class LLTexGlobalColorInfo; +class LLTexGlobalColor; +class LLAvatarAppearance; + +// Abstract class. +class LLWearable +{ + //-------------------------------------------------------------------- + // Constructors and destructors + //-------------------------------------------------------------------- +public: + virtual ~LLWearable() {}; + + //-------------------------------------------------------------------- + // Accessors + //-------------------------------------------------------------------- +public: + virtual LLWearableType::EType getType() const = 0; + virtual void writeToAvatar(LLAvatarAppearance* avatarp) = 0; + virtual LLLocalTextureObject* getLocalTextureObject(S32 index) = 0; + virtual const LLLocalTextureObject* getLocalTextureObject(S32 index) const = 0; + virtual void setVisualParamWeight(S32 index, F32 value, BOOL upload_bake) = 0; + virtual F32 getVisualParamWeight(S32 index) const = 0; + virtual LLVisualParam* getVisualParam(S32 index) const = 0; + + // Something happened that requires the wearable to be updated (e.g. worn/unworn). + virtual void setUpdated() const = 0; + + // Update the baked texture hash. + virtual void addToBakedTextureHash(LLMD5& hash) const = 0; +}; + +#endif // LL_LLWEARABLE_H diff --git a/indra/llappearance/llwearabledata.cpp b/indra/llappearance/llwearabledata.cpp new file mode 100644 index 000000000..f3ddfcb2f --- /dev/null +++ b/indra/llappearance/llwearabledata.cpp @@ -0,0 +1,363 @@ +/** + * @file llwearabledata.cpp + * @brief LLWearableData class implementation + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * 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. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llwearabledata.h" + +#include "llavatarappearance.h" +#include "llavatarappearancedefines.h" +#include "lldriverparam.h" +#include "llmd5.h" + +LLWearableData::LLWearableData() : + mAvatarAppearance(NULL) +{ +} + +// virtual +LLWearableData::~LLWearableData() +{ +} + +using namespace LLAvatarAppearanceDefines; + +LLWearable* LLWearableData::getWearable(const LLWearableType::EType type, U32 index) +{ + //llassert_always(index == 0); + wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) + { + return NULL; + } + wearableentry_vec_t& wearable_vec = wearable_iter->second; + if (index>=wearable_vec.size()) + { + return NULL; + } + else + { + return wearable_vec[index]; + } +} + +void LLWearableData::setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable) +{ + //llassert_always(index == 0); + LLWearable *old_wearable = getWearable(type,index); + if (!old_wearable) + { + pushWearable(type,wearable); + return; + } + + wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) + { + llwarns << "invalid type, type " << type << " index " << index << llendl; + return; + } + wearableentry_vec_t& wearable_vec = wearable_iter->second; + if (index>=wearable_vec.size()) + { + llwarns << "invalid index, type " << type << " index " << index << llendl; + } + else + { + wearable_vec[index] = wearable; + old_wearable->setUpdated(); + const BOOL removed = FALSE; + wearableUpdated(wearable, removed); + } +} + +U32 LLWearableData::pushWearable(const LLWearableType::EType type, + LLWearable *wearable) +{ + if (wearable == NULL) + { + // no null wearables please! + llwarns << "Null wearable sent for type " << type << llendl; + return MAX_CLOTHING_PER_TYPE; + } +// if (type < LLWearableType::WT_COUNT || mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) +// { +// mWearableDatas[type].push_back(wearable); +// wearableUpdated(wearable); +// checkWearableAgainstInventory(wearable); +// return mWearableDatas[type].size()-1; +// } +// [RLVa:KB] - Checked: 2010-06-08 (RLVa-1.2.0g) | Added: RLVa-1.2.0g + if ( (type < LLWearableType::WT_COUNT) && (mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) ) + { + // Don't add the same wearable twice + U32 idxWearable = getWearableIndex(wearable); + //RLV_ASSERT(MAX_CLOTHING_PER_TYPE == idxWearable); // pushWearable() on an already added wearable is a bug *somewhere* + if (MAX_CLOTHING_PER_TYPE == idxWearable) + { + mWearableDatas[type].push_back(wearable); + idxWearable = mWearableDatas[type].size() - 1; + } + const BOOL removed = FALSE; + wearableUpdated(wearable, removed); + return idxWearable; +// [/RLVa:KB] + } + return MAX_CLOTHING_PER_TYPE; +} + +// virtual +void LLWearableData::wearableUpdated(LLWearable *wearable, BOOL removed) +{ + wearable->setUpdated(); + // FIXME DRANO avoid updating params via wearables when rendering server-baked appearance. +#if 0 + if (mAvatarAppearance->isUsingServerBakes() && !mAvatarAppearance->isUsingLocalAppearance()) + { + return; + } +#endif + if (!removed) + { + pullCrossWearableValues(wearable->getType()); + } +} + +void LLWearableData::popWearable(LLWearable *wearable) +{ + if (wearable == NULL) + { + // nothing to do here. move along. + return; + } + + U32 index = getWearableIndex(wearable); + const LLWearableType::EType type = wearable->getType(); + + if (index < MAX_CLOTHING_PER_TYPE && index < getWearableCount(type)) + { + popWearable(type, index); + } +} + +void LLWearableData::popWearable(const LLWearableType::EType type, U32 index) +{ + //llassert_always(index == 0); + LLWearable *wearable = getWearable(type, index); + if (wearable) + { + mWearableDatas[type].erase(mWearableDatas[type].begin() + index); + const BOOL removed = TRUE; + wearableUpdated(wearable, removed); + } +} + +bool LLWearableData::swapWearables(const LLWearableType::EType type, U32 index_a, U32 index_b) +{ + wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) + { + return false; + } + + wearableentry_vec_t& wearable_vec = wearable_iter->second; + if (0 > index_a || index_a >= wearable_vec.size()) return false; + if (0 > index_b || index_b >= wearable_vec.size()) return false; + + LLWearable* wearable = wearable_vec[index_a]; + wearable_vec[index_a] = wearable_vec[index_b]; + wearable_vec[index_b] = wearable; + return true; +} + +void LLWearableData::pullCrossWearableValues(const LLWearableType::EType type) +{ + llassert(mAvatarAppearance); + // scan through all of the avatar's visual parameters + for (LLViewerVisualParam* param = (LLViewerVisualParam*) mAvatarAppearance->getFirstVisualParam(); + param; + param = (LLViewerVisualParam*) mAvatarAppearance->getNextVisualParam()) + { + if( param ) + { + LLDriverParam *driver_param = dynamic_cast(param); + if(driver_param) + { + // parameter is a driver parameter, have it update its cross-driven params + driver_param->updateCrossDrivenParams(type); + } + } + } +} + + +U32 LLWearableData::getWearableIndex(const LLWearable *wearable) const +{ + if (wearable == NULL) + { + return MAX_CLOTHING_PER_TYPE; + } + + const LLWearableType::EType type = wearable->getType(); + wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) + { + llwarns << "tried to get wearable index with an invalid type!" << llendl; + return MAX_CLOTHING_PER_TYPE; + } + const wearableentry_vec_t& wearable_vec = wearable_iter->second; + for(U32 index = 0; index < wearable_vec.size(); index++) + { + if (wearable_vec[index] == wearable) + { + return index; + } + } + + return MAX_CLOTHING_PER_TYPE; +} + +BOOL LLWearableData::isOnTop(LLWearable* wearable) const +{ + if (!wearable) return FALSE; + const LLWearableType::EType type = wearable->getType(); + return ( getTopWearable(type) == wearable ); +} + +const LLWearable* LLWearableData::getWearable(const LLWearableType::EType type, U32 index) const +{ + //llassert_always(index == 0); + wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) + { + return NULL; + } + const wearableentry_vec_t& wearable_vec = wearable_iter->second; + if (index>=wearable_vec.size()) + { + return NULL; + } + else + { + return wearable_vec[index]; + } +} + +LLWearable* LLWearableData::getTopWearable(const LLWearableType::EType type) +{ + U32 count = getWearableCount(type); + if ( count == 0) + { + return NULL; + } + + return getWearable(type, count-1); +} + +const LLWearable* LLWearableData::getTopWearable(const LLWearableType::EType type) const +{ + U32 count = getWearableCount(type); + if ( count == 0) + { + return NULL; + } + + return getWearable(type, count-1); +} + +LLWearable* LLWearableData::getBottomWearable(const LLWearableType::EType type) +{ + if (getWearableCount(type) == 0) + { + return NULL; + } + + return getWearable(type, 0); +} + +const LLWearable* LLWearableData::getBottomWearable(const LLWearableType::EType type) const +{ + if (getWearableCount(type) == 0) + { + return NULL; + } + + return getWearable(type, 0); +} + +U32 LLWearableData::getWearableCount(const LLWearableType::EType type) const +{ + wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); + if (wearable_iter == mWearableDatas.end()) + { + return 0; + } + const wearableentry_vec_t& wearable_vec = wearable_iter->second; + return wearable_vec.size(); +} + +U32 LLWearableData::getWearableCount(const U32 tex_index) const +{ + const LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getTEWearableType((LLAvatarAppearanceDefines::ETextureIndex)tex_index); + return getWearableCount(wearable_type); +} + +LLUUID LLWearableData::computeBakedTextureHash(LLAvatarAppearanceDefines::EBakedTextureIndex baked_index, + BOOL generate_valid_hash) // Set to false if you want to upload the baked texture w/o putting it in the cache +{ + LLUUID hash_id; + bool hash_computed = false; + LLMD5 hash; + const LLAvatarAppearanceDictionary::BakedEntry *baked_dict = LLAvatarAppearanceDictionary::getInstance()->getBakedTexture(baked_index); + + for (U8 i=0; i < baked_dict->mWearables.size(); i++) + { + const LLWearableType::EType baked_type = baked_dict->mWearables[i]; + const U32 num_wearables = getWearableCount(baked_type); + for (U32 index = 0; index < num_wearables; ++index) + { + const LLWearable* wearable = getWearable(baked_type,index); + if (wearable) + { + wearable->addToBakedTextureHash(hash); + hash_computed = true; + } + } + } + if (hash_computed) + { + hash.update((const unsigned char*)baked_dict->mWearablesHashID.mData, UUID_BYTES); + + if (!generate_valid_hash) + { + invalidateBakedTextureHash(hash); + } + hash.finalize(); + hash.raw_digest(hash_id.mData); + } + + return hash_id; +} \ No newline at end of file diff --git a/indra/llappearance/llwearabledata.h b/indra/llappearance/llwearabledata.h new file mode 100644 index 000000000..c3f80a72d --- /dev/null +++ b/indra/llappearance/llwearabledata.h @@ -0,0 +1,106 @@ +/** + * @file llwearabledata.h + * @brief LLWearableData class header file + * + * $LicenseInfo:firstyear=20012license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * 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. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_WEARABLEDATA_H +#define LL_WEARABLEDATA_H + +#include "llavatarappearancedefines.h" +#include "llwearable.h" +#include "llerror.h" + +class LLAvatarAppearance; + +class LLWearableData +{ + // *TODO: Figure out why this is causing compile error. + //LOG_CLASS(LLWearableData); + + //-------------------------------------------------------------------- + // Constructors / destructors / Initializers + //-------------------------------------------------------------------- +public: + LLWearableData(); + virtual ~LLWearableData(); + + void setAvatarAppearance(LLAvatarAppearance* appearance) { mAvatarAppearance = appearance; } + +protected: + //-------------------------------------------------------------------- + // Accessors + //-------------------------------------------------------------------- +public: + LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/); + const LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const; + LLWearable* getTopWearable(const LLWearableType::EType type); + const LLWearable* getTopWearable(const LLWearableType::EType type) const; + LLWearable* getBottomWearable(const LLWearableType::EType type); + const LLWearable* getBottomWearable(const LLWearableType::EType type) const; + U32 getWearableCount(const LLWearableType::EType type) const; + U32 getWearableCount(const U32 tex_index) const; + U32 getWearableIndex(const LLWearable *wearable) const; + + BOOL isOnTop(LLWearable* wearable) const; + + static const U32 MAX_CLOTHING_PER_TYPE = 5; + + //-------------------------------------------------------------------- + // Setters + //-------------------------------------------------------------------- +protected: + // Low-level data structure setter - public access is via setWearableItem, etc. + void setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable); + U32 pushWearable(const LLWearableType::EType type, LLWearable *wearable); + virtual void wearableUpdated(LLWearable *wearable, BOOL removed) = 0; + void popWearable(LLWearable *wearable); + void popWearable(const LLWearableType::EType type, U32 index); + bool swapWearables(const LLWearableType::EType type, U32 index_a, U32 index_b); + +private: + void pullCrossWearableValues(const LLWearableType::EType type); + + //-------------------------------------------------------------------- + // Server Communication + //-------------------------------------------------------------------- +public: + LLUUID computeBakedTextureHash(LLAvatarAppearanceDefines::EBakedTextureIndex baked_index, + BOOL generate_valid_hash = TRUE); +protected: + virtual void invalidateBakedTextureHash(LLMD5& hash) const = 0; + + //-------------------------------------------------------------------- + // Member variables + //-------------------------------------------------------------------- +protected: + LLAvatarAppearance* mAvatarAppearance; + typedef std::vector wearableentry_vec_t; // all wearables of a certain type (EG all shirts) + typedef std::map wearableentry_map_t; // wearable "categories" arranged by wearable type + wearableentry_map_t mWearableDatas; + +}; + + + +#endif // LL_WEARABLEDATA_H \ No newline at end of file diff --git a/indra/llcharacter/llvisualparam.cpp b/indra/llcharacter/llvisualparam.cpp index 809b312ab..1a724e471 100644 --- a/indra/llcharacter/llvisualparam.cpp +++ b/indra/llcharacter/llvisualparam.cpp @@ -168,7 +168,8 @@ LLVisualParam::LLVisualParam() mIsAnimating( FALSE ), mID( -1 ), mInfo( 0 ), - mIsDummy(FALSE) + mIsDummy(FALSE), + mParamLocation(LOC_UNKNOWN) { } @@ -319,3 +320,32 @@ void LLVisualParam::resetDrivenParams() // nothing to do for non-driver parameters return; } + +const std::string param_location_name(const EParamLocation& loc) +{ + switch (loc) + { + case LOC_UNKNOWN: return "unknown"; + case LOC_AV_SELF: return "self"; + case LOC_AV_OTHER: return "other"; + case LOC_WEARABLE: return "wearable"; + default: return "error"; + } +} + +void LLVisualParam::setParamLocation(EParamLocation loc) +{ + if (mParamLocation == LOC_UNKNOWN || loc == LOC_UNKNOWN) + { + mParamLocation = loc; + } + else if (mParamLocation == loc) + { + // no action + } + else + { + lldebugs << "param location is already " << mParamLocation << ", not slamming to " << loc << llendl; + } +} + diff --git a/indra/llcharacter/llvisualparam.h b/indra/llcharacter/llvisualparam.h index 694e27f37..a5864c15c 100644 --- a/indra/llcharacter/llvisualparam.h +++ b/indra/llcharacter/llvisualparam.h @@ -50,6 +50,16 @@ enum EVisualParamGroup NUM_VISUAL_PARAM_GROUPS }; +enum EParamLocation +{ + LOC_UNKNOWN, + LOC_AV_SELF, + LOC_AV_OTHER, + LOC_WEARABLE +}; + +const std::string param_location_name(const EParamLocation& loc); + const S32 MAX_TRANSMITTED_VISUAL_PARAMS = 255; //----------------------------------------------------------------------------- @@ -149,6 +159,9 @@ public: void setIsDummy(BOOL is_dummy) { mIsDummy = is_dummy; } + void setParamLocation(EParamLocation loc); + EParamLocation getParamLocation() const { return mParamLocation; } + protected: F32 mCurWeight; // current weight F32 mLastWeight; // last weight @@ -160,6 +173,7 @@ protected: S32 mID; // id for storing weight/morphtarget compares compactly LLVisualParamInfo *mInfo; + EParamLocation mParamLocation; // where does this visual param live? }; #endif // LL_LLVisualParam_H diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 2f64b0c9f..dde798f4d 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -166,5 +166,7 @@ public: extern LLGLSLShader gUIProgram; //output vec4(color.rgb,color.a*tex0[tc0].a) extern LLGLSLShader gSolidColorProgram; +//Alpha mask shader (declared here so llappearance can access properly) +extern LLGLSLShader gAlphaMaskProgram; #endif diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 70e4c62e5..eb575bf76 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -153,7 +153,6 @@ set(viewer_SOURCE_FILES lldrawpooltree.cpp lldrawpoolwater.cpp lldrawpoolwlsky.cpp - lldriverparam.cpp lldroptarget.cpp lldynamictexture.cpp llemote.cpp @@ -299,7 +298,6 @@ set(viewer_SOURCE_FILES lljoystickbutton.cpp lllandmarklist.cpp lllocalinventory.cpp - lllocaltextureobject.cpp lllogchat.cpp llloginhandler.cpp llmainlooprepeater.cpp @@ -509,6 +507,7 @@ set(viewer_SOURCE_FILES llviewertextureanim.cpp llviewertexturelist.cpp llviewerthrottle.cpp + llviewerwearable.cpp llviewerwindow.cpp llvlcomposition.cpp llvlmanager.cpp @@ -532,7 +531,6 @@ set(viewer_SOURCE_FILES llwatchdog.cpp llwaterparammanager.cpp llwaterparamset.cpp - llwearable.cpp llwearablelist.cpp llweb.cpp llwebprofile.cpp @@ -654,7 +652,6 @@ set(viewer_HEADER_FILES lldrawpooltree.h lldrawpoolwater.h lldrawpoolwlsky.h - lldriverparam.h lldroptarget.h lldynamictexture.h llemote.h @@ -800,7 +797,6 @@ set(viewer_HEADER_FILES lllandmarklist.h lllightconstants.h lllocalinventory.h - lllocaltextureobject.h lllogchat.h llloginhandler.h llmainlooprepeater.h @@ -1014,6 +1010,7 @@ set(viewer_HEADER_FILES llviewertextureanim.h llviewertexturelist.h llviewerthrottle.h + llviewerwearable.h llviewerwindow.h llvlcomposition.h llvlmanager.h @@ -1038,7 +1035,6 @@ set(viewer_HEADER_FILES llwatchdog.h llwaterparammanager.h llwaterparamset.h - llwearable.h llwearablelist.h llweb.h llwebprofile.h diff --git a/indra/newview/importtracker.cpp b/indra/newview/importtracker.cpp index ce2e6bb1e..d1a8baf9b 100644 --- a/indra/newview/importtracker.cpp +++ b/indra/newview/importtracker.cpp @@ -642,7 +642,7 @@ void ImportTracker::send_inventory(LLSD& prim) LLFILE* fp = LLFile::fopen(data->filename, "rb"); if(fp)//HACK LOL LOL LOL { - LLWearable* wearable = new LLWearable(LLUUID::null); + LLViewerWearable* wearable = new LLWearable(LLUUID::null); wearable->importFile( fp ); //if (!res) { diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 481719402..1e886ce7a 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1114,8 +1114,8 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) if (!isAgentAvatarValid()) return; - LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation(); - LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation(); + LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation(); + LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation(); if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) && (root_at * last_at_axis > 0.95f)) @@ -1477,7 +1477,7 @@ void LLAgentCamera::updateCamera() LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation(); LLVector3 diff = mCameraPositionAgent - head_pos; - diff = diff * ~gAgentAvatarp->mRoot.getWorldRotation(); + diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation(); LLJoint* torso_joint = gAgentAvatarp->mTorsop; LLJoint* chest_joint = gAgentAvatarp->mChestp; @@ -1501,7 +1501,7 @@ void LLAgentCamera::updateCamera() gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff); - gAgentAvatarp->mRoot.updateWorldMatrixChildren(); + gAgentAvatarp->mRoot->updateWorldMatrixChildren(); for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); iter != gAgentAvatarp->mAttachmentPoints.end(); ) @@ -1762,7 +1762,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) F32 camera_land_height; LLVector3d frame_center_global = !isAgentAvatarValid() ? gAgent.getPositionGlobal() : - gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot.getWorldPosition()); + gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition()); BOOL isConstrained = FALSE; LLVector3d head_offset; @@ -2354,7 +2354,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) //----------------------------------------------------------------------------- void LLAgentCamera::changeCameraToCustomizeAvatar() { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) + if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid()) { return; } diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index c13b38a68..27044e30d 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -95,7 +95,7 @@ class LLWearAndEditCallback : public LLInventoryCallback // wearable type stored in asset is some other value. // Calling this function whenever a wearable is added to increase visibility if this problem // turns up in other inventories. -void checkWearableAgainstInventory(LLWearable *wearable) +void checkWearableAgainstInventory(LLViewerWearable *wearable) { if (wearable->getItemID().isNull()) return; @@ -132,7 +132,7 @@ void LLAgentWearables::dump() llinfos << "Type: " << i << " count " << count << llendl; for (U32 j=0; joutputRezTiming("Sending wearables request"); sendAgentWearablesRequest(); + setAvatarAppearance(avatar); } } @@ -226,7 +229,7 @@ LLAgentWearables::sendAgentWearablesUpdateCallback::~sendAgentWearablesUpdateCal * @param todo Bitmask of actions to take on completion. */ LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInventoryCallback( - LLPointer cb, LLWearableType::EType type, U32 index, LLWearable* wearable, U32 todo) : + LLPointer cb, LLWearableType::EType type, U32 index, LLViewerWearable* wearable, U32 todo) : mType(type), mIndex(index), mWearable(wearable), @@ -279,7 +282,7 @@ void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& i void LLAgentWearables::addWearabletoAgentInventoryDone(const LLWearableType::EType type, const U32 index, const LLUUID& item_id, - LLWearable* wearable) + LLViewerWearable* wearable) { llinfos << "type " << type << " index " << index << " item " << item_id.asString() << llendl; @@ -326,7 +329,7 @@ void LLAgentWearables::sendAgentWearablesUpdate() { for (U32 index=0; index < getWearableCount((LLWearableType::EType)type); ++index) { - LLWearable* wearable = getWearable((LLWearableType::EType)type,index); + LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)type,index); if (wearable) { if (wearable->getItemID().isNull()) @@ -368,7 +371,7 @@ void LLAgentWearables::sendAgentWearablesUpdate() U8 type_u8 = (U8)type; gMessageSystem->addU8Fast(_PREHASH_WearableType, type_u8 ); - LLWearable* wearable = getWearable((LLWearableType::EType)type, 0); + LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)type, 0); if( wearable ) { //llinfos << "Sending wearable " << wearable->getName() << llendl; @@ -397,14 +400,14 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32 const std::string new_name) { //llassert_always(index == 0); - LLWearable* old_wearable = getWearable(type, index); + LLViewerWearable* old_wearable = getViewerWearable(type, index); if(!old_wearable) return; bool name_changed = !new_name.empty() && (new_name != old_wearable->getName()); if (name_changed || old_wearable->isDirty() || old_wearable->isOldVersion()) { LLUUID old_item_id = old_wearable->getItemID(); - LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable); - new_wearable->setItemID(old_item_id); // should this be in LLWearable::copyDataFrom()? + LLViewerWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable); + new_wearable->setItemID(old_item_id); // should this be in LLViewerWearable::copyDataFrom()? setWearable(type,index,new_wearable); // old_wearable may still be referred to by other inventory items. Revert @@ -470,7 +473,7 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32 } } -LLWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType type, +LLViewerWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, BOOL save_in_lost_and_found) @@ -480,7 +483,7 @@ LLWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType type, llwarns << "LLAgent::saveWearableAs() not copyable." << llendl; return NULL; } - LLWearable* old_wearable = getWearable(type, index); + LLViewerWearable* old_wearable = getViewerWearable(type, index); if (!old_wearable) { llwarns << "LLAgent::saveWearableAs() no old wearable." << llendl; @@ -495,7 +498,7 @@ LLWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType type, } std::string trunc_name(new_name); LLStringUtil::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN); - LLWearable* new_wearable = LLWearableList::instance().createCopy( + LLViewerWearable* new_wearable = LLWearableList::instance().createCopy( old_wearable, trunc_name); LLPointer cb = @@ -534,7 +537,7 @@ LLWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType type, void LLAgentWearables::revertWearable(const LLWearableType::EType type, const U32 index) { - LLWearable* wearable = getWearable(type, index); + LLViewerWearable* wearable = getViewerWearable(type, index); llassert(wearable); if (wearable) { @@ -551,7 +554,7 @@ void LLAgentWearables::saveAllWearables() // return; //} - for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) + for (S32 i=0; i < LLWearableType::WT_COUNT; i++) { for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++) saveWearable((LLWearableType::EType)i, j, FALSE); @@ -559,23 +562,23 @@ void LLAgentWearables::saveAllWearables() sendAgentWearablesUpdate(); } -// Called when the user changes the name of a wearable inventory item that is currenlty being worn. -void LLAgentWearables::setWearableName( const LLUUID& item_id, const std::string& new_name ) +// Called when the user changes the name of a wearable inventory item that is currently being worn. +void LLAgentWearables::setWearableName(const LLUUID& item_id, const std::string& new_name) { - for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) + for (S32 i=0; i < LLWearableType::WT_COUNT; i++) { for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++) { LLUUID curr_item_id = getWearableItemID((LLWearableType::EType)i,j); if (curr_item_id == item_id) { - LLWearable* old_wearable = getWearable((LLWearableType::EType)i,j); + LLViewerWearable* old_wearable = getViewerWearable((LLWearableType::EType)i,j); llassert(old_wearable); if (!old_wearable) continue; std::string old_name = old_wearable->getName(); old_wearable->setName(new_name); - LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable); + LLViewerWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable); new_wearable->setItemID(item_id); LLInventoryItem* item = gInventory.getItem(item_id); if (item) @@ -659,14 +662,14 @@ LLInventoryItem* LLAgentWearables::getWearableInventoryItem(LLWearableType::ETyp return item; } -const LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) const +const LLViewerWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) const { const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id); for (S32 i=0; i < LLWearableType::WT_COUNT; i++) { for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++) { - const LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j); + const LLViewerWearable * curr_wearable = getViewerWearable((LLWearableType::EType)i, j); if (curr_wearable && (curr_wearable->getItemID() == base_item_id)) { return curr_wearable; @@ -676,14 +679,14 @@ const LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id return NULL; } -LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) +LLViewerWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id) { const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id); for (S32 i=0; i < LLWearableType::WT_COUNT; i++) { for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++) { - LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j); + LLViewerWearable * curr_wearable = getViewerWearable((LLWearableType::EType)i, j); if (curr_wearable && (curr_wearable->getItemID() == base_item_id)) { return curr_wearable; @@ -693,13 +696,13 @@ LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) return NULL; } -LLWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id) +LLViewerWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id) { for (S32 i=0; i < LLWearableType::WT_COUNT; i++) { for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++) { - LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j); + LLViewerWearable * curr_wearable = getViewerWearable((LLWearableType::EType)i, j); if (curr_wearable && (curr_wearable->getAssetID() == asset_id)) { return curr_wearable; @@ -718,240 +721,63 @@ void LLAgentWearables::sendAgentWearablesRequest() gAgent.sendReliableMessage(); } -// Used to enable/disable menu items. +LLViewerWearable* LLAgentWearables::getViewerWearable(const LLWearableType::EType type, U32 index /*= 0*/) +{ + return dynamic_cast (getWearable(type, index)); +} + +const LLViewerWearable* LLAgentWearables::getViewerWearable(const LLWearableType::EType type, U32 index /*= 0*/) const +{ + return dynamic_cast (getWearable(type, index)); +} + // static BOOL LLAgentWearables::selfHasWearable(LLWearableType::EType type) { return (gAgentWearables.getWearableCount(type) > 0); } -LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index) +// virtual +void LLAgentWearables::wearableUpdated(LLWearable *wearable, BOOL removed) { - //llassert_always(index == 0); - wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); - if (wearable_iter == mWearableDatas.end()) + if (isAgentAvatarValid()) { - return NULL; - } - wearableentry_vec_t& wearable_vec = wearable_iter->second; - if (index>=wearable_vec.size()) - { - return NULL; - } - else - { - return wearable_vec[index]; - } -} - -void LLAgentWearables::setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable) -{ - //llassert_always(index == 0); - LLWearable *old_wearable = getWearable(type,index); - if (!old_wearable) - { - pushWearable(type,wearable); - return; + const BOOL upload_result = removed; + gAgentAvatarp->wearableUpdated(wearable->getType(), upload_result); } - wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); - if (wearable_iter == mWearableDatas.end()) - { - llwarns << "invalid type, type " << type << " index " << index << llendl; - return; - } - wearableentry_vec_t& wearable_vec = wearable_iter->second; - if (index>=wearable_vec.size()) - { - llwarns << "invalid index, type " << type << " index " << index << llendl; - } - else - { - wearable_vec[index] = wearable; - old_wearable->setLabelUpdated(); - wearableUpdated(wearable); - checkWearableAgainstInventory(wearable); - } -} + LLWearableData::wearableUpdated(wearable, removed); -U32 LLAgentWearables::pushWearable(const LLWearableType::EType type, LLWearable *wearable) -{ - if (wearable == NULL) + if (!removed) { - // no null wearables please! - llwarns << "Null wearable sent for type " << type << llendl; - return MAX_CLOTHING_PER_TYPE; - } -// if (type < LLWearableType::WT_COUNT || mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) -// { -// mWearableDatas[type].push_back(wearable); -// wearableUpdated(wearable); -// checkWearableAgainstInventory(wearable); -// return mWearableDatas[type].size()-1; -// } -// [RLVa:KB] - Checked: 2010-06-08 (RLVa-1.2.0g) | Added: RLVa-1.2.0g - if ( (type < LLWearableType::WT_COUNT) && (mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) ) - { - // Don't add the same wearable twice - U32 idxWearable = getWearableIndex(wearable); - RLV_ASSERT(MAX_CLOTHING_PER_TYPE == idxWearable); // pushWearable() on an already added wearable is a bug *somewhere* - if (MAX_CLOTHING_PER_TYPE == idxWearable) + LLViewerWearable* viewer_wearable = dynamic_cast(wearable); + viewer_wearable->refreshName(); + + // Hack pt 2. If the wearable we just loaded has definition version 24, + // then force a re-save of this wearable after slamming the version number to 22. + // This number was incorrectly incremented for internal builds before release, and + // this fix will ensure that the affected wearables are re-saved with the right version number. + // the versions themselves are compatible. This code can be removed before release. + if( viewer_wearable->getDefinitionVersion() == 24 ) { - mWearableDatas[type].push_back(wearable); - idxWearable = mWearableDatas[type].size() - 1; + viewer_wearable->setDefinitionVersion(22); + U32 index = getWearableIndex(wearable); + llinfos << "forcing wearable type " << wearable->getType() << " to version 22 from 24" << llendl; + saveWearable(wearable->getType(),index,TRUE); } - wearableUpdated(wearable); - checkWearableAgainstInventory(wearable); - return idxWearable; -// [/RLVa:KB] + + //Needed as wearable 'save' process is a mess and fires superfluous updateScrollingPanelList calls + //while the wearable being created has not yet been stuffed into the wearable list. + //This results in the param hints being buggered and screwing up the current wearable during LLVisualParamHint::preRender, + //thus making the wearable 'dirty'. The code below basically 'forces' a refresh of the panel to fix this. + if(gFloaterCustomize) + gFloaterCustomize->wearablesChanged(wearable->getType()); + + checkWearableAgainstInventory(viewer_wearable); } - return MAX_CLOTHING_PER_TYPE; -} - -void LLAgentWearables::wearableUpdated(LLWearable *wearable) -{ - gAgentAvatarp->wearableUpdated(wearable->getType(), FALSE); - wearable->refreshName(); - wearable->setLabelUpdated(); - - wearable->pullCrossWearableValues(); - - // Hack pt 2. If the wearable we just loaded has definition version 24, - // then force a re-save of this wearable after slamming the version number to 22. - // This number was incorrectly incremented for internal builds before release, and - // this fix will ensure that the affected wearables are re-saved with the right version number. - // the versions themselves are compatible. This code can be removed before release. - if( wearable->getDefinitionVersion() == 24 ) - { - wearable->setDefinitionVersion(22); - U32 index = getWearableIndex(wearable); - llinfos << "forcing werable type " << wearable->getType() << " to version 22 from 24" << llendl; - saveWearable(wearable->getType(),index,TRUE); - } - - //Needed as wearable 'save' process is a mess and fires superfluous updateScrollingPanelList calls - //while the wearable being created has not yet been stuffed into the wearable list. - //This results in the param hints being buggered and screwing up the current wearable during LLVisualParamHint::preRender, - //thus making the wearable 'dirty'. The code below basically 'forces' a refresh of the panel to fix this. - if(gFloaterCustomize) - gFloaterCustomize->wearablesChanged(wearable->getType()); } -void LLAgentWearables::popWearable(LLWearable *wearable) -{ - if (wearable == NULL) - { - // nothing to do here. move along. - return; - } - - U32 index = getWearableIndex(wearable); - LLWearableType::EType type = wearable->getType(); - - if (index < MAX_CLOTHING_PER_TYPE && index < getWearableCount(type)) - { - popWearable(type, index); - } -} - -void LLAgentWearables::popWearable(const LLWearableType::EType type, U32 index) -{ - //llassert_always(index == 0); - LLWearable *wearable = getWearable(type, index); - if (wearable) - { - mWearableDatas[type].erase(mWearableDatas[type].begin() + index); - if (isAgentAvatarValid()) - { - gAgentAvatarp->wearableUpdated(wearable->getType(), TRUE); - } - wearable->setLabelUpdated(); - } -} - -U32 LLAgentWearables::getWearableIndex(const LLWearable *wearable) const -{ - if (wearable == NULL) - { - return MAX_CLOTHING_PER_TYPE; - } - - const LLWearableType::EType type = wearable->getType(); - wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); - if (wearable_iter == mWearableDatas.end()) - { - llwarns << "tried to get wearable index with an invalid type!" << llendl; - return MAX_CLOTHING_PER_TYPE; - } - const wearableentry_vec_t& wearable_vec = wearable_iter->second; - for(U32 index = 0; index < wearable_vec.size(); index++) - { - if (wearable_vec[index] == wearable) - { - return index; - } - } - - return MAX_CLOTHING_PER_TYPE; -} - -const LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index) const -{ - //llassert_always(index == 0); - wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); - if (wearable_iter == mWearableDatas.end()) - { - return NULL; - } - const wearableentry_vec_t& wearable_vec = wearable_iter->second; - if (index>=wearable_vec.size()) - { - return NULL; - } - else - { - return wearable_vec[index]; - } -} - -LLWearable* LLAgentWearables::getTopWearable(const LLWearableType::EType type) -{ - U32 count = getWearableCount(type); - if ( count == 0) - { - return NULL; - } - - return getWearable(type, count-1); -} - -LLWearable* LLAgentWearables::getBottomWearable(const LLWearableType::EType type) -{ - if (getWearableCount(type) == 0) - { - return NULL; - } - - return getWearable(type, 0); -} - -U32 LLAgentWearables::getWearableCount(const LLWearableType::EType type) const -{ - wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); - if (wearable_iter == mWearableDatas.end()) - { - return 0; - } - const wearableentry_vec_t& wearable_vec = wearable_iter->second; - return wearable_vec.size(); -} - -U32 LLAgentWearables::getWearableCount(const U32 tex_index) const -{ - const LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getTEWearableType((LLAvatarAppearanceDefines::ETextureIndex)tex_index); - return getWearableCount(wearable_type); -} BOOL LLAgentWearables::itemUpdatePending(const LLUUID& item_id) const @@ -966,7 +792,7 @@ U32 LLAgentWearables::itemUpdatePendingCount() const const LLUUID LLAgentWearables::getWearableItemID(LLWearableType::EType type, U32 index) const { - const LLWearable *wearable = getWearable(type,index); + const LLViewerWearable *wearable = getViewerWearable(type,index); if (wearable) return wearable->getItemID(); else @@ -991,7 +817,9 @@ void LLAgentWearables::getWearableItemIDs(LLWearableType::EType eType, uuid_vec_ for (wearableentry_vec_t::const_iterator itWearable = itWearableType->second.begin(), endWearable = itWearableType->second.end(); itWearable != endWearable; ++itWearable) { - idItems.push_back((*itWearable)->getItemID()); + LLViewerWearable* wearable = dynamic_cast(*itWearable); + if(wearable) + idItems.push_back(wearable->getItemID()); } } } @@ -999,7 +827,7 @@ void LLAgentWearables::getWearableItemIDs(LLWearableType::EType eType, uuid_vec_ const LLUUID LLAgentWearables::getWearableAssetID(LLWearableType::EType type, U32 index) const { - const LLWearable *wearable = getWearable(type,index); + const LLViewerWearable *wearable = getViewerWearable(type,index); if (wearable) return wearable->getAssetID(); else @@ -1080,7 +908,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs gMessageSystem->getUUIDFast(_PREHASH_WearableData, _PREHASH_AssetID, asset_id, i ); if( asset_id.isNull() ) { - LLWearable::removeFromAvatar( type, FALSE ); + LLViewerWearable::removeFromAvatar( type, FALSE ); } else { @@ -1127,7 +955,7 @@ void LLAgentWearables::recoverMissingWearable(const LLWearableType::EType type, // Try to recover by replacing missing wearable with a new one. LLNotificationsUtil::add("ReplacedMissingWearable"); lldebugs << "Wearable " << LLWearableType::getTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl; - LLWearable* new_wearable = LLWearableList::instance().createNewWearable(type); + LLViewerWearable* new_wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); setWearable(type,index,new_wearable); //new_wearable->writeToAvatar( TRUE ); @@ -1164,7 +992,7 @@ void LLAgentWearables::recoverMissingWearableDone() void LLAgentWearables::addLocalTextureObject(const LLWearableType::EType wearable_type, const LLAvatarAppearanceDefines::ETextureIndex texture_type, U32 wearable_index) { - LLWearable* wearable = getWearable((LLWearableType::EType)wearable_type, wearable_index); + LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)wearable_type, wearable_index); if (!wearable) { llerrs << "Tried to add local texture object to invalid wearable with type " << wearable_type << " and index " << wearable_index << llendl; @@ -1197,7 +1025,7 @@ public: mItemsToLink, link_waiter); } - void addPendingWearable(LLWearable *wearable) + void addPendingWearable(LLViewerWearable *wearable) { if (!wearable) { @@ -1232,7 +1060,7 @@ public: LLWearableType::EType type = item->getWearableType(); if (type < LLWearableType::WT_COUNT) { - LLWearable *wearable = mWearablesAwaitingItems[type]; + LLViewerWearable *wearable = mWearablesAwaitingItems[type]; if (wearable) wearable->setItemID(inv_item); } @@ -1245,7 +1073,7 @@ public: private: LLInventoryModel::item_array_t mItemsToLink; - std::vector mWearablesAwaitingItems; + std::vector mWearablesAwaitingItems; }; void LLAgentWearables::createStandardWearables() @@ -1258,20 +1086,20 @@ void LLAgentWearables::createStandardWearables() { TRUE, //LLWearableType::WT_SHAPE TRUE, //LLWearableType::WT_SKIN - TRUE, //WT_HAIR - TRUE, //WT_EYES - TRUE, //WT_SHIRT - TRUE, //WT_PANTS - TRUE, //WT_SHOES - TRUE, //WT_SOCKS - FALSE, //WT_JACKET - FALSE, //WT_GLOVES - TRUE, //WT_UNDERSHIRT - TRUE, //WT_UNDERPANTS - FALSE, //WT_SKIRT - FALSE, //WT_ALPHA - FALSE, //WT_TATTOO - FALSE, //WT_PHYSICS + TRUE, //LLWearableType::WT_HAIR + TRUE, //LLWearableType::WT_EYES + TRUE, //LLWearableType::WT_SHIRT + TRUE, //LLWearableType::WT_PANTS + TRUE, //LLWearableType::WT_SHOES + TRUE, //LLWearableType::WT_SOCKS + FALSE, //LLWearableType::WT_JACKET + FALSE, //LLWearableType::WT_GLOVES + TRUE, //LLWearableType::WT_UNDERSHIRT + TRUE, //LLWearableType::WT_UNDERPANTS + FALSE, //LLWearableType::WT_SKIRT + FALSE, //LLWearableType::WT_ALPHA + FALSE, //LLWearableType::WT_TATTOO + FALSE //LLWearableType::WT_PHYSICS }; LLPointer cb = new OnWearableItemCreatedCB; @@ -1280,7 +1108,7 @@ void LLAgentWearables::createStandardWearables() if (create[i]) { llassert(getWearableCount((LLWearableType::EType)i) == 0); - LLWearable* wearable = LLWearableList::instance().createNewWearable((LLWearableType::EType)i); + LLViewerWearable* wearable = LLWearableList::instance().createNewWearable((LLWearableType::EType)i, gAgentAvatarp); ((OnWearableItemCreatedCB*)(&(*cb)))->addPendingWearable(wearable); // no need to update here... LLUUID category_id = LLUUID::null; @@ -1339,7 +1167,7 @@ void LLAgentWearables::makeNewOutfitDone(S32 type, U32 index) void LLAgentWearables::addWearableToAgentInventory(LLPointer cb, - LLWearable* wearable, + LLViewerWearable* wearable, const LLUUID& category_id, BOOL notify) { @@ -1377,7 +1205,7 @@ void LLAgentWearables::removeWearable(const LLWearableType::EType type, bool do_ } else { - LLWearable* old_wearable = getWearable(type,index); + LLViewerWearable* old_wearable = getViewerWearable(type,index); // if (old_wearable) // [RLVa:KB] - Checked: 2010-05-11 (RLVa-1.2.0c) | Modified: RLVa-1.2.0g @@ -1436,10 +1264,10 @@ void LLAgentWearables::removeWearableFinal( LLWearableType::EType type, bool do_ //llassert_always(index == 0); if (do_remove_all) { - S32 max_entry = mWearableDatas[type].size()-1; + S32 max_entry = getWearableCount(type)-1; for (S32 i=max_entry; i>=0; i--) { - LLWearable* old_wearable = getWearable(type,i); + LLViewerWearable* old_wearable = getViewerWearable(type,i); //queryWearableCache(); // moved below // if (old_wearable) // [RLVa:KB] - Checked: 2010-05-14 (RLVa-1.2.0g) | Added: RLVa-1.2.0g @@ -1458,7 +1286,7 @@ void LLAgentWearables::removeWearableFinal( LLWearableType::EType type, bool do_ } else { - LLWearable* old_wearable = getWearable(type, index); + LLViewerWearable* old_wearable = getViewerWearable(type, index); //queryWearableCache(); // moved below // if (old_wearable) @@ -1504,7 +1332,7 @@ void LLAgentWearables::removeWearableFinal( LLWearableType::EType type, bool do_ // Assumes existing wearables are not dirty. void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& items, - const LLDynamicArray< LLWearable* >& wearables, + const LLDynamicArray< LLViewerWearable* >& wearables, BOOL remove) { llinfos << "setWearableOutfit() start" << llendl; @@ -1535,7 +1363,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it S32 i; for (i = 0; i < count; i++) { - LLWearable* new_wearable = wearables[i]; + LLViewerWearable* new_wearable = wearables[i]; LLPointer new_item = items[i]; llassert(new_wearable); @@ -1601,8 +1429,8 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it idxCurPerType[type]++; // [/RLVa:KB] - wearableUpdated(new_wearable); - checkWearableAgainstInventory(new_wearable); + const BOOL removed = FALSE; + wearableUpdated(new_wearable, removed); } } @@ -1645,7 +1473,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it // User has picked "wear on avatar" from a menu. -void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append) +void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append) { //LLAgentDumper dumper("setWearableItem"); if (isWearingItem(new_item->getUUID())) @@ -1670,7 +1498,7 @@ void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLWearable* ne { // Remove old wearable, if any // MULTI_WEARABLE: hardwired to 0 - LLWearable* old_wearable = getWearable(type,0); + LLViewerWearable* old_wearable = getViewerWearable(type,0); if( old_wearable ) { const LLUUID& old_item_id = old_wearable->getItemID(); @@ -1696,7 +1524,7 @@ void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLWearable* ne } // static -bool LLAgentWearables::onSetWearableDialog( const LLSD& notification, const LLSD& response, LLWearable* wearable ) +bool LLAgentWearables::onSetWearableDialog(const LLSD& notification, const LLSD& response, LLViewerWearable* wearable) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLInventoryItem* new_item = gInventory.getItem( notification["payload"]["item_id"].asUUID()); @@ -1732,7 +1560,7 @@ bool LLAgentWearables::onSetWearableDialog( const LLSD& notification, const LLSD // Called from setWearableItem() and onSetWearableDialog() to actually set the wearable. // MULTI_WEARABLE: unify code after null objects are gone. -void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append) +void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append) { const LLWearableType::EType type = new_wearable->getType(); @@ -1750,7 +1578,7 @@ void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLWearable* n // Replace the old wearable with a new one. llassert(new_item->getAssetUUID() == new_wearable->getAssetID()); - LLWearable *old_wearable = getWearable(type,0); + LLViewerWearable *old_wearable = getViewerWearable(type,0); LLUUID old_item_id; if (old_wearable) { @@ -1765,7 +1593,7 @@ void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLWearable* n gInventory.notifyObservers(); } llinfos << "Replaced current element 0 for type " << type - << " size is now " << mWearableDatas[type].size() << llendl; + << " size is now " << getWearableCount(type) << llendl; } //llinfos << "LLVOAvatar::setWearableItem()" << llendl; @@ -1831,46 +1659,14 @@ void LLAgentWearables::queryWearableCache() } } -LLUUID LLAgentWearables::computeBakedTextureHash(LLAvatarAppearanceDefines::EBakedTextureIndex baked_index, - BOOL generate_valid_hash) // Set to false if you want to upload the baked texture w/o putting it in the cache +// virtual +void LLAgentWearables::invalidateBakedTextureHash(LLMD5& hash) const { - LLUUID hash_id; - bool hash_computed = false; - LLMD5 hash; - const LLAvatarAppearanceDictionary::BakedEntry *baked_dict = LLAvatarAppearanceDictionary::getInstance()->getBakedTexture(baked_index); - - for (U8 i=0; i < baked_dict->mWearables.size(); i++) + // Add some garbage into the hash so that it becomes invalid. + if (isAgentAvatarValid()) { - const LLWearableType::EType baked_type = baked_dict->mWearables[i]; - const U32 num_wearables = getWearableCount(baked_type); - for (U32 index = 0; index < num_wearables; ++index) - { - const LLWearable* wearable = getWearable(baked_type,index); - if (wearable) - { - LLUUID asset_id = wearable->getAssetID(); - hash.update((const unsigned char*)asset_id.mData, UUID_BYTES); - hash_computed = true; - } - } + hash.update((const unsigned char*)gAgentAvatarp->getID().mData, UUID_BYTES); } - if (hash_computed) - { - hash.update((const unsigned char*)baked_dict->mWearablesHashID.mData, UUID_BYTES); - - // Add some garbage into the hash so that it becomes invalid. - if (!generate_valid_hash) - { - if (isAgentAvatarValid()) - { - hash.update((const unsigned char*)gAgentAvatarp->getID().mData, UUID_BYTES); - } - } - hash.finalize(); - hash.raw_digest(hash_id.mData); - } - - return hash_id; } // User has picked "remove from avatar" from a menu. @@ -2146,7 +1942,7 @@ void LLAgentWearables::checkWearablesLoaded() const // Returns false if the given wearable is already topmost/bottommost // (depending on closer_to_body parameter). -bool LLAgentWearables::canMoveWearable(const LLUUID& item_id, bool closer_to_body) +bool LLAgentWearables::canMoveWearable(const LLUUID& item_id, bool closer_to_body) const { const LLWearable* wearable = getWearableFromItemID(item_id); if (!wearable) return false; @@ -2174,7 +1970,7 @@ void LLAgentWearables::updateWearablesLoaded() } } -bool LLAgentWearables::canWearableBeRemoved(const LLWearable* wearable) const +bool LLAgentWearables::canWearableBeRemoved(const LLViewerWearable* wearable) const { if (!wearable) return false; @@ -2189,7 +1985,7 @@ void LLAgentWearables::animateAllWearableParams(F32 delta, BOOL upload_bake) { for (S32 count = 0; count < (S32)getWearableCount((LLWearableType::EType)type); ++count) { - LLWearable *wearable = getWearable((LLWearableType::EType)type,count); + LLViewerWearable *wearable = getViewerWearable((LLWearableType::EType)type,count); llassert(wearable); if (wearable) { @@ -2204,28 +2000,39 @@ bool LLAgentWearables::moveWearable(const LLViewerInventoryItem* item, bool clos if (!item) return false; if (!item->isWearableType()) return false; - wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(item->getWearableType()); - if (wearable_iter == mWearableDatas.end()) return false; - - wearableentry_vec_t& wearable_vec = wearable_iter->second; - if (wearable_vec.empty()) return false; + LLWearableType::EType type = item->getWearableType(); + U32 wearable_count = getWearableCount(type); + if (0 == wearable_count) return false; const LLUUID& asset_id = item->getAssetUUID(); //nowhere to move if the wearable is already on any boundary (closest to the body/furthest from the body) - if (closer_to_body && asset_id == wearable_vec.front()->getAssetID()) return false; - if (!closer_to_body && asset_id == wearable_vec.back()->getAssetID()) return false; - - for (U32 i = 0; i < wearable_vec.size(); ++i) + if (closer_to_body) { - LLWearable* wearable = wearable_vec[i]; + LLViewerWearable* bottom_wearable = dynamic_cast( getBottomWearable(type) ); + if (bottom_wearable->getAssetID() == asset_id) + { + return false; + } + } + else // !closer_to_body + { + LLViewerWearable* top_wearable = dynamic_cast( getTopWearable(type) ); + if (top_wearable->getAssetID() == asset_id) + { + return false; + } + } + + for (U32 i = 0; i < wearable_count; ++i) + { + LLViewerWearable* wearable = getViewerWearable(type, i); if (!wearable) continue; if (wearable->getAssetID() != asset_id) continue; //swapping wearables U32 swap_i = closer_to_body ? i-1 : i+1; - wearable_vec[i] = wearable_vec[swap_i]; - wearable_vec[swap_i] = wearable; + swapWearables(type, i, swap_i); if(gFloaterCustomize) { @@ -2243,7 +2050,7 @@ void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, con { if (type == LLWearableType::WT_INVALID || type == LLWearableType::WT_NONE) return; - LLWearable* wearable = LLWearableList::instance().createNewWearable(type); + LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); LLAssetType::EType asset_type = wearable->getAssetType(); LLInventoryType::EType inv_type = LLInventoryType::IT_WEARABLE; LLPointer cb = wear ? new LLWearAndEditCallback : NULL; @@ -2276,7 +2083,7 @@ void LLAgentWearables::editWearable(const LLUUID& item_id) return; } - LLWearable* wearable = gAgentWearables.getWearableFromItemID(item_id); + LLViewerWearable* wearable = gAgentWearables.getWearableFromItemID(item_id); if (!wearable) { llwarns << "Cannot get wearable" << llendl; diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h index d4af114ea..41dacedf5 100644 --- a/indra/newview/llagentwearables.h +++ b/indra/newview/llagentwearables.h @@ -37,15 +37,15 @@ #include "llinventorymodel.h" #include "llviewerinventory.h" #include "llavatarappearancedefines.h" +#include "llwearabledata.h" class LLInventoryItem; class LLVOAvatarSelf; -class LLWearable; +class LLViewerWearable; class LLInitialWearablesFetch; class LLViewerObject; -class LLTexLayerTemplate; -class LLAgentWearables : public LLInitClass +class LLAgentWearables : public LLInitClass, public LLWearableData { //-------------------------------------------------------------------- // Constructors / destructors / Initializers @@ -82,10 +82,10 @@ public: bool isCOFChangeInProgress() const { return mCOFChangeInProgress; } void updateWearablesLoaded(); void checkWearablesLoaded() const; - bool canMoveWearable(const LLUUID& item_id, bool closer_to_body); + bool canMoveWearable(const LLUUID& item_id, bool closer_to_body) const; // Note: False for shape, skin, eyes, and hair, unless you have MORE than 1. - bool canWearableBeRemoved(const LLWearable* wearable) const; + bool canWearableBeRemoved(const LLViewerWearable* wearable) const; void animateAllWearableParams(F32 delta, BOOL upload_bake); @@ -99,52 +99,38 @@ public: // [/RLVa:KB] const LLUUID getWearableItemID(LLWearableType::EType type, U32 index /*= 0*/) const; const LLUUID getWearableAssetID(LLWearableType::EType type, U32 index /*= 0*/) const; - const LLWearable* getWearableFromItemID(const LLUUID& item_id) const; - LLWearable* getWearableFromItemID(const LLUUID& item_id); - LLWearable* getWearableFromAssetID(const LLUUID& asset_id); + const LLViewerWearable* getWearableFromItemID(const LLUUID& item_id) const; + LLViewerWearable* getWearableFromItemID(const LLUUID& item_id); + LLViewerWearable* getWearableFromAssetID(const LLUUID& asset_id); + LLViewerWearable* getViewerWearable(const LLWearableType::EType type, U32 index /*= 0*/); + const LLViewerWearable* getViewerWearable(const LLWearableType::EType type, U32 index /*= 0*/) const; LLInventoryItem* getWearableInventoryItem(LLWearableType::EType type, U32 index /*= 0*/); static BOOL selfHasWearable(LLWearableType::EType type); - LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/); - const LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const; - LLWearable* getTopWearable(const LLWearableType::EType type); - LLWearable* getBottomWearable(const LLWearableType::EType type); - U32 getWearableCount(const LLWearableType::EType type) const; - U32 getWearableCount(const U32 tex_index) const; - - static const U32 MAX_CLOTHING_PER_TYPE = 5; - //-------------------------------------------------------------------- // Setters //-------------------------------------------------------------------- - private: - // Low-level data structure setter - public access is via setWearableItem, etc. - void setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable); - U32 pushWearable(const LLWearableType::EType type, LLWearable *wearable); - void wearableUpdated(LLWearable *wearable); - void popWearable(LLWearable *wearable); - void popWearable(const LLWearableType::EType type, U32 index); - + /*virtual*/void wearableUpdated(LLWearable *wearable, BOOL removed); public: - void setWearableItem(LLInventoryItem* new_item, LLWearable* wearable, bool do_append = false); - void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove); + void setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable, bool do_append = false); + void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLViewerWearable* >& wearables, BOOL remove); void setWearableName(const LLUUID& item_id, const std::string& new_name); + // *TODO: Move this into llappearance/LLWearableData ? void addLocalTextureObject(const LLWearableType::EType wearable_type, const LLAvatarAppearanceDefines::ETextureIndex texture_type, U32 wearable_index); - U32 getWearableIndex(const LLWearable *wearable) const; protected: - void setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append = false); - static bool onSetWearableDialog(const LLSD& notification, const LLSD& response, LLWearable* wearable); + void setWearableFinal(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append = false); + static bool onSetWearableDialog(const LLSD& notification, const LLSD& response, LLViewerWearable* wearable); void addWearableToAgentInventory(LLPointer cb, - LLWearable* wearable, + LLViewerWearable* wearable, const LLUUID& category_id = LLUUID::null, BOOL notify = TRUE); void addWearabletoAgentInventoryDone(const LLWearableType::EType type, const U32 index, const LLUUID& item_id, - LLWearable* wearable); + LLViewerWearable* wearable); void recoverMissingWearable(const LLWearableType::EType type, U32 index /*= 0*/); void recoverMissingWearableDone(); @@ -179,15 +165,15 @@ protected: public: // Processes the initial wearables update message (if necessary, since the outfit folder makes it redundant) static void processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys, void** user_data); - LLUUID computeBakedTextureHash(LLAvatarAppearanceDefines::EBakedTextureIndex baked_index, - BOOL generate_valid_hash = TRUE); protected: + + /*virtual*/ void invalidateBakedTextureHash(LLMD5& hash) const; void sendAgentWearablesUpdate(); void sendAgentWearablesRequest(); void queryWearableCache(); void updateServer(); - static void onInitialWearableAssetArrived(LLWearable* wearable, void* userdata); + static void onInitialWearableAssetArrived(LLViewerWearable* wearable, void* userdata); //-------------------------------------------------------------------- // Outfits @@ -205,7 +191,7 @@ private: // Save Wearables //-------------------------------------------------------------------- public: - LLWearable* saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, BOOL save_in_lost_and_found); + LLViewerWearable* saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, BOOL save_in_lost_and_found); void saveWearable(const LLWearableType::EType type, const U32 index, BOOL send_update = TRUE, const std::string new_name = ""); void saveAllWearables(); @@ -262,10 +248,6 @@ private: // Member variables //-------------------------------------------------------------------- private: - typedef std::vector wearableentry_vec_t; // all wearables of a certain type (EG all shirts) - typedef std::map wearableentry_map_t; // wearable "categories" arranged by wearable type - wearableentry_map_t mWearableDatas; - static BOOL mInitialWearablesUpdateReceived; // [SL:KB] - Patch: Appearance-InitialWearablesLoadedCallback | Checked: 2010-08-14 (Catznip-3.0.0a) | Added: Catznip-2.2.0a static bool mInitialWearablesLoaded; @@ -309,13 +291,13 @@ private: addWearableToAgentInventoryCallback(LLPointer cb, LLWearableType::EType type, U32 index, - LLWearable* wearable, + LLViewerWearable* wearable, U32 todo = CALL_NONE); virtual void fire(const LLUUID& inv_item); private: LLWearableType::EType mType; U32 mIndex; - LLWearable* mWearable; + LLViewerWearable* mWearable; U32 mTodo; LLPointer mCB; }; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index a3439995e..7d4b9c222 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -277,7 +277,7 @@ struct LLFoundData std::string mName; LLAssetType::EType mAssetType; LLWearableType::EType mWearableType; - LLWearable* mWearable; + LLViewerWearable* mWearable; bool mIsReplacement; }; @@ -301,7 +301,7 @@ public: void recoverMissingWearable(LLWearableType::EType type); void clearCOFLinksForMissingWearables(); - void onWearableAssetFetch(LLWearable *wearable); + void onWearableAssetFetch(LLViewerWearable *wearable); void onAllComplete(); // [SL:KB] - Patch: Appearance-COFCorruption | Checked: 2010-04-14 (Catznip-3.0.0a) | Added: Catznip-2.0.0a @@ -331,7 +331,7 @@ private: typedef std::set type_set_hp; static type_set_hp sActiveHoldingPatterns; bool mIsMostRecent; - std::set mLateArrivals; + std::set mLateArrivals; bool mIsAllComplete; }; @@ -564,7 +564,7 @@ bool LLWearableHoldingPattern::pollFetchCompletion() class RecoveredItemLinkCB: public LLInventoryCallback { public: - RecoveredItemLinkCB(LLWearableType::EType type, LLWearable *wearable, LLWearableHoldingPattern* holder): + RecoveredItemLinkCB(LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder): mHolder(holder), mWearable(wearable), mType(type) @@ -611,14 +611,14 @@ public: } private: LLWearableHoldingPattern* mHolder; - LLWearable *mWearable; + LLViewerWearable *mWearable; LLWearableType::EType mType; }; class RecoveredItemCB: public LLInventoryCallback { public: - RecoveredItemCB(LLWearableType::EType type, LLWearable *wearable, LLWearableHoldingPattern* holder): + RecoveredItemCB(LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder): mHolder(holder), mWearable(wearable), mType(type) @@ -656,7 +656,7 @@ public: } private: LLWearableHoldingPattern* mHolder; - LLWearable *mWearable; + LLViewerWearable *mWearable; LLWearableType::EType mType; }; @@ -672,7 +672,7 @@ void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type LLNotificationsUtil::add("ReplacedMissingWearable"); lldebugs << "Wearable " << LLWearableType::getTypeLabel(type) << " could not be downloaded. Replaced inventory item with default wearable." << llendl; - LLWearable* wearable = LLWearableList::instance().createNewWearable(type); + LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); // Add a new one in the lost and found folder. const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); @@ -796,11 +796,11 @@ void LLWearableHoldingPattern::handleLateArrivals() iter != getFoundList().end(); ++iter) { LLFoundData& data = *iter; - for (std::set::iterator wear_it = mLateArrivals.begin(); + for (std::set::iterator wear_it = mLateArrivals.begin(); wear_it != mLateArrivals.end(); ++wear_it) { - LLWearable *wearable = *wear_it; + LLViewerWearable *wearable = *wear_it; if(wearable->getAssetID() == data.mAssetID) { @@ -860,7 +860,7 @@ void LLWearableHoldingPattern::resetTime(F32 timeout) mWaitTime.setTimerExpirySec(timeout); } -void LLWearableHoldingPattern::onWearableAssetFetch(LLWearable *wearable) +void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable) { if (!isMostRecent()) { @@ -911,7 +911,7 @@ void LLWearableHoldingPattern::onWearableAssetFetch(LLWearable *wearable) } } -static void onWearableAssetFetch(LLWearable* wearable, void* data) +static void onWearableAssetFetch(LLViewerWearable* wearable, void* data) { LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; holder->onWearableAssetFetch(wearable); @@ -1796,7 +1796,7 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo { lldebugs << "updateAgentWearables()" << llendl; LLInventoryItem::item_array_t items; - LLDynamicArray< LLWearable* > wearables; + LLDynamicArray< LLViewerWearable* > wearables; // [RLVa:KB] - Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f uuid_vec_t idsCurrent; LLInventoryModel::item_array_t itemsNew; if (rlv_handler_t::isEnabled()) @@ -1813,7 +1813,7 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo iter != holder->getFoundList().end(); ++iter) { LLFoundData& data = *iter; - LLWearable* wearable = data.mWearable; + LLViewerWearable* wearable = data.mWearable; if( wearable && ((S32)wearable->getType() == i) ) { LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID); @@ -1862,7 +1862,7 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo // We need to report removals before additions or scripts will get confused for (uuid_vec_t::const_iterator itItemID = idsCurrent.begin(); itItemID != idsCurrent.end(); ++itItemID) { - const LLWearable* pWearable = gAgentWearables.getWearableFromItemID(*itItemID); + const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(*itItemID); if (pWearable) RlvBehaviourNotifyHandler::onTakeOff(pWearable->getType(), true); } @@ -2149,6 +2149,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) // Fetch the wearables about to be worn. LLWearableList::instance().getAsset(found.mAssetID, found.mName, + gAgentAvatarp, found.mAssetType, onWearableAssetFetch, (void*)holder); @@ -2514,7 +2515,7 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update std::string description = vitem->getIsLinkType() ? vitem->getDescription() : ""; if(description.empty()) { - LLWearable* wearable = gAgentWearables.getWearableFromItemID(vitem->getLinkedUUID()); + LLViewerWearable* wearable = gAgentWearables.getWearableFromItemID(vitem->getLinkedUUID()); if(wearable) { U32 index = gAgentWearables.getWearableIndex(wearable); @@ -3355,7 +3356,7 @@ void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) if ( (!rlv_handler_t::isEnabled()) || (gRlvWearableLocks.canRemove(item_to_remove)) ) // [/RLVa:KB] { - const LLWearable* pWearable = gAgentWearables.getWearableFromItemID(item_to_remove->getLinkedUUID()); + const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(item_to_remove->getLinkedUUID()); if ( (pWearable) && (LLAssetType::AT_BODYPART != pWearable->getAssetType()) ) { U32 idxWearable = gAgentWearables.getWearableIndex(pWearable); diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index 52eee0eb8..6aa573ba8 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -1547,12 +1547,12 @@ BOOL LLPreviewAnimation::render() gGL.flush(); - LLVector3 target_pos = avatarp->mRoot.getWorldPosition(); + LLVector3 target_pos = avatarp->mRoot->getWorldPosition(); LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * LLQuaternion(mCameraYaw, LLVector3::z_axis); - LLQuaternion av_rot = avatarp->mRoot.getWorldRotation() * camera_rot; + LLQuaternion av_rot = avatarp->mRoot->getWorldRotation() * camera_rot; LLViewerCamera::getInstance()->setOriginAndLookAt( target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + mCameraOffset) * av_rot), // camera LLVector3::z_axis, // up diff --git a/indra/newview/llfloatercustomize.cpp b/indra/newview/llfloatercustomize.cpp index e0d6cee27..efe449191 100644 --- a/indra/newview/llfloatercustomize.cpp +++ b/indra/newview/llfloatercustomize.cpp @@ -544,7 +544,7 @@ void LLFloaterCustomize::onBtnExport_continued(AIFilePicker* filepicker) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) { is_modifiable = FALSE; - LLWearable* old_wearable = gAgentWearables.getWearable((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE + LLViewerWearable* old_wearable = gAgentWearables.getViewerWearable((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE if( old_wearable ) { item = gInventory.getItem(old_wearable->getItemID()); @@ -568,7 +568,7 @@ void LLFloaterCustomize::onBtnExport_continued(AIFilePicker* filepicker) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) { is_modifiable = FALSE; - LLWearable* old_wearable = gAgentWearables.getWearable((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE + LLViewerWearable* old_wearable = gAgentWearables.getViewerWearable((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE if( old_wearable ) { item = gInventory.getItem(old_wearable->getItemID()); @@ -725,7 +725,7 @@ BOOL LLFloaterCustomize::isDirty() const LLWearableType::EType cur = getCurrentWearableType(); for(U32 i = 0; i < gAgentWearables.getWearableCount(cur); ++i) { - LLWearable* wearable = gAgentWearables.getWearable(cur,i); + LLViewerWearable* wearable = gAgentWearables.getViewerWearable(cur,i); if(wearable && wearable->isDirty()) return TRUE; } @@ -859,7 +859,7 @@ bool LLFloaterCustomize::onSaveDialog(const LLSD& notification, const LLSD& resp for(U32 i = 0;i < gAgentWearables.getWearableCount(cur);++i) { - LLWearable* wearable = gAgentWearables.getWearable(cur,i); + LLViewerWearable* wearable = gAgentWearables.getViewerWearable(cur,i); if(wearable && wearable->isDirty()) { switch( option ) @@ -938,7 +938,7 @@ void LLFloaterCustomize::updateInventoryUI() panel = mWearablePanelList[i]; if(panel) { - LLWearable* wearable = panel->getWearable(); + LLViewerWearable* wearable = panel->getWearable(); if(wearable) item = gInventory.getItem(wearable->getItemID()); } diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 905c5f600..935f61c3a 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -664,7 +664,7 @@ S8 LLImagePreviewAvatar::getType() const void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male) { - mTargetJoint = mDummyAvatar->mRoot.findJoint(joint_name); + mTargetJoint = mDummyAvatar->mRoot->findJoint(joint_name); // clear out existing test mesh if (mTargetMesh) { @@ -683,9 +683,9 @@ void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const mDummyAvatar->updateVisualParams(); mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); } - mDummyAvatar->mRoot.setVisible(FALSE, TRUE); + mDummyAvatar->mRoot->setVisible(FALSE, TRUE); - mTargetMesh = dynamic_cast(mDummyAvatar->mRoot.findJoint(mesh_name)); + mTargetMesh = dynamic_cast(mDummyAvatar->mRoot->findJoint(mesh_name)); mTargetMesh->setTestTexture(mTextureName); mTargetMesh->setVisible(TRUE, FALSE); mCameraDistance = distance; @@ -702,7 +702,7 @@ void LLImagePreviewAvatar::clearPreviewTexture(const std::string& mesh_name) { if (mDummyAvatar) { - LLViewerJointMesh *mesh = dynamic_cast(mDummyAvatar->mRoot.findJoint(mesh_name)); + LLViewerJointMesh *mesh = dynamic_cast(mDummyAvatar->mRoot->findJoint(mesh_name)); // clear out existing test mesh if (mesh) { diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index a06361d99..2a180897b 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -691,7 +691,7 @@ bool LLHUDEffectLookAt::calcTargetPosition() } else { - target_rot = target_av->mRoot.getWorldRotation(); + target_rot = target_av->mRoot->getWorldRotation(); } } else // target obj is not an avatar diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 10c1a3176..e2be8d97a 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -6100,7 +6100,7 @@ void LLWearableBridge::wearAddOnAvatar() } // static -//void LLWearableBridge::onWearOnAvatarArrived( LLWearable* wearable, void* userdata ) +//void LLWearableBridge::onWearOnAvatarArrived( LLViewerWearable* wearable, void* userdata ) //{ // LLUUID* item_id = (LLUUID*) userdata; // if(wearable) @@ -6126,7 +6126,7 @@ void LLWearableBridge::wearAddOnAvatar() // static // BAP remove the "add" code path once everything is fully COF-ified. -//void LLWearableBridge::onWearAddOnAvatarArrived( LLWearable* wearable, void* userdata ) +//void LLWearableBridge::onWearAddOnAvatarArrived( LLViewerWearable* wearable, void* userdata ) //{ // LLUUID* item_id = (LLUUID*) userdata; // if(wearable) @@ -6207,7 +6207,7 @@ BOOL LLWearableBridge::canRemoveFromAvatar(void* user_data) //} // static -//void LLWearableBridge::onRemoveFromAvatarArrived(LLWearable* wearable, +//void LLWearableBridge::onRemoveFromAvatarArrived(LLViewerWearable* wearable, // void* userdata) //{ // OnRemoveStruct *on_remove_struct = (OnRemoveStruct*) userdata; diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index c5e26b752..fbd7102e5 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -33,7 +33,7 @@ #include "llinventorymodel.h" #include "llinventoryobserver.h" #include "llviewercontrol.h" -#include "llwearable.h" +#include "llviewerwearable.h" class LLInventoryPanel; class LLInventoryModel; @@ -503,10 +503,10 @@ public: static void onWearOnAvatar( void* userdata ); // Access to wearOnAvatar() from menu static BOOL canWearOnAvatar( void* userdata ); - static void onWearOnAvatarArrived( LLWearable* wearable, void* userdata ); + static void onWearOnAvatarArrived( LLViewerWearable* wearable, void* userdata ); void wearOnAvatar(); - static void onWearAddOnAvatarArrived( LLWearable* wearable, void* userdata ); + static void onWearAddOnAvatarArrived( LLViewerWearable* wearable, void* userdata ); void wearAddOnAvatar(); static BOOL canEditOnAvatar( void* userdata ); // Access to editOnAvatar() from menu @@ -515,7 +515,7 @@ public: static BOOL canRemoveFromAvatar( void* userdata ); static void onRemoveFromAvatar( void* userdata ); - static void onRemoveFromAvatarArrived( LLWearable* wearable, void* userdata ); + static void onRemoveFromAvatarArrived( LLViewerWearable* wearable, void* userdata ); static void removeItemFromAvatar(LLViewerInventoryItem *item); static void removeAllClothesFromAvatar(); void removeFromAvatar(); diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 9fe7c979b..92ae10c9e 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -28,7 +28,7 @@ #include "llpaneleditwearable.h" #include "llpanel.h" -#include "llwearable.h" +#include "llviewerwearable.h" #include "lluictrl.h" #include "llscrollingpanellist.h" #include "llvisualparam.h" @@ -767,7 +767,7 @@ BOOL LLPanelEditWearable::postBuild() BOOL LLPanelEditWearable::isDirty() const { - LLWearable* wearable = getWearable(); + LLViewerWearable* wearable = getWearable(); return wearable && wearable->isDirty(); } @@ -778,7 +778,7 @@ void LLPanelEditWearable::draw() refreshWearables(false); - LLWearable* wearable = getWearable(); + LLViewerWearable* wearable = getWearable(); BOOL has_wearable = (wearable != NULL ); BOOL has_any_wearable = has_wearable || gAgentWearables.getWearableCount(mType); BOOL is_dirty = isDirty(); @@ -931,7 +931,7 @@ void LLPanelEditWearable::setWearableIndex(S32 index) tab->selectTab(tab_index); } - LLWearable* wearable = gAgentWearables.getWearable(mType,mCurrentIndex); + LLViewerWearable* wearable = gAgentWearables.getViewerWearable(mType,mCurrentIndex); if(wearable == getWearable()) return; @@ -1059,7 +1059,7 @@ void LLPanelEditWearable::onBtnSaveAs( void* userdata ) LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; if(self->mActiveModal) return; - LLWearable* wearable = self->getWearable(); + LLViewerWearable* wearable = self->getWearable(); if( wearable ) { self->mActiveModal = new LLWearableSaveAsDialog( wearable->getName(), self, onSaveAsCommit, self ); @@ -1095,7 +1095,7 @@ void LLPanelEditWearable::onCommitSexChange() } bool is_new_sex_male = (gSavedSettings.getU32("AvatarSex") ? SEX_MALE : SEX_FEMALE) == SEX_MALE; - LLWearable* wearable = gAgentWearables.getWearable(type, index); + LLViewerWearable* wearable = gAgentWearables.getViewerWearable(type, index); if (wearable) { wearable->setVisualParamWeight(param->getID(), is_new_sex_male, FALSE); @@ -1142,7 +1142,7 @@ bool LLPanelEditWearable::onSelectAutoWearOption(const LLSD& notification, const if(avatar) { // Create a new wearable in the default folder for the wearable's asset type. - LLWearable* wearable = LLWearableList::instance().createNewWearable( (LLWearableType::EType)notification["payload"]["wearable_type"].asInteger() ); + LLViewerWearable* wearable = LLWearableList::instance().createNewWearable( (LLWearableType::EType)notification["payload"]["wearable_type"].asInteger(), avatar ); LLAssetType::EType asset_type = wearable->getAssetType(); LLUUID folder_id; @@ -1160,7 +1160,7 @@ bool LLPanelEditWearable::onSelectAutoWearOption(const LLSD& notification, const return false; } -LLWearable* LLPanelEditWearable::getWearable() const +LLViewerWearable* LLPanelEditWearable::getWearable() const { return mCurrentWearable;//gAgentWearables.getWearable(mType, mCurrentIndex); // TODO: MULTI-WEARABLE } @@ -1267,7 +1267,7 @@ void LLPanelEditWearable::saveChanges(bool force_save_as, std::string new_name) { // the name of the wearable has changed, re-save wearable with new name LLAppearanceMgr::instance().removeCOFItemLinks(getWearable()->getItemID(),false); - LLWearable* new_wearable = gAgentWearables.saveWearableAs(mType, index, new_name, FALSE); + LLViewerWearable* new_wearable = gAgentWearables.saveWearableAs(mType, index, new_name, FALSE); if(new_wearable) { mPendingWearable = new_wearable; @@ -1284,7 +1284,7 @@ void LLPanelEditWearable::saveChanges(bool force_save_as, std::string new_name) void LLPanelEditWearable::revertChanges() { - LLWearable* wearable = getWearable(); + LLViewerWearable* wearable = getWearable(); if (!wearable || !isDirty()) { // no unsaved changes to revert @@ -1383,7 +1383,7 @@ void LLPanelEditWearable::changeCamera(U8 subpart) } // Update the thumbnails we display - LLWearable* wearable = getWearable(); + LLViewerWearable* wearable = getWearable(); LLViewerInventoryItem* item = wearable ? gInventory.getItem(wearable->getItemID()) : NULL; U32 perm_mask = 0x0; BOOL is_complete = FALSE; @@ -1435,7 +1435,7 @@ void LLPanelEditWearable::updateScrollingPanelList() void LLPanelEditWearable::updateScrollingPanelUI() { - LLWearable* wearable = getWearable(); + LLViewerWearable* wearable = getWearable(); // do nothing if we don't have a valid wearable we're editing if(!wearable) { @@ -1460,7 +1460,7 @@ void LLPanelEditWearable::onBtnTakeOff( void* userdata ) { LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; - LLWearable* wearable = self->getWearable(); + LLViewerWearable* wearable = self->getWearable(); if( !wearable ) { return; @@ -1475,12 +1475,12 @@ void LLPanelEditWearable::getSortedParams(value_map_t &sorted_params, const std: { if(!getWearable())return; - LLWearable::visual_param_vec_t param_list; + LLViewerWearable::visual_param_vec_t param_list; ESex avatar_sex = gAgentAvatarp->getSex(); getWearable()->getVisualParams(param_list); - for (LLWearable::visual_param_vec_t::iterator iter = param_list.begin(); + for (LLViewerWearable::visual_param_vec_t::iterator iter = param_list.begin(); iter != param_list.end(); ++iter) { diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h index d94d59b06..05d8201e2 100644 --- a/indra/newview/llpaneleditwearable.h +++ b/indra/newview/llpaneleditwearable.h @@ -35,7 +35,7 @@ class LLAccordionCtrl; class LLCheckBoxCtrl; -class LLWearable; +class LLViewerWearable; class LLTextBox; class LLViewerInventoryItem; class LLViewerVisualParam; @@ -64,7 +64,7 @@ public: const std::string& getLabel() { return LLWearableType::getTypeLabel( mType ); } LLWearableType::EType getType() const{ return mType; } - LLWearable* getWearable() const; + LLViewerWearable* getWearable() const; void onTabChanged(LLUICtrl* ctrl); bool onTabPrecommit(); @@ -129,8 +129,8 @@ private: s32_uuid_map_t mPreviousAlphaTexture; U32 mCurrentSubpart; U32 mCurrentIndex; - LLWearable* mCurrentWearable; - LLWearable* mPendingWearable; //For SaveAs. There's a period where the old wearable will be removed, but the new one will still be pending, + LLViewerWearable* mCurrentWearable; + LLViewerWearable* mPendingWearable; //For SaveAs. There's a period where the old wearable will be removed, but the new one will still be pending, //so this is needed to retain focus on this wearables tab over the messy transition. bool mPendingRefresh; //LLAgentWearables::setWearableOutfit fires a buttload of remove/wear calls which spams wearablesChanged //a bazillion pointless (and not particularly valid) times. Deferring to draw effectively sorts it all out. diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index 7afcf82c4..85d796d9c 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -269,7 +269,7 @@ void LLScrollingPanelParam::onHintHeldDown( bool max ) && new_percent < slider->getMaxValue()) { mWearable->setVisualParamWeight(param->getID(), new_weight, FALSE); - mWearable->writeToAvatar(); + mWearable->writeToAvatar(gAgentAvatarp); gAgentAvatarp->updateVisualParams(); slider->setValue( weightToPercent( new_weight ) ); @@ -308,7 +308,7 @@ void LLScrollingPanelParam::onHintMouseUp( bool max ) && new_percent < slider->getMaxValue()) { mWearable->setVisualParamWeight(param->getID(), new_weight, FALSE); - mWearable->writeToAvatar(); + mWearable->writeToAvatar(gAgentAvatarp); slider->setValue( weightToPercent( new_weight ) ); } } diff --git a/indra/newview/llscrollingpanelparambase.cpp b/indra/newview/llscrollingpanelparambase.cpp index 0a83ac44a..672153d04 100644 --- a/indra/newview/llscrollingpanelparambase.cpp +++ b/indra/newview/llscrollingpanelparambase.cpp @@ -120,7 +120,7 @@ void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl) if (current_weight != new_weight ) { mWearable->setVisualParamWeight( mParam->getID(), new_weight, FALSE); - mWearable->writeToAvatar(); + mWearable->writeToAvatar(gAgentAvatarp); gAgentAvatarp->updateVisualParams(); } } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index c10947ff9..68017ece0 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3834,7 +3834,7 @@ void renderAgentTarget(LLVOAvatar* avatar) { renderCrossHairs(avatar->getPositionAgent(), 0.2f, LLColor4(1, 0, 0, 0.8f)); renderCrossHairs(avatar->mDrawable->getPositionAgent(), 0.2f, LLColor4(1, 0, 0, 0.8f)); - renderCrossHairs(avatar->mRoot.getWorldPosition(), 0.2f, LLColor4(1, 1, 1, 0.8f)); + renderCrossHairs(avatar->mRoot->getWorldPosition(), 0.2f, LLColor4(1, 1, 1, 0.8f)); renderCrossHairs(avatar->mPelvisp->getWorldPosition(), 0.2f, LLColor4(0, 0, 1, 0.8f)); } } @@ -3899,9 +3899,6 @@ public: return; } - LLVector4a nodeCenter = group->mBounds[0]; - LLVector4a octCenter = group->mOctreeNode->getCenter(); - group->rebuildGeom(); group->rebuildMesh(); diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp index f7929713e..5cbb60f5c 100644 --- a/indra/newview/lltoolmorph.cpp +++ b/indra/newview/lltoolmorph.cpp @@ -40,6 +40,7 @@ #include "llaudioengine.h" #include "llviewercontrol.h" #include "llfontgl.h" +#include "llwearable.h" #include "sound_ids.h" #include "v3math.h" #include "v3color.h" diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 3346e98df..22297758c 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -241,7 +241,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) // setup current color //---------------------------------------------------------------- if (is_dummy) - gGL.diffuseColor4fv(LLVOAvatar::getDummyColor().mV); + gGL.diffuseColor4fv(LLAvatarAppearance::getDummyColor().mV); else gGL.diffuseColor4fv(mColor.mV); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 5319933b5..83ee4d27f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -9185,7 +9185,7 @@ class LLEditTakeOff : public view_listener_t // We'll use the first wearable we come across that can be removed (moving from top to bottom) for (; wearable_index >= 0; wearable_index--) { - const LLWearable* pWearable = gAgentWearables.getWearable(type, wearable_index); + const LLViewerWearable* pWearable = gAgentWearables.getViewerWearable(type, wearable_index); if (!gRlvWearableLocks.isLockedWearable(pWearable)) break; } diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp index 5c82e3c8f..c708f5058 100644 --- a/indra/newview/llviewertexlayer.cpp +++ b/indra/newview/llviewertexlayer.cpp @@ -31,27 +31,16 @@ #include "llagent.h" #include "llimagej2c.h" -#include "llimagetga.h" #include "llnotificationsutil.h" #include "llvfile.h" #include "llvfs.h" -#include "llviewerstats.h" #include "llviewerregion.h" -#include "llvoavatar.h" +#include "llglslshader.h" #include "llvoavatarself.h" #include "pipeline.h" #include "llassetuploadresponders.h" -#include "lltexlayerparams.h" -#include "llui.h" -#include "llagentwearables.h" -#include "llwearable.h" #include "llviewercontrol.h" -#include "llviewershadermgr.h" -#include "llviewervisualparam.h" - -//#include "../tools/imdebug/imdebug.h" - -using namespace LLAvatarAppearanceDefines; +#include "llviewerstats.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 @@ -59,42 +48,6 @@ static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power o // runway consolidate extern std::string self_av_string(); -class LLTexLayerInfo -{ - friend class LLTexLayer; - friend class LLTexLayerTemplate; - friend class LLTexLayerInterface; -public: - LLTexLayerInfo(); - ~LLTexLayerInfo(); - - BOOL parseXml(LLXmlTreeNode* node); - BOOL createVisualParams(LLAvatarAppearance *appearance); - BOOL isUserSettable() { return mLocalTexture != -1; } - S32 getLocalTexture() const { return mLocalTexture; } - BOOL getOnlyAlpha() const { return mUseLocalTextureAlphaOnly; } - std::string getName() const { return mName; } - -private: - std::string mName; - - BOOL mWriteAllChannels; // Don't use masking. Just write RGBA into buffer, - LLTexLayerInterface::ERenderPass mRenderPass; - - std::string mGlobalColor; - LLColor4 mFixedColor; - - S32 mLocalTexture; - std::string mStaticImageFileName; - BOOL mStaticImageIsMask; - BOOL mUseLocalTextureAlphaOnly; // Ignore RGB channels from the input texture. Use alpha as a mask - BOOL mIsVisibilityMask; - - typedef std::vector< std::pair< std::string,BOOL > > morph_name_list_t; - morph_name_list_t mMorphNameList; - param_color_info_list_t mParamColorInfoList; - param_alpha_info_list_t mParamAlphaInfoList; -}; //----------------------------------------------------------------------------- // LLBakedUploadData() @@ -219,27 +172,7 @@ void LLViewerTexLayerSetBuffer::cancelUpload() mUploadRetryTimer.reset(); } -void LLViewerTexLayerSetBuffer::pushProjection() const -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); -} - -void LLViewerTexLayerSetBuffer::popProjection() const -{ - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); -} - +// virtual BOOL LLViewerTexLayerSetBuffer::needsRender() { llassert(mTexLayerSet->getAvatarAppearance() == gAgentAvatarp); @@ -272,48 +205,30 @@ BOOL LLViewerTexLayerSetBuffer::needsRender() return getViewerTexLayerSet()->isLocalTextureDataAvailable(); } -void LLViewerTexLayerSetBuffer::preRender(BOOL clear_depth) +// virtual +void LLViewerTexLayerSetBuffer::preRenderTexLayerSet() { - // Set up an ortho projection - pushProjection(); + LLTexLayerSetBuffer::preRenderTexLayerSet(); // keep depth buffer, we don't need to clear it LLViewerDynamicTexture::preRender(FALSE); } -void LLViewerTexLayerSetBuffer::postRender(BOOL success) +// virtual +void LLViewerTexLayerSetBuffer::postRenderTexLayerSet(BOOL success) { - popProjection(); + LLTexLayerSetBuffer::postRenderTexLayerSet(success); LLViewerDynamicTexture::postRender(success); } -BOOL LLViewerTexLayerSetBuffer::render() +// virtual +void LLViewerTexLayerSetBuffer::midRenderTexLayerSet(BOOL success) { - // Default color mask for tex layer render - gGL.setColorMask(true, true); - // do we need to upload, and do we have sufficient data to create an uploadable composite? // TODO: When do we upload the texture if gAgent.mNumPendingQueries is non-zero? const BOOL upload_now = mNeedsUpload && isReadyToUpload(); const BOOL update_now = mNeedsUpdate && isReadyToUpdate(); - - BOOL success = TRUE; - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - if (use_shaders) - { - gAlphaMaskProgram.bind(); - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - - LLVertexBuffer::unbind(); - - // Composite the color data - LLGLSUIDefault gls_ui; - success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); - gGL.flush(); if(upload_now) { @@ -345,21 +260,9 @@ BOOL LLViewerTexLayerSetBuffer::render() doUpdate(); } - if (use_shaders) - { - gAlphaMaskProgram.unbind(); - } - - LLVertexBuffer::unbind(); - - // reset GL state - gGL.setColorMask(true, true); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - + // *TODO: Old logic does not check success before setGLTextureCreated // we have valid texture data now mGLTexturep->setGLTextureCreated(true); - - return success; } BOOL LLViewerTexLayerSetBuffer::isInitialized(void) const @@ -480,6 +383,7 @@ void LLViewerTexLayerSetBuffer::doUpload() LLPointer baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 ); U8* baked_mask_data = baked_mask_image->getData(); layer_set->gatherMorphMaskAlpha(baked_mask_data, + mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight); @@ -724,189 +628,15 @@ void LLViewerTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, // An ordered set of texture layers that get composited into a single texture. //----------------------------------------------------------------------------- -LLTexLayerSetInfo::LLTexLayerSetInfo() : - mBodyRegion( "" ), - mWidth( 512 ), - mHeight( 512 ), - mClearAlpha( TRUE ) -{ -} - -LLTexLayerSetInfo::~LLTexLayerSetInfo( ) -{ - std::for_each(mLayerInfoList.begin(), mLayerInfoList.end(), DeletePointer()); -} - -BOOL LLTexLayerSetInfo::parseXml(LLXmlTreeNode* node) -{ - llassert( node->hasName( "layer_set" ) ); - if( !node->hasName( "layer_set" ) ) - { - return FALSE; - } - - // body_region - static LLStdStringHandle body_region_string = LLXmlTree::addAttributeString("body_region"); - if( !node->getFastAttributeString( body_region_string, mBodyRegion ) ) - { - llwarns << " is missing body_region attribute" << llendl; - return FALSE; - } - - // width, height - static LLStdStringHandle width_string = LLXmlTree::addAttributeString("width"); - if( !node->getFastAttributeS32( width_string, mWidth ) ) - { - return FALSE; - } - - static LLStdStringHandle height_string = LLXmlTree::addAttributeString("height"); - if( !node->getFastAttributeS32( height_string, mHeight ) ) - { - return FALSE; - } - - // Optional alpha component to apply after all compositing is complete. - static LLStdStringHandle alpha_tga_file_string = LLXmlTree::addAttributeString("alpha_tga_file"); - node->getFastAttributeString( alpha_tga_file_string, mStaticAlphaFileName ); - - static LLStdStringHandle clear_alpha_string = LLXmlTree::addAttributeString("clear_alpha"); - node->getFastAttributeBOOL( clear_alpha_string, mClearAlpha ); - - // - for (LLXmlTreeNode* child = node->getChildByName( "layer" ); - child; - child = node->getNextNamedChild()) - { - LLTexLayerInfo* info = new LLTexLayerInfo(); - if( !info->parseXml( child )) - { - delete info; - return FALSE; - } - mLayerInfoList.push_back( info ); - } - return TRUE; -} - -// creates visual params without generating layersets or layers -void LLTexLayerSetInfo::createVisualParams(LLAvatarAppearance *appearance) -{ - //layer_info_list_t mLayerInfoList; - for (layer_info_list_t::iterator layer_iter = mLayerInfoList.begin(); - layer_iter != mLayerInfoList.end(); - layer_iter++) - { - LLTexLayerInfo *layer_info = *layer_iter; - layer_info->createVisualParams(appearance); - } -} - -//----------------------------------------------------------------------------- -// LLTexLayerSet -// An ordered set of texture layers that get composited into a single texture. -//----------------------------------------------------------------------------- - LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) : LLTexLayerSet(appearance), - mComposite( NULL ), - mUpdatesEnabled( FALSE ), - mIsVisible( TRUE ), - mBakedTexIndex(LLAvatarAppearanceDefines::BAKED_HEAD), - mInfo( NULL ) + mUpdatesEnabled( FALSE ) { } // virtual LLViewerTexLayerSet::~LLViewerTexLayerSet() { - deleteCaches(); - std::for_each(mLayerList.begin(), mLayerList.end(), DeletePointer()); - std::for_each(mMaskLayerList.begin(), mMaskLayerList.end(), DeletePointer()); -} - -//----------------------------------------------------------------------------- -// setInfo -//----------------------------------------------------------------------------- - -BOOL LLViewerTexLayerSet::setInfo(const LLTexLayerSetInfo *info) -{ - llassert(mInfo == NULL); - mInfo = info; - //mID = info->mID; // No ID - - mLayerList.reserve(info->mLayerInfoList.size()); - for (LLTexLayerSetInfo::layer_info_list_t::const_iterator iter = info->mLayerInfoList.begin(); - iter != info->mLayerInfoList.end(); - iter++) - { - LLTexLayerInterface *layer = NULL; - if ( (*iter)->isUserSettable() ) - { - layer = new LLTexLayerTemplate( this ); - } - else - { - layer = new LLTexLayer(this); - } - // this is the first time this layer (of either type) is being created - make sure you add the parameters to the avatar - if (!layer->setInfo(*iter, NULL)) - { - mInfo = NULL; - return FALSE; - } - if (!layer->isVisibilityMask()) - { - mLayerList.push_back( layer ); - } - else - { - mMaskLayerList.push_back(layer); - } - } - - requestUpdate(); - - stop_glerror(); - - return TRUE; -} - -#if 0 // obsolete -//----------------------------------------------------------------------------- -// parseData -//----------------------------------------------------------------------------- - -BOOL LLTexLayerSet::parseData(LLXmlTreeNode* node) -{ - LLTexLayerSetInfo *info = new LLTexLayerSetInfo; - - if (!info->parseXml(node)) - { - delete info; - return FALSE; - } - if (!setInfo(info)) - { - delete info; - return FALSE; - } - return TRUE; -} -#endif - -void LLViewerTexLayerSet::deleteCaches() -{ - for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - layer->deleteCaches(); - } - for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++) - { - LLTexLayerInterface* layer = *iter; - layer->deleteCaches(); - } } // Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on. @@ -925,105 +655,6 @@ BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const } -BOOL LLViewerTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) -{ - BOOL success = TRUE; - mIsVisible = TRUE; - - if (mMaskLayerList.size() > 0) - { - for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++) - { - LLTexLayerInterface* layer = *iter; - if (layer->isInvisibleAlphaMask()) - { - mIsVisible = FALSE; - } - } - } - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - LLGLSUIDefault gls_ui; - LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE); - gGL.setColorMask(true, true); - - // clear buffer area to ensure we don't pick up UI elements - { - gGL.flush(); - LLGLDisable no_alpha(GL_ALPHA_TEST); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.0f); - } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f( 0.f, 0.f, 0.f, 1.f ); - - gl_rect_2d_simple( width, height ); - - gGL.flush(); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - } - - if (mIsVisible) - { - // composite color layers - for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - if (layer->getRenderPass() == LLTexLayer::RP_COLOR) - { - gGL.flush(); - success &= layer->render(x, y, width, height); - gGL.flush(); - } - } - - renderAlphaMaskTextures(x, y, width, height, false); - - stop_glerror(); - } - else - { - gGL.flush(); - - gGL.setSceneBlendType(LLRender::BT_REPLACE); - LLGLDisable no_alpha(GL_ALPHA_TEST); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f( 0.f, 0.f, 0.f, 0.f ); - - gl_rect_2d_simple( width, height ); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gGL.flush(); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - } - - return success; -} - - -BOOL LLViewerTexLayerSet::isBodyRegion(const std::string& region) const -{ - return mInfo->mBodyRegion == region; -} - -const std::string LLViewerTexLayerSet::getBodyRegionName() const -{ - return mInfo->mBodyRegion; -} - void LLViewerTexLayerSet::requestUpdate() { if( mUpdatesEnabled ) @@ -1069,14 +700,6 @@ void LLViewerTexLayerSet::createComposite() } } -void LLViewerTexLayerSet::destroyComposite() -{ - if( mComposite ) - { - mComposite = NULL; - } -} - void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b ) { mUpdatesEnabled = b; @@ -1102,1284 +725,7 @@ const LLViewerTexLayerSetBuffer* LLViewerTexLayerSet::getViewerComposite() const return dynamic_cast (getComposite()); } -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); -} - -void LLViewerTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear) -{ - const LLTexLayerSetInfo *info = getInfo(); - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - gGL.setColorMask(false, true); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - - // (Optionally) replace alpha with a single component image from a tga file. - if (!info->mStaticAlphaFileName.empty()) - { - gGL.flush(); - { - LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(info->mStaticAlphaFileName, TRUE); - if( tex ) - { - LLGLSUIDefault gls_ui; - gGL.getTexUnit(0)->bind(tex); - gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE ); - gl_rect_2d_simple_tex( width, height ); - } - } - gGL.flush(); - } - else if (forceClear || info->mClearAlpha || (mMaskLayerList.size() > 0)) - { - // Set the alpha channel to one (clean up after previous blending) - gGL.flush(); - LLGLDisable no_alpha(GL_ALPHA_TEST); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f( 0.f, 0.f, 0.f, 1.f ); - - gl_rect_2d_simple( width, height ); - - gGL.flush(); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - } - - // (Optional) Mask out part of the baked texture with alpha masks - // will still have an effect even if mClearAlpha is set or the alpha component was replaced - if (mMaskLayerList.size() > 0) - { - gGL.setSceneBlendType(LLRender::BT_MULT_ALPHA); - gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE ); - for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++) - { - LLTexLayerInterface* layer = *iter; - gGL.flush(); - layer->blendAlphaTexture(x,y,width, height); - gGL.flush(); - } - - } - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - gGL.setColorMask(true, true); - gGL.setSceneBlendType(LLRender::BT_ALPHA); -} - -void LLViewerTexLayerSet::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components) -{ - mAvatarAppearance->applyMorphMask(tex_data, width, height, num_components, mBakedTexIndex); -} - -BOOL LLViewerTexLayerSet::isMorphValid() const -{ - for(layer_list_t::const_iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - const LLTexLayerInterface* layer = *iter; - if (layer && !layer->isMorphValid()) - { - return FALSE; - } - } - return TRUE; -} - -void LLViewerTexLayerSet::invalidateMorphMasks() -{ - for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - if (layer) - { - layer->invalidateMorphMasks(); - } - } -} - - -//----------------------------------------------------------------------------- -// LLTexLayerInfo -//----------------------------------------------------------------------------- -LLTexLayerInfo::LLTexLayerInfo() : - mWriteAllChannels( FALSE ), - mRenderPass(LLTexLayer::RP_COLOR), - mFixedColor( 0.f, 0.f, 0.f, 0.f ), - mLocalTexture( -1 ), - mStaticImageIsMask( FALSE ), - mUseLocalTextureAlphaOnly(FALSE), - mIsVisibilityMask(FALSE) -{ -} - -LLTexLayerInfo::~LLTexLayerInfo( ) -{ - std::for_each(mParamColorInfoList.begin(), mParamColorInfoList.end(), DeletePointer()); - std::for_each(mParamAlphaInfoList.begin(), mParamAlphaInfoList.end(), DeletePointer()); -} - -BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node) -{ - llassert( node->hasName( "layer" ) ); - - // name attribute - static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); - if( !node->getFastAttributeString( name_string, mName ) ) - { - return FALSE; - } - - static LLStdStringHandle write_all_channels_string = LLXmlTree::addAttributeString("write_all_channels"); - node->getFastAttributeBOOL( write_all_channels_string, mWriteAllChannels ); - - std::string render_pass_name; - static LLStdStringHandle render_pass_string = LLXmlTree::addAttributeString("render_pass"); - if( node->getFastAttributeString( render_pass_string, render_pass_name ) ) - { - if( render_pass_name == "bump" ) - { - mRenderPass = LLTexLayer::RP_BUMP; - } - } - - // Note: layers can have either a "global_color" attrib, a "fixed_color" attrib, or a child. - // global color attribute (optional) - static LLStdStringHandle global_color_string = LLXmlTree::addAttributeString("global_color"); - node->getFastAttributeString( global_color_string, mGlobalColor ); - - // Visibility mask (optional) - BOOL is_visibility; - static LLStdStringHandle visibility_mask_string = LLXmlTree::addAttributeString("visibility_mask"); - if (node->getFastAttributeBOOL(visibility_mask_string, is_visibility)) - { - mIsVisibilityMask = is_visibility; - } - - // color attribute (optional) - LLColor4U color4u; - static LLStdStringHandle fixed_color_string = LLXmlTree::addAttributeString("fixed_color"); - if( node->getFastAttributeColor4U( fixed_color_string, color4u ) ) - { - mFixedColor.setVec( color4u ); - } - - // optional sub-element - for (LLXmlTreeNode* texture_node = node->getChildByName( "texture" ); - texture_node; - texture_node = node->getNextNamedChild()) - { - std::string local_texture_name; - static LLStdStringHandle tga_file_string = LLXmlTree::addAttributeString("tga_file"); - static LLStdStringHandle local_texture_string = LLXmlTree::addAttributeString("local_texture"); - static LLStdStringHandle file_is_mask_string = LLXmlTree::addAttributeString("file_is_mask"); - static LLStdStringHandle local_texture_alpha_only_string = LLXmlTree::addAttributeString("local_texture_alpha_only"); - if( texture_node->getFastAttributeString( tga_file_string, mStaticImageFileName ) ) - { - texture_node->getFastAttributeBOOL( file_is_mask_string, mStaticImageIsMask ); - } - else if (texture_node->getFastAttributeString(local_texture_string, local_texture_name)) - { - texture_node->getFastAttributeBOOL( local_texture_alpha_only_string, mUseLocalTextureAlphaOnly ); - - /* if ("upper_shirt" == local_texture_name) - mLocalTexture = TEX_UPPER_SHIRT; */ - mLocalTexture = TEX_NUM_INDICES; - for (LLAvatarAppearanceDictionary::Textures::const_iterator iter = LLAvatarAppearanceDictionary::getInstance()->getTextures().begin(); - iter != LLAvatarAppearanceDictionary::getInstance()->getTextures().end(); - iter++) - { - const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = iter->second; - if (local_texture_name == texture_dict->mName) - { - mLocalTexture = iter->first; - break; - } - } - if (mLocalTexture == TEX_NUM_INDICES) - { - llwarns << " element has invalid local_texture attribute: " << mName << " " << local_texture_name << llendl; - return FALSE; - } - } - else - { - llwarns << " element is missing a required attribute. " << mName << llendl; - return FALSE; - } - } - - for (LLXmlTreeNode* maskNode = node->getChildByName( "morph_mask" ); - maskNode; - maskNode = node->getNextNamedChild()) - { - std::string morph_name; - static LLStdStringHandle morph_name_string = LLXmlTree::addAttributeString("morph_name"); - if (maskNode->getFastAttributeString(morph_name_string, morph_name)) - { - BOOL invert = FALSE; - static LLStdStringHandle invert_string = LLXmlTree::addAttributeString("invert"); - maskNode->getFastAttributeBOOL(invert_string, invert); - mMorphNameList.push_back(std::pair(morph_name,invert)); - } - } - - // optional sub-element (color or alpha params) - for (LLXmlTreeNode* child = node->getChildByName( "param" ); - child; - child = node->getNextNamedChild()) - { - if( child->getChildByName( "param_color" ) ) - { - // - LLTexLayerParamColorInfo* info = new LLTexLayerParamColorInfo(); - if (!info->parseXml(child)) - { - delete info; - return FALSE; - } - mParamColorInfoList.push_back(info); - } - else if( child->getChildByName( "param_alpha" ) ) - { - // - LLTexLayerParamAlphaInfo* info = new LLTexLayerParamAlphaInfo( ); - if (!info->parseXml(child)) - { - delete info; - return FALSE; - } - mParamAlphaInfoList.push_back(info); - } - } - - return TRUE; -} - -BOOL LLTexLayerInfo::createVisualParams(LLAvatarAppearance *appearance) -{ - BOOL success = TRUE; - for (param_color_info_list_t::iterator color_info_iter = mParamColorInfoList.begin(); - color_info_iter != mParamColorInfoList.end(); - color_info_iter++) - { - LLTexLayerParamColorInfo * color_info = *color_info_iter; - LLTexLayerParamColor* param_color = new LLTexLayerParamColor(appearance); - if (!param_color->setInfo(color_info, TRUE)) - { - llwarns << "NULL TexLayer Color Param could not be added to visual param list. Deleting." << llendl; - delete param_color; - success = FALSE; - } - } - - for (param_alpha_info_list_t::iterator alpha_info_iter = mParamAlphaInfoList.begin(); - alpha_info_iter != mParamAlphaInfoList.end(); - alpha_info_iter++) - { - LLTexLayerParamAlphaInfo * alpha_info = *alpha_info_iter; - LLTexLayerParamAlpha* param_alpha = new LLTexLayerParamAlpha(appearance); - if (!param_alpha->setInfo(alpha_info, TRUE)) - { - llwarns << "NULL TexLayer Alpha Param could not be added to visual param list. Deleting." << llendl; - delete param_alpha; - success = FALSE; - } - } - - return success; -} - -LLTexLayerInterface::LLTexLayerInterface(LLTexLayerSet* const layer_set): - mTexLayerSet( layer_set ), - mMorphMasksValid( FALSE ), - mInfo(NULL), - mHasMorph(FALSE) -{ -} - -LLTexLayerInterface::LLTexLayerInterface(const LLTexLayerInterface &layer, LLWearable *wearable): - mTexLayerSet( layer.mTexLayerSet ), - mInfo(NULL) -{ - // don't add visual params for cloned layers - setInfo(layer.getInfo(), wearable); - - mHasMorph = layer.mHasMorph; -} - -BOOL LLTexLayerInterface::setInfo(const LLTexLayerInfo *info, LLWearable* wearable ) // This sets mInfo and calls initialization functions -{ - // setInfo should only be called once. Code is not robust enough to handle redefinition of a texlayer. - // Not a critical warning, but could be useful for debugging later issues. -Nyx - if (mInfo != NULL) - { - llwarns << "mInfo != NULL" << llendl; - } - mInfo = info; - //mID = info->mID; // No ID - - mParamColorList.reserve(mInfo->mParamColorInfoList.size()); - for (param_color_info_list_t::const_iterator iter = mInfo->mParamColorInfoList.begin(); - iter != mInfo->mParamColorInfoList.end(); - iter++) - { - LLTexLayerParamColor* param_color; - if (!wearable) - { - param_color = new LLTexLayerParamColor(this); - if (!param_color->setInfo(*iter, TRUE)) - { - mInfo = NULL; - return FALSE; - } - } - else - { - param_color = (LLTexLayerParamColor*)wearable->getVisualParam((*iter)->getID()); - if (!param_color) - { - mInfo = NULL; - return FALSE; - } - } - mParamColorList.push_back( param_color ); - } - - mParamAlphaList.reserve(mInfo->mParamAlphaInfoList.size()); - for (param_alpha_info_list_t::const_iterator iter = mInfo->mParamAlphaInfoList.begin(); - iter != mInfo->mParamAlphaInfoList.end(); - iter++) - { - LLTexLayerParamAlpha* param_alpha; - if (!wearable) - { - param_alpha = new LLTexLayerParamAlpha( this ); - if (!param_alpha->setInfo(*iter, TRUE)) - { - mInfo = NULL; - return FALSE; - } - } - else - { - param_alpha = (LLTexLayerParamAlpha*) wearable->getVisualParam((*iter)->getID()); - if (!param_alpha) - { - mInfo = NULL; - return FALSE; - } - } - mParamAlphaList.push_back( param_alpha ); - } - - return TRUE; -} - -/*virtual*/ void LLTexLayerInterface::requestUpdate() -{ - mTexLayerSet->requestUpdate(); -} - -const std::string& LLTexLayerInterface::getName() const -{ - return mInfo->mName; -} - -LLTexLayerInterface::ERenderPass LLTexLayerInterface::getRenderPass() const -{ - return mInfo->mRenderPass; -} - -const std::string& LLTexLayerInterface::getGlobalColor() const -{ - return mInfo->mGlobalColor; -} - -BOOL LLTexLayerInterface::isVisibilityMask() const -{ - return mInfo->mIsVisibilityMask; -} - -void LLTexLayerInterface::invalidateMorphMasks() -{ - mMorphMasksValid = FALSE; -} - -LLViewerVisualParam* LLTexLayerInterface::getVisualParamPtr(S32 index) const -{ - LLViewerVisualParam *result = NULL; - for (param_color_list_t::const_iterator color_iter = mParamColorList.begin(); color_iter != mParamColorList.end() && !result; ++color_iter) - { - if ((*color_iter)->getID() == index) - { - result = *color_iter; - } - } - for (param_alpha_list_t::const_iterator alpha_iter = mParamAlphaList.begin(); alpha_iter != mParamAlphaList.end() && !result; ++alpha_iter) - { - if ((*alpha_iter)->getID() == index) - { - result = *alpha_iter; - } - } - - return result; -} - -//----------------------------------------------------------------------------- -// LLTexLayer -// A single texture layer, consisting of: -// * color, consisting of either -// * one or more color parameters (weighted colors) -// * a reference to a global color -// * a fixed color with non-zero alpha -// * opaque white (the default) -// * (optional) a texture defined by either -// * a GUID -// * a texture entry index (TE) -// * (optional) one or more alpha parameters (weighted alpha textures) -//----------------------------------------------------------------------------- -LLTexLayer::LLTexLayer(LLTexLayerSet* const layer_set) : - LLTexLayerInterface( layer_set ), - mLocalTextureObject(NULL) -{ -} - -LLTexLayer::LLTexLayer(const LLTexLayer &layer, LLWearable *wearable) : - LLTexLayerInterface( layer, wearable ), - mLocalTextureObject(NULL) -{ -} - -LLTexLayer::LLTexLayer(const LLTexLayerTemplate &layer_template, LLLocalTextureObject *lto, LLWearable *wearable) : - LLTexLayerInterface( layer_template, wearable ), - mLocalTextureObject(lto) -{ -} - -LLTexLayer::~LLTexLayer() -{ - // mParamAlphaList and mParamColorList are LLViewerVisualParam's and get - // deleted with ~LLCharacter() - //std::for_each(mParamAlphaList.begin(), mParamAlphaList.end(), DeletePointer()); - //std::for_each(mParamColorList.begin(), mParamColorList.end(), DeletePointer()); - - for( alpha_cache_t::iterator iter = mAlphaCache.begin(); - iter != mAlphaCache.end(); iter++ ) - { - U8* alpha_data = iter->second; - delete [] alpha_data; - } - -} - -//----------------------------------------------------------------------------- -// setInfo -//----------------------------------------------------------------------------- - -BOOL LLTexLayer::setInfo(const LLTexLayerInfo* info, LLWearable* wearable ) -{ - return LLTexLayerInterface::setInfo(info, wearable); -} - -//static -void LLTexLayer::calculateTexLayerColor(const param_color_list_t ¶m_list, LLColor4 &net_color) -{ - for (param_color_list_t::const_iterator iter = param_list.begin(); - iter != param_list.end(); iter++) - { - const LLTexLayerParamColor* param = *iter; - LLColor4 param_net = param->getNetColor(); - const LLTexLayerParamColorInfo *info = (LLTexLayerParamColorInfo *)param->getInfo(); - switch(info->getOperation()) - { - case LLTexLayerParamColor::OP_ADD: - net_color += param_net; - break; - case LLTexLayerParamColor::OP_MULTIPLY: - net_color = net_color * param_net; - break; - case LLTexLayerParamColor::OP_BLEND: - net_color = lerp(net_color, param_net, param->getWeight()); - break; - default: - llassert(0); - break; - } - } - net_color.clamp(); -} - -/*virtual*/ void LLTexLayer::deleteCaches() -{ - // Only need to delete caches for alpha params. Color params don't hold extra memory - for (param_alpha_list_t::iterator iter = mParamAlphaList.begin(); - iter != mParamAlphaList.end(); iter++ ) - { - LLTexLayerParamAlpha* param = *iter; - param->deleteCaches(); - } -} - -BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) -{ - LLGLEnable color_mat(GL_COLOR_MATERIAL); - gPipeline.disableLights(); - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - LLColor4 net_color; - BOOL color_specified = findNetColor(&net_color); - - if (dynamic_cast(mTexLayerSet)->getAvatar()->mIsDummy) - { - color_specified = true; - net_color = LLVOAvatar::getDummyColor(); - } - - BOOL success = TRUE; - - // If you can't see the layer, don't render it. - if( is_approx_zero( net_color.mV[VW] ) ) - { - return success; - } - - BOOL alpha_mask_specified = FALSE; - param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); - if( iter != mParamAlphaList.end() ) - { - // If we have alpha masks, but we're skipping all of them, skip the whole layer. - // However, we can't do this optimization if we have morph masks that need updating. -/* if (!mHasMorph) - { - BOOL skip_layer = TRUE; - - while( iter != mParamAlphaList.end() ) - { - const LLTexLayerParamAlpha* param = *iter; - - if( !param->getSkip() ) - { - skip_layer = FALSE; - break; - } - - iter++; - } - - if( skip_layer ) - { - return success; - } - }//*/ - - renderMorphMasks(x, y, width, height, net_color); - alpha_mask_specified = TRUE; - gGL.flush(); - gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_ONE_MINUS_DEST_ALPHA); - } - - gGL.color4fv( net_color.mV); - - if( getInfo()->mWriteAllChannels ) - { - gGL.flush(); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - } - - if( (getInfo()->mLocalTexture != -1) && !getInfo()->mUseLocalTextureAlphaOnly ) - { - { - LLViewerTexture* tex = NULL; - if (mLocalTextureObject && mLocalTextureObject->getImage()) - { - tex = mLocalTextureObject->getImage(); - if (mLocalTextureObject->getID() == IMG_DEFAULT_AVATAR) - { - tex = NULL; - } - } - else - { - llinfos << "lto not defined or image not defined: " << getInfo()->getLocalTexture() << " lto: " << mLocalTextureObject << llendl; - } -// if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) ) - { - if( tex ) - { - bool no_alpha_test = getInfo()->mWriteAllChannels; - LLGLDisable alpha_test(no_alpha_test ? GL_ALPHA_TEST : 0); - if (use_shaders && no_alpha_test) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - - LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); - - gGL.getTexUnit(0)->bind(tex, TRUE); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - - gl_rect_2d_simple_tex( width, height ); - - gGL.getTexUnit(0)->setTextureAddressMode(old_mode); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - if (use_shaders && no_alpha_test) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - - } - } -// else -// { -// success = FALSE; -// } - } - } - - if( !getInfo()->mStaticImageFileName.empty() ) - { - { - LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); - if( tex ) - { - gGL.getTexUnit(0)->bind(tex, TRUE); - gl_rect_2d_simple_tex( width, height ); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - else - { - success = FALSE; - } - } - } - - if(((-1 == getInfo()->mLocalTexture) || - getInfo()->mUseLocalTextureAlphaOnly) && - getInfo()->mStaticImageFileName.empty() && - color_specified ) - { - LLGLDisable no_alpha(GL_ALPHA_TEST); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4fv( net_color.mV ); - gl_rect_2d_simple( width, height ); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - } - - if( alpha_mask_specified || getInfo()->mWriteAllChannels ) - { - // Restore standard blend func value - gGL.flush(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - stop_glerror(); - } - - if( !success ) - { - llinfos << "LLTexLayer::render() partial: " << getInfo()->mName << llendl; - } - return success; -} - -const U8* LLTexLayer::getAlphaData() const -{ - LLCRC alpha_mask_crc; - const LLUUID& uuid = getUUID(); - alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES); - - for (param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++) - { - const LLTexLayerParamAlpha* param = *iter; - // MULTI-WEARABLE: verify visual parameters used here - F32 param_weight = param->getWeight(); - alpha_mask_crc.update((U8*)¶m_weight, sizeof(F32)); - } - - U32 cache_index = alpha_mask_crc.getCRC(); - - alpha_cache_t::const_iterator iter2 = mAlphaCache.find(cache_index); - return (iter2 == mAlphaCache.end()) ? 0 : iter2->second; -} - -BOOL LLTexLayer::findNetColor(LLColor4* net_color) const -{ - // Color is either: - // * one or more color parameters (weighted colors) (which may make use of a global color or fixed color) - // * a reference to a global color - // * a fixed color with non-zero alpha - // * opaque white (the default) - - if( !mParamColorList.empty() ) - { - if( !getGlobalColor().empty() ) - { - net_color->setVec( mTexLayerSet->getAvatarAppearance()->getGlobalColor( getInfo()->mGlobalColor ) ); - } - else if (getInfo()->mFixedColor.mV[VW]) - { - net_color->setVec( getInfo()->mFixedColor ); - } - else - { - net_color->setVec( 0.f, 0.f, 0.f, 0.f ); - } - - calculateTexLayerColor(mParamColorList, *net_color); - return TRUE; - } - - if( !getGlobalColor().empty() ) - { - net_color->setVec( mTexLayerSet->getAvatarAppearance()->getGlobalColor( getGlobalColor() ) ); - return TRUE; - } - - if( getInfo()->mFixedColor.mV[VW] ) - { - net_color->setVec( getInfo()->mFixedColor ); - return TRUE; - } - - net_color->setToWhite(); - - return FALSE; // No need to draw a separate colored polygon -} - -BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) -{ - BOOL success = TRUE; - - gGL.flush(); - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - if( !getInfo()->mStaticImageFileName.empty() ) - { - LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask ); - if( tex ) - { - LLGLSNoAlphaTest gls_no_alpha_test; - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - gGL.getTexUnit(0)->bind(tex, TRUE); - gl_rect_2d_simple_tex( width, height ); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - } - else - { - success = FALSE; - } - } - else - { - if (getInfo()->mLocalTexture >=0 && getInfo()->mLocalTexture < TEX_NUM_INDICES) - { - LLViewerTexture* tex = mLocalTextureObject->getImage(); - if (tex) - { - LLGLSNoAlphaTest gls_no_alpha_test; - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - gGL.getTexUnit(0)->bind(tex); - gl_rect_2d_simple_tex( width, height ); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - success = TRUE; - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - } - } - } - - return success; -} - -/*virtual*/ void LLTexLayer::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) -{ - addAlphaMask(data, originX, originY, width, height); -} - -BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLColor4 &layer_color) -{ - BOOL success = TRUE; - - llassert( !mParamAlphaList.empty() ); - - bool use_shaders = LLGLSLShader::sNoFixedFunction; - - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.f); - } - - gGL.setColorMask(false, true); - - LLTexLayerParamAlpha* first_param = *mParamAlphaList.begin(); - // Note: if the first param is a mulitply, multiply against the current buffer's alpha - if( !first_param || !first_param->getMultiplyBlend() ) - { - LLGLDisable no_alpha(GL_ALPHA_TEST); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - // Clear the alpha - gGL.flush(); - gGL.setSceneBlendType(LLRender::BT_REPLACE); - - gGL.color4f( 0.f, 0.f, 0.f, 0.f ); - gl_rect_2d_simple( width, height ); - } - - // Accumulate alphas - LLGLSNoAlphaTest gls_no_alpha_test; - gGL.color4f( 1.f, 1.f, 1.f, 1.f ); - for (param_alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++) - { - LLTexLayerParamAlpha* param = *iter; - success &= param->render( x, y, width, height ); - } - - // Approximates a min() function - gGL.flush(); - gGL.setSceneBlendType(LLRender::BT_MULT_ALPHA); - - // Accumulate the alpha component of the texture - if( getInfo()->mLocalTexture != -1 ) - { - LLViewerTexture* tex = mLocalTextureObject->getImage(); - if( tex && (tex->getComponents() == 4) ) - { - LLGLSNoAlphaTest gls_no_alpha_test; - LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); - - gGL.getTexUnit(0)->bind(tex, TRUE); - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - - gl_rect_2d_simple_tex( width, height ); - - gGL.getTexUnit(0)->setTextureAddressMode(old_mode); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - } - - if( !getInfo()->mStaticImageFileName.empty() ) - { - LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); - if( tex ) - { - if( (tex->getComponents() == 4) || - ( (tex->getComponents() == 1) && getInfo()->mStaticImageIsMask ) ) - { - LLGLSNoAlphaTest gls_no_alpha_test; - gGL.getTexUnit(0)->bind(tex, TRUE); - gl_rect_2d_simple_tex( width, height ); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - } - } - - // Draw a rectangle with the layer color to multiply the alpha by that color's alpha. - // Note: we're still using gGL.blendFunc( GL_DST_ALPHA, GL_ZERO ); - if (layer_color.mV[VW] != 1.f) - { - LLGLDisable no_alpha(GL_ALPHA_TEST); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4fv(layer_color.mV); - gl_rect_2d_simple( width, height ); - } - - if (use_shaders) - { - gAlphaMaskProgram.setMinimumAlpha(0.004f); - } - - LLGLSUIDefault gls_ui; - - gGL.setColorMask(true, true); - - if (hasMorph() && success) - { - LLCRC alpha_mask_crc; - const LLUUID& uuid = getUUID(); - alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES); - - for (param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++) - { - const LLTexLayerParamAlpha* param = *iter; - F32 param_weight = param->getWeight(); - alpha_mask_crc.update((U8*)¶m_weight, sizeof(F32)); - } - - U32 cache_index = alpha_mask_crc.getCRC(); - U8* alpha_data = get_if_there(mAlphaCache,cache_index,(U8*)NULL); - if (!alpha_data) - { - // clear out a slot if we have filled our cache - S32 max_cache_entries = getTexLayerSet()->getAvatarAppearance()->isSelf() ? 4 : 1; - while ((S32)mAlphaCache.size() >= max_cache_entries) - { - alpha_cache_t::iterator iter2 = mAlphaCache.begin(); // arbitrarily grab the first entry - alpha_data = iter2->second; - delete [] alpha_data; - mAlphaCache.erase(iter2); - } - alpha_data = new U8[width * height]; - mAlphaCache[cache_index] = alpha_data; - glReadPixels(x, y, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_data); - } - - getTexLayerSet()->getAvatarAppearance()->dirtyMesh(); - - mMorphMasksValid = TRUE; - dynamic_cast(getTexLayerSet())->applyMorphMask(alpha_data, width, height, 1); - } - - return success; -} - -void LLTexLayer::addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height) -{ - S32 size = width * height; - const U8* alphaData = getAlphaData(); - if (!alphaData && hasAlphaParams()) - { - LLColor4 net_color; - findNetColor( &net_color ); - // TODO: eliminate need for layer morph mask valid flag - invalidateMorphMasks(); - renderMorphMasks(originX, originY, width, height, net_color); - alphaData = getAlphaData(); - } - if (alphaData) - { - for( S32 i = 0; i < size; i++ ) - { - U8 curAlpha = data[i]; - U16 resultAlpha = curAlpha; - resultAlpha *= (alphaData[i] + 1); - resultAlpha = resultAlpha >> 8; - data[i] = (U8)resultAlpha; - } - } -} - -/*virtual*/ BOOL LLTexLayer::isInvisibleAlphaMask() const -{ - if (mLocalTextureObject) - { - if (mLocalTextureObject->getID() == IMG_INVISIBLE) - { - return TRUE; - } - } - - return FALSE; -} - -LLUUID LLTexLayer::getUUID() const -{ - LLUUID uuid; - if( getInfo()->mLocalTexture != -1 ) - { - LLViewerTexture* tex = mLocalTextureObject->getImage(); - if (tex) - { - uuid = mLocalTextureObject->getID(); - } - } - if( !getInfo()->mStaticImageFileName.empty() ) - { - LLGLTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); - if( tex ) - { - uuid = tex->getID(); - } - } - return uuid; -} - - -//----------------------------------------------------------------------------- -// LLTexLayerTemplate -// A single texture layer, consisting of: -// * color, consisting of either -// * one or more color parameters (weighted colors) -// * a reference to a global color -// * a fixed color with non-zero alpha -// * opaque white (the default) -// * (optional) a texture defined by either -// * a GUID -// * a texture entry index (TE) -// * (optional) one or more alpha parameters (weighted alpha textures) -//----------------------------------------------------------------------------- -LLTexLayerTemplate::LLTexLayerTemplate(LLTexLayerSet* layer_set) : - LLTexLayerInterface(layer_set) -{ -} - -LLTexLayerTemplate::LLTexLayerTemplate(const LLTexLayerTemplate &layer) : - LLTexLayerInterface(layer) -{ -} - -LLTexLayerTemplate::~LLTexLayerTemplate() -{ -} - -//----------------------------------------------------------------------------- -// setInfo -//----------------------------------------------------------------------------- - -/*virtual*/ BOOL LLTexLayerTemplate::setInfo(const LLTexLayerInfo* info, LLWearable* wearable ) -{ - return LLTexLayerInterface::setInfo(info, wearable); -} - -U32 LLTexLayerTemplate::updateWearableCache() const -{ - mWearableCache.clear(); - - S32 te = mInfo->mLocalTexture; - if (te == -1) - { - //this isn't a cloneable layer - return 0; - } - LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getTEWearableType((ETextureIndex)te); - U32 num_wearables = gAgentWearables.getWearableCount(wearable_type); - U32 added = 0; - for (U32 i = 0; i < num_wearables; i++) - { - LLWearable* wearable = gAgentWearables.getWearable(wearable_type, i); - if (!wearable) - { - continue; - } - mWearableCache.push_back(wearable); - added++; - } - return added; -} -LLTexLayer* LLTexLayerTemplate::getLayer(U32 i) const -{ - if (mWearableCache.size() <= i) - { - return NULL; - } - LLWearable *wearable = mWearableCache[i]; - LLLocalTextureObject *lto = NULL; - LLTexLayer *layer = NULL; - if (wearable) - { - lto = wearable->getLocalTextureObject(mInfo->mLocalTexture); - } - if (lto) - { - layer = lto->getTexLayer(getName()); - } - return layer; -} - -/*virtual*/ BOOL LLTexLayerTemplate::render(S32 x, S32 y, S32 width, S32 height) -{ - if(!mInfo) - { - return FALSE ; - } - - BOOL success = TRUE; - updateWearableCache(); - for (wearable_cache_t::const_iterator iter = mWearableCache.begin(); iter!= mWearableCache.end(); iter++) - { - LLWearable* wearable = NULL; - LLLocalTextureObject *lto = NULL; - LLTexLayer *layer = NULL; - wearable = *iter; - if (wearable) - { - lto = wearable->getLocalTextureObject(mInfo->mLocalTexture); - } - if (lto) - { - layer = lto->getTexLayer(getName()); - } - if (layer) - { - wearable->writeToAvatar(); - layer->setLTO(lto); - success &= layer->render(x,y,width,height); - } - } - - return success; -} - -/*virtual*/ BOOL LLTexLayerTemplate::blendAlphaTexture( S32 x, S32 y, S32 width, S32 height) // Multiplies a single alpha texture against the frame buffer -{ - BOOL success = TRUE; - U32 num_wearables = updateWearableCache(); - for (U32 i = 0; i < num_wearables; i++) - { - LLTexLayer *layer = getLayer(i); - if (layer) - { - success &= layer->blendAlphaTexture(x,y,width,height); - } - } - return success; -} - -/*virtual*/ void LLTexLayerTemplate::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) -{ - U32 num_wearables = updateWearableCache(); - for (U32 i = 0; i < num_wearables; i++) - { - LLTexLayer *layer = getLayer(i); - if (layer) - { - layer->addAlphaMask(data, originX, originY, width, height); - } - } -} - -/*virtual*/ void LLTexLayerTemplate::setHasMorph(BOOL newval) -{ - mHasMorph = newval; - U32 num_wearables = updateWearableCache(); - for (U32 i = 0; i < num_wearables; i++) - { - LLTexLayer *layer = getLayer(i); - if (layer) - { - layer->setHasMorph(newval); - } - } -} - -/*virtual*/ void LLTexLayerTemplate::deleteCaches() -{ - U32 num_wearables = updateWearableCache(); - for (U32 i = 0; i < num_wearables; i++) - { - LLTexLayer *layer = getLayer(i); - if (layer) - { - layer->deleteCaches(); - } - } -} - -/*virtual*/ BOOL LLTexLayerTemplate::isInvisibleAlphaMask() const -{ - U32 num_wearables = updateWearableCache(); - for (U32 i = 0; i < num_wearables; i++) - { - LLTexLayer *layer = getLayer(i); - if (layer) - { - if (layer->isInvisibleAlphaMask()) - { - return TRUE; - } - } - } - - return FALSE; -} - - -//----------------------------------------------------------------------------- -// finds a specific layer based on a passed in name -//----------------------------------------------------------------------------- -LLTexLayerInterface* LLViewerTexLayerSet::findLayerByName(const std::string& name) -{ - for (layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - if (layer->getName() == name) - { - return layer; - } - } - for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ ) - { - LLTexLayerInterface* layer = *iter; - if (layer->getName() == name) - { - return layer; - } - } - return NULL; -} - -void LLViewerTexLayerSet::cloneTemplates(LLLocalTextureObject *lto, LLAvatarAppearanceDefines::ETextureIndex tex_index, LLWearable *wearable) -{ - // initialize all texlayers with this texture type for this LTO - for( LLViewerTexLayerSet::layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ ) - { - LLTexLayerTemplate* layer = (LLTexLayerTemplate*)*iter; - if (layer->getInfo()->getLocalTexture() == (S32) tex_index) - { - lto->addTexLayer(layer, wearable); - } - } - for( LLViewerTexLayerSet::layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ ) - { - LLTexLayerTemplate* layer = (LLTexLayerTemplate*)*iter; - if (layer->getInfo()->getLocalTexture() == (S32) tex_index) - { - lto->addTexLayer(layer, wearable); - } - } -} const std::string LLViewerTexLayerSetBuffer::dumpTextureInfo() const { if (!isAgentAvatarValid()) return ""; diff --git a/indra/newview/llviewertexlayer.h b/indra/newview/llviewertexlayer.h index 781bfd334..959c883da 100644 --- a/indra/newview/llviewertexlayer.h +++ b/indra/newview/llviewertexlayer.h @@ -27,149 +27,12 @@ #ifndef LL_VIEWER_TEXLAYER_H #define LL_VIEWER_TEXLAYER_H -#include #include "lldynamictexture.h" -#include "llavatarappearancedefines.h" -#include "lltexlayerparams.h" +#include "llextendedstatus.h" #include "lltexlayer.h" -class LLVOAvatar; class LLVOAvatarSelf; -class LLImageTGA; -class LLImageRaw; -class LLXmlTreeNode; -class LLTexLayerSet; -class LLTexLayerSetInfo; -class LLTexLayerInfo; class LLViewerTexLayerSetBuffer; -class LLWearable; -class LLViewerVisualParam; -class LLLocalTextureObject; - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// LLTexLayerInterface -// -// Interface class to generalize functionality shared by LLTexLayer -// and LLTexLayerTemplate. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLTexLayerInterface : public LLTexLayerInterfaceTMP -{ -public: - enum ERenderPass - { - RP_COLOR, - RP_BUMP, - RP_SHINE - }; - - LLTexLayerInterface(LLTexLayerSet* const layer_set); - LLTexLayerInterface(const LLTexLayerInterface &layer, LLWearable *wearable); - virtual ~LLTexLayerInterface() {} - - virtual BOOL render(S32 x, S32 y, S32 width, S32 height) = 0; - virtual void deleteCaches() = 0; - virtual BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) = 0; - virtual BOOL isInvisibleAlphaMask() const = 0; - - const LLTexLayerInfo* getInfo() const { return mInfo; } - virtual BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // sets mInfo, calls initialization functions - - const std::string& getName() const; - const LLTexLayerSet* const getTexLayerSet() const { return mTexLayerSet; } - LLTexLayerSet* const getTexLayerSet() { return mTexLayerSet; } - - void invalidateMorphMasks(); - virtual void setHasMorph(BOOL newval) { mHasMorph = newval; } - BOOL hasMorph() const { return mHasMorph; } - BOOL isMorphValid() const { return mMorphMasksValid; } - - void requestUpdate(); - virtual void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) = 0; - BOOL hasAlphaParams() const { return !mParamAlphaList.empty(); } - - ERenderPass getRenderPass() const; - BOOL isVisibilityMask() const; - -protected: - const std::string& getGlobalColor() const; - LLViewerVisualParam* getVisualParamPtr(S32 index) const; - -protected: - LLTexLayerSet* const mTexLayerSet; - const LLTexLayerInfo* mInfo; - BOOL mMorphMasksValid; - BOOL mHasMorph; - - // Layers can have either mParamColorList, mGlobalColor, or mFixedColor. They are looked for in that order. - param_color_list_t mParamColorList; - param_alpha_list_t mParamAlphaList; - // mGlobalColor name stored in mInfo - // mFixedColor value stored in mInfo -}; - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// LLTexLayerTemplate -// -// Only exists for llvoavatarself. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLTexLayerTemplate : public LLTexLayerInterface -{ -public: - LLTexLayerTemplate(LLTexLayerSet* const layer_set); - LLTexLayerTemplate(const LLTexLayerTemplate &layer); - /*virtual*/ ~LLTexLayerTemplate(); - /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height); - /*virtual*/ BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // This sets mInfo and calls initialization functions - /*virtual*/ BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height); // Multiplies a single alpha texture against the frame buffer - /*virtual*/ void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height); - /*virtual*/ void setHasMorph(BOOL newval); - /*virtual*/ void deleteCaches(); - /*virtual*/ BOOL isInvisibleAlphaMask() const; -protected: - U32 updateWearableCache() const; - LLTexLayer* getLayer(U32 i) const; -private: - typedef std::vector wearable_cache_t; - mutable wearable_cache_t mWearableCache; // mutable b/c most get- require updating this cache -}; - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// LLTexLayer -// -// A single texture layer. Only exists for llvoavatarself. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLTexLayer : public LLTexLayerInterface -{ -public: - LLTexLayer(LLTexLayerSet* const layer_set); - LLTexLayer(const LLTexLayer &layer, LLWearable *wearable); - LLTexLayer(const LLTexLayerTemplate &layer_template, LLLocalTextureObject *lto, LLWearable *wearable); - /*virtual*/ ~LLTexLayer(); - - /*virtual*/ BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // This sets mInfo and calls initialization functions - /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height); - - /*virtual*/ void deleteCaches(); - const U8* getAlphaData() const; - - BOOL findNetColor(LLColor4* color) const; - /*virtual*/ BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height); // Multiplies a single alpha texture against the frame buffer - /*virtual*/ void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height); - BOOL renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLColor4 &layer_color); - void addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height); - /*virtual*/ BOOL isInvisibleAlphaMask() const; - - void setLTO(LLLocalTextureObject *lto) { mLocalTextureObject = lto; } - LLLocalTextureObject* getLTO() { return mLocalTextureObject; } - - static void calculateTexLayerColor(const param_color_list_t ¶m_list, LLColor4 &net_color); -protected: - LLUUID getUUID() const; -private: - typedef std::map alpha_cache_t; - alpha_cache_t mAlphaCache; - LLLocalTextureObject* mLocalTextureObject; -}; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLViewerTexLayerSet @@ -179,35 +42,11 @@ private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLViewerTexLayerSet : public LLTexLayerSet { - friend class LLViewerTexLayerSetBuffer; public: LLViewerTexLayerSet(LLAvatarAppearance* const appearance); virtual ~LLViewerTexLayerSet(); - - /*virtual*/ const LLTexLayerSetInfo* getInfo() const { return mInfo; } - /*virtual*/ BOOL setInfo(const LLTexLayerSetInfo *info); // This sets mInfo and calls initialization functions - /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height); - /*virtual*/ void renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear = false); - - /*virtual*/ BOOL isBodyRegion(const std::string& region) const; - /*virtual*/ LLTexLayerSetBuffer* getComposite(); - /*virtual*/ const LLTexLayerSetBuffer* getComposite() const; // Do not create one if it doesn't exist. - /*virtual*/ void destroyComposite(); - /*virtual*/ void gatherMorphMaskAlpha(U8 *data, S32 width, S32 height); - /*virtual*/ void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components); - /*virtual*/ BOOL isMorphValid() const; - /*virtual*/ void invalidateMorphMasks(); - /*virtual*/ void deleteCaches(); - /*virtual*/ LLTexLayerInterface* findLayerByName(const std::string& name); - /*virtual*/ void cloneTemplates(LLLocalTextureObject *lto, LLAvatarAppearanceDefines::ETextureIndex tex_index, LLWearable* wearable); - /*virtual*/ const std::string getBodyRegionName() const; - /*virtual*/ BOOL hasComposite() const { return (mComposite.notNull()); } - /*virtual*/ LLAvatarAppearanceDefines::EBakedTextureIndex getBakedTexIndex() const { return mBakedTexIndex; } - /*virtual*/ void setBakedTexIndex(LLAvatarAppearanceDefines::EBakedTextureIndex index) { mBakedTexIndex = index; } - /*virtual*/ BOOL isVisible() const { return mIsVisible; } - - /*virtual*/void requestUpdate(); + /*virtual*/void requestUpdate(); void requestUpload(); void cancelUpload(); BOOL isLocalTextureDataAvailable() const; @@ -223,46 +62,14 @@ public: const LLViewerTexLayerSetBuffer* getViewerComposite() const; private: - typedef std::vector layer_list_t; - layer_list_t mLayerList; - layer_list_t mMaskLayerList; - LLPointer mComposite; BOOL mUpdatesEnabled; - BOOL mIsVisible; - LLAvatarAppearanceDefines::EBakedTextureIndex mBakedTexIndex; - const LLTexLayerSetInfo* mInfo; -}; - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// LLTexLayerSetInfo -// -// Contains shared layer set data. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLTexLayerSetInfo -{ - friend class LLViewerTexLayerSet; -public: - LLTexLayerSetInfo(); - ~LLTexLayerSetInfo(); - BOOL parseXml(LLXmlTreeNode* node); - void createVisualParams(LLAvatarAppearance *appearance); - S32 getWidth() const { return mWidth; } - S32 getHeight() const { return mHeight; } -private: - std::string mBodyRegion; - S32 mWidth; - S32 mHeight; - std::string mStaticAlphaFileName; - BOOL mClearAlpha; // Set alpha to 1 for this layerset (if there is no mStaticAlphaFileName) - typedef std::vector layer_info_list_t; - layer_info_list_t mLayerInfoList; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLViewerTexLayerSetBuffer // -// The composite image that a LLTexLayerSet writes to. Each LLTexLayerSet has one. +// The composite image that a LLViewerTexLayerSet writes to. Each LLViewerTexLayerSet has one. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLViewerTexLayerSetBuffer : public LLTexLayerSetBuffer, public LLViewerDynamicTexture { @@ -279,9 +86,6 @@ public: const std::string dumpTextureInfo() const; virtual void restoreGLTexture(); virtual void destroyGLTexture(); -protected: - void pushProjection() const; - void popProjection() const; private: LLViewerTexLayerSet* getViewerTexLayerSet() { return dynamic_cast (mTexLayerSet); } @@ -290,15 +94,26 @@ private: static S32 sGLByteCount; //-------------------------------------------------------------------- - // Render + // Tex Layer Render + //-------------------------------------------------------------------- + virtual void preRenderTexLayerSet(); + virtual void midRenderTexLayerSet(BOOL success); + virtual void postRenderTexLayerSet(BOOL success); + virtual S32 getCompositeOriginX() const { return getOriginX(); } + virtual S32 getCompositeOriginY() const { return getOriginY(); } + virtual S32 getCompositeWidth() const { return getFullWidth(); } + virtual S32 getCompositeHeight() const { return getFullHeight(); } + + //-------------------------------------------------------------------- + // Dynamic Texture Interface //-------------------------------------------------------------------- public: /*virtual*/ BOOL needsRender(); protected: - BOOL render(S32 x, S32 y, S32 width, S32 height); - virtual void preRender(BOOL clear_depth); - virtual void postRender(BOOL success); - virtual BOOL render(); + // Pass these along for tex layer rendering. + virtual void preRender(BOOL clear_depth) { preRenderTexLayerSet(); } + virtual void postRender(BOOL success) { postRenderTexLayerSet(success); } + virtual BOOL render() { return renderTexLayerSet(); } //-------------------------------------------------------------------- // Uploads @@ -341,10 +156,11 @@ private: LLFrameTimer mNeedsUpdateTimer; // Tracks time since update was requested and performed. }; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLBakedUploadData // -// Used by LLViewerTexLayerSetBuffer for a callback. +// Used by LLTexLayerSetBuffer for a callback. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ struct LLBakedUploadData { diff --git a/indra/newview/llwearable.cpp b/indra/newview/llviewerwearable.cpp similarity index 86% rename from indra/newview/llwearable.cpp rename to indra/newview/llviewerwearable.cpp index c009d354a..c0d10b8ee 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llviewerwearable.cpp @@ -1,8 +1,8 @@ /** - * @file llwearable.cpp - * @brief LLWearable class implementation + * @file llviewerwearable.cpp + * @brief LLViewerWearable class implementation * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * @@ -44,14 +44,14 @@ #include "llvoavatar.h" #include "llvoavatarself.h" #include "llavatarappearancedefines.h" -#include "llwearable.h" +#include "llviewerwearable.h" #include "llviewercontrol.h" #include "llviewertexlayer.h" using namespace LLAvatarAppearanceDefines; // static -S32 LLWearable::sCurrentDefinitionVersion = 1; +S32 LLViewerWearable::sCurrentDefinitionVersion = 1; // support class - remove for 2.1 (hackity hack hack) class LLOverrideBakedTextureUpdate @@ -83,42 +83,45 @@ private: static std::string terse_F32_to_string(F32 f); static std::string asset_id_to_filename(const LLUUID &asset_id); -LLWearable::LLWearable(const LLTransactionID& transaction_id) : - mDefinitionVersion(LLWearable::sCurrentDefinitionVersion), +LLViewerWearable::LLViewerWearable(const LLTransactionID& transaction_id) : + LLWearable(), + mDefinitionVersion(LLViewerWearable::sCurrentDefinitionVersion), mType(LLWearableType::WT_INVALID) { mTransactionID = transaction_id; mAssetID = mTransactionID.makeAssetID(gAgent.getSecureSessionID()); } -LLWearable::LLWearable(const LLAssetID& asset_id) : - mDefinitionVersion( LLWearable::sCurrentDefinitionVersion ), +LLViewerWearable::LLViewerWearable(const LLAssetID& asset_id) : + LLWearable(), + mDefinitionVersion( LLViewerWearable::sCurrentDefinitionVersion ), mType(LLWearableType::WT_INVALID) { mAssetID = asset_id; mTransactionID.setNull(); } -LLWearable::~LLWearable() +// virtual +LLViewerWearable::~LLViewerWearable() { } -const std::string& LLWearable::getTypeLabel() const +const std::string& LLViewerWearable::getTypeLabel() const { return LLWearableType::getTypeLabel(mType); } -const std::string& LLWearable::getTypeName() const +const std::string& LLViewerWearable::getTypeName() const { return LLWearableType::getTypeName(mType); } -LLAssetType::EType LLWearable::getAssetType() const +LLAssetType::EType LLViewerWearable::getAssetType() const { return LLWearableType::getAssetType(mType); } -const LLUUID LLWearable::getDefaultTextureImageID(LLAvatarAppearanceDefines::ETextureIndex index) +const LLUUID LLViewerWearable::getDefaultTextureImageID(LLAvatarAppearanceDefines::ETextureIndex index) { const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = LLAvatarAppearanceDictionary::getInstance()->getTexture(index); const std::string &default_image_name = texture_dict->mDefaultImageName; @@ -133,7 +136,7 @@ const LLUUID LLWearable::getDefaultTextureImageID(LLAvatarAppearanceDefines::ETe } // reX: new function -BOOL LLWearable::FileExportParams( FILE* file ) +BOOL LLViewerWearable::FileExportParams( FILE* file ) { // wearable type S32 type = (S32)mType; @@ -155,7 +158,7 @@ BOOL LLWearable::FileExportParams( FILE* file ) } // reX: new function -BOOL LLWearable::FileExportTextures( FILE* file ) +BOOL LLViewerWearable::FileExportTextures( FILE* file ) { // wearable type S32 type = (S32)mType; @@ -175,7 +178,7 @@ BOOL LLWearable::FileExportTextures( FILE* file ) return TRUE; } -BOOL LLWearable::exportFile(LLFILE* file) const +BOOL LLViewerWearable::exportFile(LLFILE* file) const { // header and version if( fprintf( file, "LLWearable version %d\n", mDefinitionVersion ) < 0 ) @@ -254,7 +257,7 @@ BOOL LLWearable::exportFile(LLFILE* file) const } -void LLWearable::createVisualParams() +void LLViewerWearable::createVisualParams() { for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); param; @@ -262,7 +265,10 @@ void LLWearable::createVisualParams() { if (param->getWearableType() == mType) { - addVisualParam(param->cloneParam(this)); + LLVisualParam *clone_param = param->cloneParam(this); + clone_param->setParamLocation(LOC_UNKNOWN); + clone_param->setParamLocation(LOC_WEARABLE); + addVisualParam(clone_param); } } @@ -272,11 +278,11 @@ void LLWearable::createVisualParams() ++param_iter) { LLVisualParam* param = param_iter->second; - LLVisualParam*(LLWearable::*wearable_function)(S32)const = &LLWearable::getVisualParam; + LLVisualParam*(LLViewerWearable::*wearable_function)(S32)const = &LLViewerWearable::getVisualParam; // need this line to disambiguate between versions of LLCharacter::getVisualParam() LLVisualParam*(LLVOAvatarSelf::*avatar_function)(S32)const = &LLVOAvatarSelf::getVisualParam; param->resetDrivenParams(); - if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false)) + if(!param->linkDrivenParams(boost::bind(wearable_function,(LLViewerWearable*)this, _1), false)) { if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatarp.get(),_1 ), true)) { @@ -287,7 +293,7 @@ void LLWearable::createVisualParams() } } -BOOL LLWearable::importFile( LLFILE* file ) +BOOL LLViewerWearable::importFile( LLFILE* file ) { // *NOTE: changing the type or size of this buffer will require // changes in the fscanf() code below. You would be better off @@ -316,9 +322,9 @@ BOOL LLWearable::importFile( LLFILE* file ) // the extra check for version == 24 can be removed before release, once internal testers // have loaded these wearables again. See hack pt 2 at bottom of function to ensure that // these wearables get re-saved with version definition 22. - if( mDefinitionVersion > LLWearable::sCurrentDefinitionVersion && mDefinitionVersion != 24 ) + if( mDefinitionVersion > LLViewerWearable::sCurrentDefinitionVersion && mDefinitionVersion != 24 ) { - llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLWearable::sCurrentDefinitionVersion << ")" << llendl; + llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLViewerWearable::sCurrentDefinitionVersion << ")" << llendl; return FALSE; } @@ -516,17 +522,17 @@ BOOL LLWearable::importFile( LLFILE* file ) // 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. -BOOL LLWearable::isOldVersion() const +BOOL LLViewerWearable::isOldVersion() const { if (!isAgentAvatarValid()) return FALSE; - if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion ) + if( LLViewerWearable::sCurrentDefinitionVersion < mDefinitionVersion ) { - llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLWearable::sCurrentDefinitionVersion << ")" << llendl; + llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLViewerWearable::sCurrentDefinitionVersion << ")" << llendl; llassert(0); } - if( LLWearable::sCurrentDefinitionVersion != mDefinitionVersion ) + if( LLViewerWearable::sCurrentDefinitionVersion != mDefinitionVersion ) { return TRUE; } @@ -578,7 +584,7 @@ BOOL LLWearable::isOldVersion() const // * If parameters or textures have been ADDED since the wearable was created, // they are taken to have default values, so we consider the wearable clean // only if those values are the same as the defaults. -BOOL LLWearable::isDirty() const +BOOL LLViewerWearable::isDirty() const { if (!isAgentAvatarValid()) return FALSE; @@ -637,7 +643,7 @@ BOOL LLWearable::isDirty() const } -void LLWearable::setParamsToDefaults() +void LLViewerWearable::setParamsToDefaults() { if (!isAgentAvatarValid()) return; @@ -650,7 +656,7 @@ void LLWearable::setParamsToDefaults() } } -void LLWearable::setTexturesToDefaults() +void LLViewerWearable::setTexturesToDefaults() { for( S32 te = 0; te < TEX_NUM_INDICES; te++ ) { @@ -675,11 +681,16 @@ void LLWearable::setTexturesToDefaults() } // Updates the user's avatar's appearance -void LLWearable::writeToAvatar() +//virtual +void LLViewerWearable::writeToAvatar(LLAvatarAppearance *avatarp) { - if (!isAgentAvatarValid()) return; + LLVOAvatarSelf* viewer_avatar = dynamic_cast(avatarp); - ESex old_sex = gAgentAvatarp->getSex(); + if (!avatarp || !viewer_avatar) return; + + if (!viewer_avatar->isAgent()) return; + + ESex old_sex = avatarp->getSex(); // Pull params for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() ) @@ -712,21 +723,21 @@ void LLWearable::writeToAvatar() } LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE ); // MULTI-WEARABLE: assume index 0 will be used when writing to avatar. TODO: eliminate the need for this. - gAgentAvatarp->setLocalTextureTE(te, image, 0); + viewer_avatar->setLocalTextureTE(te, image, 0); } } - ESex new_sex = gAgentAvatarp->getSex(); + ESex new_sex = avatarp->getSex(); if( old_sex != new_sex ) { - gAgentAvatarp->updateSexDependentLayerSets( FALSE ); + viewer_avatar->updateSexDependentLayerSets( FALSE ); } } // Updates the user's avatar's appearance, replacing this wearables' parameters and textures with default values. // static -void LLWearable::removeFromAvatar( LLWearableType::EType type, BOOL upload_bake ) +void LLViewerWearable::removeFromAvatar( LLWearableType::EType type, BOOL upload_bake ) { if (!isAgentAvatarValid()) return; @@ -765,11 +776,11 @@ void LLWearable::removeFromAvatar( LLWearableType::EType type, BOOL upload_bake // Does not copy mAssetID. // Definition version is current: removes obsolete enties and creates default values for new ones. -void LLWearable::copyDataFrom(const LLWearable* src) +void LLViewerWearable::copyDataFrom(const LLViewerWearable* src) { if (!isAgentAvatarValid()) return; - mDefinitionVersion = LLWearable::sCurrentDefinitionVersion; + mDefinitionVersion = LLViewerWearable::sCurrentDefinitionVersion; mName = src->mName; mDescription = src->mDescription; @@ -794,7 +805,7 @@ void LLWearable::copyDataFrom(const LLWearable* src) destroyTextures(); // Deep copy of mTEMap (copies only those tes that are current, filling in defaults where needed) - for( S32 te = 0; te < TEX_NUM_INDICES; te++ ) + for (S32 te = 0; te < TEX_NUM_INDICES; te++) { if (LLAvatarAppearanceDictionary::getTEWearableType((ETextureIndex) te) == mType) { @@ -803,7 +814,7 @@ void LLWearable::copyDataFrom(const LLWearable* src) LLViewerFetchedTexture *image = NULL; if(iter != src->mTEMap.end()) { - image = src->getLocalTextureObject(te)->getImage(); + image = dynamic_cast (src->getLocalTextureObject(te)->getImage()); image_id = src->getLocalTextureObject(te)->getID(); mTEMap[te] = new LLLocalTextureObject(image, image_id); mSavedTEMap[te] = new LLLocalTextureObject(image, image_id); @@ -826,23 +837,23 @@ void LLWearable::copyDataFrom(const LLWearable* src) revertValues(); } -void LLWearable::setItemID(const LLUUID& item_id) +void LLViewerWearable::setItemID(const LLUUID& item_id) { mItemID = item_id; } -const LLUUID& LLWearable::getItemID() const +const LLUUID& LLViewerWearable::getItemID() const { return mItemID; } -void LLWearable::setType(LLWearableType::EType type) +void LLViewerWearable::setType(LLWearableType::EType type) { mType = type; createVisualParams(); } -LLLocalTextureObject* LLWearable::getLocalTextureObject(S32 index) +LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index) { te_map_t::iterator iter = mTEMap.find(index); if( iter != mTEMap.end() ) @@ -853,7 +864,7 @@ LLLocalTextureObject* LLWearable::getLocalTextureObject(S32 index) return NULL; } -const LLLocalTextureObject* LLWearable::getLocalTextureObject(S32 index) const +const LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index) const { te_map_t::const_iterator iter = mTEMap.find(index); if( iter != mTEMap.end() ) @@ -864,7 +875,7 @@ const LLLocalTextureObject* LLWearable::getLocalTextureObject(S32 index) const return NULL; } -void LLWearable::setLocalTextureObject(S32 index, LLLocalTextureObject <o) +void LLViewerWearable::setLocalTextureObject(S32 index, LLLocalTextureObject <o) { if( mTEMap.find(index) != mTEMap.end() ) { @@ -874,18 +885,19 @@ void LLWearable::setLocalTextureObject(S32 index, LLLocalTextureObject <o) } -void LLWearable::addVisualParam(LLVisualParam *param) +void LLViewerWearable::addVisualParam(LLVisualParam *param) { if( mVisualParamIndexMap[param->getID()] ) { delete mVisualParamIndexMap[param->getID()]; } param->setIsDummy(FALSE); + param->setParamLocation(LOC_WEARABLE); mVisualParamIndexMap[param->getID()] = param; mSavedVisualParamMap[param->getID()] = param->getDefaultWeight(); } -void LLWearable::setVisualParams() +void LLViewerWearable::setVisualParams() { for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++) { @@ -897,7 +909,7 @@ void LLWearable::setVisualParams() } -void LLWearable::setVisualParamWeight(S32 param_index, F32 value, BOOL upload_bake) +void LLViewerWearable::setVisualParamWeight(S32 param_index, F32 value, BOOL upload_bake) { if( is_in_map(mVisualParamIndexMap, param_index ) ) { @@ -906,11 +918,11 @@ void LLWearable::setVisualParamWeight(S32 param_index, F32 value, BOOL upload_ba } else { - llerrs << "LLWearable::setVisualParam passed invalid parameter index: " << param_index << " for wearable type: " << this->getName() << llendl; + llerrs << "LLViewerWearable::setVisualParam passed invalid parameter index: " << param_index << " for wearable type: " << this->getName() << llendl; } } -F32 LLWearable::getVisualParamWeight(S32 param_index) const +F32 LLViewerWearable::getVisualParamWeight(S32 param_index) const { if( is_in_map(mVisualParamIndexMap, param_index ) ) { @@ -924,14 +936,14 @@ F32 LLWearable::getVisualParamWeight(S32 param_index) const return (F32)-1.0; } -LLVisualParam* LLWearable::getVisualParam(S32 index) const +LLVisualParam* LLViewerWearable::getVisualParam(S32 index) const { visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.find(index); return (iter == mVisualParamIndexMap.end()) ? NULL : iter->second; } -void LLWearable::getVisualParams(visual_param_vec_t &list) +void LLViewerWearable::getVisualParams(visual_param_vec_t &list) { visual_param_index_map_t::iterator iter = mVisualParamIndexMap.begin(); visual_param_index_map_t::iterator end = mVisualParamIndexMap.end(); @@ -943,7 +955,7 @@ void LLWearable::getVisualParams(visual_param_vec_t &list) } } -void LLWearable::animateParams(F32 delta, BOOL upload_bake) +void LLViewerWearable::animateParams(F32 delta, BOOL upload_bake) { for(visual_param_index_map_t::iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); @@ -954,7 +966,7 @@ void LLWearable::animateParams(F32 delta, BOOL upload_bake) } } -LLColor4 LLWearable::getClothesColor(S32 te) const +LLColor4 LLViewerWearable::getClothesColor(S32 te) const { LLColor4 color; U32 param_name[3]; @@ -968,7 +980,7 @@ LLColor4 LLWearable::getClothesColor(S32 te) const return color; } -void LLWearable::setClothesColor( S32 te, const LLColor4& new_color, BOOL upload_bake ) +void LLViewerWearable::setClothesColor( S32 te, const LLColor4& new_color, BOOL upload_bake ) { U32 param_name[3]; if( LLVOAvatar::teToColorParams( (LLAvatarAppearanceDefines::ETextureIndex)te, param_name ) ) @@ -980,7 +992,7 @@ void LLWearable::setClothesColor( S32 te, const LLColor4& new_color, BOOL upload } } -void LLWearable::revertValues() +void LLViewerWearable::revertValues() { //update saved settings so wearable is no longer dirty // non-driver params first @@ -1031,12 +1043,12 @@ void LLWearable::revertValues() } -BOOL LLWearable::isOnTop() const +BOOL LLViewerWearable::isOnTop() const { return (this == gAgentWearables.getTopWearable(mType)); } -void LLWearable::createLayers(S32 te) +void LLViewerWearable::createLayers(S32 te) { LLViewerTexLayerSet *layer_set = dynamic_cast(gAgentAvatarp->getLayerSet((ETextureIndex)te)); if (layer_set) @@ -1049,7 +1061,7 @@ void LLWearable::createLayers(S32 te) } } -void LLWearable::saveValues() +void LLViewerWearable::saveValues() { //update saved settings so wearable is no longer dirty mSavedVisualParamMap.clear(); @@ -1075,7 +1087,7 @@ void LLWearable::saveValues() gFloaterCustomize->updateScrollingPanelList(); } -void LLWearable::syncImages(te_map_t &src, te_map_t &dst) +void LLViewerWearable::syncImages(te_map_t &src, te_map_t &dst) { // Deep copy of src (copies only those tes that are current, filling in defaults where needed) for( S32 te = 0; te < TEX_NUM_INDICES; te++ ) @@ -1084,7 +1096,7 @@ void LLWearable::syncImages(te_map_t &src, te_map_t &dst) { te_map_t::const_iterator iter = src.find(te); LLUUID image_id; - LLViewerFetchedTexture *image = NULL; + LLGLTexture *image = NULL; LLLocalTextureObject *lto = NULL; if(iter != src.end()) { @@ -1122,7 +1134,7 @@ void LLWearable::syncImages(te_map_t &src, te_map_t &dst) } } -void LLWearable::destroyTextures() +void LLViewerWearable::destroyTextures() { for( te_map_t::iterator iter = mTEMap.begin(); iter != mTEMap.end(); ++iter ) { @@ -1138,26 +1150,7 @@ void LLWearable::destroyTextures() mSavedTEMap.clear(); } -void LLWearable::pullCrossWearableValues() -{ - // scan through all of the avatar's visual parameters - for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); - param; - param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam()) - { - if( param ) - { - LLDriverParam *driver_param = dynamic_cast(param); - if(driver_param) - { - // parameter is a driver parameter, have it update its - driver_param->updateCrossDrivenParams(getType()); - } - } - } -} - -/*void LLWearable::readFromAvatar() +/*void LLViewerWearable::readFromAvatar() { LLVOAvatar* avatar = gAgentAvatarp; llassert( avatar ); @@ -1166,7 +1159,7 @@ void LLWearable::pullCrossWearableValues() return; } - mDefinitionVersion = LLWearable::sCurrentDefinitionVersion; + mDefinitionVersion = LLViewerWearable::sCurrentDefinitionVersion; mVisualParamMap.clear(); for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) @@ -1197,12 +1190,12 @@ void LLWearable::pullCrossWearableValues() }*/ -void LLWearable::setLabelUpdated() const +void LLViewerWearable::setUpdated() const { gInventory.addChangedMask(LLInventoryObserver::LABEL, getItemID()); } -void LLWearable::refreshName() +void LLViewerWearable::refreshName() { LLUUID item_id = getItemID(); LLInventoryItem* item = gInventory.getItem(item_id); @@ -1212,14 +1205,21 @@ void LLWearable::refreshName() } } +// virtual +void LLViewerWearable::addToBakedTextureHash(LLMD5& hash) const +{ + LLUUID asset_id = getAssetID(); + hash.update((const unsigned char*)asset_id.mData, UUID_BYTES); +} + struct LLWearableSaveData { LLWearableType::EType mType; }; -void LLWearable::saveNewAsset() const +void LLViewerWearable::saveNewAsset() const { -// llinfos << "LLWearable::saveNewAsset() type: " << getTypeName() << llendl; +// llinfos << "LLViewerWearable::saveNewAsset() type: " << getTypeName() << llendl; //llinfos << *this << llendl; const std::string filename = asset_id_to_filename(mAssetID); @@ -1268,13 +1268,13 @@ void LLWearable::saveNewAsset() const LLWearableSaveData* data = new LLWearableSaveData; data->mType = mType; gAssetStorage->storeAssetData(filename, mTransactionID, getAssetType(), - &LLWearable::onSaveNewAssetComplete, + &LLViewerWearable::onSaveNewAssetComplete, (void*)data); } } // static -void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userdata, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) +void LLViewerWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userdata, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLWearableSaveData* data = (LLWearableSaveData*)userdata; const std::string& type_name = LLWearableType::getTypeName(data->mType); @@ -1301,7 +1301,7 @@ void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userda } -std::ostream& operator<<(std::ostream &s, const LLWearable &w) +std::ostream& operator<<(std::ostream &s, const LLViewerWearable &w) { s << "wearable " << LLWearableType::getTypeName(w.mType) << "\n"; s << " Name: " << w.mName << "\n"; @@ -1310,7 +1310,7 @@ std::ostream& operator<<(std::ostream &s, const LLWearable &w) //w.mSaleInfo s << " Params:" << "\n"; - for (LLWearable::visual_param_index_map_t::const_iterator iter = w.mVisualParamIndexMap.begin(); + for (LLViewerWearable::visual_param_index_map_t::const_iterator iter = w.mVisualParamIndexMap.begin(); iter != w.mVisualParamIndexMap.end(); ++iter) { S32 param_id = iter->first; @@ -1320,7 +1320,7 @@ std::ostream& operator<<(std::ostream &s, const LLWearable &w) } s << " Textures:" << "\n"; - for (LLWearable::te_map_t::const_iterator iter = w.mTEMap.begin(); + for (LLViewerWearable::te_map_t::const_iterator iter = w.mTEMap.begin(); iter != w.mTEMap.end(); ++iter) { S32 te = iter->first; diff --git a/indra/newview/llwearable.h b/indra/newview/llviewerwearable.h similarity index 85% rename from indra/newview/llwearable.h rename to indra/newview/llviewerwearable.h index 2e0bf0814..cf3f054b6 100644 --- a/indra/newview/llwearable.h +++ b/indra/newview/llviewerwearable.h @@ -1,8 +1,8 @@ /** - * @file llwearable.h - * @brief LLWearable class header file + * @file llviewerwearable.h + * @brief LLViewerWearable class header file * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * @@ -24,8 +24,8 @@ * $/LicenseInfo$ */ -#ifndef LL_LLWEARABLE_H -#define LL_LLWEARABLE_H +#ifndef LL_VIEWER_WEARABLE_H +#define LL_VIEWER_WEARABLE_H #include "lluuid.h" #include "llstring.h" @@ -35,6 +35,7 @@ #include "llwearabletype.h" #include "llfile.h" #include "lllocaltextureobject.h" +#include "llwearable.h" #include "llavatarappearancedefines.h" class LLViewerInventoryItem; @@ -42,7 +43,7 @@ class LLVisualParam; class LLTexGlobalColorInfo; class LLTexGlobalColor; -class LLWearable +class LLViewerWearable : public LLWearable { friend class LLWearableList; @@ -51,10 +52,10 @@ class LLWearable //-------------------------------------------------------------------- private: // Private constructors used by LLWearableList - LLWearable(const LLTransactionID& transactionID); - LLWearable(const LLAssetID& assetID); + LLViewerWearable(const LLTransactionID& transactionID); + LLViewerWearable(const LLAssetID& assetID); public: - virtual ~LLWearable(); + virtual ~LLViewerWearable(); //-------------------------------------------------------------------- // Accessors @@ -91,8 +92,8 @@ public: BOOL isDirty() const; BOOL isOldVersion() const; - void writeToAvatar(); - void removeFromAvatar( BOOL upload_bake ) { LLWearable::removeFromAvatar( mType, upload_bake ); } + /*virtual*/ void writeToAvatar(LLAvatarAppearance* avatarp); + void removeFromAvatar( BOOL upload_bake ) { LLViewerWearable::removeFromAvatar( mType, upload_bake ); } static void removeFromAvatar( LLWearableType::EType type, BOOL upload_bake ); BOOL exportFile(LLFILE* file) const; @@ -104,11 +105,11 @@ public: void saveNewAsset() const; static void onSaveNewAssetComplete( const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status ); - void copyDataFrom(const LLWearable* src); + void copyDataFrom(const LLViewerWearable* src); - static void setCurrentDefinitionVersion( S32 version ) { LLWearable::sCurrentDefinitionVersion = version; } + static void setCurrentDefinitionVersion( S32 version ) { LLViewerWearable::sCurrentDefinitionVersion = version; } - friend std::ostream& operator<<(std::ostream &s, const LLWearable &w); + friend std::ostream& operator<<(std::ostream &s, const LLViewerWearable &w); void setItemID(const LLUUID& item_id); LLLocalTextureObject* getLocalTextureObject(S32 index); @@ -128,17 +129,18 @@ public: void revertValues(); void saveValues(); - void pullCrossWearableValues(); BOOL isOnTop() const; // Something happened that requires the wearable's label to be updated (e.g. worn/unworn). - void setLabelUpdated() const; + void setUpdated() const; // the wearable was worn. make sure the name of the wearable object matches the LLViewerInventoryItem, // not the wearable asset itself. void refreshName(); + // Update the baked texture hash. + /*virtual*/void addToBakedTextureHash(LLMD5& hash) const; private: typedef std::map te_map_t; typedef std::map visual_param_index_map_t; @@ -168,4 +170,5 @@ private: LLUUID mItemID; // ID of the inventory item in the agent's inventory }; -#endif // LL_LLWEARABLE_H + +#endif // LL_VIEWER_WEARABLE_H diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2348fb588..ee1cc9000 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -366,7 +366,7 @@ public: if (isAgentAvatarValid()) { - tvector = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot.getWorldPosition()); + tvector = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition()); agent_root_center_text = llformat("AgentRootCenter %f %f %f", (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index cc6f07531..30f9e9267 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -209,8 +209,6 @@ const F32 BUBBLE_CHAT_TIME = CHAT_FADE_TIME * 3.f; const U32 EMERALD_BOOB_SIZE_PARAM = 105; const U32 EMERALD_BOOB_GRAVITY_PARAM = 507; -const LLColor4 DUMMY_COLOR = LLColor4(0.5,0.5,0.5,1.0); - //Singu note: FADE and ALWAYS are swapped around from LL's source to match our preference panel. // Changing the "RenderName" order would cause confusion when 'always' setting suddenly gets // interpreted as 'fade', and vice versa. @@ -1002,8 +1000,8 @@ bool LLVOAvatar::isAgent() const { return gAgentAvatarp == this && gAgentAvatarp LLVOAvatar::LLVOAvatar(const LLUUID& id, const LLPCode pcode, LLViewerRegion* regionp) : + LLAvatarAppearance(&gAgentWearables), LLViewerObject(id, pcode, regionp), - mIsDummy(FALSE), mSpecialRenderMode(0), mAttachmentGeometryBytes(0), mAttachmentSurfaceArea(0.f), @@ -1038,6 +1036,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mTexSkinColor( NULL ), mTexHairColor( NULL ), mTexEyeColor( NULL ), + mRoot(NULL), mNeedsSkin(FALSE), mLastSkinTime(0.f), mUpdatePeriod(1), @@ -1175,7 +1174,8 @@ LLVOAvatar::~LLVOAvatar() } lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl; - mRoot.removeAllChildren(); + if (mRoot) mRoot->removeAllChildren(); + deleteAndClear(mRoot); mJointMap.clear(); std::for_each(mSkeleton.begin(), mSkeleton.end(), DeletePointer()); @@ -1203,14 +1203,14 @@ LLVOAvatar::~LLVOAvatar() deleteAndClear(mTexHairColor); deleteAndClear(mTexEyeColor); - std::for_each(mMeshes.begin(), mMeshes.end(), DeletePairedPointer()); - mMeshes.clear(); + std::for_each(mPolyMeshes.begin(), mPolyMeshes.end(), DeletePairedPointer()); + mPolyMeshes.clear(); for (avatar_joint_list_t::iterator jointIter = mMeshLOD.begin(); jointIter != mMeshLOD.end(); ++jointIter) { - LLViewerJoint* joint = dynamic_cast(*jointIter); + LLAvatarJoint* joint = *jointIter; std::for_each(joint->mMeshParts.begin(), joint->mMeshParts.end(), DeletePointer()); joint->mMeshParts.clear(); } @@ -1261,7 +1261,7 @@ BOOL LLVOAvatar::isFullyTextured() const { for (U32 i = 0; i < (U32)mMeshLOD.size(); i++) { - LLViewerJoint* joint = (LLViewerJoint*) mMeshLOD[i]; + LLAvatarJoint* joint = mMeshLOD[i]; if (i==MESH_ID_SKIRT && !isWearingWearableType(LLWearableType::WT_SKIRT)) { continue; // don't care about skirt textures if we're not wearing one. @@ -1273,7 +1273,7 @@ BOOL LLVOAvatar::isFullyTextured() const avatar_joint_mesh_list_t::iterator meshIter = joint->mMeshParts.begin(); if (meshIter != joint->mMeshParts.end()) { - LLViewerJointMesh *mesh = (LLViewerJointMesh*)*meshIter; + LLAvatarJointMesh *mesh = (*meshIter); if (!mesh) { continue; // nonexistent mesh OK @@ -1504,7 +1504,7 @@ void LLVOAvatar::restoreGL() gAgentAvatarp->setCompositeUpdatesEnabled(TRUE); for (U32 i = 0; i < gAgentAvatarp->mBakedTextureDatas.size(); i++) { - gAgentAvatarp->invalidateComposite(gAgentAvatarp->mBakedTextureDatas[i].mTexLayerSet, FALSE); + gAgentAvatarp->invalidateComposite(gAgentAvatarp->getTexLayerSet(i), FALSE); } gAgentAvatarp->updateMeshTextures(); } @@ -1588,7 +1588,7 @@ void LLVOAvatar::initClass() S32 wearable_def_version = 1; static LLStdStringHandle wearable_definition_version_string = LLXmlTree::addAttributeString("wearable_definition_version"); root->getFastAttributeS32( wearable_definition_version_string, wearable_def_version ); - LLWearable::setCurrentDefinitionVersion( wearable_def_version ); + LLViewerWearable::setCurrentDefinitionVersion( wearable_def_version ); std::string mesh_file_name; @@ -1673,15 +1673,16 @@ void LLVOAvatar::initInstance(void) //------------------------------------------------------------------------- // initialize joint, mesh and shape members //------------------------------------------------------------------------- - mRoot.setName( "mRoot" ); + mRoot = createAvatarJoint(); + mRoot->setName( "mRoot" ); for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().begin(); - iter != LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().end(); + iter != LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().end(); ++iter) { const EMeshIndex mesh_index = iter->first; const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = iter->second; - LLViewerJoint* joint = new LLViewerJoint(); + LLAvatarJoint* joint = createAvatarJoint(); joint->setName(mesh_dict->mName); joint->setMeshID(mesh_index); mMeshLOD.push_back(joint); @@ -1692,7 +1693,7 @@ void LLVOAvatar::initInstance(void) mHairMesh1.setName("mHairMesh1"); */ for (U32 lod = 0; lod < mesh_dict->mLOD; lod++) { - LLViewerJointMesh* mesh = new LLViewerJointMesh(); + LLAvatarJointMesh* mesh = createAvatarJointMesh(); std::string mesh_name = "m" + mesh_dict->mName + boost::lexical_cast(lod); // We pre-pended an m - need to capitalize first character for camelCase mesh_name[1] = toupper(mesh_name[1]); @@ -1735,7 +1736,7 @@ void LLVOAvatar::initInstance(void) iter != mMeshLOD[mesh_index]->mMeshParts.end(); ++iter) { - LLViewerJointMesh* mesh = (LLViewerJointMesh*) *iter; + LLAvatarJointMesh* mesh = (*iter); mBakedTextureDatas[(int)baked_texture_index].mJointMeshes.push_back(mesh); } } @@ -1825,6 +1826,30 @@ void LLVOAvatar::initInstance(void) mVoiceVisualizer->setVoiceEnabled( gVoiceClient->getVoiceEnabled( mID ) ); } +// virtual +LLAvatarJoint* LLVOAvatar::createAvatarJoint() +{ + return new LLViewerJoint(); +} + +// virtual +LLAvatarJoint* LLVOAvatar::createAvatarJoint(S32 joint_num) +{ + return new LLViewerJoint(joint_num); +} + +// virtual +LLAvatarJointMesh* LLVOAvatar::createAvatarJointMesh() +{ + return new LLViewerJointMesh(); +} + +// virtual +LLTexLayerSet* LLVOAvatar::createTexLayerSet() +{ + return new LLViewerTexLayerSet(this); +} + const LLVector3 LLVOAvatar::getRenderPosition() const { if (mDrawable.isNull() || mDrawable->getGeneration() < 0) @@ -1897,7 +1922,7 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) float max_attachment_span = DEFAULT_MAX_PRIM_SCALE * 5.0f; //stretch bounding box by joint positions - for (polymesh_map_t::iterator i = mMeshes.begin(); i != mMeshes.end(); ++i) + for (polymesh_map_t::iterator i = mPolyMeshes.begin(); i != mPolyMeshes.end(); ++i) { LLPolyMesh* mesh = i->second; for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.count(); joint_num++) @@ -2182,15 +2207,15 @@ BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename) //----------------------------------------------------------------------------- // setupBone() //----------------------------------------------------------------------------- -BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 &volume_num, S32 &joint_num) +BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLJoint* parent, S32 &volume_num, S32 &joint_num) { LLMemType mt(LLMemType::MTYPE_AVATAR); - LLViewerJoint* joint = NULL; + LLJoint* joint = NULL; if (info->mIsJoint) { - joint = dynamic_cast(getCharacterJoint(joint_num)); + joint = getCharacterJoint(joint_num); if (!joint) { llwarns << "Too many bones" << llendl; @@ -2205,7 +2230,7 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent llwarns << "Too many bones" << llendl; return FALSE; } - joint = (LLViewerJoint*)(&mCollisionVolumes[volume_num]); + joint = (&mCollisionVolumes[volume_num]); joint->setName( info->mName ); } @@ -2337,21 +2362,21 @@ void LLVOAvatar::buildCharacter() //------------------------------------------------------------------------- // remove all of mRoot's children //------------------------------------------------------------------------- - mRoot.removeAllChildren(); + mRoot->removeAllChildren(); mJointMap.clear(); mIsBuilt = FALSE; //------------------------------------------------------------------------- // clear mesh data //------------------------------------------------------------------------- - for (std::vector::iterator jointIter = mMeshLOD.begin(); + for (avatar_joint_list_t::iterator jointIter = mMeshLOD.begin(); jointIter != mMeshLOD.end(); ++jointIter) { - LLViewerJoint* joint = (LLViewerJoint*) *jointIter; + LLAvatarJoint* joint = *jointIter; for (avatar_joint_mesh_list_t::iterator meshIter = joint->mMeshParts.begin(); meshIter != joint->mMeshParts.end(); ++meshIter) { - LLViewerJointMesh * mesh = (LLViewerJointMesh *) *meshIter; + LLAvatarJointMesh * mesh = *meshIter; mesh->setMesh(NULL); } } @@ -2389,24 +2414,24 @@ void LLVOAvatar::buildCharacter() //------------------------------------------------------------------------- // initialize "well known" joint pointers //------------------------------------------------------------------------- - mPelvisp = mRoot.findJoint("mPelvis"); - mTorsop = mRoot.findJoint("mTorso"); - mChestp = mRoot.findJoint("mChest"); - mNeckp = mRoot.findJoint("mNeck"); - mHeadp = mRoot.findJoint("mHead"); - mSkullp = mRoot.findJoint("mSkull"); - mHipLeftp = mRoot.findJoint("mHipLeft"); - mHipRightp = mRoot.findJoint("mHipRight"); - mKneeLeftp = mRoot.findJoint("mKneeLeft"); - mKneeRightp = mRoot.findJoint("mKneeRight"); - mAnkleLeftp = mRoot.findJoint("mAnkleLeft"); - mAnkleRightp = mRoot.findJoint("mAnkleRight"); - mFootLeftp = mRoot.findJoint("mFootLeft"); - mFootRightp = mRoot.findJoint("mFootRight"); - mWristLeftp = mRoot.findJoint("mWristLeft"); - mWristRightp = mRoot.findJoint("mWristRight"); - mEyeLeftp = mRoot.findJoint("mEyeLeft"); - mEyeRightp = mRoot.findJoint("mEyeRight"); + mPelvisp = mRoot->findJoint("mPelvis"); + mTorsop = mRoot->findJoint("mTorso"); + mChestp = mRoot->findJoint("mChest"); + mNeckp = mRoot->findJoint("mNeck"); + mHeadp = mRoot->findJoint("mHead"); + mSkullp = mRoot->findJoint("mSkull"); + mHipLeftp = mRoot->findJoint("mHipLeft"); + mHipRightp = mRoot->findJoint("mHipRight"); + mKneeLeftp = mRoot->findJoint("mKneeLeft"); + mKneeRightp = mRoot->findJoint("mKneeRight"); + mAnkleLeftp = mRoot->findJoint("mAnkleLeft"); + mAnkleRightp = mRoot->findJoint("mAnkleRight"); + mFootLeftp = mRoot->findJoint("mFootLeft"); + mFootRightp = mRoot->findJoint("mFootRight"); + mWristLeftp = mRoot->findJoint("mWristLeft"); + mWristRightp = mRoot->findJoint("mWristRight"); + mEyeLeftp = mRoot->findJoint("mEyeLeft"); + mEyeRightp = mRoot->findJoint("mEyeRight"); //------------------------------------------------------------------------- // Make sure "well known" pointers exist @@ -2698,7 +2723,7 @@ void LLVOAvatar::computeBodySize() // some of the joints have not been cached LLVector3 skull = mSkullp->getPosition(); - LLVector3 skull_scale = mSkullp->getScale(); + //LLVector3 skull_scale = mSkullp->getScale(); LLVector3 neck = mNeckp->getPosition(); LLVector3 neck_scale = mNeckp->getScale(); @@ -2937,7 +2962,7 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) // animate the character // store off last frame's root position to be consistent with camera position - LLVector3 root_pos_last = mRoot.getWorldPosition(); + LLVector3 root_pos_last = mRoot->getWorldPosition(); bool detailed_update = updateCharacter(agent); bool voice_enabled = gVoiceClient->getVoiceEnabled( mID ) && gVoiceClient->inProximalChannel(); @@ -3060,11 +3085,11 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled) if ( mIsSitting ) { LLVector3 headOffset = LLVector3( 0.0f, 0.0f, mHeadOffset.mV[2] ); - mVoiceVisualizer->setVoiceSourceWorldPosition( mRoot.getWorldPosition() + headOffset ); + mVoiceVisualizer->setVoiceSourceWorldPosition( mRoot->getWorldPosition() + headOffset ); } else { - LLVector3 tagPos = mRoot.getWorldPosition(); + LLVector3 tagPos = mRoot->getWorldPosition(); tagPos[VZ] -= mPelvisToFoot; tagPos[VZ] += ( mBodySize[VZ] + 0.125f ); mVoiceVisualizer->setVoiceSourceWorldPosition( tagPos ); @@ -3994,7 +4019,7 @@ void LLVOAvatar::invalidateNameTags() // Compute name tag position during idle update LLVector3 LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last) { - LLQuaternion root_rot = mRoot.getWorldRotation(); + LLQuaternion root_rot = mRoot->getWorldRotation(); LLVector3 pixel_right_vec; LLVector3 pixel_up_vec; LLViewerCamera::getInstance()->getPixelVectors(root_pos_last, pixel_up_vec, pixel_right_vec); @@ -4008,7 +4033,7 @@ LLVector3 LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last) local_camera_up.scaleVec(mBodySize * 0.5f); local_camera_at.scaleVec(mBodySize * 0.5f); - LLVector3 name_position = mRoot.getWorldPosition(); + LLVector3 name_position = mRoot->getWorldPosition(); name_position[VZ] -= mPelvisToFoot; name_position[VZ] += (mBodySize[VZ]* 0.55f); name_position += (local_camera_up * root_rot) - (projected_vec(local_camera_at * root_rot, camera_to_av)); @@ -4075,13 +4100,13 @@ void LLVOAvatar::idleUpdateBelowWater() void LLVOAvatar::slamPosition() { gAgent.setPositionAgent(getPositionAgent()); - mRoot.setWorldPosition(getPositionAgent()); // teleport + mRoot->setWorldPosition(getPositionAgent()); // teleport setChanged(TRANSLATED); if (mDrawable.notNull()) { gPipeline.updateMoveNormalAsync(mDrawable); } - mRoot.updateWorldMatrixChildren(); + mRoot->updateWorldMatrixChildren(); } bool LLVOAvatar::isVisuallyMuted() const @@ -4253,8 +4278,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) xyVel.mV[VZ] = 0.0f; speed = xyVel.length(); - BOOL throttle = TRUE; - if (!(mIsSitting && getParent())) { //-------------------------------------------------------------------- @@ -4265,11 +4288,10 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) if (mTimeLast == 0.0f) { mTimeLast = animation_time; - throttle = FALSE; // put the pelvis at slaved position/mRotation - mRoot.setWorldPosition( getPositionAgent() ); // first frame - mRoot.setWorldRotation( getRotation() ); + mRoot->setWorldPosition( getPositionAgent() ); // first frame + mRoot->setWorldRotation( getRotation() ); } //-------------------------------------------------------------------- @@ -4312,10 +4334,10 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) LLVector3 newPosition = gAgent.getPosAgentFromGlobal(root_pos); - if (newPosition != mRoot.getXform()->getWorldPosition()) + if (newPosition != mRoot->getXform()->getWorldPosition()) { - mRoot.touch(); - mRoot.setWorldPosition(newPosition ); // regular update + mRoot->touch(); + mRoot->setWorldPosition(newPosition ); // regular update } @@ -4376,7 +4398,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) } - LLQuaternion root_rotation = mRoot.getWorldMatrix().quaternion(); + LLQuaternion root_rotation = mRoot->getWorldMatrix().quaternion(); F32 root_roll, root_pitch, root_yaw; root_rotation.getEulerAngles(&root_roll, &root_pitch, &root_yaw); @@ -4393,7 +4415,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) // and head turn. Once in motion, it must conform however. BOOL self_in_mouselook = isSelf() && gAgentCamera.cameraMouselook(); - LLVector3 pelvisDir( mRoot.getWorldMatrix().getFwdRow4().mV ); + LLVector3 pelvisDir( mRoot->getWorldMatrix().getFwdRow4().mV ); F32 pelvis_rot_threshold = clamp_rescale(speed, 0.1f, 1.0f, PELVIS_ROT_THRESHOLD_SLOW, PELVIS_ROT_THRESHOLD_FAST); if (self_in_mouselook) @@ -4475,14 +4497,14 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) F32 u = llclamp((deltaTime / pelvis_lag_time), 0.0f, 1.0f); - mRoot.setWorldRotation( slerp(u, mRoot.getWorldRotation(), wQv) ); + mRoot->setWorldRotation( slerp(u, mRoot->getWorldRotation(), wQv) ); } } else if (mDrawable.notNull()) { - mRoot.setPosition(mDrawable->getPosition()); - mRoot.setRotation(mDrawable->getRotation()); + mRoot->setPosition(mDrawable->getPosition()); + mRoot->setRotation(mDrawable->getRotation()); } //------------------------------------------------------------------------- @@ -4582,7 +4604,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) } } - mRoot.updateWorldMatrixChildren(); + mRoot->updateWorldMatrixChildren(); if (!mDebugText.size() && mText.notNull()) { @@ -4599,7 +4621,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) return TRUE; } - //----------------------------------------------------------------------------- // updateHeadOffset() //----------------------------------------------------------------------------- @@ -4607,7 +4628,7 @@ void LLVOAvatar::updateHeadOffset() { // since we only care about Z, just grab one of the eyes LLVector3 midEyePt = mEyeLeftp->getWorldPosition(); - midEyePt -= mDrawable.notNull() ? mDrawable->getWorldPosition() : mRoot.getWorldPosition(); + midEyePt -= mDrawable.notNull() ? mDrawable->getWorldPosition() : mRoot->getWorldPosition(); midEyePt.mV[VZ] = llmax(-mPelvisToFoot + LLViewerCamera::getInstance()->getNear(), midEyePt.mV[VZ]); if (mDrawable.notNull()) @@ -4645,8 +4666,8 @@ void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount, void LLVOAvatar::postPelvisSetRecalc( void ) { computeBodySize(); - mRoot.touch(); - mRoot.updateWorldMatrixChildren(); + mRoot->touch(); + mRoot->updateWorldMatrixChildren(); dirtyMesh(); updateHeadOffset(); } @@ -5969,7 +5990,7 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name ) if (iter == mJointMap.end() || iter->second == NULL) { //search for joint and cache found joint in lookup table - jointp = mRoot.findJoint(name); + jointp = mRoot->findJoint(name); mJointMap[name] = jointp; } else @@ -5985,7 +6006,7 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name ) //----------------------------------------------------------------------------- void LLVOAvatar::resetSpecificJointPosition( const std::string& name ) { - LLJoint* pJoint = mRoot.findJoint( name ); + LLJoint* pJoint = mRoot->findJoint( name ); if ( pJoint && pJoint->doesJointNeedToBeReset() ) { @@ -6121,7 +6142,7 @@ F32 LLVOAvatar::getPixelArea() const //----------------------------------------------------------------------------- LLPolyMesh* LLVOAvatar::getHeadMesh() { - return ((LLViewerJointMesh*)(mMeshLOD[MESH_ID_HEAD]->mMeshParts[0]))->getMesh(); + return mMeshLOD[MESH_ID_HEAD]->mMeshParts[0]->getMesh(); } @@ -6130,7 +6151,7 @@ LLPolyMesh* LLVOAvatar::getHeadMesh() //----------------------------------------------------------------------------- LLPolyMesh* LLVOAvatar::getUpperBodyMesh() { - return ((LLViewerJointMesh*)(mMeshLOD[MESH_ID_UPPER_BODY]->mMeshParts[0]))->getMesh(); + return mMeshLOD[MESH_ID_UPPER_BODY]->mMeshParts[0]->getMesh(); } @@ -6160,7 +6181,7 @@ BOOL LLVOAvatar::allocateCharacterJoints( U32 num ) for(S32 joint_num = 0; joint_num < (S32)num; joint_num++) { - mSkeleton.push_back(new LLViewerJoint(joint_num)); + mSkeleton.push_back(createAvatarJoint(joint_num)); } @@ -6310,9 +6331,9 @@ BOOL LLVOAvatar::loadAvatar() EBakedTextureIndex baked = LLAvatarAppearanceDictionary::findBakedByRegionName(info->mRegion); if (baked != BAKED_NUM_INDICES) { - LLPolyMorphTarget *morph_param; + LLVisualParam* morph_param; const std::string *name = &info->mName; - morph_param = (LLPolyMorphTarget *)(getVisualParam(name->c_str())); + morph_param = getVisualParam(name->c_str()); if (morph_param) { BOOL invert = info->mInvert; @@ -6334,6 +6355,7 @@ BOOL LLVOAvatar::loadAvatar() if (driver_param->setInfo(info)) { addVisualParam( driver_param ); + driver_param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER); LLVisualParam*(LLVOAvatar::*avatar_function)(S32)const = &LLVOAvatar::getVisualParam; if( !driver_param->linkDrivenParams(boost::bind(avatar_function,(LLVOAvatar*)this,_1 ), false)) { @@ -6358,9 +6380,10 @@ BOOL LLVOAvatar::loadAvatar() //----------------------------------------------------------------------------- BOOL LLVOAvatar::loadSkeletonNode () { - mRoot.addChild( mSkeleton[0] ); + mRoot->addChild( mSkeleton[0] ); - for (std::vector::iterator iter = mMeshLOD.begin(); + // make meshes children before calling parent version of the function + for (avatar_joint_list_t::iterator iter = mMeshLOD.begin(); iter != mMeshLOD.end(); ++iter) { @@ -6369,26 +6392,26 @@ BOOL LLVOAvatar::loadSkeletonNode () joint->setMeshesToChildren(); } - mRoot.addChild(mMeshLOD[MESH_ID_HEAD]); - mRoot.addChild(mMeshLOD[MESH_ID_EYELASH]); - mRoot.addChild(mMeshLOD[MESH_ID_UPPER_BODY]); - mRoot.addChild(mMeshLOD[MESH_ID_LOWER_BODY]); - mRoot.addChild(mMeshLOD[MESH_ID_SKIRT]); - mRoot.addChild(mMeshLOD[MESH_ID_HEAD]); + mRoot->addChild(mMeshLOD[MESH_ID_HEAD]); + mRoot->addChild(mMeshLOD[MESH_ID_EYELASH]); + mRoot->addChild(mMeshLOD[MESH_ID_UPPER_BODY]); + mRoot->addChild(mMeshLOD[MESH_ID_LOWER_BODY]); + mRoot->addChild(mMeshLOD[MESH_ID_SKIRT]); + mRoot->addChild(mMeshLOD[MESH_ID_HEAD]); - LLAvatarJoint *skull = (LLAvatarJoint*)mRoot.findJoint("mSkull"); + LLAvatarJoint *skull = (LLAvatarJoint*)mRoot->findJoint("mSkull"); if (skull) { skull->addChild(mMeshLOD[MESH_ID_HAIR] ); } - LLAvatarJoint *eyeL = (LLAvatarJoint*)mRoot.findJoint("mEyeLeft"); + LLAvatarJoint *eyeL = (LLAvatarJoint*)mRoot->findJoint("mEyeLeft"); if (eyeL) { eyeL->addChild( mMeshLOD[MESH_ID_EYEBALL_LEFT] ); } - LLAvatarJoint *eyeR = (LLAvatarJoint*)mRoot.findJoint("mEyeRight"); + LLAvatarJoint *eyeR = (LLAvatarJoint*)mRoot->findJoint("mEyeRight"); if (eyeR) { eyeR->addChild( mMeshLOD[MESH_ID_EYEBALL_RIGHT] ); @@ -6401,7 +6424,7 @@ BOOL LLVOAvatar::loadSkeletonNode () iter != sAvatarXmlInfo->mSkeletalDistortionInfoList.end(); ++iter) { - LLPolySkeletalDistortionInfo *info = *iter; + LLPolySkeletalDistortionInfo *info = (LLPolySkeletalDistortionInfo*)*iter; LLPolySkeletalDistortion *param = new LLPolySkeletalDistortion(this); if (!param->setInfo(info)) { @@ -6411,6 +6434,7 @@ BOOL LLVOAvatar::loadSkeletonNode () else { addVisualParam(param); + param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER); } } } @@ -6507,7 +6531,7 @@ BOOL LLVOAvatar::loadMeshNodes() const std::string &type = info->mType; S32 lod = info->mLOD; - LLViewerJointMesh* mesh = NULL; + LLAvatarJointMesh* mesh = NULL; U8 mesh_id = 0; BOOL found_mesh_id = FALSE; @@ -6533,7 +6557,7 @@ BOOL LLVOAvatar::loadMeshNodes() { if (lod < (S32)mMeshLOD[mesh_id]->mMeshParts.size()) { - mesh = (LLViewerJointMesh*)mMeshLOD[mesh_id]->mMeshParts[lod]; + mesh = mMeshLOD[mesh_id]->mMeshParts[lod]; } else { @@ -6551,14 +6575,14 @@ BOOL LLVOAvatar::loadMeshNodes() // If this isn't set to white (1.0), avatars will *ALWAYS* be darker than their surroundings. // Do not touch!!! - mesh->setColor( 1.0f, 1.0f, 1.0f, 1.0f ); + mesh->setColor( LLColor4::white ); LLPolyMesh *poly_mesh = NULL; if (!info->mReferenceMeshName.empty()) { - polymesh_map_t::const_iterator polymesh_iter = mMeshes.find(info->mReferenceMeshName); - if (polymesh_iter != mMeshes.end()) + polymesh_map_t::const_iterator polymesh_iter = mPolyMeshes.find(info->mReferenceMeshName); + if (polymesh_iter != mPolyMeshes.end()) { poly_mesh = LLPolyMesh::getMesh(info->mMeshFileName, polymesh_iter->second); poly_mesh->setAvatar(this); @@ -6582,7 +6606,7 @@ BOOL LLVOAvatar::loadMeshNodes() } // Multimap insert - mMeshes.insert(std::make_pair(info->mMeshFileName, poly_mesh)); + mPolyMeshes.insert(std::make_pair(info->mMeshFileName, poly_mesh)); mesh->setMesh( poly_mesh ); mesh->setLOD( info->mMinPixelArea ); @@ -6593,7 +6617,7 @@ BOOL LLVOAvatar::loadMeshNodes() { const LLVOAvatarXmlInfo::LLVOAvatarMeshInfo::morph_info_pair_t *info_pair = &(*xmlinfo_iter); LLPolyMorphTarget *param = new LLPolyMorphTarget(mesh->getMesh()); - if (!param->setInfo(info_pair->first)) + if (!param->setInfo((LLPolyMorphTargetInfo*)info_pair->first)) { delete param; return FALSE; @@ -6603,10 +6627,12 @@ BOOL LLVOAvatar::loadMeshNodes() if (info_pair->second) { addSharedVisualParam(param); + param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER); } else { addVisualParam(param); + param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER); } } } @@ -6650,7 +6676,7 @@ void LLVOAvatar::updateVisualParams() { computeBodySize(); mLastSkeletonSerialNum = mSkeletonSerialNum; - mRoot.updateWorldMatrixChildren(); + mRoot->updateWorldMatrixChildren(); } dirtyMesh(); @@ -6740,7 +6766,12 @@ BOOL LLVOAvatar::updateJointLODs() } // now select meshes to render based on adjusted pixel area - BOOL res = mRoot.updateLOD(mAdjustedPixelArea, TRUE); + LLViewerJoint* root = dynamic_cast(mRoot); + BOOL res = FALSE; + if (root) + { + res = root->updateLOD(mAdjustedPixelArea, TRUE); + } if (res) { sNumLODChangesThisFrame++; @@ -6852,7 +6883,7 @@ void LLVOAvatar::hideSkirt() //----------------------------------------------------------------------------- LLPolyMesh* LLVOAvatar::getMesh( LLPolyMeshSharedData *shared_data ) { - for (polymesh_map_t::iterator i = mMeshes.begin(); i != mMeshes.end(); ++i) + for (polymesh_map_t::iterator i = mPolyMeshes.begin(); i != mPolyMeshes.end(); ++i) { LLPolyMesh* mesh = i->second; if (mesh->getSharedData() == shared_data) @@ -7270,9 +7301,9 @@ void LLVOAvatar::sitOnObject(LLViewerObject *sit_object) // Notice that removing sitDown() from here causes avatars sitting on // objects to be not rendered for new arrivals. See EXT-6835 and EXT-1655. sitDown(TRUE); - mRoot.getXform()->setParent(&sit_object->mDrawable->mXform); // LLVOAvatar::sitOnObject - mRoot.setPosition(getPosition()); - mRoot.updateWorldMatrixChildren(); + mRoot->getXform()->setParent(&sit_object->mDrawable->mXform); // LLVOAvatar::sitOnObject + mRoot->setPosition(getPosition()); + mRoot->updateWorldMatrixChildren(); stopMotion(ANIM_AGENT_BODY_NOISE); @@ -7318,10 +7349,10 @@ void LLVOAvatar::getOffObject() sitDown(FALSE); - mRoot.getXform()->setParent(NULL); // LLVOAvatar::getOffObject - mRoot.setPosition(cur_position_world); - mRoot.setRotation(cur_rotation_world); - mRoot.getXform()->update(); + mRoot->getXform()->setParent(NULL); // LLVOAvatar::getOffObject + mRoot->setPosition(cur_position_world); + mRoot->setRotation(cur_rotation_world); + mRoot->getXform()->update(); startMotion(ANIM_AGENT_BODY_NOISE); @@ -7949,11 +7980,34 @@ void LLVOAvatar::addMaskedMorph(EBakedTextureIndex index, LLVisualParam* morph_t { if (index < BAKED_NUM_INDICES) { - LLMaskedMorph *morph = new LLMaskedMorph((LLPolyMorphTarget*)morph_target, invert, layer); + LLMaskedMorph *morph = new LLMaskedMorph(morph_target, invert, layer); mBakedTextureDatas[index].mMaskedMorphs.push_front(morph); } } + + +void LLVOAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index) +{ + if (index >= BAKED_NUM_INDICES) + { + llwarns << "invalid baked texture index passed to applyMorphMask" << llendl; + return; + } + + for (morph_list_t::const_iterator iter = mBakedTextureDatas[index].mMaskedMorphs.begin(); + iter != mBakedTextureDatas[index].mMaskedMorphs.end(); ++iter) + { + const LLMaskedMorph* maskedMorph = (*iter); + LLPolyMorphTarget* morph_target = dynamic_cast(maskedMorph->mMorphTarget); + if (morph_target) + { + morph_target->applyMask(tex_data, width, height, num_components, maskedMorph->mInvert); + } + } +} + + // returns TRUE if morph masks are present and not valid for a given baked texture, FALSE otherwise BOOL LLVOAvatar::morphMaskNeedsUpdate(LLAvatarAppearanceDefines::EBakedTextureIndex index) { @@ -7981,23 +8035,6 @@ BOOL LLVOAvatar::morphMaskNeedsUpdate(LLAvatarAppearanceDefines::EBakedTextureIn return FALSE; } -void LLVOAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index) -{ - if (index >= BAKED_NUM_INDICES) - { - llwarns << "invalid baked texture index passed to applyMorphMask" << llendl; - return; - } - - for (morph_list_t::const_iterator iter = mBakedTextureDatas[index].mMaskedMorphs.begin(); - iter != mBakedTextureDatas[index].mMaskedMorphs.end(); ++iter) - { - const LLMaskedMorph* maskedMorph = (*iter); - maskedMorph->mMorphTarget->applyMask(tex_data, width, height, num_components, maskedMorph->mInvert); - } -} - - //----------------------------------------------------------------------------- // releaseComponentTextures() // release any component texture UUIDs for which we have a baked texture @@ -8136,12 +8173,6 @@ LLColor4 LLVOAvatar::getClothesColor( ETextureIndex te ) return color; } -// static -LLColor4 LLVOAvatar::getDummyColor() -{ - return DUMMY_COLOR; -} - void LLVOAvatar::dumpAvatarTEs( const std::string& context ) const { LL_DEBUGS("Avatar") << avString() << (isSelf() ? "Self: " : "Other: ") << context << LL_ENDL; @@ -9897,7 +9928,7 @@ BOOL LLVOAvatar::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, } //virtual -BOOL LLVOAvatar::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLWearable *wearable) const +BOOL LLVOAvatar::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLViewerWearable *wearable) const { // non-self avatars don't have wearables return FALSE; @@ -10006,3 +10037,16 @@ U32 calc_shame(LLVOVolume* volume, std::set &textures) return shame; } + +LLVOAvatar::LLMaskedMorph::LLMaskedMorph(LLVisualParam *morph_target, BOOL invert, std::string layer) : + mMorphTarget(morph_target), + mInvert(invert), + mLayer(layer) +{ + LLPolyMorphTarget *target = dynamic_cast(morph_target); + if (target) + { + target->addPendingMorphMask(); + } +} + diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 7f465877e..c98ab0276 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -74,6 +74,7 @@ class LLTexGlobalColor; class LLVOAvatarBoneInfo; class LLAvatarSkeletonInfo; class LLPolySkeletalDistortionInfo; +class LLViewerWearable; class SHClientTagMgr : public LLSingleton, public boost::signals2::trackable { @@ -129,7 +130,7 @@ public: friend class LLVOAvatarSelf; protected: struct LLVOAvatarXmlInfo; - struct LLMaskedMorph; + class LLMaskedMorph; /******************************************************************************** ** ** @@ -162,6 +163,7 @@ protected: ** ** *******************************************************************************/ +public: /*virtual*/ bool isAgent() const; @@ -236,7 +238,7 @@ public: void dumpAnimationState(); virtual LLJoint* getJoint(const std::string &name); - virtual LLJoint* getRootJoint() { return &mRoot; } + virtual LLJoint* getRootJoint() { return mRoot; } void resetJointPositionsToDefault( void ); void resetSpecificJointPosition( const std::string& name ); @@ -368,6 +370,9 @@ protected: ** SKELETON **/ + virtual LLAvatarJoint* createAvatarJoint(); + virtual LLAvatarJoint* createAvatarJoint(S32 joint_num); + virtual LLAvatarJointMesh* createAvatarJointMesh(); public: void updateHeadOffset(); virtual F32 getPelvisToFoot() const { return mPelvisToFoot; } @@ -383,7 +388,7 @@ public: F32 mLastPelvisFixup; LLVector3 mHeadOffset; // current head position - LLViewerJoint mRoot; + LLAvatarJoint *mRoot; typedef std::map joint_map_t; joint_map_t mJointMap; @@ -393,11 +398,11 @@ public: virtual void buildCharacter(); virtual BOOL loadAvatar(); - BOOL setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 ¤t_volume_num, S32 ¤t_joint_num); + BOOL setupBone(const LLVOAvatarBoneInfo* info, LLJoint* parent, S32 ¤t_volume_num, S32 ¤t_joint_num); virtual BOOL buildSkeleton(const LLAvatarSkeletonInfo *info); private: - typedef std::vector avatar_joint_list_t; BOOL mIsBuilt; // state of deferred character building + typedef std::vector avatar_joint_list_t; avatar_joint_list_t mSkeleton; //-------------------------------------------------------------------- @@ -461,7 +466,6 @@ public: static void deleteCachedImages(bool clearAll=true); static void destroyGL(); static void restoreGL(); - BOOL mIsDummy; // for special views S32 mSpecialRenderMode; // special lighting U32 mAttachmentGeometryBytes; //number of bytes in attached geometry F32 mAttachmentSurfaceArea; //estimated surface area of attachments @@ -584,7 +588,7 @@ public: public: virtual BOOL isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex type, U32 index = 0) const; virtual BOOL isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, U32 index = 0) const; - virtual BOOL isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLWearable *wearable) const; + virtual BOOL isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLViewerWearable *wearable) const; BOOL isFullyBaked(); static BOOL areAllNearbyInstancesBaked(S32& grey_avatars); @@ -604,6 +608,8 @@ protected: void useBakedTexture(const LLUUID& id); LLViewerTexLayerSet* getTexLayerSet(const U32 index) const { return dynamic_cast(mBakedTextureDatas[index].mTexLayerSet); } + LLTexLayerSet* createTexLayerSet(); + typedef std::deque morph_list_t; struct BakedTextureData { @@ -703,7 +709,7 @@ private: BOOL mMeshTexturesDirty; typedef std::multimap polymesh_map_t; - polymesh_map_t mMeshes; + polymesh_map_t mPolyMeshes; avatar_joint_list_t mMeshLOD; //-------------------------------------------------------------------- @@ -771,7 +777,6 @@ public: void setVisibilityRank(U32 rank); U32 getVisibilityRank() const { return mVisibilityRank; } // unused static S32 sNumVisibleAvatars; // Number of instances of this class - static LLColor4 getDummyColor(); /** Appearance ** ** *******************************************************************************/ @@ -781,8 +786,7 @@ public: ** WEARABLES **/ -public: - virtual BOOL isWearingWearableType(LLWearableType::EType type ) const; + //-------------------------------------------------------------------- // Attachments @@ -793,6 +797,7 @@ public: virtual BOOL detachObject(LLViewerObject *viewer_object); void cleanupAttachedMesh( LLViewerObject* pVO ); static LLVOAvatar* findAvatarFromAttachment(LLViewerObject* obj); + virtual BOOL isWearingWearableType(LLWearableType::EType type ) const; protected: LLViewerJointAttachment* getTargetAttachmentPoint(LLViewerObject* viewer_object); void lazyAttach(); @@ -1138,7 +1143,7 @@ protected: // Shared with LLVOAvatarSelf struct LLVOAvatarMeshInfo { - typedef std::pair morph_info_pair_t; + typedef std::pair morph_info_pair_t; typedef std::vector morph_info_list_t; LLVOAvatarMeshInfo() : mLOD(0), mMinPixelArea(.1f) {} @@ -1162,7 +1167,7 @@ protected: // Shared with LLVOAvatarSelf typedef std::vector mesh_info_list_t; mesh_info_list_t mMeshInfoList; - typedef std::vector skeletal_distortion_info_list_t; + typedef std::vector skeletal_distortion_info_list_t; skeletal_distortion_info_list_t mSkeletalDistortionInfoList; struct LLVOAvatarAttachmentInfo @@ -1209,17 +1214,13 @@ protected: // Shared with LLVOAvatarSelf morph_info_list_t mMorphMaskInfoList; }; - struct LLMaskedMorph + + class LLMaskedMorph { - LLMaskedMorph(LLPolyMorphTarget *morph_target, BOOL invert, std::string layer) : - mMorphTarget(morph_target), - mInvert(invert), - mLayer(layer) - { - morph_target->addPendingMorphMask(); - } + public: + LLMaskedMorph(LLVisualParam *morph_target, BOOL invert, std::string layer); - LLPolyMorphTarget *mMorphTarget; + LLVisualParam *mMorphTarget; BOOL mInvert; std::string mLayer; }; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 20a83b024..3579059ed 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -633,7 +633,7 @@ BOOL LLVOAvatarSelf::setParamWeight(const LLViewerVisualParam *param, F32 weight U32 size = gAgentWearables.getWearableCount(type); for (U32 count = 0; count < size; ++count) { - LLWearable *wearable = gAgentWearables.getWearable(type,count); + LLViewerWearable *wearable = gAgentWearables.getViewerWearable(type,count); if (wearable) { wearable->setVisualParamWeight(param->getID(), weight, upload_bake); @@ -667,7 +667,7 @@ void LLVOAvatarSelf::idleUpdateAppearanceAnimation() LLWearable *wearable = gAgentWearables.getTopWearable((LLWearableType::EType)type); if (wearable) { - wearable->writeToAvatar(); + wearable->writeToAvatar(this); } } @@ -1358,7 +1358,7 @@ BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLViewerTexture** tex { return FALSE; } - *tex_pp = local_tex_obj->getImage(); + *tex_pp = dynamic_cast (local_tex_obj->getImage()); return TRUE; } @@ -1378,7 +1378,7 @@ LLViewerFetchedTexture* LLVOAvatarSelf::getLocalTextureGL(LLAvatarAppearanceDefi { return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR); } - return local_tex_obj->getImage(); + return dynamic_cast (local_tex_obj->getImage()); } const LLUUID& LLVOAvatarSelf::getLocalTextureID(ETextureIndex type, U32 index) const @@ -1552,7 +1552,7 @@ BOOL LLVOAvatarSelf::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex t } //virtual -BOOL LLVOAvatarSelf::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLWearable *wearable) const +BOOL LLVOAvatarSelf::isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLViewerWearable *wearable) const { if (isIndexBakedTexture(type)) { @@ -2167,7 +2167,7 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const for (U32 wearable_index = 0; wearable_index < count; ++wearable_index) { - LLWearable *wearable = gAgentWearables.getWearable(wearable_type, wearable_index); + LLViewerWearable *wearable = gAgentWearables.getViewerWearable(wearable_type, wearable_index); if (wearable) { const LLLocalTextureObject *texture = wearable->getLocalTextureObject((S32)t_index); @@ -2242,7 +2242,7 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe LLLocalTextureObject* LLVOAvatarSelf::getLocalTextureObject(LLAvatarAppearanceDefines::ETextureIndex i, U32 wearable_index) const { LLWearableType::EType type = LLAvatarAppearanceDictionary::getInstance()->getTEWearableType(i); - LLWearable* wearable = gAgentWearables.getWearable(type, wearable_index); + LLViewerWearable* wearable = gAgentWearables.getViewerWearable(type, wearable_index); if (wearable) { return wearable->getLocalTextureObject(i); diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index c89ca0a60..602bfe408 100644 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -201,7 +201,7 @@ public: // If you want to check all textures of a given type, pass gAgentWearables.getWearableCount() for index /*virtual*/ BOOL isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex type, U32 index) const; /*virtual*/ BOOL isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, U32 index = 0) const; - /*virtual*/ BOOL isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLWearable *wearable) const; + /*virtual*/ BOOL isTextureVisible(LLAvatarAppearanceDefines::ETextureIndex type, LLViewerWearable *wearable) const; //-------------------------------------------------------------------- diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 6f6411ce3..a813bf04d 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -42,20 +42,23 @@ struct LLWearableArrivedData { LLWearableArrivedData(LLAssetType::EType asset_type, const std::string& wearable_name, - void(*asset_arrived_callback)(LLWearable*, void* userdata), + LLAvatarAppearance* avatarp, + void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata) : mAssetType( asset_type ), mCallback( asset_arrived_callback ), mUserdata( userdata ), mName( wearable_name ), - mRetries(0) + mRetries(0), + mAvatarp(avatarp) {} LLAssetType::EType mAssetType; - void (*mCallback)(LLWearable*, void* userdata); + void (*mCallback)(LLViewerWearable*, void* userdata); void* mUserdata; std::string mName; S32 mRetries; + LLAvatarAppearance *mAvatarp; }; //////////////////////////////////////////////////////////////////////////// @@ -72,10 +75,10 @@ void LLWearableList::cleanup() mList.clear(); } -void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata) +void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAvatarAppearance* avatarp, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata) { llassert( (asset_type == LLAssetType::AT_CLOTHING) || (asset_type == LLAssetType::AT_BODYPART) ); - LLWearable* instance = get_if_there(mList, assetID, (LLWearable*)NULL ); + LLViewerWearable* instance = get_if_there(mList, assetID, (LLViewerWearable*)NULL ); if( instance ) { asset_arrived_callback( instance, userdata ); @@ -85,7 +88,7 @@ void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& weara gAssetStorage->getAssetData(assetID, asset_type, LLWearableList::processGetAssetReply, - (void*)new LLWearableArrivedData( asset_type, wearable_name, asset_arrived_callback, userdata ), + (void*)new LLWearableArrivedData( asset_type, wearable_name, avatarp, asset_arrived_callback, userdata ), TRUE); } } @@ -95,12 +98,17 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID { BOOL isNewWearable = FALSE; LLWearableArrivedData* data = (LLWearableArrivedData*) userdata; - LLWearable* wearable = NULL; // NULL indicates failure + LLViewerWearable* wearable = NULL; // NULL indicates failure + LLAvatarAppearance *avatarp = data->mAvatarp; if( !filename ) { LL_WARNS("Wearable") << "Bad Wearable Asset: missing file." << LL_ENDL; } + else if(!avatarp) + { + LL_WARNS("Wearable") << "Bad asset request: missing avatar pointer." << LL_ENDL; + } else if (status >= 0) { // read the file @@ -111,7 +119,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID } else { - wearable = new LLWearable(uuid); + wearable = new LLViewerWearable(uuid); bool res = wearable->importFile( fp ); if (!res) { @@ -203,11 +211,11 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID } -LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std::string& new_name) +LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearable, const std::string& new_name) { lldebugs << "LLWearableList::createCopy()" << llendl; - LLWearable *wearable = generateNewWearable(); + LLViewerWearable *wearable = generateNewWearable(); wearable->copyDataFrom(old_wearable); LLPermissions perm(old_wearable->getPermissions()); @@ -222,11 +230,11 @@ LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std return wearable; } -LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type ) +LLViewerWearable* LLWearableList::createNewWearable( LLWearableType::EType type, LLAvatarAppearance *avatarp ) { lldebugs << "LLWearableList::createNewWearable()" << llendl; - LLWearable *wearable = generateNewWearable(); + LLViewerWearable *wearable = generateNewWearable(); wearable->setType( type ); std::string name = LLTrans::getString( LLWearableType::getTypeDefaultNewName(wearable->getType()) ); @@ -251,13 +259,13 @@ LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type ) return wearable; } -LLWearable *LLWearableList::generateNewWearable() +LLViewerWearable *LLWearableList::generateNewWearable() { LLTransactionID tid; tid.generate(); LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - LLWearable* wearable = new LLWearable(tid); + LLViewerWearable* wearable = new LLViewerWearable(tid); mList[new_asset_id] = wearable; return wearable; } diff --git a/indra/newview/llwearablelist.h b/indra/newview/llwearablelist.h index 12d0037ae..d6f0fd09a 100644 --- a/indra/newview/llwearablelist.h +++ b/indra/newview/llwearablelist.h @@ -28,7 +28,7 @@ #define LL_LLWEARABLELIST_H #include "llmemory.h" -#include "llwearable.h" +#include "llviewerwearable.h" #include "lluuid.h" #include "llassetstorage.h" @@ -50,20 +50,21 @@ public: void getAsset(const LLAssetID& assetID, const std::string& wearable_name, + LLAvatarAppearance *avatarp, LLAssetType::EType asset_type, - void(*asset_arrived_callback)(LLWearable*, void* userdata), + void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata); - LLWearable* createCopy(const LLWearable* old_wearable, const std::string& new_name = std::string()); - LLWearable* createNewWearable(LLWearableType::EType type); + LLViewerWearable* createCopy(const LLViewerWearable* old_wearable, const std::string& new_name = std::string()); + LLViewerWearable* createNewWearable(LLWearableType::EType type, LLAvatarAppearance *avatarp); // Callback static void processGetAssetReply(const char* filename, const LLAssetID& assetID, void* user_data, S32 status, LLExtStat ext_status); protected: - LLWearable* generateNewWearable(); // used for the create... functions + LLViewerWearable* generateNewWearable(); // used for the create... functions private: - std::map mList; + std::map mList; }; #endif // LL_LLWEARABLELIST_H diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 853af1d82..9da50b526 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -881,7 +881,7 @@ bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const if ( (getCompositeInfo(idItem, &strComposite, &pFolder)) && (cstrItemType != strComposite) ) { LLUUID idCompositeItem; - if ((type = LLWearable::typeNameToType(strComposite)) != WT_INVALID) + if ((type = LLViewerWearable::typeNameToType(strComposite)) != WT_INVALID) { idCompositeItem = gAgent.getWearableItem(type); } @@ -931,7 +931,7 @@ bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const case LLAssetType::AT_BODYPART: case LLAssetType::AT_CLOTHING: { - LLWearable* pWearable = gAgent.getWearableFromWearableItem(pItem->getUUID()); + LLViewerWearable* pWearable = gAgent.getWearableFromWearableItem(pItem->getUUID()); if ( (pWearable) && (!isRemovable(pWearable->getType())) ) return false; // If one wearable in the folder is non-removeable then the entire folder should be } diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 455f7dfa3..8832fd854 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -472,7 +472,7 @@ void RlvForceWear::forceFolder(const LLViewerInventoryCategory* pFolder, EWearAc } else { - const LLWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getUUID()); + const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getUUID()); if ( (pWearable) && (isForceRemovable(pWearable, false)) ) remWearable(pWearable); } @@ -612,7 +612,7 @@ void RlvForceWear::forceDetach(const LLViewerJointAttachment* pAttachPt) } // Checked: 2010-03-19 (RLVa-1.1.3b) | Modified: RLVa-1.2.0a -bool RlvForceWear::isForceRemovable(const LLWearable* pWearable, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) +bool RlvForceWear::isForceRemovable(const LLViewerWearable* pWearable, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) { // Wearable can be removed by an RLV command if: // - its asset type is AT_CLOTHING @@ -640,13 +640,13 @@ bool RlvForceWear::isForceRemovable(LLWearableType::EType wtType, bool fCheckCom { // Wearable type can be removed by an RLV command if there's at least one currently worn wearable that can be removed for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(wtType); idxWearable < cntWearable; idxWearable++) - if (isForceRemovable(gAgentWearables.getWearable(wtType, idxWearable), fCheckComposite, idExcept)) + if (isForceRemovable(gAgentWearables.getViewerWearable(wtType, idxWearable), fCheckComposite, idExcept)) return true; return false; } // Checked: 2010-03-19 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a -void RlvForceWear::forceRemove(const LLWearable* pWearable) +void RlvForceWear::forceRemove(const LLViewerWearable* pWearable) { // Sanity check - no need to process duplicate removes if ( (!pWearable) || (isRemWearable(pWearable)) ) @@ -675,7 +675,7 @@ void RlvForceWear::forceRemove(const LLWearable* pWearable) void RlvForceWear::forceRemove(LLWearableType::EType wtType) { for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(wtType); idxWearable < cntWearable; idxWearable++) - forceRemove(gAgentWearables.getWearable(wtType, idxWearable)); + forceRemove(gAgentWearables.getViewerWearable(wtType, idxWearable)); } // Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a @@ -784,7 +784,7 @@ void RlvForceWear::remAttachment(const LLViewerObject* pAttachObj) // Checked: 2010-08-30 (RLVa-1.1.3b) | Modified: RLVa-1.2.1c void RlvForceWear::addWearable(const LLViewerInventoryItem* pItem, EWearAction eAction) { - const LLWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()); + const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()); // When replacing remove all currently worn wearables of this type *unless* the item is currently worn if ( (ACTION_WEAR_REPLACE == eAction) && (!pWearable) ) forceRemove(pItem->getWearableType()); @@ -812,7 +812,7 @@ void RlvForceWear::addWearable(const LLViewerInventoryItem* pItem, EWearAction e } // Checked: 2010-08-30 (RLVa-1.1.3b) | Modified: RLVa-1.2.1c -void RlvForceWear::remWearable(const LLWearable* pWearable) +void RlvForceWear::remWearable(const LLViewerWearable* pWearable) { // Remove it from 'm_addWearables' if it's queued for wearing const LLViewerInventoryItem* pItem = gInventory.getItem(pWearable->getItemID()); @@ -850,7 +850,7 @@ void RlvForceWear::done() // Wearables if (m_remWearables.size()) { - for (std::list::const_iterator itWearable = m_remWearables.begin(); itWearable != m_remWearables.end(); ++itWearable) + for (std::list::const_iterator itWearable = m_remWearables.begin(); itWearable != m_remWearables.end(); ++itWearable) pAppearanceMgr->removeItemFromAvatar((*itWearable)->getItemID()); m_remWearables.clear(); } diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index 7ecb7b065..9b9179505 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -237,9 +237,9 @@ public: void forceDetach(const LLViewerJointAttachment* ptAttachPt); // Wearables - static bool isForceRemovable(const LLWearable* pWearable, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); + static bool isForceRemovable(const LLViewerWearable* pWearable, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); static bool isForceRemovable(LLWearableType::EType wtType, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); - void forceRemove(const LLWearable* pWearable); + void forceRemove(const LLViewerWearable* pWearable); void forceRemove(LLWearableType::EType wtType); public: @@ -248,7 +248,7 @@ protected: void addAttachment(const LLViewerInventoryItem* pItem, EWearAction eAction); void remAttachment(const LLViewerObject* pAttachObj); void addWearable(const LLViewerInventoryItem* pItem, EWearAction eAction); - void remWearable(const LLWearable* pWearable); + void remWearable(const LLViewerWearable* pWearable); // Convenience (prevents long lines that run off the screen elsewhere) bool isAddAttachment(const LLViewerInventoryItem* pItem) const @@ -277,7 +277,7 @@ protected: } return fFound; } - bool isRemWearable(const LLWearable* pWearable) const + bool isRemWearable(const LLViewerWearable* pWearable) const { return std::find(m_remWearables.begin(), m_remWearables.end(), pWearable) != m_remWearables.end(); } @@ -291,7 +291,7 @@ protected: addattachments_map_t m_addAttachments; LLInventoryModel::item_array_t m_addGestures; std::list m_remAttachments; - std::list m_remWearables; + std::list m_remWearables; LLInventoryModel::item_array_t m_remGestures; private: diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp index 2fa4736db..268d27f98 100644 --- a/indra/newview/rlvlocks.cpp +++ b/indra/newview/rlvlocks.cpp @@ -936,7 +936,7 @@ bool RlvWearableLocks::canRemove(LLWearableType::EType eType) const { // NOTE: we return TRUE if the wearable type has at least one wearable that can be removed by the user for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(eType); idxWearable < cntWearable; idxWearable++) - if (!isLockedWearable(gAgentWearables.getWearable(eType, idxWearable))) + if (!isLockedWearable(gAgentWearables.getViewerWearable(eType, idxWearable))) return true; return false; } @@ -946,13 +946,13 @@ bool RlvWearableLocks::hasLockedWearable(LLWearableType::EType eType) const { // NOTE: we return TRUE if there is at least 1 non-removable wearable currently worn on this wearable type for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(eType); idxWearable < cntWearable; idxWearable++) - if (isLockedWearable(gAgentWearables.getWearable(eType, idxWearable))) + if (isLockedWearable(gAgentWearables.getViewerWearable(eType, idxWearable))) return true; return false; } // Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a -bool RlvWearableLocks::isLockedWearableExcept(const LLWearable* pWearable, const LLUUID& idRlvObj) const +bool RlvWearableLocks::isLockedWearableExcept(const LLViewerWearable* pWearable, const LLUUID& idRlvObj) const { if (idRlvObj.isNull()) return isLockedWearable(pWearable); diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h index ac207450d..6e185e322 100644 --- a/indra/newview/rlvlocks.h +++ b/indra/newview/rlvlocks.h @@ -21,6 +21,7 @@ #include "llagentwearables.h" #include "lleventtimer.h" #include "llvoavatarself.h" +#include "llviewerwearable.h" #include "rlvdefines.h" #include "rlvcommon.h" @@ -237,9 +238,9 @@ public: void removeWearableTypeLock(LLWearableType::EType eType, const LLUUID& idRlvObj, ERlvLockMask eLock); // Returns TRUE if the wearable is RLV_LOCK_REMOVE locked - bool isLockedWearable(const LLWearable* pWearable) const; + bool isLockedWearable(const LLViewerWearable* pWearable) const; // Returns TRUE if the wearable is RLV_LOCK_REMOVE locked by anything other than idRlvObj - bool isLockedWearableExcept(const LLWearable* pWearable, const LLUUID& idRlvObj) const; + bool isLockedWearableExcept(const LLViewerWearable* pWearable, const LLUUID& idRlvObj) const; // NOTE: isLockedWearableType doesn't check if a worn wearable is a specific wearable lock so don't let these be called by the outside protected: @@ -503,7 +504,7 @@ inline bool RlvWearableLocks::canRemove(const LLInventoryItem* pItem) const { // The specified item can be removed if its wearable can be removed RLV_ASSERT( (pItem) && (LLInventoryType::IT_WEARABLE == pItem->getInventoryType()) ); - const LLWearable* pWearable = (pItem) ? gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()) : NULL; + const LLViewerWearable* pWearable = (pItem) ? gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()) : NULL; return (pWearable) && (!isLockedWearable(pWearable)); } @@ -540,7 +541,7 @@ inline bool RlvWearableLocks::hasLockedWearableType(ERlvLockMask eLock) const } // Checked: 2010-11-30 (RLVa-1.3.0b) | Modified: RLVa-1.2.0a -inline bool RlvWearableLocks::isLockedWearable(const LLWearable* pWearable) const +inline bool RlvWearableLocks::isLockedWearable(const LLViewerWearable* pWearable) const { // Wearable is locked if: // - it's specifically marked as non-removable