diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2020-08-28 17:56:44 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2020-08-28 18:01:06 +0300 |
commit | 9e09b5c418c0a436e3c84ccf38c065527988b0a0 (patch) | |
tree | c0e81b8834aaf27c22a2734e364452fa2af5c6c1 /source/blender/modifiers/intern/MOD_boolean.c | |
parent | 4a17508c6d2a24dfb7c018ae49c80f12b4d3e610 (diff) |
Merge newboolean branch into master.
This is for design task T67744, Boolean Redesign.
It adds a choice of solver to the Boolean modifier and the
Intersect (Boolean) and Intersect (Knife) tools.
The 'Fast' choice is the current Bmesh boolean.
The new 'Exact' choice is a more advanced algorithm that supports
overlapping geometry and uses more robust calculations, but is
slower than the Fast choice.
The default with this commit is set to 'Exact'. We can decide before
the 2.91 release whether or not this is the right choice, but this
choice now will get us more testing and feedback on the new code.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_boolean.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.c | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 08fd7fb229d..0c8b8f6af3e 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -62,6 +62,7 @@ #include "bmesh.h" #include "bmesh_tools.h" +#include "tools/bmesh_boolean.h" #include "tools/bmesh_intersect.h" #ifdef DEBUG_TIME @@ -75,6 +76,11 @@ static void initData(ModifierData *md) bmd->double_threshold = 1e-6f; bmd->operation = eBooleanModifierOp_Difference; +#ifdef WITH_GMP + bmd->solver = eBooleanModifierSolver_Exact; +#else + bmd->solver = eBooleanModifierSolver_Fast; +#endif } static bool isDisabled(const struct Scene *UNUSED(scene), @@ -315,19 +321,30 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * 0; } - BM_mesh_intersect(bm, - looptris, - tottri, - bm_face_isect_pair, - NULL, - false, - use_separate, - use_dissolve, - use_island_connect, - false, - false, - bmd->operation, - bmd->double_threshold); +#ifdef WITH_GMP + bool use_exact = bmd->solver == eBooleanModifierSolver_Exact; +#else + bool use_exact = false; +#endif + + if (use_exact) { + BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, false, bmd->operation); + } + else { + BM_mesh_intersect(bm, + looptris, + tottri, + bm_face_isect_pair, + NULL, + false, + use_separate, + use_dissolve, + use_island_connect, + false, + false, + bmd->operation, + bmd->double_threshold); + } MEM_freeN(looptris); } @@ -374,7 +391,18 @@ 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, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE); +#endif if (G.debug) { uiLayout *col = uiLayoutColumn(layout, true); @@ -394,7 +422,7 @@ ModifierTypeInfo modifierType_Boolean = { /* structName */ "BooleanModifierData", /* structSize */ sizeof(BooleanModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh, + /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode, /* copyData */ BKE_modifier_copydata_generic, |