From 7b3e1cbb9627031dcad6b986b95d2faec295d950 Mon Sep 17 00:00:00 2001 From: Chris Blackbourn Date: Thu, 6 Jul 2023 14:33:47 +1200 Subject: [PATCH] Fix #109674: UV: Follow Active Quads uses face selection in 3d editor To ensure consistency between the UV unwrapping operators, the `UV > Follow Active Quads` operator will now use 3D selection when called from the 3D editor, and UV selection when called from the UV editor. --- .../startup/bl_operators/uvcalc_follow_active.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/startup/bl_operators/uvcalc_follow_active.py b/scripts/startup/bl_operators/uvcalc_follow_active.py index 4bf997fac70..ff6c0017dc9 100644 --- a/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -16,7 +16,7 @@ STATUS_ERR_MISSING_UV_LAYER = (1 << 4) STATUS_ERR_NO_FACES_SELECTED = (1 << 5) -def extend(obj, EXTEND_MODE): +def extend(obj, EXTEND_MODE, use_uv_selection): import bmesh from .uvcalc_transform import is_face_uv_selected @@ -38,7 +38,11 @@ def extend(obj, EXTEND_MODE): uv_act = bm.loops.layers.uv.active # Always use the active UV layer. # Construct a set of selected quads. - faces = {f for f in bm.faces if len(f.verts) == 4 and is_face_uv_selected(f, uv_act, False)} + faces = {f for f in bm.faces if len(f.verts) == 4 and f.select} + if use_uv_selection: + # Filter `faces` to extract only UV selected quads. + faces = {f for f in faces if is_face_uv_selected(f, uv_act, False)} + if not faces: return STATUS_ERR_NO_FACES_SELECTED @@ -214,6 +218,11 @@ def extend(obj, EXTEND_MODE): def main(context, operator): + use_uv_selection = True + view = context.space_data + if context.space_data and context.space_data.type == 'VIEW_3D': + use_uv_selection = False # When called from the 3D editor, UV selection is ignored. + num_meshes = 0 num_errors = 0 status = 0 @@ -222,7 +231,7 @@ def main(context, operator): for ob in ob_list: num_meshes += 1 - ret = extend(ob, operator.properties.mode) + ret = extend(ob, operator.properties.mode, use_uv_selection) if ret != STATUS_OK: num_errors += 1 status |= ret