From 4705515e785b56165f1b936d4e2baec6a2836b6c Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 3 Aug 2023 20:29:30 +0300 Subject: SL-19303 switch automatically between Materials/PBR/Media based on current values --- indra/newview/llpanelface.cpp | 70 ++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 24 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 83a330af37..b5ed4f50af 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1022,6 +1022,52 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } } + // *NOTE: The "identical" variable is currently only used to decide if + // the texgen control should be tentative - this is not used by GLTF + // materials. -Cosmic;2022-11-09 + bool identical = true; // true because it is anded below + bool identical_diffuse = false; + bool identical_norm = false; + bool identical_spec = false; + + LLTextureCtrl *texture_ctrl = getChild("texture control"); + LLTextureCtrl *shinytexture_ctrl = getChild("shinytexture control"); + LLTextureCtrl *bumpytexture_ctrl = getChild("bumpytexture control"); + + LLUUID id; + LLUUID normmap_id; + LLUUID specmap_id; + + LLSelectedTE::getTexId(id, identical_diffuse); + LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm); + LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); + + static S32 selected_te = -1; + if ((LLToolFace::getInstance() == LLToolMgr::getInstance()->getCurrentTool()) && + !LLSelectMgr::getInstance()->getSelection()->isMultipleTESelected()) + { + S32 new_selection = LLSelectMgr::getInstance()->getSelection()->getFirstNode()->getLastSelectedTE(); + if (new_selection != selected_te) + { + bool te_has_media = objectp->getTE(new_selection) && objectp->getTE(new_selection)->hasMedia(); + bool te_has_pbr = objectp->getRenderMaterialID(new_selection).notNull(); + + if (te_has_pbr && !((mComboMatMedia->getCurrentIndex() == MATMEDIA_MEDIA) && te_has_media)) + { + mComboMatMedia->selectNthItem(MATMEDIA_PBR); + } + else if (te_has_media) + { + mComboMatMedia->selectNthItem(MATMEDIA_MEDIA); + } + else if (id.notNull() || normmap_id.notNull() || specmap_id.notNull()) + { + mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); + } + selected_te = new_selection; + } + } + mComboMatMedia->setEnabled(editable); LLRadioGroup* radio_mat_type = getChild("radio_material_type"); @@ -1045,22 +1091,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) updateVisibility(); - // *NOTE: The "identical" variable is currently only used to decide if - // the texgen control should be tentative - this is not used by GLTF - // materials. -Cosmic;2022-11-09 - bool identical = true; // true because it is anded below - bool identical_diffuse = false; - bool identical_norm = false; - bool identical_spec = false; - - LLTextureCtrl* texture_ctrl = getChild("texture control"); - LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); - LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); - - LLUUID id; - LLUUID normmap_id; - LLUUID specmap_id; - // Color swatch { getChildView("color label")->setEnabled(editable); @@ -1090,9 +1120,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild("ColorTrans")->setValue(editable ? transparency : 0); getChildView("ColorTrans")->setEnabled(editable && has_material); - // Specular map - LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); - U8 shiny = 0; bool identical_shiny = false; @@ -1158,11 +1185,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Texture { - LLSelectedTE::getTexId(id,identical_diffuse); - - // Normal map - LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm); - mIsAlpha = FALSE; LLGLenum image_format = GL_RGB; bool identical_image_format = false; -- cgit v1.2.3