diff options
| author | Cosmic Linden <cosmic@lindenlab.com> | 2023-03-22 15:26:21 -0700 | 
|---|---|---|
| committer | Cosmic Linden <cosmic@lindenlab.com> | 2023-03-22 17:07:42 -0700 | 
| commit | ad590887cc1bd950c189f71b4edd52c012d02e7a (patch) | |
| tree | 3bb5839592715de742e2fe1cebc60300c53d1e8f | |
| parent | 65fe41eb6e0df6029e9187a26e1aee5f27fa70d6 (diff) | |
SL-19399: Allow editing all PBR texture transforms at once with Complete material radio
| -rw-r--r-- | indra/newview/llpanelface.cpp | 101 | 
1 files changed, 67 insertions, 34 deletions
| diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index cb7bc7b5df..5cffef5f6d 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1827,9 +1827,7 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,      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; -        const bool new_state = show_texture_info && has_pbr_capabilities && has_pbr_material; +        const bool new_state = has_pbr_capabilities && has_pbr_material;          LLUICtrl* gltfCtrlTextureScaleU = getChild<LLUICtrl>("gltfTextureScaleU");          LLUICtrl* gltfCtrlTextureScaleV = getChild<LLUICtrl>("gltfTextureScaleV"); @@ -1858,11 +1856,6 @@ void LLPanelFace::updateVisibilityGLTF()      const U32 pbr_type = radio_pbr_type->getSelectedIndex();      const bool show_pbr_render_material_id = show_pbr && (pbr_type == PBRTYPE_RENDER_MATERIAL_ID); -    const bool show_pbr_base_color = show_pbr && (pbr_type == PBRTYPE_BASE_COLOR); -    const bool show_pbr_normal = show_pbr && (pbr_type == PBRTYPE_NORMAL); -    const bool show_pbr_metallic_roughness = show_pbr && (pbr_type == PBRTYPE_METALLIC_ROUGHNESS); -    const bool show_pbr_emissive = show_pbr && (pbr_type == PBRTYPE_EMISSIVE); -    const bool show_pbr_transform = show_pbr_base_color || show_pbr_normal || show_pbr_metallic_roughness || show_pbr_emissive;      getChildView("pbr_control")->setVisible(show_pbr_render_material_id); @@ -1870,11 +1863,11 @@ void LLPanelFace::updateVisibilityGLTF()      getChildView("edit_selected_pbr")->setVisible(show_pbr_render_material_id);      getChildView("save_selected_pbr")->setVisible(show_pbr_render_material_id); -    getChildView("gltfTextureScaleU")->setVisible(show_pbr_transform); -    getChildView("gltfTextureScaleV")->setVisible(show_pbr_transform); -    getChildView("gltfTextureRotation")->setVisible(show_pbr_transform); -    getChildView("gltfTextureOffsetU")->setVisible(show_pbr_transform); -    getChildView("gltfTextureOffsetV")->setVisible(show_pbr_transform); +    getChildView("gltfTextureScaleU")->setVisible(show_pbr); +    getChildView("gltfTextureScaleV")->setVisible(show_pbr); +    getChildView("gltfTextureRotation")->setVisible(show_pbr); +    getChildView("gltfTextureOffsetU")->setVisible(show_pbr); +    getChildView("gltfTextureOffsetV")->setVisible(show_pbr);  }  void LLPanelFace::updateCopyTexButton() @@ -4654,7 +4647,8 @@ void LLPanelFace::updateGLTFTextureTransform(float value, U32 pbr_type, std::fun  {      U32 texture_info_start;      U32 texture_info_end; -    if (gSavedSettings.getBOOL("SyncMaterialSettings")) +    const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); +    if (gSavedSettings.getBOOL("SyncMaterialSettings") || texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT)      {          texture_info_start = 0;          texture_info_end = LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; @@ -4685,11 +4679,20 @@ void LLPanelFace::setMaterialOverridesFromSelection()  {      const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex();      const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); +    U32 texture_info_start; +    U32 texture_info_end;      if (texture_info == LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT)      { -        return; +        texture_info_start = 0; +        texture_info_end = LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT; +    } +    else +    { +        texture_info_start = texture_info; +        texture_info_end = texture_info + 1;      } +    bool read_transform = true;      LLGLTFMaterial::TextureTransform transform;      bool scale_u_same = true;      bool scale_v_same = true; @@ -4697,26 +4700,56 @@ void LLPanelFace::setMaterialOverridesFromSelection()      bool offset_u_same = true;      bool offset_v_same = true; -    readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) -    { -        return mat ? mat->mTextureTransform[texture_info].mScale[VX] : 0.f; -    }, transform.mScale[VX], scale_u_same, true, 1e-3f); -    readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) -    { -        return mat ? mat->mTextureTransform[texture_info].mScale[VY] : 0.f; -    }, transform.mScale[VY], scale_v_same, true, 1e-3f); -    readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) +    for (U32 i = texture_info_start; i < texture_info_end; ++i)      { -        return mat ? mat->mTextureTransform[texture_info].mRotation : 0.f; -    }, transform.mRotation, rotation_same, true, 1e-3f); -    readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) -    { -        return mat ? mat->mTextureTransform[texture_info].mOffset[VX] : 0.f; -    }, transform.mOffset[VX], offset_u_same, true, 1e-3f); -    readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) -    { -        return mat ? mat->mTextureTransform[texture_info].mOffset[VY] : 0.f; -    }, transform.mOffset[VY], offset_v_same, true, 1e-3f); +        LLGLTFMaterial::TextureTransform this_transform; +        bool this_scale_u_same = true; +        bool this_scale_v_same = true; +        bool this_rotation_same = true; +        bool this_offset_u_same = true; +        bool this_offset_v_same = true; + +        readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) +        { +            return mat ? mat->mTextureTransform[i].mScale[VX] : 0.f; +        }, this_transform.mScale[VX], this_scale_u_same, true, 1e-3f); +        readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) +        { +            return mat ? mat->mTextureTransform[i].mScale[VY] : 0.f; +        }, this_transform.mScale[VY], this_scale_v_same, true, 1e-3f); +        readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) +        { +            return mat ? mat->mTextureTransform[i].mRotation : 0.f; +        }, this_transform.mRotation, this_rotation_same, true, 1e-3f); +        readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) +        { +            return mat ? mat->mTextureTransform[i].mOffset[VX] : 0.f; +        }, this_transform.mOffset[VX], this_offset_u_same, true, 1e-3f); +        readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat) +        { +            return mat ? mat->mTextureTransform[i].mOffset[VY] : 0.f; +        }, this_transform.mOffset[VY], this_offset_v_same, true, 1e-3f); + +        scale_u_same = scale_u_same && this_scale_u_same; +        scale_v_same = scale_v_same && this_scale_v_same; +        rotation_same = rotation_same && this_rotation_same; +        offset_u_same = offset_u_same && this_offset_u_same; +        offset_v_same = offset_v_same && this_offset_v_same; + +        if (read_transform) +        { +            read_transform = false; +            transform = this_transform; +        } +        else +        { +            scale_u_same = scale_u_same && (this_transform.mScale[VX] == transform.mScale[VX]); +            scale_v_same = scale_v_same && (this_transform.mScale[VY] == transform.mScale[VY]); +            rotation_same = rotation_same && (this_transform.mRotation == transform.mRotation); +            offset_u_same = offset_u_same && (this_transform.mOffset[VX] == transform.mOffset[VX]); +            offset_v_same = offset_v_same && (this_transform.mOffset[VY] == transform.mOffset[VY]); +        } +    }      LLUICtrl* gltfCtrlTextureScaleU = getChild<LLUICtrl>("gltfTextureScaleU");      LLUICtrl* gltfCtrlTextureScaleV = getChild<LLUICtrl>("gltfTextureScaleV"); | 
