Revamp of multi modifier option!
authorTon Roosendaal <ton@blender.org>
Mon, 19 Nov 2007 18:00:48 +0000 (18:00 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 19 Nov 2007 18:00:48 +0000 (18:00 +0000)
- error fix: overall weight group value was used inverted
- added "Inv" button to make weight group work inverted
- added bigger, more clear Multi Modifier button

source/blender/blenkernel/intern/armature.c
source/blender/makesdna/DNA_armature_types.h
source/blender/src/buttons_editing.c

index 477ee98213861d7f329314a73bbd952f6a9aeec2..9450e32806f602ec1d5c0674222bb227292c5e98 100644 (file)
@@ -801,6 +801,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
        int use_envelope = deformflag & ARM_DEF_ENVELOPE;
        int use_quaternion = deformflag & ARM_DEF_QUATERNION;
        int bbone_rest_def = deformflag & ARM_DEF_B_BONE_REST;
+       int invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP;
        int numGroups = 0;              /* safety for vertexgroup index overflow */
        int i, target_totvert = 0;      /* safety for vertexgroup overflow */
        int use_dverts = 0;
@@ -921,7 +922,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
                        }
                        /* hackish: the blending factor can be used for blending with prevCos too */
                        if(prevCos) {
-                               prevco_weight= armature_weight;
+                               if(invert_vgroup)
+                                       prevco_weight= 1.0f-armature_weight;
+                               else
+                                       prevco_weight= armature_weight;
                                armature_weight= 1.0f;
                        }
                }
@@ -1018,11 +1022,11 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
                
                
                /* interpolate with previous modifier position using weight group */
-               if(prevCos && prevco_weight!=1.0f) {
+               if(prevCos) {
                        float mw= 1.0f - prevco_weight;
-                       vertexCos[i][0]= mw*vertexCos[i][0] + prevco_weight*co[0];
-                       vertexCos[i][1]= mw*vertexCos[i][1] + prevco_weight*co[1];
-                       vertexCos[i][2]= mw*vertexCos[i][2] + prevco_weight*co[2];
+                       vertexCos[i][0]= prevco_weight*vertexCos[i][0] + mw*co[0];
+                       vertexCos[i][1]= prevco_weight*vertexCos[i][1] + mw*co[1];
+                       vertexCos[i][2]= prevco_weight*vertexCos[i][2] + mw*co[2];
                }
        }
 
index 82d120533d6da6ee04e4e762d42ef1ca748640fb..f5eacede809d7e7efa198f540afd4e2943c945a8 100644 (file)
@@ -112,10 +112,11 @@ typedef struct bArmature {
 #define                ARM_ENVELOPE    3
 
 /* armature->deformflag */
-#define                ARM_DEF_VGROUP          1
-#define                ARM_DEF_ENVELOPE        2
-#define                ARM_DEF_QUATERNION      4
-#define                ARM_DEF_B_BONE_REST     8
+#define                ARM_DEF_VGROUP                  1
+#define                ARM_DEF_ENVELOPE                2
+#define                ARM_DEF_QUATERNION              4
+#define                ARM_DEF_B_BONE_REST             8
+#define                ARM_DEF_INVERT_VGROUP   16
 
 /* armature->pathflag */
 #define                ARM_PATH_FNUMS          (1<<0)
index 9dcd7f9921b31ce5324764e70035a822ec1eea81..b1d13d86f38ea7411d4d758c189cbfa558705b54 100644 (file)
@@ -1632,7 +1632,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
                        if(wmd->flag & MOD_WAVE_NORM)
                                height += 19;
                } else if (md->type==eModifierType_Armature) {
-                       height = 86;
+                       height = 105;
                } else if (md->type==eModifierType_Hook) {
                        HookModifierData *hmd = (HookModifierData*) md;
                        height = 86;
@@ -1959,12 +1959,15 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
                        
                        but=uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ",                           lx, (cy-=19), buttonWidth-40,19, &amd->defgrp_name, 0.0, 31.0, 0, 0, "Vertex Group name to control overall armature influence");
                        uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ob);
-                       uiDefButS(block, TOG, B_ARM_RECALCDATA, "MM",   lx+buttonWidth-40,cy, 40, 20, &amd->multi, 0, 0, 0, 0, "MultiModifier: This modifier uses same input as previous modifier, and mixes using this vgroup");
+                       uiDefButBitS(block, TOG, ARM_DEF_INVERT_VGROUP, B_ARM_RECALCDATA, "Inv",        lx+buttonWidth-40,cy, 40, 20, &amd->deformflag, 0, 0, 0, 0, "Invert vertex group influence");
                        
                        uiDefButBitS(block, TOG, ARM_DEF_VGROUP, B_ARM_RECALCDATA, "Vert.Groups",       lx,cy-=19,buttonWidth/2,20, &amd->deformflag, 0, 0, 0, 0, "Enable VertexGroups defining deform");
                        uiDefButBitS(block, TOG, ARM_DEF_ENVELOPE, B_ARM_RECALCDATA, "Envelopes",       lx+buttonWidth/2,cy,(buttonWidth + 1)/2,20, &amd->deformflag, 0, 0, 0, 0, "Enable Bone Envelopes defining deform");
                        uiDefButBitS(block, TOG, ARM_DEF_QUATERNION, B_ARM_RECALCDATA, "Quaternion",    lx,(cy-=19),buttonWidth/2,20, &amd->deformflag, 0, 0, 0, 0, "Enable deform rotation interpolation with Quaternions");
                        uiDefButBitS(block, TOG, ARM_DEF_B_BONE_REST, B_ARM_RECALCDATA, "B-Bone Rest", lx+buttonWidth/2,cy,(buttonWidth + 1)/2,20, &amd->deformflag, 0, 0, 0, 0, "Make B-Bones deform already in rest position");
+                       
+                       uiDefButS(block, TOG, B_ARM_RECALCDATA, "MultiModifier",        lx,cy-=19, buttonWidth, 20, &amd->multi, 0, 0, 0, 0, "Use same input as previous modifier, and mix results using overall vgroup");
+
                } else if (md->type==eModifierType_Hook) {
                        HookModifierData *hmd = (HookModifierData*) md;
                        uiDefButF(block, NUM, B_MODIFIER_RECALC, "Falloff: ",           lx, (cy-=19), buttonWidth,19, &hmd->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends");