diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llpanelface.cpp | 245 | ||||
-rw-r--r-- | indra/newview/llpanelface.h | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_tools_texture.xml | 22 |
3 files changed, 223 insertions, 54 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9d720b1523..f43a5d7dbe 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -114,6 +114,73 @@ const S32 PBRTYPE_NORMAL = 2; // PBR Normal const S32 PBRTYPE_METALLIC_ROUGHNESS = 3; // PBR Metallic const S32 PBRTYPE_EMISSIVE = 4; // PBR Emissive +LLGLTFMaterial::TextureInfo texture_info_from_pbrtype(S32 pbr_type) +{ + switch (pbr_type) + { + case PBRTYPE_BASE_COLOR: + return LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR; + break; + case PBRTYPE_NORMAL: + return LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL; + break; + case PBRTYPE_METALLIC_ROUGHNESS: + return LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS; + break; + case PBRTYPE_EMISSIVE: + return LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE; + break; + default: + return LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; + break; + } +} + +void updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func) +{ + struct LLSelectedTEGLTFMaterialFunctor : public LLSelectedTEFunctor + { + LLSelectedTEGLTFMaterialFunctor(std::function<void(LLGLTFMaterial*)> func) : mFunc(func) {} + virtual ~LLSelectedTEGLTFMaterialFunctor() {}; + bool apply(LLViewerObject* object, S32 face) override + { + LLGLTFMaterial new_override; + const LLTextureEntry* tep = object->getTE(face); + if (tep->getGLTFMaterialOverride()) + { + new_override = *tep->getGLTFMaterialOverride(); + } + mFunc(&new_override); + LLGLTFMaterialList::queueModify(object->getID(), face, &new_override); + + return true; + } + + std::function<void(LLGLTFMaterial*)> mFunc; + } select_func(func); + LLSelectMgr::getInstance()->getSelection()->applyToTEs(&select_func); +} + +template<typename T> +void readSelectedGLTFMaterial(std::function<T(const LLGLTFMaterial*)> func, T& value, bool& identical, bool has_tolerance, T tolerance) +{ + struct LLSelectedTEGetGLTFMaterialFunctor : public LLSelectedTEGetFunctor<T> + { + LLSelectedTEGetGLTFMaterialFunctor(std::function<T(const LLGLTFMaterial*)> func) : mFunc(func) {} + virtual ~LLSelectedTEGetGLTFMaterialFunctor() {}; + T get(LLViewerObject* object, S32 face) override + { + const LLTextureEntry* tep = object->getTE(face); + const LLGLTFMaterial* render_material = tep->getGLTFRenderMaterial(); + + return mFunc(render_material); + } + + std::function<T(const LLGLTFMaterial*)> mFunc; + } select_func(func); + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&select_func, value, has_tolerance, tolerance); +} + BOOST_STATIC_ASSERT(MATTYPE_DIFFUSE == LLRender::DIFFUSE_MAP && MATTYPE_NORMAL == LLRender::NORMAL_MAP && MATTYPE_SPECULAR == LLRender::SPECULAR_MAP); // @@ -201,11 +268,11 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("add_media", &LLPanelFace::onClickBtnAddMedia, this); childSetCommitCallback("delete_media", &LLPanelFace::onClickBtnDeleteMedia, this); - childSetCommitCallback("gltfTextureScaleU", &LLPanelFace::onCommitGLTFTextureScaleU, this); - childSetCommitCallback("gltfTextureScaleV", &LLPanelFace::onCommitGLTFTextureScaleV, this); - childSetCommitCallback("gltfRotation", &LLPanelFace::onCommitGLTFRotation, this); - childSetCommitCallback("gltfTextureTranslationU", &LLPanelFace::onCommitGLTFTextureTranslationU, this); - childSetCommitCallback("gltfTextureTranslationV", &LLPanelFace::onCommitGLTFTextureTranslationV, this); + childSetCommitCallback("gltfTextureScaleU", boost::bind(&LLPanelFace::onCommitGLTFTextureScaleU, this, _1), nullptr); + childSetCommitCallback("gltfTextureScaleV", boost::bind(&LLPanelFace::onCommitGLTFTextureScaleV, this, _1), nullptr); + childSetCommitCallback("gltfTextureRotation", boost::bind(&LLPanelFace::onCommitGLTFRotation, this, _1), nullptr); + childSetCommitCallback("gltfTextureOffsetU", boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetU, this, _1), nullptr); + childSetCommitCallback("gltfTextureOffsetV", boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetV, this, _1), nullptr); childSetAction("button align",&LLPanelFace::onClickAutoFix,this); childSetAction("button align textures", &LLPanelFace::onAlignTexture, this); @@ -1722,6 +1789,70 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, getChildView("pbr_from_inventory")->setEnabled(editable); getChildView("edit_selected_pbr")->setEnabled(editable && has_pbr_material); getChildView("save_selected_pbr")->setEnabled(objectp->permCopy() && has_pbr_material); + + const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); + if (show_pbr) + { + + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + const bool show_texture_info = texture_info != LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; + + LLUICtrl* gltfCtrlTextureScaleU = getChild<LLUICtrl>("gltfTextureScaleU"); + LLUICtrl* gltfCtrlTextureScaleV = getChild<LLUICtrl>("gltfTextureScaleV"); + LLUICtrl* gltfCtrlTextureRotation = getChild<LLUICtrl>("gltfTextureRotation"); + LLUICtrl* gltfCtrlTextureOffsetU = getChild<LLUICtrl>("gltfTextureOffsetU"); + LLUICtrl* gltfCtrlTextureOffsetV = getChild<LLUICtrl>("gltfTextureOffsetV"); + + gltfCtrlTextureScaleU->setEnabled(show_texture_info); + gltfCtrlTextureScaleV->setEnabled(show_texture_info); + gltfCtrlTextureRotation->setEnabled(show_texture_info); + gltfCtrlTextureOffsetU->setEnabled(show_texture_info); + gltfCtrlTextureOffsetV->setEnabled(show_texture_info); + + if (show_texture_info) + { + LLGLTFMaterial::TextureTransform transform; + bool scale_u_same = true; + bool scale_v_same = true; + bool rotation_same = true; + bool offset_u_same = true; + bool offset_v_same = true; + + readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) + { + return mat->mTextureTransform[texture_info].mScale[VX]; + }, transform.mScale[VX], scale_u_same, true, 1e-3f); + readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) + { + return mat->mTextureTransform[texture_info].mScale[VY]; + }, transform.mScale[VY], scale_v_same, true, 1e-3f); + readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) + { + return mat->mTextureTransform[texture_info].mRotation; + }, transform.mRotation, rotation_same, true, 1e-3f); + readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) + { + return mat->mTextureTransform[texture_info].mOffset[VX]; + }, transform.mOffset[VX], offset_u_same, true, 1e-3f); + readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) + { + return mat->mTextureTransform[texture_info].mOffset[VY]; + }, transform.mOffset[VY], offset_v_same, true, 1e-3f); + + gltfCtrlTextureScaleU->setValue(transform.mScale[VX]); + gltfCtrlTextureScaleV->setValue(transform.mScale[VY]); + gltfCtrlTextureRotation->setValue(transform.mRotation * RAD_TO_DEG); + gltfCtrlTextureOffsetU->setValue(transform.mOffset[VX]); + gltfCtrlTextureOffsetV->setValue(transform.mOffset[VY]); + + gltfCtrlTextureScaleU->setTentative(!scale_u_same); + gltfCtrlTextureScaleV->setTentative(!scale_v_same); + gltfCtrlTextureRotation->setTentative(!rotation_same); + gltfCtrlTextureOffsetU->setTentative(!offset_u_same); + gltfCtrlTextureOffsetV->setTentative(!offset_v_same); + } + } } void LLPanelFace::updateVisibilityGLTF() @@ -1748,8 +1879,8 @@ void LLPanelFace::updateVisibilityGLTF() getChildView("gltfTextureScaleU")->setVisible(show_pbr_transform); getChildView("gltfTextureScaleV")->setVisible(show_pbr_transform); getChildView("gltfTextureRotation")->setVisible(show_pbr_transform); - getChildView("gltfTextureTranslationU")->setVisible(show_pbr_transform); - getChildView("gltfTextureTranslationV")->setVisible(show_pbr_transform); + getChildView("gltfTextureOffsetU")->setVisible(show_pbr_transform); + getChildView("gltfTextureOffsetV")->setVisible(show_pbr_transform); } void LLPanelFace::updateCopyTexButton() @@ -2597,11 +2728,15 @@ void LLPanelFace::updateVisibility() bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && mComboMatMedia->getEnabled())); bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && mComboMatMedia->getEnabled(); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); + const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + const bool show_texture_info = show_pbr && texture_info != LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; radio_mat_type->setVisible(show_material); // Shared material controls - getChildView("checkbox_sync_settings")->setVisible(show_material || show_media); + getChildView("checkbox_sync_settings")->setVisible(show_material || show_media || show_texture_info); getChildView("tex gen")->setVisible(show_material || show_media); getChildView("combobox texgen")->setVisible(show_material || show_media); getChildView("button align textures")->setVisible(show_material || show_media); @@ -4538,54 +4673,78 @@ void LLPanelFace::onCommitPlanarAlign(LLUICtrl* ctrl, void* userdata) self->sendTextureInfo(); } -// static -void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl, void* userdata) +void updateGLTFTextureTransform(float value, U32 pbr_type, std::function<void(LLGLTFMaterial::TextureTransform*)> edit) { -#if 0 - LLPanelFace* self = (LLPanelFace*)userdata; - LL_WARNS() << ctrl->getValue().asReal() << LL_ENDL; // TODO: Remove - // TODO -#endif + U32 texture_info_start; + U32 texture_info_end; + if (gSavedSettings.getBOOL("SyncMaterialSettings")) + { + texture_info_start = 0; + texture_info_end = LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; + } + else + { + texture_info_start = texture_info_from_pbrtype(pbr_type); + texture_info_end = texture_info_start + 1; + } + updateSelectedGLTFMaterials([&](LLGLTFMaterial* new_override) + { + for (U32 ti = texture_info_start; ti < texture_info_end; ++ti) + { + LLGLTFMaterial::TextureTransform& new_transform = new_override->mTextureTransform[(LLGLTFMaterial::TextureInfo)ti]; + edit(&new_transform); + } + }); } -// static -void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl) { -#if 0 - LLPanelFace* self = (LLPanelFace*)userdata; - LL_WARNS() << ctrl->getValue().asReal() << LL_ENDL; // TODO: Remove - // TODO -#endif + const float value = ctrl->getValue().asReal(); + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + { + new_transform->mScale.mV[VX] = value; + }); } -// static -void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl) +{ + const float value = ctrl->getValue().asReal(); + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + { + new_transform->mScale.mV[VY] = value; + }); +} + +void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl) { -#if 0 - LLPanelFace* self = (LLPanelFace*)userdata; - LL_WARNS() << ctrl->getValue().asReal() << LL_ENDL; // TODO: Remove - // TODO -#endif + const float value = ctrl->getValue().asReal() * DEG_TO_RAD; + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + { + new_transform->mRotation = value; + }); } -// static -void LLPanelFace::onCommitGLTFTextureTranslationU(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitGLTFTextureOffsetU(LLUICtrl* ctrl) { -#if 0 - LLPanelFace* self = (LLPanelFace*)userdata; - LL_WARNS() << ctrl->getValue().asReal() << LL_ENDL; // TODO: Remove - // TODO -#endif + const float value = ctrl->getValue().asReal(); + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + { + new_transform->mOffset.mV[VX] = value; + }); } -// static -void LLPanelFace::onCommitGLTFTextureTranslationV(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitGLTFTextureOffsetV(LLUICtrl* ctrl) { -#if 0 - LLPanelFace* self = (LLPanelFace*)userdata; - LL_WARNS() << ctrl->getValue().asReal() << LL_ENDL; // TODO: Remove - // TODO -#endif + const float value = ctrl->getValue().asReal(); + const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); + updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + { + new_transform->mOffset.mV[VY] = value; + }); } void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 0d8a86069d..69744689b5 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -229,11 +229,11 @@ protected: static void onCommitGlow( LLUICtrl* ctrl, void *userdata); static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); - static void onCommitGLTFTextureScaleU(LLUICtrl* ctrl, void* userinfo); - static void onCommitGLTFTextureScaleV(LLUICtrl* ctrl, void* userinfo); - static void onCommitGLTFRotation(LLUICtrl* ctrl, void* userinfo); - static void onCommitGLTFTextureTranslationU(LLUICtrl* ctrl, void* userinfo); - static void onCommitGLTFTextureTranslationV(LLUICtrl* ctrl, void* userinfo); + void onCommitGLTFTextureScaleU(LLUICtrl* ctrl); + void onCommitGLTFTextureScaleV(LLUICtrl* ctrl); + void onCommitGLTFRotation(LLUICtrl* ctrl); + void onCommitGLTFTextureOffsetU(LLUICtrl* ctrl); + void onCommitGLTFTextureOffsetV(LLUICtrl* ctrl); static void onClickAutoFix(void*); static void onAlignTexture(void*); static void onClickBtnLoadInvPBR(void* userdata); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index 91cd28d80a..06e2a6e98e 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -896,10 +896,12 @@ follows="left|top" height="19" initial_value="1" - label="ScaleU" + label="Scale u" label_width="205" layout="topleft" left="10" + min_val="-100" + max_val="100" name="gltfTextureScaleU" top_delta="-115" width="265" /> @@ -907,10 +909,12 @@ follows="left|top" height="19" initial_value="1" - label="ScaleV" + label="Scale v" label_width="205" layout="topleft" left="10" + min_val="-100" + max_val="100" name="gltfTextureScaleV" width="265" /> <spinner @@ -921,27 +925,33 @@ label_width="205" layout="topleft" left="10" + min_val="-360" + max_val="360" name="gltfTextureRotation" width="265" /> <spinner follows="left|top" height="19" initial_value="0" - label="TranslationU" + label="Offset u" label_width="205" layout="topleft" left="10" - name="gltfTextureTranslationU" + min_val="-999" + max_val="999" + name="gltfTextureOffsetU" width="265" /> <spinner follows="left|top" height="19" initial_value="0" - label="TranslationV" + label="Offset v" label_width="205" layout="topleft" left="10" - name="gltfTextureTranslationV" + min_val="-999" + max_val="999" + name="gltfTextureOffsetV" width="265" /> <!-- END PBR Material texture transform parameters --> <check_box |