Commit: de294bb3e27ca1e5a90c320ea2d737e6f5100a6b
Author: Howard Trickey
Date:   Thu Aug 20 21:23:21 2020 -0400
Branches: newboolean
https://developer.blender.org/rBde294bb3e27ca1e5a90c320ea2d737e6f5100a6b

Use custom layout for intersect tools, with expanded choices.

Makes "Exact" vs "Fast" a choice with tooltips for each.
Hides merge threshold when in Exact mode.

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

M       source/blender/editors/mesh/editmesh_intersect.c

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

diff --git a/source/blender/editors/mesh/editmesh_intersect.c 
b/source/blender/editors/mesh/editmesh_intersect.c
index 1803ea7fb63..92909a7e15b 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -39,6 +39,9 @@
 
 #include "WM_types.h"
 
+#include "UI_interface.h"
+#include "UI_resources.h"
+
 #include "ED_mesh.h"
 #include "ED_screen.h"
 
@@ -135,6 +138,11 @@ enum {
   ISECT_SEPARATE_NONE = 2,
 };
 
+enum {
+  ISECT_SOLVER_FAST = 0,
+  ISECT_SOLVER_EXACT = 1,
+};
+
 static int edbm_intersect_exec(bContext *C, wmOperator *op)
 {
   const int mode = RNA_enum_get(op->ptr, "mode");
@@ -144,7 +152,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op)
   const int separate_mode = RNA_enum_get(op->ptr, "separate_mode");
   const float eps = RNA_float_get(op->ptr, "threshold");
 #ifdef WITH_GMP
-  const bool exact = RNA_boolean_get(op->ptr, "use_exact");
+  const bool exact = RNA_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT;
 #else
   const bool exact = false;
 #endif
