[Bf-blender-cvs] [ffaaa0bcbf4] master: UV: Edge selection support

Siddhartha Jejurkar noreply at git.blender.org
Thu Mar 3 13:42:05 CET 2022


Commit: ffaaa0bcbf477c30cf3665b9330bbbb767397169
Author: Siddhartha Jejurkar
Date:   Thu Mar 3 17:32:07 2022 +0530
Branches: master
https://developer.blender.org/rBffaaa0bcbf477c30cf3665b9330bbbb767397169

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

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M	release/scripts/startup/bl_ui/space_image.py
M	source/blender/bmesh/tools/bmesh_path_uv.c
M	source/blender/draw/engines/overlay/overlay_edit_uv.c
M	source/blender/draw/engines/overlay/overlay_private.h
M	source/blender/draw/engines/overlay/overlay_shader.c
M	source/blender/draw/engines/overlay/shaders/edit_uv_edges_frag.glsl
M	source/blender/draw/engines/overlay/shaders/edit_uv_edges_geom.glsl
M	source/blender/draw/engines/overlay/shaders/edit_uv_edges_vert.glsl
M	source/blender/editors/include/ED_uvedit.h
M	source/blender/editors/mesh/editmesh_undo.c
M	source/blender/editors/uvedit/uvedit_intern.h
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/editors/uvedit/uvedit_path.c
M	source/blender/editors/uvedit/uvedit_rip.c
M	source/blender/editors/uvedit/uvedit_select.c
M	source/blender/editors/uvedit/uvedit_smart_stitch.c
M	source/blender/editors/uvedit/uvedit_unwrap_ops.c
M	source/blender/makesdna/DNA_meshdata_types.h
M	source/blender/makesrna/intern/rna_mesh.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/python/bmesh/bmesh_py_types_meshdata.c

===================================================================

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)
diff --git a/source/blender/bmesh/tools/bmesh_path_uv.c b/source/blender/bmesh/tools/bmesh_path_uv.c
index a2b35839454..76697f51ac7 100644
--- a/source/blender/bmesh/tools/bmesh_path_uv.c
+++ b/source/blender/bmesh/tools/bmesh_path_uv.c
@@ -185,7 +185,8 @@ struct LinkNode *BM_mesh_calc_path_uv_vert(BMesh *bm,
 /** \name BM_mesh_calc_path_uv_edge
  * \{ */
 
-/* TODO(campbell): not very urgent, since the operator fakes this using vertex path. */
+/* TODO(@sidd017): Setting this as todo, since we now support proper UV edge selection (D12028).
+ * Till then, continue using vertex path to fake shortest path calculation for edges. */
 
 /** \} */
 
diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c
index 8f566970337..93c75bde1e7 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c
@@ -113,6 +113,11 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata)
   const bool do_uv_overlay = is_image_type && is_uv_editor && has_edit_object;
   const bool show_modified_uvs = sima->flag & SI_DRAWSHADOW;
   const bool is_tiled_image = image && (image->source == IMA_SRC_TILED);
+  const bool do_edges_only = (ts->uv_flag & UV_SYNC_SELECTION) ?
+                                  /* NOTE: Ignore #SCE_SELECT_EDGE because a single selected edge
+                                   * on the mesh may cause singe UV vertices to be selected. */
+                                  false :
+                                  (ts->uv_selectmode == UV_SELECT_EDGE);
   const bool do_faces = ((sima->flag & SI_NO_DRAWFACES) == 0);
   const bool do_face_dots = (ts->uv_flag & UV_SYNC_SELECTION) ?
                                 (ts->selectmode & SCE_SELECT_FACE) != 0 :
@@ -124,6 +129,7 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata)
                                   (brush->imagepaint_tool == PAINT_TOOL_CLONE) &&
                                   brush->clone.image;
 
+  pd->edit_uv.do_verts = show_overlays && (!do_edges_only);
   pd->edit_uv.do_faces = show_overlays && do_faces && !do_uvstretching_overlay;
   pd->edit_uv.do_face_dots = show_overlays && do_faces && do_face_dots;
   pd->edit_uv.do_uv_overlay = show_overlays && do_uv_overlay;
