[Bf-blender-cvs] [5b225c59bb5] master: Cleanup: move edge-rotate into own file

Campbell Barton noreply at git.blender.org
Sun Nov 26 03:30:40 CET 2017


Commit: 5b225c59bb5d0d0284279da16895925099d3879a
Author: Campbell Barton
Date:   Sun Nov 26 13:40:26 2017 +1100
Branches: master
https://developer.blender.org/rB5b225c59bb5d0d0284279da16895925099d3879a

Cleanup: move edge-rotate into own file

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

M	source/blender/bmesh/CMakeLists.txt
A	source/blender/bmesh/operators/bmo_rotate_edge.c
M	source/blender/bmesh/operators/bmo_utils.c

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

diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 43e45eab98f..38a275483dd 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -40,6 +40,7 @@ set(INC_SYS
 )
 
 set(SRC
+	# Naming convention for BMesh operators is: bmo_*action*_*details*.c
 	operators/bmo_beautify.c
 	operators/bmo_bevel.c
 	operators/bmo_bisect_plane.c
@@ -68,6 +69,7 @@ set(SRC
 	operators/bmo_poke.c
 	operators/bmo_primitive.c
 	operators/bmo_removedoubles.c
+	operators/bmo_rotate_edge.c
 	operators/bmo_similar.c
 	operators/bmo_smooth_laplacian.c
 	operators/bmo_split_edges.c
diff --git a/source/blender/bmesh/operators/bmo_rotate_edge.c b/source/blender/bmesh/operators/bmo_rotate_edge.c
new file mode 100644
index 00000000000..e4b15c6a0ef
--- /dev/null
+++ b/source/blender/bmesh/operators/bmo_rotate_edge.c
@@ -0,0 +1,88 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/operators/bmo_rotate_edge.c
+ *  \ingroup bmesh
+ *
+ * Rotate edges topology that share two faces.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "bmesh.h"
+
+#include "intern/bmesh_operators_private.h" /* own include */
+
+void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
+{
+	BMOIter siter;
+	BMEdge *e, *e2;
+	const bool use_ccw   = BMO_slot_bool_get(op->slots_in, "use_ccw");
+	const bool is_single = BMO_slot_buffer_count(op->slots_in, "edges") == 1;
+	short check_flag = is_single ?
+	            BM_EDGEROT_CHECK_EXISTS :
+	            BM_EDGEROT_CHECK_EXISTS | BM_EDGEROT_CHECK_DEGENERATE;
+
+#define EDGE_OUT   1
+#define FACE_TAINT 1
+
+	BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
+		/**
+		 * this ends up being called twice, could add option to not to call check in
+		 * #BM_edge_rotate to get some extra speed */
+		if (BM_edge_rotate_check(e)) {
+			BMFace *fa, *fb;
+			if (BM_edge_face_pair(e, &fa, &fb)) {
+
+				/* check we're untouched */
+				if (BMO_face_flag_test(bm, fa, FACE_TAINT) == false &&
+				    BMO_face_flag_test(bm, fb, FACE_TAINT) == false)
+				{
+
+					/* don't touch again (faces will be freed so run before rotating the edge) */
+					BMO_face_flag_enable(bm, fa, FACE_TAINT);
+					BMO_face_flag_enable(bm, fb, FACE_TAINT);
+
+					if (!(e2 = BM_edge_rotate(bm, e, use_ccw, check_flag))) {
+
+						BMO_face_flag_disable(bm, fa, FACE_TAINT);
+						BMO_face_flag_disable(bm, fb, FACE_TAINT);
+#if 0
+						BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Could not rotate edge");
+						return;
+#endif
+
+						continue;
+					}
+
+					BMO_edge_flag_enable(bm, e2, EDGE_OUT);
+				}
+			}
+		}
+	}
+
+	BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT);
+
+#undef EDGE_OUT
+#undef FACE_TAINT
+
+}
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index aa1e4bc7523..e9ee1e6e552 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -121,60 +121,6 @@ void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op)
 	}
 }
 
-void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
-{
-	BMOIter siter;
-	BMEdge *e, *e2;
-	const bool use_ccw   = BMO_slot_bool_get(op->slots_in, "use_ccw");
-	const bool is_single = BMO_slot_buffer_count(op->slots_in, "edges") == 1;
-	short check_flag = is_single ?
-	            BM_EDGEROT_CHECK_EXISTS :
-	            BM_EDGEROT_CHECK_EXISTS | BM_EDGEROT_CHECK_DEGENERATE;
-
-#define EDGE_OUT   1
-#define FACE_TAINT 1
-
-	BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
-		/**
-		 * this ends up being called twice, could add option to not to call check in
-		 * #BM_edge_rotate to get some extra speed */
-		if (BM_edge_rotate_check(e)) {
-			BMFace *fa, *fb;
-			if (BM_edge_face_pair(e, &fa, &fb)) {
-
-				/* check we're untouched */
-				if (BMO_face_flag_test(bm, fa, FACE_TAINT) == false &&
-				    BMO_face_flag_test(bm, fb, FACE_TAINT) == false)
-				{
-
-					/* don't touch again (faces will be freed so run before rotating the edge) */
-					BMO_face_flag_enable(bm, fa, FACE_TAINT);
-					BMO_face_flag_enable(bm, fb, FACE_TAINT);
-
-					if (!(e2 = BM_edge_rotate(bm, e, use_ccw, check_flag))) {
-
-						BMO_face_flag_disable(bm, fa, FACE_TAINT);
-						BMO_face_flag_disable(bm, fb, FACE_TAINT);
-#if 0
-						BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Could not rotate edge");
-						return;
-#endif
-
-						continue;
-					}
-
-					BMO_edge_flag_enable(bm, e2, EDGE_OUT);
-				}
-			}
-		}
-	}
-
-	BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT);
-
-#undef EDGE_OUT
-#undef FACE_TAINT
-
-}
 
 #define SEL_FLAG	1
 #define SEL_ORIG	2



More information about the Bf-blender-cvs mailing list