Another feature request from the animation dept:
authorTon Roosendaal <ton@blender.org>
Tue, 20 Nov 2007 16:58:25 +0000 (16:58 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 20 Nov 2007 16:58:25 +0000 (16:58 +0000)
Relative shapekeys now allow to define the Shape it is relative to!
(It used to be relative with respect to the first key, which is still
default).

The reason for this feature is that keys don't always add together
well when they're all derived from the same base shape. A clear
example is hard to make... will wait for someone posting it. :)

source/blender/blenkernel/intern/key.c
source/blender/makesdna/DNA_key_types.h
source/blender/src/buttons_editing.c

index 8da3ea0b994d1d12620fa9c83c45a762844687bf..234a096edce5e4299c1f7bd3bc0d757951c6e6c1 100644 (file)
@@ -680,11 +680,15 @@ static void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, i
                        
                        /* only with value, and no difference allowed */
                        if(icuval!=0.0f && kb->totelem==tot) {
+                               KeyBlock *refb;
                                float weight, *weights= kb->weights;
                                
                                poin= basispoin;
-                               reffrom= key->refkey->data;
                                from= kb->data;
+                               /* reference now can be any block */
+                               refb= BLI_findlink(&key->block, kb->relative);
+                               if(refb==NULL) continue;
+                               reffrom= refb->data;
                                
                                poin+= start*ofs[0];
                                reffrom+= key->elemsize*start;  // key elemsize yes!
index 3292e07f80ec7d8a7d241920a86310b077b9854e..785cf515a4272bb885f09f396a753bf2a431c549 100644 (file)
@@ -44,8 +44,8 @@ typedef struct KeyBlock {
        
        float pos;
        float curval;
-       short type, adrcode;
-       int totelem;
+       short type, adrcode, relative, pad1;    /* relative == 0 means first key is reference */
+       int totelem, pad2;
        
        void *data;
        float *weights;
index b1d13d86f38ea7411d4d758c189cbfa558705b54..082353f11742a7e00d8a37667b1d309fca95b8b1 100644 (file)
@@ -2217,7 +2217,7 @@ static void editing_panel_modifiers(Object *ob)
        if(yco < 0) uiNewPanelHeight(block, 204-yco);
 }
 
-static char *make_key_menu(Key *key)
+static char *make_key_menu(Key *key, int startindex)
 {
        KeyBlock *kb;
        int index= 1;
@@ -2227,7 +2227,7 @@ static char *make_key_menu(Key *key)
        str= MEM_mallocN(index*40, "key string");
        str[0]= 0;
        
-       index= 1;
+       index= startindex;
        for (kb = key->block.first; kb; kb=kb->next, index++) {
                sprintf (item,  "|%s%%x%d", kb->name, index);
                strcat(str, item);
@@ -2273,9 +2273,10 @@ static void editing_panel_shapes(Object *ob)
        uiDefIconButBitS(block, TOG, OB_SHAPE_LOCK, B_LOCKKEY, icon, 10,150,25,20, &ob->shapeflag, 0, 0, 0, 0, "Always show the current Shape for this Object");
        uiSetButLock(G.obedit==ob, "Unable to perform in EditMode");
        uiDefIconBut(block, BUT, B_PREVKEY, ICON_TRIA_LEFT,             35,150,20,20, NULL, 0, 0, 0, 0, "Previous Shape Key");
-       strp= make_key_menu(key);
-       uiDefButS(block, MENU, B_SETKEY, strp,                                  55,150,20,20, &ob->shapenr, 0, 0, 0, 0, "Browses existing choices or adds NEW");
+       strp= make_key_menu(key, 1);
+       uiDefButS(block, MENU, B_SETKEY, strp,                                  55,150,20,20, &ob->shapenr, 0, 0, 0, 0, "Browse existing choices");
        MEM_freeN(strp);
+       
        uiDefIconBut(block, BUT, B_NEXTKEY, ICON_TRIA_RIGHT,    75,150,20,20, NULL, 0, 0, 0, 0, "Next Shape Key");
        uiClearButLock();
        uiDefBut(block, TEX, B_NAMEKEY, "",                                             95, 150, 190, 20, kb->name, 0.0, 31.0, 0, 0, "Current Shape Key name");
@@ -2289,9 +2290,14 @@ static void editing_panel_shapes(Object *ob)
                uiDefButF(block, NUM, B_REDR, "Max ",                           235,120, 75, 20, &kb->slidermax, -10.0, 10.0, 100, 1, "Maximum for slider");
                uiBlockEndAlign(block);
        }
-       if(key->type && ob->shapenr!=1)
+       if(key->type && ob->shapenr!=1) {
                uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ",     10, 90, 150,19, &kb->vgroup, 0.0, 31.0, 0, 0, "Vertex Weight Group name, to blend with Basis Shape");
 
+               strp= make_key_menu(key, 0);
+               uiDefButS(block, MENU, B_MODIFIER_RECALC, strp,         160, 90, 150,19, &kb->relative, 0.0, 0.0, 0, 0, "Shape used as a relative key");
+               MEM_freeN(strp);
+       }
+       
        if(key->type==0)
                uiDefButS(block, NUM, B_DIFF, "Slurph:",                        10, 60, 150, 19, &(key->slurph), -500.0, 500.0, 0, 0, "Creates a delay in amount of frames in applying keypositions, first vertex goes first");