fix [#25429] Armature modifier and inverted vertex group
authorCampbell Barton <ideasman42@gmail.com>
Fri, 31 Dec 2010 11:51:00 +0000 (11:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 31 Dec 2010 11:51:00 +0000 (11:51 +0000)
- the invert flag was only being used for multi-modifier, but there is no reason not to use this in normal cases as well.
- Armature modifier RNA name 'vertex_group' was incorrectly named 'vertex_group_multi_modifier' (own fault), confusion was caused by 'invert_vertex_group_multi_modifier' which was correct.

release/scripts/ui/properties_data_modifier.py
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/deform.c
source/blender/makesrna/intern/rna_modifier.c

index 49fc86e..1bc68a9 100644 (file)
@@ -61,14 +61,14 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel):
 
         split = layout.split()
         
-        col = split.column()
-        col.prop(md, "use_multi_modifier")
-        col = col.split()
-        col.active = md.use_multi_modifier
-        col.prop_search(md, "vertex_group_multi_modifier", ob, "vertex_groups", text="")
+        col = split.split()
+        col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
         sub = col.column()
-        sub.active = bool(md.vertex_group_multi_modifier)
-        sub.prop(md, "invert_vertex_group_multi_modifier")
+        sub.active = bool(md.vertex_group)
+        sub.prop(md, "invert_vertex_group")
+        
+        col = layout.column()
+        col.prop(md, "use_multi_modifier")
 
     def ARRAY(self, layout, ob, md):
         layout.prop(md, "fit_type")
index 39df877..5205171 100644 (file)
@@ -52,7 +52,7 @@ void                           defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
 struct MDeformWeight   *defvert_find_index(const struct MDeformVert *dv, const int defgroup);
 struct MDeformWeight   *defvert_verify_index(struct MDeformVert *dv, const int defgroup);
 
-float  defvert_find_weight(const struct MDeformVert *dvert, int group_num);
+float  defvert_find_weight(const struct MDeformVert *dvert, const int group_num);
 float  defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num);
 
 void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert);
index 22d27dc..6b21e45 100644 (file)
@@ -936,19 +936,15 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
                        dvert = NULL;
 
                if(armature_def_nr >= 0 && dvert) {
-                       armature_weight = 0.0f; /* a def group was given, so default to 0 */
-                       for(j = 0; j < dvert->totweight; j++) {
-                               if(dvert->dw[j].def_nr == armature_def_nr) {
-                                       armature_weight = dvert->dw[j].weight;
-                                       break;
-                               }
+                       armature_weight= defvert_find_weight(dvert, armature_def_nr);
+
+                       if(invert_vgroup) {
+                               armature_weight= 1.0f-armature_weight;
                        }
+
                        /* hackish: the blending factor can be used for blending with prevCos too */
                        if(prevCos) {
-                               if(invert_vgroup)
-                                       prevco_weight= 1.0f-armature_weight;
-                               else
-                                       prevco_weight= armature_weight;
+                               prevco_weight= armature_weight;
                                armature_weight= 1.0f;
                        }
                }
index ad79773..937681f 100644 (file)
@@ -448,7 +448,7 @@ void flip_side_name (char *name, const char *from_name, int strip_number)
        sprintf (name, "%s%s%s%s", prefix, replace, suffix, number);
 }
 
-float defvert_find_weight(const struct MDeformVert *dvert, int group_num)
+float defvert_find_weight(const struct MDeformVert *dvert, const int group_num)
 {
        MDeformWeight *dw= defvert_find_index(dvert, group_num);
        return dw ? dw->weight : 0.0f;
index ba73d61..11b0e8f 100644 (file)
@@ -1012,13 +1012,13 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Multi Modifier",  "Use same input as previous modifier, and mix results using overall vgroup");
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
        
-       prop= RNA_def_property(srna, "vertex_group_multi_modifier", PROP_STRING, PROP_NONE);
+       prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
        RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
        RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureModifier_vgroup_set");
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
-       prop= RNA_def_property(srna, "invert_vertex_group_multi_modifier", PROP_BOOLEAN, PROP_NONE);
+       prop= RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP);
        RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
        RNA_def_property_update(prop, 0, "rna_Modifier_update");