diff options
Diffstat (limited to 'indra/newview/llpanelface.cpp')
-rw-r--r-- | indra/newview/llpanelface.cpp | 531 |
1 files changed, 391 insertions, 140 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 178aba11a3..7b7fcd4585 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -80,18 +80,34 @@ #include "llpluginclassmedia.h" #include "llviewertexturelist.h"// Update sel manager as to which channel we're editing so it can reflect the correct overlay UI + + +#include "llagent.h" +#include "llfilesystem.h" +#include "llviewerassetupload.h" +#include "llviewermenufile.h" +#include "llsd.h" +#include "llsdutil.h" +#include "llsdserialize.h" +#include "llinventorymodel.h" + + // // Constant definitions for comboboxes // Must match the commbobox definitions in panel_tools_texture.xml // const S32 MATMEDIA_MATERIAL = 0; // Material -const S32 MATMEDIA_MEDIA = 1; // Media +const S32 MATMEDIA_PBR = 1; // PBR +const S32 MATMEDIA_MEDIA = 2; // Media const S32 MATTYPE_DIFFUSE = 0; // Diffuse material texture const S32 MATTYPE_NORMAL = 1; // Normal map const S32 MATTYPE_SPECULAR = 2; // Specular map const S32 ALPHAMODE_MASK = 2; // Alpha masking mode const S32 BUMPY_TEXTURE = 18; // use supplied normal map const S32 SHINY_TEXTURE = 4; // use supplied specular map +const S32 PBRTYPE_ALBEDO = 0; // PBR Albedo +const S32 PBRTYPE_NORMAL = 1; // PBR Normal +const S32 PBRTYPE_METALLIC = 2; // PBR Metallic BOOST_STATIC_ASSERT(MATTYPE_DIFFUSE == LLRender::DIFFUSE_MAP && MATTYPE_NORMAL == LLRender::NORMAL_MAP && MATTYPE_SPECULAR == LLRender::SPECULAR_MAP); @@ -187,6 +203,26 @@ BOOL LLPanelFace::postBuild() setMouseOpaque(FALSE); + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + pbr_ctrl->setDefaultImageAssetID(LLUUID::null); + pbr_ctrl->setBlankImageAssetID(LLUUID::null); // should there be some empty default material? + pbr_ctrl->setCommitCallback(boost::bind(&LLPanelFace::onCommitPbr, this, _2)); + pbr_ctrl->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelPbr, this, _2)); + pbr_ctrl->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectPbr, this, _2)); + pbr_ctrl->setDragCallback(boost::bind(&LLPanelFace::onDragPbr, this, _2)); + pbr_ctrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onPbrSelectionChanged, this, _1)); + pbr_ctrl->setOnCloseCallback(boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2)); + + pbr_ctrl->setFollowsTop(); + pbr_ctrl->setFollowsLeft(); + pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); + pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + pbr_ctrl->setBakeTextureEnabled(false); + pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + } + mTextureCtrl = getChild<LLTextureCtrl>("texture control"); if(mTextureCtrl) { @@ -290,20 +326,27 @@ BOOL LLPanelFace::postBuild() mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); } - mComboMatMedia = getChild<LLComboBox>("combobox matmedia"); - if(mComboMatMedia) + LLComboBox* combo_mat_media = findChild<LLComboBox>("combobox matmedia"); + if(combo_mat_media) { - mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this); - mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); + combo_mat_media->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this); + combo_mat_media->selectNthItem(MATMEDIA_MATERIAL); } - LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); + LLRadioGroup* radio_mat_type = findChild<LLRadioGroup>("radio_material_type"); if(radio_mat_type) { radio_mat_type->setCommitCallback(LLPanelFace::onCommitMaterialType, this); radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); } + LLRadioGroup* radio_pbr_type = findChild<LLRadioGroup>("radio_pbr_type"); + if (radio_pbr_type) + { + radio_pbr_type->setCommitCallback(LLPanelFace::onCommitPbrType, this); + radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); + } + mCtrlGlow = getChild<LLSpinCtrl>("glow"); if(mCtrlGlow) { @@ -840,41 +883,51 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // only turn on auto-adjust button if there is a media renderer and the media is loaded childSetEnabled("button align", editable); - if (mComboMatMedia) - { - if (mComboMatMedia->getCurrentIndex() < MATMEDIA_MATERIAL) - { - mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); - } - mComboMatMedia->setEnabled(editable); - } - else - { - LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL; - } + LLComboBox* combobox_matmedia = getChild<LLComboBox>("combobox matmedia"); + if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL) + { + combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL); + } + combobox_matmedia->setEnabled(editable); LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); - if(radio_mat_type) - { - if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE) - { - radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); - } - } - else - { - LL_WARNS("Materials") << "failed getChild for 'radio_material_type'" << LL_ENDL; - } + if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE) + { + radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); + } + radio_mat_type->setEnabled(editable); + + LLRadioGroup* radio_pbr_type = getChild<LLRadioGroup>("radio_pbr_type"); + if (radio_pbr_type->getSelectedIndex() < PBRTYPE_ALBEDO) + { + radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); + } + radio_pbr_type->setEnabled(editable); - getChildView("radio_material_type")->setEnabled(editable); getChildView("checkbox_sync_settings")->setEnabled(editable); childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings")); updateVisibility(); bool identical = true; // true because it is anded below - bool identical_diffuse = false; - bool identical_norm = false; - bool identical_spec = false; + bool identical_diffuse = false; + bool identical_norm = false; + bool identical_spec = false; + + // pbr material + bool has_pbr_material = false; + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + LLUUID pbr_id; + bool identical_pbr; + LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr); + identical &= identical_pbr; + + pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE); + pbr_ctrl->setEnabled(editable); + pbr_ctrl->setImageAssetID(pbr_id); + has_pbr_material = pbr_id.notNull(); + } LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild<LLTextureCtrl>("shinytexture control"); @@ -886,7 +939,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Color swatch { - getChildView("color label")->setEnabled(editable); + getChildView("color label")->setEnabled(editable && !has_pbr_material); } LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("colorswatch"); @@ -907,11 +960,11 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } // Color transparency - getChildView("color trans")->setEnabled(editable); + getChildView("color trans")->setEnabled(editable && !has_pbr_material); F32 transparency = (1.f - color.mV[VALPHA]) * 100.f; getChild<LLUICtrl>("ColorTrans")->setValue(editable ? transparency : 0); - getChildView("ColorTrans")->setEnabled(editable); + getChildView("ColorTrans")->setEnabled(editable && !has_pbr_material); // Specular map LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); @@ -956,7 +1009,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) U8 bumpy = 0; // Bumpy - { + { bool identical_bumpy = false; LLSelectedTE::getBumpmap(bumpy,identical_bumpy); @@ -977,7 +1030,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("combobox bumpiness")->setEnabled(editable); getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical_bumpy); getChildView("label bumpiness")->setEnabled(editable); - } + } // Texture { @@ -1052,10 +1105,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) texture_ctrl->setTentative(FALSE); texture_ctrl->setEnabled(editable); texture_ctrl->setImageAssetID(id); - getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f); - getChildView("label alphamode")->setEnabled(editable && mIsAlpha); - getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); - getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha); + getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f && !has_pbr_material); + getChildView("label alphamode")->setEnabled(editable && mIsAlpha && !has_pbr_material); + getChildView("maskcutoff")->setEnabled(editable && mIsAlpha && !has_pbr_material); + getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha && !has_pbr_material); texture_ctrl->setBakeTextureEnabled(TRUE); } @@ -1078,10 +1131,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) texture_ctrl->setTentative(TRUE); texture_ctrl->setEnabled(editable); texture_ctrl->setImageAssetID(id); - getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f); - getChildView("label alphamode")->setEnabled(editable && mIsAlpha); - getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); - getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha); + getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha && transparency <= 0.f && !has_pbr_material); + getChildView("label alphamode")->setEnabled(editable && mIsAlpha && !has_pbr_material); + getChildView("maskcutoff")->setEnabled(editable && mIsAlpha && !has_pbr_material); + getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha && !has_pbr_material); texture_ctrl->setBakeTextureEnabled(TRUE); } @@ -1170,9 +1223,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild<LLUICtrl>("shinyScaleU")->setValue(spec_scale_s); getChild<LLUICtrl>("bumpyScaleU")->setValue(norm_scale_s); - getChildView("TexScaleU")->setEnabled(editable); - getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexScaleU")->setEnabled(editable && has_pbr_material); + getChildView("shinyScaleU")->setEnabled(editable && has_pbr_material); + getChildView("bumpyScaleU")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexScaleU")->setEnabled(editable); + getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); + } BOOL diff_scale_tentative = !(identical && identical_diff_scale_s); BOOL norm_scale_tentative = !(identical && identical_norm_scale_s); @@ -1209,9 +1271,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) BOOL norm_scale_tentative = !identical_norm_scale_t; BOOL spec_scale_tentative = !identical_spec_scale_t; - getChildView("TexScaleV")->setEnabled(editable); - getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexScaleV")->setEnabled(editable && has_pbr_material); + getChildView("shinyScaleV")->setEnabled(editable && has_pbr_material); + getChildView("bumpyScaleV")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexScaleV")->setEnabled(editable); + getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); + } if (force_set_values) { @@ -1255,9 +1326,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild<LLUICtrl>("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative)); getChild<LLUICtrl>("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative)); - getChildView("TexOffsetU")->setEnabled(editable); - getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexOffsetU")->setEnabled(editable && has_pbr_material); + getChildView("shinyOffsetU")->setEnabled(editable && has_pbr_material); + getChildView("bumpyOffsetU")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexOffsetU")->setEnabled(editable); + getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); + } } { @@ -1285,9 +1365,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild<LLUICtrl>("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative)); getChild<LLUICtrl>("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative)); - getChildView("TexOffsetV")->setEnabled(editable); - getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexOffsetV")->setEnabled(editable && has_pbr_material); + getChildView("shinyOffsetV")->setEnabled(editable && has_pbr_material); + getChildView("bumpyOffsetV")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexOffsetV")->setEnabled(editable); + getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); + } } // Texture rotation @@ -1311,10 +1400,19 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) F32 diff_rot_deg = diff_rotation * RAD_TO_DEG; F32 norm_rot_deg = norm_rotation * RAD_TO_DEG; F32 spec_rot_deg = spec_rotation * RAD_TO_DEG; - - getChildView("TexRot")->setEnabled(editable); - getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); + + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexRot")->setEnabled(editable && has_pbr_material); + getChildView("shinyRot")->setEnabled(editable && has_pbr_material); + getChildView("bumpyRot")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexRot")->setEnabled(editable); + getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); + } getChild<LLUICtrl>("TexRot")->setTentative(diff_rot_tentative); getChild<LLUICtrl>("shinyRot")->setTentative(LLSD(norm_rot_tentative)); @@ -1331,8 +1429,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLSelectedTE::getGlow(glow,identical_glow); getChild<LLUICtrl>("glow")->setValue(glow); getChild<LLUICtrl>("glow")->setTentative(!identical_glow); - getChildView("glow")->setEnabled(editable); - getChildView("glow label")->setEnabled(editable); + getChildView("glow")->setEnabled(editable && !has_pbr_material); + getChildView("glow label")->setEnabled(editable && !has_pbr_material); } { @@ -1380,42 +1478,61 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLComboBox* mComboTexGen = getChild<LLComboBox>("combobox texgen"); if (mComboTexGen) - { + { S32 index = mComboTexGen ? mComboTexGen->getCurrentIndex() : 0; - BOOL enabled = editable && (index != 1); - BOOL identical_repeats = true; + bool enabled = editable && (index != 1); + bool identical_repeats = true; + S32 material_selection = combobox_matmedia->getCurrentIndex(); F32 repeats = 1.0f; - U32 material_type = (mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? radio_mat_type->getSelectedIndex() : MATTYPE_DIFFUSE; + U32 material_type = MATTYPE_DIFFUSE; + if (material_selection == MATMEDIA_MATERIAL) + { + material_type = radio_mat_type->getSelectedIndex(); + } + else if (material_selection == MATMEDIA_PBR) + { + enabled = editable && has_pbr_material; + material_type = radio_pbr_type->getSelectedIndex(); + } LLSelectMgr::getInstance()->setTextureChannel(LLRender::eTexIndex(material_type)); - switch (material_type) - { - default: - case MATTYPE_DIFFUSE: - { - enabled = editable && !id.isNull(); - identical_repeats = identical_diff_repeats; - repeats = repeats_diff; - } - break; + switch (material_type) + { + default: + case MATTYPE_DIFFUSE: + { + if (material_selection != MATMEDIA_PBR) + { + enabled = editable && !id.isNull(); + } + identical_repeats = identical_diff_repeats; + repeats = repeats_diff; + } + break; - case MATTYPE_SPECULAR: - { - enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull())); - identical_repeats = identical_spec_repeats; - repeats = repeats_spec; - } - break; + case MATTYPE_SPECULAR: + { + if (material_selection != MATMEDIA_PBR) + { + enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull())); + } + identical_repeats = identical_spec_repeats; + repeats = repeats_spec; + } + break; - case MATTYPE_NORMAL: - { - enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull())); - identical_repeats = identical_norm_repeats; - repeats = repeats_norm; - } - break; - } + case MATTYPE_NORMAL: + { + if (material_selection != MATMEDIA_PBR) + { + enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull())); + } + identical_repeats = identical_norm_repeats; + repeats = repeats_norm; + } + break; + } BOOL repeats_tentative = !identical_repeats; @@ -1439,7 +1556,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLMaterialPtr material; LLSelectedTEMaterial::getCurrent(material, identical); - if (material && editable) + if (material && editable) { LL_DEBUGS("Materials") << material->asLLSD() << LL_ENDL; @@ -1558,6 +1675,12 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) clearCtrls(); // Disable non-UICtrls + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + pbr_ctrl->setImageAssetID(LLUUID::null); + pbr_ctrl->setEnabled(FALSE); + } LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control"); if(texture_ctrl) { @@ -2429,22 +2552,32 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) } void LLPanelFace::updateVisibility() -{ - LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); - LLComboBox* combo_shininess = getChild<LLComboBox>("combobox shininess"); - LLComboBox* combo_bumpiness = getChild<LLComboBox>("combobox bumpiness"); - if (!radio_mat_type || !mComboMatMedia || !combo_shininess || !combo_bumpiness) +{ + LLComboBox* combo_matmedia = findChild<LLComboBox>("combobox matmedia"); + LLRadioGroup* radio_mat_type = findChild<LLRadioGroup>("radio_material_type"); + LLRadioGroup* radio_pbr_type = findChild<LLRadioGroup>("radio_pbr_type"); + LLComboBox* combo_shininess = findChild<LLComboBox>("combobox shininess"); + LLComboBox* combo_bumpiness = findChild<LLComboBox>("combobox bumpiness"); + if (!radio_mat_type || !radio_pbr_type || !combo_matmedia || !combo_shininess || !combo_bumpiness) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; return; } U32 materials_media = mComboMatMedia->getCurrentIndex(); U32 material_type = radio_mat_type->getSelectedIndex(); - bool show_media = (materials_media == MATMEDIA_MEDIA) && mComboMatMedia->getEnabled(); - bool show_texture = (show_media || ((material_type == MATTYPE_DIFFUSE) && mComboMatMedia->getEnabled())); - bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && mComboMatMedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); - getChildView("radio_material_type")->setVisible(!show_media); + U32 pbr_type = radio_pbr_type->getSelectedIndex(); + bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); + bool show_material = materials_media == MATMEDIA_MATERIAL; + bool show_pbr = materials_media == MATMEDIA_PBR; + bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); + bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); + bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); + bool show_pbr_albedo = show_pbr && (pbr_type == PBRTYPE_ALBEDO) && combo_matmedia->getEnabled(); + bool show_pbr_normal = show_pbr && (pbr_type == PBRTYPE_NORMAL) && combo_matmedia->getEnabled(); + bool show_pbr_metallic = show_pbr && (pbr_type == PBRTYPE_METALLIC) && combo_matmedia->getEnabled(); + + radio_mat_type->setVisible(show_material); + radio_pbr_type->setVisible(show_pbr); // Media controls mTitleMediaText->setVisible(show_media); @@ -2453,20 +2586,21 @@ void LLPanelFace::updateVisibility() getChildView("button align")->setVisible(show_media); // Diffuse texture controls - getChildView("texture control")->setVisible(show_texture && !show_media); - getChildView("label alphamode")->setVisible(show_texture && !show_media); - getChildView("combobox alphamode")->setVisible(show_texture && !show_media); + getChildView("texture control")->setVisible(show_texture && show_material); + getChildView("label alphamode")->setVisible(show_texture && show_material); + getChildView("combobox alphamode")->setVisible(show_texture && show_material); getChildView("label maskcutoff")->setVisible(false); getChildView("maskcutoff")->setVisible(false); - if (show_texture && !show_media) + if ((show_texture && show_material) || show_pbr) { updateAlphaControls(); } - getChildView("TexScaleU")->setVisible(show_texture); - getChildView("TexScaleV")->setVisible(show_texture); - getChildView("TexRot")->setVisible(show_texture); - getChildView("TexOffsetU")->setVisible(show_texture); - getChildView("TexOffsetV")->setVisible(show_texture); + // texture scale and position controls are shared between bpr and non-pbr textures + getChildView("TexScaleU")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexScaleV")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexRot")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexOffsetU")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexOffsetV")->setVisible(show_texture || show_pbr_albedo); // Specular map controls getChildView("shinytexture control")->setVisible(show_shininess); @@ -2482,11 +2616,11 @@ void LLPanelFace::updateVisibility() { updateShinyControls(); } - getChildView("shinyScaleU")->setVisible(show_shininess); - getChildView("shinyScaleV")->setVisible(show_shininess); - getChildView("shinyRot")->setVisible(show_shininess); - getChildView("shinyOffsetU")->setVisible(show_shininess); - getChildView("shinyOffsetV")->setVisible(show_shininess); + getChildView("shinyScaleU")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyScaleV")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyRot")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyOffsetU")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyOffsetV")->setVisible(show_shininess || show_pbr_normal); // Normal map controls if (show_bumpiness) @@ -2496,13 +2630,14 @@ void LLPanelFace::updateVisibility() getChildView("bumpytexture control")->setVisible(show_bumpiness); getChildView("combobox bumpiness")->setVisible(show_bumpiness); getChildView("label bumpiness")->setVisible(show_bumpiness); - getChildView("bumpyScaleU")->setVisible(show_bumpiness); - getChildView("bumpyScaleV")->setVisible(show_bumpiness); - getChildView("bumpyRot")->setVisible(show_bumpiness); - getChildView("bumpyOffsetU")->setVisible(show_bumpiness); - getChildView("bumpyOffsetV")->setVisible(show_bumpiness); - - + getChildView("bumpyScaleU")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyScaleV")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyRot")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyOffsetU")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyOffsetV")->setVisible(show_bumpiness || show_pbr_metallic); + + // PBR controls + getChildView("pbr_control")->setVisible(show_pbr); } // static @@ -2518,6 +2653,16 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) } // static +void LLPanelFace::onCommitPbrType(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*)userdata; + // Force to default states to side-step problems with menu contents + // and generally reflecting old state when switching tabs or objects + // + self->updateUI(); +} + +// static void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; @@ -2582,8 +2727,8 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); U32 materials_media = mComboMatMedia->getCurrentIndex(); U32 material_type = radio_mat_type->getSelectedIndex(); - bool show_media = (materials_media == MATMEDIA_MEDIA) && mComboMatMedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); + bool show_material = (materials_media == MATMEDIA_MATERIAL); + bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture getChildView("label glossiness")->setVisible(show_shinyctrls); @@ -2700,21 +2845,81 @@ void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata) } // static +BOOL LLPanelFace::onDragPbr(LLUICtrl*, LLInventoryItem* item) +{ + BOOL accept = TRUE; + for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); + iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* obj = node->getObject(); + if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) + { + accept = FALSE; + break; + } + } + return accept; +} + +void LLPanelFace::onCommitPbr(const LLSD& data) +{ + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (!pbr_ctrl) return; + if (!pbr_ctrl->getTentative()) + { + // we grab the item id first, because we want to do a + // permissions check in the selection manager. ARGH! + LLUUID id = pbr_ctrl->getImageItemID(); + if (id.isNull()) + { + id = pbr_ctrl->getImageAssetID(); + } + LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id); + } +} + +void LLPanelFace::onCancelPbr(const LLSD& data) +{ + LLSelectMgr::getInstance()->selectionRevertGLTFMaterials(); +} + +void LLPanelFace::onSelectPbr(const LLSD& data) +{ + LLSelectMgr::getInstance()->saveSelectedObjectTextures(); + + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (!pbr_ctrl) return; + if (!pbr_ctrl->getTentative()) + { + // we grab the item id first, because we want to do a + // permissions check in the selection manager. ARGH! + LLUUID id = pbr_ctrl->getImageItemID(); + if (id.isNull()) + { + id = pbr_ctrl->getImageAssetID(); + } + LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id); + LLSelectedTEMaterial::setMaterialID(this, id); + } +} + +// static BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) { - BOOL accept = TRUE; - for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); - iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) - { - LLSelectNode* node = *iter; - LLViewerObject* obj = node->getObject(); - if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) - { - accept = FALSE; - break; - } - } - return accept; + BOOL accept = TRUE; + for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); + iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* obj = node->getObject(); + if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) + { + accept = FALSE; + break; + } + } + return accept; } void LLPanelFace::onCommitTexture( const LLSD& data ) @@ -4263,6 +4468,39 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) } } +void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) +{ + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + LLUUID obj_owner_id; + std::string obj_owner_name; + LLSelectMgr::instance().selectGetOwner(obj_owner_id, obj_owner_name); + + LLSaleInfo sale_info; + LLSelectMgr::instance().selectGetSaleInfo(sale_info); + + bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this texture? + bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this texture? + bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply texture belong to the agent? + bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply texture not for sale? + + if (can_copy && can_transfer) + { + pbr_ctrl->setCanApply(true, true); + return; + } + + // if texture has (no-transfer) attribute it can be applied only for object which we own and is not for sale + pbr_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); + + if (gSavedSettings.getBOOL("TextureLivePreview")) + { + LLNotificationsUtil::add("LivePreviewUnavailable"); + } + } +} + bool LLPanelFace::isIdenticalPlanarTexgen() { LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; @@ -4342,6 +4580,18 @@ void LLPanelFace::LLSelectedTE::getTexId(LLUUID& id, bool& identical) identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); } +void LLPanelFace::LLSelectedTE::getPbrMaterialId(LLUUID& id, bool& identical) +{ + struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor<LLUUID> + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + return object->getRenderMaterialID(te_index); + } + } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, id); +} + void LLPanelFace::LLSelectedTEMaterial::getCurrent(LLMaterialPtr& material_ptr, bool& identical_material) { struct MaterialFunctor : public LLSelectedTEGetFunctor<LLMaterialPtr> @@ -4480,3 +4730,4 @@ void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identic } max_diff_repeats_func; identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_diff_repeats_func, repeats ); } + |