From 97ee8b207bf43a8acb3f2702d26eb5f3b7471e45 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 19 Sep 2023 00:54:14 +0300 Subject: SL-5522 Fix applying textuers and materials with limited restrictions to attachments 1. Texture picker now updates filter's permissions based on selection 2. Various panels now properly check permissions --- indra/newview/llpanelface.cpp | 40 ++++++++++++++++++++++++++ indra/newview/llpanelvolume.cpp | 22 ++++++++++++++ indra/newview/llselectmgr.cpp | 57 ++++++++++++++++++++++++++++++++++--- indra/newview/lltexturectrl.cpp | 17 +++++++++++ indra/newview/lltexturectrl.h | 4 +-- indra/newview/lltooldraganddrop.cpp | 2 ++ 6 files changed, 136 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index df464bc7e5..e1f08915fa 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1010,6 +1010,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) && objectp->permModify()) { BOOL editable = objectp->permModify() && !objectp->isPermanentEnforced(); + BOOL attachment = objectp->isAttachment(); bool has_pbr_material; bool has_faces_without_pbr; @@ -1306,6 +1307,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) texture_ctrl->setBakeTextureEnabled(TRUE); } + + if (attachment) + { + // attachments are in world and in inventory, + // server doesn't support changing permissions + // in such case + texture_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + } + else + { + texture_ctrl->setImmediateFilterPermMask(PERM_NONE); + } } if (shinytexture_ctrl) @@ -1313,6 +1326,15 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) shinytexture_ctrl->setTentative( !identical_spec ); shinytexture_ctrl->setEnabled( editable && !has_pbr_material); shinytexture_ctrl->setImageAssetID( specmap_id ); + + if (attachment) + { + shinytexture_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + } + else + { + shinytexture_ctrl->setImmediateFilterPermMask(PERM_NONE); + } } if (bumpytexture_ctrl) @@ -1320,6 +1342,15 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bumpytexture_ctrl->setTentative( !identical_norm ); bumpytexture_ctrl->setEnabled( editable && !has_pbr_material); bumpytexture_ctrl->setImageAssetID( normmap_id ); + + if (attachment) + { + bumpytexture_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + } + else + { + bumpytexture_ctrl->setImmediateFilterPermMask(PERM_NONE); + } } } @@ -1904,6 +1935,15 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE); pbr_ctrl->setEnabled(settable); pbr_ctrl->setImageAssetID(pbr_id); + + if (objectp->isAttachment()) + { + pbr_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER | PERM_MODIFY); + } + else + { + pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); + } } getChildView("pbr_from_inventory")->setEnabled(settable); diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index ed244f773c..d6c36bbfb7 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -365,6 +365,15 @@ void LLPanelVolume::getState( ) { LightTextureCtrl->setEnabled(FALSE); LightTextureCtrl->setValid(FALSE); + + if (objectp->isAttachment()) + { + LightTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + } + else + { + LightTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + } } getChildView("Light Intensity")->setEnabled(false); @@ -1409,6 +1418,19 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item if (volobjp) { LLViewerInventoryItem* item = gInventory.getItem(item_id); + + if (item && volobjp->isAttachment()) + { + const LLPermissions& perm = item->getPermissions(); + BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; + if (!unrestricted) + { + // Attachments are in world and in inventory simultaneously, + // at the moment server doesn't support such a situation. + return; + } + } + if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { LLToolDragAndDrop::handleDropMaterialProtections(volobjp, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 6692d124d8..ecc2783eb1 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1852,10 +1852,24 @@ bool LLSelectMgr::selectionSetImage(const LLUUID& imageid) f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {} bool apply(LLViewerObject* objectp, S32 te) { - if(objectp && !objectp->permModify()) + if(!objectp || !objectp->permModify()) { return false; } + + // Might be better to run willObjectAcceptInventory + if (mItem && objectp->isAttachment()) + { + const LLPermissions& perm = mItem->getPermissions(); + BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; + if (!unrestricted) + { + // Attachments are in world and in inventory simultaneously, + // at the moment server doesn't support such a situation. + return false; + } + } + if (mItem) { LLToolDragAndDrop::dropTextureOneFace(objectp, @@ -1938,10 +1952,21 @@ bool LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mMatId(id) {} bool apply(LLViewerObject* objectp, S32 te) { - if (objectp && !objectp->permModify()) + if (!objectp || !objectp->permModify()) { return false; } + if (mItem && objectp->isAttachment()) + { + const LLPermissions& perm = mItem->getPermissions(); + BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; + if (!unrestricted) + { + // Attachments are in world and in inventory simultaneously, + // at the moment server doesn't support such a situation. + return false; + } + } LLUUID asset_id = mMatId; if (mItem) { @@ -2256,7 +2281,19 @@ void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id) if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { LLViewerObject *object = mSelectedObjects->getFirstRootObject(); - if (!object) return; + if (!object) + { + return; + } + const LLPermissions& perm = item->getPermissions(); + BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; + BOOL attached = object->isAttachment(); + if (attached && !unrestricted) + { + // Attachments are in world and in inventory simultaneously, + // at the moment server doesn't support such a situation. + return; + } LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } getSelection()->applyToTEs(&setfunc); @@ -2316,7 +2353,19 @@ void LLSelectMgr::selectionSetShiny(U8 shiny, const LLUUID &image_id) if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { LLViewerObject *object = mSelectedObjects->getFirstRootObject(); - if (!object) return; + if (!object) + { + return; + } + const LLPermissions& perm = item->getPermissions(); + BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; + BOOL attached = object->isAttachment(); + if (attached && !unrestricted) + { + // Attachments are in world and in inventory simultaneously, + // at the moment server doesn't support such a situation. + return; + } LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } getSelection()->applyToTEs(&setfunc); diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index c13376d0a6..7e399a6808 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -1339,6 +1339,12 @@ void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryT } } +void LLFloaterTexturePicker::setImmediateFilterPermMask(PermissionMask mask) +{ + mImmediateFilterPermMask = mask; + mInventoryPanel->setFilterPermMask(mask); +} + void LLFloaterTexturePicker::onPickerCallback(const std::vector& filenames, LLHandle handle) { std::vector::const_iterator iter = filenames.begin(); @@ -1526,6 +1532,17 @@ void LLTextureCtrl::setCanApply(bool can_preview, bool can_apply) } } +void LLTextureCtrl::setImmediateFilterPermMask(PermissionMask mask) +{ + mImmediateFilterPermMask = mask; + + LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + if (floaterp) + { + floaterp->setImmediateFilterPermMask(mask); + } +} + void LLTextureCtrl::setVisible( BOOL visible ) { if( !visible ) diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index ba310dd9a6..d82a167c93 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -184,8 +184,7 @@ public: void setCanApply(bool can_preview, bool can_apply); - void setImmediateFilterPermMask(PermissionMask mask) - { mImmediateFilterPermMask = mask; } + void setImmediateFilterPermMask(PermissionMask mask); void setDnDFilterPermMask(PermissionMask mask) { mDnDFilterPermMask = mask; } PermissionMask getImmediateFilterPermMask() { return mImmediateFilterPermMask; } @@ -351,6 +350,7 @@ public: void setBakeTextureEnabled(BOOL enabled); void setInventoryPickType(LLTextureCtrl::EPickInventoryType type); + void setImmediateFilterPermMask(PermissionMask mask); static void onPickerCallback(const std::vector& filenames, LLHandle handle); diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index afcdb26f1a..1b65439b2b 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1648,6 +1648,8 @@ EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LL BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; if(attached && !unrestricted) { + // Attachments are in world and in inventory simultaneously, + // at the moment server doesn't support such a situation. return ACCEPT_NO_LOCKED; } else if(modify && transfer && volume && !worn) -- cgit v1.2.3