Commit: 143e74c0b8ebd7248d2a50353d0baf67347b83bf Author: Chris Blackbourn Date: Mon Nov 28 13:14:42 2022 +1300 Branches: blender-v3.4-release https://developer.blender.org/rB143e74c0b8ebd7248d2a50353d0baf67347b83bf
Fix (unreported) uv unwrap selected was splitting selection Add support for `pin_unselected` in new UV Packing API. Regression introduced by API change in rBe3075f3cf7ce. Duplicate change to rB0ce18561bc82 in master. =================================================================== M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c =================================================================== diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index b97cd6a9099..0cc2f317564 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -353,6 +353,7 @@ struct UVPackIsland_Params { uint use_seams : 1; uint correct_aspect : 1; bool ignore_pinned; /* Ignore islands which have any pinned UVs. */ + bool pin_unselected; /* Treat unselected UVs as if they were pinned. */ eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */ float margin; /* Additional space to add around each island. */ }; diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 92745667505..27a951779c0 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -600,7 +600,7 @@ static BoxPack *pack_islands_params(const blender::Vector<FaceIsland *> &island_ return box_array; } -static bool island_has_pins(FaceIsland *island) +static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected) { BMLoop *l; BMIter iter; @@ -611,6 +611,9 @@ static bool island_has_pins(FaceIsland *island) if (luv->flag & MLOOPUV_PINNED) { return true; } + if (pin_unselected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + return true; + } } } return false; @@ -657,12 +660,18 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, } } + bool only_selected_faces = params->only_selected_faces; + bool only_selected_uvs = params->only_selected_uvs; + if (params->ignore_pinned && params->pin_unselected) { + only_selected_faces = false; + only_selected_uvs = false; + } ListBase island_list = {nullptr}; bm_mesh_calc_uv_islands(scene, bm, &island_list, - params->only_selected_faces, - params->only_selected_uvs, + only_selected_faces, + only_selected_uvs, params->use_seams, aspect_y, cd_loop_uv_offset); @@ -670,7 +679,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Remove from linked list and append to blender::Vector. */ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, &island_list) { BLI_remlink(&island_list, island); - if (params->ignore_pinned && island_has_pins(island)) { + if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) { MEM_freeN(island->faces); MEM_freeN(island); continue; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 071f1c44c6b..81e1d673d08 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1101,6 +1101,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op) .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = false, + .pin_unselected = options.pin_unselected, .margin_method = RNA_enum_get(op->ptr, "margin_method"), .margin = RNA_float_get(op->ptr, "margin"), }; @@ -1879,6 +1880,7 @@ void ED_uvedit_live_unwrap(const Scene *scene, Object **objects, int objects_len .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = true, + .pin_unselected = options.pin_unselected, .margin_method = ED_UVPACK_MARGIN_SCALED, .margin = scene->toolsettings->uvcalc_margin, }; @@ -2026,6 +2028,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = true, + .pin_unselected = options.pin_unselected, .margin_method = RNA_enum_get(op->ptr, "margin_method"), .margin = RNA_float_get(op->ptr, "margin"), }; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs