[Bf-blender-cvs] [b88dd3b8e7b] master: UV: remove selection threshold for nearby coordinates

Campbell Barton noreply at git.blender.org
Tue Jul 21 06:33:44 CEST 2020


Commit: b88dd3b8e7b9c02ae08d4679bb427963c5d21250
Author: Campbell Barton
Date:   Tue Jul 21 12:54:23 2020 +1000
Branches: master
https://developer.blender.org/rBb88dd3b8e7b9c02ae08d4679bb427963c5d21250

UV: remove selection threshold for nearby coordinates

Internally UV selection considered close UV's to be connected.
While this could be convenient in some cases,
it complicates logic for more advanced selection operations that
need to check when UV's should be considered part of the same vertex
since simple threshold checks would give different results depending
on the order of UV's tested.

Users must now run "Merge by Distance" instead of relying
on this selection threshold.

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

M	source/blender/bmesh/intern/bmesh_query_uv.c
M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/include/ED_uvedit.h
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/transform/transform_convert_mesh_uv.c
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/editors/uvedit/uvedit_select.c

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

diff --git a/source/blender/bmesh/intern/bmesh_query_uv.c b/source/blender/bmesh/intern/bmesh_query_uv.c
index 72f264e148c..b9ea51f0c4d 100644
--- a/source/blender/bmesh/intern/bmesh_query_uv.c
+++ b/source/blender/bmesh/intern/bmesh_query_uv.c
@@ -32,11 +32,6 @@
 #include "bmesh.h"
 #include "intern/bmesh_private.h"
 
-static bool compare_v2v2_v2(const float v1[2], const float v2[2], const float limit[2])
-{
-  return (compare_ff(v1[0], v2[0], limit[0]) && compare_ff(v1[1], v2[1], limit[1]));
-}
-
 static void uv_aspect(const BMLoop *l,
                       const float aspect[2],
                       const int cd_loop_uv_offset,
@@ -117,26 +112,6 @@ float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset)
   return cross_poly_v2(uvs, f->len);
 }
 
-/**
- * Check if two loops that share an edge also have the same UV coordinates.
- */
-bool BM_loop_uv_share_edge_check_with_limit(BMLoop *l_a,
-                                            BMLoop *l_b,
-                                            const float limit[2],
-                                            const int cd_loop_uv_offset)
-{
-  BLI_assert(l_a->e == l_b->e);
-  MLoopUV *luv_a_curr = BM_ELEM_CD_GET_VOID_P(l_a, cd_loop_uv_offset);
-  MLoopUV *luv_a_next = BM_ELEM_CD_GET_VOID_P(l_a->next, cd_loop_uv_offset);
-  MLoopUV *luv_b_curr = BM_ELEM_CD_GET_VOID_P(l_b, cd_loop_uv_offset);
-  MLoopUV *luv_b_next = BM_ELEM_CD_GET_VOID_P(l_b->next, cd_loop_uv_offset);
-  if (l_a->v != l_b->v) {
-    SWAP(MLoopUV *, luv_b_curr, luv_b_next);
-  }
-  return (compare_v2v2_v2(luv_a_curr->uv, luv_b_curr->uv, limit) &&
-          compare_v2v2_v2(luv_a_next->uv, luv_b_next->uv, limit));
-}
-
 /**
  * Check if two loops that share an edge also have the same UV coordinates.
  */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 046eadb2ec3..392a5075750 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -123,7 +123,6 @@ struct BMFace *EDBM_uv_active_face_get(struct BMEditMesh *em,
 void BM_uv_vert_map_free(struct UvVertMap *vmap);
 struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v);
 struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm,
