From 23a6b5d91e942d90badeaf9ab64cf8ea3b4219a1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Aug 2020 15:11:31 +1000 Subject: 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 --- source/blender/editors/uvedit/uvedit_intern.h | 1 - source/blender/editors/uvedit/uvedit_ops.c | 16 ---------------- source/blender/editors/uvedit/uvedit_select.c | 8 ++++---- 3 files changed, 4 insertions(+), 21 deletions(-) (limited to 'source/blender/editors/uvedit') diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h index daa31869a11..8a452941954 100644 --- a/source/blender/editors/uvedit/uvedit_intern.h +++ b/source/blender/editors/uvedit/uvedit_intern.h @@ -33,7 +33,6 @@ struct wmOperatorType; /* geometric utilities */ void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len); -void uv_poly_center(struct BMFace *f, float r_cent[2], const int cd_loop_uv_offset); /* find nearest */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 532061e3dc1..deec72d368f 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -227,22 +227,6 @@ void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit) /** \name Geometric Utilities * \{ */ -void uv_poly_center(BMFace *f, float r_cent[2], const int cd_loop_uv_offset) -{ - BMLoop *l; - MLoopUV *luv; - BMIter liter; - - zero_v2(r_cent); - - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - add_v2_v2(r_cent, luv->uv); - } - - mul_v2_fl(r_cent, 1.0f / (float)f->len); -} - void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len) { int i; diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index 151c881a466..149c5cf1f96 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -724,7 +724,7 @@ bool uv_find_nearest_face(Scene *scene, Object *obedit, const float co[2], UvNea } float cent[2]; - uv_poly_center(efa, cent, cd_loop_uv_offset); + BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent); const float dist_test_sq = len_squared_v2v2(co, cent); @@ -2841,7 +2841,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op) BM_elem_flag_disable(efa, BM_ELEM_TAG); if (uvedit_face_visible_test(scene, efa)) { - uv_poly_center(efa, cent, cd_loop_uv_offset); + BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent); if (BLI_rctf_isect_pt_v(&rectf, cent)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); changed = true; @@ -3072,7 +3072,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) /* assume not touched */ if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { float cent[2]; - uv_poly_center(efa, cent, cd_loop_uv_offset); + BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent); if (uv_circle_select_is_point_inside(cent, offset, ellipse)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); changed = true; @@ -3263,7 +3263,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, /* assume not touched */ if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { float cent[2]; - uv_poly_center(efa, cent, cd_loop_uv_offset); + BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent); if (do_lasso_select_mesh_uv_is_point_inside(region, &rect, mcoords, mcoords_len, cent)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); changed = true; -- cgit v1.2.3