[Bf-blender-cvs] [c5ac037] master: BMesh: pass loops instead of edges/verts to filter funcs

Campbell Barton noreply at git.blender.org
Sat Nov 28 03:48:09 CET 2015


Commit: c5ac037c8e118ea8a9186c018b53534505bee638
Author: Campbell Barton
Date:   Sat Nov 28 13:40:18 2015 +1100
Branches: master
https://developer.blender.org/rBc5ac037c8e118ea8a9186c018b53534505bee638

BMesh: pass loops instead of edges/verts to filter funcs

This allows to check the source face we're walking over.

===================================================================

M	source/blender/bmesh/intern/bmesh_queries.c
M	source/blender/bmesh/intern/bmesh_queries.h
M	source/blender/bmesh/operators/bmo_normals.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 064c8ec..e7a93c6 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -2339,8 +2339,7 @@ float BM_mesh_calc_volume(BMesh *bm, bool is_signed)
  *        (or when hflag_test is set, the number of flagged faces).
  * \param r_group_index  index, length pairs into \a r_groups_array, size of return value
  *        int pairs: (array_start, array_length).
- * \param filter_fn  Filter the edges or verts we step over (depends on \a htype_step)
- *        as to which types we deal with.
+ * \param filter_fn  Filter the edge-loops or vert-loops we step over (depends on \a htype_step).
  * \param user_data  Optional user data for \a filter_fn, can be NULL.
  * \param hflag_test  Optional flag to test faces,
  *        use to exclude faces from the calculation, 0 for all faces.
@@ -2350,7 +2349,7 @@ float BM_mesh_calc_volume(BMesh *bm, bool is_signed)
  */
 int BM_mesh_calc_face_groups(
         BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
-        BMElemFilterFunc filter_fn, void *user_data,
+        BMLoopFilterFunc filter_fn, void *user_data,
         const char hflag_test, const char htype_step)
 {
 #ifdef DEBUG
@@ -2443,7 +2442,7 @@ int BM_mesh_calc_face_groups(
 				do {
 					BMLoop *l_radial_iter = l_iter->radial_next;
 					if ((l_radial_iter != l_iter) &&
-					    ((filter_fn == NULL) || filter_fn((BMElem *)l_iter->e, user_data)))
+					    ((filter_fn == NULL) || filter_fn(l_iter, user_data)))
 					{
 						do {
 							BMFace *f_other = l_radial_iter->f;
@@ -2461,7 +2460,7 @@ int BM_mesh_calc_face_groups(
 				/* search for other faces */
 				l_iter = l_first = BM_FACE_FIRST_LOOP(f);
 				do {
-					if ((filter_fn == NULL) || filter_fn((BMElem *)l_iter->v, user_data)) {
+					if ((filter_fn == NULL) || filter_fn(l_iter, user_data)) {
 						BMLoop *l_other;
 						BM_ITER_ELEM (l_other, &liter, l_iter, BM_LOOPS_OF_LOOP) {
 							BMFace *f_other = l_other->f;
@@ -2508,7 +2507,7 @@ int BM_mesh_calc_face_groups(
  */
 int BM_mesh_calc_edge_groups(
         BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
-        BMElemFilterFunc filter_fn, void *user_data,
+        BMVertFilterFunc filter_fn, void *user_data,
         const char hflag_test)
 {
 #ifdef DEBUG
@@ -2597,7 +2596,7 @@ int BM_mesh_calc_edge_groups(
 
 			/* search for other edges */
 			BM_ITER_ELEM (v, &viter, e, BM_VERTS_OF_EDGE) {
-				if ((filter_fn == NULL) || filter_fn((BMElem *)v, user_data)) {
+				if ((filter_fn == NULL) || filter_fn(v, user_data)) {
 					BMEdge *e_other;
 					BM_ITER_ELEM (e_other, &eiter, v, BM_EDGES_OF_VERT) {
 						if (BM_elem_flag_test(e_other, BM_ELEM_TAG) == false) {
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 2b18a5c..cfe2917 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -175,12 +175,12 @@ float BM_mesh_calc_volume(BMesh *bm, bool is_signed) ATTR_WARN_UNUSED_RESULT ATT
 
 int   BM_mesh_calc_face_groups(
         BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
-        BMElemFilterFunc filter_fn, void *user_data,
+        BMLoopFilterFunc filter_fn, void *user_data,
         const char hflag_test, const char htype_step)
         ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2, 3);
 int   BM_mesh_calc_edge_groups(
         BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
-        BMElemFilterFunc filter_fn, void *user_data,
+        BMVertFilterFunc filter_fn, void *user_data,
         const char hflag_test)
         ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2, 3);
 
diff --git a/source/blender/bmesh/operators/bmo_normals.c b/source/blender/bmesh/operators/bmo_normals.c
index 06ceece..6044960 100644
--- a/source/blender/bmesh/operators/bmo_normals.c
+++ b/source/blender/bmesh/operators/bmo_normals.c
@@ -41,9 +41,9 @@
 #define FACE_FLIP	(1 << 1)
 #define FACE_TEMP	(1 << 2)
 
-static bool bmo_recalc_normal_edge_filter_cb(const BMElem *ele, void *UNUSED(user_data))
+static bool bmo_recalc_normal_loop_filter_cb(const BMLoop *l, void *UNUSED(user_data))
 {
-	return BM_edge_is_manifold((const BMEdge *)ele);
+	return BM_edge_is_manifold(l->e);
 }
 
 /**
@@ -229,7 +229,7 @@ static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int f
 		do {
 			BMLoop *l_other = l_iter->radial_next;
 
-			if ((l_other != l_iter) && bmo_recalc_normal_edge_filter_cb((const BMElem *)l_iter->e, NULL)) {
+			if ((l_other != l_iter) && bmo_recalc_normal_loop_filter_cb(l_iter, NULL)) {
 				if (!BMO_elem_flag_test(bm, l_other->f, FACE_TEMP)) {
 					BMO_elem_flag_enable(bm, l_other->f, FACE_TEMP);
 					BMO_elem_flag_set(bm, l_other->f, FACE_FLIP, (l_other->v == l_iter->v) != flip_state);
@@ -264,9 +264,10 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
 	BMFace **faces_grp = MEM_mallocN(sizeof(*faces_grp) * bm->totface, __func__);
 
 	int (*group_index)[2];
-	const int group_tot = BM_mesh_calc_face_groups(bm, groups_array, &group_index,
-	                                               bmo_recalc_normal_edge_filter_cb, NULL,
-	                                               0, BM_EDGE);
+	const int group_tot = BM_mesh_calc_face_groups(
+	        bm, groups_array, &group_index,
+	        bmo_recalc_normal_loop_filter_cb, NULL,
+	        0, BM_EDGE);
 	int i;
 
 	BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_FLAG);




More information about the Bf-blender-cvs mailing list