[Bf-blender-cvs] [fc9fa07] master: BMesh: BM_face_exists no longer uses return arg

Campbell Barton noreply at git.blender.org
Sun Nov 13 18:19:58 CET 2016


Commit: fc9fa07c0e177bda4c5ae2233616081ed48f2c8c
Author: Campbell Barton
Date:   Mon Nov 14 04:10:47 2016 +1100
Branches: master
https://developer.blender.org/rBfc9fa07c0e177bda4c5ae2233616081ed48f2c8c

BMesh: BM_face_exists no longer uses return arg

Just return the face or NULL, like BM_edge_exists(),
Also for BM_face_exists_overlap & bm_face_exists_tri_from_loop_vert.
No functional changes.

Old code did some partial overlap checks where this made some sense,
but it's since been removed.

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

M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/bmesh/intern/bmesh_core.c
M	source/blender/bmesh/intern/bmesh_queries.c
M	source/blender/bmesh/intern/bmesh_queries.h
M	source/blender/bmesh/operators/bmo_bridge.c
M	source/blender/bmesh/operators/bmo_fill_edgeloop.c
M	source/blender/bmesh/operators/bmo_hull.c
M	source/blender/bmesh/operators/bmo_removedoubles.c
M	source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
M	source/blender/editors/mesh/editmesh_rip.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/python/bmesh/bmesh_py_types.c

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

diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 55f9f38..a821578 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -148,8 +148,7 @@ BLI_INLINE void bm_face_as_array_index_tri(BMFace *f, int r_index[3])
  *
  * Its assumed that \a l_radial_first is never forming the target face.
  */
-static bool bm_face_exists_tri_from_loop_vert(
-        BMLoop *l_radial_first, BMVert *v_opposite, BMFace **r_face_existing)
+static BMFace *bm_face_exists_tri_from_loop_vert(BMLoop *l_radial_first, BMVert *v_opposite)
 {
 	BLI_assert(!ELEM(v_opposite, l_radial_first->v, l_radial_first->next->v, l_radial_first->prev->v));
 	if (l_radial_first->radial_next != l_radial_first) {
@@ -157,12 +156,11 @@ static bool bm_face_exists_tri_from_loop_vert(
 		do {
 			BLI_assert(l_radial_iter->f->len == 3);
 			if (l_radial_iter->prev->v == v_opposite) {
-				*r_face_existing = l_radial_iter->f;
-				return true;
+				return l_radial_iter->f;
 			}
 		} while ((l_radial_iter = l_radial_iter->radial_next) != l_radial_first);
 	}
-	return false;
+	return NULL;
 }
 
 /**
@@ -519,7 +517,7 @@ static BMFace *pbvh_bmesh_face_create(
 	PBVHNode *node = &bvh->nodes[node_index];
 
 	/* ensure we never add existing face */
-	BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
+	BLI_assert(!BM_face_exists(v_tri, 3));
 
 	BMFace *f = BM_face_create(bvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
 	f->head.hflag = f_example->head.hflag;
@@ -1313,18 +1311,17 @@ static void pbvh_bmesh_collapse_edge(
 		 * deletion as well. Prevents extraneous "flaps" from being
 		 * created. */
 #if 0
-		if (UNLIKELY(BM_face_exists(v_tri, 3, &existing_face)))
+		if (UNLIKELY(existing_face = BM_face_exists(v_tri, 3)))
 #else
-		if (UNLIKELY(bm_face_exists_tri_from_loop_vert(l->next, v_conn, &existing_face)))
+		if (UNLIKELY(existing_face = bm_face_exists_tri_from_loop_vert(l->next, v_conn)))
 #endif
 		{
-			BLI_assert(existing_face);
 			BLI_buffer_append(deleted_faces, BMFace *, existing_face);
 		}
 		else {
 			BMVert *v_tri[3] = {v_conn, l->next->v, l->prev->v};
 
-			BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
+			BLI_assert(!BM_face_exists(v_tri, 3));
 			BMEdge *e_tri[3];
 			PBVHNode *n = pbvh_bmesh_node_from_face(bvh, f);
 			int ni = n - bvh->nodes;
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index a7e1aa7..0460a33 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -444,13 +444,10 @@ BMFace *BM_face_create(
 
 	if (create_flag & BM_CREATE_NO_DOUBLE) {
 		/* Check if face already exists */
-		const bool is_overlap = BM_face_exists(verts, len, &f);
-		if (is_overlap) {
+		f = BM_face_exists(verts, len);
+		if (f != NULL) {
 			return f;
 		}
-		else {
-			BLI_assert(f == NULL);
-		}
 	}
 
 	f = bm_face_create__internal(bm);
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 0287498..8767180 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -1925,7 +1925,7 @@ BMEdge *BM_edge_find_double(BMEdge *e)
  *
  * \note there used to be a BM_face_exists_overlap function that checks for partial overlap.
  */
-bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
+BMFace *BM_face_exists(BMVert **varr, int len)
 {
 	if (varr[0]->e) {
 		BMEdge *e_iter, *e_first;
@@ -1964,10 +1964,7 @@ bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
 						}
 
 						if (i_walk == len) {
-							if (r_existface) {
-								*r_existface = l_iter_radial->f;
-							}
-							return true;
+							return l_iter_radial->f;
 						}
 					}
 				} while ((l_iter_radial = l_iter_radial->radial_next) != l_first_radial);
@@ -1976,10 +1973,7 @@ bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
 		} while ((e_iter = BM_DISK_EDGE_NEXT(e_iter, varr[0])) != e_first);
 	}
 
-	if (r_existface) {
-		*r_existface = NULL;
-	}
-	return false;
+	return NULL;
 }
 
 
@@ -2122,26 +2116,21 @@ bool BM_face_exists_multi_edge(BMEdge **earr, int len)
  * \note The face may contain other verts \b not in \a varr.
  *
  * \note Its possible there are more than one overlapping faces,
- * in this case the first one found will be assigned to \a r_f_overlap.
+ * in this case the first one found will be returned.
  *
  * \param varr  Array of unordered verts.
  * \param len  \a varr array length.
- * \param r_f_overlap  The overlapping face to return.
- * \return Success
+ * \return The face or NULL.
  */
 
-bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap)
+BMFace *BM_face_exists_overlap(BMVert **varr, const int len)
 {
 	BMIter viter;
 	BMFace *f;
 	int i;
-	bool is_overlap = false;
+	BMFace *f_overlap = NULL;
 	LinkNode *f_lnk = NULL;
 
-	if (r_f_overlap) {
-		*r_f_overlap = NULL;
-	}
-
 #ifdef DEBUG
 	/* check flag isn't already set */
 	for (i = 0; i < len; i++) {
@@ -2155,10 +2144,7 @@ bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap)
 		BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
 			if (BM_ELEM_API_FLAG_TEST(f, _FLAG_OVERLAP) == 0) {
 				if (len <= BM_verts_in_face_count(varr, len, f)) {
-					if (r_f_overlap)
-						*r_f_overlap = f;
-
-					is_overlap = true;
+					f_overlap = f;
 					break;
 				}
 
@@ -2172,7 +2158,7 @@ bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap)
 		BM_ELEM_API_FLAG_DISABLE((BMFace *)f_lnk->link, _FLAG_OVERLAP);
 	}
 
-	return is_overlap;
+	return f_overlap;
 }
 
 /**
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 10e4b9a..282050b 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -135,12 +135,12 @@ BMLoop *BM_face_find_longest_loop(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNUL
 BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 BMEdge *BM_edge_find_double(BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
-bool    BM_face_exists(BMVert **varr, int len, BMFace **r_existface) ATTR_NONNULL(1);
+BMFace* BM_face_exists(BMVert **varr, int len) ATTR_NONNULL(1);
 
 bool    BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 bool    BM_face_exists_multi_edge(BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
-bool    BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+BMFace *BM_face_exists_overlap(BMVert **varr, const int len) ATTR_WARN_UNUSED_RESULT;
 bool    BM_face_exists_overlap_subset(BMVert **varr, const int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
 int     BM_face_share_face_count(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c
index 6ef0fd6..61179d7 100644
--- a/source/blender/bmesh/operators/bmo_bridge.c
+++ b/source/blender/bmesh/operators/bmo_bridge.c
@@ -398,7 +398,8 @@ static void bridge_loop_pair(
 
 			if (v_b != v_b_next) {
 				BMVert *v_arr[4] = {v_a, v_b, v_b_next, v_a_next};
-				if (BM_face_exists(v_arr, 4, &f) == false) {
+				f = BM_face_exists(v_arr, 4);
+				if (f == NULL) {
 					/* copy if loop data if its is missing on one ring */
 					f = BM_face_create_verts(bm, v_arr, 4, NULL, BM_CREATE_NOP, true);
 
