From ffaaa0bcbf477c30cf3665b9330bbbb767397169 Mon Sep 17 00:00:00 2001 From: Siddhartha Jejurkar Date: Thu, 3 Mar 2022 17:32:07 +0530 Subject: UV: Edge selection support This patch adds edge selection support for UV editing (refer T76545). Developed as a part of GSoC 2021 project - UV Editor Improvements. Previously, selections in the UV editor always flushed down to vertices and this caused multiple issues such as T76343, T78757 and T26676. This patch fixes that by adding edge selection support for all UV operators and adding support for flushing selections between vertices and edges. Updating UV select modes is now done using a separate operator, which also handles select mode flushing and undo for UV select modes. Drawing edges (in UV edge mode) is also updated to match the edit-mesh display in the 3D viewport. Notes on technical changes made with this patch: * MLOOPUV_EDGESEL flag is restored (was removed in rB9fa29fe7652a). * Support for flushing selection between vertices and edges. * Restored the BMLoopUV.select_edge boolean in the Python API. * New operator to update UV select modes and flushing. * UV select mode is now part of editmesh undo. TODOs added with this patch: * Edge support for shortest path operator (currently uses vertex path logic). * Change default theme color instead of reducing contrast with edge-select. * Proper UV element selections for Reveal Hidden operator. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D12028 --- .../presets/keyconfig/keymap_data/blender_default.py | 6 +++--- .../keyconfig/keymap_data/industry_compatible_data.py | 16 ++++++++-------- release/scripts/startup/bl_ui/space_image.py | 12 +++++++++++- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'release') diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 6f4f862a3b8..83946fbf68f 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -385,9 +385,9 @@ def _template_items_uv_select_mode(params): *_template_items_editmode_mesh_select_mode(params), # Hack to prevent fall-through, when sync select isn't enabled (and the island button isn't visible). ("mesh.select_mode", {"type": 'FOUR', "value": 'PRESS'}, None), - *(("wm.context_set_enum", {"type": NUMBERS_1[i], "value": 'PRESS'}, - {"properties": [("data_path", 'tool_settings.uv_select_mode'), ("value", ty)]}) - for i, ty in enumerate(('VERTEX', 'EDGE', 'FACE', 'ISLAND'))) + *(("uv.select_mode", {"type": k, "value": 'PRESS'}, + {"properties": [("type", e)]}) + for k, e in (('ONE', 'VERTEX'), ('TWO', 'EDGE'), ('THREE', 'FACE'), ('FOUR', 'ISLAND'))) ] diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index e65ac32d088..8c303bc3f69 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -554,14 +554,14 @@ def km_uv_editor(params): ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None), # Selection modes. *_template_items_editmode_mesh_select_mode(params), - ("wm.context_set_enum", {"type": 'ONE', "value": 'PRESS'}, - {"properties": [("data_path", 'tool_settings.uv_select_mode'), ("value", 'VERTEX')]}), - ("wm.context_set_enum", {"type": 'TWO', "value": 'PRESS'}, - {"properties": [("data_path", 'tool_settings.uv_select_mode'), ("value", 'EDGE')]}), - ("wm.context_set_enum", {"type": 'THREE', "value": 'PRESS'}, - {"properties": [("data_path", 'tool_settings.uv_select_mode'), ("value", 'FACE')]}), - ("wm.context_set_enum", {"type": 'FOUR', "value": 'PRESS'}, - {"properties": [("data_path", 'tool_settings.uv_select_mode'), ("value", 'ISLAND')]}), + ("uv.select_mode", {"type": 'ONE', "value": 'PRESS'}, + {"properties": [("type", 'VERTEX')]}), + ("uv.select_mode", {"type": 'TWO', "value": 'PRESS'}, + {"properties": [("type", 'EDGE')]}), + ("uv.select_mode", {"type": 'THREE', "value": 'PRESS'}, + {"properties": [("type", 'FACE')]}), + ("uv.select_mode", {"type": 'FOUR', "value": 'PRESS'}, + {"properties": [("type", 'ISLAND')]}), ("uv.select", {"type": 'LEFTMOUSE', "value": 'CLICK'}, {"properties": [("extend", False), ("deselect_all", True)]}), diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 5b840fae341..0aac224bc68 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -779,7 +779,17 @@ class IMAGE_HT_header(Header): if tool_settings.use_uv_select_sync: layout.template_edit_mode_selection() else: - layout.prop(tool_settings, "uv_select_mode", text="", expand=True) + row = layout.row(align=True) + uv_select_mode = tool_settings.uv_select_mode[:] + row.operator("uv.select_mode", text="", icon='UV_VERTEXSEL', + depress=(uv_select_mode == 'VERTEX')).type = 'VERTEX' + row.operator("uv.select_mode", text="", icon='UV_EDGESEL', + depress=(uv_select_mode == 'EDGE')).type = 'EDGE' + row.operator("uv.select_mode", text="", icon='UV_FACESEL', + depress=(uv_select_mode == 'FACE')).type = 'FACE' + row.operator("uv.select_mode", text="", icon='UV_ISLANDSEL', + depress=(uv_select_mode == 'ISLAND')).type = 'ISLAND' + layout.prop(tool_settings, "uv_sticky_select_mode", icon_only=True) IMAGE_MT_editor_menus.draw_collapsible(context, layout) -- cgit v1.2.3