[Bf-blender-cvs] [481927d4d6e] newboolean: Use an enum type for solver in boolean modifier.

Howard Trickey noreply at git.blender.org
Fri Aug 21 14:25:06 CEST 2020


Commit: 481927d4d6e124af8f707cd9d8c97f9e8a127d0c
Author: Howard Trickey
Date:   Fri Aug 21 08:23:18 2020 -0400
Branches: newboolean
https://developer.blender.org/rB481927d4d6e124af8f707cd9d8c97f9e8a127d0c

Use an enum type for solver in boolean modifier.

This matches what was done in a previous commit for the tool.
It makes it easier to associate a tooltip with each choice.
For this branch, I have the default solver be the Exact one;
when we merge to master, we will have to decide the best default.
Make format caught a coouple other files, sorr for not doing those
earlier.

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

M	source/blender/blenlib/tests/BLI_mesh_boolean_test.cc
M	source/blender/bmesh/tools/bmesh_boolean.cc
M	source/blender/editors/mesh/editmesh_intersect.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_boolean.c

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

diff --git a/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc b/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc
index f7590cc69ff..2cd6fdc6b4f 100644
--- a/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc
+++ b/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc
@@ -9,9 +9,9 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_array.hh"
-#include "BLI_mesh_boolean.hh"
 #include "BLI_map.hh"
 #include "BLI_math_mpq.hh"
+#include "BLI_mesh_boolean.hh"
 #include "BLI_mpq3.hh"
 #include "BLI_vector.hh"
 
diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc
index e28414d7609..83a2abc58cb 100644
--- a/source/blender/bmesh/tools/bmesh_boolean.cc
+++ b/source/blender/bmesh/tools/bmesh_boolean.cc
@@ -21,9 +21,9 @@
  */
 
 #include "BLI_array.hh"
-#include "BLI_mesh_boolean.hh"
 #include "BLI_math.h"
 #include "BLI_math_mpq.hh"
+#include "BLI_mesh_boolean.hh"
 #include "BLI_mesh_intersect.hh"
 
 #include "bmesh.h"
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 92909a7e15b..d56daaf8094 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -253,7 +253,7 @@ static void edbm_intersect_ui(bContext *UNUSED(C), wmOperator *op)
 #else
   bool use_exact = false;
 #endif
-  
+
   uiLayoutSetPropSep(layout, true);
   uiLayoutSetPropDecorate(layout, false);
   row = uiLayoutRow(layout, false);
@@ -262,11 +262,11 @@ static void edbm_intersect_ui(bContext *UNUSED(C), wmOperator *op)
   row = uiLayoutRow(layout, false);
   uiItemR(row, &ptr, "separate_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
   uiItemS(layout);
-  #ifdef WITH_GMP
+#ifdef WITH_GMP
   row = uiLayoutRow(layout, false);
   uiItemR(row, &ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
   uiItemS(layout);
-  #endif
+#endif
   if (!use_exact) {
     uiItemR(layout, &ptr, "threshold", 0, NULL, ICON_NONE);
   }
@@ -296,9 +296,9 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
   };
 
   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},
+      {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 */
@@ -418,7 +418,7 @@ static void edbm_intersect_boolean_ui(bContext *UNUSED(C), wmOperator *op)
 #else
   bool use_exact = false;
 #endif
-  
+
   uiLayoutSetPropSep(layout, true);
   uiLayoutSetPropDecorate(layout, false);
 
@@ -446,9 +446,9 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
       {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},
+      {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 */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 339840d55f2..2839d826df9 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -862,7 +862,8 @@ typedef struct BooleanModifierData {
 
   struct Object *object;
   char operation;
-  char _pad[2];
+  char solver;
+  char _pad[1];
   char bm_flag;
   float double_threshold;
 } BooleanModifierData;
@@ -873,12 +874,16 @@ typedef enum {
   eBooleanModifierOp_Difference = 2,
 } BooleanModifierOp;
 
-/* bm_flag (first three only used when G_DEBUG) */
+typedef enum {
+  eBooleanModifierSolver_Fast = 0,
+  eBooleanModifierSolver_Exact = 1,
+} BooleanModifierSolver;
+
+/* bm_flag only used when G_DEBUG. */
 enum {
   eBooleanModifierBMeshFlag_BMesh_Separate = (1 << 0),
   eBooleanModifierBMeshFlag_BMesh_NoDissolve = (1 << 1),
   eBooleanModifierBMeshFlag_BMesh_NoConnectRegions = (1 << 2),
-  eBooleanModifierBMeshFlag_BMesh_Exact = (1 << 3),
 };
 
 typedef struct MDefInfluence {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 1147e4466f5..2b8dbd6ae05 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2819,6 +2819,16 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem prop_solver_items[] = {
+      {eBooleanModifierSolver_Fast, "FAST", 0, "Fast", "Faster Solver, some limitations"},
+      {eBooleanModifierSolver_Exact,
+       "EXACT",
+       0,
+       "Exact",
+       "Exact Solver, slower, handles more cases"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "BooleanModifier", "Modifier");
   RNA_def_struct_ui_text(srna, "Boolean Modifier", "Boolean operations modifier");
   RNA_def_struct_sdna(srna, "BooleanModifierData");
@@ -2847,12 +2857,10 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
       prop, "Overlap Threshold", "Threshold for checking overlapping geometry");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
-  prop = RNA_def_boolean(srna,
-                         "use_exact",
-                         true,
-                         "Exact",
-                         "Use the Exact-arithmetic boolean (slower, handles more cases");
-  RNA_def_property_boolean_sdna(prop, NULL, "bm_flag", eBooleanModifierBMeshFlag_BMesh_Exact);
+  prop = RNA_def_property(srna, "solver", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, prop_solver_items);
+  RNA_def_property_enum_default(prop, eBooleanModifierSolver_Exact);
+  RNA_def_property_ui_text(prop, "Solver", "Which boolean solver to use.");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
   /* BMesh debugging options, only used when G_DEBUG is set */
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 6ba6eed64ce..0c8b8f6af3e 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -77,7 +77,9 @@ static void initData(ModifierData *md)
   bmd->double_threshold = 1e-6f;
   bmd->operation = eBooleanModifierOp_Difference;
 #ifdef WITH_GMP
-  bmd->bm_flag = eBooleanModifierBMeshFlag_BMesh_Exact;
+  bmd->solver = eBooleanModifierSolver_Exact;
+#else
+  bmd->solver = eBooleanModifierSolver_Fast;
 #endif
 }
 
@@ -320,7 +322,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
         }
 
 #ifdef WITH_GMP
-        bool use_exact = bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Exact;
+        bool use_exact = bmd->solver == eBooleanModifierSolver_Exact;
 #else
         bool use_exact = false;
 #endif
@@ -389,9 +391,17 @@ static void panel_draw(const bContext *C, Panel *panel)
   uiLayoutSetPropSep(layout, true);
 
   uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
-  uiItemR(layout, &ptr, "double_threshold", 0, NULL, ICON_NONE);
+
+#ifdef WITH_GMP
+  bool use_exact = RNA_enum_get(&ptr, "solver") == eBooleanModifierSolver_Exact;
+#else
+  bool use_exact = false;
+#endif
+  if (!use_exact) {
+    uiItemR(layout, &ptr, "double_threshold", 0, NULL, ICON_NONE);
+  }
 #ifdef WITH_GMP
-  uiItemR(layout, &ptr, "use_exact", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
 #endif
 
   if (G.debug) {



More information about the Bf-blender-cvs mailing list