@@ -411,7 +412,8 @@ static void bridge_loop_pair(
 			}
 			else {
 				BMVert *v_arr[3] = {v_a, v_b, v_a_next};
-				if (BM_face_exists(v_arr, 3, &f) == false) {
+				f = BM_face_exists(v_arr, 3);
+				if (f == NULL) {
 					/* fan-fill a triangle */
 					f = BM_face_create_verts(bm, v_arr, 3, NULL, BM_CREATE_NOP, true);
 
diff --git a/source/blender/bmesh/operators/bmo_fill_edgeloop.c b/source/blender/bmesh/operators/bmo_fill_edgeloop.c
index c68130b..f33a60c 100644
--- a/source/blender/bmesh/operators/bmo_fill_edgeloop.c
+++ b/source/blender/bmesh/operators/bmo_fill_edgeloop.c
@@ -136,7 +136,7 @@ void bmo_edgeloop_fill_exec(BMesh *bm, BMOperator *op)
 				i++;
 			} while ((v != f_verts[0]));
 
-			if (BM_face_exists(f_verts, i, NULL) == false) {
+			if (!BM_face_exists(f_verts, i)) {
 				BMFace *f;
 
 				/* don't use calc_edges option because we already have the edges */
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index 9c41e4f..81ec286 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -119,7 +119,8 @@ static void hull_output_triangles(BMesh *bm, GSet *hull_triangles)
 			};
 			BMFace *f, *example = NULL;
 
-			if (BM_face_exists(t->v, 3, &f)) {
+			f = BM_face_exists(t->v, 3);
+			if (f != NULL) {
 				/* If the operator is run with "use_existing_faces"
 				 * disabled, but an output face in the hull is the
 				 * same as a face in the existing mesh, it should not
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 6da591b..0ad8247 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -160,7 +160,7 @@ finally:
 	}
 
 	if (STACK_SIZE(edges) >= 3) {
-		if (!BM_face_exists(verts, STACK_SIZE(edges), NULL)) {
+		if (!BM_face_exists(verts, STACK_SIZE(edges))) {
 			BMFace *f_new = BM_face_create(bm, verts, edges, STACK_SIZE(edges), f, BM_CREATE_NOP);
 			BLI_assert(f_new != f);
 
diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
index 0fc571b..92300ae 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
@@ -74,7 +74,7 @@ static bool bm_vert_dissolve_fan_test(BMVert *v)
 	    ((tot_edge == 3) && (tot_edge_boundary == 0) && (tot_edge_manifold == 3)) ||
 	    ((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1)))
 	{
-		if (!BM_face_exists(varr, tot_edge, NULL)) {
+		if (!BM_f

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list