Animato - More work on Action Editor
authorJoshua Leung <aligorith@gmail.com>
Tue, 20 Jan 2009 11:56:45 +0000 (11:56 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 20 Jan 2009 11:56:45 +0000 (11:56 +0000)
* Added back Auto Preview-Range tool (i.e. set preview-range from keyframe extents)

* Restored delete keyframe tool. For now, this doesn't delete empty F-Curves, even though its keyframe-api counterpart still does. I still need to figure out how to do this in the best way.

* Fixed crashes when selecting keyframes in 'object' summary channels

* Removed prototypes for a few unused/depreceated functions...

source/blender/blenkernel/BKE_fcurve.h
source/blender/blenkernel/intern/fcurve.c
source/blender/editors/animation/keyframes_general.c
source/blender/editors/include/ED_keyframes_edit.h
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_select.c

index 7a71168684e7bd8ea7c389551a613ab47e55e9dd..8732d63f0472f7e240abba8e74ae61da8d43fa86 100644 (file)
@@ -85,6 +85,9 @@ void copy_fcurves(ListBase *dst, ListBase *src);
 /* find matching F-Curve in the given list of F-Curves */
 struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index);
 
+/* get the time extents for F-Curve */
+void calc_fcurve_range(struct FCurve *fcu, float *min, float *max);
+
 /* -------- Curve Sanity --------  */
 
 void calchandles_fcurve(struct FCurve *fcu);
index a7d375cb9552a2698a18501e3719838b8f51d1ba..f547b483092346bcc241f366dd738a5fec3f3d4a 100644 (file)
@@ -169,6 +169,37 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array
        return NULL;
 }
 
+/* Calculate the extents of F-Curve's keyframes */
+void calc_fcurve_range (FCurve *fcu, float *start, float *end)
+{
+       float min=999999999.0f, max=-999999999.0f;
+       short foundvert=0;
+
+       if (fcu->totvert) {
+               if (fcu->bezt) {
+                       min= MIN2(min, fcu->bezt[0].vec[1][0]);
+                       max= MAX2(max, fcu->bezt[fcu->totvert-1].vec[1][0]);
+               }
+               else if (fcu->fpt) {
+                       min= MIN2(min, fcu->fpt[0].vec[0]);
+                       max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]);
+               }
+               
+               foundvert=1;
+       }
+       
+       /* minimum length is 1 frame */
+       if (foundvert) {
+               if (min == max) max += 1.0f;
+               *start= min;
+               *end= max;
+       }
+       else {
+               *start= 0.0f;
+               *end= 1.0f;
+       }
+}
+
 /* ***************************** Keyframe Column Tools ********************************* */
 
 /* add a BezTriple to a column */
index 8ff65a2a00895f16efaeee047945a18aedf98707..11397a1d60b4dca7c87bfab7bc457f8a7f270b11 100644 (file)
@@ -89,73 +89,62 @@ void delete_fcurve_key(FCurve *fcu, int index, short do_recalc)
                calchandles_fcurve(fcu);
 }
 
-#if 0 // XXX obsolete
-/* Delete selected keyframes in given IPO block */
-void delete_ipo_keys(Ipo *ipo)
+/* Delete selected keyframes in given F-Curve */
+void delete_fcurve_keys(FCurve *fcu)
 {
-       IpoCurve *icu, *next;
        int i;
        
-       if (ipo == NULL)
-               return;
-       
-       for (icu= ipo->curve.first; icu; icu= next) {
-               /* store pointer to next ipo-curve, as we may delete the current one */
-               next = icu->next;
-               
-               /* Delete selected BezTriples */
-               for (i=0; i<icu->totvert; i++) {
-                       if (icu->bezt[i].f2 & SELECT) {
-                               memmove(&icu->bezt[i], &icu->bezt[i+1], sizeof(BezTriple)*(icu->totvert-i-1));
-                               icu->totvert--;
-                               i--;
-                       }
-               }
-               
-               /* Only delete if there isn't an ipo-driver still hanging around on an empty curve */
-               if ((icu->totvert==0) && (icu->driver==NULL)) {
-                       BLI_remlink(&ipo->curve, icu);
-                       free_ipo_curve(icu);
+       /* Delete selected BezTriples */
+       for (i=0; i < fcu->totvert; i++) {
+               if (fcu->bezt[i].f2 & SELECT) {
+                       memmove(&fcu->bezt[i], &fcu->bezt[i+1], sizeof(BezTriple)*(fcu->totvert-i-1));
+                       fcu->totvert--;
+                       i--;
                }
        }
+       
+#if 0 // XXX for now, we don't get rid of empty curves...
+       /* Only delete if there isn't an ipo-driver still hanging around on an empty curve */
+       if ((icu->totvert==0) && (icu->driver==NULL)) {
+               BLI_remlink(&ipo->curve, icu);
+               free_ipo_curve(icu);
+       }
+#endif 
 }
-#endif // XXX obsolete
 
 /* ---------------- */
 
-/* duplicate selected keyframes for the given IPO block */
-void duplicate_ipo_keys(Ipo *ipo)
+/* duplicate selected keyframes for the given F-Curve */
+void duplicate_fcurve_keys(FCurve *fcu)
 {
-       IpoCurve *icu;
        BezTriple *newbezt;
        int i;
 
-       if (ipo == NULL)
+       if (fcu == NULL)
                return;
-
-       for (icu= ipo->curve.first; icu; icu= icu->next) {
-               for (i=0; i<icu->totvert; i++) {
-                       /* If a key is selected */
-                       if (icu->bezt[i].f2 & SELECT) {
-                               /* Expand the list */
-                               newbezt = MEM_callocN(sizeof(BezTriple) * (icu->totvert+1), "beztriple");
-                               
-                               memcpy(newbezt, icu->bezt, sizeof(BezTriple) * (i+1));
-                               memcpy(newbezt+i+1, icu->bezt+i, sizeof(BezTriple));
-                               memcpy(newbezt+i+2, icu->bezt+i+1, sizeof (BezTriple) *(icu->totvert-(i+1)));
-                               icu->totvert++;
-                               
-                               /* reassign pointers... (free old, and add new) */
-                               MEM_freeN(icu->bezt);
-                               icu->bezt=newbezt;
-                               
-                               /* Unselect the current key*/
-                               BEZ_DESEL(&icu->bezt[i]);
-                               i++;
-                               
-                               /* Select the copied key */
-                               BEZ_SEL(&icu->bezt[i]);
-                       }
+       
+       // XXX this does not take into account sample data...
+       for (i=0; i < fcu->totvert; i++) {
+               /* If a key is selected */
+               if (fcu->bezt[i].f2 & SELECT) {
+                       /* Expand the list */
+                       newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert+1), "beztriple");
+                       
+                       memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i+1));
+                       memcpy(newbezt+i+1, fcu->bezt+i, sizeof(BezTriple));
+                       memcpy(newbezt+i+2, fcu->bezt+i+1, sizeof (BezTriple) *(fcu->totvert-(i+1)));
+                       fcu->totvert++;
+                       
+                       /* reassign pointers... (free old, and add new) */
+                       MEM_freeN(fcu->bezt);
+                       fcu->bezt=newbezt;
+                       
+                       /* Unselect the current key */
+                       BEZ_DESEL(&fcu->bezt[i]);
+                       i++;
+                       
+                       /* Select the copied key */
+                       BEZ_SEL(&fcu->bezt[i]);
                }
        }
 }
