From 6fdb2ed861b8edf022e51bbc783acabbd2a0e581 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Sep 2013 06:27:22 +0000 Subject: bmesh utility functions BM_face_as_array_loop_tri, BM_face_as_array_loop_quad also set attributes for the header and remove debug print in mask.c --- source/blender/bmesh/intern/bmesh_polygon.c | 34 ++++++++++++++++++++++++ source/blender/bmesh/intern/bmesh_polygon.h | 41 ++++++++++++++++------------- 2 files changed, 56 insertions(+), 19 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 8765bc7d579..a82d3d07712 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -1203,3 +1203,37 @@ void BM_face_as_array_vert_quad(BMFace *f, BMVert *r_verts[4]) r_verts[2] = l->v; l = l->next; r_verts[3] = l->v; } + + +/** + * Small utility functions for fast access + * + * faster alternative to: + * BM_iter_as_array(bm, BM_LOOPS_OF_FACE, f, (void **)l, 3); + */ +void BM_face_as_array_loop_tri(BMFace *f, BMLoop *r_loops[3]) +{ + BMLoop *l = BM_FACE_FIRST_LOOP(f); + + BLI_assert(f->len == 3); + + r_loops[0] = l; l = l->next; + r_loops[1] = l; l = l->next; + r_loops[2] = l; +} + +/** + * faster alternative to: + * BM_iter_as_array(bm, BM_LOOPS_OF_FACE, f, (void **)l, 4); + */ +void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4]) +{ + BMLoop *l = BM_FACE_FIRST_LOOP(f); + + BLI_assert(f->len == 4); + + r_loops[0] = l; l = l->next; + r_loops[1] = l; l = l->next; + r_loops[2] = l; l = l->next; + r_loops[3] = l; +} diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 90f0075da26..14fe1e76360 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -30,34 +30,37 @@ #include "BLI_compiler_attrs.h" int BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, int (*r_index)[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -void BM_face_calc_normal(const BMFace *f, float r_no[3]); +void BM_face_calc_normal(const BMFace *f, float r_no[3]) ATTR_NONNULL(); void BM_face_calc_normal_vcos(BMesh *bm, BMFace *f, float r_no[3], - float const (*vertexCos)[3]); -float BM_face_calc_area(BMFace *f); -float BM_face_calc_perimeter(BMFace *f); -void BM_face_calc_plane(BMFace *f, float r_plane[3]); -void BM_face_calc_center_bounds(BMFace *f, float center[3]); -void BM_face_calc_center_mean(BMFace *f, float center[3]); + float const (*vertexCos)[3]) ATTR_NONNULL(); +float BM_face_calc_area(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +float BM_face_calc_perimeter(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +void BM_face_calc_plane(BMFace *f, float r_plane[3]) ATTR_NONNULL(); +void BM_face_calc_center_bounds(BMFace *f, float center[3]) ATTR_NONNULL(); +void BM_face_calc_center_mean(BMFace *f, float center[3]) ATTR_NONNULL(); void BM_face_calc_center_mean_vcos(BMesh *bm, BMFace *f, float r_cent[3], - float const (*vertexCos)[3]); -void BM_face_calc_center_mean_weighted(BMFace *f, float center[3]); + float const (*vertexCos)[3]) ATTR_NONNULL(); +void BM_face_calc_center_mean_weighted(BMFace *f, float center[3]) ATTR_NONNULL(); -void BM_face_normal_update(BMFace *f); +void BM_face_normal_update(BMFace *f) ATTR_NONNULL(); -void BM_edge_normals_update(BMEdge *e); +void BM_edge_normals_update(BMEdge *e) ATTR_NONNULL(); -void BM_vert_normal_update(BMVert *v); -void BM_vert_normal_update_all(BMVert *v); +void BM_vert_normal_update(BMVert *v) ATTR_NONNULL(); +void BM_vert_normal_update_all(BMVert *v) ATTR_NONNULL(); -void BM_face_normal_flip(BMesh *bm, BMFace *f); -bool BM_face_point_inside_test(BMFace *f, const float co[3]); +void BM_face_normal_flip(BMesh *bm, BMFace *f) ATTR_NONNULL(); +bool BM_face_point_inside_test(BMFace *f, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); void BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **newfaces, - const bool use_beauty, const bool use_tag); + const bool use_beauty, const bool use_tag) ATTR_NONNULL(1, 2); -void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len); +void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len) ATTR_NONNULL(); -void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3]); -void BM_face_as_array_vert_quad(BMFace *f, BMVert *r_verts[4]); +void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3]) ATTR_NONNULL(); +void BM_face_as_array_vert_quad(BMFace *f, BMVert *r_verts[4]) ATTR_NONNULL(); + +void BM_face_as_array_loop_tri(BMFace *f, BMLoop *r_loops[3]) ATTR_NONNULL(); +void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4]) ATTR_NONNULL(); #endif /* __BMESH_POLYGON_H__ */ -- cgit v1.2.3