[Bf-blender-cvs] [5c3586c] bmesh-boolean-experiment: Support dissolving vertices created by tessellated edges
Campbell Barton
noreply at git.blender.org
Thu Dec 3 06:20:24 CET 2015
Commit: 5c3586c350af37795cb58cfa2af4220f7c9ad4f5
Author: Campbell Barton
Date: Thu Dec 3 16:09:30 2015 +1100
Branches: bmesh-boolean-experiment
https://developer.blender.org/rB5c3586c350af37795cb58cfa2af4220f7c9ad4f5
Support dissolving vertices created by tessellated edges
This needs to be done using different logic for boolean operations to ensure its not creating 2-sided faces.
Also make dissolve and separate into options (mainly for testing/debugging).
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/bmesh/tools/bmesh_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/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index e7877e1..457e8c3 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -154,6 +154,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "operation", text="")
if md.method == 'BMESH':
col.prop(md, "threshold")
+ col.prop(md, "options", expand=True)
col = split.column()
col.label(text="Object:")
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index 6437835..639071d 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -1307,7 +1307,7 @@ bool BM_mesh_intersect(
/* important to handle before edgenet */
#ifdef USE_DISSOLVE
- if (use_dissolve) {
+ if (use_dissolve && (boolean_mode == BOOLEAN_NONE)) {
/* first pass */
BMVert *(*splice_ls)[2];
STACK_DECLARE(splice_ls);
@@ -1659,6 +1659,37 @@ bool BM_mesh_intersect(
MEM_freeN(groups_array);
MEM_freeN(group_index);
+#ifdef USE_DISSOLVE
+ /* We have dissolve code above, this is alternative logic,
+ * we need to do it after the boolean is executed. */
+ if (use_dissolve) {
+ LinkNode *node;
+ for (node = s.vert_dissolve; node; node = node->next) {
+ BMVert *v = node->link;
+ if (BM_vert_is_edge_pair(v)) {
+ /* we wont create degenerate faces from this */
+ bool ok = true;
+
+ /* would we create a 2-sided-face?
+ * if so, don't dissolve this since we may */
+ if (v->e->l) {
+ BMLoop *l_iter = v->e->l;
+ do {
+ if (l_iter->f->len == 3) {
+ ok = false;
+ break;
+ }
+ } while ((l_iter = l_iter->radial_next) != v->e->l);
+ }
+
+ if (ok) {
+ BM_vert_collapse_edge(bm, v->e, v, true, false);
+ }
+ }
+ }
+ }
+#endif
+
{
int tot = bm->totface;
for (i = 0; i < tot; i++) {
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 8887d8b..3744ff3 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -640,7 +640,7 @@ typedef struct BooleanModifierData {
ModifierData modifier;
struct Object *object;
- short operation, method;
+ char operation, method, flag, _pad, pad[8];
float threshold;
} BooleanModifierData;
@@ -655,6 +655,11 @@ typedef enum {
eBooleanModifierMethod_BMesh = 1,
} BooleanModifierMethod;
+typedef enum {
+ eBooleanModifierFlag_Dissolve = (1 << 0),
+ eBooleanModifierFlag_Separate = (1 << 1),
+} BooleanModifierFlag;
+
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 0be06f2..69a3380 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1874,6 +1874,12 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem prop_option_items[] = {
+ {eBooleanModifierFlag_Dissolve, "DISSOLVE", 0, "Dissolve", ""},
+ {eBooleanModifierFlag_Separate, "SEPARATE", 0, "Separate", ""},
+ {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");
@@ -1895,6 +1901,14 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Method", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "options", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, prop_option_items);
+ RNA_def_property_flag(prop, PROP_ENUM_FLAG);
+ RNA_def_property_ui_text(prop, "Options", "");
+ RNA_def_property_flag(prop, PROP_ENUM_FLAG);
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "threshold");
RNA_def_property_range(prop, 0, 1.0f);
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index c28c6f9..05cc231 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -253,7 +253,9 @@ static DerivedMesh *applyModifier_bmesh(
bm,
looptris, tottri,
bm_face_isect_pair, NULL,
- false, false, false,
+ false,
+ (bmd->flag & eBooleanModifierFlag_Separate) != 0,
+ (bmd->flag & eBooleanModifierFlag_Dissolve) != 0,
bmd->operation,
bmd->threshold);
More information about the Bf-blender-cvs
mailing list