[Bf-blender-cvs] [09616c3f2fe] blender2.8: Multi-Objects: Select similar edge SIMEDGE_FREESTYLE

Dalai Felinto noreply at git.blender.org
Fri Sep 21 21:32:45 CEST 2018


Commit: 09616c3f2feb2ffa9d2e03d0d22b7921afa2c318
Author: Dalai Felinto
Date:   Fri Sep 21 16:28:25 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB09616c3f2feb2ffa9d2e03d0d22b7921afa2c318

Multi-Objects: Select similar edge SIMEDGE_FREESTYLE

I'm not happy with #ifdef WITH_FREESTYLE everywhere.
But I will remove them in an upcoming commit

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

M	source/blender/editors/mesh/editmesh_select_similar.c

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

diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index b94b29b2a15..ee21262fb01 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -39,6 +39,8 @@
 #include "BKE_layer.h"
 #include "BKE_report.h"
 
+#include "DNA_meshdata_types.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -295,9 +297,6 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 	const int compare = RNA_enum_get(op->ptr, "compare");
 
 	if (ELEM(type,
-#ifdef WITH_FREESTYLE
-	         SIMEDGE_FREESTYLE,
-#endif
 	         SIMEDGE_CREASE,
 	         SIMEDGE_BEVEL))
 	{
@@ -347,6 +346,15 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 			continue;
 		}
 
+#ifdef WITH_FREESTYLE
+		if (type == SIMEDGE_FREESTYLE) {
+			if (!CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) {
+				edge_data_value |= SIMEDGE_DATA_FALSE;
+				continue;
+			}
+		}
+#endif
+
 		BMEdge *edge; /* Mesh edge. */
 		BMIter iter; /* Selected edges iterator. */
 
@@ -389,11 +397,32 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 							goto selectall;
 						}
 						break;
+#ifdef WITH_FREESTYLE
+					case SIMEDGE_FREESTYLE:
+					{
+						FreestyleEdge *fedge;
+						fedge = CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE);
+						if ((fedge == NULL) || ((fedge->flag & FREESTYLE_EDGE_MARK) == 0)) {
+							edge_data_value |= SIMEDGE_DATA_FALSE;
+						}
+						else {
+							edge_data_value |= SIMEDGE_DATA_TRUE;
+						}
+						if (edge_data_value == SIMEDGE_DATA_ALL) {
+							goto selectall;
+						}
+						break;
+					}
+#endif
 				}
 			}
 		}
 	}
 
+#ifdef WITH_FREESTYLE
+	BLI_assert((type != SIMEDGE_FREESTYLE) || (edge_data_value != SIMEDGE_DATA_NONE));
+#endif
+
 	if (tree != NULL) {
 		BLI_kdtree_balance(tree);
 	}
@@ -404,6 +433,16 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 		BMesh *bm = em->bm;
 		bool changed = false;
 
+#ifdef WITH_FREESTYLE
+		bool has_freestyle_layer;
+		if (type == SIMEDGE_FREESTYLE) {
+			has_freestyle_layer = CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE);
+			if ((edge_data_value == SIMEDGE_DATA_TRUE) && !has_freestyle_layer) {
+				continue;
+			}
+		}
+#endif
+
 		BMEdge *edge; /* Mesh edge. */
 		BMIter iter; /* Selected edges iterator. */
 
@@ -474,6 +513,26 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 							select = true;
 						}
 						break;
+#ifdef WITH_FREESTYLE
+					case SIMEDGE_FREESTYLE:
+					{
+						FreestyleEdge *fedge;
+
+						if (!has_freestyle_layer) {
+							BLI_assert(edge_data_value == SIMEDGE_DATA_FALSE);
+							select = true;
+							break;
+						}
+
+						fedge = CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE);
+						if (((fedge != NULL) && (fedge->flag & FREESTYLE_EDGE_MARK)) ==
+						    ((edge_data_value & SIMEDGE_DATA_TRUE) != 0))
+						{
+							select = true;
+						}
+						break;
+					}
+#endif
 				}
 
 				if (select) {
@@ -491,7 +550,12 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 
 	if (false) {
 selectall:
-		BLI_assert(ELEM(type, SIMEDGE_SEAM, SIMEDGE_SHARP));
+		BLI_assert(ELEM(type,
+		                SIMEDGE_SEAM,
+#ifdef WITH_FREESTYLE
+		                SIMEDGE_FREESTYLE,
+#endif
+		                SIMEDGE_SHARP));
 
 		for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 			Object *ob = objects[ob_index];



More information about the Bf-blender-cvs mailing list