Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-08-11 08:11:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-11 08:11:31 +0300
commit23a6b5d91e942d90badeaf9ab64cf8ea3b4219a1 (patch)
treee4ded62cdff80338483f1d8a8f063024c0607eb4 /source/blender/bmesh
parentfc5ff997709bdc5ec458647eb8db0a6eced670a2 (diff)
BMesh: add UV calculate center call
Move uv_poly_center to BM_face_uv_calc_center_median as it was only defined in uvedit_intern.h
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_query_uv.c14
-rw-r--r--source/blender/bmesh/intern/bmesh_query_uv.h2
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();