From 6526c3ced8b52e5583ff12095e5a9fe30410062e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Apr 2020 15:23:01 +1000 Subject: Fix displaying edit-mesh measurements with deform modifiers Resolves regression from 2.7x --- source/blender/bmesh/intern/bmesh_polygon.c | 25 +++++++++++++++++++++++++ source/blender/bmesh/intern/bmesh_polygon.h | 8 ++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'source/blender/bmesh/intern') diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 9ab5106cec2..a40c293f1aa 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -595,6 +595,31 @@ void BM_face_calc_center_bounds(const BMFace *f, float r_cent[3]) mid_v3_v3v3(r_cent, min, max); } +/** + * computes center of face in 3d. uses center of bounding box. + */ +void BM_face_calc_center_bounds_vcos(const BMesh *bm, + const BMFace *f, + float r_cent[3], + float const (*vertexCos)[3]) +{ + /* must have valid index data */ + BLI_assert((bm->elem_index_dirty & BM_VERT) == 0); + (void)bm; + + const BMLoop *l_iter, *l_first; + float min[3], max[3]; + + INIT_MINMAX(min, max); + + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + minmax_v3v3_v3(min, max, vertexCos[BM_elem_index_get(l_iter->v)]); + } while ((l_iter = l_iter->next) != l_first); + + mid_v3_v3v3(r_cent, min, max); +} + /** * computes the center of a face, using the mean average */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 2ae32777a7d..1611bc0b893 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -60,10 +60,14 @@ void BM_face_calc_tangent_edge_diagonal(const BMFace *f, float r_plane[3]) ATTR_ void BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_plane[3]) ATTR_NONNULL(); void BM_face_calc_tangent_auto(const BMFace *f, float r_plane[3]) ATTR_NONNULL(); void BM_face_calc_center_bounds(const BMFace *f, float center[3]) ATTR_NONNULL(); -void BM_face_calc_center_median(const BMFace *f, float center[3]) ATTR_NONNULL(); +void BM_face_calc_center_bounds_vcos(const BMesh *bm, + const BMFace *f, + float r_center[3], + float const (*vertexCos)[3]) ATTR_NONNULL(); +void BM_face_calc_center_median(const BMFace *f, float r_center[3]) ATTR_NONNULL(); void BM_face_calc_center_median_vcos(const BMesh *bm, const BMFace *f, - float r_cent[3], + float r_center[3], float const (*vertexCos)[3]) ATTR_NONNULL(); void BM_face_calc_center_median_weighted(const BMFace *f, float center[3]) ATTR_NONNULL(); -- cgit v1.2.3