@@ -183,7 +189,11 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
       DRW_PASS_CREATE(psl->edit_uv_edges_ps,
                       DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
                           DRW_STATE_BLEND_ALPHA);
-      GPUShader *sh = OVERLAY_shader_edit_uv_edges_get();
+      const bool do_edges_only = (ts->uv_flag & UV_SYNC_SELECTION) ?
+                                     false :
+                                     (ts->uv_selectmode & UV_SELECT_EDGE);
+      GPUShader *sh = do_edges_only ? OVERLAY_shader_edit_uv_edges_for_edge_select_get() :
+                                      OVERLAY_shader_edit_uv_edges_get();
       if (pd->edit_uv.do_uv_shadow_overlay) {
         pd->edit_uv_shadow_edges_grp = DRW_shgroup_create(sh, psl->edit_uv_edges_ps);
         DRW_shgroup_uniform_block(pd->edit_uv_shadow_edges_grp, "globalsBlock", G_draw.block_ubo);
@@ -211,11 +221,14 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
   }
 
   if (pd->edit_uv.do_uv_overlay) {
-    /* uv verts */
-    {
+    if (pd->edit_uv.do_verts || pd->edit_uv.do_face_dots) {
       DRW_PASS_CREATE(psl->edit_uv_verts_ps,
                       DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
                           DRW_STATE_BLEND_ALPHA);
+    }
+
+    /* uv verts */
+    if (pd->edit_uv.do_verts) {
       GPUShader *sh = OVERLAY_shader_edit_uv_verts_get();
       pd->edit_uv_verts_grp = DRW_shgroup_create(sh, psl->edit_uv_verts_ps);
 
@@ -430,9 +443,11 @@ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob)
       if (geom) {
         DRW_shgroup_call_obmat(pd->edit_uv_edges_grp, geom, NULL);
       }
-      geom = DRW_mesh_batch_cache_get_edituv_verts(ob, ob->data);
-      if (geom) {
-        DRW_shgroup_call_obmat(pd->edit_uv_verts_grp, geom, NULL);
+      if (pd->edit_uv.do_verts) {
+        geom = DRW_mesh_batch_cache_get_edituv_verts(ob, ob->data);
+        if (geom) {
+          DRW_shgroup_call_obmat(pd->edit_uv_verts_grp, geom, NULL);
+        }
       }
       if (pd->edit_uv.do_faces) {
         geom = DRW_mesh_batch_cache_get_edituv_faces(ob, ob->data);
diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h
index 3cc70527659..94eccbcb1f3 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -359,6 +359,7 @@ typedef struct OVERLAY_PrivateData {
     bool do_stencil_overlay;
     bool do_mask_overlay;
 
+    bool do_verts;
     bool do_faces;
     bool do_face_dots;
 
@@ -699,6 +700,7 @@ GPUShader *OVERLAY_shader_edit_mesh_vert(void);
 GPUShader *OVERLAY_shader_edit_particle_strand(void);
 GPUShader *OVERLAY_shader_edit_particle_point(void);
 GPUShader *OVERLAY_shader_edit_uv_edges_get(void);
+GPUShader *OVERLAY_shader_edit_uv_edges_for_edge_select_get(void);
 GPUShader *OVERLAY_shader_edit_uv_face_get(void);
 GPUShader *OVERLAY_shader_edit_uv_face_dots_get(void);
 GPUShader *OVERLAY_shader_edit_uv_verts_get(void);
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c
index da2c2cff2f6..639b20feae4 100644
--- a/source/blender/draw/engines/overlay/overlay_shader.c
+++ b/source/blender/draw/engines/overlay/overlay_shader.c
@@ -167,6 +167,7 @@ typedef struct OVERLAY_Shaders {
   GPUShader *edit_uv_verts;
   GPUShader *edit_uv_faces;
   GPUShader *edit_uv_edges;
+  GPUShader *edit_uv_edges_for_edge_select;
   GPU

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list