From 1e1707d532560583744bb877adfed11864f2db31 Mon Sep 17 00:00:00 2001 From: Kadah_Coba Date: Mon, 14 Oct 2019 20:35:44 -0700 Subject: [Project Copy/Paste] Texture support --- indra/newview/llpanelface.cpp | 482 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 478 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 5e6a44c09d..29994253c4 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -38,6 +38,7 @@ #include "llfontgl.h" // project includes +#include "llagent.h" // gAgent #include "llagentdata.h" #include "llbutton.h" #include "llcheckboxctrl.h" @@ -45,10 +46,14 @@ #include "llcombobox.h" #include "lldrawpoolbump.h" #include "llface.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" // gInventory #include "lllineeditor.h" #include "llmaterialmgr.h" #include "llmediaentry.h" +#include "llmenubutton.h" #include "llnotificationsutil.h" +#include "llpanelobject.h" // LLPanelObject::canCopyTexture #include "llradiogroup.h" #include "llresmgr.h" #include "llselectmgr.h" @@ -295,7 +300,18 @@ BOOL LLPanelFace::postBuild() { mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this); } - + + mBtnCopyFaces = getChild("copy_face_btn"); + if(mBtnCopyFaces) + { + BtnCopyFaces->setCommitCallback(boost::bind(&LLPanelFace::onCopyFaces, this)); + } + mBtnPasteFaces = getChild("paste_face_btn"); + if (mBtnPasteFaces) + { + mBtnPasteFaces->setCommitCallback(boost::bind(&LLPanelFace::onPasteFaces, this)); + } + mBtnPasteMenu = getChild("paste_face_gear_btn"); clearCtrls(); @@ -304,9 +320,21 @@ BOOL LLPanelFace::postBuild() LLPanelFace::LLPanelFace() : LLPanel(), - mIsAlpha(false) + mIsAlpha(false), + mPasteColor(TRUE), + mPasteAlpha(TRUE), + mPasteGlow(TRUE), + mPasteDiffuse(TRUE), + mPasteNormal(TRUE), + mPasteSpecular(TRUE), + mPasteMapping(TRUE), + mPasteMedia(TRUE) { USE_TEXTURE = LLTrans::getString("use_texture"); + + mEnableCallbackRegistrar.add("BuildFace.PasteCheckItem", boost::bind(&LLPanelFace::pasteCheckMenuItem, this, _2)); + mCommitCallbackRegistrar.add("BuildFace.PasteDoToSelected", boost::bind(&LLPanelFace::pasteDoMenuItem, this, _2)); + mEnableCallbackRegistrar.add("BuildFace.PasteEnable", boost::bind(&LLPanelFace::pasteEnabletMenuItem, this, _2)); } @@ -1407,6 +1435,12 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } } + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + BOOL single_volume = (selected_count == 1); + mBtnCopyFaces->setEnabled(editable && single_volume); + mBtnPasteFaces->setEnabled(editable && (mClipboard.size() > 0)); + mBtnPasteMenu->setEnabled(editable); + // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); calcp->setVar(LLCalc::TEX_U_SCALE, childGetValue("TexScaleU").asReal()); @@ -1602,8 +1636,6 @@ void LLPanelFace::updateVisibility() getChildView("bumpyRot")->setVisible(show_bumpiness); getChildView("bumpyOffsetU")->setVisible(show_bumpiness); getChildView("bumpyOffsetV")->setVisible(show_bumpiness); - - } // static @@ -2681,3 +2713,445 @@ void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identic } max_diff_repeats_func; identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_diff_repeats_func, repeats ); } + +static LLSD texture_clipboard; + +void LLPanelFace::onCopyFaces() +{ + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + if( !objectp || !node + || objectp->getPCode() != LL_PCODE_VOLUME + || !objectp->permModify() + || objectp->isPermanentEnforced() + || selected_count > 1) + { + return; + } + + mClipboard.clear(); + + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + LLTextureEntry* tep = objectp->getTE(te); + if (tep) + { + LLSD te_data; + + te_data["te"] = tep->asLLSD(); + te_data["te"]["glow"] = tep->getGlow(); + te_data["te"]["shiny"] = tep->getShiny(); + + if (te_data["te"].has("imageid")) + { + LLUUID id = te_data["te"]["imageid"].asUUID(); + if (id.isNull() || !LLPanelObject::canCopyTexture(id)) + { + te_data["te"].erase("imageid"); + te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); + } + // else + // { + // te_data["te"]["imageid"] = canCopyTexture(te_data["te"]["imageid"].asUUID()); + // } + } + + LLMaterialPtr material_ptr = tep->getMaterialParams(); + if (!material_ptr.isNull()) + { + LLSD mat_data; + + mat_data["NormMap"] = material_ptr->getNormalID(); + mat_data["SpecMap"] = material_ptr->getSpecularID(); + + mat_data["NormRepX"] = material_ptr->getNormalRepeatX(); + mat_data["NormRepY"] = material_ptr->getNormalRepeatY(); + mat_data["NormOffX"] = material_ptr->getNormalOffsetX(); + mat_data["NormOffY"] = material_ptr->getNormalOffsetY(); + mat_data["NormRot"] = material_ptr->getNormalRotation(); + + mat_data["SpecRepX"] = material_ptr->getSpecularRepeatX(); + mat_data["SpecRepY"] = material_ptr->getSpecularRepeatY(); + mat_data["SpecOffX"] = material_ptr->getSpecularOffsetX(); + mat_data["SpecOffY"] = material_ptr->getSpecularOffsetY(); + mat_data["SpecRot"] = material_ptr->getSpecularRotation(); + + mat_data["SpecColor"] = material_ptr->getSpecularLightColor().getValue(); + mat_data["SpecExp"] = material_ptr->getSpecularLightExponent(); + mat_data["EnvIntensity"] = material_ptr->getEnvironmentIntensity(); + mat_data["AlphaMaskCutoff"] = material_ptr->getAlphaMaskCutoff(); + mat_data["DiffuseAlphaMode"] = material_ptr->getDiffuseAlphaMode(); + + // Replace no-copy textures, destination texture will get used instead if available + if (mat_data.has("NormMap")) + { + LLUUID id = te_data["material"]["NormMap"].asUUID(); + if (id.notNull() && !LLPanelObject::canCopyTexture(id)) + { + mat_data["NormMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); + mat_data["NormMapNoCopy"] = true; + } + + } + if (mat_data.has("SpecMap")) + { + LLUUID id = te_data["material"]["SpecMap"].asUUID(); + if (id.notNull() && !LLPanelObject::canCopyTexture(id)) + { + mat_data["SpecMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); + mat_data["SpecMapNoCopy"] = true; + } + + } + + te_data["material"] = mat_data; + } + + //*TODO: Media + + mClipboard.append(te_data); + } + } + } +} + +void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) +{ + LLSD te_data; + if (mClipboard.size() == 1) + { + te_data = *(mClipboard.beginArray()); + } + else if (mClipboard[te]) + { + te_data = mClipboard[te]; + } + else + { + return; + } + + LLTextureEntry* tep = objectp->getTE(te); + if (tep) + { + if (te_data.has("te")) + { + // Texture + if (mPasteDiffuse) + { + // Replace no-copy texture with target's + if (!te_data["te"].has("imageid")) + { + te_data["te"]["imageid"] = tep->getID(); + } + const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); + LLViewerInventoryItem* item = gInventory.getItem(imageid); + if (item) + { + if (te == -1) // all faces + { + LLToolDragAndDrop::dropTextureAllFaces(objectp, + item, + LLToolDragAndDrop::SOURCE_AGENT, + LLUUID::null); + } + else // one face + { + LLToolDragAndDrop::dropTextureOneFace(objectp, + te, + item, + LLToolDragAndDrop::SOURCE_AGENT, + LLUUID::null); + } + } + else // not an inventory item + { + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + objectp->setTEImage(U8(te), image); + } + } + + // Color / Alpha + if ((mPasteColor || mPasteAlpha) && te_data.has("colors")) + { + LLColor4 color = objectp->getTE(te)->getColor(); + + LLColor4 clip_color; + clip_color.setValue(te_data["colors"]); + + // Color + if (mPasteColor) + { + color.mV[VRED] = clip_color.mV[VRED]; + color.mV[VGREEN] = clip_color.mV[VGREEN]; + color.mV[VBLUE] = clip_color.mV[VBLUE]; + } + + // Alpha + if (mPasteAlpha) + { + color.mV[VALPHA] = clip_color.mV[VALPHA]; + } + + objectp->setTEColor(te, color); + } + + // Glow + if (mPasteGlow && te_data.has("glow")) + { + objectp->setTEGlow(te, (F32)te_data["glow"].asReal()); + } + + // Texture map + if (mPasteMapping) + { + if (te_data.has("scales") && te_data.has("scalet")) + { + objectp->setTEScale(te, (F32)te_data["scales"].asReal(), (F32)te_data["scalet"].asReal()); + } + if (te_data.has("offsets") && te_data.has("offsett")) + { + objectp->setTEOffset(te, (F32)te_data["offsets"].asReal(), (F32)te_data["offsett"].asReal()); + } + if (te_data.has("imagerot")) + { + objectp->setTERotation(te, (F32)te_data["imagerot"].asReal()); + } + } + + // Media + if (mPasteMedia && te_data.has("media")) + { + //*TODO + } + else + { + // // Keep media flags on destination unchanged + // // Media is handled later + // if (te_data["te"].has("media_flags")) + // { + // te_data["te"]["media_flags"] = tep->getMediaTexGen(); + // } + } + } + + if (te_data.has("material")) + { + LLUUID object_id = objectp->getID(); + + LLSelectedTEMaterial::setAlphaMaskCutoff(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); + + if (mPasteNormal) + { + // Replace placeholders with target's + if (te_data["material"].has("NormMapNoCopy")) + { + LLMaterialPtr material = tep->getMaterialParams(); + if (material.notNull()) + { + LLUUID id = material->getNormalID(); + if (id.notNull()) + { + te_data["material"]["NormMap"] = id; + } + } + } + LLSelectedTEMaterial::setNormalID(this, te_data["material"]["NormMap"].asUUID(), te, object_id); + LLSelectedTEMaterial::setNormalRepeatX(this, (F32)te_data["material"]["NormRepX"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalRepeatY(this, (F32)te_data["material"]["NormRepY"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalOffsetX(this, (F32)te_data["material"]["NormOffX"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalOffsetY(this, (F32)te_data["material"]["NormOffY"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalRotation(this, (F32)te_data["material"]["NormRot"].asReal(), te, object_id); + } + + if (mPasteSpecular) + { + // Replace placeholders with target's + if (te_data["material"].has("SpecMapNoCopy")) + { + LLMaterialPtr material = tep->getMaterialParams(); + if (material.notNull()) + { + LLUUID id = material->getSpecularID(); + if (id.notNull()) + { + te_data["material"]["SpecMap"] = id; + } + } + } + LLSelectedTEMaterial::setSpecularID(this, te_data["material"]["SpecMap"].asUUID(), te, object_id); + LLSelectedTEMaterial::setSpecularRepeatX(this, (F32)te_data["material"]["SpecRepX"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularRepeatY(this, (F32)te_data["material"]["SpecRepY"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularOffsetX(this, (F32)te_data["material"]["SpecOffX"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularOffsetY(this, (F32)te_data["material"]["SpecOffY"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularRotation(this, (F32)te_data["material"]["SpecRot"].asReal(), te, object_id); + LLColor4 spec_color(te_data["material"]["SpecColor"]); + LLSelectedTEMaterial::setSpecularLightColor(this, spec_color, te); + LLSelectedTEMaterial::setSpecularLightExponent(this, (U8)te_data["material"]["SpecExp"].asInteger(), te, object_id); + LLSelectedTEMaterial::setEnvironmentIntensity(this, (U8)te_data["material"]["EnvIntensity"].asInteger(), te), object_id; + LLSelectedTEMaterial::setDiffuseAlphaMode(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); + if (te_data.has("shiny")) + { + objectp->setTEShiny(te, (U8)te_data["shiny"].asInteger()); + } + } + } + } +} + +struct LLPanelFacePasteTexFunctor : public LLSelectedTEFunctor +{ + LLPanelFacePasteTexFunctor(LLPanelFace* panel) : + mPanelFace(panel){} + + virtual bool apply(LLViewerObject* objectp, S32 te) + { + mPanelFace->pasteFace(objectp, te); + return true; + } +private: + LLPanelFace *mPanelFace; +}; + +void LLPanelFace::onPasteFaces() +{ + LLPanelFacePasteTexFunctor paste_func(this); + LLSelectMgr::getInstance()->getSelection()->applyToTEs(&paste_func); + + LLPanelFaceSendFunctor sendfunc; + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc); +} + +bool LLPanelFace::pasteCheckMenuItem(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + if ("Color" == command) + { + return mPasteColor; + } + if ("Transparency" == command) + { + return mPasteAlpha; + } + if ("Glow" == command) + { + return mPasteGlow; + } + if ("Diffuse" == command) + { + return mPasteDiffuse; + } + if ("Normal" == command) + { + return mPasteNormal; + } + if ("Specular" == command) + { + return mPasteSpecular; + } + if ("Mapping" == command) + { + return mPasteMapping; + } + if ("Media" == command) + { + return mPasteMedia; + } + + return false; +} + +void LLPanelFace::pasteDoMenuItem(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + if ("Color" == command) + { + mPasteColor = !mPasteColor; + } + if ("Transparency" == command) + { + mPasteAlpha = !mPasteAlpha; + } + if ("Glow" == command) + { + mPasteGlow = !mPasteGlow; + } + if ("Diffuse" == command) + { + mPasteDiffuse = !mPasteDiffuse; + } + if ("Normal" == command) + { + mPasteNormal = !mPasteNormal; + } + if ("Specular" == command) + { + mPasteSpecular = !mPasteSpecular; + } + if ("Mapping" == command) + { + mPasteMapping = !mPasteMapping; + } + if ("Media" == command) + { + mPasteMedia = !mPasteMedia; + } +} + +bool LLPanelFace::pasteEnabletMenuItem(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + // Keep at least one option enabled + S32 num_enabled = mPasteColor + + mPasteAlpha + + mPasteGlow + + mPasteDiffuse + + mPasteNormal + + mPasteSpecular + + mPasteMapping + + mPasteMedia; + if ( num_enabled == 1) + { + if ("Color" == command && mPasteColor) + { + return false; + } + if ("Transparency" == command && mPasteAlpha) + { + return false; + } + if ("Glow" == command && mPasteGlow) + { + return false; + } + if ("Diffuse" == command && mPasteDiffuse) + { + return false; + } + if ("Normal" == command && mPasteNormal) + { + return false; + } + if ("Specular" == command && mPasteSpecular) + { + return false; + } + if ("Mapping" == command && mPasteMapping) + { + return false; + } + if ("Media" == command && mPasteMedia) + { + return false; + } + } + + return true; +} -- cgit v1.2.3 From be7d81626e512019b46a8ed301b4a1825e129aa5 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Tue, 15 Oct 2019 19:20:36 +0300 Subject: Buildfix (typo) --- indra/newview/llpanelface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 1e0b1874f7..fb99ffef09 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -307,7 +307,7 @@ BOOL LLPanelFace::postBuild() mBtnCopyFaces = getChild("copy_face_btn"); if(mBtnCopyFaces) { - BtnCopyFaces->setCommitCallback(boost::bind(&LLPanelFace::onCopyFaces, this)); + mBtnCopyFaces->setCommitCallback(boost::bind(&LLPanelFace::onCopyFaces, this)); } mBtnPasteFaces = getChild("paste_face_btn"); if (mBtnPasteFaces) -- cgit v1.2.3 From a09f68a809d8537041ea91c0768ba503f107f26b Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Thu, 17 Oct 2019 02:46:09 +0300 Subject: Buildfix (typo) --- indra/newview/llpanelface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index fb99ffef09..8f8f1b4763 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -3161,7 +3161,7 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) LLColor4 spec_color(te_data["material"]["SpecColor"]); LLSelectedTEMaterial::setSpecularLightColor(this, spec_color, te); LLSelectedTEMaterial::setSpecularLightExponent(this, (U8)te_data["material"]["SpecExp"].asInteger(), te, object_id); - LLSelectedTEMaterial::setEnvironmentIntensity(this, (U8)te_data["material"]["EnvIntensity"].asInteger(), te), object_id; + LLSelectedTEMaterial::setEnvironmentIntensity(this, (U8)te_data["material"]["EnvIntensity"].asInteger(), te, object_id); LLSelectedTEMaterial::setDiffuseAlphaMode(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); if (te_data.has("shiny")) { -- cgit v1.2.3 From 448eff8307324d12c86185f81c9d3896aec153fb Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 4 Nov 2019 17:00:21 +0200 Subject: SL-12212 Unable to copy-paste Color, Transparency and Glow settings --- indra/newview/llpanelface.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 8f8f1b4763..4e2fa5c95c 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -3045,12 +3045,12 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) } // Color / Alpha - if ((mPasteColor || mPasteAlpha) && te_data.has("colors")) + if ((mPasteColor || mPasteAlpha) && te_data["te"].has("colors")) { LLColor4 color = objectp->getTE(te)->getColor(); LLColor4 clip_color; - clip_color.setValue(te_data["colors"]); + clip_color.setValue(te_data["te"]["colors"]); // Color if (mPasteColor) @@ -3068,32 +3068,38 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) objectp->setTEColor(te, color); } - + + if (mPasteColor && te_data["te"].has("fullbright")) + { + objectp->setTEFullbright(te, te_data["te"]["fullbright"].asInteger()); + } + + // Glow - if (mPasteGlow && te_data.has("glow")) + if (mPasteGlow && te_data["te"].has("glow")) { - objectp->setTEGlow(te, (F32)te_data["glow"].asReal()); + objectp->setTEGlow(te, (F32)te_data["te"]["glow"].asReal()); } // Texture map if (mPasteMapping) { - if (te_data.has("scales") && te_data.has("scalet")) + if (te_data["te"].has("scales") && te_data["te"].has("scalet")) { - objectp->setTEScale(te, (F32)te_data["scales"].asReal(), (F32)te_data["scalet"].asReal()); + objectp->setTEScale(te, (F32)te_data["te"]["scales"].asReal(), (F32)te_data["te"]["scalet"].asReal()); } - if (te_data.has("offsets") && te_data.has("offsett")) + if (te_data["te"].has("offsets") && te_data["te"].has("offsett")) { - objectp->setTEOffset(te, (F32)te_data["offsets"].asReal(), (F32)te_data["offsett"].asReal()); + objectp->setTEOffset(te, (F32)te_data["te"]["offsets"].asReal(), (F32)te_data["te"]["offsett"].asReal()); } - if (te_data.has("imagerot")) + if (te_data["te"].has("imagerot")) { - objectp->setTERotation(te, (F32)te_data["imagerot"].asReal()); + objectp->setTERotation(te, (F32)te_data["te"]["imagerot"].asReal()); } } // Media - if (mPasteMedia && te_data.has("media")) + if (mPasteMedia && te_data.has("media")) //te_data["te"]? { //*TODO } @@ -3163,9 +3169,9 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) LLSelectedTEMaterial::setSpecularLightExponent(this, (U8)te_data["material"]["SpecExp"].asInteger(), te, object_id); LLSelectedTEMaterial::setEnvironmentIntensity(this, (U8)te_data["material"]["EnvIntensity"].asInteger(), te, object_id); LLSelectedTEMaterial::setDiffuseAlphaMode(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); - if (te_data.has("shiny")) + if (te_data.has("te") && te_data["te"].has("shiny")) { - objectp->setTEShiny(te, (U8)te_data["shiny"].asInteger()); + objectp->setTEShiny(te, (U8)te_data["te"]["shiny"].asInteger()); } } } -- cgit v1.2.3 From c17a08721bd6a767c722100e44f904b95e12bf58 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 11 Nov 2019 17:21:33 +0200 Subject: SL-12244 Copying a no transfer texture does not set target object to no transfer --- indra/newview/llpanelface.cpp | 101 +++++++++++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 16 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 4e2fa5c95c..2ed6ec0b0d 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -48,6 +48,7 @@ #include "llface.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" // gInventory +#include "llinventorymodelbackgroundfetch.h" #include "lllineeditor.h" #include "llmaterialmgr.h" #include "llmediaentry.h" @@ -2918,15 +2919,36 @@ void LLPanelFace::onCopyFaces() if (te_data["te"].has("imageid")) { LLUUID id = te_data["te"]["imageid"].asUUID(); + // Doesn't support local images! if (id.isNull() || !LLPanelObject::canCopyTexture(id)) { te_data["te"].erase("imageid"); te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); + te_data["te"]["itemfullperm"] = true; + } + else + { + te_data["te"]["itemfullperm"] = false; // if item is not in inventory, we won't get here + LLTextureCtrl* texture_ctrl = getChild("texture control"); + LLUUID item_id = texture_ctrl->getImageItemID(); + if (item_id.notNull()) + { + // Texture control should have the id (otherwise canCopyTexture == false), + // use it for consistency. + te_data["te"]["imageitemid"] = item_id; + + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (itemp) + { + te_data["te"]["itemfullperm"] = itemp->getIsFullPerm(); + if (!itemp->isFinished()) + { + // needed for dropTextureAllFaces + LLInventoryModelBackgroundFetch::instance().start(item_id, false); + } + } + } } - // else - // { - // te_data["te"]["imageid"] = canCopyTexture(te_data["te"]["imageid"].asUUID()); - // } } LLMaterialPtr material_ptr = tep->getMaterialParams(); @@ -3010,21 +3032,63 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) if (te_data.has("te")) { // Texture - if (mPasteDiffuse) + if (mPasteDiffuse && te_data["te"].has("imageid")) { - // Replace no-copy texture with target's - if (!te_data["te"].has("imageid")) + const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); //texture or asset id + LLViewerInventoryItem* itemp_res = NULL; + + if (te_data["te"].has("imageitemid")) { - te_data["te"]["imageid"] = tep->getID(); + LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); + if (item_id.notNull()) + { + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (itemp && itemp->isFinished()) + { + // dropTextureAllFaces will fail if incomplete + itemp_res = itemp; + } + } } - const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); - LLViewerInventoryItem* item = gInventory.getItem(imageid); - if (item) + + // for case when item got removed from inventory after we pressed 'copy' + if (!itemp_res) + { + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(imageid); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + + // Extremely unreliable and perfomance unfriendly. + // But we need this to check permissions and it is how texture control finds items + for (S32 i = 0; i < items.size(); i++) + { + LLViewerInventoryItem* itemp = items[i]; + if (itemp && itemp->isFinished()) + { + // dropTextureAllFaces will fail if incomplete + LLPermissions item_permissions = itemp->getPermissions(); + if (item_permissions.allowOperationBy(PERM_COPY, + gAgent.getID(), + gAgent.getGroupID())) + { + itemp_res = itemp; + break; // first match + } + } + } + } + + if (itemp_res) { if (te == -1) // all faces { LLToolDragAndDrop::dropTextureAllFaces(objectp, - item, + itemp_res, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } @@ -3032,15 +3096,20 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) { LLToolDragAndDrop::dropTextureOneFace(objectp, te, - item, + itemp_res, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } } - else // not an inventory item + // not an inventory item or no complete items + else if (te_data["te"].has("itemfullperm")) { - LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - objectp->setTEImage(U8(te), image); + if (te_data["te"]["itemfullperm"].asBoolean()) + { + // when user clicked copy, item existed in inventory as fullperm (also can be used for local images) + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + objectp->setTEImage(U8(te), image); + } } } -- cgit v1.2.3 From 87fd7cbea501ba9cd9211ee0cc90e9e8c9421ec2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 14 Nov 2019 21:22:10 +0200 Subject: SL-12289 'Copy media face' support --- indra/newview/llpanelface.cpp | 83 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 15 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9c80d582d5..9eb491ef3a 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2912,6 +2912,7 @@ void LLPanelFace::onCopyFaces() { LLSD te_data; + // asLLSD() includes media te_data["te"] = tep->asLLSD(); te_data["te"]["glow"] = tep->getGlow(); te_data["te"]["shiny"] = tep->getShiny(); @@ -3002,8 +3003,6 @@ void LLPanelFace::onCopyFaces() te_data["material"] = mat_data; } - //*TODO: Media - mClipboard.append(te_data); } } @@ -3116,7 +3115,7 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) // Color / Alpha if ((mPasteColor || mPasteAlpha) && te_data["te"].has("colors")) { - LLColor4 color = objectp->getTE(te)->getColor(); + LLColor4 color = tep->getColor(); LLColor4 clip_color; clip_color.setValue(te_data["te"]["colors"]); @@ -3167,19 +3166,20 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) } } - // Media - if (mPasteMedia && te_data.has("media")) //te_data["te"]? + // Media + if (mPasteMedia && te_data["te"].has("media_flags")) { - //*TODO + U8 media_flags = te_data["te"]["media_flags"].asInteger(); + objectp->setTEMediaFlags(te, media_flags); + LLVOVolume *vo = dynamic_cast(objectp); + if (vo && te_data["te"].has(LLTextureEntry::TEXTURE_MEDIA_DATA_KEY)) + { + vo->syncMediaData(te, te_data["te"][LLTextureEntry::TEXTURE_MEDIA_DATA_KEY], true/*merge*/, true/*ignore_agent*/); + } } else { - // // Keep media flags on destination unchanged - // // Media is handled later - // if (te_data["te"].has("media_flags")) - // { - // te_data["te"]["media_flags"] = tep->getMediaTexGen(); - // } + // Keep media flags on destination unchanged } } @@ -3261,13 +3261,66 @@ private: LLPanelFace *mPanelFace; }; +struct LLPanelFaceUpdateFunctor : public LLSelectedObjectFunctor +{ + LLPanelFaceUpdateFunctor(bool update_media) : mUpdateMedia(update_media) {} + virtual bool apply(LLViewerObject* object) + { + object->sendTEUpdate(); + if (mUpdateMedia) + { + LLVOVolume *vo = dynamic_cast(object); + if (vo && vo->hasMedia()) + { + vo->sendMediaDataUpdate(); + } + } + return true; + } +private: + bool mUpdateMedia; +}; + +struct LLPanelFaceNavigateHomeFunctor : public LLSelectedTEFunctor +{ + virtual bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && objectp->getTE(te)) + { + LLTextureEntry* tep = objectp->getTE(te); + const LLMediaEntry *media_data = tep->getMediaData(); + if (media_data) + { + if (media_data->getCurrentURL().empty() && media_data->getAutoPlay()) + { + viewer_media_t media_impl = + LLViewerMedia::getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); + if (media_impl) + { + media_impl->navigateHome(); + } + } + } + } + return true; + } +}; + void LLPanelFace::onPasteFaces() { + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + LLPanelFacePasteTexFunctor paste_func(this); - LLSelectMgr::getInstance()->getSelection()->applyToTEs(&paste_func); + selected_objects->applyToTEs(&paste_func); + + LLPanelFaceUpdateFunctor sendfunc(mPasteMedia); + selected_objects->applyToObjects(&sendfunc); - LLPanelFaceSendFunctor sendfunc; - LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc); + if (mPasteMedia) + { + LLPanelFaceNavigateHomeFunctor navigate_home_func; + selected_objects->applyToTEs(&navigate_home_func); + } } bool LLPanelFace::pasteCheckMenuItem(const LLSD& userdata) -- cgit v1.2.3 From 0afe586856765b9e3f8a39dd9b5b18bd0b02283d Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 15 Nov 2019 15:40:09 +0200 Subject: SL-12289 Build fix --- indra/newview/llpanelface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9eb491ef3a..e19e3f13ee 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -3294,7 +3294,7 @@ struct LLPanelFaceNavigateHomeFunctor : public LLSelectedTEFunctor if (media_data->getCurrentURL().empty() && media_data->getAutoPlay()) { viewer_media_t media_impl = - LLViewerMedia::getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); + LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); if (media_impl) { media_impl->navigateHome(); -- cgit v1.2.3 From 4fcf31e20319fbbfdd76240b351753e5de726eb5 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 15 Nov 2019 17:58:32 +0200 Subject: SL-12287 FIXED [Project Copy/Paste] Unable to paste texture from "local" storage --- indra/newview/llpanelface.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index e19e3f13ee..da471b0b62 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2923,8 +2923,15 @@ void LLPanelFace::onCopyFaces() // Doesn't support local images! if (id.isNull() || !LLPanelObject::canCopyTexture(id)) { - te_data["te"].erase("imageid"); - te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); + if (LLLocalBitmapMgr::getInstance()->isLocalBitmap(id)) + { + te_data["te"]["imageid"] = id; + } + else + { + te_data["te"].erase("imageid"); + te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); + } te_data["te"]["itemfullperm"] = true; } else -- cgit v1.2.3 From 0a411b0b1a89001afbe009c17b5aac70748289c6 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 3 Dec 2019 17:31:46 +0200 Subject: SL-12374 FIXED [Project Copy/Paste] Normal & specular texture UUIDs are copied to clipboard from no-copy or no-transfer objects --- indra/newview/llpanelface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index da471b0b62..2aba115e3f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2988,7 +2988,7 @@ void LLPanelFace::onCopyFaces() // Replace no-copy textures, destination texture will get used instead if available if (mat_data.has("NormMap")) { - LLUUID id = te_data["material"]["NormMap"].asUUID(); + LLUUID id = mat_data["NormMap"].asUUID(); if (id.notNull() && !LLPanelObject::canCopyTexture(id)) { mat_data["NormMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); @@ -2998,7 +2998,7 @@ void LLPanelFace::onCopyFaces() } if (mat_data.has("SpecMap")) { - LLUUID id = te_data["material"]["SpecMap"].asUUID(); + LLUUID id = mat_data["SpecMap"].asUUID(); if (id.notNull() && !LLPanelObject::canCopyTexture(id)) { mat_data["SpecMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); -- cgit v1.2.3 From b3d57f93b6c445578ea3f4caf596472f4ee6fa43 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Mon, 9 Dec 2019 17:26:16 +0200 Subject: SL-12413 FIXED [Project Copy/Paste] Bumpiness/Shininess parameters are not pasted from the clipboard --- indra/newview/llpanelface.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 2aba115e3f..3a48db0a1a 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2916,6 +2916,9 @@ void LLPanelFace::onCopyFaces() te_data["te"] = tep->asLLSD(); te_data["te"]["glow"] = tep->getGlow(); te_data["te"]["shiny"] = tep->getShiny(); + te_data["te"]["bumpmap"] = tep->getBumpmap(); + te_data["te"]["bumpshiny"] = tep->getBumpShiny(); + te_data["te"]["bumpfullbright"] = tep->getBumpShinyFullbright(); if (te_data["te"].has("imageid")) { @@ -3156,6 +3159,19 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) objectp->setTEGlow(te, (F32)te_data["te"]["glow"].asReal()); } + if (mPasteNormal && te_data["te"].has("bumpmap")) + { + objectp->setTEBumpmap(te, (U8)te_data["te"]["bumpmap"].asInteger()); + } + if (mPasteSpecular && te_data["te"].has("bumpshiny")) + { + objectp->setTEBumpShiny(te, (U8)te_data["te"]["bumpshiny"].asInteger()); + } + if (mPasteSpecular && te_data["te"].has("bumpfullbright")) + { + objectp->setTEBumpShinyFullbright(te, (U8)te_data["te"]["bumpfullbright"].asInteger()); + } + // Texture map if (mPasteMapping) { -- cgit v1.2.3 From eaa4e977d687abbfb28687c66cb0b92e66deb484 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 11 Dec 2019 22:48:46 +0200 Subject: SL-12334 [Copypaste] Texture is not copied to clipboard from a full-perms object --- indra/newview/llpanelface.cpp | 69 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 27 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 3a48db0a1a..914863ccc0 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2922,15 +2922,24 @@ void LLPanelFace::onCopyFaces() if (te_data["te"].has("imageid")) { + LLUUID item_id; LLUUID id = te_data["te"]["imageid"].asUUID(); - // Doesn't support local images! - if (id.isNull() || !LLPanelObject::canCopyTexture(id)) + bool full_perm = LLPanelObject::isLibraryTexture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + + // todo: fix this, we are often searching same tuxture multiple times (equal to number of faces) + if (id.notNull() && !full_perm) { - if (LLLocalBitmapMgr::getInstance()->isLocalBitmap(id)) - { - te_data["te"]["imageid"] = id; - } - else + // What this does is simply searches inventory for item with same asset id, + // as result it is Hightly unreliable, leaves little control to user, borderline hack + // but there are little options to preserve permissions - multiple inventory + // items might reference same asset and inventory search is expensive. + item_id = LLPanelObject::getCopyPermInventoryTextureId(id); + } + + if (id.isNull() + || (!full_perm && item_id.isNull())) + { + if (!LLLocalBitmapMgr::getInstance()->isLocalBitmap(id)) { te_data["te"].erase("imageid"); te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); @@ -2939,23 +2948,30 @@ void LLPanelFace::onCopyFaces() } else { - te_data["te"]["itemfullperm"] = false; // if item is not in inventory, we won't get here - LLTextureCtrl* texture_ctrl = getChild("texture control"); - LLUUID item_id = texture_ctrl->getImageItemID(); - if (item_id.notNull()) + te_data["te"]["itemfullperm"] = full_perm; + // If full permission object, texture is free to copy, + // but otherwise we need to check inventory and extract permissions + // + // Normally we care only about restrictions for current user and objects + // don't inherit any 'next owner' permissions from texture, so there is + // no need to record item id if full_perm==true + if (!full_perm && item_id.notNull()) { - // Texture control should have the id (otherwise canCopyTexture == false), - // use it for consistency. - te_data["te"]["imageitemid"] = item_id; - LLViewerInventoryItem* itemp = gInventory.getItem(item_id); if (itemp) { - te_data["te"]["itemfullperm"] = itemp->getIsFullPerm(); - if (!itemp->isFinished()) + LLPermissions item_permissions = itemp->getPermissions(); + if (item_permissions.allowOperationBy(PERM_COPY, + gAgent.getID(), + gAgent.getGroupID())) { - // needed for dropTextureAllFaces - LLInventoryModelBackgroundFetch::instance().start(item_id, false); + te_data["te"]["imageitemid"] = item_id; + te_data["te"]["itemfullperm"] = itemp->getIsFullPerm(); + if (!itemp->isFinished()) + { + // needed for dropTextureAllFaces + LLInventoryModelBackgroundFetch::instance().start(item_id, false); + } } } } @@ -3041,6 +3057,7 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) if (te_data.has("te")) { // Texture + bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); if (mPasteDiffuse && te_data["te"].has("imageid")) { const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); //texture or asset id @@ -3061,8 +3078,9 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) } // for case when item got removed from inventory after we pressed 'copy' - if (!itemp_res) + if (!itemp_res && !full_perm) { + // todo: fix this, we are often searching same tuxter multiple times (equal to number of faces) LLViewerInventoryCategory::cat_array_t cats; LLViewerInventoryItem::item_array_t items; LLAssetIDMatches asset_id_matches(imageid); @@ -3111,14 +3129,11 @@ void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) } } // not an inventory item or no complete items - else if (te_data["te"].has("itemfullperm")) + else if (full_perm) { - if (te_data["te"]["itemfullperm"].asBoolean()) - { - // when user clicked copy, item existed in inventory as fullperm (also can be used for local images) - LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - objectp->setTEImage(U8(te), image); - } + // Either library, local or existed as fullperm when user made a copy + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + objectp->setTEImage(U8(te), image); } } -- cgit v1.2.3 From ee3ae8cb4abcb8e738d434fe15b97c628d6ca815 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 12 Dec 2019 15:05:14 +0200 Subject: SL-12334 Reduce inventory use --- indra/newview/llpanelface.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 914863ccc0..f8199090dc 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2901,6 +2901,7 @@ void LLPanelFace::onCopyFaces() } mClipboard.clear(); + std::map asset_item_map; S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); for (S32 te = 0; te < num_tes; ++te) @@ -2926,14 +2927,23 @@ void LLPanelFace::onCopyFaces() LLUUID id = te_data["te"]["imageid"].asUUID(); bool full_perm = LLPanelObject::isLibraryTexture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); - // todo: fix this, we are often searching same tuxture multiple times (equal to number of faces) if (id.notNull() && !full_perm) { - // What this does is simply searches inventory for item with same asset id, - // as result it is Hightly unreliable, leaves little control to user, borderline hack - // but there are little options to preserve permissions - multiple inventory - // items might reference same asset and inventory search is expensive. - item_id = LLPanelObject::getCopyPermInventoryTextureId(id); + std::map::iterator iter = asset_item_map.find(id); + if (iter != asset_item_map.end()) + { + item_id = iter->second; + } + else + { + // What this does is simply searches inventory for item with same asset id, + // as result it is Hightly unreliable, leaves little control to user, borderline hack + // but there are little options to preserve permissions - multiple inventory + // items might reference same asset and inventory search is expensive. + item_id = LLPanelObject::getCopyPermInventoryTextureId(id); + // record value to avoid repeating inventory search when possible + asset_item_map[id] = item_id; + } } if (id.isNull() -- cgit v1.2.3 From c34f9c28b08a3dba50b831cde9a884f831366bee Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 19 Feb 2020 17:15:20 +0200 Subject: SL-12473 FIXED Copied texture params get duplicated when pasting to objects that use different face counts. --- indra/newview/llpanelface.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f8199090dc..810c18de40 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -63,6 +63,8 @@ #include "lltexturectrl.h" #include "lltextureentry.h" #include "lltooldraganddrop.h" +#include "lltoolface.h" +#include "lltoolmgr.h" #include "lltrans.h" #include "llui.h" #include "llviewercontrol.h" @@ -332,7 +334,8 @@ LLPanelFace::LLPanelFace() mPasteNormal(TRUE), mPasteSpecular(TRUE), mPasteMapping(TRUE), - mPasteMedia(TRUE) + mPasteMedia(TRUE), + mPopulateAllTEs(TRUE) { USE_TEXTURE = LLTrans::getString("use_texture"); @@ -2904,6 +2907,7 @@ void LLPanelFace::onCopyFaces() std::map asset_item_map; S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + mPopulateAllTEs = (num_tes != 1) || (LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool()); for (S32 te = 0; te < num_tes; ++te) { if (node->isTESelected(te)) @@ -3048,7 +3052,7 @@ void LLPanelFace::onCopyFaces() void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) { LLSD te_data; - if (mClipboard.size() == 1) + if ((mClipboard.size() == 1) && mPopulateAllTEs) { te_data = *(mClipboard.beginArray()); } -- cgit v1.2.3 From f4c7c8aff55d0cd8f044d5b7c8cddb2be750dde5 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Sun, 26 Apr 2020 21:15:54 +0300 Subject: Post-merge build fixes --- indra/newview/llpanelface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 810c18de40..13d0e377d7 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2953,7 +2953,7 @@ void LLPanelFace::onCopyFaces() if (id.isNull() || (!full_perm && item_id.isNull())) { - if (!LLLocalBitmapMgr::getInstance()->isLocalBitmap(id)) + if (!LLLocalBitmapMgr::getInstance()->isLocal(id)) { te_data["te"].erase("imageid"); te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); -- cgit v1.2.3 From 090bb3e6de6d5cb70ed372748a76e391f61cb32e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 2 Jun 2020 15:27:34 +0300 Subject: SL-13359 #1 Revert floater_tools and object panel changes --- indra/newview/llpanelface.cpp | 63 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 13d0e377d7..369861fa25 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2929,7 +2929,7 @@ void LLPanelFace::onCopyFaces() { LLUUID item_id; LLUUID id = te_data["te"]["imageid"].asUUID(); - bool full_perm = LLPanelObject::isLibraryTexture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + bool full_perm = LLPanelFace::isLibraryTexture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); if (id.notNull() && !full_perm) { @@ -2944,7 +2944,7 @@ void LLPanelFace::onCopyFaces() // as result it is Hightly unreliable, leaves little control to user, borderline hack // but there are little options to preserve permissions - multiple inventory // items might reference same asset and inventory search is expensive. - item_id = LLPanelObject::getCopyPermInventoryTextureId(id); + item_id = LLPanelFace::getCopyPermInventoryTextureId(id); // record value to avoid repeating inventory search when possible asset_item_map[id] = item_id; } @@ -3022,7 +3022,7 @@ void LLPanelFace::onCopyFaces() if (mat_data.has("NormMap")) { LLUUID id = mat_data["NormMap"].asUUID(); - if (id.notNull() && !LLPanelObject::canCopyTexture(id)) + if (id.notNull() && !LLPanelFace::canCopyTexture(id)) { mat_data["NormMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); mat_data["NormMapNoCopy"] = true; @@ -3032,7 +3032,7 @@ void LLPanelFace::onCopyFaces() if (mat_data.has("SpecMap")) { LLUUID id = mat_data["SpecMap"].asUUID(); - if (id.notNull() && !LLPanelObject::canCopyTexture(id)) + if (id.notNull() && !LLPanelFace::canCopyTexture(id)) { mat_data["SpecMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); mat_data["SpecMapNoCopy"] = true; @@ -3504,3 +3504,58 @@ bool LLPanelFace::pasteEnabletMenuItem(const LLSD& userdata) return true; } + +//static +bool LLPanelFace::isLibraryTexture(LLUUID image_id) +{ + if (gInventory.isObjectDescendentOf(image_id, gInventory.getLibraryRootFolderID()) + || image_id == LLUUID(gSavedSettings.getString("DefaultObjectTexture")) + || image_id == LLUUID(gSavedSettings.getString("UIImgWhiteUUID")) + || image_id == LLUUID(gSavedSettings.getString("UIImgInvisibleUUID")) + || image_id == LLUUID(SCULPT_DEFAULT_TEXTURE)) + { + return true; + } + return false; +} + +//static +LLUUID LLPanelFace::getCopyPermInventoryTextureId(LLUUID image_id) +{ + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(image_id); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + if (items.size()) + { + for (S32 i = 0; i < items.size(); i++) + { + LLViewerInventoryItem* itemp = items[i]; + if (itemp) + { + LLPermissions item_permissions = itemp->getPermissions(); + if (item_permissions.allowOperationBy(PERM_COPY, + gAgent.getID(), + gAgent.getGroupID())) + { + return itemp->getUUID(); + } + } + } + } + return LLUUID::null; +} + +// Static +bool LLPanelFace::canCopyTexture(LLUUID image_id) +{ + // User is allowed to copy a texture if: + // library asset or default texture, + // or copy perm asset exists in user's inventory + + return isLibraryTexture(image_id) || getCopyPermInventoryTextureId(image_id).notNull(); +} -- cgit v1.2.3 From 1310fac3b10b3927cb502008c156c16631b97663 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 17 Jun 2020 23:38:55 +0300 Subject: SL-13359 #5 Implemented revised changes --- indra/newview/llpanelface.cpp | 64 +++---------------------------------------- 1 file changed, 4 insertions(+), 60 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 369861fa25..6e99a10b98 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -54,7 +54,6 @@ #include "llmediaentry.h" #include "llmenubutton.h" #include "llnotificationsutil.h" -#include "llpanelobject.h" // LLPanelObject::canCopyTexture #include "llradiogroup.h" #include "llresmgr.h" #include "llselectmgr.h" @@ -2929,7 +2928,7 @@ void LLPanelFace::onCopyFaces() { LLUUID item_id; LLUUID id = te_data["te"]["imageid"].asUUID(); - bool full_perm = LLPanelFace::isLibraryTexture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + bool full_perm = get_is_library_texture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); if (id.notNull() && !full_perm) { @@ -2944,7 +2943,7 @@ void LLPanelFace::onCopyFaces() // as result it is Hightly unreliable, leaves little control to user, borderline hack // but there are little options to preserve permissions - multiple inventory // items might reference same asset and inventory search is expensive. - item_id = LLPanelFace::getCopyPermInventoryTextureId(id); + item_id = get_copy_free_item_by_asset_id(id); // record value to avoid repeating inventory search when possible asset_item_map[id] = item_id; } @@ -3022,7 +3021,7 @@ void LLPanelFace::onCopyFaces() if (mat_data.has("NormMap")) { LLUUID id = mat_data["NormMap"].asUUID(); - if (id.notNull() && !LLPanelFace::canCopyTexture(id)) + if (id.notNull() && !get_can_copy_texture(id)) { mat_data["NormMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); mat_data["NormMapNoCopy"] = true; @@ -3032,7 +3031,7 @@ void LLPanelFace::onCopyFaces() if (mat_data.has("SpecMap")) { LLUUID id = mat_data["SpecMap"].asUUID(); - if (id.notNull() && !LLPanelFace::canCopyTexture(id)) + if (id.notNull() && !get_can_copy_texture(id)) { mat_data["SpecMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); mat_data["SpecMapNoCopy"] = true; @@ -3504,58 +3503,3 @@ bool LLPanelFace::pasteEnabletMenuItem(const LLSD& userdata) return true; } - -//static -bool LLPanelFace::isLibraryTexture(LLUUID image_id) -{ - if (gInventory.isObjectDescendentOf(image_id, gInventory.getLibraryRootFolderID()) - || image_id == LLUUID(gSavedSettings.getString("DefaultObjectTexture")) - || image_id == LLUUID(gSavedSettings.getString("UIImgWhiteUUID")) - || image_id == LLUUID(gSavedSettings.getString("UIImgInvisibleUUID")) - || image_id == LLUUID(SCULPT_DEFAULT_TEXTURE)) - { - return true; - } - return false; -} - -//static -LLUUID LLPanelFace::getCopyPermInventoryTextureId(LLUUID image_id) -{ - LLViewerInventoryCategory::cat_array_t cats; - LLViewerInventoryItem::item_array_t items; - LLAssetIDMatches asset_id_matches(image_id); - gInventory.collectDescendentsIf(LLUUID::null, - cats, - items, - LLInventoryModel::INCLUDE_TRASH, - asset_id_matches); - if (items.size()) - { - for (S32 i = 0; i < items.size(); i++) - { - LLViewerInventoryItem* itemp = items[i]; - if (itemp) - { - LLPermissions item_permissions = itemp->getPermissions(); - if (item_permissions.allowOperationBy(PERM_COPY, - gAgent.getID(), - gAgent.getGroupID())) - { - return itemp->getUUID(); - } - } - } - } - return LLUUID::null; -} - -// Static -bool LLPanelFace::canCopyTexture(LLUUID image_id) -{ - // User is allowed to copy a texture if: - // library asset or default texture, - // or copy perm asset exists in user's inventory - - return isLibraryTexture(image_id) || getCopyPermInventoryTextureId(image_id).notNull(); -} -- cgit v1.2.3 From 15f02e2da231827a7cac18a2444c212efc8c1d1c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 19 Jun 2020 17:34:57 +0300 Subject: SL-13359 #8 Reverted changes to texture tab This reverts commit 1e1707d532560583744bb877adfed11864f2db31. --- indra/newview/llpanelface.cpp | 659 +----------------------------------------- 1 file changed, 4 insertions(+), 655 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 6e99a10b98..778cb77309 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -38,7 +38,6 @@ #include "llfontgl.h" // project includes -#include "llagent.h" // gAgent #include "llagentdata.h" #include "llbutton.h" #include "llcheckboxctrl.h" @@ -46,13 +45,9 @@ #include "llcombobox.h" #include "lldrawpoolbump.h" #include "llface.h" -#include "llinventoryfunctions.h" -#include "llinventorymodel.h" // gInventory -#include "llinventorymodelbackgroundfetch.h" #include "lllineeditor.h" #include "llmaterialmgr.h" #include "llmediaentry.h" -#include "llmenubutton.h" #include "llnotificationsutil.h" #include "llradiogroup.h" #include "llresmgr.h" @@ -305,18 +300,7 @@ BOOL LLPanelFace::postBuild() { mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this); } - - mBtnCopyFaces = getChild("copy_face_btn"); - if(mBtnCopyFaces) - { - mBtnCopyFaces->setCommitCallback(boost::bind(&LLPanelFace::onCopyFaces, this)); - } - mBtnPasteFaces = getChild("paste_face_btn"); - if (mBtnPasteFaces) - { - mBtnPasteFaces->setCommitCallback(boost::bind(&LLPanelFace::onPasteFaces, this)); - } - mBtnPasteMenu = getChild("paste_face_gear_btn"); + clearCtrls(); @@ -325,22 +309,9 @@ BOOL LLPanelFace::postBuild() LLPanelFace::LLPanelFace() : LLPanel(), - mIsAlpha(false), - mPasteColor(TRUE), - mPasteAlpha(TRUE), - mPasteGlow(TRUE), - mPasteDiffuse(TRUE), - mPasteNormal(TRUE), - mPasteSpecular(TRUE), - mPasteMapping(TRUE), - mPasteMedia(TRUE), - mPopulateAllTEs(TRUE) + mIsAlpha(false) { USE_TEXTURE = LLTrans::getString("use_texture"); - - mEnableCallbackRegistrar.add("BuildFace.PasteCheckItem", boost::bind(&LLPanelFace::pasteCheckMenuItem, this, _2)); - mCommitCallbackRegistrar.add("BuildFace.PasteDoToSelected", boost::bind(&LLPanelFace::pasteDoMenuItem, this, _2)); - mEnableCallbackRegistrar.add("BuildFace.PasteEnable", boost::bind(&LLPanelFace::pasteEnabletMenuItem, this, _2)); } @@ -1566,12 +1537,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } } - S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); - BOOL single_volume = (selected_count == 1); - mBtnCopyFaces->setEnabled(editable && single_volume); - mBtnPasteFaces->setEnabled(editable && (mClipboard.size() > 0)); - mBtnPasteMenu->setEnabled(editable); - // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); calcp->setVar(LLCalc::TEX_U_SCALE, childGetValue("TexScaleU").asReal()); @@ -1772,6 +1737,8 @@ void LLPanelFace::updateVisibility() getChildView("bumpyRot")->setVisible(show_bumpiness); getChildView("bumpyOffsetU")->setVisible(show_bumpiness); getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + + } // static @@ -2885,621 +2852,3 @@ void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identic } max_diff_repeats_func; identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_diff_repeats_func, repeats ); } - -static LLSD texture_clipboard; - -void LLPanelFace::onCopyFaces() -{ - LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); - LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); - S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); - if( !objectp || !node - || objectp->getPCode() != LL_PCODE_VOLUME - || !objectp->permModify() - || objectp->isPermanentEnforced() - || selected_count > 1) - { - return; - } - - mClipboard.clear(); - std::map asset_item_map; - - S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); - mPopulateAllTEs = (num_tes != 1) || (LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool()); - for (S32 te = 0; te < num_tes; ++te) - { - if (node->isTESelected(te)) - { - LLTextureEntry* tep = objectp->getTE(te); - if (tep) - { - LLSD te_data; - - // asLLSD() includes media - te_data["te"] = tep->asLLSD(); - te_data["te"]["glow"] = tep->getGlow(); - te_data["te"]["shiny"] = tep->getShiny(); - te_data["te"]["bumpmap"] = tep->getBumpmap(); - te_data["te"]["bumpshiny"] = tep->getBumpShiny(); - te_data["te"]["bumpfullbright"] = tep->getBumpShinyFullbright(); - - if (te_data["te"].has("imageid")) - { - LLUUID item_id; - LLUUID id = te_data["te"]["imageid"].asUUID(); - bool full_perm = get_is_library_texture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); - - if (id.notNull() && !full_perm) - { - std::map::iterator iter = asset_item_map.find(id); - if (iter != asset_item_map.end()) - { - item_id = iter->second; - } - else - { - // What this does is simply searches inventory for item with same asset id, - // as result it is Hightly unreliable, leaves little control to user, borderline hack - // but there are little options to preserve permissions - multiple inventory - // items might reference same asset and inventory search is expensive. - item_id = get_copy_free_item_by_asset_id(id); - // record value to avoid repeating inventory search when possible - asset_item_map[id] = item_id; - } - } - - if (id.isNull() - || (!full_perm && item_id.isNull())) - { - if (!LLLocalBitmapMgr::getInstance()->isLocal(id)) - { - te_data["te"].erase("imageid"); - te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); - } - te_data["te"]["itemfullperm"] = true; - } - else - { - te_data["te"]["itemfullperm"] = full_perm; - // If full permission object, texture is free to copy, - // but otherwise we need to check inventory and extract permissions - // - // Normally we care only about restrictions for current user and objects - // don't inherit any 'next owner' permissions from texture, so there is - // no need to record item id if full_perm==true - if (!full_perm && item_id.notNull()) - { - LLViewerInventoryItem* itemp = gInventory.getItem(item_id); - if (itemp) - { - LLPermissions item_permissions = itemp->getPermissions(); - if (item_permissions.allowOperationBy(PERM_COPY, - gAgent.getID(), - gAgent.getGroupID())) - { - te_data["te"]["imageitemid"] = item_id; - te_data["te"]["itemfullperm"] = itemp->getIsFullPerm(); - if (!itemp->isFinished()) - { - // needed for dropTextureAllFaces - LLInventoryModelBackgroundFetch::instance().start(item_id, false); - } - } - } - } - } - } - - LLMaterialPtr material_ptr = tep->getMaterialParams(); - if (!material_ptr.isNull()) - { - LLSD mat_data; - - mat_data["NormMap"] = material_ptr->getNormalID(); - mat_data["SpecMap"] = material_ptr->getSpecularID(); - - mat_data["NormRepX"] = material_ptr->getNormalRepeatX(); - mat_data["NormRepY"] = material_ptr->getNormalRepeatY(); - mat_data["NormOffX"] = material_ptr->getNormalOffsetX(); - mat_data["NormOffY"] = material_ptr->getNormalOffsetY(); - mat_data["NormRot"] = material_ptr->getNormalRotation(); - - mat_data["SpecRepX"] = material_ptr->getSpecularRepeatX(); - mat_data["SpecRepY"] = material_ptr->getSpecularRepeatY(); - mat_data["SpecOffX"] = material_ptr->getSpecularOffsetX(); - mat_data["SpecOffY"] = material_ptr->getSpecularOffsetY(); - mat_data["SpecRot"] = material_ptr->getSpecularRotation(); - - mat_data["SpecColor"] = material_ptr->getSpecularLightColor().getValue(); - mat_data["SpecExp"] = material_ptr->getSpecularLightExponent(); - mat_data["EnvIntensity"] = material_ptr->getEnvironmentIntensity(); - mat_data["AlphaMaskCutoff"] = material_ptr->getAlphaMaskCutoff(); - mat_data["DiffuseAlphaMode"] = material_ptr->getDiffuseAlphaMode(); - - // Replace no-copy textures, destination texture will get used instead if available - if (mat_data.has("NormMap")) - { - LLUUID id = mat_data["NormMap"].asUUID(); - if (id.notNull() && !get_can_copy_texture(id)) - { - mat_data["NormMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); - mat_data["NormMapNoCopy"] = true; - } - - } - if (mat_data.has("SpecMap")) - { - LLUUID id = mat_data["SpecMap"].asUUID(); - if (id.notNull() && !get_can_copy_texture(id)) - { - mat_data["SpecMap"] = LLUUID(gSavedSettings.getString( "DefaultObjectTexture" )); - mat_data["SpecMapNoCopy"] = true; - } - - } - - te_data["material"] = mat_data; - } - - mClipboard.append(te_data); - } - } - } -} - -void LLPanelFace::pasteFace(LLViewerObject* objectp, S32 te) -{ - LLSD te_data; - if ((mClipboard.size() == 1) && mPopulateAllTEs) - { - te_data = *(mClipboard.beginArray()); - } - else if (mClipboard[te]) - { - te_data = mClipboard[te]; - } - else - { - return; - } - - LLTextureEntry* tep = objectp->getTE(te); - if (tep) - { - if (te_data.has("te")) - { - // Texture - bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); - if (mPasteDiffuse && te_data["te"].has("imageid")) - { - const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); //texture or asset id - LLViewerInventoryItem* itemp_res = NULL; - - if (te_data["te"].has("imageitemid")) - { - LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); - if (item_id.notNull()) - { - LLViewerInventoryItem* itemp = gInventory.getItem(item_id); - if (itemp && itemp->isFinished()) - { - // dropTextureAllFaces will fail if incomplete - itemp_res = itemp; - } - } - } - - // for case when item got removed from inventory after we pressed 'copy' - if (!itemp_res && !full_perm) - { - // todo: fix this, we are often searching same tuxter multiple times (equal to number of faces) - LLViewerInventoryCategory::cat_array_t cats; - LLViewerInventoryItem::item_array_t items; - LLAssetIDMatches asset_id_matches(imageid); - gInventory.collectDescendentsIf(LLUUID::null, - cats, - items, - LLInventoryModel::INCLUDE_TRASH, - asset_id_matches); - - // Extremely unreliable and perfomance unfriendly. - // But we need this to check permissions and it is how texture control finds items - for (S32 i = 0; i < items.size(); i++) - { - LLViewerInventoryItem* itemp = items[i]; - if (itemp && itemp->isFinished()) - { - // dropTextureAllFaces will fail if incomplete - LLPermissions item_permissions = itemp->getPermissions(); - if (item_permissions.allowOperationBy(PERM_COPY, - gAgent.getID(), - gAgent.getGroupID())) - { - itemp_res = itemp; - break; // first match - } - } - } - } - - if (itemp_res) - { - if (te == -1) // all faces - { - LLToolDragAndDrop::dropTextureAllFaces(objectp, - itemp_res, - LLToolDragAndDrop::SOURCE_AGENT, - LLUUID::null); - } - else // one face - { - LLToolDragAndDrop::dropTextureOneFace(objectp, - te, - itemp_res, - LLToolDragAndDrop::SOURCE_AGENT, - LLUUID::null); - } - } - // not an inventory item or no complete items - else if (full_perm) - { - // Either library, local or existed as fullperm when user made a copy - LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - objectp->setTEImage(U8(te), image); - } - } - - // Color / Alpha - if ((mPasteColor || mPasteAlpha) && te_data["te"].has("colors")) - { - LLColor4 color = tep->getColor(); - - LLColor4 clip_color; - clip_color.setValue(te_data["te"]["colors"]); - - // Color - if (mPasteColor) - { - color.mV[VRED] = clip_color.mV[VRED]; - color.mV[VGREEN] = clip_color.mV[VGREEN]; - color.mV[VBLUE] = clip_color.mV[VBLUE]; - } - - // Alpha - if (mPasteAlpha) - { - color.mV[VALPHA] = clip_color.mV[VALPHA]; - } - - objectp->setTEColor(te, color); - } - - if (mPasteColor && te_data["te"].has("fullbright")) - { - objectp->setTEFullbright(te, te_data["te"]["fullbright"].asInteger()); - } - - - // Glow - if (mPasteGlow && te_data["te"].has("glow")) - { - objectp->setTEGlow(te, (F32)te_data["te"]["glow"].asReal()); - } - - if (mPasteNormal && te_data["te"].has("bumpmap")) - { - objectp->setTEBumpmap(te, (U8)te_data["te"]["bumpmap"].asInteger()); - } - if (mPasteSpecular && te_data["te"].has("bumpshiny")) - { - objectp->setTEBumpShiny(te, (U8)te_data["te"]["bumpshiny"].asInteger()); - } - if (mPasteSpecular && te_data["te"].has("bumpfullbright")) - { - objectp->setTEBumpShinyFullbright(te, (U8)te_data["te"]["bumpfullbright"].asInteger()); - } - - // Texture map - if (mPasteMapping) - { - if (te_data["te"].has("scales") && te_data["te"].has("scalet")) - { - objectp->setTEScale(te, (F32)te_data["te"]["scales"].asReal(), (F32)te_data["te"]["scalet"].asReal()); - } - if (te_data["te"].has("offsets") && te_data["te"].has("offsett")) - { - objectp->setTEOffset(te, (F32)te_data["te"]["offsets"].asReal(), (F32)te_data["te"]["offsett"].asReal()); - } - if (te_data["te"].has("imagerot")) - { - objectp->setTERotation(te, (F32)te_data["te"]["imagerot"].asReal()); - } - } - - // Media - if (mPasteMedia && te_data["te"].has("media_flags")) - { - U8 media_flags = te_data["te"]["media_flags"].asInteger(); - objectp->setTEMediaFlags(te, media_flags); - LLVOVolume *vo = dynamic_cast(objectp); - if (vo && te_data["te"].has(LLTextureEntry::TEXTURE_MEDIA_DATA_KEY)) - { - vo->syncMediaData(te, te_data["te"][LLTextureEntry::TEXTURE_MEDIA_DATA_KEY], true/*merge*/, true/*ignore_agent*/); - } - } - else - { - // Keep media flags on destination unchanged - } - } - - if (te_data.has("material")) - { - LLUUID object_id = objectp->getID(); - - LLSelectedTEMaterial::setAlphaMaskCutoff(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); - - if (mPasteNormal) - { - // Replace placeholders with target's - if (te_data["material"].has("NormMapNoCopy")) - { - LLMaterialPtr material = tep->getMaterialParams(); - if (material.notNull()) - { - LLUUID id = material->getNormalID(); - if (id.notNull()) - { - te_data["material"]["NormMap"] = id; - } - } - } - LLSelectedTEMaterial::setNormalID(this, te_data["material"]["NormMap"].asUUID(), te, object_id); - LLSelectedTEMaterial::setNormalRepeatX(this, (F32)te_data["material"]["NormRepX"].asReal(), te, object_id); - LLSelectedTEMaterial::setNormalRepeatY(this, (F32)te_data["material"]["NormRepY"].asReal(), te, object_id); - LLSelectedTEMaterial::setNormalOffsetX(this, (F32)te_data["material"]["NormOffX"].asReal(), te, object_id); - LLSelectedTEMaterial::setNormalOffsetY(this, (F32)te_data["material"]["NormOffY"].asReal(), te, object_id); - LLSelectedTEMaterial::setNormalRotation(this, (F32)te_data["material"]["NormRot"].asReal(), te, object_id); - } - - if (mPasteSpecular) - { - // Replace placeholders with target's - if (te_data["material"].has("SpecMapNoCopy")) - { - LLMaterialPtr material = tep->getMaterialParams(); - if (material.notNull()) - { - LLUUID id = material->getSpecularID(); - if (id.notNull()) - { - te_data["material"]["SpecMap"] = id; - } - } - } - LLSelectedTEMaterial::setSpecularID(this, te_data["material"]["SpecMap"].asUUID(), te, object_id); - LLSelectedTEMaterial::setSpecularRepeatX(this, (F32)te_data["material"]["SpecRepX"].asReal(), te, object_id); - LLSelectedTEMaterial::setSpecularRepeatY(this, (F32)te_data["material"]["SpecRepY"].asReal(), te, object_id); - LLSelectedTEMaterial::setSpecularOffsetX(this, (F32)te_data["material"]["SpecOffX"].asReal(), te, object_id); - LLSelectedTEMaterial::setSpecularOffsetY(this, (F32)te_data["material"]["SpecOffY"].asReal(), te, object_id); - LLSelectedTEMaterial::setSpecularRotation(this, (F32)te_data["material"]["SpecRot"].asReal(), te, object_id); - LLColor4 spec_color(te_data["material"]["SpecColor"]); - LLSelectedTEMaterial::setSpecularLightColor(this, spec_color, te); - LLSelectedTEMaterial::setSpecularLightExponent(this, (U8)te_data["material"]["SpecExp"].asInteger(), te, object_id); - LLSelectedTEMaterial::setEnvironmentIntensity(this, (U8)te_data["material"]["EnvIntensity"].asInteger(), te, object_id); - LLSelectedTEMaterial::setDiffuseAlphaMode(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); - if (te_data.has("te") && te_data["te"].has("shiny")) - { - objectp->setTEShiny(te, (U8)te_data["te"]["shiny"].asInteger()); - } - } - } - } -} - -struct LLPanelFacePasteTexFunctor : public LLSelectedTEFunctor -{ - LLPanelFacePasteTexFunctor(LLPanelFace* panel) : - mPanelFace(panel){} - - virtual bool apply(LLViewerObject* objectp, S32 te) - { - mPanelFace->pasteFace(objectp, te); - return true; - } -private: - LLPanelFace *mPanelFace; -}; - -struct LLPanelFaceUpdateFunctor : public LLSelectedObjectFunctor -{ - LLPanelFaceUpdateFunctor(bool update_media) : mUpdateMedia(update_media) {} - virtual bool apply(LLViewerObject* object) - { - object->sendTEUpdate(); - if (mUpdateMedia) - { - LLVOVolume *vo = dynamic_cast(object); - if (vo && vo->hasMedia()) - { - vo->sendMediaDataUpdate(); - } - } - return true; - } -private: - bool mUpdateMedia; -}; - -struct LLPanelFaceNavigateHomeFunctor : public LLSelectedTEFunctor -{ - virtual bool apply(LLViewerObject* objectp, S32 te) - { - if (objectp && objectp->getTE(te)) - { - LLTextureEntry* tep = objectp->getTE(te); - const LLMediaEntry *media_data = tep->getMediaData(); - if (media_data) - { - if (media_data->getCurrentURL().empty() && media_data->getAutoPlay()) - { - viewer_media_t media_impl = - LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); - if (media_impl) - { - media_impl->navigateHome(); - } - } - } - } - return true; - } -}; - -void LLPanelFace::onPasteFaces() -{ - LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); - - LLPanelFacePasteTexFunctor paste_func(this); - selected_objects->applyToTEs(&paste_func); - - LLPanelFaceUpdateFunctor sendfunc(mPasteMedia); - selected_objects->applyToObjects(&sendfunc); - - if (mPasteMedia) - { - LLPanelFaceNavigateHomeFunctor navigate_home_func; - selected_objects->applyToTEs(&navigate_home_func); - } -} - -bool LLPanelFace::pasteCheckMenuItem(const LLSD& userdata) -{ - std::string command = userdata.asString(); - - if ("Color" == command) - { - return mPasteColor; - } - if ("Transparency" == command) - { - return mPasteAlpha; - } - if ("Glow" == command) - { - return mPasteGlow; - } - if ("Diffuse" == command) - { - return mPasteDiffuse; - } - if ("Normal" == command) - { - return mPasteNormal; - } - if ("Specular" == command) - { - return mPasteSpecular; - } - if ("Mapping" == command) - { - return mPasteMapping; - } - if ("Media" == command) - { - return mPasteMedia; - } - - return false; -} - -void LLPanelFace::pasteDoMenuItem(const LLSD& userdata) -{ - std::string command = userdata.asString(); - - if ("Color" == command) - { - mPasteColor = !mPasteColor; - } - if ("Transparency" == command) - { - mPasteAlpha = !mPasteAlpha; - } - if ("Glow" == command) - { - mPasteGlow = !mPasteGlow; - } - if ("Diffuse" == command) - { - mPasteDiffuse = !mPasteDiffuse; - } - if ("Normal" == command) - { - mPasteNormal = !mPasteNormal; - } - if ("Specular" == command) - { - mPasteSpecular = !mPasteSpecular; - } - if ("Mapping" == command) - { - mPasteMapping = !mPasteMapping; - } - if ("Media" == command) - { - mPasteMedia = !mPasteMedia; - } -} - -bool LLPanelFace::pasteEnabletMenuItem(const LLSD& userdata) -{ - std::string command = userdata.asString(); - - // Keep at least one option enabled - S32 num_enabled = mPasteColor - + mPasteAlpha - + mPasteGlow - + mPasteDiffuse - + mPasteNormal - + mPasteSpecular - + mPasteMapping - + mPasteMedia; - if ( num_enabled == 1) - { - if ("Color" == command && mPasteColor) - { - return false; - } - if ("Transparency" == command && mPasteAlpha) - { - return false; - } - if ("Glow" == command && mPasteGlow) - { - return false; - } - if ("Diffuse" == command && mPasteDiffuse) - { - return false; - } - if ("Normal" == command && mPasteNormal) - { - return false; - } - if ("Specular" == command && mPasteSpecular) - { - return false; - } - if ("Mapping" == command && mPasteMapping) - { - return false; - } - if ("Media" == command && mPasteMedia) - { - return false; - } - } - - return true; -} -- cgit v1.2.3 From 052e1adcd052e5e9a9fc29612daf6ec5d568f895 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 19 Jun 2020 22:18:31 +0300 Subject: SL-13359 #9 Texture tab --- indra/newview/llpanelface.cpp | 633 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 631 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 778cb77309..6b5d14300f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -45,9 +45,11 @@ #include "llcombobox.h" #include "lldrawpoolbump.h" #include "llface.h" +#include "llinventorymodel.h" // gInventory #include "lllineeditor.h" #include "llmaterialmgr.h" #include "llmediaentry.h" +#include "llmenubutton.h" #include "llnotificationsutil.h" #include "llradiogroup.h" #include "llresmgr.h" @@ -300,7 +302,9 @@ BOOL LLPanelFace::postBuild() { mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this); } - + + mMenuClipboardColor = getChild("clipboard_color_params_btn"); + mMenuClipboardTexture = getChild("clipboard_texture_params_btn"); clearCtrls(); @@ -311,7 +315,9 @@ LLPanelFace::LLPanelFace() : LLPanel(), mIsAlpha(false) { - USE_TEXTURE = LLTrans::getString("use_texture"); + USE_TEXTURE = LLTrans::getString("use_texture"); + mCommitCallbackRegistrar.add("PanelFace.menuDoToSelected", boost::bind(&LLPanelFace::menuDoToSelected, this, _2)); + mEnableCallbackRegistrar.add("PanelFace.menuEnable", boost::bind(&LLPanelFace::menuEnableItem, this, _2)); } @@ -1536,6 +1542,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } } } + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + BOOL single_volume = (selected_count == 1); + mMenuClipboardColor->setEnabled(editable && single_volume); + mMenuClipboardTexture->setEnabled(editable && single_volume); // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); @@ -2566,6 +2576,625 @@ void LLPanelFace::onAlignTexture(void* userdata) self->alignTestureLayer(); } +void LLPanelFace::onCopyColor() +{ + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + if (!objectp || !node + || objectp->getPCode() != LL_PCODE_VOLUME + || !objectp->permModify() + || objectp->isPermanentEnforced() + || selected_count > 1) + { + return; + } + + if (mClipboardParams.has("color")) + { + mClipboardParams["color"].clear(); + } + else + { + mClipboardParams["color"] = LLSD::emptyArray(); + } + + std::map asset_item_map; + + // a way to resolve situations where source and target have different amount of faces + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + mClipboardParams["color_all_tes"] = (num_tes != 1) || (LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool()); + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + LLTextureEntry* tep = objectp->getTE(te); + if (tep) + { + LLSD te_data; + + // asLLSD() includes media + te_data["te"] = tep->asLLSD(); // Note: includes a lot more than just color/alpha/glow + + mClipboardParams["color"].append(te_data); + } + } + } +} + +void LLPanelFace::onPasteColor(LLViewerObject* objectp, S32 te) +{ + if (!mClipboardParams.has("color")) + { + return; + } + LLSD te_data; + LLSD &clipboard = mClipboardParams["color"]; // array + if ((clipboard.size() == 1) && mClipboardParams["color_all_tes"].asBoolean()) + { + te_data = *(clipboard.beginArray()); + } + else if (clipboard[te]) + { + te_data = clipboard[te]; + } + else + { + return; + } + + LLTextureEntry* tep = objectp->getTE(te); + if (tep) + { + if (te_data.has("te")) + { + // Color / Alpha + if (te_data["te"].has("colors")) + { + LLColor4 color = tep->getColor(); + + LLColor4 clip_color; + clip_color.setValue(te_data["te"]["colors"]); + + // Color + color.mV[VRED] = clip_color.mV[VRED]; + color.mV[VGREEN] = clip_color.mV[VGREEN]; + color.mV[VBLUE] = clip_color.mV[VBLUE]; + + // Alpha + color.mV[VALPHA] = clip_color.mV[VALPHA]; + + objectp->setTEColor(te, color); + } + + // Color/fullbright + if (te_data["te"].has("fullbright")) + { + objectp->setTEFullbright(te, te_data["te"]["fullbright"].asInteger()); + } + + // Glow + if (te_data["te"].has("glow")) + { + objectp->setTEGlow(te, (F32)te_data["te"]["glow"].asReal()); + } + } + } +} + +void LLPanelFace::onCopyTexture() +{ + + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + if (!objectp || !node + || objectp->getPCode() != LL_PCODE_VOLUME + || !objectp->permModify() + || objectp->isPermanentEnforced() + || selected_count > 1) + { + return; + } + + if (mClipboardParams.has("texture")) + { + mClipboardParams["texture"].clear(); + } + else + { + mClipboardParams["texture"] = LLSD::emptyArray(); + } + + std::map asset_item_map; + + // a way to resolve situations where source and target have different amount of faces + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + mClipboardParams["texture_all_tes"] = (num_tes != 1) || (LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool()); + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + LLTextureEntry* tep = objectp->getTE(te); + if (tep) + { + LLSD te_data; + + // asLLSD() includes media + te_data["te"] = tep->asLLSD(); + te_data["te"]["shiny"] = tep->getShiny(); + te_data["te"]["bumpmap"] = tep->getBumpmap(); + te_data["te"]["bumpshiny"] = tep->getBumpShiny(); + te_data["te"]["bumpfullbright"] = tep->getBumpShinyFullbright(); + + if (te_data["te"].has("imageid")) + { + LLUUID item_id; + LLUUID id = te_data["te"]["imageid"].asUUID(); + bool full_perm = get_is_library_texture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + + if (id.notNull() && !full_perm) + { + std::map::iterator iter = asset_item_map.find(id); + if (iter != asset_item_map.end()) + { + item_id = iter->second; + } + else + { + // What this does is simply searches inventory for item with same asset id, + // as result it is Hightly unreliable, leaves little control to user, borderline hack + // but there are little options to preserve permissions - multiple inventory + // items might reference same asset and inventory search is expensive. + item_id = get_copy_free_item_by_asset_id(id); + // record value to avoid repeating inventory search when possible + asset_item_map[id] = item_id; + } + } + + if (id.isNull() + || (!full_perm && item_id.isNull())) + { + if (!LLLocalBitmapMgr::getInstance()->isLocal(id)) + { + te_data["te"].erase("imageid"); + te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); + } + te_data["te"]["itemfullperm"] = true; + } + else + { + te_data["te"]["itemfullperm"] = full_perm; + // If full permission object, texture is free to copy, + // but otherwise we need to check inventory and extract permissions + // + // Normally we care only about restrictions for current user and objects + // don't inherit any 'next owner' permissions from texture, so there is + // no need to record item id if full_perm==true + if (!full_perm && item_id.notNull()) + { + //Todo: + // also same thing probably needs to be present in object and volume panels for sculpt and projector images + /* + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (itemp) + { + LLPermissions item_permissions = itemp->getPermissions(); + if (item_permissions.allowOperationBy(PERM_COPY, + gAgent.getID(), + gAgent.getGroupID())) + { + te_data["te"]["imageitemid"] = item_id; + te_data["te"]["itemfullperm"] = itemp->getIsFullPerm(); + if (!itemp->isFinished()) + { + // needed for dropTextureAllFaces + LLInventoryModelBackgroundFetch::instance().start(item_id, false); + } + } + } + */ + } + } + } + + LLMaterialPtr material_ptr = tep->getMaterialParams(); + if (!material_ptr.isNull()) + { + LLSD mat_data; + + mat_data["NormMap"] = material_ptr->getNormalID(); + mat_data["SpecMap"] = material_ptr->getSpecularID(); + + mat_data["NormRepX"] = material_ptr->getNormalRepeatX(); + mat_data["NormRepY"] = material_ptr->getNormalRepeatY(); + mat_data["NormOffX"] = material_ptr->getNormalOffsetX(); + mat_data["NormOffY"] = material_ptr->getNormalOffsetY(); + mat_data["NormRot"] = material_ptr->getNormalRotation(); + + mat_data["SpecRepX"] = material_ptr->getSpecularRepeatX(); + mat_data["SpecRepY"] = material_ptr->getSpecularRepeatY(); + mat_data["SpecOffX"] = material_ptr->getSpecularOffsetX(); + mat_data["SpecOffY"] = material_ptr->getSpecularOffsetY(); + mat_data["SpecRot"] = material_ptr->getSpecularRotation(); + + mat_data["SpecColor"] = material_ptr->getSpecularLightColor().getValue(); + mat_data["SpecExp"] = material_ptr->getSpecularLightExponent(); + mat_data["EnvIntensity"] = material_ptr->getEnvironmentIntensity(); + mat_data["AlphaMaskCutoff"] = material_ptr->getAlphaMaskCutoff(); + mat_data["DiffuseAlphaMode"] = material_ptr->getDiffuseAlphaMode(); + + // Replace no-copy textures, destination texture will get used instead if available + if (mat_data.has("NormMap")) + { + LLUUID id = mat_data["NormMap"].asUUID(); + if (id.notNull() && !get_can_copy_texture(id)) + { + mat_data["NormMap"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); + mat_data["NormMapNoCopy"] = true; + } + + } + if (mat_data.has("SpecMap")) + { + LLUUID id = mat_data["SpecMap"].asUUID(); + if (id.notNull() && !get_can_copy_texture(id)) + { + mat_data["SpecMap"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); + mat_data["SpecMapNoCopy"] = true; + } + + } + + te_data["material"] = mat_data; + } + + mClipboardParams["texture"].append(te_data); + } + } + } +} + +void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) +{ + if (!mClipboardParams.has("texture")) + { + return; + } + LLSD te_data; + LLSD &clipboard = mClipboardParams["texture"]; // array + if ((clipboard.size() == 1) && mClipboardParams["texture_all_tes"].asBoolean()) + { + te_data = *(clipboard.beginArray()); + } + else if (clipboard[te]) + { + te_data = clipboard[te]; + } + else + { + return; + } + + LLTextureEntry* tep = objectp->getTE(te); + if (tep) + { + if (te_data.has("te")) + { + // Texture + bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); + if (te_data["te"].has("imageid")) + { + const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); //texture or asset id + LLViewerInventoryItem* itemp_res = NULL; + + if (te_data["te"].has("imageitemid")) + { + LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); + if (item_id.notNull()) + { + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (itemp && itemp->isFinished()) + { + // dropTextureAllFaces will fail if incomplete + itemp_res = itemp; + } + } + } + //todo: + // for case when item got removed from inventory after we pressed 'copy' + /*if (!itemp_res && !full_perm) + { + // todo: fix this, we are often searching same tuxter multiple times (equal to number of faces) + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(imageid); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + + // Extremely unreliable and perfomance unfriendly. + // But we need this to check permissions and it is how texture control finds items + for (S32 i = 0; i < items.size(); i++) + { + LLViewerInventoryItem* itemp = items[i]; + if (itemp && itemp->isFinished()) + { + // dropTextureAllFaces will fail if incomplete + LLPermissions item_permissions = itemp->getPermissions(); + if (item_permissions.allowOperationBy(PERM_COPY, + gAgent.getID(), + gAgent.getGroupID())) + { + itemp_res = itemp; + break; // first match + } + } + } + }*/ + + if (itemp_res) + { + if (te == -1) // all faces + { + LLToolDragAndDrop::dropTextureAllFaces(objectp, + itemp_res, + LLToolDragAndDrop::SOURCE_AGENT, + LLUUID::null); + } + else // one face + { + LLToolDragAndDrop::dropTextureOneFace(objectp, + te, + itemp_res, + LLToolDragAndDrop::SOURCE_AGENT, + LLUUID::null); + } + } + // not an inventory item or no complete items + else if (full_perm) + { + // Either library, local or existed as fullperm when user made a copy + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(imageid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + objectp->setTEImage(U8(te), image); + } + } + + if (te_data["te"].has("bumpmap")) + { + objectp->setTEBumpmap(te, (U8)te_data["te"]["bumpmap"].asInteger()); + } + if (te_data["te"].has("bumpshiny")) + { + objectp->setTEBumpShiny(te, (U8)te_data["te"]["bumpshiny"].asInteger()); + } + if (te_data["te"].has("bumpfullbright")) + { + objectp->setTEBumpShinyFullbright(te, (U8)te_data["te"]["bumpfullbright"].asInteger()); + } + + // Texture map + if (te_data["te"].has("scales") && te_data["te"].has("scalet")) + { + objectp->setTEScale(te, (F32)te_data["te"]["scales"].asReal(), (F32)te_data["te"]["scalet"].asReal()); + } + if (te_data["te"].has("offsets") && te_data["te"].has("offsett")) + { + objectp->setTEOffset(te, (F32)te_data["te"]["offsets"].asReal(), (F32)te_data["te"]["offsett"].asReal()); + } + if (te_data["te"].has("imagerot")) + { + objectp->setTERotation(te, (F32)te_data["te"]["imagerot"].asReal()); + } + + // Media + if (te_data["te"].has("media_flags")) + { + U8 media_flags = te_data["te"]["media_flags"].asInteger(); + objectp->setTEMediaFlags(te, media_flags); + LLVOVolume *vo = dynamic_cast(objectp); + if (vo && te_data["te"].has(LLTextureEntry::TEXTURE_MEDIA_DATA_KEY)) + { + vo->syncMediaData(te, te_data["te"][LLTextureEntry::TEXTURE_MEDIA_DATA_KEY], true/*merge*/, true/*ignore_agent*/); + } + } + else + { + // Keep media flags on destination unchanged + } + } + + if (te_data.has("material")) + { + LLUUID object_id = objectp->getID(); + + LLSelectedTEMaterial::setAlphaMaskCutoff(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); + + // Normal + // Replace placeholders with target's + if (te_data["material"].has("NormMapNoCopy")) + { + LLMaterialPtr material = tep->getMaterialParams(); + if (material.notNull()) + { + LLUUID id = material->getNormalID(); + if (id.notNull()) + { + te_data["material"]["NormMap"] = id; + } + } + } + LLSelectedTEMaterial::setNormalID(this, te_data["material"]["NormMap"].asUUID(), te, object_id); + LLSelectedTEMaterial::setNormalRepeatX(this, (F32)te_data["material"]["NormRepX"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalRepeatY(this, (F32)te_data["material"]["NormRepY"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalOffsetX(this, (F32)te_data["material"]["NormOffX"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalOffsetY(this, (F32)te_data["material"]["NormOffY"].asReal(), te, object_id); + LLSelectedTEMaterial::setNormalRotation(this, (F32)te_data["material"]["NormRot"].asReal(), te, object_id); + + // Specular + // Replace placeholders with target's + if (te_data["material"].has("SpecMapNoCopy")) + { + LLMaterialPtr material = tep->getMaterialParams(); + if (material.notNull()) + { + LLUUID id = material->getSpecularID(); + if (id.notNull()) + { + te_data["material"]["SpecMap"] = id; + } + } + } + LLSelectedTEMaterial::setSpecularID(this, te_data["material"]["SpecMap"].asUUID(), te, object_id); + LLSelectedTEMaterial::setSpecularRepeatX(this, (F32)te_data["material"]["SpecRepX"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularRepeatY(this, (F32)te_data["material"]["SpecRepY"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularOffsetX(this, (F32)te_data["material"]["SpecOffX"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularOffsetY(this, (F32)te_data["material"]["SpecOffY"].asReal(), te, object_id); + LLSelectedTEMaterial::setSpecularRotation(this, (F32)te_data["material"]["SpecRot"].asReal(), te, object_id); + LLColor4 spec_color(te_data["material"]["SpecColor"]); + LLSelectedTEMaterial::setSpecularLightColor(this, spec_color, te); + LLSelectedTEMaterial::setSpecularLightExponent(this, (U8)te_data["material"]["SpecExp"].asInteger(), te, object_id); + LLSelectedTEMaterial::setEnvironmentIntensity(this, (U8)te_data["material"]["EnvIntensity"].asInteger(), te, object_id); + LLSelectedTEMaterial::setDiffuseAlphaMode(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); + if (te_data.has("te") && te_data["te"].has("shiny")) + { + objectp->setTEShiny(te, (U8)te_data["te"]["shiny"].asInteger()); + } + } + } +} + +enum EPasteMode +{ + PASTE_COLOR, + PASTE_TEXTURE +}; + +struct LLPanelFacePasteTexFunctor : public LLSelectedTEFunctor +{ + LLPanelFacePasteTexFunctor(LLPanelFace* panel, EPasteMode mode) : + mPanelFace(panel), mMode(mode) {} + + virtual bool apply(LLViewerObject* objectp, S32 te) + { + switch (mMode) + { + case PASTE_COLOR: + mPanelFace->onPasteColor(objectp, te); + break; + case PASTE_TEXTURE: + mPanelFace->onPasteTexture(objectp, te); + break; + } + return true; + } +private: + LLPanelFace *mPanelFace; + EPasteMode mMode; +}; + +struct LLPanelFaceUpdateFunctor : public LLSelectedObjectFunctor +{ + LLPanelFaceUpdateFunctor(bool update_media) : mUpdateMedia(update_media) {} + virtual bool apply(LLViewerObject* object) + { + object->sendTEUpdate(); + if (mUpdateMedia) + { + LLVOVolume *vo = dynamic_cast(object); + if (vo && vo->hasMedia()) + { + vo->sendMediaDataUpdate(); + } + } + return true; + } +private: + bool mUpdateMedia; +}; + +struct LLPanelFaceNavigateHomeFunctor : public LLSelectedTEFunctor +{ + virtual bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && objectp->getTE(te)) + { + LLTextureEntry* tep = objectp->getTE(te); + const LLMediaEntry *media_data = tep->getMediaData(); + if (media_data) + { + if (media_data->getCurrentURL().empty() && media_data->getAutoPlay()) + { + viewer_media_t media_impl = + LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); + if (media_impl) + { + media_impl->navigateHome(); + } + } + } + } + return true; + } +}; + +void LLPanelFace::menuDoToSelected(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + // paste + if (command == "color_paste") + { + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + + LLPanelFacePasteTexFunctor paste_func(this, PASTE_COLOR); + selected_objects->applyToTEs(&paste_func); + + LLPanelFaceUpdateFunctor sendfunc(false); + selected_objects->applyToObjects(&sendfunc); + } + else if (command == "texture_paste") + { + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + + LLPanelFacePasteTexFunctor paste_func(this, PASTE_TEXTURE); + selected_objects->applyToTEs(&paste_func); + + LLPanelFaceUpdateFunctor sendfunc(true); + selected_objects->applyToObjects(&sendfunc); + + LLPanelFaceNavigateHomeFunctor navigate_home_func; + selected_objects->applyToTEs(&navigate_home_func); + } + // copy + else if (command == "color_copy") + { + onCopyColor(); + } + else if (command == "texture_copy") + { + onCopyTexture(); + } +} + +bool LLPanelFace::menuEnableItem(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + // paste options + if (command == "color_paste") + { + return mClipboardParams.has("color"); + } + else if (command == "texture_paste") + { + return mClipboardParams.has("texture"); + } + return false; +} + // TODO: I don't know who put these in or what these are for??? void LLPanelFace::setMediaURL(const std::string& url) -- cgit v1.2.3 From 8590a8efe628bff36fe9a564a5a437b567df4f55 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 19 Jun 2020 22:45:20 +0300 Subject: SL-13359 #9.5 Texture tab --- indra/newview/llpanelface.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 6b5d14300f..f4122cac5f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -38,6 +38,7 @@ #include "llfontgl.h" // project includes +#include "llagent.h" #include "llagentdata.h" #include "llbutton.h" #include "llcheckboxctrl.h" @@ -45,7 +46,9 @@ #include "llcombobox.h" #include "lldrawpoolbump.h" #include "llface.h" +#include "llinventoryfunctions.h" #include "llinventorymodel.h" // gInventory +#include "llinventorymodelbackgroundfetch.h" #include "lllineeditor.h" #include "llmaterialmgr.h" #include "llmediaentry.h" @@ -2773,9 +2776,6 @@ void LLPanelFace::onCopyTexture() // no need to record item id if full_perm==true if (!full_perm && item_id.notNull()) { - //Todo: - // also same thing probably needs to be present in object and volume panels for sculpt and projector images - /* LLViewerInventoryItem* itemp = gInventory.getItem(item_id); if (itemp) { @@ -2793,7 +2793,6 @@ void LLPanelFace::onCopyTexture() } } } - */ } } } @@ -2901,11 +2900,12 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) } } } - //todo: // for case when item got removed from inventory after we pressed 'copy' - /*if (!itemp_res && !full_perm) + // or texture got pasted into previous object + if (!itemp_res && !full_perm) { - // todo: fix this, we are often searching same tuxter multiple times (equal to number of faces) + // Todo: fix this, we are often searching same texture multiple times (equal to number of faces) + // Perhaps just mPanelFace->onPasteTexture(objectp, te, &asset_to_item_id_map); ? Not pretty, but will work LLViewerInventoryCategory::cat_array_t cats; LLViewerInventoryItem::item_array_t items; LLAssetIDMatches asset_id_matches(imageid); @@ -2933,7 +2933,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) } } } - }*/ + } if (itemp_res) { @@ -3013,7 +3013,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) LLSelectedTEMaterial::setAlphaMaskCutoff(this, (U8)te_data["material"]["SpecRot"].asInteger(), te, object_id); // Normal - // Replace placeholders with target's + // Replace placeholders with target's if (te_data["material"].has("NormMapNoCopy")) { LLMaterialPtr material = tep->getMaterialParams(); -- cgit v1.2.3 From 23f20c207d1e69c03e2ce2cb9100ad216ac60708 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 23 Jun 2020 22:02:33 +0300 Subject: SL-12688 Warnings part #1 --- indra/newview/llpanelface.cpp | 299 +++++++++++++++++++++++++++++------------- 1 file changed, 205 insertions(+), 94 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f4122cac5f..3849e5c8f7 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2579,6 +2579,80 @@ void LLPanelFace::onAlignTexture(void* userdata) self->alignTestureLayer(); } +enum EPasteMode +{ + PASTE_COLOR, + PASTE_TEXTURE +}; + +struct LLPanelFacePasteTexFunctor : public LLSelectedTEFunctor +{ + LLPanelFacePasteTexFunctor(LLPanelFace* panel, EPasteMode mode) : + mPanelFace(panel), mMode(mode) {} + + virtual bool apply(LLViewerObject* objectp, S32 te) + { + switch (mMode) + { + case PASTE_COLOR: + mPanelFace->onPasteColor(objectp, te); + break; + case PASTE_TEXTURE: + mPanelFace->onPasteTexture(objectp, te); + break; + } + return true; + } +private: + LLPanelFace *mPanelFace; + EPasteMode mMode; +}; + +struct LLPanelFaceUpdateFunctor : public LLSelectedObjectFunctor +{ + LLPanelFaceUpdateFunctor(bool update_media) : mUpdateMedia(update_media) {} + virtual bool apply(LLViewerObject* object) + { + object->sendTEUpdate(); + if (mUpdateMedia) + { + LLVOVolume *vo = dynamic_cast(object); + if (vo && vo->hasMedia()) + { + vo->sendMediaDataUpdate(); + } + } + return true; + } +private: + bool mUpdateMedia; +}; + +struct LLPanelFaceNavigateHomeFunctor : public LLSelectedTEFunctor +{ + virtual bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && objectp->getTE(te)) + { + LLTextureEntry* tep = objectp->getTE(te); + const LLMediaEntry *media_data = tep->getMediaData(); + if (media_data) + { + if (media_data->getCurrentURL().empty() && media_data->getAutoPlay()) + { + viewer_media_t media_impl = + LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); + if (media_impl) + { + media_impl->navigateHome(); + } + } + } + } + return true; + } +}; + void LLPanelFace::onCopyColor() { LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); @@ -2625,12 +2699,74 @@ void LLPanelFace::onCopyColor() } } -void LLPanelFace::onPasteColor(LLViewerObject* objectp, S32 te) +void LLPanelFace::onPasteColor() { if (!mClipboardParams.has("color")) { return; } + + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + if (!objectp || !node + || objectp->getPCode() != LL_PCODE_VOLUME + || !objectp->permModify() + || objectp->isPermanentEnforced() + || selected_count > 1) + { + // not supposed to happen + LL_WARNS() << "Failed to paste color due to missing or wrong selection" << LL_ENDL; + return; + } + + bool face_selection_mode = LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool(); + LLSD &clipboard = mClipboardParams["color"]; // array + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + S32 compare_tes = num_tes; + + if (face_selection_mode) + { + compare_tes = 0; + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + compare_tes++; + } + } + } + + // we can copy if single face was copied in edit face mode or if face count matches + if (!((clipboard.size() == 1) && mClipboardParams["color_all_tes"].asBoolean()) + && compare_tes != clipboard.size()) + { + LLSD notif_args; + if (face_selection_mode) + { + static std::string reason = getString("paste_error_face_selection_mismatch"); + notif_args["REASON"] = reason; + } + else + { + static std::string reason = getString("paste_error_object_face_count_mismatch"); + notif_args["REASON"] = reason; + } + LLNotificationsUtil::add("FacePasteFailed", notif_args); + return; + } + + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + + LLPanelFacePasteTexFunctor paste_func(this, PASTE_COLOR); + selected_objects->applyToTEs(&paste_func); + + LLPanelFaceUpdateFunctor sendfunc(false); + selected_objects->applyToObjects(&sendfunc); +} + +void LLPanelFace::onPasteColor(LLViewerObject* objectp, S32 te) +{ LLSD te_data; LLSD &clipboard = mClipboardParams["color"]; // array if ((clipboard.size() == 1) && mClipboardParams["color_all_tes"].asBoolean()) @@ -2687,7 +2823,6 @@ void LLPanelFace::onPasteColor(LLViewerObject* objectp, S32 te) void LLPanelFace::onCopyTexture() { - LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); @@ -2854,12 +2989,77 @@ void LLPanelFace::onCopyTexture() } } -void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) +void LLPanelFace::onPasteTexture() { if (!mClipboardParams.has("texture")) { return; } + + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(); + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + if (!objectp || !node + || objectp->getPCode() != LL_PCODE_VOLUME + || !objectp->permModify() + || objectp->isPermanentEnforced() + || selected_count > 1) + { + // not supposed to happen + LL_WARNS() << "Failed to paste texture due to missing or wrong selection" << LL_ENDL; + return; + } + + bool face_selection_mode = LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool(); + LLSD &clipboard = mClipboardParams["texture"]; // array + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + S32 compare_tes = num_tes; + + if (face_selection_mode) + { + compare_tes = 0; + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + compare_tes++; + } + } + } + + // we can copy if single face was copied in edit face mode or if face count matches + if (!((clipboard.size() == 1) && mClipboardParams["texture_all_tes"].asBoolean()) + && compare_tes != clipboard.size()) + { + LLSD notif_args; + if (face_selection_mode) + { + static std::string reason = getString("paste_error_face_selection_mismatch"); + notif_args["REASON"] = reason; + } + else + { + static std::string reason = getString("paste_error_object_face_count_mismatch"); + notif_args["REASON"] = reason; + } + LLNotificationsUtil::add("FacePasteFailed", notif_args); + return; + } + + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + + LLPanelFacePasteTexFunctor paste_func(this, PASTE_TEXTURE); + selected_objects->applyToTEs(&paste_func); + + LLPanelFaceUpdateFunctor sendfunc(true); + selected_objects->applyToObjects(&sendfunc); + + LLPanelFaceNavigateHomeFunctor navigate_home_func; + selected_objects->applyToTEs(&navigate_home_func); +} + +void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) +{ LLSD te_data; LLSD &clipboard = mClipboardParams["texture"]; // array if ((clipboard.size() == 1) && mClipboardParams["texture_all_tes"].asBoolean()) @@ -3066,80 +3266,6 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) } } -enum EPasteMode -{ - PASTE_COLOR, - PASTE_TEXTURE -}; - -struct LLPanelFacePasteTexFunctor : public LLSelectedTEFunctor -{ - LLPanelFacePasteTexFunctor(LLPanelFace* panel, EPasteMode mode) : - mPanelFace(panel), mMode(mode) {} - - virtual bool apply(LLViewerObject* objectp, S32 te) - { - switch (mMode) - { - case PASTE_COLOR: - mPanelFace->onPasteColor(objectp, te); - break; - case PASTE_TEXTURE: - mPanelFace->onPasteTexture(objectp, te); - break; - } - return true; - } -private: - LLPanelFace *mPanelFace; - EPasteMode mMode; -}; - -struct LLPanelFaceUpdateFunctor : public LLSelectedObjectFunctor -{ - LLPanelFaceUpdateFunctor(bool update_media) : mUpdateMedia(update_media) {} - virtual bool apply(LLViewerObject* object) - { - object->sendTEUpdate(); - if (mUpdateMedia) - { - LLVOVolume *vo = dynamic_cast(object); - if (vo && vo->hasMedia()) - { - vo->sendMediaDataUpdate(); - } - } - return true; - } -private: - bool mUpdateMedia; -}; - -struct LLPanelFaceNavigateHomeFunctor : public LLSelectedTEFunctor -{ - virtual bool apply(LLViewerObject* objectp, S32 te) - { - if (objectp && objectp->getTE(te)) - { - LLTextureEntry* tep = objectp->getTE(te); - const LLMediaEntry *media_data = tep->getMediaData(); - if (media_data) - { - if (media_data->getCurrentURL().empty() && media_data->getAutoPlay()) - { - viewer_media_t media_impl = - LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getMediaData()->getMediaID()); - if (media_impl) - { - media_impl->navigateHome(); - } - } - } - } - return true; - } -}; - void LLPanelFace::menuDoToSelected(const LLSD& userdata) { std::string command = userdata.asString(); @@ -3147,26 +3273,11 @@ void LLPanelFace::menuDoToSelected(const LLSD& userdata) // paste if (command == "color_paste") { - LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); - - LLPanelFacePasteTexFunctor paste_func(this, PASTE_COLOR); - selected_objects->applyToTEs(&paste_func); - - LLPanelFaceUpdateFunctor sendfunc(false); - selected_objects->applyToObjects(&sendfunc); + onPasteColor(); } else if (command == "texture_paste") { - LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); - - LLPanelFacePasteTexFunctor paste_func(this, PASTE_TEXTURE); - selected_objects->applyToTEs(&paste_func); - - LLPanelFaceUpdateFunctor sendfunc(true); - selected_objects->applyToObjects(&sendfunc); - - LLPanelFaceNavigateHomeFunctor navigate_home_func; - selected_objects->applyToTEs(&navigate_home_func); + onPasteTexture(); } // copy else if (command == "color_copy") -- cgit v1.2.3 From f3216ca1cd6e63a254123635c18ba661297e8eef Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 24 Jun 2020 18:57:49 +0300 Subject: SL-12688 Warnings part #2 --- indra/newview/llpanelface.cpp | 64 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 3849e5c8f7..641a3602c8 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2869,7 +2869,8 @@ void LLPanelFace::onCopyTexture() { LLUUID item_id; LLUUID id = te_data["te"]["imageid"].asUUID(); - bool full_perm = get_is_library_texture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + bool from_library = get_is_predefined_texture(id); + bool full_perm = from_library || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); if (id.notNull() && !full_perm) { @@ -2890,6 +2891,12 @@ void LLPanelFace::onCopyTexture() } } + if (item_id.notNull() && gInventory.isObjectDescendentOf(item_id, gInventory.getLibraryRootFolderID())) + { + full_perm = true; + from_library = true; + } + if (id.isNull() || (!full_perm && item_id.isNull())) { @@ -2899,10 +2906,15 @@ void LLPanelFace::onCopyTexture() te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); } te_data["te"]["itemfullperm"] = true; + te_data["te"]["fromlibrary"] = true; } else { te_data["te"]["itemfullperm"] = full_perm; + // from_library is unreliable since we don't get texture item if source object + // is fullperm but it merely means additional checks when assigning texture + te_data["te"]["fromlibrary"] = from_library; + // If full permission object, texture is free to copy, // but otherwise we need to check inventory and extract permissions // @@ -3046,6 +3058,40 @@ void LLPanelFace::onPasteTexture() return; } + bool full_perm = true; + LLSD::array_const_iterator iter = clipboard.beginArray(); + LLSD::array_const_iterator end = clipboard.endArray(); + for (; iter != end; ++iter) + { + const LLSD& te_data = *iter; + if (te_data.has("te")) + { + full_perm &= te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); + if (te_data["te"].has("imageitemid")) + { + LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); + if (item_id.notNull()) + { + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (!itemp) + { + // image might be in object's inventory, but it can be not up to date + LLSD notif_args; + static std::string reason = getString("paste_error_inventory_not_found"); + notif_args["REASON"] = reason; + LLNotificationsUtil::add("FacePasteFailed", notif_args); + return; + } + } + } + } + } + + if (!full_perm) + { + LLNotificationsUtil::add("FacePasteTexturePermissions"); + } + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); LLPanelFacePasteTexFunctor paste_func(this, PASTE_TEXTURE); @@ -3082,6 +3128,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) { // Texture bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); + bool from_library = te_data["te"].has("fromlibrary") && te_data["te"]["fromlibrary"].asBoolean(); if (te_data["te"].has("imageid")) { const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); //texture or asset id @@ -3098,12 +3145,21 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) // dropTextureAllFaces will fail if incomplete itemp_res = itemp; } + else + { + // Theoretically shouldn't happend, but if it does happen, we + // might need to add a notification to user that paste will fail + // since inventory isn't fully loaded + LL_WARNS() << "Item " << item_id << " is incomplete, paste might fail silently." << LL_ENDL; + } } } // for case when item got removed from inventory after we pressed 'copy' // or texture got pasted into previous object if (!itemp_res && !full_perm) { + // Due to checks for imageitemid in LLPanelFace::onPasteTexture() this should no longer be reachable. + LL_INFOS() << "Item " << te_data["te"]["imageitemid"].asUUID() << " no longer in inventory." << LL_ENDL; // Todo: fix this, we are often searching same texture multiple times (equal to number of faces) // Perhaps just mPanelFace->onPasteTexture(objectp, te, &asset_to_item_id_map); ? Not pretty, but will work LLViewerInventoryCategory::cat_array_t cats; @@ -3137,11 +3193,13 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) if (itemp_res) { + // from_library is unreliable since we don't get texture item if object is + // fullperm but it merely means additional checks when assigning texture if (te == -1) // all faces { LLToolDragAndDrop::dropTextureAllFaces(objectp, itemp_res, - LLToolDragAndDrop::SOURCE_AGENT, + from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } else // one face @@ -3149,7 +3207,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) LLToolDragAndDrop::dropTextureOneFace(objectp, te, itemp_res, - LLToolDragAndDrop::SOURCE_AGENT, + from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } } -- cgit v1.2.3 From 46b037aabd90bd673061d7dc7576b71eb91a3b9b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 25 Jun 2020 23:34:22 +0300 Subject: SL-12688 Restored stricter permission requirements You need to own texture in inventory to be able to copy it --- indra/newview/llpanelface.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 641a3602c8..4249a13827 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2870,7 +2870,7 @@ void LLPanelFace::onCopyTexture() LLUUID item_id; LLUUID id = te_data["te"]["imageid"].asUUID(); bool from_library = get_is_predefined_texture(id); - bool full_perm = from_library || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + bool full_perm = from_library; if (id.notNull() && !full_perm) { @@ -2911,8 +2911,6 @@ void LLPanelFace::onCopyTexture() else { te_data["te"]["itemfullperm"] = full_perm; - // from_library is unreliable since we don't get texture item if source object - // is fullperm but it merely means additional checks when assigning texture te_data["te"]["fromlibrary"] = from_library; // If full permission object, texture is free to copy, @@ -2921,7 +2919,7 @@ void LLPanelFace::onCopyTexture() // Normally we care only about restrictions for current user and objects // don't inherit any 'next owner' permissions from texture, so there is // no need to record item id if full_perm==true - if (!full_perm && item_id.notNull()) + if (!full_perm && !from_library && item_id.notNull()) { LLViewerInventoryItem* itemp = gInventory.getItem(item_id); if (itemp) @@ -3193,8 +3191,6 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) if (itemp_res) { - // from_library is unreliable since we don't get texture item if object is - // fullperm but it merely means additional checks when assigning texture if (te == -1) // all faces { LLToolDragAndDrop::dropTextureAllFaces(objectp, -- cgit v1.2.3 From ccf51f173ca80215e5ecb02cdb04724374349de9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 Jul 2020 17:21:09 +0300 Subject: SL-12334 Texture UUID is not copied to clipboard from a full-perms object --- indra/newview/llpanelface.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 4249a13827..091ea3764d 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2872,6 +2872,20 @@ void LLPanelFace::onCopyTexture() bool from_library = get_is_predefined_texture(id); bool full_perm = from_library; + if (!full_perm + && objectp->permCopy() + && objectp->permTransfer() + && objectp->permModify()) + { + // If agent created this object and nothing is limiting permissions, mark as full perm + // If agent was granted permission to edit objects owned and created by somebody else, mark full perm + // This check is not perfect since we can't figure out whom textures belong to so this ended up restrictive + std::string creator_app_link; + LLUUID creator_id; + LLSelectMgr::getInstance()->selectGetCreator(creator_id, creator_app_link); + full_perm = objectp->mOwnerID == creator_id; + } + if (id.notNull() && !full_perm) { std::map::iterator iter = asset_item_map.find(id); @@ -3056,7 +3070,7 @@ void LLPanelFace::onPasteTexture() return; } - bool full_perm = true; + bool full_perm_object = true; LLSD::array_const_iterator iter = clipboard.beginArray(); LLSD::array_const_iterator end = clipboard.endArray(); for (; iter != end; ++iter) @@ -3064,8 +3078,9 @@ void LLPanelFace::onPasteTexture() const LLSD& te_data = *iter; if (te_data.has("te")) { - full_perm &= te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); - if (te_data["te"].has("imageitemid")) + bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); + full_perm_object &= full_perm; + if (!full_perm && te_data["te"].has("imageitemid")) { LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); if (item_id.notNull()) @@ -3085,7 +3100,7 @@ void LLPanelFace::onPasteTexture() } } - if (!full_perm) + if (!full_perm_object) { LLNotificationsUtil::add("FacePasteTexturePermissions"); } -- cgit v1.2.3 From 3fde31b61026f9052243a5a716dbc0a6419880ae Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 2 Jul 2020 18:36:19 +0300 Subject: SL-12688 Fixed Warning --- indra/newview/llpanelface.cpp | 50 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 091ea3764d..a3f9acb85a 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2911,18 +2911,6 @@ void LLPanelFace::onCopyTexture() from_library = true; } - if (id.isNull() - || (!full_perm && item_id.isNull())) - { - if (!LLLocalBitmapMgr::getInstance()->isLocal(id)) - { - te_data["te"].erase("imageid"); - te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); - } - te_data["te"]["itemfullperm"] = true; - te_data["te"]["fromlibrary"] = true; - } - else { te_data["te"]["itemfullperm"] = full_perm; te_data["te"]["fromlibrary"] = from_library; @@ -3076,26 +3064,40 @@ void LLPanelFace::onPasteTexture() for (; iter != end; ++iter) { const LLSD& te_data = *iter; - if (te_data.has("te")) + if (te_data.has("te") && te_data["te"].has("imageid")) { bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); full_perm_object &= full_perm; - if (!full_perm && te_data["te"].has("imageitemid")) + if (!full_perm) { - LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); - if (item_id.notNull()) + if (te_data["te"].has("imageitemid")) { - LLViewerInventoryItem* itemp = gInventory.getItem(item_id); - if (!itemp) + LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); + if (item_id.notNull()) { - // image might be in object's inventory, but it can be not up to date - LLSD notif_args; - static std::string reason = getString("paste_error_inventory_not_found"); - notif_args["REASON"] = reason; - LLNotificationsUtil::add("FacePasteFailed", notif_args); - return; + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (!itemp) + { + // image might be in object's inventory, but it can be not up to date + LLSD notif_args; + static std::string reason = getString("paste_error_inventory_not_found"); + notif_args["REASON"] = reason; + LLNotificationsUtil::add("FacePasteFailed", notif_args); + return; + } } } + else + { + // Item was not found on 'copy' stage + // Since this happened at copy, might be better to either show this + // at copy stage or to drop clipboard here + LLSD notif_args; + static std::string reason = getString("paste_error_inventory_not_found"); + notif_args["REASON"] = reason; + LLNotificationsUtil::add("FacePasteFailed", notif_args); + return; + } } } } -- cgit v1.2.3 From bbdbd6c2dd79adc4749e24c88c9f04755a4b12a1 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 15 Apr 2022 22:14:38 +0300 Subject: SL-17204 FIXED The texture with full permissions is settled on the prim after copying texture from the object with texture with no transfer permission --- indra/newview/llpanelface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 2ac5022695..f50f587f8f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2873,7 +2873,12 @@ void LLPanelFace::onCopyTexture() // as result it is Hightly unreliable, leaves little control to user, borderline hack // but there are little options to preserve permissions - multiple inventory // items might reference same asset and inventory search is expensive. - item_id = get_copy_free_item_by_asset_id(id); + bool no_transfer = false; + if (objectp->getInventoryItemByAsset(id)) + { + no_transfer = !objectp->getInventoryItemByAsset(id)->getIsFullPerm(); + } + item_id = get_copy_free_item_by_asset_id(id, no_transfer); // record value to avoid repeating inventory search when possible asset_item_map[id] = item_id; } -- cgit v1.2.3 From 2445525cc573024f8eb64cabac1e6e3dc3362085 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 19 Apr 2022 02:33:59 +0300 Subject: SL-17231 Copying textures should be disabled if object content was not yet updated --- indra/newview/llpanelface.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f50f587f8f..d50d42bf2f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -330,6 +330,13 @@ LLPanelFace::~LLPanelFace() } +void LLPanelFace::draw() +{ + updateCopyTexButton(); + + LLPanel::draw(); +} + void LLPanelFace::sendTexture() { LLTextureCtrl* mTextureCtrl = getChild("texture control"); @@ -1522,7 +1529,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); BOOL single_volume = (selected_count == 1); mMenuClipboardColor->setEnabled(editable && single_volume); - mMenuClipboardTexture->setEnabled(editable && single_volume); // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); @@ -1583,6 +1589,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } +void LLPanelFace::updateCopyTexButton() +{ + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + mMenuClipboardTexture->setEnabled(objectp && objectp->getPCode() == LL_PCODE_VOLUME && objectp->permModify() + && !objectp->isPermanentEnforced() && !objectp->isInventoryPending() + && (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1)); + std::string tooltip = (objectp && objectp->isInventoryPending()) ? LLTrans::getString("LoadingContents") : getString("paste_options"); + mMenuClipboardTexture->setToolTip(tooltip); + +} + void LLPanelFace::refresh() { LL_DEBUGS("Materials") << LL_ENDL; -- cgit v1.2.3 From 8112cefa731031dc1d06b98b119e177ea7be6a25 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 26 Apr 2022 19:07:39 +0300 Subject: SL-16026 FIXED Copying only one diffuse texture allows pasting this texture into other types of textures --- indra/newview/llpanelface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelface.cpp') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index d50d42bf2f..7fe5b1dd3f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -3217,7 +3217,8 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) te, itemp_res, from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT, - LLUUID::null); + LLUUID::null, + 0); } } // not an inventory item or no complete items -- cgit v1.2.3