diff options
Diffstat (limited to 'indra/newview/llpanelface.cpp')
| -rw-r--r-- | indra/newview/llpanelface.cpp | 104 | 
1 files changed, 87 insertions, 17 deletions
| diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index a4a91baad8..fd8bf044f8 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -46,6 +46,7 @@  #include "llcombobox.h"  #include "lldrawpoolbump.h"  #include "llface.h" +#include "llgltfmateriallist.h"  #include "llinventoryfunctions.h"  #include "llinventorymodel.h" // gInventory  #include "llinventorymodelbackgroundfetch.h" @@ -53,6 +54,7 @@  #include "llfloaterreg.h"  #include "lllineeditor.h"  #include "llmaterialmgr.h" +#include "llmaterialeditor.h"  #include "llmediactrl.h"  #include "llmediaentry.h"  #include "llmenubutton.h" @@ -91,6 +93,7 @@  #include "llsdserialize.h"  #include "llinventorymodel.h" +using namespace std::literals;  //  // Constant definitions for comboboxes @@ -119,10 +122,23 @@ std::string USE_TEXTURE;  LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit()  { -	LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); -	LLRender::eTexIndex channel_to_edit = (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? -	                                                    (radio_mat_type ? (LLRender::eTexIndex)radio_mat_type->getSelectedIndex() : LLRender::DIFFUSE_MAP) : LLRender::DIFFUSE_MAP; + +    LLRender::eTexIndex channel_to_edit = LLRender::DIFFUSE_MAP; +    if (mComboMatMedia) +    { +        U32 matmedia_selection = mComboMatMedia->getCurrentIndex(); +        if (matmedia_selection == MATMEDIA_MATERIAL) +        { +            LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); +            channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex(); +        } +        if (matmedia_selection == MATMEDIA_PBR) +        { +            LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_pbr_type"); +            channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex(); +        } +    }  	channel_to_edit = (channel_to_edit == LLRender::NORMAL_MAP)		? (getCurrentNormalMap().isNull()		? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit;  	channel_to_edit = (channel_to_edit == LLRender::SPECULAR_MAP)	? (getCurrentSpecularMap().isNull()		? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; @@ -221,6 +237,9 @@ BOOL	LLPanelFace::postBuild()          pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);          pbr_ctrl->setBakeTextureEnabled(false);          pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + +        // TODO - design real UI for activating live editing +        pbr_ctrl->setRightMouseUpCallback(boost::bind(&LLPanelFace::onPbrStartEditing, this));      }  	mTextureCtrl = getChild<LLTextureCtrl>("texture control"); @@ -517,20 +536,42 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor  	{  		BOOL valid;  		F32 value; - -        LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type");          std::string prefix; -        switch (radio_mat_type->getSelectedIndex()) +        U32 materials_media = mPanel->getChild<LLComboBox>("combobox matmedia")->getCurrentIndex(); + +        if (MATMEDIA_PBR == materials_media)          { -        case MATTYPE_DIFFUSE: -            prefix = "Tex"; -            break; -        case MATTYPE_NORMAL: -            prefix = "bumpy"; -            break; -        case MATTYPE_SPECULAR: -            prefix = "shiny"; -            break; +            LLRadioGroup * radio_pbr_type = mPanel->getChild<LLRadioGroup>("radio_pbr_type"); +            switch (radio_pbr_type->getSelectedIndex()) +            { +            case PBRTYPE_BASE_COLOR: +                prefix = "Tex"; +                break; +            case PBRTYPE_NORMAL: +                prefix = "bumpy"; +                break; +            case PBRTYPE_METALLIC: +                prefix = "shiny"; +                break; +            } +        } +        else +        { +            // Effectively the same as MATMEDIA_PBR sans using different radio, +            // separate for the sake of clarity +            LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type"); +            switch (radio_mat_type->getSelectedIndex()) +            { +            case MATTYPE_DIFFUSE: +                prefix = "Tex"; +                break; +            case MATTYPE_NORMAL: +                prefix = "bumpy"; +                break; +            case MATTYPE_SPECULAR: +                prefix = "shiny"; +                break; +            }          }          LLSpinCtrl * ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleU"); @@ -3468,11 +3509,20 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata)  	LLPanelFace* self = (LLPanelFace*) userdata;  	LLUICtrl*	repeats_ctrl	= self->getChild<LLUICtrl>("rptctrl"); -	LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_material_type");  	U32 materials_media = self->mComboMatMedia->getCurrentIndex(); +    U32 material_type = 0; +    if (materials_media == MATMEDIA_PBR) +    { +        LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_pbr_type"); +        material_type = radio_mat_type->getSelectedIndex(); +    } +    if (materials_media == MATMEDIA_MATERIAL) +    { +        LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_material_type"); +        material_type = radio_mat_type->getSelectedIndex(); +    } -	U32 material_type           = (materials_media == MATMEDIA_MATERIAL) ? radio_mat_type->getSelectedIndex() : 0;  	F32 repeats_per_meter	= repeats_ctrl->getValue().asReal();     F32 obj_scale_s = 1.0f; @@ -4530,6 +4580,26 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp)      }  } +void LLPanelFace::onPbrStartEditing() { +    LL_DEBUGS() << "begin live editing material" << LL_ENDL; + +    LLMaterialEditor *editor = +        dynamic_cast<LLMaterialEditor *>(LLFloaterReg::showInstance("material_editor", LLSD(LLUUID::null), TAKE_FOCUS_YES)); +    if (editor) +    { +        bool   identical; +        LLUUID material_id; +        LLSelectedTE::getPbrMaterialId(material_id, identical); + +        LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL; + +        LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id); +        editor->setTitle("Editing material on selection"s); +        editor->setAssetId(material_id); +        editor->setFromGLTFMaterial(material); +    } +} +  bool LLPanelFace::isIdenticalPlanarTexgen()  {  	LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; | 
