[Bf-blender-cvs] [c48ccb38cbf] master: BMesh: utility for checking shared edge with limit argument

Campbell Barton noreply at git.blender.org
Sat Jul 18 08:09:38 CEST 2020


Commit: c48ccb38cbff3ff7d7be4a36b1c13731160a9faa
Author: Campbell Barton
Date:   Sat Jul 18 15:54:04 2020 +1000
Branches: master
https://developer.blender.org/rBc48ccb38cbff3ff7d7be4a36b1c13731160a9faa

BMesh: utility for checking shared edge with limit argument

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

M	source/blender/bmesh/intern/bmesh_query_uv.c
M	source/blender/bmesh/intern/bmesh_query_uv.h

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

diff --git a/source/blender/bmesh/intern/bmesh_query_uv.c b/source/blender/bmesh/intern/bmesh_query_uv.c
index b9ea51f0c4d..72f264e148c 100644
--- a/source/blender/bmesh/intern/bmesh_query_uv.c
+++ b/source/blender/bmesh/intern/bmesh_query_uv.c
@@ -32,6 +32,11 @@
 #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,
@@ -112,6 +117,26 @@ 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/bmesh/intern/bmesh_query_uv.h b/source/blender/bmesh/intern/bmesh_query_uv.h
index 293715a8c69..2558f814f32 100644
--- a/source/blender/bmesh/intern/bmesh_query_uv.h
+++ b/source/blender/bmesh/intern/bmesh_query_uv.h
@@ -36,6 +36,12 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f,
 float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT
     ATTR_NONNULL();
 
+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) ATTR_WARN_UNUSED_RESULT
+    ATTR_NONNULL();
+
 bool BM_loop_uv_share_edge_check(BMLoop *l_a,
                                  BMLoop *l_b,
                                  const int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT



More information about the Bf-blender-cvs mailing list