From 38a565f71a54aaa66300a0ab593e366731aac769 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 9 Oct 2012 12:30:38 -0700 Subject: Initial pass at getting a list of viewer objects with non-null material IDs. --- indra/llprimitive/lltextureentry.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 34eff17519..b04fa809d2 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -29,6 +29,7 @@ #include "lluuid.h" #include "llmediaentry.h" #include "lltextureentry.h" +#include "llmaterialid.h" #include "llsdutil_math.h" #include "v4color.h" @@ -83,6 +84,8 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) mBump = rhs.mBump; mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; + mMaterialID = rhs.mMaterialID; + if (rhs.mMediaEntry != NULL) { // Make a copy mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry); @@ -103,6 +106,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mBump = rhs.mBump; mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; + mMaterialID = rhs.mMaterialID; if (mMediaEntry != NULL) { delete mMediaEntry; } @@ -130,6 +134,7 @@ void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 of mBump = bump; mMediaFlags = 0x0; mGlow = 0; + mMaterialID.clear(); setColor(LLColor4(1.f, 1.f, 1.f, 1.f)); if (mMediaEntry != NULL) { @@ -159,6 +164,7 @@ bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const if (mBump != rhs.mBump) return (true); if (mMediaFlags != rhs.mMediaFlags) return (true); if (mGlow != rhs.mGlow) return (true); + if (mMaterialID != rhs.mMaterialID) return (true); return(false); } @@ -174,6 +180,7 @@ bool LLTextureEntry::operator==(const LLTextureEntry &rhs) const if (mBump != rhs.mBump) return (false); if (mMediaFlags != rhs.mMediaFlags) return false; if (mGlow != rhs.mGlow) return false; + if (mMaterialID != rhs.mMaterialID) return (false); return(true); } @@ -523,6 +530,16 @@ S32 LLTextureEntry::setGlow(F32 glow) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) +{ + if (mMaterialID != pMaterialID) + { + mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; -- cgit v1.3 From 5f03e197f4cfb43de93dc42b16b54beafccd376a Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 25 Jan 2013 17:54:38 -0500 Subject: Trying to set materials up for rendering! Yay! --- indra/llprimitive/llmaterial.h | 2 +- indra/llprimitive/llprimitive.cpp | 6 +- indra/llprimitive/llprimitive.h | 1 + indra/llprimitive/llprimtexturelist.cpp | 9 ++ indra/llprimitive/llprimtexturelist.h | 2 + indra/llprimitive/lltextureentry.cpp | 10 ++ indra/llprimitive/lltextureentry.h | 2 + indra/llrender/llshadermgr.cpp | 2 + indra/llrender/llshadermgr.h | 2 + indra/newview/lldrawable.cpp | 47 ++++++++++ indra/newview/lldrawable.h | 2 + indra/newview/lldrawpoolbump.cpp | 13 ++- indra/newview/lldrawpoolbump.h | 5 +- indra/newview/llface.cpp | 42 +++++++++ indra/newview/llface.h | 6 ++ indra/newview/llselectmgr.cpp | 2 +- indra/newview/llspatialpartition.h | 13 ++- indra/newview/llviewerobject.cpp | 157 ++++++++++++++++++++++++++++++-- indra/newview/llviewerobject.h | 10 ++ indra/newview/llvovolume.cpp | 64 +++++++++++-- indra/newview/llvovolume.h | 1 + 21 files changed, 378 insertions(+), 20 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index da364e548c..6f94cfda17 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -60,7 +60,7 @@ public: F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } - const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } U8 getSpecularLightExponent() const { return mSpecularLightExponent; } void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 86aa371368..94df529b25 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -271,7 +271,6 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t) return mTextureList.setScale(index, s, t); } - // BUG: slow - done this way because texture entries have some // voodoo related to texture coords S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s) @@ -372,6 +371,10 @@ S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID return mTextureList.setMaterialID(index, pMaterialID); } +S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + return mTextureList.setMaterialParams(index, pMaterialParams); +} LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { @@ -1349,6 +1352,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); retval |= setTEMaterialID(i, material_ids[i]); + coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e1635740ef..6a9c5e9639 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -355,6 +355,7 @@ public: virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); + virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed void copyTEs(const LLPrimitive *primitive); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 20438578b3..c0923315cb 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -369,6 +369,15 @@ S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMateri return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + if (index < mEntryList.size()) + { + return mEntryList[index]->setMaterialParams(pMaterialParams); + } + return TEM_CHANGE_NONE; +} + S32 LLPrimTextureList::size() const { return mEntryList.size(); diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 691df44c18..d7fabbbb79 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -31,6 +31,7 @@ #include "lluuid.h" #include "v3color.h" #include "v4color.h" +#include "llmaterial.h" class LLTextureEntry; @@ -104,6 +105,7 @@ public: S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); + S32 setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); S32 size() const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index b04fa809d2..23b15b697c 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -540,6 +540,16 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) +{ + if (mMaterial != pMaterialParams) + { + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index ff1cc65bba..c443ebcb30 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -124,6 +124,7 @@ public: S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); S32 setMaterialID(const LLMaterialID& pMaterialID); + S32 setMaterialParams(const LLMaterialPtr pMaterialParams); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -143,6 +144,7 @@ public: U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; + const LLMaterialPtr getMaterialParams() const { return mMaterial; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e52411ebe5..b6b39028d3 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1124,6 +1124,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("global_gamma"); mReservedUniforms.push_back("texture_gamma"); + + mReservedUniforms.push_back("specular_color"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index a711a64919..a89e031906 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -168,6 +168,8 @@ public: GLOBAL_GAMMA, TEXTURE_GAMMA, + SPECULAR_COLOR, + END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 4894d63e13..1ca2344c41 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -300,6 +300,53 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) } +LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp) +{ + LLMemType mt(LLMemType::MTYPE_DRAWABLE); + + LLFace *face; + face = new LLFace(this, mVObjp); + + face->setTEOffset(mFaces.size()); + face->setTexture(texturep); + face->setNormalMap(normalp); + face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); + + mFaces.push_back(face); + + if (isState(UNLIT)) + { + face->setState(LLFace::FULLBRIGHT); + } + + return face; + +} + +LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp) +{ + LLMemType mt(LLMemType::MTYPE_DRAWABLE); + + LLFace *face; + face = new LLFace(this, mVObjp); + + face->setTEOffset(mFaces.size()); + face->setTexture(texturep); + face->setNormalMap(normalp); + face->setSpecularMap(specularp); + face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); + + mFaces.push_back(face); + + if (isState(UNLIT)) + { + face->setState(LLFace::FULLBRIGHT); + } + + return face; + +} + void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { if (newFaces == (S32)mFaces.size()) diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index b1e32bdb5b..13089f4f26 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -147,6 +147,8 @@ public: //void removeFace(const S32 i); // SJB: Avoid using this, it's slow LLFace* addFace(LLFacePool *poolp, LLViewerTexture *texturep); LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep); + LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp); + LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp); void deleteFaces(S32 offset, S32 count); void setNumFaces(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep); void setNumFacesFast(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 718133ba29..d613def1bd 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -632,6 +632,11 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel) { U8 bump_code = params.mBump; + if (params.mNormalMap.notNull()) + { + bump_code = BE_CUSTOM; + return bindBumpMap(bump_code, params.mNormalMap, params.mVSize, channel); + } return bindBumpMap(bump_code, params.mTexture, params.mVSize, channel); } @@ -670,7 +675,9 @@ BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsi case BE_DARKNESS: bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code ); break; - + case BE_CUSTOM: + bump = tex; + break; default: if( bump_code < LLStandardBumpmap::sStandardBumpmapCount ) { @@ -855,7 +862,9 @@ void LLDrawPoolBump::renderDeferred(S32 pass) for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo& params = **i; - + + gDeferredBumpProgram.uniform4fv(LLShaderMgr::SPECULAR_COLOR, 4, (GLfloat*)params.mSpecColor.mV); + LLDrawPoolBump::bindBumpMap(params, bump_channel); pushBatch(params, mask, TRUE); } diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 476b1d41b7..aaf0bdf36f 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -100,8 +100,9 @@ enum EBumpEffect BE_NO_BUMP = 0, BE_BRIGHTNESS = 1, BE_DARKNESS = 2, - BE_STANDARD_0 = 3, // Standard must always be the last one - BE_COUNT = 4 + BE_CUSTOM = 3, + BE_STANDARD_0 = 4, // Standard must always be the last one + BE_COUNT = 5 }; //////////////////////////////////////////////////////////////// diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 605cb81c10..01cbfafe16 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -316,6 +316,48 @@ void LLFace::setTexture(LLViewerTexture* tex) mTexture = tex ; } +void LLFace::setNormalMap(LLViewerTexture* tex) +{ + if(mNormalMap == tex) + { + return ; + } + + if(mNormalMap.notNull()) + { + mNormalMap->removeFace(this) ; + removeAtlas() ; + } + + if(tex) + { + tex->addFace(this) ; + } + + mNormalMap = tex ; +} + +void LLFace::setSpecularMap(LLViewerTexture* tex) +{ + if(mSpecMap == tex) + { + return ; + } + + if(mSpecMap.notNull()) + { + mSpecMap->removeFace(this) ; + removeAtlas() ; + } + + if(tex) + { + tex->addFace(this) ; + } + + mSpecMap = tex ; +} + void LLFace::dirtyTexture() { LLDrawable* drawablep = getDrawable(); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index de4d03351c..cb76c6e8a6 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -111,6 +111,8 @@ public: void setTextureIndex(U8 index); U8 getTextureIndex() const { return mTextureIndex; } void setTexture(LLViewerTexture* tex) ; + void setNormalMap(LLViewerTexture* tex); + void setSpecularMap(LLViewerTexture* tex); void switchTexture(LLViewerTexture* new_texture); void dirtyTexture(); LLXformMatrix* getXform() const { return mXform; } @@ -266,6 +268,8 @@ public: F32 mLastSkinTime; F32 mLastMoveTime; LLMatrix4* mTextureMatrix; + LLMatrix4* mSpecMapMatrix; + LLMatrix4* mNormalMapMatrix; LLDrawInfo* mDrawInfo; private: @@ -285,6 +289,8 @@ private: LLXformMatrix* mXform; LLPointer mTexture; + LLPointer mSpecMap; + LLPointer mNormalMap; LLPointer mDrawablep; LLPointer mVObjp; S32 mTEOffset; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c3c37141ed..ff4c120623 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1927,7 +1927,7 @@ void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) llassert(mMediaData.isMap()); const LLTextureEntry *texture_entry = object->getTE(te); if (!mMediaData.isMap() || - (NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY)) + ((NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY))) { // skip adding/updating media } diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index b1706d9d35..2c4f6754ec 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -119,6 +119,17 @@ public: LL_ALIGN_16(LLFace* mFace); //associated face F32 mDistance; U32 mDrawMode; + + LLMaterialID *mMaterialID; // If this is false, the following parameters are unused. + LLPointer mSpecularMap; + const LLMatrix4* mSpecularMapMatrix; + LLPointer mNormalMap; + const LLMatrix4* mNormalMapMatrix; + LLVector4 mSpecColor; // XYZ = Specular RGB, W = Specular Exponent + F32 mEnvIntensity; + F32 mAlphaMaskCutoff; + U8 mDiffuseAlphaMode; + struct CompareTexture { @@ -169,7 +180,7 @@ public: } }; - + struct CompareBump { bool operator()(const LLPointer& lhs, const LLPointer& rhs) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 347d82d492..4490e51493 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -202,6 +202,8 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mTotalCRC(0), mListIndex(-1), mTEImages(NULL), + mTENormalMaps(NULL), + mTESpecularMaps(NULL), mGLName(0), mbCanSelect(TRUE), mFlags(0), @@ -322,6 +324,18 @@ void LLViewerObject::deleteTEImages() { delete[] mTEImages; mTEImages = NULL; + + if (mTENormalMaps != NULL) + { + delete[] mTENormalMaps; + mTENormalMaps = NULL; + } + + if (mTESpecularMaps != NULL) + { + delete[] mTESpecularMaps; + mTESpecularMaps = NULL; + } } void LLViewerObject::markDead() @@ -3935,25 +3949,39 @@ void LLViewerObject::setNumTEs(const U8 num_tes) { LLPointer *new_images; new_images = new LLPointer[num_tes]; + + LLPointer *new_normmaps; + new_normmaps = new LLPointer[num_tes]; + + LLPointer *new_specmaps; + new_specmaps = new LLPointer[num_tes]; for (i = 0; i < num_tes; i++) { if (i < getNumTEs()) { new_images[i] = mTEImages[i]; + new_normmaps[i] = mTENormalMaps[i]; + new_specmaps[i] = mTESpecularMaps[i]; } else if (getNumTEs()) { new_images[i] = mTEImages[getNumTEs()-1]; + new_normmaps[i] = mTENormalMaps[i]; + new_specmaps[i] = mTESpecularMaps[i]; } else { new_images[i] = NULL; + new_normmaps[i] = NULL; + new_specmaps[i] = NULL; } } deleteTEImages(); mTEImages = new_images; + mTENormalMaps = new_normmaps; + mTESpecularMaps = new_specmaps; } else { @@ -4032,12 +4060,18 @@ void LLViewerObject::sendTEUpdate() const void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) { LLPrimitive::setTE(te, texture_entry); -// This doesn't work, don't get any textures. -// if (mDrawable.notNull() && mDrawable->isVisible()) -// { - const LLUUID& image_id = getTE(te)->getID(); - mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); -// } + + const LLUUID& image_id = getTE(te)->getID(); + mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + + if (getTE(te)->getMaterialParams() != NULL) + { + const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); + mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE); + + const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID(); + mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + } } void LLViewerObject::setTEImage(const U8 te, LLViewerTexture *imagep) @@ -4072,6 +4106,46 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos return retval; } +S32 LLViewerObject::setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost host) +{ + LL_INFOS("Materials") << "Maybe normal maps! " << uuid << LL_ENDL; + S32 retval = 0; + if (uuid != getTE(te)->getMaterialParams()->getNormalID() || + uuid == LLUUID::null) + { + LL_INFOS("Materials") << "Normal maps! " << uuid << LL_ENDL; + retval = TEM_CHANGE_TEXTURE; + getTE(te)->getMaterialParams()->setNormalID(uuid); + mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE, 0, 0, host); + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } + } + return retval; +} + +S32 LLViewerObject::setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost host) +{ + LL_INFOS("Materials") << "Maybe specular maps! " << uuid << LL_ENDL; + S32 retval = 0; + if (uuid != getTE(te)->getMaterialParams()->getSpecularID() || + uuid == LLUUID::null) + { + LL_INFOS("Materials") << "Specular maps! " << uuid << LL_ENDL; + retval = TEM_CHANGE_TEXTURE; + getTE(te)->getMaterialParams()->setSpecularID(uuid); + mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } + } + return retval; +} + //virtual void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image) { @@ -4082,12 +4156,39 @@ void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image) mTEImages[index] = new_image ; } +void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) +{ + if(index < 0 || index >= getNumTEs()) + { + return ; + } + mTENormalMaps[index] = new_image ; +} + +void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) +{ + if(index < 0 || index >= getNumTEs()) + { + return ; + } + mTESpecularMaps[index] = new_image ; +} + S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid) { // Invalid host == get from the agent's sim return setTETextureCore(te, uuid, LLHost::invalid); } +S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid) +{ + return setTENormalMapCore(te, uuid, LLHost::invalid); +} + +S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid) +{ + return setTESpecularMapCore(te, uuid, LLHost::invalid); +} S32 LLViewerObject::setTEColor(const U8 te, const LLColor3& color) { @@ -4369,6 +4470,50 @@ LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const } +LLViewerTexture *LLViewerObject::getTENormalMap(const U8 face) const +{ + // llassert(mTEImages); + + if (face < getNumTEs()) + { + LLViewerTexture* image = mTENormalMaps[face]; + if (image) + { + return image; + } + else + { + return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep); + } + } + + llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl; + + return NULL; +} + +LLViewerTexture *LLViewerObject::getTESpecularMap(const U8 face) const +{ + // llassert(mTEImages); + + if (face < getNumTEs()) + { + LLViewerTexture* image = mTESpecularMaps[face]; + if (image) + { + return image; + } + else + { + return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep); + } + } + + llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl; + + return NULL; +} + void LLViewerObject::fitFaceTexture(const U8 face) { llinfos << "fitFaceTexture not implemented" << llendl; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 255d0cd080..7b98c01243 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -292,7 +292,11 @@ public: /*virtual*/ void setNumTEs(const U8 num_tes); /*virtual*/ void setTE(const U8 te, const LLTextureEntry &texture_entry); /*virtual*/ S32 setTETexture(const U8 te, const LLUUID &uuid); + /*virtual*/ S32 setTENormalMap(const U8 te, const LLUUID &uuid); + /*virtual*/ S32 setTESpecularMap(const U8 te, const LLUUID &uuid); S32 setTETextureCore(const U8 te, const LLUUID& uuid, LLHost host); + S32 setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost host); + S32 setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost host); /*virtual*/ S32 setTEColor(const U8 te, const LLColor3 &color); /*virtual*/ S32 setTEColor(const U8 te, const LLColor4 &color); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); @@ -313,7 +317,11 @@ public: /*virtual*/ BOOL setMaterial(const U8 material); virtual void setTEImage(const U8 te, LLViewerTexture *imagep); // Not derived from LLPrimitive virtual void changeTEImage(S32 index, LLViewerTexture* new_image) ; + virtual void changeTENormalMap(S32 index, LLViewerTexture* new_image) ; + virtual void changeTESpecularMap(S32 index, LLViewerTexture* new_image) ; LLViewerTexture *getTEImage(const U8 te) const; + LLViewerTexture *getTENormalMap(const U8 te) const; + LLViewerTexture *getTESpecularMap(const U8 te) const; void fitFaceTexture(const U8 face); void sendTEUpdate() const; // Sends packed representation of all texture entry information @@ -588,6 +596,8 @@ public: S32 mListIndex; LLPointer *mTEImages; + LLPointer *mTENormalMaps; + LLPointer *mTESpecularMaps; // Selection, picking and rendering variables U32 mGLName; // GL "name" used by selection code diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index a37dea4a60..c90ca48b01 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -77,6 +77,7 @@ #include "llviewershadermgr.h" #include "llvoavatar.h" #include "llvocache.h" +#include "llmaterialmgr.h" const S32 MIN_QUIET_FRAMES_COALESCE = 30; const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; @@ -919,6 +920,12 @@ LLFace* LLVOVolume::addFace(S32 f) { const LLTextureEntry* te = getTE(f); LLViewerTexture* imagep = getTEImage(f); + if (te->getMaterialParams() != NULL) + { + LLViewerTexture* normalp = getTENormalMap(f); + LLViewerTexture* specularp = getTESpecularMap(f); + return mDrawable->addFace(te, imagep, normalp, specularp); + } return mDrawable->addFace(te, imagep); } @@ -1404,6 +1411,11 @@ void LLVOVolume::regenFaces() facep->setTEOffset(i); facep->setTexture(getTEImage(i)); + if (facep->getTextureEntry()->getMaterialParams() != NULL) + { + facep->setNormalMap(getTENormalMap(i)); + facep->setSpecularMap(getTESpecularMap(i)); + } facep->setViewerObject(this); // If the face had media on it, this will have broken the link between the LLViewerMediaTexture and the face. @@ -1979,13 +1991,33 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + if (!pMaterialID.isNull()) + { + LL_INFOS("Materials") << "Oh god it's a material! " << pMaterialID.asString() << LL_ENDL; + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + if (res) + { + LL_INFOS("Materials") << "We have a material!" << LL_ENDL; + LLMaterialPtr pMatParam = LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID); + setTEMaterialParams(te, pMatParam); + gPipeline.markTextured(mDrawable); + mFaceMappingChanged = TRUE; + } + return res; + } + return 0; +} + +S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) +{ + S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); if (res) { gPipeline.markTextured(mDrawable); mFaceMappingChanged = TRUE; } - return res; + + return res; } S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) @@ -4050,6 +4082,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerTexture* tex = facep->getTexture(); U8 index = facep->getTextureIndex(); + + LLMaterialID matid = facep->getTextureEntry()->getMaterialID(); bool batchable = false; @@ -4106,12 +4140,30 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 offset = facep->getIndicesStart(); U32 count = facep->getIndicesCount(); LLPointer draw_info = new LLDrawInfo(start,end,count,offset, tex, - facep->getVertexBuffer(), fullbright, bump); + facep->getVertexBuffer(), fullbright, bump); draw_info->mGroup = group; draw_info->mVSize = facep->getVirtualSize(); draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; + + if (!facep->getTextureEntry()->getMaterialID().isNull() && facep->getTextureEntry()->getMaterialParams() != NULL) + { + // We have a material. Update our draw info accordingly. + //draw_info->mMaterialID = facep->getTextureEntry()->getMaterialID(); + LLVector4 specColor; + specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.0 / 255); + specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.0 / 255); + specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.0 / 255); + specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.0 / 255); + draw_info->mSpecColor = specColor; + draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.0 / 255); + draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.0 / 255); + draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode(); + draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTextureIndex()); + draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTextureIndex()); + } + if (type == LLRenderPass::PASS_ALPHA) { //for alpha sorting facep->setDrawInfo(draw_info); @@ -4267,7 +4319,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } if (vobj->isMesh() && - (vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded() || !gMeshRepo.meshRezEnabled())) + ((vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded()) || !gMeshRepo.meshRezEnabled())) { continue; } @@ -5134,7 +5186,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } } - else if (te->getBumpmap()) + else if (te->getBumpmap() || te->getMaterialParams() != NULL) { //register in deferred bump pass registerFace(group, facep, LLRenderPass::PASS_BUMP); } @@ -5169,7 +5221,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } else { - if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap()) + if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && (te->getBumpmap() || te->getMaterialParams() != NULL)) { //non-shiny or fullbright deferred bump registerFace(group, facep, LLRenderPass::PASS_BUMP); } diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index ff6dca9737..c996fac6f2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,6 +187,7 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); + /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); /*virtual*/ S32 setTEScaleT(const U8 te, const F32 t); -- cgit v1.3 From f189ba4a3d927fe0ecfb83b36b60a47c88525fdd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Apr 2013 16:56:59 -0500 Subject: NORSPEC-71 Lots more UI hookups Written with and Reviewed By Graham --- indra/llprimitive/llmaterial.h | 6 +- indra/llprimitive/lltextureentry.cpp | 4 + indra/newview/llpanelface.cpp | 97 +++++++++++++++------- indra/newview/llviewerobject.cpp | 16 +++- indra/newview/llvovolume.cpp | 60 ++++++------- .../skins/default/xui/en/panel_tools_texture.xml | 3 + 6 files changed, 119 insertions(+), 67 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index fd35045e45..dc3484309c 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -32,8 +32,10 @@ #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" +#include "llpointer.h" +#include "llrefcount.h" -class LLMaterial +class LLMaterial : public LLRefCount { public: @@ -115,6 +117,6 @@ protected: U8 mAlphaMaskCutoff; }; -typedef boost::shared_ptr LLMaterialPtr; +typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 23b15b697c..691216e035 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -535,6 +535,10 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } return TEM_CHANGE_TEXTURE; } return TEM_CHANGE_NONE; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 4dad363eb8..43001e7d2c 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -301,10 +301,17 @@ void LLPanelFace::sendBump() if (bumpiness < BUMPY_TEXTURE) { LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(LLUUID()); + //texture_ctrl->setImageAssetID(LLUUID()); + texture_ctrl->clear(); + LLSD dummy_data; + onSelectMaterialTexture(dummy_data); } U8 bump = (U8) bumpiness & TEM_BUMP_MASK; LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); + + //refresh material state (in case this change impacts material params) + LLSD dummy_data; + onCommitMaterialTexture(dummy_data); } void LLPanelFace::sendTexGen() @@ -592,7 +599,7 @@ void LLPanelFace::sendTextureInfo() } void LLPanelFace::getState() -{ +{ //set state of UI to match state of texture entry(ies) (calls setEnabled, setValue, etc, but NOT setVisible) LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); if( objectp @@ -760,24 +767,45 @@ void LLPanelFace::getState() getChildView("button align")->setEnabled(editable); } + // Specular map + struct alpha_get : public LLSelectedTEGetFunctor { - // Default alpha mode to None if texture has no alpha, or Alpha Blending if present - // Will be overridden later if a material is present for this face - S32 default_alpha = ALPHAMODE_NONE; - if (mIsAlpha) + U8 get(LLViewerObject* object, S32 te_index) { - default_alpha = ALPHAMODE_BLEND; + U8 ret = 1; + + LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); + + if (mat) + { + ret = mat->getDiffuseAlphaMode(); + } + + return ret; } + } alpha_get_func; + + U8 alpha_mode = 1; + LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &alpha_get_func, alpha_mode); + + { LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - combobox_alphamode->selectNthItem(default_alpha); + if (!mIsAlpha) + { + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + } + + combobox_alphamode->selectNthItem(alpha_mode); } else { llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } + updateAlphaControls(getChild("combobox alphamode"),this); } @@ -1432,7 +1460,8 @@ void LLPanelFace::getState() // Materials { mMaterialID = LLMaterialID::null; - mMaterial.reset(); + mMaterial = NULL; + struct f1 : public LLSelectedTEGetFunctor { LLMaterialID get(LLViewerObject* object, S32 te_index) @@ -1515,10 +1544,13 @@ void LLPanelFace::refresh() } void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) -{ +{ //laying out UI based on material parameters (calls setVisible on various components) LL_DEBUGS("Materials") << "Loaded material " << material_id.asString() << material->asLLSD() << LL_ENDL; - mMaterial = material; - + + //make a local copy of the material for editing + // (prevents local edits from overwriting client state on shared materials) + mMaterial = new LLMaterial(*material); + // Alpha LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); @@ -1586,30 +1618,21 @@ void LLPanelFace::updateMaterial() U32 alpha_mode = comboAlphaMode->getCurrentIndex(); U32 bumpiness = comboBumpiness->getCurrentIndex(); U32 shininess = comboShininess->getCurrentIndex(); - if ((mIsAlpha && (alpha_mode != ALPHAMODE_BLEND)) + if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) || (bumpiness == BUMPY_TEXTURE) || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. + bool new_material = false; if (!mMaterial) { + new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); - //set defaults according to UI spec - mMaterial->setSpecularLightColor(LLColor4U::white); - mMaterial->setSpecularLightExponent((U8) (255*0.2f)); - mMaterial->setEnvironmentIntensity(0); - mMaterial->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - mMaterial->setAlphaMaskCutoff(0); - } - else - { - mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); - mMaterial->setSpecularLightExponent((U8)(255*getChild("glossiness")->getValue().asReal())); - mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); - mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); } + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + if (bumpiness == BUMPY_TEXTURE) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; @@ -1637,6 +1660,20 @@ void LLPanelFace::updateMaterial() mMaterial->setSpecularRepeat(getChild("shinyScaleU")->getValue().asReal(), getChild("shinyScaleV")->getValue().asReal()); mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + + //override shininess to 0.2f if this is a new material + if (new_material) + { + mMaterial->setSpecularLightColor(LLColor4U::white); + mMaterial->setSpecularLightExponent((U8) (0.2f*255.f)); + mMaterial->setEnvironmentIntensity(0); + } + else + { + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent((U8)(255*getChild("glossiness")->getValue().asReal())); + mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); + } } else { @@ -1645,6 +1682,8 @@ void LLPanelFace::updateMaterial() mMaterial->setSpecularOffset(0.0f,0.0f); mMaterial->setSpecularRepeat(1.0f,1.0f); mMaterial->setSpecularRotation(0.0f); + mMaterial->setSpecularLightExponent(0); + mMaterial->setEnvironmentIntensity(0); } LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; @@ -1656,7 +1695,7 @@ void LLPanelFace::updateMaterial() if (mMaterial || !mMaterialID.isNull()) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; - mMaterial.reset(); + mMaterial = NULL; mMaterialID = LLMaterialID::null; // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f1b54e0e01..286604e367 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4045,7 +4045,7 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) const LLUUID& image_id = getTE(te)->getID(); mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - if (getTE(te)->getMaterialParams() != NULL) + if (getTE(te)->getMaterialParams().notNull()) { const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE); @@ -4094,7 +4094,12 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost h // uuid == LLUUID::null) { retval = TEM_CHANGE_TEXTURE; - getTE(te)->getMaterialParams()->setNormalID(uuid); + LLTextureEntry* tep = getTE(te); + LLMaterial* mat = tep->getMaterialParams(); + if (mat) + { + mat->setNormalID(uuid); + } mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE, 0, 0, host); setChanged(TEXTURE); if (mDrawable.notNull()) @@ -4112,7 +4117,12 @@ S32 LLViewerObject::setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost // uuid == LLUUID::null) { retval = TEM_CHANGE_TEXTURE; - getTE(te)->getMaterialParams()->setSpecularID(uuid); + LLTextureEntry* tep = getTE(te); + LLMaterial* mat = tep->getMaterialParams(); + if (mat) + { + mat->setSpecularID(uuid); + } mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); setChanged(TEXTURE); if (mDrawable.notNull()) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8a1f00aa0e..43c57602f5 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -892,7 +892,7 @@ LLFace* LLVOVolume::addFace(S32 f) { const LLTextureEntry* te = getTE(f); LLViewerTexture* imagep = getTEImage(f); - if (te->getMaterialParams() != NULL) + if (te->getMaterialParams().notNull()) { LLViewerTexture* normalp = getTENormalMap(f); LLViewerTexture* specularp = getTESpecularMap(f); @@ -1395,7 +1395,7 @@ void LLVOVolume::regenFaces() facep->setTEOffset(i); facep->setTexture(getTEImage(i)); - if (facep->getTextureEntry()->getMaterialParams() != NULL) + if (facep->getTextureEntry()->getMaterialParams().notNull()) { facep->setNormalMap(getTENormalMap(i)); facep->setSpecularMap(getTESpecularMap(i)); @@ -1986,19 +1986,15 @@ void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, co S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - if (!pMaterialID.isNull()) + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + if (res) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); - if (res) - { - LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); - gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; - } - return res; + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); + gPipeline.markTextured(mDrawable); + mFaceMappingChanged = TRUE; } - return 0; + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) @@ -4135,26 +4131,24 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; - if (!facep->getTextureEntry()->getMaterialID().isNull()) + if (facep->getTextureEntry()->getMaterialParams().notNull()) + { + // We have a material. Update our draw info accordingly. + draw_info->mMaterialID = matid; + LLVector4 specColor; + specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.f / 255.f); + specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.f / 255.f); + specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.f / 255.f); + specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.f / 255.f); + draw_info->mSpecColor = specColor; + draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.f / 255.f); + draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.f / 255.f); + draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode(); + draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTEOffset()); + draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTEOffset()); + } + else { - - if (facep->getTextureEntry()->getMaterialParams() != NULL) - { - // We have a material. Update our draw info accordingly. - draw_info->mMaterialID = matid; - LLVector4 specColor; - specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.f / 255.f); - specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.f / 255.f); - specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.f / 255.f); - specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.f / 255.f); - draw_info->mSpecColor = specColor; - draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.f / 255.f); - draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.f / 255.f); - draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode(); - draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTEOffset()); - draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTEOffset()); - } - } else { U8 shiny = facep->getTextureEntry()->getShiny(); float alpha[4] = { @@ -4662,7 +4656,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (gPipeline.canUseWindLightShadersOnObjects() && LLPipeline::sRenderBump) { - if (LLPipeline::sRenderDeferred && te->getMaterialParams() != NULL) + if (LLPipeline::sRenderDeferred && te->getMaterialParams().notNull()) { LLMaterial* mat = te->getMaterialParams().get(); if (mat->getNormalID().notNull()) diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index e156b3e07c..5e2caa28a9 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -209,9 +209,11 @@ layout="topleft" top_pad="4" left_delta="0" + increment="1" name="maskcutoff" width="80" /> Date: Thu, 9 May 2013 15:41:07 -0700 Subject: NORSPEC-164 fix TE copy ctor and operator= to include material pointer in addition to ID --- indra/llprimitive/lltextureentry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 691216e035..53816266eb 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -85,7 +85,7 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; mMaterialID = rhs.mMaterialID; - + mMaterial = rhs.mMaterial; if (rhs.mMediaEntry != NULL) { // Make a copy mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry); @@ -107,6 +107,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; mMaterialID = rhs.mMaterialID; + mMaterial = rhs.mMaterial; if (mMediaEntry != NULL) { delete mMediaEntry; } -- cgit v1.3 From 269b8b7de53f368791fbffde8a6f8d47d9cbbcdc Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 10 May 2013 10:50:50 +0200 Subject: NORSPEC-102 Rapid materials updates are not smooth to viewer which is editing the object --- indra/llprimitive/llprimitive.cpp | 18 +++++++++++++++ indra/llprimitive/llprimitive.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 20 +++++++++++++++- indra/llprimitive/lltextureentry.h | 6 +++++ indra/newview/llpanelface.cpp | 44 ++++++++++++------------------------ indra/newview/llpanelface.h | 3 +-- indra/newview/llselectmgr.cpp | 6 +++++ indra/newview/llviewerobject.cpp | 20 +++++++++++++--- indra/newview/llviewerobject.h | 2 +- 9 files changed, 84 insertions(+), 37 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0578f0b192..3f57dbe26d 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -373,6 +373,24 @@ S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMateri return mTextureList.setMaterialParams(index, pMaterialParams); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6a9c5e9639..dc21af2649 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -332,6 +332,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -357,6 +358,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 691216e035..6e5d27bb94 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -61,18 +61,24 @@ LLTextureEntry* LLTextureEntry::newTextureEntry() //=============================================================== LLTextureEntry::LLTextureEntry() : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(LLUUID::null,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -532,8 +538,16 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { + if (mSelected) + { + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; + } + + mMaterialUpdatePending = false; mMaterialID = pMaterialID; if (mMaterialID.isNull()) { @@ -548,6 +562,10 @@ S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { if (mMaterial != pMaterialParams) { + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..f867f45819 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -99,6 +99,10 @@ public: virtual LLTextureEntry* newCopy() const; void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index a0f2fb702e..032d066c48 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -262,7 +262,6 @@ BOOL LLPanelFace::postBuild() LLPanelFace::LLPanelFace() : LLPanel(), - mMaterialID(LLMaterialID::null), mMaterial(LLMaterialPtr()), mIsAlpha(false) { @@ -1575,26 +1574,23 @@ void LLPanelFace::getState() // Materials { - mMaterialID = LLMaterialID::null; - mMaterial = NULL; - - struct f1 : public LLSelectedTEGetFunctor + struct f1 : public LLSelectedTEGetFunctor { - LLMaterialID get(LLViewerObject* object, S32 te_index) + LLMaterialPtr get(LLViewerObject* object, S32 te_index) { LLMaterialID material_id; - return object->getTE(te_index)->getMaterialID(); + return object->getTE(te_index)->getMaterialParams(); } } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterialID ); - llinfos << "Material ID returned: '" - << mMaterialID.asString() << "', isNull? " - << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; - if (!mMaterialID.isNull() && editable) + + LLMaterialPtr material; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material ); + + mMaterial = (material) ? new LLMaterial(*material) : NULL; + if (mMaterial && editable) { - llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; - LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); + onMaterialLoaded(mMaterial); } } @@ -1659,15 +1655,8 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) +void LLPanelFace::onMaterialLoaded(const LLMaterialPtr material) { //laying out UI based on material parameters (calls setVisible on various components) - LL_DEBUGS("Materials") << "Loaded material " << material_id.asString() << material->asLLSD() << LL_ENDL; - - //make a local copy of the material for editing - // (prevents local edits from overwriting client state on shared materials) - mMaterial = new LLMaterial(*material); - mMaterialID = material_id; - // Alpha LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); @@ -1780,13 +1769,9 @@ void LLPanelFace::updateMaterial() || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. - bool new_material = false; - if (!mMaterial) - { - new_material = true; - mMaterial = LLMaterialPtr(new LLMaterial()); - } + bool new_material = !mMaterial; + mMaterial = LLMaterialPtr(new LLMaterial()); mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); @@ -1866,11 +1851,10 @@ void LLPanelFace::updateMaterial() else { // The user has specified settings that don't need a material. - if (mMaterial || !mMaterialID.isNull()) + if (mMaterial) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; mMaterial = NULL; - mMaterialID = LLMaterialID::null; // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 2138319365..470da10bee 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -84,7 +84,7 @@ protected: void onCommitAlpha(const LLSD& data); void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material); + void onMaterialLoaded(const LLMaterialPtr material); void updateMaterial(); static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); @@ -115,7 +115,6 @@ private: */ void onTextureSelectionChanged(LLInventoryItem* itemp); - LLMaterialID mMaterialID; LLMaterialPtr mMaterial; bool mIsAlpha; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 5089570319..8ef56af379 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -816,6 +816,7 @@ void LLSelectMgr::addAsFamily(std::vector& objects, BOOL add_to if (objectp->getNumTEs() > 0) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else { @@ -873,10 +874,12 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab else if (face == SELECT_ALL_TES) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else if (0 <= face && face < SELECT_MAX_TES) { nodep->selectTE(face, TRUE); + objectp->setTESelected(face, true); } else { @@ -1096,6 +1099,7 @@ LLObjectSelectionHandle LLSelectMgr::selectHighlightedObjects() // flag this object as selected objectp->setSelected(TRUE); + objectp->setAllTESelected(true); mSelectedObjects->mSelectType = getSelectTypeForObject(objectp); @@ -1321,6 +1325,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) if (nodep->isTESelected(te)) { nodep->selectTE(te, FALSE); + objectp->setTESelected(te, false); } else { @@ -5751,6 +5756,7 @@ void LLSelectNode::selectTE(S32 te_index, BOOL selected) { return; } + S32 mask = 0x1 << te_index; if(selected) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 286604e367..4a112d3ab3 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -531,6 +531,17 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) } } +void LLViewerObject::setSelected(BOOL sel) +{ + mUserSelected = sel; + resetRot(); + + if (!sel) + { + setAllTESelected(false); + } +} + // This method returns true if the object is over land owned by the // agent. bool LLViewerObject::isReturnable() @@ -4354,10 +4365,13 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) + if (retval) { - gPipeline.markTextured(mDrawable); + setChanged(TEXTURE); + if (mDrawable.notNull() && retval) + { + gPipeline.markTextured(mDrawable); + } } } return retval; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index a6569740bb..05b2e0361b 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -200,7 +200,7 @@ public: LLViewerRegion* getRegion() const { return mRegionp; } BOOL isSelected() const { return mUserSelected; } - virtual void setSelected(BOOL sel) { mUserSelected = sel; resetRot();} + virtual void setSelected(BOOL sel); const LLUUID &getID() const { return mID; } U32 getLocalID() const { return mLocalID; } -- cgit v1.3 From f356d7eb9fd730f5f6f5a29fb0706e20876ad3bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 11 May 2013 19:58:56 -0700 Subject: Fix many issues with selection misapplication and rendering not matching applied materials --- indra/llprimitive/llprimitive.cpp | 18 ++ indra/llprimitive/llprimitive.h | 2 + indra/llprimitive/lltextureentry.cpp | 25 +- indra/llprimitive/lltextureentry.h | 6 + indra/newview/llmaterialmgr.cpp | 61 ++++ indra/newview/llmaterialmgr.h | 24 ++ indra/newview/llpanelface.cpp | 318 +++++++++------------ indra/newview/llpanelface.h | 2 +- indra/newview/llselectmgr.cpp | 5 + indra/newview/llviewerobject.cpp | 78 ++--- indra/newview/llviewerobject.h | 2 +- indra/newview/llvovolume.cpp | 47 +-- indra/newview/llvovolume.h | 2 +- .../skins/default/xui/en/panel_tools_texture.xml | 8 +- 14 files changed, 338 insertions(+), 260 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index e5905c3a3b..2fa77177f5 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -374,6 +374,24 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index b1f8090416..47a21beaaf 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -361,6 +361,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -386,6 +387,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 53816266eb..1d581da897 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -67,12 +67,16 @@ LLTextureEntry::LLTextureEntry() LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -536,23 +540,20 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + } - return TEM_CHANGE_NONE; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mMaterial != pMaterialParams) - { - mMaterial = pMaterialParams; - return TEM_CHANGE_TEXTURE; - } - return TEM_CHANGE_NONE; + + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; } void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..5cc76cfe82 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -100,6 +100,10 @@ public: void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } + // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); S32 setColor(const LLColor4 &color); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..e41a46038f 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -216,6 +216,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -300,6 +345,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 39be5cab29..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,8 +44,12 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; + const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); + typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); @@ -78,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9c40ff06cc..837b8687e8 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1562,36 +1562,108 @@ void LLPanelFace::getState() // Materials { - mMaterialID = LLMaterialID::null; - mMaterial = NULL; + struct f1 : public LLSelectedTEGetFunctor + { + LLMaterialPtr get(LLViewerObject* object, S32 te_index) + { + return object->getTE(te_index)->getMaterialParams(); + } + } func; - struct f1 : public LLSelectedTEGetFunctor + LLMaterialPtr material; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterial ); + + if (mMaterial && editable) { - LLMaterialID get(LLViewerObject* object, S32 te_index) + LL_DEBUGS("Materials: OnMatererialsLoaded:") << material->asLLSD() << LL_ENDL; + + // Alpha + LLCtrlSelectionInterface* combobox_alphamode = + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - LLMaterialID material_id; + combobox_alphamode->selectNthItem(mMaterial->getDiffuseAlphaMode()); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; + } + getChild("maskcutoff")->setValue(mMaterial->getAlphaMaskCutoff()); + updateAlphaControls(getChild("combobox alphamode"),this); + + LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; + bool identical_texgen = true; + bool identical_planar_texgen = false; - return object->getTE(te_index)->getMaterialID(); + struct f44 : public LLSelectedTEGetFunctor + { + LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) + { + return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); + } + } func; + identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); + identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); + + // Shiny (specular) + F32 offset_x, offset_y, repeat_x, repeat_y, rot; + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); + texture_ctrl->setImageAssetID(material->getSpecularID()); + LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->getSpecularID().isNull()) + { + mMaterial->getSpecularOffset(offset_x,offset_y); + mMaterial->getSpecularRepeat(repeat_x,repeat_y); + + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = mMaterial->getSpecularRotation(); + getChild("shinyScaleU")->setValue(repeat_x); + getChild("shinyScaleV")->setValue(repeat_y); + getChild("shinyRot")->setValue(rot*RAD_TO_DEG); + getChild("shinyOffsetU")->setValue(offset_x); + getChild("shinyOffsetV")->setValue(offset_y); + getChild("glossiness")->setValue(mMaterial->getSpecularLightExponent()); + getChild("environment")->setValue(mMaterial->getEnvironmentIntensity()); } - } func; + updateShinyControls(combobox_shininess,this, !mMaterial->getSpecularID().isNull(), true); - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) + // Assert desired colorswatch color to match material AFTER updateShinyControls + // to avoid getting overwritten with the default on some UI state changes. + // + if (!material->getSpecularID().isNull()) { - mMaterialID = node->getObject()->getTE(selected_te)->getMaterialID(); + getChild("shinycolorswatch")->setOriginal(mMaterial->getSpecularLightColor()); + getChild("shinycolorswatch")->set(mMaterial->getSpecularLightColor(),TRUE); } - } - llinfos << "Material ID returned: '" << mMaterialID.asString() << "', isNull? " << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; + // Bumpy (normal) + texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(mMaterial->getNormalID()); + LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!mMaterial->getNormalID().isNull()) + { + mMaterial->getNormalOffset(offset_x,offset_y); + mMaterial->getNormalRepeat(repeat_x,repeat_y); - if (!mMaterialID.isNull() && editable) - { - llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; - LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = material->getNormalRotation(); + getChild("bumpyScaleU")->setValue(repeat_x); + getChild("bumpyScaleV")->setValue(repeat_y); + getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); + getChild("bumpyOffsetU")->setValue(offset_x); + getChild("bumpyOffsetV")->setValue(offset_y); + } + updateBumpyControls(combobox_bumpiness,this, !mMaterial->getNormalID().isNull(), true); } } @@ -1658,104 +1730,6 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) -{ //laying out UI based on material parameters (calls setVisible on various components) - LL_DEBUGS("Materials") << "material id " << material_id.asString() << " data " << material->asLLSD() << LL_ENDL; - - //make a local copy of the material for editing - // (prevents local edits from overwriting client state on shared materials) - mMaterial = new LLMaterial(*material); - mMaterialID = material_id; - - // Alpha - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); - if (combobox_alphamode) - { - combobox_alphamode->selectNthItem(material->getDiffuseAlphaMode()); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; - } - getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("combobox alphamode"),this); - - LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; - bool identical_texgen = true; - bool identical_planar_texgen = false; - - struct f44 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); - identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - - // Shiny (specular) - F32 offset_x, offset_y, repeat_x, repeat_y, rot; - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("combobox shininess"); - if (!material->getSpecularID().isNull()) - { - material->getSpecularOffset(offset_x,offset_y); - material->getSpecularRepeat(repeat_x,repeat_y); - - if (identical_planar_texgen) - { - repeat_x *= 2.0f; - repeat_y *= 2.0f; - } - - rot = material->getSpecularRotation(); - getChild("shinyScaleU")->setValue(repeat_x); - getChild("shinyScaleV")->setValue(repeat_y); - getChild("shinyRot")->setValue(rot*RAD_TO_DEG); - getChild("shinyOffsetU")->setValue(offset_x); - getChild("shinyOffsetV")->setValue(offset_y); - getChild("glossiness")->setValue(material->getSpecularLightExponent()); - getChild("environment")->setValue(material->getEnvironmentIntensity()); - } - updateShinyControls(combobox_shininess,this, !material->getSpecularID().isNull(), true); - - // Assert desired colorswatch color to match material AFTER updateShinyControls - // to avoid getting overwritten with the default on some UI state changes. - // - if (!material->getSpecularID().isNull()) - { - getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); - getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); - } - - // Bumpy (normal) - texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); - if (!material->getNormalID().isNull()) - { - material->getNormalOffset(offset_x,offset_y); - material->getNormalRepeat(repeat_x,repeat_y); - - if (identical_planar_texgen) - { - repeat_x *= 2.0f; - repeat_y *= 2.0f; - } - - rot = material->getNormalRotation(); - getChild("bumpyScaleU")->setValue(repeat_x); - getChild("bumpyScaleV")->setValue(repeat_y); - getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); - getChild("bumpyOffsetU")->setValue(offset_x); - getChild("bumpyOffsetV")->setValue(offset_y); - } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); -} - void LLPanelFace::updateMaterial() { // assign current state of UI to material definition for submit to sim LL_DEBUGS("Materials") << "Entered." << LL_ENDL; @@ -1781,53 +1755,38 @@ void LLPanelFace::updateMaterial() bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) + bool is_default_blend_mode = mIsAlpha ? (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + : (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE); + + if ( !is_default_blend_mode || (bumpiness == BUMPY_TEXTURE) || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. bool new_material = false; - if (!mMaterial) + + // Create new or clone material + // + if (mMaterial.isNull()) { - new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); + new_material = true; } - - LLMaterialPtr material_to_set = mMaterial; - - bool subselection = false; - - // If we're editing a single face and not the entire material for an object, - // we need to clone the material so that our changes to the material's settings - // don't automatically propagate to the non-selected faces - // NORSPEC-92 - // - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) + else { - if (node->getTESelectMask() != TE_SELECT_MASK_ALL) - { - llinfos << "Cloning material to apply to subselection." << llendl; - material_to_set = new LLMaterial(mMaterial->asLLSD()); - subselection = true; - } - else - { - llinfos << "Apply material change to whole selection." << llendl; - } + mMaterial = LLMaterialPtr(new LLMaterial(mMaterial->asLLSD())); } - llassert(!material_to_set.isNull()); + llassert_always(mMaterial); - material_to_set->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - material_to_set->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(norm_map_id); + mMaterial->setNormalID(norm_map_id); F32 bumpy_scale_u = getChild("bumpyScaleU")->getValue().asReal(); F32 bumpy_scale_v = getChild("bumpyScaleV")->getValue().asReal(); @@ -1838,18 +1797,18 @@ void LLPanelFace::updateMaterial() bumpy_scale_v *= 0.5f; } - material_to_set->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), + mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), getChild("bumpyOffsetV")->getValue().asReal()); - material_to_set->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); - material_to_set->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); + mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); } else { LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(LLUUID()); - material_to_set->setNormalOffset(0.0f,0.0f); - material_to_set->setNormalRepeat(1.0f,1.0f); - material_to_set->setNormalRotation(0.0f); + mMaterial->setNormalID(LLUUID()); + mMaterial->setNormalOffset(0.0f,0.0f); + mMaterial->setNormalRepeat(1.0f,1.0f); + mMaterial->setNormalRotation(0.0f); } LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); @@ -1857,8 +1816,8 @@ void LLPanelFace::updateMaterial() if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(spec_map_id); - material_to_set->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), + mMaterial->setSpecularID(spec_map_id); + mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), getChild("shinyOffsetV")->getValue().asReal()); F32 shiny_scale_u = getChild("shinyScaleU")->getValue().asReal(); @@ -1870,55 +1829,42 @@ void LLPanelFace::updateMaterial() shiny_scale_v *= 0.5f; } - material_to_set->setSpecularRepeat(shiny_scale_u, shiny_scale_v); - material_to_set->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setSpecularRepeat(shiny_scale_u, shiny_scale_v); + mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); //override shininess to 0.2f if this is a new material if (!new_material) { - material_to_set->setSpecularLightColor(getChild("shinycolorswatch")->get()); - material_to_set->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); - material_to_set->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); + mMaterial->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); } } else { LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(LLUUID()); - material_to_set->setSpecularOffset(0.0f,0.0f); - material_to_set->setSpecularRepeat(1.0f,1.0f); - material_to_set->setSpecularRotation(0.0f); - material_to_set->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); - material_to_set->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - material_to_set->setEnvironmentIntensity(0); + mMaterial->setSpecularID(LLUUID()); + mMaterial->setSpecularOffset(0.0f,0.0f); + mMaterial->setSpecularRepeat(1.0f,1.0f); + mMaterial->setSpecularRotation(0.0f); + mMaterial->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); + mMaterial->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + mMaterial->setEnvironmentIntensity(0); } - LL_DEBUGS("Materials") << "Updating material: " << material_to_set->asLLSD() << LL_ENDL; - + LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; - if (node && node->getObject() && node->getObject()->permModify() && subselection) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) - { - LLMaterialMgr::getInstance()->put(node->getObject()->getID(),selected_te,*material_to_set); - node->getObject()->getTE(selected_te)->setMaterialParams(material_to_set); - node->getObject()->sendTEUpdate(); - } - } - else - { - LLSelectMgr::getInstance()->selectionSetMaterial( material_to_set ); - } + LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); } else { // The user has specified settings that don't need a material. - if (mMaterial || !mMaterialID.isNull()) + //if (mMaterial || !mMaterialID.isNull()) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; mMaterial = NULL; mMaterialID = LLMaterialID::null; + // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 7fbeef223b..401dbd1e94 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -87,7 +87,7 @@ protected: void onCommitAlpha(const LLSD& data); void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material); + void updateMaterial(); static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 5a65623b91..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -815,6 +815,7 @@ void LLSelectMgr::addAsFamily(std::vector& objects, BOOL add_to if (objectp->getNumTEs() > 0) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else { @@ -872,10 +873,12 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab else if (face == SELECT_ALL_TES) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else if (0 <= face && face < SELECT_MAX_TES) { nodep->selectTE(face, TRUE); + objectp->setTESelected(face, true); } else { @@ -1095,6 +1098,7 @@ LLObjectSelectionHandle LLSelectMgr::selectHighlightedObjects() // flag this object as selected objectp->setSelected(TRUE); + objectp->setAllTESelected(true); mSelectedObjects->mSelectType = getSelectTypeForObject(objectp); @@ -1318,6 +1322,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) if (nodep->isTESelected(te)) { nodep->selectTE(te, FALSE); + objectp->setTESelected(te, false); } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 2965d968a3..548fb236d6 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -530,6 +530,17 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) } } +void LLViewerObject::setSelected(BOOL sel) +{ + mUserSelected = sel; + resetRot(); + + if (!sel) + { + setAllTESelected(false); + } +} + // This method returns true if the object is over land owned by the // agent. bool LLViewerObject::isReturnable() @@ -4116,14 +4127,8 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, LLViewerTexture *image) { mat->setNormalID(uuid); } - - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } } - mTENormalMaps[te] = image; + changeTENormalMap(te,image); return retval; } @@ -4144,14 +4149,9 @@ S32 LLViewerObject::setTESpecularMapCore(const U8 te, LLViewerTexture *image) if (mat) { mat->setSpecularID(uuid); - } - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); } } - mTESpecularMaps[te] = image; + changeTESpecularMap(te, image); return retval; } @@ -4171,6 +4171,11 @@ void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTENormalMaps[index] = new_image ; } @@ -4180,6 +4185,11 @@ void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTESpecularMaps[index] = new_image ; } @@ -4375,18 +4385,21 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; } - else if (pMaterialID != tep->getMaterialID()) + //else if (pMaterialID != tep->getMaterialID()) { LL_DEBUGS("Material") << "Changing texture entry for te " << (S32)te << ", object " << mID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); } return retval; } @@ -4398,22 +4411,23 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri if (!tep) { llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; + return 0; } - else if (pMaterialParams != tep->getMaterialParams()) + + retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); + LL_DEBUGS("Material") << "Changing material params for te " << (S32)te + << ", object " << mID + << " (" << retval << ")" + << LL_ENDL; + setTENormalMap(te, tep->getMaterialParams()->getNormalID()); + setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + + setChanged(TEXTURE); + if (mDrawable.notNull()) { - retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("Material") << "Changing material params for te " << (S32)te - << ", object " << mID - << " (" << retval << ")" - << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } + return retval; } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ba23ad97b0..bcb74a8d1f 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -211,7 +211,7 @@ public: LLViewerRegion* getRegion() const { return mRegionp; } BOOL isSelected() const { return mUserSelected; } - virtual void setSelected(BOOL sel) { mUserSelected = sel; resetRot();} + virtual void setSelected(BOOL sel); const LLUUID &getID() const { return mID; } U32 getLocalID() const { return mLocalID; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 941892a597..df014513ad 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,33 +1973,34 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) +void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; - for (U8 i = 0; i < getNumTEs(); i++) + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; + LLTextureEntry* texture_entry = getTE(te); + if (texture_entry && (texture_entry->getMaterialID().isNull() || (texture_entry->getMaterialID() == pMaterialID))) { - if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) - { - setTEMaterialParams(i, pMaterialParams); - } + setTEMaterialParams(te, pMaterialParams); } } S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); - LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res - << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) - << LL_ENDL; - if (res) - { - LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); - gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; - } - return res; + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res + << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) + << LL_ENDL; + + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); } + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; +} S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { @@ -2007,13 +2008,13 @@ S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialPa LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; - if (res) + setChanged(TEXTURE); + if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; } - - return res; + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index d1bfefdc70..a5f933c319 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,7 +187,7 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); + void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index b6fc48212a..a5425062ec 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -644,8 +644,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="bumpyRot" width="265" /> @@ -707,8 +707,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="shinyRot" width="265" /> -- cgit v1.3 From 5ac9d9cb05f22099bea8c9312f5e0b234430022a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 12 May 2013 16:10:31 +0200 Subject: LLMaterialMgr::get() doesn't handle a callback request for LLMaterialID::null --- indra/llprimitive/lltextureentry.cpp | 7 ++----- indra/newview/llmaterialmgr.cpp | 1 + indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 23 +++++++++++++---------- indra/newview/llvovolume.cpp | 18 ++++++++++-------- 5 files changed, 27 insertions(+), 24 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 8365c9d7b6..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -550,12 +550,9 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) mMaterialUpdatePending = false; mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; } - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + return TEM_CHANGE_NONE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..f217ff160e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -116,6 +116,7 @@ void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) LLMaterialMgr::LLMaterialMgr() { + mMaterials.insert(std::pair(LLMaterialID::null, LLMaterialPtr(NULL))); gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..e80ad6976e 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face,LLMaterialID::null); + object->setTEMaterialParams(face, NULL); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index d56df96c44..4e233d479a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,15 +4393,18 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - } - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) + if (retval) { - gPipeline.markTextured(mDrawable); + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } } + } return retval; } @@ -4420,11 +4423,11 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri << ", object " << mID << " (" << retval << ")" << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + setTENormalMap(te, (pMaterialParams) ? pMaterialParams->getNormalID() : LLUUID::null); + setTESpecularMap(te, (pMaterialParams) ? pMaterialParams->getSpecularID() : LLUUID::null); setChanged(TEXTURE); - if (mDrawable.notNull()) + if (mDrawable.notNull()) { gPipeline.markTextured(mDrawable); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 734ac2afc8..8e811527eb 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,21 +1991,23 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); - setChanged(TEXTURE); - if (!mDrawable.isNull()) + if (res) { - gPipeline.markTextured(mDrawable); + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); + } + mFaceMappingChanged = TRUE; } - mFaceMappingChanged = TRUE; - return TEM_CHANGE_TEXTURE; + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res + LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterialParams) ? pMaterialParams->asLLSD() : LLSD("null")) << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; setChanged(TEXTURE); -- cgit v1.3 From d9e8ee7cfd323872145c23e4032989f9b7770f55 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 13 May 2013 13:02:53 -0700 Subject: NORSPEC-178 NORSPEC-179 NORSPEC-180 made enable/disable handling more consistent and increased max range on repeats per meter --- indra/llprimitive/lltextureentry.cpp | 21 +- indra/newview/llmaterialmgr.cpp | 61 ++++++ indra/newview/llmaterialmgr.h | 22 ++ indra/newview/llpanelface.cpp | 241 +++++++++------------ indra/newview/llpanelface.h | 52 +++-- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 17 +- indra/newview/llvovolume.cpp | 8 +- .../skins/default/xui/en/panel_tools_texture.xml | 2 +- 9 files changed, 244 insertions(+), 182 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..ca57f1edbd 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,28 +539,21 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) + if (mMaterialID != pMaterialID) { - if (mSelected) + mMaterialID = pMaterialID; + + } + if (mMaterialID.isNull()) { - mMaterialUpdatePending = true; - mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + setMaterialParams(NULL); } - - mMaterialUpdatePending = false; - mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } - return TEM_CHANGE_NONE; -} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mSelected) - { - mMaterialUpdatePending = true; - } + mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index f217ff160e..59e5d05736 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,6 +217,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -301,6 +346,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index a6a7a5d1d7..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,9 +44,11 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -80,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index d108a260bc..b2f76e2114 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -596,6 +596,11 @@ void LLPanelFace::sendTextureInfo() } void LLPanelFace::getState() +{ + updateUI(); +} + +void LLPanelFace::updateUI() { //set state of UI to match state of texture entry(ies) (calls setEnabled, setValue, etc, but NOT setVisible) LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); @@ -636,12 +641,12 @@ void LLPanelFace::getState() } getChildView("combobox mattype")->setEnabled(editable); - onCommitMaterialsMedia(NULL, this); + updateVisibility(); bool identical; - bool identical_diffuse; - bool identical_norm; - bool identical_spec; + bool identical_diffuse; + bool identical_norm; + bool identical_spec; LLTextureCtrl* texture_ctrl = getChild("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); @@ -798,7 +803,7 @@ void LLPanelFace::getState() llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } - updateAlphaControls(getChild("combobox alphamode"),this); + updateAlphaControls(); } if(texture_ctrl && !texture_ctrl->isPickerShown()) @@ -1587,7 +1592,7 @@ void LLPanelFace::getState() llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("combobox alphamode"),this); + updateAlphaControls(); LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; bool identical_texgen = true; @@ -1607,7 +1612,7 @@ void LLPanelFace::getState() F32 offset_x, offset_y, repeat_x, repeat_y, rot; LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->getSpecularID().isNull()) { material->getSpecularOffset(offset_x,offset_y); @@ -1628,7 +1633,7 @@ void LLPanelFace::getState() getChild("glossiness")->setValue(material->getSpecularLightExponent()); getChild("environment")->setValue(material->getEnvironmentIntensity()); } - updateShinyControls(combobox_shininess,this, !material->getSpecularID().isNull(), true); + updateShinyControls(!material->getSpecularID().isNull(), true); // Assert desired colorswatch color to match material AFTER updateShinyControls // to avoid getting overwritten with the default on some UI state changes. @@ -1642,7 +1647,7 @@ void LLPanelFace::getState() // Bumpy (normal) texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!material->getNormalID().isNull()) { material->getNormalOffset(offset_x,offset_y); @@ -1661,7 +1666,7 @@ void LLPanelFace::getState() getChild("bumpyOffsetU")->setValue(offset_x); getChild("bumpyOffsetV")->setValue(offset_y); } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); + updateBumpyControls(!material->getNormalID().isNull(), true); } } @@ -1702,12 +1707,11 @@ void LLPanelFace::getState() getChildView("tex gen")->setEnabled(FALSE); getChildView("label shininess")->setEnabled(FALSE); getChildView("label bumpiness")->setEnabled(FALSE); - getChildView("button align")->setEnabled(FALSE); //getChildView("has media")->setEnabled(FALSE); //getChildView("media info set")->setEnabled(FALSE); - onCommitMaterialsMedia(NULL,this); + updateVisibility(); // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); @@ -1904,10 +1908,16 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); - LLComboBox* combo_mattype = self->getChild("combobox mattype"); - LLComboBox* combo_shininess = self->getChild("combobox shininess"); - LLComboBox* combo_bumpiness = self->getChild("combobox bumpiness"); + self->updateUI(); +} + +// static +void LLPanelFace::updateVisibility() +{ + LLComboBox* combo_matmedia = getChild("combobox matmedia"); + LLComboBox* combo_mattype = getChild("combobox mattype"); + LLComboBox* combo_shininess = getChild("combobox shininess"); + LLComboBox* combo_bumpiness = getChild("combobox bumpiness"); if (!combo_mattype || !combo_matmedia || !combo_shininess || !combo_bumpiness) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; @@ -1919,93 +1929,66 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) bool show_texture = (show_media || ((material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); - self->getChildView("combobox mattype")->setVisible(!show_media); - self->getChildView("rptctrl")->setVisible(true); + getChildView("combobox mattype")->setVisible(!show_media); + getChildView("rptctrl")->setVisible(true); // Media controls - self->getChildView("media_info")->setVisible(show_media); - self->getChildView("add_media")->setVisible(show_media); - self->getChildView("delete_media")->setVisible(show_media); - self->getChildView("button align")->setVisible(show_media); + getChildView("media_info")->setVisible(show_media); + getChildView("add_media")->setVisible(show_media); + getChildView("delete_media")->setVisible(show_media); + getChildView("button align")->setVisible(show_media); // Diffuse texture controls - self->getChildView("texture control")->setVisible(show_texture && !show_media); - self->getChildView("label alphamode")->setVisible(show_texture && !show_media); - self->getChildView("combobox alphamode")->setVisible(show_texture && !show_media); - self->getChildView("label maskcutoff")->setVisible(false); - self->getChildView("maskcutoff")->setVisible(false); + getChildView("texture control")->setVisible(show_texture && !show_media); + getChildView("label alphamode")->setVisible(show_texture && !show_media); + getChildView("combobox alphamode")->setVisible(show_texture && !show_media); + getChildView("label maskcutoff")->setVisible(false); + getChildView("maskcutoff")->setVisible(false); if (show_texture && !show_media) { - updateAlphaControls(ctrl, userdata); + updateAlphaControls(); } - self->getChildView("TexScaleU")->setVisible(show_texture); - self->getChildView("TexScaleV")->setVisible(show_texture); - self->getChildView("TexRot")->setVisible(show_texture); - self->getChildView("TexOffsetU")->setVisible(show_texture); - self->getChildView("TexOffsetV")->setVisible(show_texture); + getChildView("TexScaleU")->setVisible(show_texture); + getChildView("TexScaleV")->setVisible(show_texture); + getChildView("TexRot")->setVisible(show_texture); + getChildView("TexOffsetU")->setVisible(show_texture); + getChildView("TexOffsetV")->setVisible(show_texture); // Specular map controls - self->getChildView("shinytexture control")->setVisible(show_shininess); - self->getChildView("combobox shininess")->setVisible(show_shininess); - self->getChildView("label shininess")->setVisible(show_shininess); - self->getChildView("label glossiness")->setVisible(false); - self->getChildView("glossiness")->setVisible(false); - self->getChildView("label environment")->setVisible(false); - self->getChildView("environment")->setVisible(false); - self->getChildView("label shinycolor")->setVisible(false); - self->getChildView("shinycolorswatch")->setVisible(false); + getChildView("shinytexture control")->setVisible(show_shininess); + getChildView("combobox shininess")->setVisible(show_shininess); + getChildView("label shininess")->setVisible(show_shininess); + getChildView("label glossiness")->setVisible(false); + getChildView("glossiness")->setVisible(false); + getChildView("label environment")->setVisible(false); + getChildView("environment")->setVisible(false); + getChildView("label shinycolor")->setVisible(false); + getChildView("shinycolorswatch")->setVisible(false); if (show_shininess) { - updateShinyControls(ctrl, userdata); + updateShinyControls(); } - self->getChildView("shinyScaleU")->setVisible(show_shininess); - self->getChildView("shinyScaleV")->setVisible(show_shininess); - self->getChildView("shinyRot")->setVisible(show_shininess); - self->getChildView("shinyOffsetU")->setVisible(show_shininess); - self->getChildView("shinyOffsetV")->setVisible(show_shininess); + getChildView("shinyScaleU")->setVisible(show_shininess); + getChildView("shinyScaleV")->setVisible(show_shininess); + getChildView("shinyRot")->setVisible(show_shininess); + getChildView("shinyOffsetU")->setVisible(show_shininess); + getChildView("shinyOffsetV")->setVisible(show_shininess); // Normal map controls if (show_bumpiness) { - updateBumpyControls(ctrl, userdata); + updateBumpyControls(); } - self->getChildView("bumpytexture control")->setVisible(show_bumpiness); - self->getChildView("combobox bumpiness")->setVisible(show_bumpiness); - self->getChildView("label bumpiness")->setVisible(show_bumpiness); - self->getChildView("bumpyScaleU")->setVisible(show_bumpiness); - self->getChildView("bumpyScaleV")->setVisible(show_bumpiness); - self->getChildView("bumpyRot")->setVisible(show_bumpiness); - self->getChildView("bumpyOffsetU")->setVisible(show_bumpiness); - self->getChildView("bumpyOffsetV")->setVisible(show_bumpiness); - - // Enable texture scale/rotation/offset parameters if there's one - // present to set for - bool texParmsEnable = show_texture || - (show_shininess && (combo_shininess->getCurrentIndex() == SHINY_TEXTURE)) || - (show_bumpiness && (combo_bumpiness->getCurrentIndex() == BUMPY_TEXTURE)); - self->getChildView("tex gen")->setEnabled(texParmsEnable); - self->getChildView("combobox texgen")->setEnabled(texParmsEnable); - self->getChildView("rptctrl")->setEnabled(texParmsEnable); - self->getChildView("TexScaleU")->setEnabled(texParmsEnable); - self->getChildView("TexScaleV")->setEnabled(texParmsEnable); - self->getChildView("TexRot")->setEnabled(texParmsEnable); - self->getChildView("TexOffsetU")->setEnabled(texParmsEnable); - self->getChildView("TexOffsetV")->setEnabled(texParmsEnable); - self->getChildView("shinyScaleU")->setEnabled(texParmsEnable); - self->getChildView("shinyScaleV")->setEnabled(texParmsEnable); - self->getChildView("shinyRot")->setEnabled(texParmsEnable); - self->getChildView("shinyOffsetU")->setEnabled(texParmsEnable); - self->getChildView("shinyOffsetV")->setEnabled(texParmsEnable); - self->getChildView("bumpyScaleU")->setEnabled(texParmsEnable); - self->getChildView("bumpyScaleV")->setEnabled(texParmsEnable); - self->getChildView("bumpyRot")->setEnabled(texParmsEnable); - self->getChildView("bumpyOffsetU")->setEnabled(texParmsEnable); - self->getChildView("bumpyOffsetV")->setEnabled(texParmsEnable); - self->getChildView("checkbox planar align")->setEnabled(texParmsEnable); - - // Needed to handle transitions to/from media mode - // NORSPEC-84 - updateAlphaControls(ctrl,userdata); + getChildView("bumpytexture control")->setVisible(show_bumpiness); + getChildView("combobox bumpiness")->setVisible(show_bumpiness); + getChildView("label bumpiness")->setVisible(show_bumpiness); + getChildView("bumpyScaleU")->setVisible(show_bumpiness); + getChildView("bumpyScaleV")->setVisible(show_bumpiness); + getChildView("bumpyRot")->setVisible(show_bumpiness); + getChildView("bumpyOffsetU")->setVisible(show_bumpiness); + getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + + } // static @@ -2016,7 +1999,7 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) // like the texture ctrls for diffuse/norm/spec so that they are correct // when switching modes // - self->getState(); + self->updateUI(); } // static @@ -2024,10 +2007,7 @@ void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->sendBump(); - - LLComboBox* combo_bumpy = self->getChild("combobox bumpiness"); - - updateBumpyControls(combo_bumpy,self, false, true); + self->updateBumpyControls(false, true); self->updateMaterial(); } @@ -2039,13 +2019,12 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) } // static -void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_shiny_combobox) +void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_shiny_combobox) { - LLPanelFace* self = (LLPanelFace*) userdata; - LLTextureCtrl* texture_ctrl = self->getChild("shinytexture control"); + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); LLUUID shiny_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; - LLComboBox* comboShiny = self->getChild("combobox shininess"); + LLComboBox* comboShiny = getChild("combobox shininess"); if(mess_with_shiny_combobox) { @@ -2061,15 +2040,15 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_se // NORSPEC-94: Set default specular color to white // - LLColorSwatchCtrl* mShinyColorSwatch = self->getChild("shinycolorswatch"); + LLColorSwatchCtrl* mShinyColorSwatch = getChild("shinycolorswatch"); if(mShinyColorSwatch) { LL_DEBUGS("Materials") << "Resetting specular color to default of white" << LL_ENDL; mShinyColorSwatch->setOriginal(LLColor4::white); mShinyColorSwatch->set(LLColor4::white, TRUE); } - self->getChild("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - self->getChild("environment")->setValue(0); + getChild("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + getChild("environment")->setValue(0); } comboShiny->setSimple(USE_TEXTURE); } @@ -2084,30 +2063,29 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_se } } - LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); - LLComboBox* combo_mattype = self->getChild("combobox mattype"); + LLComboBox* combo_matmedia = getChild("combobox matmedia"); + LLComboBox* combo_mattype = getChild("combobox mattype"); U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = combo_mattype->getCurrentIndex(); bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture - self->getChildView("label glossiness")->setVisible(show_shinyctrls); - self->getChildView("glossiness")->setVisible(show_shinyctrls); - self->getChildView("label environment")->setVisible(show_shinyctrls); - self->getChildView("environment")->setVisible(show_shinyctrls); - self->getChildView("label shinycolor")->setVisible(show_shinyctrls); - self->getChildView("shinycolorswatch")->setVisible(show_shinyctrls); + getChildView("label glossiness")->setVisible(show_shinyctrls); + getChildView("glossiness")->setVisible(show_shinyctrls); + getChildView("label environment")->setVisible(show_shinyctrls); + getChildView("environment")->setVisible(show_shinyctrls); + getChildView("label shinycolor")->setVisible(show_shinyctrls); + getChildView("shinycolorswatch")->setVisible(show_shinyctrls); } // static -void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_combobox) +void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_combobox) { - LLPanelFace* self = (LLPanelFace*) userdata; - LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; - LLComboBox* comboBumpy = self->getChild("combobox bumpiness"); + LLComboBox* comboBumpy = getChild("combobox bumpiness"); if (!comboBumpy) { return; @@ -2115,7 +2093,7 @@ void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_se if (mess_with_combobox) { - LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; @@ -2144,19 +2122,17 @@ void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->sendShiny(); - LLComboBox* combo_shiny = self->getChild("combobox shininess"); // Need 'true' here to insure that the 'Use Texture' choice is removed // when we select something other than a spec texture // - updateShinyControls(combo_shiny,self, false, true); + self->updateShinyControls(false, true); self->updateMaterial(); } // static -void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::updateAlphaControls() { - LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* comboAlphaMode = self->getChild("combobox alphamode"); + LLComboBox* comboAlphaMode = getChild("combobox alphamode"); if (!comboAlphaMode) { return; @@ -2164,14 +2140,14 @@ void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) U32 alpha_value = comboAlphaMode->getCurrentIndex(); bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking - LLComboBox* combobox_matmedia = self->getChild("combobox matmedia"); + LLComboBox* combobox_matmedia = getChild("combobox matmedia"); U32 mat_media = MATMEDIA_MATERIAL; if (combobox_matmedia) { mat_media = combobox_matmedia->getCurrentIndex(); } - LLComboBox* combobox_mattype = self->getChild("combobox mattype"); + LLComboBox* combobox_mattype = getChild("combobox mattype"); U32 mat_type = MATTYPE_DIFFUSE; if (combobox_mattype) { @@ -2181,15 +2157,15 @@ void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) show_alphactrls = show_alphactrls && (mat_media == MATMEDIA_MATERIAL); show_alphactrls = show_alphactrls && (mat_type == MATTYPE_DIFFUSE); - self->getChildView("label maskcutoff")->setVisible(show_alphactrls); - self->getChildView("maskcutoff")->setVisible(show_alphactrls); + getChildView("label maskcutoff")->setVisible(show_alphactrls); + getChildView("maskcutoff")->setVisible(show_alphactrls); } // static void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - updateAlphaControls(ctrl,userdata); + self->updateAlphaControls(); self->updateMaterial(); } @@ -2245,46 +2221,40 @@ void LLPanelFace::onSelectTexture(const LLSD& data) void LLPanelFace::onCommitSpecularTexture( const LLSD& data ) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, true, true); + updateShinyControls(true, true); updateMaterial(); } void LLPanelFace::onCommitNormalTexture( const LLSD& data ) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy, this, true, true); + updateBumpyControls(true, true); updateMaterial(); } void LLPanelFace::onCancelSpecularTexture(const LLSD& data) { updateMaterial(); - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, false, true); + updateShinyControls(false, true); } void LLPanelFace::onCancelNormalTexture(const LLSD& data) { updateMaterial(); - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy,this, false, true); + updateBumpyControls(false, true); } void LLPanelFace::onSelectSpecularTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; updateMaterial(); - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, true, true); + updateShinyControls(true, true); } void LLPanelFace::onSelectNormalTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy,this, true, true); + updateBumpyControls(true, true); updateMaterial(); } @@ -2310,9 +2280,10 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) gFocusMgr.setKeyboardFocus( NULL ); - //F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get(); - F32 repeats_per_meter = (F32)self->getChild("rptctrl")->getValue().asReal();//self->mCtrlRepeatsPerMeter->get(); + LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); F32 obj_scale_s = 1.0f; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 4e97295b84..88f32e45f8 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -67,7 +67,7 @@ protected: void sendTexGen(); // applies and sends bump map void sendShiny(); // applies and sends shininess void sendFullbright(); // applies and sends full bright - void sendGlow(); + void sendGlow(); void sendMedia(); // this function is to return TRUE if the drag should succeed. @@ -88,29 +88,49 @@ protected: void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void updateMaterial(); - - static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); - static void onCommitBump( LLUICtrl* ctrl, void* userdata); + // Make UI reflect state of currently selected material (refresh) + // and UI mode (e.g. editing normal map v diffuse map) + // + void updateUI(); + + // Callback funcs for individual controls + // + static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); + static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); - static void updateShinyControls( LLUICtrl* ctrl, void* userdata, bool is_setting_texture = false, bool mess_with_combobox = false); - static void updateBumpyControls( LLUICtrl* ctrl, void* userdata, bool is_setting_texture = false, bool mess_with_combobox = false); - static void onCommitShiny( LLUICtrl* ctrl, void* userdata); - static void updateAlphaControls( LLUICtrl* ctrl, void* userdata); + static void onCommitShiny( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); - static void onCommitGlow( LLUICtrl* ctrl, void *userdata); - static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); - + static void onCommitGlow( LLUICtrl* ctrl, void *userdata); + static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); static void onClickAutoFix(void*); - static F32 valueGlow(LLViewerObject* object, S32 face); + + static F32 valueGlow(LLViewerObject* object, S32 face); private: + // Update visibility of controls to match current UI mode + // (e.g. materials vs media editing) + // + // Do NOT call updateUI from within this function. + // + void updateVisibility(); + + // Make material reflect current state of UI (apply edit) + // + void updateMaterial(); + + // Update vis and enabling of specific subsets of controls based on material params + // (e.g. hide the spec controls if no spec texture is applied) + // + void updateShinyControls(bool is_setting_texture = false, bool mess_with_combobox = false); + void updateBumpyControls(bool is_setting_texture = false, bool mess_with_combobox = false); + void updateAlphaControls(); + /* * Checks whether the selected texture from the LLFloaterTexturePicker can be applied to the currently selected object. * If agent selects texture which is not allowed to be applied for the currently selected object, diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index e80ad6976e..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialParams(face, NULL); + object->setTEMaterialID(face,LLMaterialID::null); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4e233d479a..f8bc6ef4d3 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,18 +4393,15 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - if (retval) + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) { - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } - } return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8e811527eb..1021615255 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,17 +1991,15 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - if (res) - { - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); setChanged(TEXTURE); if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); } mFaceMappingChanged = TRUE; - } - return res; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index a5425062ec..5be3ca9d9f 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -567,7 +567,7 @@ layout="topleft" label_width="205" left="10" - max_val="10" + max_val="100" min_val="0.1" name="rptctrl" width="265" /> -- cgit v1.3 From ad09e2111cd980117ae937b79155ef6c24e4567c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 14 May 2013 21:14:46 +0200 Subject: NORSPEC-102 & Co Reloaded --- indra/llprimitive/lltextureentry.cpp | 21 ++++++++----- indra/newview/llmaterialmgr.cpp | 61 ------------------------------------ indra/newview/llmaterialmgr.h | 22 ------------- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 17 +++++----- indra/newview/llvovolume.cpp | 8 +++-- 6 files changed, 30 insertions(+), 101 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index ca57f1edbd..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,21 +539,28 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { - mMaterialID = pMaterialID; - - } - if (mMaterialID.isNull()) + if (mSelected) { - setMaterialParams(NULL); + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; } + + mMaterialUpdatePending = false; + mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } + return TEM_CHANGE_NONE; +} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 59e5d05736..f217ff160e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,51 +217,6 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } -boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) -{ - boost::signals2::connection connection; - - material_map_t::const_iterator itMaterial = mMaterials.find(material_id); - if (itMaterial != mMaterials.end()) - { - LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; - get_callback_te_t signal; - signal.connect(cb); - signal(material_id, itMaterial->second, te); - connection = boost::signals2::connection(); - } - else - { - if (!isGetPending(region_id, material_id)) - { - get_queue_t::iterator itQueue = mGetQueue.find(region_id); - if (mGetQueue.end() == itQueue) - { - LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); - itQueue = ret.first; - } - LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; - itQueue->second.insert(material_id); - markGetPending(region_id, material_id); - } - - TEMaterialPair te_mat_pair; - te_mat_pair.te = te; - te_mat_pair.materialID = material_id; - - get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); - if (itCallback == mGetTECallbacks.end()) - { - std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); - itCallback = ret.first; - } - connection = itCallback->second->connect(cb); - } - - return connection; -} - bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -346,22 +301,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } - TEMaterialPair te_mat_pair; - te_mat_pair.materialID = material_id; - - U32 i = 0; - while (i < LLTEContents::MAX_TES) - { - te_mat_pair.te = i++; - get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); - if (itCallbackTE != mGetTECallbacks.end()) - { - (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); - delete itCallbackTE->second; - mGetTECallbacks.erase(itCallbackTE); - } - } - return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 922b16f1cf..a6a7a5d1d7 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,11 +44,9 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; - typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); - boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -82,26 +80,6 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; - // struct for TE-specific material ID query - struct TEMaterialPair - { - U32 te; - LLMaterialID materialID; - }; - - // needed for std::map compliance only - // - friend inline bool operator<( - const struct LLMaterialMgr::TEMaterialPair& lhs, - const struct LLMaterialMgr::TEMaterialPair& rhs) - { - return (lhs.materialID < rhs.materialID) ? TRUE : - (lhs.te < rhs.te) ? TRUE : FALSE; - } - - typedef std::map get_callback_te_map_t; - get_callback_te_map_t mGetTECallbacks; - typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..e80ad6976e 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face,LLMaterialID::null); + object->setTEMaterialParams(face, NULL); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f8bc6ef4d3..4e233d479a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,15 +4393,18 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - } - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) + if (retval) { - gPipeline.markTextured(mDrawable); + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } } + } return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 1021615255..8e811527eb 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,15 +1991,17 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + if (res) + { + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); setChanged(TEXTURE); if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); } mFaceMappingChanged = TRUE; - return TEM_CHANGE_TEXTURE; + } + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) -- cgit v1.3