Transform: Individual Origins: Create islands between only selected uvs.
authormano-wii <germano.costa@ig.com.br>
Tue, 31 Dec 2019 15:56:27 +0000 (12:56 -0300)
committermano-wii <germano.costa@ig.com.br>
Tue, 31 Dec 2019 16:04:57 +0000 (13:04 -0300)
Currently the islands are created depending only on the visible UVs.
This can be confusing because compared to Edit Meshes, islands are created based on the selected elements.

T68284 shows a case where this confusion is observed.

Differential Revision: https://developer.blender.org/D6502

source/blender/editors/include/ED_mesh.h
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/sculpt_paint/sculpt_uv.c
source/blender/editors/transform/transform_convert_mesh.c
source/blender/editors/uvedit/uvedit_smart_stitch.c

index 4bf43a2034ad7b33900b0ff702987920dcd842d5..90ad90058e7e752356f784fd3f8ca51104a42dfc 100644 (file)
@@ -109,7 +109,9 @@ void EDBM_update_generic(struct BMEditMesh *em,
                          const bool is_destructive);
 
 struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm,
-                                              const bool selected,
+                                              struct Scene *scene,
+                                              const bool face_selected,
+                                              const bool uv_selected,
                                               const bool use_winding,
                                               const bool do_islands);
 void BM_uv_element_map_free(struct UvElementMap *vmap);
index 42404554ed86305e0cf98e06199b4c203e14af68..67f8db71e54c8c54a2c05fc4f3dd05f135e89470 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "ED_mesh.h"
 #include "ED_screen.h"
+#include "ED_uvedit.h"
 #include "ED_view3d.h"
 
 #include "mesh_intern.h" /* own include */
@@ -662,7 +663,9 @@ UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v)
 
 /* A specialized vert map used by stitch operator */
 UvElementMap *BM_uv_element_map_create(BMesh *bm,
-                                       const bool selected,
+                                       const Scene *scene,
+                                       const bool face_selected,
+                                       const bool uv_selected,
                                        const bool use_winding,
                                        const bool do_islands)
 {
@@ -689,8 +692,17 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
 
   /* generate UvElement array */
   BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
-    if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
-      totuv += efa->len;
+    if (!face_selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
+      if (!uv_selected) {
+        totuv += efa->len;
+      }
+      else {
+        BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+          if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+            totuv++;
+          }
+        }
+      }
     }
   }
 
@@ -715,7 +727,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
       winding[j] = false;
     }
 
-    if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
+    if (!face_selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
       float(*tf_uv)[2] = NULL;
 
       if (use_winding) {
@@ -723,6 +735,10 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
       }
 
       BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
+        if (uv_selected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+          continue;
+        }
+
         buf->l = l;
         buf->separate = 0;
         buf->island = INVALID_ISLAND;
@@ -832,6 +848,10 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
           efa = stack[--stacksize];
 
           BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+            if (uv_selected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+              continue;
+            }
+
             UvElement *element, *initelement = element_map->vert[BM_elem_index_get(l->v)];
 
             for (element = initelement; element; element = element->next) {
index 8fbaf3396bd043a66cc3313ffdaa8ee4795043e6..72b02436b9261a581b06a8793cea0e3bd58b3800 100644 (file)
@@ -521,18 +521,18 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
     if (do_island_optimization) {
       /* We will need island information */
       if (ts->uv_flag & UV_SYNC_SELECTION) {
-        data->elementMap = BM_uv_element_map_create(bm, false, true, true);
+        data->elementMap = BM_uv_element_map_create(bm, scene, false, false, true, true);
       }
       else {
-        data->elementMap = BM_uv_element_map_create(bm, true, true, true);
+        data->elementMap = BM_uv_element_map_create(bm, scene, true, false, true, true);
       }
     }
     else {
       if (ts->uv_flag & UV_SYNC_SELECTION) {
-        data->elementMap = BM_uv_element_map_create(bm, false, true, false);
+        data->elementMap = BM_uv_element_map_create(bm, scene, false, false, true, false);
       }
       else {
-        data->elementMap = BM_uv_element_map_create(bm, true, true, false);
+        data->elementMap = BM_uv_element_map_create(bm, scene, true, false, true, false);
       }
     }
 
index 8b7dcecf9e80baa04f68f58c8bfc9de690d6f2f7..006f913f218f28a4ece5813a3d865327e185c20f 100644 (file)
@@ -1451,7 +1451,7 @@ void createTransUVs(bContext *C, TransInfo *t)
     if (is_prop_connected || is_island_center) {
       /* create element map with island information */
       const bool use_facesel = (ts->uv_flag & UV_SYNC_SELECTION) == 0;
-      elementmap = BM_uv_element_map_create(em->bm, use_facesel, false, true);
+      elementmap = BM_uv_element_map_create(em->bm, scene, use_facesel, true, false, true);
       if (elementmap == NULL) {
         continue;
       }
index 5a8301fae679fb0c3422c376b48e6b05d0717437..5d3d016e6c1103b6e93e6f894049e6ad9a0985e5 100644 (file)
@@ -1935,10 +1935,10 @@ static StitchState *stitch_init(bContext *C,
 
   /* in uv synch selection, all uv's are visible */
   if (ts->uv_flag & UV_SYNC_SELECTION) {
-    state->element_map = BM_uv_element_map_create(state->em->bm, false, true, true);
+    state->element_map = BM_uv_element_map_create(state->em->bm, scene, false, false, true, true);
   }
   else {
-    state->element_map = BM_uv_element_map_create(state->em->bm, true, true, true);
+    state->element_map = BM_uv_element_map_create(state->em->bm, scene, true, false, true, true);
   }
   if (!state->element_map) {
     state_delete(state);