Animato - Bugfixes for ShapeKeys + ShapeKey Drivers
authorJoshua Leung <aligorith@gmail.com>
Sun, 2 Aug 2009 06:10:24 +0000 (06:10 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 2 Aug 2009 06:10:24 +0000 (06:10 +0000)
* Animated ShapeKey F-Curves/Drivers are now visible in the Animation Editors.

* As a result of this, the old 'ShapeKeys' mode (which would display all the shapekey channels, even if they had no keyframes yet) in the DopeSheet, no longer works for now. However, it would have been of no use as no sliders were shown anyway.

* Drivers which depended on the rotation of bones now work again. These now point to the right RNA properties, and get some extra 'time' corrections (for degrees -> radians change).

source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/key.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/space_graph/space_graph.c

index ebd94b94f8c777771a37f628f707ca78443cca28..90bf08059d766aabd5d81bcce9a67f71846d423f 100644 (file)
@@ -722,6 +722,8 @@ float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar)
                                break;
                }
        }
+       else if (G.f & G_DEBUG)
+               printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, path);
        
        return value;
 }
index cf7e486613bc8a5e4cda3150d4b76add3f932605..a72f26f6157a534f7614deded385d9f79c324695 100644 (file)
@@ -296,8 +296,8 @@ static char *pchan_adrcodes_to_paths (int adrcode, int *array_index)
                case AC_EUL_Z:
                        *array_index= 2; return "euler_rotation";
                        
-               case -1: // XXX special case for rotation drivers... until eulers are added...
-                       *array_index= 0; return "rotation";
+               case -1: /* special case for euler-rotations used by old drivers */
+                       *array_index= 0; return "euler_rotation";
                        
                case AC_LOC_X:
                        *array_index= 0; return "location";
@@ -1023,12 +1023,11 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
                                                dtar->rna_path= get_rna_access(ID_PO, AC_SIZE_Z, idriver->name, NULL, &dtar->array_index);
                                                break;  
                                                
-                                       case OB_ROT_X:  /* rotation - we need to be careful with this... XXX (another reason why we need eulers) */     
+                                       case OB_ROT_X:  /* rotation - we need to be careful with this... */     
                                        case OB_ROT_Y:
                                        case OB_ROT_Z:
                                        {
-                                               // XXX this is not yet a 1:1 map, since we'd need euler rotations to make this work nicely (unless we make some hacks)
-                                               // XXX -1 here is a special hack...
+                                               /* -1 here, not rotation code, since old system didn't have eulers */
                                                dtar->rna_path= get_rna_access(ID_PO, -1, idriver->name, NULL, NULL);
                                                dtar->array_index= idriver->adrcode - OB_ROT_X;
                                        }
@@ -1276,6 +1275,26 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha
                                        dst->vec[1][1] *= fac;
                                        dst->vec[2][1] *= fac;
                                }
+                               
+                               /* correct times for rotation drivers 
+                                *      - need to go from degrees to radians...
+                                *      - there's only really 1 target to worry about 
+                                */
+                               if (fcu->driver && fcu->driver->targets.first) {
+                                       DriverTarget *dtar= fcu->driver->targets.first;
+                                       
+                                       /* since drivers could only be for objects, we should just check for 'rotation' being 
+                                        * in the name of the path given
+                                        *      - WARNING: this will break if we encounter a bone or object explictly named in that way...
+                                        */
+                                       if ((dtar && dtar->rna_path) && strstr(dtar->rna_path, "rotation")) {
+                                               const float fac= (float)M_PI / 180.0f;
+                                               
+                                               dst->vec[0][0] *= fac;
+                                               dst->vec[1][0] *= fac;
+                                               dst->vec[2][0] *= fac;
+                                       }
+                               }
                        }
                        
                        /* free this data now */
index 595ba37e09c1037d3b2d3a22299f9b14760ef9c1..a2fa97cabc907de64116dcee64112c6a129dc136 100644 (file)
@@ -1382,18 +1382,11 @@ int do_ob_key(Scene *scene, Object *ob)
                return 1;
        }
        else {
-#if 0 // XXX old animation system
-               // NOTE: this stuff was NEVER reliable at all...
-               if(ob->ipoflag & OB_ACTION_KEY)
-                       do_all_object_actions(scene, ob);
-               else {
-                       calc_ipo(key->ipo, bsystem_time(scene, ob, scene->r.cfra, 0.0));
-                       execute_ipo((ID *)key, key->ipo);
-               }
-#endif // XXX old animation system
                /* do shapekey local drivers */
                float ctime= (float)scene->r.cfra; // XXX this needs to be checked
-               if (G.f & G_DEBUG) printf("ob %s - do shapekey (%s) drivers \n", ob->id.name+2, key->id.name+2);
+               
+               if (G.f & G_DEBUG) 
+                       printf("ob %s - do shapekey (%s) drivers \n", ob->id.name+2, key->id.name+2);
                BKE_animsys_evaluate_animdata(&key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
                
                if(ob->type==OB_MESH) return do_mesh_key(scene, ob, ob->data);
index 5970cf481ac2d9bb64e0387de5a42ace4294b127..4e479bd75d0941ecda5fcc687fe1a113fd05174c 100644 (file)
@@ -856,71 +856,6 @@ static int animdata_filter_nla (ListBase *anim_data, AnimData *adt, int filter_m
        /* return the number of items added to the list */
        return items;
 }
-
-static int animdata_filter_shapekey (ListBase *anim_data, Key *key, int filter_mode, void *owner, short ownertype, ID *owner_id)
-{
-       bAnimListElem *ale;
-       KeyBlock *kb;
-       //FCurve *fcu;
-       int i, items=0;
-       
-       /* are we filtering for display or editing */
-       if (filter_mode & ANIMFILTER_CHANNELS) {
-               /* for display - loop over shapekeys, adding ipo-curve references where needed */
-               kb= key->block.first;
-               
-               /* loop through possible shapekeys, manually creating entries */
-               for (i= 1; i < key->totkey; i++) {
-                       ale= MEM_callocN(sizeof(bAnimListElem), "bAnimListElem");
-                       kb = kb->next; /* do this even on the first try, as the first is 'Basis' (which doesn't get included) */
-                       
-                       ale->data= kb;
-                       ale->type= ANIMTYPE_SHAPEKEY; /* 'abused' usage of this type */
-                       ale->owner= key;
-                       ale->ownertype= ANIMTYPE_SHAPEKEY;
-                       ale->datatype= ALE_NONE;
-                       ale->index = i;
-                       
-#if 0 // XXX fixme... old system
-                       if (key->ipo) {
-                               for (icu= key->ipo->curve.first; icu; icu=icu->next) {
-                                       if (icu->adrcode == i) {
-                                               ale->key_data= icu;
-                                               ale->datatype= ALE_ICU;
-                                               break;
-                                       }
-                               }
-                       }
-#endif // XXX fixme... old system
-                       
-                       ale->id= owner_id;
-                       
-                       BLI_addtail(anim_data, ale);
-                       items++;
-               }
-       }
-       else {
-#if 0 // XXX fixme... old system
-               /* loop over ipo curves if present - for editing */
-               if (key->ipo) {
-                       if (filter_mode & ANIMFILTER_IPOKEYS) {
-                               ale= make_new_animlistelem(key->ipo, ANIMTYPE_IPO, key, ANIMTYPE_SHAPEKEY);
-                               if (ale) {
-                                       if (owned) ale->id= owner;
-                                       BLI_addtail(anim_data, ale);
-                                       items++;
-                               }
-                       }
-                       else {
-                               items += animdata_filter_ipocurves(anim_data, key->ipo, filter_mode, key, ANIMTYPE_SHAPEKEY, (owned)?(owner):(NULL));
-                       }
-               }
-#endif // XXX fixme... old system
-       }
-       
-       /* return the number of items added to the list */
-       return items;
-}
  
 #if 0
 // FIXME: switch this to use the bDopeSheet...
@@ -1272,7 +1207,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                                
                                /* add channels */
                                if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+                                       items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, key, ANIMTYPE_DSSKEY, filter_mode, (ID *)key);
                                }
                        },
                        { /* action (keyframes) */
@@ -1287,7 +1222,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                                
                                /* add channels */
                                if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+                                       items += animdata_filter_action(anim_data, adt->action, filter_mode, key, ANIMTYPE_DSSKEY, (ID *)key); 
                                }
                        }
                );
@@ -1792,7 +1727,7 @@ int ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_mode
                                break;
                                
                        case ANIMCONT_SHAPEKEY:
-                               items= animdata_filter_shapekey(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE, (ID *)obact);
+                               //items= animdata_filter_shapekey(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE, (ID *)obact);
                                break;
                                
                        case ANIMCONT_GPENCIL:
index 222f2142c38013aadc78e59ec614d664ae337bce..0390586951b035f7451ec6d4324e907208790583 100644 (file)
@@ -69,20 +69,20 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
        ARegion *ar, *arnew;
        
        for (ar= sa->regionbase.first; ar; ar= ar->next) {
-               if(ar->regiontype==RGN_TYPE_UI)
+               if (ar->regiontype==RGN_TYPE_UI)
                        return ar;
        }
        
-       /* add subdiv level; after main window */
+       /* add subdiv level; after main */
        for (ar= sa->regionbase.first; ar; ar= ar->next) {
-               if(ar->regiontype==RGN_TYPE_WINDOW)
+               if (ar->regiontype==RGN_TYPE_WINDOW)
                        break;
        }
        
        /* is error! */
-       if(ar==NULL) return NULL;
+       if (ar==NULL) return NULL;
        
-       arnew= MEM_callocN(sizeof(ARegion), "buttons for nla");
+       arnew= MEM_callocN(sizeof(ARegion), "buttons for graph");
        
        BLI_insertlinkafter(&sa->regionbase, ar, arnew);
        arnew->regiontype= RGN_TYPE_UI;