[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59867] trunk/blender/source/blender: bmesh utility functions BM_face_as_array_loop_tri, BM_face_as_array_loop_quad

Campbell Barton ideasman42 at gmail.com
Fri Sep 6 08:27:22 CEST 2013


Revision: 59867
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59867
Author:   campbellbarton
Date:     2013-09-06 06:27:22 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
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

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/mask.c
    trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
    trunk/blender/source/blender/bmesh/intern/bmesh_polygon.h

Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c	2013-09-06 05:44:18 UTC (rev 59866)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c	2013-09-06 06:27:22 UTC (rev 59867)
@@ -1402,7 +1402,7 @@
 				int j;
 
 				for (j = 0; j <= 2; j += 2) { /* (0, 2) */
-					printf("--- %d %d, %d, %d\n", i, j, i_prev, i_next);
+					// printf("--- %d %d, %d, %d\n", i, j, i_prev, i_next);
 					barycentric_weights_v2(bezt_prev->vec[1], bezt->vec[1], bezt_next->vec[1],
 					                       bezt->vec[j], w_src);
 					interp_v3_v3v3v3(bezt_def->vec[j],

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2013-09-06 05:44:18 UTC (rev 59866)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2013-09-06 06:27:22 UTC (rev 59867)
@@ -1203,3 +1203,37 @@
 	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;
+}

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_polygon.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_polygon.h	2013-09-06 05:44:18 UTC (rev 59866)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_polygon.h	2013-09-06 06:27:22 UTC (rev 59867)
@@ -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__ */




More information about the Bf-blender-cvs mailing list