From 9c25c14bc301c6f305d792629288087bfa8112f3 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 3 Apr 2023 15:13:38 +0200 Subject: [PATCH] Fix #106396: UV stitch crash with hidden faces This was the case with hidden faces and `Sync Selection` turned ON. Caused by 8f543a73abc42843fb924fc6d849e3055e3ae011. Since 8f543a73abc42843fb924fc6d849e3055e3ae011, the UV element map respects the hidden state of geometry, but stitching [which also respected this on its own even prior to the culprit commit in its calculation of connectivity] did this differently [it only skipped hidden geo when UV_SYNC_SELECTION was OFF -- even though UVs would not be visible which is probably the real error here, I believe there is this principle that we "dont act on stuff we dont see"]. To fix this, also skip hidden geo (even with UV_SYNC_SELECTION = ON) in the stitch calculation of connectivity, just as `BM_uv_element_map_create` does it. --- source/blender/editors/mesh/editmesh_utils.c | 2 +- source/blender/editors/uvedit/uvedit_smart_stitch.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index b9dc21430f2..a661a82500f 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -974,7 +974,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, const bool use_seams, const bool do_islands) { - /* In uv sync selection, all UVs are visible. */ + /* In uv sync selection, all UVs (from unhidden geometry) are visible. */ const bool face_selected = !(scene->toolsettings->uv_flag & UV_SYNC_SELECTION); BMVert *ev; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 4ca9f2d5b82..b5165f4f1de 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1889,9 +1889,12 @@ static StitchState *stitch_init(bContext *C, counter = 0; /* Now, on to generate our uv connectivity data */ + const bool face_selected = !(ts->uv_flag & UV_SYNC_SELECTION); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!(ts->uv_flag & UV_SYNC_SELECTION) && - (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT))) { + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { + continue; + } + if (face_selected && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { continue; } -- 2.30.2