[Bf-blender-cvs] [75eb947275c] blender2.8: Multi-Objects: Select similar edge SIMEDGE_CREASE and SIMEDGE_CREASE

Dalai Felinto noreply at git.blender.org
Tue Sep 25 21:36:17 CEST 2018


Commit: 75eb947275ca86c975e3aca35772d46150188521
Author: Dalai Felinto
Date:   Tue Sep 25 16:34:29 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB75eb947275ca86c975e3aca35772d46150188521

Multi-Objects: Select similar edge SIMEDGE_CREASE and SIMEDGE_CREASE

All edge options are done now.

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

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 aa917f0d529..144f5445d08 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -294,15 +294,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 	const float thresh = RNA_float_get(op->ptr, "threshold");
 	const float thresh_radians = thresh * (float)M_PI + FLT_EPSILON;
 	const int compare = RNA_enum_get(op->ptr, "compare");
-
-	if (ELEM(type,
-	         SIMEDGE_CREASE,
-	         SIMEDGE_BEVEL))
-	{
-		/* TODO (dfelinto) port the edge modes to multi-object. */
-		BKE_report(op->reports, RPT_ERROR, "Select similar edge mode not supported at the moment");
-		return OPERATOR_CANCELLED;
-	}
+	int custom_data_type = -1;
 
 	int tot_edges_selected_all = 0;
 	uint objects_len = 0;
@@ -325,6 +317,8 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 	int edge_data_value = SIMEDGE_DATA_NONE;
 
 	switch (type) {
+		case SIMEDGE_CREASE:
+		case SIMEDGE_BEVEL:
 		case SIMEDGE_FACE_ANGLE:
 		case SIMEDGE_LENGTH:
 		case SIMEDGE_DIR:
@@ -335,6 +329,15 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 			break;
 	}
 
+	switch (type) {
+		case SIMEDGE_CREASE:
+			custom_data_type = CD_CREASE;
+			break;
+		case SIMEDGE_BEVEL:
+			custom_data_type = CD_BWEIGHT;
+			break;
+	}
+
 	int tree_index = 0;
 	for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 		Object *ob = objects[ob_index];
@@ -345,10 +348,24 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 			continue;
 		}
 
-		if (type == SIMEDGE_FREESTYLE) {
-			if (!CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) {
-				edge_data_value |= SIMEDGE_DATA_FALSE;
-				continue;
+		switch (type) {
+			case SIMEDGE_FREESTYLE:
+			{
+				if (!CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) {
+					edge_data_value |= SIMEDGE_DATA_FALSE;
+					continue;
+				}
+				break;
+			}
+			case SIMEDGE_CREASE:
+			case SIMEDGE_BEVEL:
+			{
+				if (!CustomData_has_layer(&bm->edata, custom_data_type)) {
+					float dummy[3] = {0.0f, 0.0f, 0.0f};
+					BLI_kdtree_insert(tree, tree_index++, dummy);
+					continue;
+				}
+				break;
 			}
 		}
 
@@ -409,6 +426,14 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 						}
 						break;
 					}
+					case SIMEDGE_CREASE:
+					case SIMEDGE_BEVEL:
+					{
+						const float *value = CustomData_bmesh_get(&bm->edata, edge->head.data, custom_data_type);
+						float dummy[3] = {*value, 0.0f, 0.0f};
+						BLI_kdtree_insert(tree, tree_index++, dummy);
+						break;
+					}
 				}
 			}
 		}
@@ -426,11 +451,28 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 		BMesh *bm = em->bm;
 		bool changed = false;
 
-		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;
+		bool has_custom_data_layer;
+		switch (type) {
+			case SIMEDGE_FREESTYLE:
+			{
+				has_custom_data_layer = CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE);
+				if ((edge_data_value == SIMEDGE_DATA_TRUE) && !has_custom_data_layer) {
+					continue;
+				}
+				break;
+			}
+			case SIMEDGE_CREASE:
+			case SIMEDGE_BEVEL:
+			{
+				has_custom_data_layer = CustomData_has_layer(&bm->edata, custom_data_type);
+				if (!has_custom_data_layer) {
+					/* Proceed only if we have to select all the edges that have custom data value of 0.0f.
+					 * In this case we will just select all the edges.
+					 * Otherwise continue the for loop. */
+					if (!select_similar_compare_float_tree(tree, 0.0f, thresh, compare)) {
+						continue;
+					}
+				}
 			}
 		}
 
@@ -508,7 +550,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 					{
 						FreestyleEdge *fedge;
 
-						if (!has_freestyle_layer) {
+						if (!has_custom_data_layer) {
 							BLI_assert(edge_data_value == SIMEDGE_DATA_FALSE);
 							select = true;
 							break;
@@ -522,6 +564,20 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
 						}
 						break;
 					}
+					case SIMEDGE_CREASE:
+					case SIMEDGE_BEVEL:
+					{
+						if (!has_custom_data_layer) {
+							select = true;
+							break;
+						}
+
+						const float *value = CustomData_bmesh_get(&bm->edata, edge->head.data, custom_data_type);
+						if (select_similar_compare_float_tree(tree, *value, thresh, compare)) {
+							select = true;
+						}
+						break;
+					}
 				}
 
 				if (select) {



More information about the Bf-blender-cvs mailing list