From de21ab418d69ca82a07ec7c836b1deca09bbd57f Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Mon, 7 Sep 2020 14:26:00 -0400 Subject: Add a Self option to the Exact boolean modifier. Fixes T52425. With this option, self-intersections in either or both operands will be handled properly (if both sides are piecewise winding number constant, and maybe some other cases too). In the Boolean tool, this flag was there already but the code forced a unary operation in that case; this commit corrects it to make a binary operation. This flag makes the code slower, which is why it is an option and not an always-on thing. --- source/blender/modifiers/intern/MOD_boolean.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_boolean.c') diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 87489c90de3..bef7d5d8e4f 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -77,6 +77,7 @@ static void initData(ModifierData *md) bmd->double_threshold = 1e-6f; bmd->operation = eBooleanModifierOp_Difference; bmd->solver = eBooleanModifierSolver_Exact; + bmd->flag = 0; } static bool isDisabled(const struct Scene *UNUSED(scene), @@ -319,15 +320,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * #ifdef WITH_GMP const bool use_exact = bmd->solver == eBooleanModifierSolver_Exact; + const bool use_self = (bmd->flag & eBooleanModifierFlag_Self) != 0; #else if (bmd->solver == eBooleanModifierSolver_Exact) { BKE_modifier_set_error(md, "Compiled without GMP, using fast solver"); } const bool use_exact = false; + const bool use_self = false; #endif if (use_exact) { - BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, false, bmd->operation); + BM_mesh_boolean( + bm, looptris, tottri, bm_face_isect_pair, NULL, use_self, bmd->operation); } else { BM_mesh_intersect(bm, @@ -393,7 +397,10 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - if (!use_exact) { + if (use_exact) { + uiItemR(layout, ptr, "use_self", 0, NULL, ICON_NONE); + } + else { uiItemR(layout, ptr, "double_threshold", 0, NULL, ICON_NONE); } -- cgit v1.2.3