From 414efe56bdf061edddd9026b015f6197c7615577 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 27 Oct 2022 21:35:46 +0300 Subject: SL-18008 Edit PBR in menu should not be enabled if selection has no pbr materials --- indra/newview/llviewermenu.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index e1b92e5f2e..3161579482 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2809,37 +2809,39 @@ void handle_object_open() LLFloaterReg::showInstance("openobject"); } -struct LLSelectedTEGetmatIdAndPermissions : public LLSelectedTEGetFunctor +struct LLSelectedTEGetmatIdAndPermissions : public LLSelectedTEFunctor { LLSelectedTEGetmatIdAndPermissions() : mCanCopy(true), mCanModify(true), mCanTransfer(true) {} - LLUUID get(LLViewerObject* object, S32 te_index) + bool apply(LLViewerObject* objectp, S32 te_index) { - mCanCopy &= (bool)object->permCopy(); - mCanTransfer &= (bool)object->permTransfer(); - mCanModify &= (bool)object->permModify(); - // return true if all ids are identical - return object->getRenderMaterialID(te_index); + mCanCopy &= (bool)objectp->permCopy(); + mCanTransfer &= (bool)objectp->permTransfer(); + mCanModify &= (bool)objectp->permModify(); + LLUUID mat_id = objectp->getRenderMaterialID(te_index); + if (mat_id.notNull()) + { + mMaterialId = mat_id; + } + return true; } bool mCanCopy; bool mCanModify; bool mCanTransfer; + LLUUID mMaterialId; }; bool enable_object_edit_gltf_material() { LLSelectedTEGetmatIdAndPermissions func; - LLUUID mat_id; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); - - return func.mCanModify; + LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); + return func.mCanModify && func.mMaterialId.notNull(); } bool enable_object_save_gltf_material() { LLSelectedTEGetmatIdAndPermissions func; - LLUUID mat_id; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); - return func.mCanCopy && mat_id.notNull(); + LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); + return func.mCanCopy && func.mMaterialId.notNull(); } bool enable_object_open() -- cgit v1.2.3