fix [#28225] Solidify Modifier creates wrong results when vertex group is attached
authorCampbell Barton <ideasman42@gmail.com>
Sun, 14 Aug 2011 06:43:58 +0000 (06:43 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 14 Aug 2011 06:43:58 +0000 (06:43 +0000)
infact this is not really a bug, irrespective zero vertex group weights gave overlapping geometry which isn't useful, add an option to set the thickness factor for zero weighted verts.

release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/properties_data_modifier.py
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/modifiers/intern/MOD_solidify.c

index 75df7dad5f2fc3be25a4c6df3cccc0e15cbdb936..896b76c59f6b25a9eec87e76b208ab54c769a2f3 100644 (file)
@@ -73,7 +73,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
         ob = context.object
         mesh = context.mesh
         space = context.space_data
-
+        layout.prop(context.scene.tool_settings, "mesh_select_mode", index=0, text="Vertex")
         if ob:
             layout.template_ID(ob, "data")
         elif mesh:
index e4bbd7d7d7d1429cedb47be9802e0dc4d2094cb5..179921c3c85784fdcaae0693dddd0332282ea39f 100644 (file)
@@ -577,13 +577,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         sub = col.column()
         sub.active = bool(md.vertex_group)
         sub.prop(md, "invert_vertex_group", text="Invert")
+        sub.prop(md, "thickness_vertex_group", text="Factor")
 
         col.prop(md, "use_even_offset")
         col.prop(md, "use_quality_normals")
         col.prop(md, "use_rim")
 
         sub = col.column()
-        sub.label()
         row = sub.split(align=True, percentage=0.4)
         row.prop(md, "material_offset", text="")
         row = row.row()
index 3787675f339da4766981bf723ced730abf5164b8..053f3b381683689041954b409a8f3bb714a8dc82 100644 (file)
@@ -712,16 +712,16 @@ typedef struct ShapeKeyModifierData {
 typedef struct SolidifyModifierData {
        ModifierData modifier;
 
-       char defgrp_name[32];           /* name of vertex group to use */
+       char defgrp_name[32];   /* name of vertex group to use */
        float offset;                   /* new surface offset level*/
        float offset_fac;               /* midpoint of the offset  */
+       float offset_fac_vg;    /* factor for the minimum weight to use when vgroups are used, avoids 0.0 weights giving duplicate geometry */
        float crease_inner;
        float crease_outer;
        float crease_rim;
        int flag;
        short mat_ofs;
        short mat_ofs_rim;
-       int pad;
 } SolidifyModifierData;
 
 #define MOD_SOLIDIFY_RIM                       (1<<0)
index ba655915fb62a961c43bf94264d47655bafc7d25..5c5391b0bba76af79cf61e4d8d44e17e0ee841dc 100644 (file)
@@ -2265,6 +2265,13 @@ static void rna_def_modifier_solidify(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Thickness", "Thickness of the shell");
        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);
+       RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
+       RNA_def_property_ui_text(prop, "Vertex Group Factor", "Thickness factor to use for zero vertex group influence");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
        prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_float_sdna(prop, NULL, "offset_fac");
        RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
index 0b1fac06e148cf74720114dc69f00fda3e1e6e1a..afe6da8b38a602930194d468d6b0b9f43747b061 100644 (file)
@@ -232,8 +232,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 
        float (*vert_nors)[3]= NULL;
 
-       float const ofs_orig=                           - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset);
-       float const ofs_new= smd->offset        - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset);
+       const float ofs_orig=                           - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset);
+       const float ofs_new= smd->offset        - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset);
+       const float offset_fac_vg= smd->offset_fac_vg;
+       const float offset_fac_vg_inv= 1.0f - smd->offset_fac_vg;
 
        /* weights */
        MDeformVert *dvert, *dv= NULL;
@@ -391,8 +393,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                        dv= dvert;
                        for(i=0; i<numVerts; i++, mv++) {
                                if(dv) {
-                                       if(defgrp_invert)       scalar_short_vgroup = scalar_short * (1.0f - defvert_find_weight(dv, defgrp_index));
-                                       else                            scalar_short_vgroup = scalar_short * defvert_find_weight(dv, defgrp_index);
+                                       if(defgrp_invert)       scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
+                                       else                            scalar_short_vgroup = defvert_find_weight(dv, defgrp_index);
+                                       scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short;
                                        dv++;
                                }
                                VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup);
@@ -405,8 +408,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                        dv= dvert;
                        for(i=0; i<numVerts; i++, mv++) {
                                if(dv) {
-                                       if(defgrp_invert)       scalar_short_vgroup = scalar_short * (1.0f - defvert_find_weight(dv, defgrp_index));
-                                       else                            scalar_short_vgroup = scalar_short * defvert_find_weight(dv, defgrp_index);
+                                       if(defgrp_invert)       scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
+                                       else                            scalar_short_vgroup = defvert_find_weight(dv, defgrp_index);
+                                       scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short;
                                        dv++;
                                }
                                VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup);
@@ -466,15 +470,21 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 
                /* vertex group support */
                if(dvert) {
+                       float scalar;
+
                        dv= dvert;
                        if(defgrp_invert) {
                                for(i=0; i<numVerts; i++, dv++) {
-                                       vert_angles[i] *= (1.0f - defvert_find_weight(dv, defgrp_index));
+                                       scalar= 1.0f - defvert_find_weight(dv, defgrp_index);
+                                       scalar= offset_fac_vg + (scalar * offset_fac_vg_inv);
+                                       vert_angles[i] *= scalar;
                                }
                        }
                        else {
                                for(i=0; i<numVerts; i++, dv++) {
-                                       vert_angles[i] *= defvert_find_weight(dv, defgrp_index);
+                                       scalar= defvert_find_weight(dv, defgrp_index);
+                                       scalar= offset_fac_vg + (scalar * offset_fac_vg_inv);
+                                       vert_angles[i] *= scalar;
                                }
                        }
                }