[Bf-blender-cvs] [e45cfb574ee] master: Solidify Modifier: support non-manifold input

Henrik Dick noreply at git.blender.org
Mon Nov 4 00:36:22 CET 2019


Commit: e45cfb574ee75b85de084d09fcb8325778806bd2
Author: Henrik Dick
Date:   Sun Nov 3 14:24:24 2019 +1100
Branches: master
https://developer.blender.org/rBe45cfb574ee75b85de084d09fcb8325778806bd2

Solidify Modifier: support non-manifold input

This adds a new mode to solidify to support non-manifold geometry
with edges using 3 or more faces as input, resulting in a manifold mesh.

Since the differences between these methods don't translate well
into short terms, they're named "Simple" and "Complex" in the UI.

This also adds clamp with respect to angles
to the existing solidify modifier calculation.

===================================================================

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/intern/MOD_solidify.c
A	source/blender/modifiers/intern/MOD_solidify_extrude.c
A	source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
A	source/blender/modifiers/intern/MOD_solidify_util.h

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 124fe77cb52..3f1764faabe 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -954,11 +954,23 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.label(text="Settings are inside the Physics tab")
 
     def SOLIDIFY(self, layout, ob, md):
+
+        layout.row().prop(md, "solidify_mode")
+
+        solidify_mode = md.solidify_mode
+
+        if solidify_mode == 'NON_MANIFOLD':
+            layout.prop(md, "nonmanifold_thickness_mode")
+            layout.prop(md, "nonmanifold_boundary_mode")
+
         split = layout.split()
 
         col = split.column()
         col.prop(md, "thickness")
         col.prop(md, "thickness_clamp")
+        row = col.row()
+        row.active = md.thickness_clamp > 0.0
+        row.prop(md, "use_thickness_angle_clamp")
 
         col.separator()
 
@@ -972,18 +984,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         sub.active = bool(md.vertex_group)
         sub.prop(md, "thickness_vertex_group", text="Factor")
 
-        col.label(text="Crease:")
-        col.prop(md, "edge_crease_inner", text="Inner")
-        col.prop(md, "edge_crease_outer", text="Outer")
-        col.prop(md, "edge_crease_rim", text="Rim")
+        if solidify_mode == 'EXTRUDE':
+            col.label(text="Crease:")
+            col.prop(md, "edge_crease_inner", text="Inner")
+            col.prop(md, "edge_crease_outer", text="Outer")
+            col.prop(md, "edge_crease_rim", text="Rim")
 
         col = split.column()
 
         col.prop(md, "offset")
+
         col.prop(md, "use_flip_normals")
 
