diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-11-17 21:55:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-11-17 22:10:53 +0300 |
commit | 03a395766aee1b19d42360edaca2fdd03acebb7b (patch) | |
tree | 6a16c3860b8c6d3af8b85ce18452341a7d47bb00 /source/blender/bmesh | |
parent | 46739f1e5ceee43f6e7313dcb4c21829a13789d6 (diff) |
BMesh: avoid using temp array for face-area
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index c500d7b9ec2..6acd790fc0c 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -225,24 +225,16 @@ void BM_face_calc_point_in_face(const BMFace *f, float r_co[3]) */ float BM_face_calc_area(const BMFace *f) { + /* inline 'area_poly_v3' logic, avoid creating a temp array */ const BMLoop *l_iter, *l_first; - float (*verts)[3] = BLI_array_alloca(verts, f->len); - float area; - unsigned int i = 0; + float n[3]; + zero_v3(n); l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - copy_v3_v3(verts[i++], l_iter->v->co); + add_newell_cross_v3_v3v3(n, l_iter->v->co, l_iter->next->v->co); } while ((l_iter = l_iter->next) != l_first); - - if (f->len == 3) { - area = area_tri_v3(verts[0], verts[1], verts[2]); - } - else { - area = area_poly_v3((const float (*)[3])verts, f->len); - } - - return area; + return len_v3(n) * 0.5f; } /** |