[Bf-blender-cvs] [9dc9692b097] master: Select Similar: hide 'threshold' from UI when not used

Philipp Oeser noreply at git.blender.org
Tue Jan 11 11:50:09 CET 2022


Commit: 9dc9692b09793cda3db9ba59108a81be338b4c4b
Author: Philipp Oeser
Date:   Fri Jan 7 11:26:05 2022 +0100
Branches: master
https://developer.blender.org/rB9dc9692b09793cda3db9ba59108a81be338b4c4b

Select Similar: hide 'threshold' from UI when not used

When the 'threshold' is not used in the type we are comparing, just hide
it. This was obvious for some types (e.g. Materials), but maybe not so
on others (e.g. Polygon Sides) and potentionally confusing.

Reported by @hitrpr in chat.

Differential Revision: https://developer.blender.org/D13760

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

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 f2311eb926d..949b12f9a65 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -1334,6 +1334,33 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
   return prop_similar_types;
 }
 
+static bool edbm_select_similar_poll_property(const bContext *UNUSED(C),
+                                              wmOperator *op,
+                                              const PropertyRNA *prop)
+{
+  const char *prop_id = RNA_property_identifier(prop);
+  const int type = RNA_enum_get(op->ptr, "type");
+
+  /* Only show threshold when it is used. */
+  if (STREQ(prop_id, "threshold")) {
+    if (!ELEM(type,
+              SIMVERT_NORMAL,
+              SIMEDGE_BEVEL,
+              SIMEDGE_CREASE,
+              SIMEDGE_DIR,
+              SIMEDGE_LENGTH,
+              SIMEDGE_FACE_ANGLE,
+              SIMFACE_AREA,
+              SIMFACE_PERIMETER,
+              SIMFACE_NORMAL,
+              SIMFACE_COPLANAR)) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
 void MESH_OT_select_similar(wmOperatorType *ot)
 {
   PropertyRNA *prop;
@@ -1347,6 +1374,7 @@ void MESH_OT_select_similar(wmOperatorType *ot)
   ot->invoke = WM_menu_invoke;
   ot->exec = edbm_select_similar_exec;
   ot->poll = ED_operator_editmesh;
+  ot->poll_property = edbm_select_similar_poll_property;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;



More information about the Bf-blender-cvs mailing list