From 6403f1526f91d81095ebe0cb648ba8af8953e2d0 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 10 Jan 2023 15:10:44 +0200 Subject: SL-18932 Canceling in material picker removes dropped material --- indra/newview/llselectmgr.cpp | 1 - indra/newview/lltooldraganddrop.cpp | 77 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 4a69eba4d3..61f9d3d6d0 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -5862,7 +5862,6 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data if (can_copy && can_transfer) { - // this should be the only place that saved textures is called node->saveTextures(texture_ids); } diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index cde33a5f96..53bc77daa9 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -2080,24 +2080,101 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject( { if (cargo_type == DAD_TEXTURE) { + LLSelectNode *nodep = nullptr; + if (obj->isSelected()) + { + // update object's saved textures + nodep = LLSelectMgr::getInstance()->getSelection()->findNode(obj); + } + if((mask & MASK_SHIFT)) { dropTextureAllFaces(obj, item, mSource, mSourceID); + + // If user dropped a texture onto face it implies + // applying texture now without cancel, save to selection + if (nodep) + { + uuid_vec_t texture_ids; + S32 num_faces = obj->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + LLViewerTexture *tex = obj->getTEImage(face); + if (tex != nullptr) + { + texture_ids.push_back(tex->getID()); + } + else + { + texture_ids.push_back(LLUUID::null); + } + } + nodep->saveTextures(texture_ids); + } } else { dropTextureOneFace(obj, face, item, mSource, mSourceID); + + // If user dropped a texture onto face it implies + // applying texture now without cancel, save to selection + LLPanelFace* panel_face = gFloaterTools->getPanelFace(); + if (nodep + && gFloaterTools->getVisible() + && panel_face + && panel_face->getTextureDropChannel() == 0 /*texture*/ + && nodep->mSavedGLTFMaterialIds.size() > face) + { + LLViewerTexture *tex = obj->getTEImage(face); + if (tex != nullptr) + { + nodep->mSavedTextures[face] = tex->getID(); + } + else + { + nodep->mSavedTextures[face] = LLUUID::null; + } + } } } else if (cargo_type == DAD_MATERIAL) { + LLSelectNode *nodep = nullptr; + if (obj->isSelected()) + { + // update object's saved materials + nodep = LLSelectMgr::getInstance()->getSelection()->findNode(obj); + } + + // If user dropped a material onto face it implies + // applying texture now without cancel, save to selection if ((mask & MASK_SHIFT)) { dropMaterialAllFaces(obj, item, mSource, mSourceID); + + if (nodep) + { + uuid_vec_t material_ids; + S32 num_faces = obj->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + material_ids.push_back(obj->getRenderMaterialID(face)); + } + nodep->saveGLTFMaterialIds(material_ids); + } } else { dropMaterialOneFace(obj, face, item, mSource, mSourceID); + + // If user dropped a material onto face it implies + // applying texture now without cancel, save to selection + if (nodep + && gFloaterTools->getVisible() + && nodep->mSavedGLTFMaterialIds.size() > face) + { + nodep->mSavedGLTFMaterialIds[face] = obj->getRenderMaterialID(face); + } } } else if (cargo_type == DAD_MESH) -- cgit v1.2.3