diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-07-18 08:54:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-07-18 08:54:04 +0300 |
commit | c48ccb38cbff3ff7d7be4a36b1c13731160a9faa (patch) | |
tree | 84dbf8796c7428a02f321de2011d35f007453c80 /source/blender/bmesh | |
parent | 4e73ba2cab1b55f5f92715ad04215e830768be82 (diff) |
BMesh: utility for checking shared edge with limit argument
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query_uv.c | 25 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query_uv.h | 6 |
2 files changed, 31 insertions, 0 deletions
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, @@ -115,6 +120,26 @@ float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset) /** * 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. + */ bool BM_loop_uv_share_edge_check(BMLoop *l_a, BMLoop *l_b, const int cd_loop_uv_offset) { BLI_assert(l_a->e == l_b->e); 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 |