-                                        const float limit[2],
                                         const bool use_select,
                                         const bool use_winding);
 
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index b9b8d162d85..c89a9fe0e99 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -121,7 +121,6 @@ void uvedit_face_select_set_with_sticky(const struct SpaceImage *sima,
                                         struct BMFace *efa,
                                         const bool select,
                                         const bool do_history,
-                                        const float limit[2],
                                         const int cd_loop_uv_offset);
 void uvedit_face_select_set(const struct Scene *scene,
                             struct BMEditMesh *em,
@@ -145,7 +144,6 @@ void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima,
                                         struct BMLoop *l,
                                         const bool select,
                                         const bool do_history,
-                                        const float limit[2],
                                         const uint cd_loop_uv_offset);
 void uvedit_edge_select_set(const struct Scene *scene,
                             struct BMEditMesh *em,
@@ -169,7 +167,6 @@ void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima,
                                       struct BMLoop *l,
                                       const bool select,
                                       const bool do_history,
-                                      const float limit[2],
                                       const uint cd_loop_uv_offset);
 void uvedit_uv_select_set(const struct Scene *scene,
                           struct BMEditMesh *em,
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 2188f758dc7..46c63d2e057 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -525,10 +525,7 @@ void EDBM_flag_enable_all(BMEditMesh *em, const char hflag)
 /**
  * Return a new UVVertMap from the editmesh
  */
-UvVertMap *BM_uv_vert_map_create(BMesh *bm,
-                                 const float limit[2],
-                                 const bool use_select,
-                                 const bool use_winding)
+UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool use_winding)
 {
   BMVert *ev;
   BMFace *efa;
@@ -537,7 +534,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
   /* vars from original func */
   UvVertMap *vmap;
   UvMapVert *buf;
-  MLoopUV *luv;
+  const MLoopUV *luv;
   uint a;
   int totverts, i, totuv, totfaces;
   const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
@@ -609,7 +606,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
   BM_ITER_MESH_INDEX (ev, &iter, bm, BM_VERTS_OF_MESH, a) {
     UvMapVert *newvlist = NULL, *vlist = vmap->vert[a];
     UvMapVert *iterv, *v, *lastv, *next;
-    float *uv, *uv2, uvdiff[2];
+    const float *uv, *uv2;
 
     while (vlist) {
       v = vlist;
@@ -633,9 +630,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
         luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
         uv2 = luv->uv;
 
-        sub_v2_v2v2(uvdiff, uv2, uv);
-
-        if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] &&
+        if (compare_v2v2(uv2, uv, STD_UV_CONNECT_LIMIT) &&
             (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) {
           if (lastv) {
             lastv->next = next;
@@ -777,7 +772,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
   BM_ITER_MESH_INDEX (ev, &iter, bm, BM_VERTS_OF_MESH, i) {
     UvElement *newvlist = NULL, *vlist = element_map->vert[i];
     UvElement *iterv, *v, *lastv, *next;
-    float *uv, *uv2, uvdiff[2];
+    const float *uv, *uv2;
     bool uv_vert_sel, uv2_vert_sel;
 
     while (vlist) {
@@ -802,12 +797,10 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
         uv2 = luv->uv;
         uv2_vert_sel = luv->flag & MLOOPUV_VERTSEL;
 
-        sub_v2_v2v2(uvdiff, uv2, uv);
-
         /* Check if the uv loops share the same selection state (if not, they are not connected as
          * they have been ripped or other edit commands have separated them). */
-        bool connected = uv_vert_sel == uv2_vert_sel && fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT &&
-                         fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT;
+        const bool connected = (uv_vert_sel == uv2_vert_sel) &&
+                               compare_v2v2(uv2, uv, STD_UV_CONNECT_LIMIT);
 
         if (connected && (!use_winding || winding[BM_elem_index_get(iterv->l->f)] ==
                                               winding[BM_elem_index_get(v->l->f)])) {
diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c b/source/blender/editors/transform/transform_convert_mesh_uv.c
index 56fa2d90fb2..f3e7446b2c4 100644
--- a/source/blender/editors/transform/transform_convert_mesh_uv.c
+++ b/source/blender/editors/transform/transform_convert_mesh_uv.c
@@ -178,9 +178,6 @@ static void uv_set_connectivity_distance(BMesh *bm, float *dists, const float as
           continue;
         }
 
-        float connected_uv[2];
-        float uvdiff[2];
-
         bool other_vert_sel, connected_vert_sel;
 
         other_vert_sel = luv_other->flag & MLOOPUV_VERTSEL;
@@ -196,16 +193,12 @@ static void uv_set_connectivity_distance(BMesh *bm, float *dists, const float as
 
           MLoopUV *luv_connected = BM_ELEM_CD_GET_VOID_P(l_connected, cd_loop_uv_offset);
           connected_vert_sel = luv_connected->flag & MLOOPUV_VERTSEL;
-          copy_v2_v2(connected_uv, luv_connected->uv);
-          mul_v2_v2(connected_uv, aspect);
 
-          sub_v2_v2v2(uvdiff, connected_uv, other_uv);
           /* Check if this loop is connected in UV space.
            * If the uv loops share the same selection state (if not, they are not connected as
            * they have been ripped or other edit commands have separated them). */
           bool connected = other_vert_sel == connected_vert_sel &&
-                           fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT &&
-                           fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT;
+                           equals_v2v2(luv_other->uv, luv_connected->uv);
           if (!connected) {
             continue;
           }
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index faf8e5013dd..e2368ae6ba8 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1843,7 +1843,6 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
 {
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
-  const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
   const bool mark_seams = RNA_boolean_get(op->ptr, "mark_seams");
   const bool mark_sharp = RNA_boolean_get(op->ptr, "mark_sharp");
   bool changed_multi = false;
@@ -1884,23 +1883,10 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
           continue;
         }
 
-        const MLoopUV *luv_curr = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
-        const MLoopUV *luv_next = BM_ELEM_CD_GET_VOID_P(l_iter->next, cd_loop_uv_offset);
-
         bool mark = false;
         BMLoop *l_other = l_iter->radial_next;
         do {
-          const MLoopUV *luv_other_curr = BM_ELEM_CD_GET_VOID_P(l_other, cd_loop_uv_offset);
-          const MLoopUV *luv_other_next = BM_ELEM_CD_GET_VOID_P(l_other->next, cd_loop_uv_offset);
-          if (l_iter->v != l_other->v) {
-            SWAP(const MLoopUV *, luv_other_curr

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list