[Bf-blender-cvs] [8cf5eaa2baa] blender2.8: Add Face-Map to select similar

Campbell Barton noreply at git.blender.org
Thu Jun 1 08:43:48 CEST 2017


Commit: 8cf5eaa2baa70515f4731cc9ac5ac6c5e5cf3c44
Author: Campbell Barton
Date:   Thu Jun 1 16:42:14 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB8cf5eaa2baa70515f4731cc9ac5ac6c5e5cf3c44

Add Face-Map to select similar

Handy for setting up face-maps,
also allows selecting all faces with no assigned map.

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

M	source/blender/bmesh/intern/bmesh_operators.h
M	source/blender/bmesh/operators/bmo_similar.c
M	source/blender/editors/mesh/editmesh_select.c

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

diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 31c696da0d4..80b57eb3565 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -83,6 +83,7 @@ enum {
 	SIMFACE_NORMAL,
 	SIMFACE_COPLANAR,
 	SIMFACE_SMOOTH,
+	SIMFACE_FACEMAP,
 #ifdef WITH_FREESTYLE
 	SIMFACE_FREESTYLE
 #endif
diff --git a/source/blender/bmesh/operators/bmo_similar.c b/source/blender/bmesh/operators/bmo_similar.c
index 0e49c957213..0cd17258834 100644
--- a/source/blender/bmesh/operators/bmo_similar.c
+++ b/source/blender/bmesh/operators/bmo_similar.c
@@ -106,11 +106,28 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
 	const float thresh = BMO_slot_float_get(op->slots_in, "thresh");
 	const float thresh_radians = thresh * (float)M_PI;
 	const int compare = BMO_slot_int_get(op->slots_in, "compare");
+	/* for comparison types that use custom-data */
+	int cd_offset = -1;
 
 	/* initial_elem - other_elem */
 	float delta_fl;
 	int   delta_i;
 
+	if (type == SIMFACE_FACEMAP) {
+		cd_offset = CustomData_get_offset(&bm->pdata, CD_FACEMAP);
+		if (cd_offset == -1) {
+			return;
+		}
+	}
+#ifdef WITH_FREESTYLE
+	else if (type == SIMFACE_FREESTYLE) {
+		cd_offset = CustomData_get_offset(&bm->pdata, CD_FREESTYLE_FACE);
+		if (cd_offset == -1) {
+			return;
+		}
+	}
+#endif
+
 	num_total = BM_mesh_elem_count(bm, BM_FACE);
 
 	/*
@@ -182,7 +199,6 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
 							cont = false;
 						}
 						break;
-
 					case SIMFACE_NORMAL:
 						angle = angle_normalized_v3v3(fs->no, fm->no);	/* if the angle between the normals -> 0 */
 						if (angle <= thresh_radians) {
@@ -239,20 +255,29 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
 							cont = false;
 						}
 						break;
+					case SIMFACE_FACEMAP:
+					{
+						BLI_assert(cd_offset != -1);
+						const int *fmap1 = BM_ELEM_CD_GET_VOID_P(fs, cd_offset);
+						const int *fmap2 = BM_ELEM_CD_GET_VOID_P(fm, cd_offset);
+						if (*fmap1  == *fmap2) {
+							BMO_face_flag_enable(bm, fm, FACE_MARK);
+							cont = false;
+						}
+						break;
+					}
 #ifdef WITH_FREESTYLE
 					case SIMFACE_FREESTYLE:
-						if (CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) {
-							FreestyleEdge *ffa1, *ffa2;
-
-							ffa1 = CustomData_bmesh_get(&bm->pdata, fs->head.data, CD_FREESTYLE_FACE);
-							ffa2 = CustomData_bmesh_get(&bm->pdata, fm->head.data, CD_FREESTYLE_FACE);
-
-							if (ffa1 && ffa2 && (ffa1->flag & FREESTYLE_FACE_MARK) == (ffa2->flag & FREESTYLE_FACE_MARK)) {
-								BMO_face_flag_enable(bm, fm, FACE_MARK);
-								cont = false;
-							}
+					{
+						BLI_assert(cd_offset != -1);
+						const FreestyleEdge *ffa1 = BM_ELEM_CD_GET_VOID_P(fs, cd_offset);
+						const FreestyleEdge *ffa2 = BM_ELEM_CD_GET_VOID_P(fm, cd_offset);
+						if ((ffa1->flag & FREESTYLE_FACE_MARK) == (ffa2->flag & FREESTYLE_FACE_MARK)) {
+							BMO_face_flag_enable(bm, fm, FACE_MARK);
+							cont = false;
 						}
 						break;
+					}
 #endif
 					default:
 						BLI_assert(0);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 4bad4fcaf49..c68c429bfb5 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -991,6 +991,7 @@ static EnumPropertyItem prop_similar_types[] = {
 	{SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""},
 	{SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""},
 	{SIMFACE_SMOOTH, "SMOOTH", 0, "Flat/Smooth", ""},
+	{SIMFACE_FACEMAP, "FACE_MAP", 0, "Face-Map", ""},
 #ifdef WITH_FREESTYLE
 	{SIMFACE_FREESTYLE, "FREESTYLE_FACE", 0, "Freestyle Face Marks", ""},
 #endif




More information about the Bf-blender-cvs mailing list