Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-09-26 00:57:28 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-09-26 01:18:30 +0300
commit424bb2ebdc69c9c09f977b4527cc0de4688def5e (patch)
tree5dbf5f8158a5b0f9708a3174919ac23c5711b612 /source/blender/editors/mesh/editmesh_select_similar.c
parentf59b968cef8541803d18ef465aa56a47a3130ad0 (diff)
Multi-Objects: Select similar face SIMFACE_SMOOTH
Diffstat (limited to 'source/blender/editors/mesh/editmesh_select_similar.c')
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c72
1 files changed, 67 insertions, 5 deletions
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index d5ea7829e58..2fa95d2085e 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -171,6 +171,30 @@ static bool select_similar_compare_float_tree(const KDTree *tree, const float le
/** \name Select Similar Face
* \{ */
+enum {
+ SIMFACE_DATA_NONE = 0,
+ SIMFACE_DATA_TRUE = (1 << 0),
+ SIMFACE_DATA_FALSE = (1 << 1),
+ SIMFACE_DATA_ALL = (SIMFACE_DATA_TRUE | SIMFACE_DATA_FALSE),
+};
+
+/**
+ * Return true if we still don't know the final value for this edge data.
+ * In other words, if we need to keep iterating over the objects or we can
+ * just go ahead and select all the objects.
+ */
+static bool face_data_value_set(BMFace *face, const int hflag, int *r_value)
+{
+ if (BM_elem_flag_test(face, hflag)) {
+ *r_value |= SIMFACE_DATA_TRUE;
+ }
+ else {
+ *r_value |= SIMFACE_DATA_FALSE;
+ }
+
+ return *r_value != SIMFACE_DATA_ALL;
+}
+
/* TODO(dfelinto): `types` that should technically be compared in world space but are not:
* -SIMFACE_AREA
* -SIMFACE_PERIMETER
@@ -186,7 +210,6 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
if (ELEM(type,
SIMFACE_COPLANAR,
- SIMFACE_SMOOTH,
SIMFACE_FACEMAP,
SIMFACE_FREESTYLE))
{
@@ -212,6 +235,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
KDTree *tree = NULL;
GSet *gset = NULL;
+ int face_data_value = SIMFACE_DATA_NONE;
switch (type) {
case SIMFACE_AREA:
@@ -290,6 +314,13 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
BLI_kdtree_insert(tree, tree_index++, normal);
break;
}
+ case SIMFACE_SMOOTH:
+ {
+ if (!face_data_value_set(face, BM_ELEM_SMOOTH, &face_data_value)) {
+ goto face_select_all;
+ }
+ break;
+ }
}
}
}
@@ -390,6 +421,13 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
}
break;
}
+ case SIMFACE_SMOOTH:
+ if ((BM_elem_flag_test(face, BM_ELEM_SMOOTH) != 0) ==
+ ((face_data_value & SIMFACE_DATA_TRUE) != 0))
+ {
+ select = true;
+ }
+ break;
}
if (select) {
@@ -405,6 +443,30 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
}
}
+ if (false) {
+face_select_all:
+ BLI_assert(ELEM(type,
+ SIMFACE_SMOOTH
+ ));
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(ob);
+ BMesh *bm = em->bm;
+
+ BMFace *face; /* Mesh face. */
+ BMIter iter; /* Selected faces iterator. */
+
+ BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(face, BM_ELEM_SELECT)) {
+ BM_face_select_set(bm, face, true);
+ }
+ }
+ EDBM_selectmode_flush(em);
+ EDBM_update_generic(em, false, false);
+ }
+ }
+
MEM_freeN(objects);
BLI_kdtree_free(tree);
if (gset != NULL) {
@@ -609,12 +671,12 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
}
case SIMEDGE_SEAM:
if (!edge_data_value_set(edge, BM_ELEM_SEAM, &edge_data_value)) {
- goto selectall;
+ goto edge_select_all;
}
break;
case SIMEDGE_SHARP:
if (!edge_data_value_set(edge, BM_ELEM_SMOOTH, &edge_data_value)) {
- goto selectall;
+ goto edge_select_all;
}
break;
case SIMEDGE_FREESTYLE:
@@ -628,7 +690,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
edge_data_value |= SIMEDGE_DATA_TRUE;
}
if (edge_data_value == SIMEDGE_DATA_ALL) {
- goto selectall;
+ goto edge_select_all;
}
break;
}
@@ -800,7 +862,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
}
if (false) {
-selectall:
+edge_select_all:
BLI_assert(ELEM(type,
SIMEDGE_SEAM,
SIMEDGE_SHARP,