New Boolean: Always expose solver propery, add warning

After discussion with @howardt, it seems the solver property should
always be exposed, even in lite builds. This commit removes the
ifdefs for that property and adds a warning if the "Exact" solver is
used when Blender is compiled without GMP.

These changes apply to the boolean modifier as well.
This commit is contained in:
Hans Goudey 2020-08-31 11:49:22 -05:00
parent 7056f180d3
commit fc8533a3c9
2 changed files with 18 additions and 29 deletions

View File

@ -154,6 +154,9 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op)
#ifdef WITH_GMP
const bool exact = RNA_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT;
#else
if (RNA_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT) {
BKE_report(op->reports, RPT_WARNING, "Compiled without GMP, using fast solver");
}
const bool exact = false;
#endif
bool use_self;
@ -248,11 +251,7 @@ static void edbm_intersect_ui(bContext *UNUSED(C), wmOperator *op)
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);
@ -262,11 +261,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
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);
}
@ -295,13 +294,11 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
{0, NULL, 0, NULL, NULL},
};
#ifdef WITH_GMP
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},
};
#endif
/* identifiers */
ot->name = "Intersect (Knife)";
@ -319,14 +316,12 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
ot->srna, "separate_mode", isect_separate_items, ISECT_SEPARATE_CUT, "Separate Mode", "");
RNA_def_float_distance(
ot->srna, "threshold", 0.000001f, 0.0, 0.01, "Merge threshold", "", 0.0, 0.001);
#ifdef WITH_GMP
RNA_def_enum(ot->srna,
"solver",
isect_intersect_solver_items,
ISECT_SOLVER_EXACT,
"Solver",
"Which Intersect solver to use");
#endif
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -351,9 +346,12 @@ 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_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT;
const bool use_exact = RNA_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT;
#else
bool use_exact = false;
if (RNA_enum_get(op->ptr, "solver") == ISECT_SOLVER_EXACT) {
BKE_report(op->reports, RPT_WARNING, "Compiled without GMP, using fast solver");
}
const bool use_exact = false;
#endif
const float eps = RNA_float_get(op->ptr, "threshold");
int (*test_fn)(BMFace *, void *);
@ -415,11 +413,7 @@ static void edbm_intersect_boolean_ui(bContext *UNUSED(C), wmOperator *op)
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);
@ -427,11 +421,11 @@ static void edbm_intersect_boolean_ui(bContext *UNUSED(C), wmOperator *op)
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) {
@ -447,13 +441,12 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
{BMESH_ISECT_BOOLEAN_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""},
{0, NULL, 0, NULL, NULL},
};
#ifdef WITH_GMP
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},
};
#endif
/* identifiers */
ot->name = "Intersect (Boolean)";
@ -480,14 +473,12 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "use_self", false, "Self", "Do self-union or self-intersection");
RNA_def_float_distance(
ot->srna, "threshold", 0.000001f, 0.0, 0.01, "Merge threshold", "", 0.0, 0.001);
#ifdef WITH_GMP
RNA_def_enum(ot->srna,
"solver",
isect_boolean_solver_items,
ISECT_SOLVER_EXACT,
"Solver",
"Which Boolean solver to use");
#endif
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

View File

@ -324,6 +324,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
#ifdef WITH_GMP
bool use_exact = bmd->solver == eBooleanModifierSolver_Exact;
#else
if (bmd->solver == eBooleanModifierSolver_Exact) {
BKE_modifier_set_error(md, "Compiled without GMP, using fast solver");
}
bool use_exact = false;
#endif
@ -390,15 +393,10 @@ static void panel_draw(const bContext *C, Panel *panel)
uiLayoutSetPropSep(layout, true);
const bool use_exact = RNA_enum_get(&ptr, "solver") == eBooleanModifierSolver_Exact;
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
#ifndef WITH_GMP
bool use_exact = false;
#else
bool use_exact = RNA_enum_get(&ptr, "solver") == eBooleanModifierSolver_Exact;
uiItemR(layout, &ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
#endif
if (!use_exact) {
uiItemR(layout, &ptr, "double_threshold", 0, NULL, ICON_NONE);