diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 0c1b119328..bc519ed7ef 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1919,8 +1919,52 @@ bool LLObjectSelection::applyRestrictedPbrMaterialToTEs(LLViewerInventoryItem* i //----------------------------------------------------------------------------- // selectionSetImage() //----------------------------------------------------------------------------- +// Allow editing of non-PBR materials in-situ +template +struct TextureApplyFunctor : public LLSelectedTEFunctor +{ + LLViewerInventoryItem* mItem; + LLUUID mImageID; + TextureApplyFunctor(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {} + bool apply(LLViewerObject* objectp, S32 te) override + { + 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) + { + return false; + } + } + + if (mItem) + { + if constexpr (IsPBR) + { + LLToolDragAndDrop::dropTextureOneFace(objectp, te, mItem, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null, false); + } + else + { + LLToolDragAndDrop::dropTextureOneFace(objectp, te, mItem, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null, false, -2); // -2 means no PBR + } + } + else // not an inventory item + { + objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE)); + } + + return true; + } +}; +// // *TODO: re-arch texture applying out of lltooldraganddrop -bool LLSelectMgr::selectionSetImage(const LLUUID& imageid) +bool LLSelectMgr::selectionSetImage(const LLUUID& imageid, bool isPBR) { // First for (no copy) textures and multiple object selection LLViewerInventoryItem* item = gInventory.getItem(imageid); @@ -1935,60 +1979,73 @@ bool LLSelectMgr::selectionSetImage(const LLUUID& imageid) return false; } - struct f : public LLSelectedTEFunctor - { - LLViewerInventoryItem* mItem; - LLUUID mImageID; - f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {} - bool apply(LLViewerObject* objectp, S32 te) - { - if(!objectp || !objectp->permModify()) - { - return false; - } + // Allow editing of non-PBR materials in-situ + // struct f : public LLSelectedTEFunctor + // { + // LLViewerInventoryItem* mItem; + // LLUUID mImageID; + // f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mImageID(id) {} + // bool apply(LLViewerObject* objectp, S32 te) + // { + // 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; - } - } + // // 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, - te, - mItem, - LLToolDragAndDrop::SOURCE_AGENT, - LLUUID::null, - false); - } - else // not an inventory item - { - // Texture picker defaults aren't inventory items - // * Don't need to worry about permissions for them - // * Can just apply the texture and be done with it. - objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE)); - } - - return true; - } - }; + // if (mItem) + // { + // LLToolDragAndDrop::dropTextureOneFace(objectp, + // te, + // mItem, + // LLToolDragAndDrop::SOURCE_AGENT, + // LLUUID::null, + // false); + // } + // else // not an inventory item + // { + // // Texture picker defaults aren't inventory items + // // * Don't need to worry about permissions for them + // // * Can just apply the texture and be done with it. + // objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE)); + // } + // return true; + // } + // }; + // if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { getSelection()->applyNoCopyTextureToTEs(item); } else { - f setfunc(item, imageid); - getSelection()->applyToTEs(&setfunc); + // Allow editing of non-PBR materials in-situ + // f setfunc(item, imageid); + // getSelection()->applyToTEs(&setfunc); + TextureApplyFunctor setfuncPBR(item, imageid); // For PBR textures + TextureApplyFunctor setfuncBP(item, imageid); // For non-PBR textures + if(isPBR) + { + getSelection()->applyToTEs(&setfuncPBR); + } + else + { + getSelection()->applyToTEs(&setfuncBP); + } + // } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 0902fc1b39..5bea652f10 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -717,7 +717,7 @@ public: void selectionSetDensity(F32 density); void selectionSetRestitution(F32 restitution); void selectionSetMaterial(U8 material); - bool selectionSetImage(const LLUUID& imageid); // could be item or asset id + bool selectionSetImage(const LLUUID& imageid, bool isPBR=true); // inject PBR awareness. bool selectionSetGLTFMaterial(const LLUUID& mat_id); // material id only void selectionSetColor(const LLColor4 &color); void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 6617f19d6e..6a115f4021 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1467,7 +1467,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, LLUUID asset_id = item->getAssetUUID(); - if (hit_obj->getRenderMaterialID(hit_face).notNull() && !remove_pbr) + if (hit_obj->getRenderMaterialID(hit_face).notNull() && !remove_pbr && tex_channel >= -1) // tex_channel -2 means ignorePBR then treat as -1, don't judge me. { // Overrides require textures to be copy and transfer free LLPermissions item_permissions = item->getPermissions(); @@ -1493,6 +1493,12 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, } return; } + // tex_channel -2 means ignorePBR then treat as -1 + if(tex_channel < -1) + { + tex_channel = -1; + } + // BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id); if (!success) {