index cac32b18036c17e68056271873afb62b3bc9dea5..8fd5a0152c9dcdfe6d81f1ca2c9cb74d62d83731 100644 (file)
@@ -126,21 +126,11 @@ BeztEditFunc ANIM_editkeyframes_ipo(short mode);
 
 void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc);
 void delete_fcurve_keys(struct FCurve *fcu);
-void duplicate_ipo_keys(struct Ipo *ipo);
+void duplicate_fcurve_keys(struct FCurve *fcu); // XXX fixme...
 
 void clean_fcurve(struct FCurve *fcu, float thresh);
 void smooth_fcurve(struct FCurve *fcu, short mode);
 
-/* ************************************************ */
-
-// XXX all of these funcs should be depreceated or at least renamed!
-
-/* in keyframes_edit.c */
-short is_ipo_key_selected(struct Ipo *ipo);
-void set_ipo_key_selection(struct Ipo *ipo, short sel);
-
-
-
 /* ************************************************ */
 
 #endif /* ED_KEYFRAMES_EDIT_H */
index 6a7e7d7421edb75231e0016434cb094e1db37fd5..c54ceba67f8e24f486b04e84eb889e840e1f0093 100644 (file)
@@ -109,11 +109,11 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
                /* go through channels, finding max extents */
                for (ale= anim_data.first; ale; ale= ale->next) {
                        Object *nob= ANIM_nla_mapping_get(ac, ale);
-                       //Ipo *ipo= (Ipo *)ale->key_data;  // XXX fixme
+                       FCurve *fcu= (FCurve *)ale->key_data;
                        float tmin, tmax;
                        
                        /* get range and apply necessary scaling before */
-                       //calc_ipo_range(ipo, &tmin, &tmax);
+                       calc_fcurve_range(fcu, &tmin, &tmax);
                        tmin= tmax= 0.0f; // xxx
                        
                        if (nob) {
@@ -608,7 +608,7 @@ static void delete_action_keys (bAnimContext *ac)
                //if (ale->type == ANIMTYPE_GPLAYER)
                //      delete_gplayer_frames((bGPDlayer *)ale->data);
                //else
-               //      delete_ipo_keys((Ipo *)ale->key_data); // XXX fixme for the new animsys...
+                       delete_fcurve_keys((FCurve *)ale->key_data); // XXX... this doesn't delete empty curves anymore
        }
        
        /* free filtered list */
index c4e2d0b972a6faaeb00cf14e4f4d7030130ff36d..9b121bfb2705180f42c1205708aae807c62b009e 100644 (file)
@@ -198,7 +198,7 @@ static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float *selx,
                
                /* figure out what to return */
                if (ac->datatype == ANIMCONT_ACTION) {
-                       *par= ale->owner; /* assume that this is an action channel */
+                       *par= ale->owner; /* assume that this is an action group */
                        *ret_type= ale->type;
                        data = ale->data;
                }
@@ -863,11 +863,11 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode)
                ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
        else if (agrp) {
                for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next)
-                       ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
+                       ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
        }
        else if (act) {
                for (fcu= act->curves.first; fcu; fcu= fcu->next)
-                       ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
+                       ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
        }
        else if (ob) {
                AnimData *adt;
@@ -875,12 +875,13 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode)
                /* Object's own animation */
                if (ob->adt && ob->adt->action) {
                        adt= ob->adt;
+                       act= adt->action;
                        
                        selxa= get_action_frame(ob, selx); // xxx
                        bed.f1= selxa;
                        
                        for (fcu= act->curves.first; fcu; fcu= fcu->next)
-                       ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
+                               ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
                }
                
                /* 'Sub-Object' animation data */