-        col.prop(md, "use_even_offset")
-        col.prop(md, "use_quality_normals")
+        if solidify_mode == 'EXTRUDE':
+            col.prop(md, "use_even_offset")
+            col.prop(md, "use_quality_normals")
+
         col.prop(md, "use_rim")
         col_rim = col.column()
         col_rim.active = md.use_rim
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index cceeb9c71d5..9c4d7bcd3b1 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1115,7 +1115,13 @@ typedef struct SolidifyModifierData {
   float offset_fac_vg;
   /** Clamp offset based on surrounding geometry. */
   float offset_clamp;
-  char _pad[4];
+  char mode;
+
+  /** Variables for #MOD_SOLIDIFY_MODE_NONMANIFOLD. */
+  char nonmanifold_offset_mode;
+  char nonmanifold_boundary_mode;
+
+  char _pad;
   float crease_inner;
   float crease_outer;
   float crease_rim;
@@ -1124,6 +1130,7 @@ typedef struct SolidifyModifierData {
   short mat_ofs_rim;
 } SolidifyModifierData;
 
+/** #SolidifyModifierData.flag */
 enum {
   MOD_SOLIDIFY_RIM = (1 << 0),
   MOD_SOLIDIFY_EVEN = (1 << 1),
@@ -1134,6 +1141,27 @@ enum {
 #endif
   MOD_SOLIDIFY_FLIP = (1 << 5),
   MOD_SOLIDIFY_NOSHELL = (1 << 6),
+  MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP = (1 << 7),
+};
+
+/** #SolidifyModifierData.mode */
+enum {
+  MOD_SOLIDIFY_MODE_EXTRUDE = 0,
+  MOD_SOLIDIFY_MODE_NONMANIFOLD = 1,
+};
+
+/** #SolidifyModifierData.nonmanifold_offset_mode */
+enum {
+  MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_FIXED = 0,
+  MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_EVEN = 1,
+  MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS = 2,
+};
+
+/** #SolidifyModifierData.nonmanifold_boundary_mode */
+enum {
+  MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_NONE = 0,
+  MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_ROUND = 1,
+  MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_FLAT = 2,
 };
 
 typedef struct ScrewModifierData {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 2a125625681..6e81b1343f5 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4059,16 +4059,71 @@ static void rna_def_modifier_surface(BlenderRNA *brna)
 
 static void rna_def_modifier_solidify(BlenderRNA *brna)
 {
+  static const EnumPropertyItem mode_items[] = {
+      {MOD_SOLIDIFY_MODE_EXTRUDE,
+       "EXTRUDE",
+       0,
+       "Simple",
+       "Output a solidified version of a mesh by simple extrusion"},
+      {MOD_SOLIDIFY_MODE_NONMANIFOLD,
+       "NON_MANIFOLD",
+       0,
+       "Complex",
+       "Output a manifold mesh even if the base mesh is non-manifold, "
+       "where edges have 3 or more connecting faces."
+       "This method is slower"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
+  static const EnumPropertyItem nonmanifold_thickness_mode_items[] = {
+      {MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_FIXED,
+       "FIXED",
+       0,
+       "Fixed",
+       "Most basic thickness calculation"},
+      {MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_EVEN,
+       "EVEN",
+       0,
+       "Even",
+       "Even thickness calculation which takes the angle between faces into account"},
+      {MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS,
+       "CONSTRAINTS",
+       0,
+       "Constraints",
+       "Thickness calculation using constraints, most advanced"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
+  static const EnumPropertyItem nonmanifold_boundary_mode_items[] = {
+      {MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_NONE, "NONE", 0, "None", "No shape correction"},
+      {MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_ROUND,
+       "ROUND",
+       0,
+       "Round",
+       "Round open perimeter shape"},
+      {MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_FLAT,
+       "FLAT",
+       0,
+       "Flat",
+       "Flat open perimeter shape"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   StructRNA *srna;
   PropertyRNA *prop;
 
   srna = RNA_def_struct(brna, "SolidifyModifier", "Modifier");
-  RNA_def_struct_ui_text(srna,
-                         "Solidify Modifier",
-                         "Create a solid skin by extruding, compensating for sharp angles");
+  RNA_def_struct_ui_text(
+      srna, "Solidify Modifier", "Create a solid skin, compensating for sharp angles");
   RNA_def_struct_sdna(srna, "SolidifyModifierData");
   RNA_def_struct_ui_icon(srna, ICON_MOD_SOLIDIFY);
 
+  prop = RNA_def_property(srna, "solidify_mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "mode");
+  RNA_def_property_enum_items(prop, mode_items);
+  RNA_def_property_ui_text(prop, "Mode", "Selects the used algorithm");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   prop = RNA_def_property(srna, "thickness", PROP_FLOAT, PROP_DISTANCE);
   RNA_def_property_float_sdna(prop, NULL, "offset");
   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
@@ -4083,6 +4138,11 @@ static void rna_def_modifier_solidify(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Clamp", "Offset clamp based on geometry scale");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+  prop = RNA_def_property(srna, "use_thickness_angle_clamp", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP);
+  RNA_def_property_ui_text(prop, "Angle Clamp", "Clamp thickness based on angles");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   prop = RNA_def_property(srna, "thickness_vertex_group", PROP_FLOAT, PROP_FACTOR);
   RNA_def_property_float_sdna(prop, NULL, "offset_fac_vg");
   RNA_def_property_range(prop, 0.0, 1.0);
@@ -4176,6 +4236,18 @@ static void rna_def_modifier_solidify(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_NOSHELL);
   RNA_def_property_ui_text(prop, "Only Rim", "Only add the rim to the original data");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  /* Settings for #MOD_SOLIDIFY_MODE_NONMANIFOLD */
+  prop = RNA_def_property(srna, "nonmanifold_thickness_mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "nonmanifold_offset_mode");
+  RNA_def_property_enum_items(prop, nonmanifold_thickness_mode_items);
+  RNA_def_property_ui_text(prop, "Thickness Mode", "Selects the used thickness algorithm");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "nonmanifold_boundary_mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, nonmanifold_boundary_mode_items);
+  RNA_def_property_ui_text(prop, "Boundary Shape", "Selects the boundary adjustment algorithm");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 static void rna_def_modifier_screw(BlenderRNA *brna)
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 1ae1f891e6f..602ef634e1b 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -85,6 +85,8 @@ set(SRC
   intern/MOD_smooth.c
   intern/MOD_softbody.c
   intern/MOD_solidify.c
+  intern/MOD_solidify_extrude.c
+  intern/MOD_solidify_nonmanifold.c
   intern/MOD_subsurf.c
   intern/MOD_surface.c
   intern/MOD_surfacedeform.c
@@ -104,6 +106,7 @@ set(SRC
   MOD_modifiertypes.h
   intern/MOD_fluidsim_util.h
   intern/MOD_meshcache_util.h
+  intern/MOD_solidify_util.h
   intern/MOD_util.h
   intern/MOD_weightvg_util.h
 )
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 292e659fe03..8ea0a602b65 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -23,142 +23,25 @@
 
 #include "BLI_utildefines.h"
 
-#include "BLI_bitmap.h"
-#include "BLI_math.h"
-#include "BLI_utildefines_stack.h"
-
 #include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "MEM_guardedalloc.h"
 
-#include "BKE_mesh.h"
 #include "BKE_particle.h"
-#include "BKE_deform.h"
 
 #include "MOD_modifiertypes.h"
-#include "MOD_util.h"
+
+#include "MOD_solidify_util.h"
 
 #ifdef __GNUC__
 #  pragma GCC diagnostic error "-Wsign-conversion"
 #endif
 
-/* skip shell thickness for non-manifold edges, see [#35710] */
-#define USE_NONMANIFOLD_WORKAROUND
-
-/* *** derived mesh high quality normal calculation function  *** */
-/* could be exposed for other functions to use */
-
-typedef struct EdgeFaceRef

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list