[Bf-blender-cvs] [c9d0873e90a] blender2.8: Multi-Objects: Select similar face SIMFACE_FREESTYLE

Dalai Felinto noreply at git.blender.org
Wed Sep 26 00:19:07 CEST 2018


Commit: c9d0873e90acd8505ab984c5070f2f7890a29b5d
Author: Dalai Felinto
Date:   Tue Sep 25 19:10:58 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBc9d0873e90acd8505ab984c5070f2f7890a29b5d

Multi-Objects: Select similar face SIMFACE_FREESTYLE

Note: 2.7x seem to be checking for edge data instead of face, but I do not see why not to get FreestyleFace.

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

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 2fa95d2085e..bd17b066d2e 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -210,8 +210,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 
 	if (ELEM(type,
 	         SIMFACE_COPLANAR,
-	         SIMFACE_FACEMAP,
-	         SIMFACE_FREESTYLE))
+	         SIMFACE_FACEMAP))
 	{
 		BKE_report(op->reports, RPT_ERROR, "Select similar face mode not supported at the moment");
 		return OPERATOR_CANCELLED;
@@ -270,6 +269,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 				material_array = give_matarar(ob);
 				break;
 			}
+			case SIMFACE_FREESTYLE:
+			{
+				if (!CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) {
+					face_data_value |= SIMFACE_DATA_FALSE;
+					continue;
+				}
+				break;
+			}
 		}
 
 		BMFace *face; /* Mesh face. */
@@ -321,11 +328,28 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 						}
 						break;
 					}
+					case SIMFACE_FREESTYLE:
+					{
+						FreestyleFace *fface;
+						fface = CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE);
+						if ((fface == NULL) || ((fface->flag & FREESTYLE_FACE_MARK) == 0)) {
+							face_data_value |= SIMFACE_DATA_FALSE;
+						}
+						else {
+							face_data_value |= SIMFACE_DATA_TRUE;
+						}
+						if (face_data_value == SIMFACE_DATA_ALL) {
+							goto face_select_all;
+						}
+						break;
+					}
 				}
 			}
 		}
 	}
 
+	BLI_assert((type != SIMFACE_FREESTYLE) || (face_data_value != SIMFACE_DATA_NONE));
+
 	if (tree != NULL) {
 		BLI_kdtree_balance(tree);
 	}
@@ -337,6 +361,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 		bool changed = false;
 		Material ***material_array;
 
+		bool has_custom_data_layer;
 		switch (type) {
 			case SIMFACE_MATERIAL:
 			{
@@ -346,6 +371,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 				material_array = give_matarar(ob);
 				break;
 			}
+			case SIMFACE_FREESTYLE:
+			{
+				has_custom_data_layer = CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE);
+				if ((face_data_value == SIMFACE_DATA_TRUE) && !has_custom_data_layer) {
+					continue;
+				}
+				break;
+			}
 		}
 		
 		BMFace *face; /* Mesh face. */
@@ -428,6 +461,24 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 							select = true;
 						}
 						break;
+					case SIMFACE_FREESTYLE:
+					{
+						FreestyleFace *fface;
+
+						if (!has_custom_data_layer) {
+							BLI_assert(face_data_value == SIMFACE_DATA_FALSE);
+							select = true;
+							break;
+						}
+
+						fface = CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE);
+						if (((fface != NULL) && (fface->flag & FREESTYLE_FACE_MARK)) ==
+						    ((face_data_value & SIMFACE_DATA_TRUE) != 0))
+						{
+							select = true;
+						}
+						break;
+					}
 				}
 
 				if (select) {
@@ -446,7 +497,8 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 	if (false) {
 face_select_all:
 		BLI_assert(ELEM(type,
-		                SIMFACE_SMOOTH
+		                SIMFACE_SMOOTH,
+		                SIMFACE_FREESTYLE
 		                ));
 
 		for (uint ob_index = 0; ob_index < objects_len; ob_index++) {



More information about the Bf-blender-cvs mailing list