diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-11 09:34:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-11 09:34:50 +0300 |
commit | 77c4ed1d0442f596b666f3ee6309c86f09511061 (patch) | |
tree | 7fce98715bf28b37b3505d8c76ef7d1f3b3fcc75 /source/blender/bmesh | |
parent | fb049a79761f50aefc4b4f86a23f0c9358928ccc (diff) | |
parent | 23a6b5d91e942d90badeaf9ab64cf8ea3b4219a1 (diff) |
Merge branch 'blender-v2.90-release' into master
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query_uv.c | 14 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query_uv.h | 2 |
2 files changed, 16 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..1aa75bfb037 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.c +++ b/source/blender/bmesh/intern/bmesh_query_uv.c @@ -95,6 +95,20 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f, #undef UV_ASPECT +void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset, float r_cent[2]) +{ + const BMLoop *l_iter; + const BMLoop *l_first; + zero_v2(r_cent); + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset); + add_v2_v2(r_cent, luv->uv); + } while ((l_iter = l_iter->next) != l_first); + + mul_v2_fl(r_cent, 1.0f / (float)f->len); +} + /** * Calculate the UV cross product (use the sign to check the winding). */ diff --git a/source/blender/bmesh/intern/bmesh_query_uv.h b/source/blender/bmesh/intern/bmesh_query_uv.h index 3465a831bea..0a86c0cbeae 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.h +++ b/source/blender/bmesh/intern/bmesh_query_uv.h @@ -31,6 +31,8 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f, const float aspect[2], const int cd_loop_uv_offset, float r_cent[2]) ATTR_NONNULL(); +void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset, float r_cent[2]) + ATTR_NONNULL(); float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); |