@@ -232,6 +240,38 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
+static void edbm_intersect_ui(bContext *UNUSED(C), wmOperator *op)
+{
+  uiLayout *layout = op->layout;
+  uiLayout *row;
+  PointerRNA ptr;
+
+  RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+
+#ifdef WITH_GMP
+  bool use_exact = RNA_enum_get(&ptr, "solver") == ISECT_SOLVER_EXACT;
+#else
+  bool use_exact = false;
+#endif
+  
+  uiLayoutSetPropSep(layout, true);
+  uiLayoutSetPropDecorate(layout, false);
+  row = uiLayoutRow(layout, false);
+  uiItemR(row, &ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+  uiItemS(layout);
+  row = uiLayoutRow(layout, false);
+  uiItemR(row, &ptr, "separate_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+  uiItemS(layout);
+  #ifdef WITH_GMP
+  row = uiLayoutRow(layout, false);
+  uiItemR(row, &ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+  uiItemS(layout);
+  #endif
+  if (!use_exact) {
+    uiItemR(layout, &ptr, "threshold", 0, NULL, ICON_NONE);
+  }
+}
+
 void MESH_OT_intersect(struct wmOperatorType *ot)
 {
   static const EnumPropertyItem isect_mode_items[] = {
@@ -255,6 +295,12 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem isect_intersect_solver_items[] = {
+    {ISECT_SOLVER_FAST, "FAST", 0, "Fast", "Faster Solver, some limitations"},
+    {ISECT_SOLVER_EXACT, "EXACT", 0, "Exact", "Exact Solver, slower, handles 
more cases"},
+    {0, NULL, 0, NULL, NULL},
+  };
+
   /* identifiers */
   ot->name = "Intersect (Knife)";
   ot->description = "Cut an intersection into faces";
@@ -263,6 +309,7 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
   /* api callbacks */
   ot->exec = edbm_intersect_exec;
   ot->poll = ED_operator_editmesh;
+  ot->ui = edbm_intersect_ui;
 
   /* props */
   RNA_def_enum(ot->srna, "mode", isect_mode_items, ISECT_SEL_UNSEL, "Source", 
"");
@@ -271,11 +318,12 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
   RNA_def_float_distance(
       ot->srna, "threshold", 0.000001f, 0.0, 0.01, "Merge threshold", "", 0.0, 
0.001);
 #ifdef WITH_GMP
-  RNA_def_boolean(ot->srna,
-                  "use_exact",
-                  true,
-                  "Exact",
-                  "Use the Exact-arithmetic boolean (slower, handles more 
cases");
+  RNA_def_enum(ot->srna,
+               "solver",
+               isect_intersect_solver_items,
+               ISECT_SOLVER_EXACT,
+               "Solver",
+               "Which Intersect solver to use");
 #endif
 
   /* flags */
@@ -301,7 +349,7 @@ static int edbm_intersect_boolean_exec(bContext *C, 
wmOperator *op)
   bool use_swap = RNA_boolean_get(op->ptr, "use_swap");
   bool use_self = RNA_boolean_get(op->ptr, "use_self");
 #ifdef WITH_GMP
-  bool use_exact = RNA_boolean_get(op->ptr, "use_exact");
+  bool use_exact = RNA_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT;
 #else
   bool use_exact = false;
 #endif
@@ -357,6 +405,38 @@ static int edbm_intersect_boolean_exec(bContext *C, 
wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
+static void edbm_intersect_boolean_ui(bContext *UNUSED(C), wmOperator *op)
+{
+  uiLayout *layout = op->layout;
+  uiLayout *row;
+  PointerRNA ptr;
+
+  RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+
+#ifdef WITH_GMP
+  bool use_exact = RNA_enum_get(&ptr, "solver") == ISECT_SOLVER_EXACT;
+#else
+  bool use_exact = false;
+#endif
+  
+  uiLayoutSetPropSep(layout, true);
+  uiLayoutSetPropDecorate(layout, false);
+
+  row = uiLayoutRow(layout, false);
+  uiItemR(row, &ptr, "operation", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+  uiItemS(layout);
+#ifdef WITH_GMP
+  row = uiLayoutRow(layout, false);
+  uiItemR(row, &ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+  uiItemS(layout);
+#endif
+  uiItemR(layout, &ptr, "use_swap", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "use_self", 0, NULL, ICON_NONE);
+  if (!use_exact) {
+    uiItemR(layout, &ptr, "threshold", 0, NULL, ICON_NONE);
+  }
+}
+
 void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
 {
   static const EnumPropertyItem isect_boolean_operation_items[] = {
@@ -365,6 +445,11 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
       {BMESH_ISECT_BOOLEAN_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""},
       {0, NULL, 0, NULL, NULL},
   };
+  static const EnumPropertyItem isect_boolean_solver_items[] = {
+    {ISECT_SOLVER_FAST, "FAST", 0, "Fast", "Faster Solver, some limitations"},
+    {ISECT_SOLVER_EXACT, "EXACT", 0, "Exact", "Exact Solver, slower, handles 
more cases"},
+    {0, NULL, 0, NULL, NULL},
+  };
 
   /* identifiers */
   ot->name = "Intersect (Boolean)";
@@ -374,14 +459,15 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
   /* api callbacks */
   ot->exec = edbm_intersect_boolean_exec;
   ot->poll = ED_operator_editmesh;
+  ot->ui = edbm_intersect_boolean_ui;
 
   /* props */
   RNA_def_enum(ot->srna,
                "operation",
                isect_boolean_operation_items,
                BMESH_ISECT_BOOLEAN_DIFFERENCE,
-               "Boolean",
-               "");
+               "Boolean operation",
+               "Which boolean operation to apply");
   RNA_def_boolean(ot->srna,
                   "use_swap",
                   false,
@@ -391,11 +477,12 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
   RNA_def_float_distance(
       ot->srna, "threshold", 0.000001f, 0.0, 0.01, "Merge threshold", "", 0.0, 
0.001);
 #ifdef WITH_GMP
-  RNA_def_boolean(ot->srna,
-                  "use_exact",
-                  true,
-                  "Exact",
-                  "Use the Exact-arithmetic boolean (slower, handles more 
cases");
+  RNA_def_enum(ot->srna,
+               "solver",
+               isect_boolean_solver_items,
+               ISECT_SOLVER_EXACT,
+               "Solver",
+               "Which Boolean solver to use");
 #endif
 
   /* flags */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to