diff options
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 25 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.h | 8 |
2 files changed, 31 insertions, 2 deletions
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 @@ -596,6 +596,31 @@ void BM_face_calc_center_bounds(const BMFace *f, float r_cent[3]) } /** + * 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 */ void BM_face_calc_center_median(const BMFace *f, float r_cent[3]) 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(); |