From 215651af1b09571eaceafd1c4269d559eb5328ca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Sep 2017 18:29:52 +1000 Subject: Boolean Modifier: add debug options Only show & use when running in debug mode. --- .../scripts/startup/bl_ui/properties_data_modifier.py | 11 ++++++++--- source/blender/makesdna/DNA_modifier_types.h | 10 +++++++++- source/blender/makesrna/intern/rna_modifier.c | 17 +++++++++++++++++ source/blender/modifiers/intern/MOD_boolean.c | 9 ++++++++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 15c9077d970..ff76c8d7d39 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -146,9 +146,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.row().prop(md, "offset_type", expand=True) def BOOLEAN(self, layout, ob, md): + solver = md.solver if not bpy.app.build_options.mod_boolean: - layout.label("Built without Boolean modifier") - return + if solver == 'CARVE': + layout.label("Built without Carve solver") split = layout.split() @@ -164,9 +165,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): split.column().label(text="Solver:") split.column().prop(md, "solver", text="") - if md.solver == 'BMESH': + if solver == 'BMESH': layout.prop(md, "double_threshold") + if bpy.app.debug: + layout.prop(md, "debug_options") + + def BUILD(self, layout, ob, md): split = layout.split() diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 67b29264d6c..e2dde412163 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -654,7 +654,8 @@ typedef struct BooleanModifierData { struct Object *object; char operation; char solver; - char pad[2]; + char pad; + char bm_flag; float double_threshold; } BooleanModifierData; @@ -669,6 +670,13 @@ typedef enum { eBooleanModifierSolver_BMesh = 1, } BooleanSolver; +/* bm_flag (only used when G_DEBUG) */ +enum { + eBooleanModifierBMeshFlag_BMesh_Separate = (1 << 0), + eBooleanModifierBMeshFlag_BMesh_NoDissolve = (1 << 1), + eBooleanModifierBMeshFlag_BMesh_NoConnectRegions = (1 << 2), +}; + typedef struct MDefInfluence { int vertex; float weight; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 96b88d98270..4db8b9e9de9 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1977,6 +1977,23 @@ static void rna_def_modifier_boolean(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 1, 0.0001, 6); RNA_def_property_ui_text(prop, "Overlap Threshold", "Threshold for checking overlapping geometry"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* BMesh debugging options, only used when G_DEBUG is set */ + + /* BMesh intersection options */ + static EnumPropertyItem debug_items[] = { + {eBooleanModifierBMeshFlag_BMesh_Separate, "SEPARATE", 0, "Separate", ""}, + {eBooleanModifierBMeshFlag_BMesh_NoDissolve, "NO_DISSOLVE", 0, "NoDissolve", ""}, + {eBooleanModifierBMeshFlag_BMesh_NoConnectRegions, "NO_CONNECT_REGIONS", 0, "NoConnectRegions", ""}, + {0, NULL, 0, NULL, NULL} + }; + + prop = RNA_def_property(srna, "debug_options", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, debug_items); + RNA_def_property_enum_sdna(prop, NULL, "bm_flag"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Debug", "Debugging options, only when started with '-d'"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_array(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index f94ab777eb4..1140460161f 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -59,6 +59,7 @@ #include "BLI_alloca.h" #include "BLI_math_geom.h" #include "BKE_material.h" +#include "BKE_global.h" /* only to check G.debug */ #include "MEM_guardedalloc.h" #include "bmesh.h" @@ -322,11 +323,17 @@ static DerivedMesh *applyModifier_bmesh( * currently this is ok for 'BM_mesh_intersect' */ // BM_mesh_normals_update(bm); - /* change for testing */ bool use_separate = false; bool use_dissolve = true; bool use_island_connect = true; + /* change for testing */ + if (G.debug & G_DEBUG) { + use_separate = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Separate) != 0; + use_dissolve = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoDissolve) == 0; + use_island_connect = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoConnectRegions) == 0; + } + BM_mesh_intersect( bm, looptris, tottri, -- cgit v1.2.3