Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-01-20 14:56:45 +0300
committerJoshua Leung <aligorith@gmail.com>2009-01-20 14:56:45 +0300
commit822203e4cf9d3b878662e6d00fc8001c38ccef25 (patch)
tree218d8658c7c216ce7a552d1fc0da8270786e4e96 /source
parentb5904f10a820611e35c77be7d69cf931c19007e3 (diff)
Animato - More work on Action Editor
* 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...
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h3
-rw-r--r--source/blender/blenkernel/intern/fcurve.c31
-rw-r--r--source/blender/editors/animation/keyframes_general.c95
-rw-r--r--source/blender/editors/include/ED_keyframes_edit.h12
-rw-r--r--source/blender/editors/space_action/action_edit.c6
-rw-r--r--source/blender/editors/space_action/action_select.c9
6 files changed, 85 insertions, 71 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 7a71168684e..8732d63f047 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -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);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index a7d375cb955..f547b483092 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -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 */
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 8ff65a2a008..11397a1d60b 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -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]);
}
}
}
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index cac32b18036..8fd5a0152c9 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -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 */
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 6a7e7d7421e..c54ceba67f8 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -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 */
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index c4e2d0b972a..9b121bfb270 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -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 */