diff options
Diffstat (limited to 'source/blender/editors')
25 files changed, 707 insertions, 1099 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index e6b8293071f..2bf433dab46 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -524,7 +524,7 @@ static int animdata_filter_ipocurves (ListBase *anim_data, Ipo *ipo, int filter_ /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_ICU(icu)) { /* only include this curve if selected or we are including all IPO-curves */ - if (!(filter_mode & ANIMFILTER_SEL) || (filter_mode & ANIMFILTER_ONLYICU) || (SEL_ICU(icu))) { + if (!(filter_mode & ANIMFILTER_SEL) || (filter_mode & ANIMFILTER_ONLYFCU) || (SEL_ICU(icu))) { /* owner/ownertype will be either object or action-channel, depending if it was dopesheet or part of an action */ ale= make_new_animlistelem(icu, ANIMTYPE_ICU, owner, ownertype); @@ -556,7 +556,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a /* check if this achan should only be included if it is selected */ if (!(filter_mode & ANIMFILTER_SEL) || SEL_ACHAN(achan)) { /* are we only interested in the ipo-curves? */ - if ((filter_mode & ANIMFILTER_ONLYICU)==0) { + if ((filter_mode & ANIMFILTER_ONLYFCU)==0) { ale= make_new_animlistelem(achan, ANIMTYPE_ACHAN, achan, ANIMTYPE_ACHAN); if (ale) { @@ -572,7 +572,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a } /* check if expanded - if not, continue on to next animion channel */ - if (EXPANDED_ACHAN(achan) == 0 && (filter_mode & ANIMFILTER_ONLYICU)==0) { + if (EXPANDED_ACHAN(achan) == 0 && (filter_mode & ANIMFILTER_ONLYFCU)==0) { /* only exit if we don't need to include constraint channels for group-channel keyframes */ if ( !(filter_mode & ANIMFILTER_IPOKEYS) || (achan->grp == NULL) || (EXPANDED_AGRP(achan->grp)==0) ) return items; @@ -581,7 +581,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a /* ipo channels */ if ((achan->ipo) && (filter_mode & ANIMFILTER_IPOKEYS)==0) { /* include ipo-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && (filter_mode & ANIMFILTER_ONLYICU)==0) { + if ((filter_mode & ANIMFILTER_CHANNELS) && (filter_mode & ANIMFILTER_ONLYFCU)==0) { ale= make_new_animlistelem(achan, ANIMTYPE_FILLIPO, achan, ANIMTYPE_ACHAN); if (ale) { @@ -592,7 +592,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a } /* add ipo-curve channels? */ - if (FILTER_IPO_ACHAN(achan) || (filter_mode & ANIMFILTER_ONLYICU)) { + if (FILTER_IPO_ACHAN(achan) || (filter_mode & ANIMFILTER_ONLYFCU)) { /* loop through ipo-curve channels, adding them */ items += animdata_filter_ipocurves(anim_data, achan->ipo, filter_mode, achan, ANIMTYPE_ACHAN, (owned)?(owner):(NULL)); } @@ -601,7 +601,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a /* constraint channels */ if (achan->constraintChannels.first) { /* include constraint-expand widget? */ - if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYICU) + if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYFCU) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { ale= make_new_animlistelem(achan, ANIMTYPE_FILLCON, achan, ANIMTYPE_ACHAN); @@ -614,7 +614,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a } /* add constraint channels? */ - if (FILTER_CON_ACHAN(achan) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) { + if (FILTER_CON_ACHAN(achan) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) { /* loop through constraint channels, checking and adding them */ for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next) { /* only work with this channel and its subchannels if it is editable */ @@ -662,7 +662,7 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter /* loop over groups */ for (agrp= act->groups.first; agrp; agrp= agrp->next) { /* add this group as a channel first */ - if (!(filter_mode & ANIMFILTER_ONLYICU) && !(filter_mode & ANIMFILTER_IPOKEYS)) { + if (!(filter_mode & ANIMFILTER_ONLYFCU) && !(filter_mode & ANIMFILTER_IPOKEYS)) { /* check if filtering by selection */ if ( !(filter_mode & ANIMFILTER_SEL) || SEL_AGRP(agrp) ) { ale= make_new_animlistelem(agrp, ANIMTYPE_GROUP, NULL, ANIMTYPE_NONE); @@ -691,7 +691,7 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter * - we're interested in keyframes, but not if they appear in selected channels */ if ( (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_AGRP(agrp)) || - ( ((filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) && + ( ((filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) && (!(filter_mode & ANIMFILTER_SEL) || (SEL_AGRP(agrp))) ) ) { if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) { @@ -798,7 +798,7 @@ static int animdata_filter_gpencil (ListBase *anim_data, bScreen *sc, int filter int items = 0; /* check if filtering types are appropriate */ - if ( !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU|ANIMFILTER_ACTGROUPED)) ) + if ( !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU|ANIMFILTER_ACTGROUPED)) ) { /* special hack for fullscreen area (which must be this one then): * - we use the curarea->full as screen to get spaces from, since the @@ -859,7 +859,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads, int items = 0; /* include materials-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU))) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU))) { ale= make_new_animlistelem(ob, ANIMTYPE_FILLMATD, base, ANIMTYPE_OBJECT); if (ale) { BLI_addtail(anim_data, ale); @@ -868,7 +868,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads, } /* add materials? */ - if (FILTER_MAT_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) { + if (FILTER_MAT_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) { short a; /* for each material, either add channels separately, or as ipo-block */ @@ -889,7 +889,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads, } /* add material's ipo-curve channels? */ - if ( (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_ONLYICU)) && + if ( (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_ONLYFCU)) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { items += animdata_filter_ipocurves(anim_data, ma->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ma); @@ -919,7 +919,7 @@ static int animdata_filter_dopesheet_cam (ListBase *anim_data, bDopeSheet *ads, } /* add camera ipo-curve channels? */ - if ( (FILTER_CAM_OBJD(ca) || (filter_mode & ANIMFILTER_ONLYICU)) && + if ( (FILTER_CAM_OBJD(ca) || (filter_mode & ANIMFILTER_ONLYFCU)) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { items += animdata_filter_ipocurves(anim_data, ca->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ca); @@ -946,7 +946,7 @@ static int animdata_filter_dopesheet_lamp (ListBase *anim_data, bDopeSheet *ads, } /* add lamp ipo-curve channels? */ - if ( (FILTER_LAM_OBJD(la) || (filter_mode & ANIMFILTER_ONLYICU)) && + if ( (FILTER_LAM_OBJD(la) || (filter_mode & ANIMFILTER_ONLYFCU)) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { items += animdata_filter_ipocurves(anim_data, la->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)la); @@ -973,7 +973,7 @@ static int animdata_filter_dopesheet_curve (ListBase *anim_data, bDopeSheet *ads } /* add curve ipo-curve channels? */ - if ( (FILTER_CUR_OBJD(cu) || (filter_mode & ANIMFILTER_ONLYICU)) && + if ( (FILTER_CUR_OBJD(cu) || (filter_mode & ANIMFILTER_ONLYFCU)) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { items += animdata_filter_ipocurves(anim_data, cu->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)cu); @@ -992,7 +992,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B int items = 0; /* add this object as a channel first */ - if (!(filter_mode & ANIMFILTER_ONLYICU) && !(filter_mode & ANIMFILTER_IPOKEYS)) { + if (!(filter_mode & ANIMFILTER_ONLYFCU) && !(filter_mode & ANIMFILTER_IPOKEYS)) { /* check if filtering by selection */ if ( !(filter_mode & ANIMFILTER_SEL) || ((base->flag & SELECT) || (base == sce->basact)) ) { ale= make_new_animlistelem(base, ANIMTYPE_OBJECT, NULL, ANIMTYPE_NONE); @@ -1004,7 +1004,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B } /* if collapsed, don't go any further (unless adding keyframes only) */ - if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU)) ) + if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU)) ) return items; /* IPO? */ @@ -1019,7 +1019,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B } /* add ipo-curve channels? */ - if ( (FILTER_IPO_OBJC(ob) || (filter_mode & ANIMFILTER_ONLYICU)) && + if ( (FILTER_IPO_OBJC(ob) || (filter_mode & ANIMFILTER_ONLYFCU)) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { items += animdata_filter_ipocurves(anim_data, ob->ipo, filter_mode, base, ANIMTYPE_OBJECT, NULL); // err... why not set ob? @@ -1029,7 +1029,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B /* Action? */ if ((ob->action) && !(ads->filterflag & ADS_FILTER_NOACTS)) { /* include animion-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU))) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU))) { ale= make_new_animlistelem(ob->action, ANIMTYPE_FILLACTD, base, ANIMTYPE_OBJECT); if (ale) { ale->id= (ID *)ob; // err.... is this a good idea? @@ -1048,7 +1048,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B /* ShapeKeys? */ if ((key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) { /* include shapekey-expand widget? */ - if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU))) { + if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU))) { ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT); if (ale) { BLI_addtail(anim_data, ale); @@ -1057,7 +1057,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B } /* add channels */ - if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) { + if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) { items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT); } } @@ -1096,7 +1096,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B bConstraintChannel *conchan; /* include constraint-expand widget? */ - if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYICU) + if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYFCU) && !(filter_mode & ANIMFILTER_IPOKEYS) ) { ale= make_new_animlistelem(ob, ANIMTYPE_FILLCOND, base, ANIMTYPE_OBJECT); @@ -1107,7 +1107,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B } /* add constraint channels? */ - if (FILTER_CON_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) { + if (FILTER_CON_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) { /* loop through constraint channels, checking and adding them */ for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next) { /* only work with this channel and its subchannels if it is editable */ diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 503e083d061..8ef7eedb4c0 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -52,6 +52,7 @@ #include "WM_types.h" #include "ED_anim_api.h" +#include "ED_keyframing.h" // XXX remove? #include "ED_markers.h" #include "ED_screen.h" @@ -359,6 +360,10 @@ void ED_operatortypes_anim(void) WM_operatortype_append(ANIM_OT_previewrange_define); WM_operatortype_append(ANIM_OT_previewrange_clear); + + // XXX this is used all over... maybe for screen instead? + WM_operatortype_append(ANIM_OT_insert_keyframe); + WM_operatortype_append(ANIM_OT_delete_keyframe); } void ED_keymap_anim(wmWindowManager *wm) diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 6f1f454b907..b38cbde7410 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -34,17 +34,18 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" -#include "DNA_ipo_types.h" +#include "DNA_ipo_types.h" // XXX to be phased out #include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BKE_key.h" #include "BKE_utildefines.h" @@ -218,16 +219,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) int filter; /* filter animation data */ - filter= ANIMFILTER_ONLYICU; + filter= ANIMFILTER_ONLYFCU; ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); /* loop over ipo-curves that are likely to have been edited, and check them */ for (ale= anim_data.first; ale; ale= ale->next) { - IpoCurve *icu= ale->key_data; + FCurve *fcu= ale->key_data; /* make sure keyframes in IPO-curve are all in order, and handles are in valid positions */ - sort_time_ipocurve(icu); - testhandles_ipocurve(icu); + sort_time_fcurve(fcu); + testhandles_fcurve(fcu); } /* free temp data */ @@ -404,56 +405,6 @@ BeztEditFunc ANIM_editkeyframes_mirror(short type) } } -/* --------- */ - -/* This function is called to calculate the average location of the - * selected keyframes, and place the current frame at that location. - * - * It must be called like so: - * snap_cfra_ipo_keys(scene, NULL, -1); // initialise the static vars first - * for (ipo...) snap_cfra_ipo_keys(scene, ipo, 0); // sum up keyframe times - * snap_cfra_ipo_keys(scene, NULL, 1); // set current frame after taking average - */ -// XXX this thing needs to be refactored! -void snap_cfra_ipo_keys(BeztEditData *bed, Ipo *ipo, short mode) -{ - static int cfra; - static int tot; - - Scene *scene= bed->scene; - IpoCurve *icu; - BezTriple *bezt; - int a; - - - if (mode == -1) { - /* initialise a new snap-operation */ - cfra= 0; - tot= 0; - } - else if (mode == 1) { - /* set current frame - using average frame */ - if (tot != 0) - CFRA = cfra / tot; - } - else { - /* loop through keys in ipo, summing the frame - * numbers of those that are selected - */ - if (ipo == NULL) - return; - - for (icu= ipo->curve.first; icu; icu= icu->next) { - for (a=0, bezt=icu->bezt; a < icu->totvert; a++, bezt++) { - if (BEZSELECTED(bezt)) { - cfra += (int)floor(bezt->vec[1][0] + 0.5f); - tot++; - } - } - } - } -} - /* ******************************************* */ /* Settings */ @@ -548,7 +499,7 @@ void ANIM_editkeyframes_ipocurve_ipotype(IpoCurve *icu) icu->ipo= IPO_MIXED; /* recalculate handles, as some changes may have occurred */ - calchandles_ipocurve(icu); + //calchandles_ipocurve(icu); // XXX } static short set_bezt_constant(BeztEditData *bed, BezTriple *bezt) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 57a4d6952c7..8ff65a2a008 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -35,16 +35,17 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_curve_types.h" -#include "DNA_ipo_types.h" +#include "DNA_ipo_types.h" // XXX to be removed #include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BKE_key.h" #include "BKE_utildefines.h" @@ -69,25 +70,26 @@ * Not recommended to be used many times successively. For that * there is delete_ipo_keys(). */ -void delete_icu_key(IpoCurve *icu, int index, short do_recalc) +void delete_fcurve_key(FCurve *fcu, int index, short do_recalc) { /* firstly check that index is valid */ if (index < 0) index *= -1; - if (icu == NULL) + if (fcu == NULL) return; - if (index >= icu->totvert) + if (index >= fcu->totvert) return; /* Delete this key */ - memmove(&icu->bezt[index], &icu->bezt[index+1], sizeof(BezTriple)*(icu->totvert-index-1)); - icu->totvert--; + memmove(&fcu->bezt[index], &fcu->bezt[index+1], sizeof(BezTriple)*(fcu->totvert-index-1)); + fcu->totvert--; /* recalc handles - only if it won't cause problems */ if (do_recalc) - calchandles_ipocurve(icu); + calchandles_fcurve(fcu); } +#if 0 // XXX obsolete /* Delete selected keyframes in given IPO block */ void delete_ipo_keys(Ipo *ipo) { @@ -117,6 +119,7 @@ void delete_ipo_keys(Ipo *ipo) } } } +#endif // XXX obsolete /* ---------------- */ @@ -160,26 +163,31 @@ void duplicate_ipo_keys(Ipo *ipo) /* **************************************************** */ /* Various Tools */ +// XXX - stub... until keyframing code is fixed... +static void insert_vert_fcu(FCurve *fcu, float x, float y, short flag) +{ +} + /* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ -void clean_ipo_curve(IpoCurve *icu, float thresh) +void clean_fcurve(FCurve *fcu, float thresh) { BezTriple *old_bezts, *bezt, *beztn; BezTriple *lastb; int totCount, i; /* check if any points */ - if ((icu == NULL) || (icu->totvert <= 1)) + if ((fcu == NULL) || (fcu->totvert <= 1)) return; /* make a copy of the old BezTriples, and clear IPO curve */ - old_bezts = icu->bezt; - totCount = icu->totvert; - icu->bezt = NULL; - icu->totvert = 0; + old_bezts = fcu->bezt; + totCount = fcu->totvert; + fcu->bezt = NULL; + fcu->totvert = 0; /* now insert first keyframe, as it should be ok */ bezt = old_bezts; - insert_vert_icu(icu, bezt->vec[1][0], bezt->vec[1][1], 0); + insert_vert_fcu(fcu, bezt->vec[1][0], bezt->vec[1][1], 0); /* Loop through BezTriples, comparing them. Skip any that do * not fit the criteria for "ok" points. @@ -196,7 +204,7 @@ void clean_ipo_curve(IpoCurve *icu, float thresh) beztn = NULL; next[0] = next[1] = 0.0f; } - lastb= (icu->bezt + (icu->totvert - 1)); + lastb= (fcu->bezt + (fcu->totvert - 1)); bezt= (old_bezts + i); /* get references for quicker access */ @@ -216,7 +224,7 @@ void clean_ipo_curve(IpoCurve *icu, float thresh) if (cur[1] > next[1]) { if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_vert_icu(icu, cur[0], cur[1], 0); + insert_vert_fcu(fcu, cur[0], cur[1], 0); } } } @@ -224,7 +232,7 @@ void clean_ipo_curve(IpoCurve *icu, float thresh) /* only add if values are a considerable distance apart */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_vert_icu(icu, cur[0], cur[1], 0); + insert_vert_fcu(fcu, cur[0], cur[1], 0); } } } @@ -234,18 +242,18 @@ void clean_ipo_curve(IpoCurve *icu, float thresh) /* does current have same value as previous and next? */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe*/ - insert_vert_icu(icu, cur[0], cur[1], 0); + insert_vert_fcu(fcu, cur[0], cur[1], 0); } else if (IS_EQT(cur[1], next[1], thresh) == 0) { /* add new keyframe */ - insert_vert_icu(icu, cur[0], cur[1], 0); + insert_vert_fcu(fcu, cur[0], cur[1], 0); } } else { /* add if value doesn't equal that of previous */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_vert_icu(icu, cur[0], cur[1], 0); + insert_vert_fcu(fcu, cur[0], cur[1], 0); } } } @@ -264,8 +272,8 @@ typedef struct tSmooth_Bezt { } tSmooth_Bezt; /* Use a weighted moving-means method to reduce intensity of fluctuations */ -//mode= pupmenu("Smooth IPO%t|Tweak Points%x1|Flatten Handles%x2"); -void smooth_ipo_curve(IpoCurve *icu, short mode) +//mode= pupmenu("Smooth F-Curve%t|Tweak Points%x1|Flatten Handles%x2"); +void smooth_fcurve(FCurve *fcu, short mode) { BezTriple *bezt; int i, x, totSel = 0; @@ -273,8 +281,8 @@ void smooth_ipo_curve(IpoCurve *icu, short mode) /* first loop through - count how many verts are selected, and fix up handles * this is done for both modes */ - bezt= icu->bezt; - for (i=0; i < icu->totvert; i++, bezt++) { + bezt= fcu->bezt; + for (i=0; i < fcu->totvert; i++, bezt++) { if (BEZSELECTED(bezt)) { /* line point's handles up with point's vertical position */ bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1]; @@ -296,8 +304,8 @@ void smooth_ipo_curve(IpoCurve *icu, short mode) tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); /* populate tarray with data of selected points */ - bezt= icu->bezt; - for (i=0, x=0; (i < icu->totvert) && (x < totSel); i++, bezt++) { + bezt= fcu->bezt; + for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { if (BEZSELECTED(bezt)) { /* tsb simply needs pointer to vec, and index */ tsb->h1 = &bezt->vec[0][1]; @@ -358,7 +366,7 @@ void smooth_ipo_curve(IpoCurve *icu, short mode) } /* recalculate handles */ - calchandles_ipocurve(icu); + calchandles_fcurve(fcu); } /* **************************************************** */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 5121932d0cc..4f62368c2b2 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1,123 +1,48 @@ -/** - * $Id: keyframing.c 17745 2008-12-08 09:16:09Z aligorith $ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2008, Blender Foundation - * This is a new part of Blender (with some old code) - * - * Contributor(s): Joshua Leung - * - * ***** END GPL LICENSE BLOCK ***** +/* Testing code for 2.5 animation system + * Copyright 2009, Joshua Leung */ - - - + #include <stdio.h> #include <string.h> -#include <stdlib.h> -#include <stddef.h> #include <math.h> #include <float.h> -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" #include "BLI_blenlib.h" +#include "BLI_arithb.h" #include "BLI_dynstr.h" -#include "DNA_listBase.h" -#include "DNA_ID.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" -#include "DNA_armature_types.h" -#include "DNA_camera_types.h" #include "DNA_constraint_types.h" -#include "DNA_curve_types.h" -#include "DNA_ipo_types.h" #include "DNA_key_types.h" -#include "DNA_lamp_types.h" #include "DNA_object_types.h" -#include "DNA_object_fluidsim.h" -#include "DNA_particle_types.h" #include "DNA_material_types.h" -#include "DNA_screen_types.h" #include "DNA_scene_types.h" -#include "DNA_sequence_types.h" -#include "DNA_space_types.h" -#include "DNA_texture_types.h" #include "DNA_userdef_types.h" -#include "DNA_vec_types.h" -#include "DNA_view3d_types.h" -#include "DNA_world_types.h" #include "DNA_windowmanager_types.h" -#include "BKE_context.h" -#include "BKE_utildefines.h" -#include "BKE_blender.h" +#include "BKE_animsys.h" #include "BKE_action.h" -#include "BKE_armature.h" -#include "BKE_constraint.h" -#include "BKE_curve.h" -#include "BKE_depsgraph.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" +#include "BKE_utildefines.h" +#include "BKE_context.h" #include "BKE_key.h" -#include "BKE_object.h" -#include "BKE_particle.h" #include "BKE_material.h" -#include "BKE_modifier.h" #include "ED_anim_api.h" #include "ED_keyframing.h" #include "ED_keyframes_edit.h" +#include "ED_screen.h" +#include "ED_util.h" #include "WM_api.h" #include "WM_types.h" -#if 0 // XXX resolve these old dependencies! - #include "BIF_butspace.h" - #include "BIF_editaction.h" - #include "BIF_editkey.h" - #include "BIF_interface.h" - #include "BIF_mywindow.h" - #include "BIF_poseobject.h" - #include "BIF_screen.h" - #include "BIF_space.h" - #include "BIF_toolbox.h" - #include "BIF_toets.h" - - #include "BSE_editipo.h" - #include "BSE_node.h" - #include "BSE_time.h" - #include "BSE_view.h" - - #include "blendef.h" - - #include "PIL_time.h" /* sleep */ - #include "mydevice.h" -#endif // XXX resolve these old dependencies! - -/* ****************************************** */ - -/* note for Joshua: add_ipo() wants scene pointer to init the view2d 'cur' for - the ipo data, which restores views. Needs to be resolved nicer? */ +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_types.h" /* ************************************************** */ /* LOCAL TYPES AND DEFINES */ @@ -130,34 +55,15 @@ typedef struct bCommonKeySrc { /* general data/destination-source settings */ ID *id; /* id-block this comes from */ - char *actname; /* name of action channel */ - char *constname; /* name of constraint channel */ + char *rna_path; /* base path to use */ // xxx.... maybe we don't need this? - /* general destination source settings */ - Ipo *ipo; /* ipo-block that id-block has (optional) */ - bAction *act; /* action-block that id-block has (optional) */ - - /* pose-level settings */ - bPoseChannel *pchan; /* pose channel */ - - /* buttons-window settings */ - int map; /* offset to apply to certain adrcodes */ + /* specific cases */ + bPoseChannel *pchan; /* only needed when doing recalcs... */ } bCommonKeySrc; /* -------------- Keying Sets ------------------- */ -/* storage for iterator for looping over keyingset channels */ -typedef struct bKS_AdrcodeGetter { - struct bKeyingSet *ks; /* keyingset this applies to */ - struct bCommonKeySrc *cks; /* data to insert/delete keyframes... */ - - short index; /* index of current channel to resume from */ - short tot; /* index after which we start returning from some special collection */ -} bKS_AdrcodeGetter; - -/* flags to look out for in keyingset channels... */ -#define KAG_CHAN_EXTEND (-1) - +#if 0 // XXX I'm not sure how these will work for now... /* keying set - a set of channels that will be keyframed together */ // TODO: move this to a header to allow custom sets someday? @@ -168,11 +74,11 @@ typedef struct bKeyingSet { short (*include_cb)(struct bKeyingSet *, const char *); char name[48]; /* name of keyingset */ - int blocktype; /* blocktype that all channels belong to */ // in future, this may be eliminated + int blocktype; /* nearest ID-blocktype to where data can be found */ short flag; /* flags to use when setting keyframes */ short chan_num; /* number of channels to insert keyframe in */ - short adrcodes[32]; /* adrcodes for channels to insert keys for (ideally would be variable-len, but limit of 32 will suffice) */ + char (*paths)[256]; /* adrcodes for channels to insert keys for (ideally would be variable-len, but limit of 32 will suffice) */ } bKeyingSet; /* keying set context - an array of keying sets and the number of them */ @@ -182,282 +88,57 @@ typedef struct bKeyingContext { int tot; /* number of keyingsets in */ } bKeyingContext; +#endif -/* ************************************************** */ -/* IPO DATA VERIFICATION */ -// XXX these will need to be modified for use with RNA-IPO... - -/* depending type, it returns ipo, if needed it creates one */ -/* returns either action ipo or "real" ipo */ -/* arguments define full context; - - *from has to be set always, to Object in case of Actions - - blocktype defines available channels of Ipo struct (blocktype ID_OB can be in action too) - - if actname, use this to locate actionchannel, and optional constname - - if bonename, the constname is the ipo to the constraint -*/ - -/* note: check header_ipo.c, spaceipo_assign_ipo() too */ -Ipo *verify_ipo(ID *from, short blocktype, char actname[], char constname[], char bonename[], short add) -{ - /* lib-linked data is not appropriate here */ - if ((from==NULL) || (from->lib)) - return NULL; - - /* first check action ipos */ - if (actname && actname[0]) { - Object *ob= (Object *)from; - bActionChannel *achan; - - if (GS(from->name)!=ID_OB) { - printf("called ipo system for action with wrong base pointer\n"); - return NULL; - } - - if ((ob->action==NULL) && (add)) - ob->action= add_empty_action("Action"); - - if (add) - achan= verify_action_channel(ob->action, actname); - else - achan= get_action_channel(ob->action, actname); - - if (achan) { - /* automatically assign achan to act-group based on pchan's grouping */ - //if ((blocktype == ID_PO) && (add)) - // verify_pchan2achan_grouping(ob->action, ob->pose, actname); - - /* constraint exception */ - if (blocktype==ID_CO) { - bConstraintChannel *conchan; - - if (add) - conchan= verify_constraint_channel(&achan->constraintChannels, constname); - else - conchan= get_constraint_channel(&achan->constraintChannels, constname); - - if (conchan) { - if ((conchan->ipo==NULL) && (add)) - conchan->ipo= add_ipo(NULL, "CoIpo", ID_CO); - return conchan->ipo; - } - } - else { - if ((achan->ipo==NULL) && (add)) - achan->ipo= add_ipo(NULL, "ActIpo", blocktype); - return achan->ipo; - } - } - } - else { - switch (GS(from->name)) { - case ID_OB: - { - Object *ob= (Object *)from; - - /* constraint exception */ - if (blocktype==ID_CO) { - /* check the local constraint ipo */ - if (bonename && bonename[0] && ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, bonename); - bConstraint *con; - - for (con= pchan->constraints.first; con; con= con->next) { - if (strcmp(con->name, constname)==0) - break; - } - - if (con) { - if ((con->ipo==NULL) && (add)) - con->ipo= add_ipo(NULL, "CoIpo", ID_CO); - return con->ipo; - } - } - else { /* the actionchannel */ - bConstraintChannel *conchan; - - if (add) - conchan= verify_constraint_channel(&ob->constraintChannels, constname); - else - conchan= get_constraint_channel(&ob->constraintChannels, constname); - - if (conchan) { - if ((conchan->ipo==NULL) && (add)) - conchan->ipo= add_ipo(NULL, "CoIpo", ID_CO); - return conchan->ipo; - } - } - } - else if (blocktype==ID_OB) { - if ((ob->ipo==NULL) && (add)) - ob->ipo= add_ipo(NULL, "ObIpo", ID_OB); - return ob->ipo; - } - else if (blocktype==ID_KE) { - Key *key= ob_get_key((Object *)from); - - if (key) { - if ((key->ipo==NULL) && (add)) - key->ipo= add_ipo(NULL, "KeyIpo", ID_KE); - return key->ipo; - } - return NULL; - } - else if (blocktype== ID_FLUIDSIM) { - Object *ob= (Object *)from; - - FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - if(fluidmd) { - FluidsimSettings *fss= fluidmd->fss; - - if ((fss->ipo==NULL) && (add)) - fss->ipo= add_ipo(NULL, "FluidsimIpo", ID_FLUIDSIM); - return fss->ipo; - } - } - else if(blocktype== ID_PA) { - Object *ob= (Object *)from; - ParticleSystem *psys= psys_get_current(ob); - - if (psys) { - if ((psys->part->ipo==NULL) && (add)) - psys->part->ipo= add_ipo(NULL, "ParticleIpo", ID_PA); - return psys->part->ipo; - } - return NULL; - } - } - break; - case ID_MA: - { - Material *ma= (Material *)from; - - if ((ma->ipo==NULL) && (add)) - ma->ipo= add_ipo(NULL, "MatIpo", ID_MA); - return ma->ipo; - } - break; - case ID_TE: - { - Tex *tex= (Tex *)from; - - if ((tex->ipo==NULL) && (add)) - tex->ipo= add_ipo(NULL, "TexIpo", ID_TE); - return tex->ipo; - } - break; - case ID_SEQ: - { - Sequence *seq= (Sequence *)from; /* note, sequence is mimicing Id */ - - if ((seq->ipo==NULL) && (add)) - seq->ipo= add_ipo(NULL, "SeqIpo", ID_SEQ); - //update_seq_ipo_rect(seq); // XXX - return seq->ipo; - } - break; - case ID_CU: - { - Curve *cu= (Curve *)from; - - if ((cu->ipo==NULL) && (add)) - cu->ipo= add_ipo(NULL, "CuIpo", ID_CU); - return cu->ipo; - } - break; - case ID_WO: - { - World *wo= (World *)from; - - if ((wo->ipo==NULL) && (add)) - wo->ipo= add_ipo(NULL, "WoIpo", ID_WO); - return wo->ipo; - } - break; - case ID_LA: - { - Lamp *la= (Lamp *)from; - - if ((la->ipo==NULL) && (add)) - la->ipo= add_ipo(NULL, "LaIpo", ID_LA); - return la->ipo; - } - break; - case ID_CA: - { - Camera *ca= (Camera *)from; - - if ((ca->ipo==NULL) && (add)) - ca->ipo= add_ipo(NULL, "CaIpo", ID_CA); - return ca->ipo; - } - break; - case ID_SO: - { -#if 0 // depreceated - bSound *snd= (bSound *)from; - - if ((snd->ipo==NULL) && (add)) - snd->ipo= add_ipo(NULL, "SndIpo", ID_SO); - return snd->ipo; -#endif // depreceated - } - break; - } - } - - return NULL; -} +/* ******************************************* */ +/* Animation Data Validation */ -/* Returns and creates - * Make sure functions check for NULL or they will crash! +/* Get (or add relevant data to be able to do so) F-Curve from the Active Action, + * for the given Animation Data block */ -IpoCurve *verify_ipocurve(ID *from, short blocktype, char actname[], char constname[], char bonename[], int adrcode, short add) +// TODO: should we check if path is valid? For now, assume that it's already set OK by caller... +FCurve *verify_fcurve (AnimData *adt, const char rna_path[], const int array_index, short add) { - Ipo *ipo; - IpoCurve *icu= NULL; + nAction *act; + FCurve *fcu; - /* return 0 if lib */ - /* creates ipo too (if add) */ - ipo= verify_ipo(from, blocktype, actname, constname, bonename, add); + /* sanity checks */ + if ELEM(NULL, adt, rna_path) + return NULL; + + /* init action if none available yet */ + // TODO: need some wizardry to handle NLA stuff correct + if ((adt->action == NULL) && (add)) + adt->action= add_empty_action("Action"); + act= adt->action; + + /* try to find f-curve matching for this setting + * - add if not found and allowed to add one + * TODO: add auto-grouping support? how this works will need to be resolved + */ + if (act) + fcu= list_find_fcurve(&act->curves, rna_path, array_index); + else + fcu= NULL; - if ((ipo) && (ipo->id.lib==NULL) && (from->lib==NULL)) { - /* try to find matching curve */ - icu= find_ipocurve(ipo, adrcode); + if ((fcu == NULL) && (add)) { + /* use default settings */ + fcu= MEM_callocN(sizeof(FCurve), "FCurve"); - /* make a new one if none found (and can add) */ - if ((icu==NULL) && (add)) { - icu= MEM_callocN(sizeof(IpoCurve), "ipocurve"); - - /* set default settings */ - icu->flag |= (IPO_VISIBLE|IPO_AUTO_HORIZ); - if (ipo->curve.first==NULL) - icu->flag |= IPO_ACTIVE; /* first one added active */ - - icu->blocktype= blocktype; - icu->adrcode= adrcode; + fcu->flag |= (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES); + if (act->curves.first==NULL) + fcu->flag |= FCURVE_ACTIVE; /* first one added active */ - set_icu_vars(icu); - - /* default curve interpolation - from userpref */ - icu->ipo= U.ipo_new; - - /* add curve to IPO-block */ - BLI_addtail(&ipo->curve, icu); - - /* special type-dependent stuff */ - switch (GS(from->name)) { - case ID_SEQ: { - //Sequence *seq= (Sequence *)from; - - //update_seq_icu_rects(seq); // XXX - break; - } - } - } + /* store path - make copy, and store that */ + fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); + fcu->array_index= array_index; + + /* add curve */ + BLI_addtail(&act->curves, fcu); // XXX it might be better to add this in order, for easier UI coding... } - /* return ipo-curve */ - return icu; + /* return the F-Curve */ + return fcu; } /* ************************************************** */ @@ -544,54 +225,55 @@ static int binarysearch_bezt_index (BezTriple array[], float frame, int arraylen return start; } -/* This function adds a given BezTriple to an IPO-Curve. It will allocate +/* This function adds a given BezTriple to an F-Curve. It will allocate * memory for the array if needed, and will insert the BezTriple into a * suitable place in chronological order. * - * NOTE: any recalculate of the IPO-Curve that needs to be done will need to + * NOTE: any recalculate of the F-Curve that needs to be done will need to * be done by the caller. */ -int insert_bezt_icu (IpoCurve *icu, BezTriple *bezt) +int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt) { BezTriple *newb; int i= 0; - if (icu->bezt) { + if (fcu->bezt) { short replace = -1; - i = binarysearch_bezt_index(icu->bezt, bezt->vec[1][0], icu->totvert, &replace); + i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace); if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ // FIXME: do not overwrite handletype if just replacing...? - if ((i >= 0) && (i < icu->totvert)) - *(icu->bezt + i) = *bezt; + if ((i >= 0) && (i < fcu->totvert)) + *(fcu->bezt + i) = *bezt; } else { /* add new */ - newb= MEM_callocN((icu->totvert+1)*sizeof(BezTriple), "beztriple"); + newb= MEM_callocN((fcu->totvert+1)*sizeof(BezTriple), "beztriple"); /* add the beztriples that should occur before the beztriple to be pasted (originally in ei->icu) */ if (i > 0) - memcpy(newb, icu->bezt, i*sizeof(BezTriple)); + memcpy(newb, fcu->bezt, i*sizeof(BezTriple)); /* add beztriple to paste at index i */ *(newb + i)= *bezt; /* add the beztriples that occur after the beztriple to be pasted (originally in icu) */ - if (i < icu->totvert) - memcpy(newb+i+1, icu->bezt+i, (icu->totvert-i)*sizeof(BezTriple)); + if (i < fcu->totvert) + memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple)); /* replace (+ free) old with new */ - MEM_freeN(icu->bezt); - icu->bezt= newb; + MEM_freeN(fcu->bezt); + fcu->bezt= newb; - icu->totvert++; + fcu->totvert++; } } else { - icu->bezt= MEM_callocN(sizeof(BezTriple), "beztriple"); - *(icu->bezt)= *bezt; - icu->totvert= 1; + // TODO: need to check for old sample-data now... + fcu->bezt= MEM_callocN(sizeof(BezTriple), "beztriple"); + *(fcu->bezt)= *bezt; + fcu->totvert= 1; } @@ -607,10 +289,10 @@ int insert_bezt_icu (IpoCurve *icu, BezTriple *bezt) * * 'fast' - is only for the python API where importing BVH's would take an extreamly long time. */ -void insert_vert_icu (IpoCurve *icu, float x, float y, short fast) +void insert_vert_fcurve (FCurve *fcu, float x, float y, short fast) { BezTriple beztr; - int a, h1, h2; + int a; /* set all three points, for nicer start position */ memset(&beztr, 0, sizeof(BezTriple)); @@ -620,12 +302,12 @@ void insert_vert_icu (IpoCurve *icu, float x, float y, short fast) beztr.vec[1][1]= y; beztr.vec[2][0]= x; beztr.vec[2][1]= y; - beztr.hide= IPO_BEZ; + beztr.ipo= U.ipo_new; /* use default interpolation mode here... */ beztr.f1= beztr.f2= beztr.f3= SELECT; - beztr.h1= beztr.h2= HD_AUTO; + beztr.h1= beztr.h2= HD_AUTO; // XXX what about when we replace an old one? /* add temp beztriple to keyframes */ - a= insert_bezt_icu(icu, &beztr); + a= insert_bezt_fcurve(fcu, &beztr); /* what if 'a' is a negative index? * for now, just exit to prevent any segfaults @@ -636,125 +318,34 @@ void insert_vert_icu (IpoCurve *icu, float x, float y, short fast) * - this is a hack to make importers faster * - we may calculate twice (see editipo_changed(), due to autohandle needing two calculations) */ - if (!fast) calchandles_ipocurve(icu); + if (!fast) calchandles_fcurve(fcu); /* set handletype and interpolation */ - if (icu->totvert > 2) { - BezTriple *bezt= (icu->bezt + a); + if (fcu->totvert > 2) { + BezTriple *bezt= (fcu->bezt + a); + short h1, h2; /* set handles (autohandles by default) */ h1= h2= HD_AUTO; if (a > 0) h1= (bezt-1)->h2; - if (a < icu->totvert-1) h2= (bezt+1)->h1; + if (a < fcu->totvert-1) h2= (bezt+1)->h1; bezt->h1= h1; bezt->h2= h2; - /* set interpolation (if curve is using IPO_MIXED, then take from previous) */ - if (icu->ipo == IPO_MIXED) { - if (a > 0) bezt->ipo= (bezt-1)->ipo; - else if (a < icu->totvert-1) bezt->ipo= (bezt+1)->ipo; - } - else - bezt->ipo= icu->ipo; + /* set interpolation from previous (if available) */ + if (a > 0) bezt->ipo= (bezt-1)->ipo; + else if (a < fcu->totvert-1) bezt->ipo= (bezt+1)->ipo; /* don't recalculate handles if fast is set * - this is a hack to make importers faster * - we may calculate twice (see editipo_changed(), due to autohandle needing two calculations) */ - if (!fast) calchandles_ipocurve(icu); - } - else { - BezTriple *bezt= (icu->bezt + a); - - /* set interpolation directly from ipo-curve */ - bezt->ipo= icu->ipo; - } -} - - -/* ------------------- Get Data ------------------------ */ - -/* Get pointer to use to get values from */ -// FIXME: this should not be possible with Data-API -static void *get_context_ipo_poin (ID *id, int blocktype, char *actname, char *constname, IpoCurve *icu, int *vartype) -{ - switch (blocktype) { - case ID_PO: /* posechannel */ - if (GS(id->name)==ID_OB) { - Object *ob= (Object *)id; - bPoseChannel *pchan= get_pose_channel(ob->pose, actname); - - if (pchan) { - if (ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) - *vartype= IPO_FLOAT_DEGR; - else - *vartype= IPO_FLOAT; - return get_pchan_ipo_poin(pchan, icu->adrcode); - } - } - break; - - case ID_CO: /* constraint */ - if ((GS(id->name)==ID_OB) && (constname && constname[0])) { - Object *ob= (Object *)id; - bConstraint *con; - - /* assume that we only want the influence (as only used for Constraint Channels) */ - if ((ob->ipoflag & OB_ACTION_OB) && !strcmp(actname, "Object")) { - for (con= ob->constraints.first; con; con= con->next) { - if (strcmp(constname, con->name)==0) { - *vartype= IPO_FLOAT; - return &con->enforce; - } - } - } - else if (ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, actname); - - if (pchan) { - for (con= pchan->constraints.first; con; con= con->next) { - if (strcmp(constname, con->name)==0) { - *vartype= IPO_FLOAT; - return &con->enforce; - } - } - } - } - } - break; - - case ID_OB: /* object */ - /* hack: layer channels for object need to be keyed WITHOUT localview flag... - * tsk... tsk... why must we just dump bitflags upon users :/ - */ - if ((GS(id->name)==ID_OB) && (icu->adrcode==OB_LAY)) { - Object *ob= (Object *)id; - static int layer = 0; - - /* init layer to be the object's layer var, then remove local view from it */ - layer = ob->lay; - layer &= 0xFFFFFF; - *vartype= IPO_INT_BIT; - - /* return pointer to this static var - * - assumes that this pointer won't be stored for use later, so may not be threadsafe - * if multiple keyframe calls are made, but that is unlikely to happen in the near future - */ - return (void *)(&layer); - } - /* no break here for other ob channel-types - as they can be done normally */ - - default: /* normal data-source */ - return get_ipo_poin(id, icu, vartype); + if (!fast) calchandles_fcurve(fcu); } - - /* not valid... */ - return NULL; } - /* -------------- 'Smarter' Keyframing Functions -------------------- */ /* return codes for new_key_needed */ enum { @@ -770,19 +361,19 @@ enum { * 2. Keyframe to be added on frame where two keyframes are already situated * 3. Keyframe lies at point that intersects the linear line between two keyframes */ -static short new_key_needed (IpoCurve *icu, float cFrame, float nValue) +static short new_key_needed (FCurve *fcu, float cFrame, float nValue) { BezTriple *bezt=NULL, *prev=NULL; int totCount, i; float valA = 0.0f, valB = 0.0f; /* safety checking */ - if (icu == NULL) return KEYNEEDED_JUSTADD; - totCount= icu->totvert; + if (fcu == NULL) return KEYNEEDED_JUSTADD; + totCount= fcu->totvert; if (totCount == 0) return KEYNEEDED_JUSTADD; /* loop through checking if any are the same */ - bezt= icu->bezt; + bezt= fcu->bezt; for (i=0; i<totCount; i++) { float prevPosi=0.0f, prevVal=0.0f; float beztPosi=0.0f, beztVal=0.0f; @@ -813,7 +404,7 @@ static short new_key_needed (IpoCurve *icu, float cFrame, float nValue) float realVal; /* get real value of curve at that point */ - realVal= eval_icu(icu, cFrame); + realVal= evaluate_fcurve(fcu, cFrame); /* compare whether it's the same as proposed */ if (IS_EQ(realVal, nValue)) @@ -859,7 +450,7 @@ static short new_key_needed (IpoCurve *icu, float cFrame, float nValue) * -> Otherwise, a keyframe is just added. 1.0 is added so that fake-2nd-to-last * keyframe is not equal to last keyframe. */ - bezt= (icu->bezt + (icu->totvert - 1)); + bezt= (fcu->bezt + (fcu->totvert - 1)); valA= bezt->vec[1][1]; if (prev) @@ -873,13 +464,49 @@ static short new_key_needed (IpoCurve *icu, float cFrame, float nValue) return KEYNEEDED_JUSTADD; } +/* ------------------ RNA Data-Access Functions ------------------ */ + +/* Try to read value using RNA-properties obtained already */ +static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int index) +{ + float value= 0.0f; + + switch (RNA_property_type(ptr, prop)) { + case PROP_BOOLEAN: + if (RNA_property_array_length(ptr, prop)) + value= (float)RNA_property_boolean_get_array(ptr, prop, index); + else + value= (float)RNA_property_boolean_get(ptr, prop); + break; + case PROP_INT: + if (RNA_property_array_length(ptr, prop)) + value= (float)RNA_property_int_get_array(ptr, prop, index); + else + value= (float)RNA_property_int_get(ptr, prop); + break; + case PROP_FLOAT: + if (RNA_property_array_length(ptr, prop)) + value= RNA_property_float_get_array(ptr, prop, index); + else + value= RNA_property_float_get(ptr, prop); + break; + case PROP_ENUM: + value= (float)RNA_property_enum_get(ptr, prop); + break; + default: + break; + } + + return value; +} + /* ------------------ 'Visual' Keyframing Functions ------------------ */ /* internal status codes for visualkey_can_use */ enum { VISUALKEY_NONE = 0, VISUALKEY_LOC, - VISUALKEY_ROT + VISUALKEY_ROT, }; /* This helper function determines if visual-keyframing should be used when @@ -888,15 +515,16 @@ enum { * blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying * settings is on. */ -static short visualkey_can_use (ID *id, int blocktype, char *actname, char *constname, int adrcode) +static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) { - Object *ob= NULL; + //Object *ob= NULL; bConstraint *con= NULL; short searchtype= VISUALKEY_NONE; +#if 0 // XXX old animation system /* validate data */ if ((id == NULL) || (GS(id->name)!=ID_OB) || !(ELEM(blocktype, ID_OB, ID_PO))) - return 0; + return 0; /* get first constraint and determine type of keyframe constraints to check for*/ ob= (Object *)id; @@ -918,6 +546,7 @@ static short visualkey_can_use (ID *id, int blocktype, char *actname, char *cons else if (ELEM4(adrcode, AC_QUAT_W, AC_QUAT_X, AC_QUAT_Y, AC_QUAT_Z)) searchtype= VISUALKEY_ROT; } +#endif /* only search if a searchtype and initial constraint are available */ if (searchtype && con) { @@ -976,10 +605,12 @@ static short visualkey_can_use (ID *id, int blocktype, char *actname, char *cons /* This helper function extracts the value to use for visual-keyframing * In the event that it is not possible to perform visual keying, try to fall-back - * to using the poin method. Assumes that all data it has been passed is valid. + * to using the default method. Assumes that all data it has been passed is valid. */ -static float visualkey_get_value (ID *id, int blocktype, char *actname, char *constname, int adrcode, IpoCurve *icu) +// xxx... ptr here should be struct that data is in.... prop is the channel that's being used +static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_index) { +#if 0 // XXX old animation system Object *ob; void *poin = NULL; int index, vartype; @@ -1053,13 +684,10 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co return quat[index]; } } +#endif // XXX old animation system - /* as the function hasn't returned yet, try reading from poin */ - poin= get_context_ipo_poin(id, blocktype, actname, constname, icu, &vartype); - if (poin) - return read_ipo_poin(poin, vartype); - else - return 0.0; + /* as the function hasn't returned yet, read value from system in the default way */ + return setting_get_rna_value(ptr, prop, array_index); } /* ------------------------- Insert Key API ------------------------- */ @@ -1072,25 +700,35 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, * and extra keyframe filtering. */ -short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag) +short insertkey (ID *id, const char rna_path[], int array_index, float cfra, short flag) { - IpoCurve *icu; + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + AnimData *adt; + FCurve *fcu; + + /* validate pointer first - exit if failure*/ + RNA_id_pointer_create(id, &id_ptr); + if (RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) { + printf("Insert Key: Could not insert keyframe, as RNA Path is invalid for the given ID \n"); + return 0; + } - /* get ipo-curve */ - icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode, 1); + /* get F-Curve */ + adt= BKE_animdata_from_id(id); + fcu= verify_fcurve(adt, rna_path, array_index, 1); - /* only continue if we have an ipo-curve to add keyframe to */ - if (icu) { - float cfra =1.0f;//= frame_to_float(CFRA); + /* only continue if we have an F-Curve to add keyframe to */ + if (fcu) { float curval= 0.0f; /* apply special time tweaking */ + // XXX check on this stuff... if (GS(id->name) == ID_OB) { - Object *ob= (Object *)id; + //Object *ob= (Object *)id; /* apply NLA-scaling (if applicable) */ - if (actname && actname[0]) - cfra= get_action_frame(ob, cfra); + //cfra= get_action_frame(ob, cfra); /* ancient time-offset cruft */ //if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) { @@ -1101,29 +739,17 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc /* obtain value to give keyframe */ if ( (flag & INSERTKEY_MATRIX) && - (visualkey_can_use(id, blocktype, actname, constname, adrcode)) ) + (visualkey_can_use(&ptr, prop)) ) { /* visual-keying is only available for object and pchan datablocks, as * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ - curval= visualkey_get_value(id, blocktype, actname, constname, adrcode, icu); + curval= visualkey_get_value(&ptr, prop, array_index); } else { - void *poin; - int vartype; - - /* get pointer to data to read from */ - poin = get_context_ipo_poin(id, blocktype, actname, constname, icu, &vartype); - if (poin == NULL) { - printf("Insert Key: No pointer to variable obtained \n"); - return 0; - } - - /* use kt's read_poin function to extract value (kt->read_poin should - * exist in all cases, but it never hurts to check) - */ - curval= read_ipo_poin(poin, vartype); + /* read value from system */ + curval= setting_get_rna_value(&ptr, prop, array_index); } /* only insert keyframes where they are needed */ @@ -1131,19 +757,19 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc short insert_mode; /* check whether this curve really needs a new keyframe */ - insert_mode= new_key_needed(icu, cfra, curval); + insert_mode= new_key_needed(fcu, cfra, curval); /* insert new keyframe at current frame */ if (insert_mode) - insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST)); + insert_vert_fcurve(fcu, cfra, curval, (flag & INSERTKEY_FAST)); /* delete keyframe immediately before/after newly added */ switch (insert_mode) { case KEYNEEDED_DELPREV: - delete_icu_key(icu, icu->totvert-2, 1); + delete_fcurve_key(fcu, fcu->totvert-2, 1); break; case KEYNEEDED_DELNEXT: - delete_icu_key(icu, 1, 1); + delete_fcurve_key(fcu, 1, 1); break; } @@ -1153,7 +779,7 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc } else { /* just insert keyframe */ - insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST)); + insert_vert_fcurve(fcu, cfra, curval, (flag & INSERTKEY_FAST)); /* return success */ return 1; @@ -1164,7 +790,6 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc return 0; } - /* ************************************************** */ /* KEYFRAME DELETION */ @@ -1175,31 +800,31 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc * The flag argument is used for special settings that alter the behaviour of * the keyframe deletion. These include the quick refresh options. */ -short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag) +short deletekey (ID *id, const char rna_path[], int array_index, float cfra, short flag) { - Ipo *ipo; - IpoCurve *icu; + AnimData *adt= BKE_animdata_from_id(id); + nAction *act; + FCurve *fcu; - /* get ipo-curve - * Note: here is one of the places where we don't want new ipo + ipo-curve added! + /* get F-Curve + * Note: here is one of the places where we don't want new Action + F-Curve added! * so 'add' var must be 0 */ - ipo= verify_ipo(id, blocktype, actname, constname, NULL, 0); - icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode, 0); + // XXX we don't check the validity of the path here yet, but it should be ok... + fcu= verify_fcurve(adt, rna_path, array_index, 0); + act= adt->action; /* only continue if we have an ipo-curve to remove keyframes from */ - if (icu) { - float cfra = 1.0f;//frame_to_float(CFRA); + if (act && fcu) { short found = -1; int i; /* apply special time tweaking */ if (GS(id->name) == ID_OB) { - Object *ob= (Object *)id; + //Object *ob= (Object *)id; /* apply NLA-scaling (if applicable) */ - if (actname && actname[0]) - cfra= get_action_frame(ob, cfra); + // cfra= get_action_frame(ob, cfra); /* ancient time-offset cruft */ //if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) { @@ -1209,15 +834,16 @@ short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrc } /* try to find index of beztriple to get rid of */ - i = binarysearch_bezt_index(icu->bezt, cfra, icu->totvert, &found); + i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found); if (found) { - /* delete the key at the index (will sanity check + do recalc afterwards ) */ - delete_icu_key(icu, i, 1); - - /* Only delete curve too 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 the key at the index (will sanity check + do recalc afterwards) */ + delete_fcurve_key(fcu, i, 1); + + /* Only delete curve too if there are no points (we don't need to check for drivers, as they're kept separate) */ + // XXX how do we handle drivers then? + if (fcu->totvert == 0) { + BLI_remlink(&act->curves, fcu); + free_fcurve(fcu); } /* return success */ @@ -1229,8 +855,8 @@ short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrc return 0; } -/* ************************************************** */ -/* COMMON KEYFRAME MANAGEMENT (common_insertkey/deletekey) */ +/* ******************************************* */ +/* KEYFRAME MODIFICATION */ /* mode for common_modifykey */ enum { @@ -1238,6 +864,8 @@ enum { COMMONKEY_MODE_DELETE, } eCommonModifyKey_Modes; +#if 0 // XXX old keyingsets code based on adrcodes... to be restored in due course + /* --------- KeyingSet Adrcode Getters ------------ */ /* initialise a channel-getter storage */ @@ -2096,7 +1724,7 @@ static void commonkey_context_finish (const bContext *C, ListBase *sources) } /* flush refreshes after undo */ -static void commonkey_context_refresh (const bContext *C) +static void commonkey_context_refresh (bContext *C) { ScrArea *curarea= CTX_wm_area(C); @@ -2190,7 +1818,7 @@ static bKeyingSet *get_keyingset_fromcontext (bKeyingContext *ksc, short index) /* ---------------- Keyframe Management API -------------------- */ /* Display a menu for handling the insertion of keyframes based on the active view */ -void common_modifykey (const bContext *C, short mode) +void common_modifykey (bContext *C, short mode) { ListBase dsources = {NULL, NULL}; bKeyingContext *ksc= NULL; @@ -2349,46 +1977,176 @@ void common_modifykey (const bContext *C, short mode) ob->pose->flag |= POSE_RECALCPATHS; /* clear unkeyed flag (it doesn't matter if it's set or not) */ - if (pchan->bone) - pchan->bone->flag &= ~BONE_UNKEYED; + // XXX old animation system + //if (pchan->bone) + // pchan->bone->flag &= ~BONE_UNKEYED; } + + // XXX for new system, need to remove overrides } } /* apply post-keying flushes for this data sources */ commonkey_context_finish(C, &dsources); - ksc->lastused= ks; /* free temp data */ BLI_freelistN(&dsources); - /* undo pushes */ - if (mode == COMMONKEY_MODE_DELETE) - BLI_snprintf(buf, 64, "Delete %s Key", ks->name); - else - BLI_snprintf(buf, 64, "Insert %s Key", ks->name); - //BIF_undo_push(buf); - /* queue updates for contexts */ commonkey_context_refresh(C); } -/* ---- */ +#endif // XXX old keyingsets code based on adrcodes... to be restored in due course + +/* Insert Key Operator ------------------------ */ + +/* XXX WARNING: + * This is currently just a basic operator, which work in 3d-view context on objects only + * and will insert keyframes for a few settings only. This is until it becomes clear how + * to separate (or not) the process for RNA-path creation between context + keyingsets. + * + * -- Joshua Leung, Jan 2009 + */ + +/* defines for basic insert-key testing operator */ + // XXX this will definitely be replaced +EnumPropertyItem prop_insertkey_types[] = { + {0, "LOC", "Location", ""}, + {1, "ROT", "Rotation", ""}, + {2, "SCALE", "Scale", ""}, + {3, "MAT_COL", "Active Material - Color", ""}, + {0, NULL, NULL, NULL} +}; + +static int insert_key_exec (bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + short mode= RNA_enum_get(op->ptr, "type"); + float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + + // XXX more comprehensive tests will be needed + CTX_DATA_BEGIN(C, Base*, base, selected_bases) + { + Object *ob= base->object; + ID *id= (ID *)ob; + short success= 0; + + /* check which keyframing mode chosen for this object */ + switch (mode) { + case 3: /* color of active material */ + // NOTE: this is just a demo... but ideally we'd go through materials instead of active one only so reference stays same + success+= insertkey(id, "active_material.diffuse_color", 0, cfra, 0); + success+= insertkey(id, "active_material.diffuse_color", 1, cfra, 0); + success+= insertkey(id, "active_material.diffuse_color", 2, cfra, 0); + break; + case 2: /* scale */ + success+= insertkey(id, "scale", 0, cfra, 0); + success+= insertkey(id, "scale", 1, cfra, 0); + success+= insertkey(id, "scale", 2, cfra, 0); + case 1: /* rotation */ + success+= insertkey(id, "rotation", 0, cfra, 0); + success+= insertkey(id, "rotation", 1, cfra, 0); + success+= insertkey(id, "rotation", 2, cfra, 0); + default: /* location */ + success+= insertkey(id, "location", 0, cfra, 0); + success+= insertkey(id, "location", 1, cfra, 0); + success+= insertkey(id, "location", 2, cfra, 0); + break; + } + + printf("Ob '%s' - Successfully added %d Keyframes \n", id->name+2, success); + + ob->recalc |= OB_RECALC_OB; + } + CTX_DATA_END; + + /* send updates */ + ED_anim_dag_flush_update(C); + ED_undo_push(C, "Insert Keyframe"); + + if (mode == 3) // material color requires different notifiers + WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, NULL); + else + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} -/* used to insert keyframes from any view */ -void common_insertkey (const bContext *C) +void ANIM_OT_insert_keyframe (wmOperatorType *ot) { - common_modifykey(C, COMMONKEY_MODE_INSERT); + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Insert Keyframe"; + ot->idname= "ANIM_OT_insert_keyframe"; + + /* callbacks */ + ot->invoke= WM_menu_invoke; // XXX we will need our own one eventually, to cope with the dynamic menus... + ot->exec= insert_key_exec; + + /* properties */ + // XXX update this for the latest RNA stuff styles... + prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_insertkey_types); } -/* used to insert keyframes from any view */ -void common_deletekey (const bContext *C) +/* Delete Key Operator ------------------------ */ + +/* XXX WARNING: + * This is currently just a basic operator, which work in 3d-view context on objects only. + * -- Joshua Leung, Jan 2009 + */ + +static int delete_key_exec (bContext *C, wmOperator *op) { - common_modifykey(C, COMMONKEY_MODE_DELETE); + Scene *scene= CTX_data_scene(C); + float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + + // XXX more comprehensive tests will be needed + CTX_DATA_BEGIN(C, Base*, base, selected_bases) + { + Object *ob= base->object; + ID *id= (ID *)ob; + nAction *act= ob->adt.action; + FCurve *fcu, *fcn; + short success= 0; + + /* loop through all curves in animdata and delete keys on this frame */ + if (act) { + for (fcu= act->curves.first; fcu; fcu= fcn) { + fcn= fcu->next; + success+= deletekey(id, fcu->rna_path, fcu->array_index, cfra, 0); + } + } + + printf("Ob '%s' - Successfully removed %d keyframes \n", id->name+2, success); + + ob->recalc |= OB_RECALC_OB; + } + CTX_DATA_END; + + /* send updates */ + ED_anim_dag_flush_update(C); + ED_undo_push(C, "Delete Keyframe"); + + // XXX what if it was a material keyframe? + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; } +void ANIM_OT_delete_keyframe (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Keyframe"; + ot->idname= "ANIM_OT_delete_keyframe"; + + /* callbacks */ + ot->invoke= WM_operator_confirm; // XXX we will need our own one eventually, to cope with the dynamic menus... + ot->exec= delete_key_exec; +} -/* ************************************************** */ +/* ******************************************* */ /* KEYFRAME DETECTION */ /* --------------- API/Per-Datablock Handling ------------------- */ @@ -2396,35 +2154,35 @@ void common_deletekey (const bContext *C) /* Checks whether an IPO-block has a keyframe for a given frame * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... */ -short ipo_frame_has_keyframe (Ipo *ipo, float frame, short filter) +short action_frame_has_keyframe (nAction *act, float frame, short filter) { - IpoCurve *icu; + FCurve *fcu; /* can only find if there is data */ - if (ipo == NULL) + if (act == NULL) return 0; /* if only check non-muted, check if muted */ - if ((filter & ANIMFILTER_KEYS_MUTED) || (ipo->muteipo)) + if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED)) return 0; - /* loop over IPO-curves, using binary-search to try to find matches + /* loop over F-Curves, using binary-search to try to find matches * - this assumes that keyframes are only beztriples */ - for (icu= ipo->curve.first; icu; icu= icu->next) { + for (fcu= act->curves.first; fcu; fcu= fcu->next) { /* only check if there are keyframes (currently only of type BezTriple) */ - if (icu->bezt) { + if (fcu->bezt) { /* we either include all regardless of muting, or only non-muted */ - if ((filter & ANIMFILTER_KEYS_MUTED) || (icu->flag & IPO_MUTE)==0) { + if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) { short replace = -1; - int i = binarysearch_bezt_index(icu->bezt, frame, icu->totvert, &replace); + int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace); /* binarysearch_bezt_index will set replace to be 0 or 1 * - obviously, 1 represents a match */ if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ - if ((i >= 0) && (i < icu->totvert)) + if ((i >= 0) && (i < fcu->totvert)) return 1; } } @@ -2435,32 +2193,6 @@ short ipo_frame_has_keyframe (Ipo *ipo, float frame, short filter) return 0; } -/* Checks whether an action-block has a keyframe for a given frame - * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... - */ -short action_frame_has_keyframe (bAction *act, float frame, short filter) -{ - bActionChannel *achan; - - /* error checking */ - if (act == NULL) - return 0; - - /* check thorugh action-channels for match */ - for (achan= act->chanbase.first; achan; achan= achan->next) { - /* we either include all regardless of muting, or only non-muted - * - here we include 'hidden' channels in the muted definition - */ - if ((filter & ANIMFILTER_KEYS_MUTED) || (achan->flag & ACHAN_HIDDEN)==0) { - if (ipo_frame_has_keyframe(achan->ipo, frame, filter)) - return 1; - } - } - - /* nothing found */ - return 0; -} - /* Checks whether an Object has a keyframe for a given frame */ short object_frame_has_keyframe (Object *ob, float frame, short filter) { @@ -2468,35 +2200,9 @@ short object_frame_has_keyframe (Object *ob, float frame, short filter) if (ob == NULL) return 0; - /* check for an action - actions take priority over normal IPO's */ - if (ob->action) { - float aframe; - - /* apply nla-action scaling if needed */ - if ((ob->nlaflag & OB_NLA_OVERRIDE) && (ob->nlastrips.first)) - aframe= get_action_frame(ob, frame); - else - aframe= frame; - - /* priority check here goes to pose-channel checks (for armatures) */ - if ((ob->pose) && (ob->flag & OB_POSEMODE)) { - /* only relevant check here is to only show active... */ - if (filter & ANIMFILTER_KEYS_ACTIVE) { - bPoseChannel *pchan= get_active_posechannel(ob); - bActionChannel *achan= (pchan) ? get_action_channel(ob->action, pchan->name) : NULL; - - /* since we're only interested in whether the selected one has any keyframes... */ - return (achan && ipo_frame_has_keyframe(achan->ipo, aframe, filter)); - } - } - - /* for everything else, just use the standard test (only return if success) */ - if (action_frame_has_keyframe(ob->action, aframe, filter)) - return 1; - } - else if (ob->ipo) { - /* only return if success */ - if (ipo_frame_has_keyframe(ob->ipo, frame, filter)) + /* check own animation data - specifically, the action it contains */ + if (ob->adt.action) { + if (action_frame_has_keyframe(ob->adt.action, frame, filter)) return 1; } @@ -2548,40 +2254,32 @@ short object_frame_has_keyframe (Object *ob, float frame, short filter) /* Checks whether a keyframe exists for the given ID-block one the given frame */ short id_frame_has_keyframe (ID *id, float frame, short filter) { - /* error checking */ + /* sanity checks */ if (id == NULL) return 0; - /* check for a valid id-type */ + /* perform special checks for 'macro' types */ switch (GS(id->name)) { - /* animation data-types */ - case ID_IP: /* ipo */ - return ipo_frame_has_keyframe((Ipo *)id, frame, filter); - case ID_AC: /* action */ - return action_frame_has_keyframe((bAction *)id, frame, filter); - case ID_OB: /* object */ return object_frame_has_keyframe((Object *)id, frame, filter); - - case ID_MA: /* material */ - { - Material *ma= (Material *)id; - - /* currently, material's only have an ipo-block */ - return ipo_frame_has_keyframe(ma->ipo, frame, filter); - } break; - case ID_KE: /* shapekey */ + case ID_SCE: /* scene */ + // XXX TODO... for now, just use 'normal' behaviour + // break; + + default: /* 'normal type' */ { - Key *key= (Key *)id; + AnimData *adt= BKE_animdata_from_id(id); - /* currently, shapekey's only have an ipo-block */ - return ipo_frame_has_keyframe(key->ipo, frame, filter); + /* only check keyframes in active action */ + if (adt) + return action_frame_has_keyframe(adt->action, frame, filter); } break; } + /* no keyframe found */ return 0; } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 5548700b2e1..5a751236e6e 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -99,8 +99,6 @@ static void error_libdata() {} static void BIF_undo_push() {} static void adduplicate() {} static void countall() {} -static void deselect_actionchannels() {} -static void select_actionchannel_by_name() {} /* ************* XXX *************** */ /* **************** tools on Editmode Armature **************** */ @@ -599,7 +597,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* action constraint? */ if (con->type == CONSTRAINT_TYPE_ACTION) { - bActionConstraint *data= con->data; + bActionConstraint *data= con->data; // XXX old animation system bAction *act; bActionChannel *achan; @@ -1330,7 +1328,8 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone) if (!(bone->flag & BONE_CONNECTED)) return; - select_actionchannel_by_name (ob->action, bone->name, !(shift)); + // XXX old cruft! use notifiers instead + //select_actionchannel_by_name (ob->action, bone->name, !(shift)); if (shift) bone->flag &= ~BONE_SELECTED; @@ -1359,7 +1358,8 @@ void selectconnected_posearmature(bContext *C) /* Select parents */ for (curBone=bone; curBone; curBone=next){ - select_actionchannel_by_name (ob->action, curBone->name, !(shift)); + // XXX old cruft! use notifiers instead + //select_actionchannel_by_name (ob->action, curBone->name, !(shift)); if (shift) curBone->flag &= ~BONE_SELECTED; else @@ -3568,7 +3568,9 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor if (!(extend) || (base != scene->basact)) { ED_pose_deselectall(ob, 0, 0); nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); - select_actionchannel_by_name(ob->action, nearBone->name, 1); + + // XXX old cruft! use notifiers instead + //select_actionchannel_by_name(ob->action, nearBone->name, 1); } else { if (nearBone->flag & BONE_SELECTED) { @@ -3579,14 +3581,18 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor } else { nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); - select_actionchannel_by_name(ob->action, nearBone->name, 0); + + // XXX old cruft! use notifiers instead + //select_actionchannel_by_name(ob->action, nearBone->name, 0); } } else { bone_looper(ob, arm->bonebase.first, NULL, clear_active_flag); nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); - select_actionchannel_by_name(ob->action, nearBone->name, 1); + + // XXX old cruft! use notifiers instead + //select_actionchannel_by_name(ob->action, nearBone->name, 1); } } @@ -3647,16 +3653,6 @@ void ED_pose_deselectall (Object *ob, int test, int doundo) } } - /* action editor */ - if (test == 3) { - deselect_actionchannels(ob->action, 2); /* inverts selection */ - } - else { - deselect_actionchannels(ob->action, 0); /* deselects for sure */ - if (selectmode == 1) - deselect_actionchannels(ob->action, 1); /* swaps */ - } - countall(); if (doundo) { @@ -4187,7 +4183,6 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) { bArmature *arm= ob->data; - Ipo *ipo; char newname[MAXBONENAME]; char oldname[MAXBONENAME]; @@ -4225,11 +4220,12 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) /* we have the object using the armature */ if (arm==ob->data) { Object *cob; - bAction *act; - bActionChannel *achan; - bActionStrip *strip; + //bAction *act; + //bActionChannel *achan; + //bActionStrip *strip; /* Rename action channel if necessary */ +#if 0 // XXX old animation system act = ob->action; if (act && !act->id.lib) { /* Find the appropriate channel */ @@ -4237,6 +4233,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) if (achan) BLI_strncpy(achan->name, newname, MAXBONENAME); } +#endif // XXX old animation system /* Rename the pose channel, if it exists */ if (ob->pose) { @@ -4246,6 +4243,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) } /* check all nla-strips too */ +#if 0 // XXX old animation system for (strip= ob->nlastrips.first; strip; strip= strip->next) { /* Rename action channel if necessary */ act = strip->act; @@ -4256,6 +4254,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) BLI_strncpy(achan->name, newname, MAXBONENAME); } } +#endif // XXX old animation system /* Update any object constraints to use the new bone name */ for (cob= G.main->object.first; cob; cob= cob->id.next) { @@ -4290,6 +4289,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) } /* do entire db - ipo's for the drivers */ +#if 0 // XXX old animation system for (ipo= G.main->ipo.first; ipo; ipo= ipo->id.next) { IpoCurve *icu; @@ -4310,6 +4310,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) } } } +#endif // XXX old animation system } } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index c6ac1adb446..ffbc787f01c 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -82,8 +82,8 @@ static int extern_qread_ext() {return 0;} static void persptoetsen() {} static void headerprint() {} -static void remake_action_ipos() {} -static void verify_pchan2achan_grouping() {} +static void remake_action_ipos() {} // xxx depreceated +//static void verify_pchan2achan_grouping() {} // xxx depreceated static void action_set_activemarker() {} /* ******* XXX ********** */ @@ -276,6 +276,7 @@ void poselib_validate_act (bAction *act) /* This function adds an ipo-curve of the right type where it's needed */ static IpoCurve *poselib_verify_icu (Ipo *ipo, int adrcode) { +#if 0 // XXX old animation system IpoCurve *icu; for (icu= ipo->curve.first; icu; icu= icu->next) { @@ -296,6 +297,8 @@ static IpoCurve *poselib_verify_icu (Ipo *ipo, int adrcode) } return icu; +#endif // XXX old animation system + return NULL; } /* This tool adds the current pose to the poselib @@ -385,6 +388,7 @@ void poselib_add_current_pose (Scene *scene, Object *ob, int val) /* check if available */ if ((pchan->bone) && (arm->layer & pchan->bone->layer)) { if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) { +#if 0 // XXX old animation system /* make action-channel if needed (action groups are also created) */ achan= verify_action_channel(act, pchan->name); verify_pchan2achan_grouping(act, pose, pchan->name); @@ -409,6 +413,7 @@ void poselib_add_current_pose (Scene *scene, Object *ob, int val) INSERT_KEY_ICU(AC_QUAT_X, pchan->quat[1]) INSERT_KEY_ICU(AC_QUAT_Y, pchan->quat[2]) INSERT_KEY_ICU(AC_QUAT_Z, pchan->quat[3]) +#endif // XXX old animation system } } } @@ -456,6 +461,7 @@ void poselib_remove_pose (Object *ob, TimeMarker *marker) } /* remove relevant keyframes */ +#if 0 // XXX old animation system for (achan= act->chanbase.first; achan; achan= achan->next) { Ipo *ipo= achan->ipo; IpoCurve *icu; @@ -472,6 +478,7 @@ void poselib_remove_pose (Object *ob, TimeMarker *marker) } } } +#endif // XXX old animation system /* remove poselib from list */ BLI_freelinkN(&act->markers, marker); @@ -687,10 +694,12 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld) ok= 1; if (ok) { +#if 0 // XXX old animation system /* Evaluates and sets the internal ipo values */ calc_ipo(achan->ipo, (float)frame); /* This call also sets the pchan flags */ execute_action_ipo(achan, pchan); +#endif // XXX old animation system } } } @@ -719,6 +728,7 @@ static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld) pchan= get_pose_channel(pose, achan->name); if (pchan) { +#if 0 // XXX old animation system // TODO: use a standard autokeying function in future (to allow autokeying-editkeys to work) if (IS_AUTOKEY_MODE(NORMAL)) { ID *id= &pld->ob->id; @@ -750,6 +760,7 @@ static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld) if (pchan->bone) pchan->bone->flag |= BONE_UNKEYED; } +#endif // XXX old animation system } } } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 08a670b9582..80b67ac70ac 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" @@ -57,11 +58,11 @@ #include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_utildefines.h" -#include "BKE_ipo.h" #include "BIF_transform.h" /* for autokey TFM_TRANSLATION, etc */ #include "BIF_gl.h" @@ -851,6 +852,7 @@ void paste_posebuf (Scene *scene, int flip) EulToQuat(eul, pchan->quat); } +#if 0 // XXX old animation system if (autokeyframe_cfra_can_key(ob)) { ID *id= &ob->id; @@ -881,6 +883,7 @@ void paste_posebuf (Scene *scene, int flip) if (chan->bone) chan->bone->flag |= BONE_UNKEYED; } +#endif // XXX old animation system } } } @@ -1513,6 +1516,7 @@ void pose_relax(Scene *scene) if (pchan->bone->layer & arm->layer) { if (pchan->bone->flag & BONE_SELECTED) { /* do we have an ipo curve? */ +#if 0 // XXX old animation system achan= get_action_channel(act, pchan->name); if (achan && achan->ipo) { @@ -1563,6 +1567,8 @@ void pose_relax(Scene *scene) /* apply BONE_TRANSFORM tag so that autokeying will pick it up */ pchan->bone->flag |= BONE_TRANSFORM; } + +#endif // XXX old animation system } } } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 4f67a31b8a3..e1455d7dfb0 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -46,7 +46,6 @@ #include "BLI_rand.h" #include "DNA_curve_types.h" -#include "DNA_ipo_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" @@ -59,7 +58,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BKE_key.h" #include "BKE_library.h" #include "BKE_global.h" @@ -77,7 +76,7 @@ /* still need to eradicate a few :( */ #define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name) -/* for curve objects in editmode that can have hidden handles - may use for IPO's later */ +/* for curve objects in editmode that can have hidden handles */ #define BEZSELECTED_HIDDENHANDLES(bezt) ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt)) /* XXX */ @@ -4456,6 +4455,7 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname) void default_curve_ipo(Scene *scene, Curve *cu) { +#if 0 // XXX old animation system IpoCurve *icu; BezTriple *bezt; @@ -4486,6 +4486,7 @@ void default_curve_ipo(Scene *scene, Curve *cu) bezt->h1= bezt->h2= HD_AUTO; calchandles_ipocurve(icu); +#endif // XXX old animation system } void add_primitiveCurve(Scene *scene, int stype) diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index e23f8500571..33ab06c0f67 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -50,7 +50,7 @@ #include "BKE_global.h" #include "BKE_utildefines.h" #include "BKE_blender.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -68,10 +68,10 @@ #include "gpencil_intern.h" /* XXX */ -static void actdata_filter() {} +static void actdata_filter() {} // is now ANIM_animdata_filter() static void BIF_undo_push() {} static void error() {} -static void *get_action_context() {return NULL;} +static void *get_action_context() {return NULL;} // is now ANIM_animdata_get_context() /* XXX */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 8b3d5df61ba..20c72c9f0e2 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -158,7 +158,7 @@ typedef enum eAnimFilter_Flags { ANIMFILTER_FOREDIT = (1<<2), /* does editable status matter */ ANIMFILTER_CHANNELS = (1<<3), /* do we only care that it is a channel */ ANIMFILTER_IPOKEYS = (1<<4), /* only channels referencing ipo's */ - ANIMFILTER_ONLYICU = (1<<5), /* only reference ipo-curves */ + ANIMFILTER_ONLYFCU = (1<<5), /* only reference ipo-curves */ ANIMFILTER_FORDRAWING = (1<<6), /* make list for interface drawing */ ANIMFILTER_ACTGROUPED = (1<<7), /* belongs to the active actiongroup */ } eAnimFilter_Flags; diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index eb6f422e425..77d41ace857 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -32,6 +32,7 @@ struct bAnimContext; struct Ipo; struct IpoCurve; +struct FCurve; struct BezTriple; struct Scene; @@ -130,12 +131,12 @@ void ANIM_editkeyframes_ipocurve_ipotype(struct IpoCurve *icu); /* ************************************************ */ /* Destructive Editing API (keyframes_general.c) */ -void delete_icu_key(struct IpoCurve *icu, int index, short do_recalc); +void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc); void delete_ipo_keys(struct Ipo *ipo); void duplicate_ipo_keys(struct Ipo *ipo); -void clean_ipo_curve(struct IpoCurve *icu, float thresh); -void smooth_ipo_curve(struct IpoCurve *icu, short mode); +void clean_fcurve(struct FCurve *fcu, float thresh); +void smooth_fcurve(struct FCurve *fcu, short mode); /* ************************************************ */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index fe456c7ea4b..e7bdbb86ffa 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -31,15 +31,10 @@ struct ListBase; struct ID; -struct Ipo; -struct IpoCurve; +struct FCurve; struct BezTriple; -/* ************ IPO/IPO-Curve Management ************** */ -// XXX these will need to be updated for RNA-IPO stuff - -struct Ipo *verify_ipo(struct ID *from, short blocktype, char actname[], char constname[], char bonename[], short add); -struct IpoCurve *verify_ipocurve(struct ID *from, short blocktype, char actname[], char constname[], char bonename[], int adrcode, short add); +struct wmOperatorType; /* ************ Keyframing Management **************** */ @@ -47,13 +42,13 @@ struct IpoCurve *verify_ipocurve(struct ID *from, short blocktype, char actname[ * Use this when validation of necessary animation data isn't necessary as it already * exists, and there is a beztriple that can be directly copied into the array. */ -int insert_bezt_icu(struct IpoCurve *icu, struct BezTriple *bezt); +int insert_bezt_fcurve(struct FCurve *fcu, struct BezTriple *bezt); /* Main Keyframing API call: * Use this when validation of necessary animation data isn't necessary as it * already exists. It will insert a keyframe using the current value being keyframed. */ -void insert_vert_icu(struct IpoCurve *icu, float x, float y, short flag); +void insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag); /* flags for use by keyframe creation/deletion calls */ @@ -78,21 +73,20 @@ enum { * Use this to create any necessary animation data, and then insert a keyframe * using the current value being keyframed, in the relevant place. Returns success. */ - // TODO: adapt this for new data-api -> this blocktype, etc. stuff is evil! -short insertkey(struct ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag); +short insertkey(struct ID *id, const char rna_path[], int array_index, float cfra, short flag); /* Main Keyframing API call: * Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case. */ -short deletekey(struct ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag); +short deletekey(struct ID *id, const char rna_path[], int array_index, float cfra, short flag); -/* Main Keyframe Management calls: +/* Main Keyframe Management operators: * These handle keyframes management from various spaces. They will handle the menus * required for each space. */ -void common_insertkey(const struct bContext *C); -void common_deletekey(const struct bContext *C); +void ANIM_OT_insert_keyframe(struct wmOperatorType *ot); +void ANIM_OT_delete_keyframe(struct wmOperatorType *ot); /* ************ Auto-Keyframing ********************** */ /* Notes: diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 75134a470d7..c8d8ece30dc 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -52,7 +52,6 @@ #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_ipo.h" #include "BKE_object.h" #include "BKE_utildefines.h" @@ -72,63 +71,6 @@ static int pupmenu() {return 0;} /* -------------- Get Active Constraint Data ---------------------- */ -ListBase *get_active_constraint_channels (Scene *scene, Object *ob, int forcevalid) -{ - char ipstr[64]; - - if (ob == NULL) - return NULL; - - /* See if we are a bone constraint */ - if (ob->flag & OB_POSEMODE) { - bActionChannel *achan; - bPoseChannel *pchan; - - pchan = get_active_posechannel(ob); - if (pchan) { - /* Make sure we have an action */ - if (ob->action == NULL) { - if (forcevalid == 0) - return NULL; - - ob->action= add_empty_action("Action"); - } - - /* Make sure we have an actionchannel */ - achan = get_action_channel(ob->action, pchan->name); - if (achan == NULL) { - if (forcevalid == 0) - return NULL; - - achan = MEM_callocN (sizeof(bActionChannel), "ActionChannel"); - - strcpy(achan->name, pchan->name); - sprintf(ipstr, "%s.%s", ob->action->id.name+2, achan->name); - ipstr[23]=0; - achan->ipo= add_ipo(scene, ipstr, ID_AC); - - BLI_addtail(&ob->action->chanbase, achan); - } - - return &achan->constraintChannels; - } - else - return NULL; - } - /* else we return object constraints */ - else { - if (ob->ipoflag & OB_ACTION_OB) { - bActionChannel *achan = get_action_channel(ob->action, "Object"); - if (achan) - return &achan->constraintChannels; - else - return NULL; - } - - return &ob->constraintChannels; - } -} - /* if object in posemode, active bone constraints, else object constraints */ ListBase *get_active_constraints (Object *ob) @@ -170,10 +112,9 @@ bConstraint *get_active_constraint (Object *ob) bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob) { bConstraint *con; - bConstraintChannel *chan; if (ob->flag & OB_POSEMODE) { - if (ob->action) { + //if (ob->action) { // XXX old animation system bPoseChannel *pchan; pchan = get_active_posechannel(ob); @@ -184,6 +125,7 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob) } if (con) { +#if 0 // XXX old animation system bActionChannel *achan = get_action_channel(ob->action, pchan->name); if (achan) { for (chan= achan->constraintChannels.first; chan; chan= chan->next) { @@ -192,9 +134,10 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob) } return chan; } +#endif // XXX old animation system } } - } + //} // xxx old animation system } else { for (con= ob->constraints.first; con; con= con->next) { @@ -203,6 +146,7 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob) } if (con) { +#if 0 // XXX old animation system ListBase *lb= get_active_constraint_channels(scene, ob, 0); if (lb) { @@ -213,6 +157,7 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob) return chan; } +#endif // XXX old animation system } } @@ -645,7 +590,6 @@ void ob_clear_constraints (Scene *scene) void rename_constraint (Object *ob, bConstraint *con, char *oldname) { bConstraint *tcon; - bConstraintChannel *conchan; ListBase *conlist= NULL; int from_object= 0; char *channame=""; @@ -686,24 +630,6 @@ void rename_constraint (Object *ob, bConstraint *con, char *oldname) /* first make sure it's a unique name within context */ unique_constraint_name (con, conlist); - - /* own channels */ - if (from_object) { - for (conchan= ob->constraintChannels.first; conchan; conchan= conchan->next) { - if ( strcmp(oldname, conchan->name)==0 ) - BLI_strncpy(conchan->name, con->name, sizeof(conchan->name)); - } - } - - /* own action */ - if (ob->action) { - bActionChannel *achan= get_action_channel(ob->action, channame); - if (achan) { - conchan= get_constraint_channel(&achan->constraintChannels, oldname); - if (conchan) - BLI_strncpy(conchan->name, con->name, sizeof(conchan->name)); - } - } } diff --git a/source/blender/editors/object/editkey.c b/source/blender/editors/object/editkey.c index 20e2dbebe2e..913046c5ab8 100644 --- a/source/blender/editors/object/editkey.c +++ b/source/blender/editors/object/editkey.c @@ -77,6 +77,7 @@ static void BIF_undo_push() {} static void error() {} /* XXX */ +#if 0 // XXX old animation system static void default_key_ipo(Scene *scene, Key *key) { IpoCurve *icu; @@ -108,7 +109,7 @@ static void default_key_ipo(Scene *scene, Key *key) calchandles_ipocurve(icu); } - +#endif // XXX old animation system /* **************************************** */ @@ -170,10 +171,11 @@ static KeyBlock *add_keyblock(Scene *scene, Key *key) key->totkey++; if(key->totkey==1) key->refkey= kb; - + // XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor... if(key->type == KEY_RELATIVE) kb->pos= curpos+0.1; else { +#if 0 // XXX old animation system curpos= bsystem_time(scene, 0, (float)CFRA, 0.0); if(calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) { curpos /= 100.0; @@ -181,6 +183,7 @@ static KeyBlock *add_keyblock(Scene *scene, Key *key) kb->pos= curpos; sort_keys(key); +#endif // XXX old animation system } return kb; } @@ -195,8 +198,8 @@ void insert_meshkey(Scene *scene, Mesh *me, short rel) if(rel) me->key->type = KEY_RELATIVE; - else - default_key_ipo(scene, me->key); +// else +// default_key_ipo(scene, me->key); // XXX old animation system } key= me->key; @@ -254,7 +257,7 @@ void insert_lattkey(Scene *scene, Lattice *lt, short rel) if(lt->key==NULL) { lt->key= add_key( (ID *)lt); - default_key_ipo(scene, lt->key); +// default_key_ipo(scene, lt->key); // XXX old animation system } key= lt->key; @@ -377,8 +380,8 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel) if (rel) cu->key->type = KEY_RELATIVE; - else - default_key_ipo(scene, cu->key); +// else +// default_key_ipo(scene, cu->key); // XXX old animation system } key= cu->key; @@ -414,7 +417,7 @@ void delete_key(Scene *scene, Object *ob) { KeyBlock *kb, *rkb; Key *key; - IpoCurve *icu; + //IpoCurve *icu; key= ob_get_key(ob); if(key==NULL) return; @@ -438,6 +441,7 @@ void delete_key(Scene *scene, Object *ob) kb->adrcode--; } +#if 0 // XXX old animation system if(key->ipo) { for(icu= key->ipo->curve.first; icu; icu= icu->next) { @@ -450,7 +454,8 @@ void delete_key(Scene *scene, Object *ob) for(icu= key->ipo->curve.first; icu; icu= icu->next) if(icu->adrcode>=ob->shapenr) icu->adrcode--; - } + } +#endif // XXX old animation system if(ob->shapenr>1) ob->shapenr--; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 7aab8bf8365..2f0f224b033 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -41,7 +41,6 @@ #include "DNA_effect_types.h" #include "DNA_group_types.h" #include "DNA_image_types.h" -#include "DNA_ipo_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" @@ -89,7 +88,6 @@ #include "BKE_font.h" #include "BKE_global.h" #include "BKE_group.h" -#include "BKE_ipo.h" #include "BKE_image.h" #include "BKE_key.h" #include "BKE_lattice.h" @@ -432,8 +430,10 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag) Object *ob; Material *ma, *mao; ID *id; +#if 0 // XXX old animation system Ipo *ipo; bActionStrip *strip; +#endif // XXX old animation system int a; /* check object pointers */ @@ -453,11 +453,13 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag) ID_NEW(ob->proxy); ID_NEW(ob->proxy_group); +#if 0 // XXX old animation system for(strip= ob->nlastrips.first; strip; strip= strip->next) { bActionModifier *amod; for(amod= strip->modifiers.first; amod; amod= amod->next) ID_NEW(amod->ob); } +#endif // XXX old animation system } } @@ -481,17 +483,20 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag) } } } +#if 0 // XXX old animation system id= (ID *)ma->ipo; if(id) { ID_NEW_US(ma->ipo) else ma->ipo= copy_ipo(ma->ipo); id->us--; } +#endif // XXX old animation system } mao= mao->id.next; } } +#if 0 // XXX old animation system /* lamps */ if( dupflag & USER_DUP_IPO) { Lamp *la= G.main->lamp.first; @@ -523,6 +528,7 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag) } ipo= ipo->id.next; } +#endif // XXX old animation system set_sca_new_poins(); @@ -1191,7 +1197,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /* ****** selection by links *******/ static EnumPropertyItem prop_select_linked_types[] = { - {1, "IPO", "Object IPO", ""}, + {1, "IPO", "Object IPO", ""}, // XXX depreceated animation system stuff... {2, "OBDATA", "Ob Data", ""}, {3, "MATERIAL", "Material", ""}, {4, "TEXTURE", "Texture", ""}, @@ -1205,7 +1211,6 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *ob; void *obdata = NULL; - Ipo *ipo = NULL; Material *mat = NULL, *mat1; Tex *tex=0; int a, b; @@ -1224,9 +1229,11 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) ob= OBACT; if(ob==0) return OPERATOR_CANCELLED; - if(nr==1) { - ipo= ob->ipo; - if(ipo==0) return OPERATOR_CANCELLED; + if(nr==1) { + // XXX old animation system + //ipo= ob->ipo; + //if(ipo==0) return OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; } else if(nr==2) { if(ob->data==0) return OPERATOR_CANCELLED; @@ -1251,8 +1258,9 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, visible_bases) { if (!(base->flag & SELECT)) { if(nr==1) { - if(base->object->ipo==ipo) base->flag |= SELECT; - changed = 1; + // XXX old animation system + //if(base->object->ipo==ipo) base->flag |= SELECT; + //changed = 1; } else if(nr==2) { if(base->object->data==obdata) base->flag |= SELECT; @@ -2076,12 +2084,6 @@ void make_proxy(Scene *scene) /* ******************** make parent operator *********************** */ -#if 0 -oldcode() -{ -} -#endif - #define PAR_OBJECT 0 #define PAR_ARMATURE 1 #define PAR_BONE 2 @@ -4422,10 +4424,6 @@ void copy_attr(Scene *scene, View3D *v3d, short event) else if(event==22) { /* Copy the constraint channels over */ copy_constraints(&base->object->constraints, &ob->constraints); - if (U.dupflag& USER_DUP_IPO) - copy_constraint_channels(&base->object->constraintChannels, &ob->constraintChannels); - else - clone_constraint_channels (&base->object->constraintChannels, &ob->constraintChannels); do_scene_sort= 1; } @@ -4440,7 +4438,9 @@ void copy_attr(Scene *scene, View3D *v3d, short event) } } else if(event==26) { +#if 0 // XXX old animation system copy_nlastrips(&base->object->nlastrips, &ob->nlastrips); +#endif // XXX old animation system } else if(event==27) { /* autosmooth */ if (base->object->type==OB_MESH) { @@ -4657,12 +4657,14 @@ void make_links(Scene *scene, View3D *v3d, short event) } } else if(event==4) { /* ob ipo */ +#if 0 // XXX old animation system if(obt->ipo) obt->ipo->id.us--; obt->ipo= ob->ipo; if(obt->ipo) { id_us_plus((ID *)obt->ipo); do_ob_ipo(scene, obt); } +#endif // XXX old animation system } else if(event==6) { if(ob->dup_group) ob->dup_group->id.us--; @@ -5044,7 +5046,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) Object *ob; Lamp *la; Curve *cu; - Camera *cam; + //Camera *cam; Base *base; Mesh *me; ID *id; @@ -5074,8 +5076,8 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) break; case OB_MESH: me= ob->data= copy_mesh(ob->data); - if(me && me->key) - ipo_idnew(me->key->ipo); /* drivers */ + //if(me && me->key) + // ipo_idnew(me->key->ipo); /* drivers */ break; case OB_MBALL: ob->data= copy_mball(ob->data); @@ -5106,6 +5108,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) } +#if 0 // XXX old animation system id= (ID *)ob->action; if (id && id->us>1 && id->lib==NULL){ if(id->newid){ @@ -5150,7 +5153,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) } break; } - +#endif // XXX old animation system } } @@ -5163,6 +5166,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) void single_ipo_users(Scene *scene, View3D *v3d, int flag) { +#if 0 // XXX old animation system Object *ob; Base *base; ID *id; @@ -5180,6 +5184,7 @@ void single_ipo_users(Scene *scene, View3D *v3d, int flag) } } } +#endif // XXX old animation system } void single_mat_users(Scene *scene, View3D *v3d, int flag) @@ -5205,12 +5210,14 @@ void single_mat_users(Scene *scene, View3D *v3d, int flag) man->id.us= 0; assign_material(ob, man, a); - + +#if 0 // XXX old animation system if(ma->ipo) { man->ipo= copy_ipo(ma->ipo); ma->ipo->id.us--; ipo_idnew(ma->ipo); /* drivers */ } +#endif // XXX old animation system for(b=0; b<MAX_MTEX; b++) { if(ma->mtex[b] && ma->mtex[b]->tex) { @@ -5394,7 +5401,7 @@ void single_user(Scene *scene, View3D *v3d) /* helper for below, ma was checked to be not NULL */ static void make_local_makelocalmaterial(Material *ma) { - ID *id; + //ID *id; int b; make_local_material(ma); @@ -5405,8 +5412,10 @@ static void make_local_makelocalmaterial(Material *ma) } } +#if 0 // XXX old animation system id= (ID *)ma->ipo; - if(id && id->lib) make_local_ipo(ma->ipo); + if(id && id->lib) make_local_ipo(ma->ipo); +#endif // XXX old animation system /* nodetree? XXX */ } @@ -5415,7 +5424,7 @@ void make_local(Scene *scene, View3D *v3d, int mode) { Base *base; Object *ob; - bActionStrip *strip; + //bActionStrip *strip; ParticleSystem *psys; Material *ma, ***matarar; Lamp *la; @@ -5467,9 +5476,10 @@ void make_local(Scene *scene, View3D *v3d, int mode) make_local_lamp((Lamp *)id); la= ob->data; +#if 0 // XXX old animation system id= (ID *)la->ipo; if(id && id->lib) make_local_ipo(la->ipo); - +#endif // XXX old animation system break; case OB_CAMERA: make_local_camera((Camera *)id); @@ -5486,8 +5496,10 @@ void make_local(Scene *scene, View3D *v3d, int mode) case OB_FONT: cu= (Curve *)id; make_local_curve(cu); +#if 0 // XXX old animation system id= (ID *)cu->ipo; if(id && id->lib) make_local_ipo(cu->ipo); +#endif // XXX old animation system make_local_key( cu->key ); break; case OB_LATTICE: @@ -5502,6 +5514,8 @@ void make_local(Scene *scene, View3D *v3d, int mode) for(psys=ob->particlesystem.first; psys; psys=psys->next) make_local_particlesettings(psys->part); } + +#if 0 // XXX old animation system id= (ID *)ob->ipo; if(id && id->lib) make_local_ipo(ob->ipo); @@ -5512,6 +5526,7 @@ void make_local(Scene *scene, View3D *v3d, int mode) if(strip->act && strip->act->id.lib) make_local_action(strip->act); } +#endif // XXX old animation system } } @@ -5622,7 +5637,7 @@ void adduplicate(Scene *scene, View3D *v3d, int mode, int dupflag) if(BASACT==base) BASACT= basen; /* duplicates using userflags */ - +#if 0 // XXX old animation system if(dupflag & USER_DUP_IPO) { bConstraintChannel *chan; id= (ID *)obn->ipo; @@ -5652,6 +5667,7 @@ void adduplicate(Scene *scene, View3D *v3d, int mode, int dupflag) id->us--; } } +#endif // XXX old animation system if(dupflag & USER_DUP_MAT) { for(a=0; a<obn->totcol; a++) { id= (ID *)obn->mat[a]; @@ -5862,6 +5878,7 @@ void image_aspect(Scene *scene, View3D *v3d) void set_ob_ipoflags(Scene *scene, View3D *v3d) { +#if 0 // XXX old animation system Base *base; int set= 1; @@ -5897,10 +5914,13 @@ void set_ob_ipoflags(Scene *scene, View3D *v3d) allqueue (REDRAWACTION, 0); // allspace(REMAKEIPO, 0); allqueue(REDRAWIPO, 0); +#endif // XXX old animation system } + void select_select_keys(Scene *scene, View3D *v3d) { +#if 0 // XXX old animation system Base *base; IpoCurve *icu; BezTriple *bezt; @@ -5943,7 +5963,7 @@ void select_select_keys(Scene *scene, View3D *v3d) allqueue(REDRAWIPO, 0); BIF_undo_push("Select keys"); - +#endif // XXX old animation system } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 2e1e9845701..d10f3730318 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -120,6 +120,8 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_verify_item(keymap, "OBJECT_OT_object_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith + WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe", IKEY, KM_PRESS, KM_ALT, 0); } diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a1d4c09b9eb..6e19982c7c7 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -41,12 +41,11 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" -#include "DNA_listBase.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_curve_types.h" -#include "DNA_ipo_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_scene_types.h" @@ -64,7 +63,7 @@ #include "BKE_action.h" #include "BKE_depsgraph.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BKE_key.h" #include "BKE_material.h" #include "BKE_object.h" @@ -110,11 +109,12 @@ 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; + //Ipo *ipo= (Ipo *)ale->key_data; // XXX fixme float tmin, tmax; /* get range and apply necessary scaling before */ - calc_ipo_range(ipo, &tmin, &tmax); + //calc_ipo_range(ipo, &tmin, &tmax); + tmin= tmax= 0.0f; // xxx if (nob) { tmin= get_action_frame_inv(nob, tmin); @@ -258,6 +258,7 @@ void free_actcopybuf () bActionChannel *achan, *anext; bConstraintChannel *conchan, *cnext; +#if 0 // XXX old animation system for (achan= actcopybuf.first; achan; achan= anext) { anext= achan->next; @@ -279,6 +280,7 @@ void free_actcopybuf () BLI_freelinkN(&actcopybuf, achan); } +#endif // XXX old animation system actcopybuf.first= actcopybuf.last= NULL; actcopy_firstframe= 999999999.0f; @@ -353,7 +355,7 @@ static short copy_action_keys (bAnimContext *ac) for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) { if (BEZSELECTED(bezt)) { /* add to buffer ipo-curve */ - insert_bezt_icu(icn, bezt); + //insert_bezt_icu(icn, bezt); // XXX /* check if this is the earliest frame encountered so far */ if (bezt->vec[1][0] < actcopy_firstframe) @@ -454,7 +456,8 @@ static short paste_action_keys (bAnimContext *ac) /* loop over curves, pasting keyframes */ for (ico= ipo_src->curve.first; ico; ico= ico->next) { /* get IPO-curve to paste to (IPO-curve might not exist for destination, so gets created) */ - icu= verify_ipocurve(ale->id, ico->blocktype, actname, conname, NULL, ico->adrcode, 1); + //icu= verify_ipocurve(ale->id, ico->blocktype, actname, conname, NULL, ico->adrcode, 1); + if (icu) { /* just start pasting, with the the first keyframe on the current frame, and so on */ @@ -465,7 +468,7 @@ static short paste_action_keys (bAnimContext *ac) bezt->vec[2][0] += offset; /* insert the keyframe */ - insert_bezt_icu(icu, bezt); + //insert_bezt_icu(icu, bezt); // XXX /* un-apply offset from src beztriple after copying */ bezt->vec[0][0] -= offset; @@ -474,7 +477,7 @@ static short paste_action_keys (bAnimContext *ac) } /* recalculate channel's handles? */ - calchandles_ipocurve(icu); + //calchandles_fcurve(fcu); } } } @@ -600,7 +603,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); + // delete_ipo_keys((Ipo *)ale->key_data); // XXX fixme for the new animsys... } /* free filtered list */ @@ -652,12 +655,12 @@ static void clean_action_keys (bAnimContext *ac, float thresh) int filter; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and clean curves */ for (ale= anim_data.first; ale; ale= ale->next) - clean_ipo_curve((IpoCurve *)ale->key_data, thresh); + clean_fcurve((FCurve *)ale->key_data, thresh); /* free temp data */ BLI_freelistN(&anim_data); @@ -724,19 +727,19 @@ static void sample_action_keys (bAnimContext *ac) int filter; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ for (ale= anim_data.first; ale; ale= ale->next) { - IpoCurve *icu= (IpoCurve *)ale->key_data; + FCurve *fcu= (FCurve *)ale->key_data; BezTriple *bezt, *start=NULL, *end=NULL; tempFrameValCache *value_cache, *fp; int sfra, range; int i, n; /* find selected keyframes... once pair has been found, add keyframes */ - for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) { + for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if selected, and which end this is */ if (BEZSELECTED(bezt)) { if (start) { @@ -755,19 +758,19 @@ static void sample_action_keys (bAnimContext *ac) /* sample values */ for (n=0, fp=value_cache; n<range && fp; n++, fp++) { fp->frame= (float)(sfra + n); - fp->val= eval_icu(icu, fp->frame); + fp->val= evaluate_fcurve(fcu, fp->frame); } /* add keyframes with these */ for (n=0, fp=value_cache; n<range && fp; n++, fp++) { - insert_vert_icu(icu, fp->frame, fp->val, 1); + insert_vert_fcurve(fcu, fp->frame, fp->val, 1); } /* free temp cache */ MEM_freeN(value_cache); /* as we added keyframes, we need to compensate so that bezt is at the right place */ - bezt = icu->bezt + i + range - 1; + bezt = fcu->bezt + i + range - 1; i += (range - 1); } @@ -784,7 +787,7 @@ static void sample_action_keys (bAnimContext *ac) } /* recalculate channel's handles? */ - calchandles_ipocurve(icu); + calchandles_fcurve(fcu); } /* admin and redraws */ @@ -1028,11 +1031,11 @@ static void sethandles_action_keys(bAnimContext *ac, short mode) toggle_cb= ANIM_editkeyframes_handles(HD_ALIGN); /* set handle-type */ - ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, toggle_cb, calchandles_ipocurve); + ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, toggle_cb, calchandles_fcurve); } else { /* directly set handle-type */ - ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, calchandles_ipocurve); + ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); } } @@ -1183,7 +1186,7 @@ static void snap_action_keys(bAnimContext *ac, short mode) if (ac->datatype == ANIMCONT_GPENCIL) filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); /* get beztriple editing callbacks */ @@ -1198,13 +1201,13 @@ static void snap_action_keys(bAnimContext *ac, short mode) if (nob) { ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1); - ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve); + ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); else - ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve); + ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); } BLI_freelistN(&anim_data); } @@ -1304,7 +1307,7 @@ static void mirror_action_keys(bAnimContext *ac, short mode) if (ac->datatype == ANIMCONT_GPENCIL) filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); /* mirror keyframes */ @@ -1313,13 +1316,13 @@ static void mirror_action_keys(bAnimContext *ac, short mode) if (nob) { ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1); - ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve); + ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); else - ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve); + ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); } BLI_freelistN(&anim_data); } diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index a8a2a56887f..f3a9ceb21ba 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -91,6 +91,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) { /* action_select.c - selection tools */ /* click-select */ + // TODO: column to alt, left-right to ctrl (for select-linked consistency) WM_keymap_add_item(keymap, "ACT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ACT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "column_select", 1); RNA_boolean_set(WM_keymap_add_item(keymap, "ACT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend_select", 1); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 7932690e1ff..58574df7788 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -38,12 +38,11 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" -#include "DNA_listBase.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_curve_types.h" -#include "DNA_ipo_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_scene_types.h" @@ -61,7 +60,7 @@ #include "BKE_action.h" #include "BKE_depsgraph.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BKE_key.h" #include "BKE_material.h" #include "BKE_object.h" @@ -662,7 +661,7 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) if (ac->datatype == ANIMCONT_GPENCIL) filter= (ANIMFILTER_VISIBLE); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); for (ale= anim_data.first; ale; ale= ale->next) { @@ -1011,7 +1010,7 @@ static void mouse_columnselect_action_keys (bAnimContext *ac, float selx) if (ac->datatype == ANIMCONT_GPENCIL) filter= (ANIMFILTER_VISIBLE); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); for (ale= anim_data.first; ale; ale= ale->next) { diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 9fa045830ab..16372791736 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -64,7 +64,6 @@ #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_object.h" -#include "BKE_ipo.h" #include "BKE_utildefines.h" #include "BIF_gl.h" @@ -1742,7 +1741,7 @@ static void draw_pose_channels(Scene *scene, View3D *v3d, Base *base, int dt) /* extra draw service for pose mode */ constflag= pchan->constflag; - if (pchan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE)) + if (pchan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE)) // XXX this is useless crap constflag |= PCHAN_HAS_ACTION; if (pchan->flag & POSE_STRIDE) constflag |= PCHAN_HAS_STRIDE; @@ -2025,7 +2024,7 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, Object *ob) { bArmature *arm= ob->data; bPoseChannel *pchan; - bAction *act; + bAction *act; // XXX old animsys - watch it! bActionChannel *achan; ActKeyColumn *ak; ListBase keys; @@ -2173,12 +2172,15 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, Object *ob) if (arm->pathflag & ARM_PATH_KFRAS) { /* build list of all keyframes in active action for pchan */ keys.first = keys.last = NULL; + + #if 0 // XXX old animation system act= ob->action; if (act) { achan= get_action_channel(act, pchan->name); if (achan) ipo_to_keylist(achan->ipo, &keys, NULL, NULL); } + #endif // XXX old animation system /* Draw slightly-larger yellow dots at each keyframe */ UI_ThemeColor(TH_VERTEX_SELECT); @@ -2294,7 +2296,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, Base *base) colfac = (end-CFRA)/range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0f*sqrt(colfac))); - do_all_pose_actions(scene, ob); + //do_all_pose_actions(scene, ob); // XXX old animation system where_is_pose(scene, ob); draw_pose_channels(scene, v3d, base, OB_WIRE); } @@ -2319,14 +2321,14 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, Base *base) static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base) { Object *ob= base->object; - bAction *act= ob->action; + bAction *act= ob->action; // XXX old animsys stuff... watch it! bArmature *arm= ob->data; bPose *posen, *poseo; ListBase keys= {NULL, NULL}; ActKeysInc aki = {0, 0, 0}; ActKeyColumn *ak, *akn; float start, end, range, colfac, i; - int cfrao, flago, ipoflago; + int cfrao, flago; aki.start= start = arm->ghostsf; aki.end= end = arm->ghostef; @@ -2351,7 +2353,6 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base) cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); - ipoflago= ob->ipoflag; ob->ipoflag |= OB_DISABLE_PATH; /* copy the pose */ @@ -2371,7 +2372,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base) CFRA= (int)ak->cfra; - do_all_pose_actions(scene, ob); + //do_all_pose_actions(scene, ob); // XXX old animation system where_is_pose(scene, ob); draw_pose_channels(scene, v3d, base, OB_WIRE); } @@ -2388,7 +2389,6 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base) arm->flag= flago; armature_rebuild_pose(ob, ob->data); ob->flag |= OB_POSEMODE; - ob->ipoflag= ipoflago; } /* draw ghosts around current frame @@ -2399,13 +2399,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base) Object *ob= base->object; bArmature *arm= ob->data; bPose *posen, *poseo; - bActionStrip *strip; + //bActionStrip *strip; float cur, start, end, stepsize, range, colfac, actframe, ctime; - int cfrao, maptime, flago, ipoflago; + int cfrao, maptime, flago; /* pre conditions, get an action with sufficient frames */ - if (ob->action==NULL) - return; + //if (ob->action==NULL) + // return; calc_action_range(ob->action, &start, &end, 0); if (start == end) @@ -2414,12 +2414,15 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base) stepsize= (float)(arm->ghostsize); range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */ +#if 0 // XXX old animation system /* we only map time for armature when an active strip exists */ for (strip=ob->nlastrips.first; strip; strip=strip->next) if (strip->flag & ACTSTRIP_ACTIVE) break; +#endif // XXX old animsys - maptime= (strip!=NULL); + //maptime= (strip!=NULL); + maptime= 0; /* store values */ ob->flag &= ~OB_POSEMODE; @@ -2428,8 +2431,6 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base) else actframe= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); - ipoflago= ob->ipoflag; - ob->ipoflag |= OB_DISABLE_PATH; /* copy the pose */ poseo= ob->pose; @@ -2453,7 +2454,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base) else CFRA= (int)floor(actframe+ctime); if (CFRA!=cfrao) { - do_all_pose_actions(scene, ob); + //do_all_pose_actions(scene, ob); // xxx old animation system crap where_is_pose(scene, ob); draw_pose_channels(scene, v3d, base, OB_WIRE); } @@ -2469,7 +2470,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base) else CFRA= (int)floor(actframe-ctime); if (CFRA != cfrao) { - do_all_pose_actions(scene, ob); + //do_all_pose_actions(scene, ob); // XXX old animation system crap... where_is_pose(scene, ob); draw_pose_channels(scene, v3d, base, OB_WIRE); } @@ -2487,7 +2488,6 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base) arm->flag= flago; armature_rebuild_pose(ob, ob->data); ob->flag |= OB_POSEMODE; - ob->ipoflag= ipoflago; } /* ********************************** Armature Drawing - Main ************************* */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 8282e021dad..7a01e1ada7a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -46,7 +46,6 @@ #include "DNA_curve_types.h" #include "DNA_constraint_types.h" // for drawing constraint #include "DNA_effect_types.h" -#include "DNA_ipo_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" @@ -82,7 +81,6 @@ #include "BKE_font.h" #include "BKE_global.h" #include "BKE_image.h" -#include "BKE_ipo.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_mesh.h" @@ -3040,7 +3038,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part pa_time=(cfra-pa->time)/pa->lifetime; pa_size=pa->size; - if((part->flag&PART_ABS_TIME)==0){ + if((part->flag&PART_ABS_TIME)==0){ +#if 0 // XXX old animation system if(ma && ma->ipo){ IpoCurve *icu; @@ -3067,6 +3066,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part pa_size = icu->curval; } } +#endif // XXX old animation system } r_tilt=1.0f+pa->r_ave[0]; @@ -3083,6 +3083,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part if((part->flag&PART_ABS_TIME)==0) { if(ma && ma->ipo){ +#if 0 // XXX old animation system IpoCurve *icu; /* correction for lifetime */ @@ -3096,6 +3097,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part else if(icu->adrcode == MA_COL_B) ma_b = icu->curval; } +#endif // XXX old animation system } } @@ -4009,6 +4011,7 @@ static void draw_empty_cone (float size) /* draw points on curve speed handles */ static void curve_draw_speed(Scene *scene, Object *ob) { +#if 0 // XXX old animation system stuff Curve *cu= ob->data; IpoCurve *icu; BezTriple *bezt; @@ -4034,6 +4037,7 @@ static void curve_draw_speed(Scene *scene, Object *ob) glPointSize(1.0); bglEnd(); +#endif // XXX old animation system stuff } @@ -4267,9 +4271,9 @@ static void draw_forcefield(Scene *scene, Object *ob) Mat4One(tmat); UI_ThemeColorBlend(curcol, TH_BACK, 0.5); - if (has_ipo_code(ob->ipo, OB_PD_FSTR)) - force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); - else + //if (has_ipo_code(ob->ipo, OB_PD_FSTR)) + // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); + //else force_val = pd->f_strength; force_val*= 0.1; drawcircball(GL_LINE_LOOP, vec, size, tmat); @@ -4285,9 +4289,9 @@ static void draw_forcefield(Scene *scene, Object *ob) else if (pd->forcefield == PFIELD_FORCE) { float ffall_val; - if (has_ipo_code(ob->ipo, OB_PD_FFALL)) - ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra); - else + //if (has_ipo_code(ob->ipo, OB_PD_FFALL)) + // ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra); + //else ffall_val = pd->f_power; UI_ThemeColorBlend(curcol, TH_BACK, 0.5); @@ -4301,14 +4305,14 @@ static void draw_forcefield(Scene *scene, Object *ob) float ffall_val, force_val; Mat4One(tmat); - if (has_ipo_code(ob->ipo, OB_PD_FFALL)) - ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra); - else + //if (has_ipo_code(ob->ipo, OB_PD_FFALL)) + // ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra); + //else ffall_val = pd->f_power; - if (has_ipo_code(ob->ipo, OB_PD_FSTR)) - force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); - else + //if (has_ipo_code(ob->ipo, OB_PD_FSTR)) + // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); + //else force_val = pd->f_strength; UI_ThemeColorBlend(curcol, TH_BACK, 0.7); @@ -4326,9 +4330,9 @@ static void draw_forcefield(Scene *scene, Object *ob) if((cu->flag & CU_PATH) && cu->path && cu->path->data) { float mindist, guidevec1[4], guidevec2[3]; - if (has_ipo_code(ob->ipo, OB_PD_FSTR)) - mindist = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); - else + //if (has_ipo_code(ob->ipo, OB_PD_FSTR)) + // mindist = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); + //else mindist = pd->f_strength; /*path end*/ @@ -4697,10 +4701,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) static int warning_recursive= 0; Object *ob; Curve *cu; - float cfraont; + //float cfraont; float vec1[3], vec2[3]; unsigned int col=0; - int sel, drawtype, colindex= 0, ipoflag; + int /*sel, drawtype,*/ colindex= 0; int i, selstart, selend, empty_object=0; short dt, dtx, zbufoff= 0; @@ -4728,6 +4732,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw keys? */ +#if 0 // XXX old animation system if(base==(scene->basact) || (base->flag & (SELECT+BA_WAS_SEL))) { if(flag==0 && warning_recursive==0 && ob!=scene->obedit) { if(ob->ipo && ob->ipo->showkey && (ob->ipoflag & OB_DRAWKEY)) { @@ -4800,6 +4805,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } } +#endif // XXX old animation system /* patch? children objects with a timeoffs change the parents. How to solve! */ /* if( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index d85be9406d7..618d30eea60 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -802,7 +802,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) } /* colour depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, frame_to_float(scene, CFRA), v3d->keyflags)) + if (id_frame_has_keyframe((ID *)ob, /*frame_to_float(scene, CFRA)*/(float)(CFRA), v3d->keyflags)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d69f318aa3f..d8421bb7a60 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -37,13 +37,13 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_curve_types.h" #include "DNA_effect_types.h" #include "DNA_image_types.h" -#include "DNA_ipo_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" @@ -81,8 +81,8 @@ #include "BKE_DerivedMesh.h" #include "BKE_effect.h" #include "BKE_font.h" +#include "BKE_fcurve.h" #include "BKE_global.h" -#include "BKE_ipo.h" #include "BKE_lattice.h" #include "BKE_key.h" #include "BKE_main.h" @@ -2698,16 +2698,16 @@ static void posttrans_gpd_clean (bGPdata *gpd) /* Called during special_aftertrans_update to make sure selected keyframes replace * any other keyframes which may reside on that frame (that is not selected). */ -static void posttrans_icu_clean (IpoCurve *icu) +static void posttrans_fcurve_clean (FCurve *fcu) { float *selcache; /* cache for frame numbers of selected frames (icu->totvert*sizeof(float)) */ int len, index, i; /* number of frames in cache, item index */ /* allocate memory for the cache */ // TODO: investigate using GHash for this instead? - if (icu->totvert == 0) + if (fcu->totvert == 0) return; - selcache= MEM_callocN(sizeof(float)*icu->totvert, "IcuSelFrameNums"); + selcache= MEM_callocN(sizeof(float)*fcu->totvert, "FCurveSelFrameNums"); len= 0; index= 0; @@ -2717,8 +2717,8 @@ static void posttrans_icu_clean (IpoCurve *icu) */ /* Loop 1: find selected keyframes */ - for (i = 0; i < icu->totvert; i++) { - BezTriple *bezt= &icu->bezt[i]; + for (i = 0; i < fcu->totvert; i++) { + BezTriple *bezt= &fcu->bezt[i]; if (BEZSELECTED(bezt)) { selcache[index]= bezt->vec[1][0]; @@ -2729,14 +2729,14 @@ static void posttrans_icu_clean (IpoCurve *icu) /* Loop 2: delete unselected keyframes on the same frames (if any keyframes were found) */ if (len) { - for (i = 0; i < icu->totvert; i++) { - BezTriple *bezt= &icu->bezt[i]; + for (i = 0; i < fcu->totvert; i++) { + BezTriple *bezt= &fcu->bezt[i]; if (BEZSELECTED(bezt) == 0) { /* check beztriple should be removed according to cache */ for (index= 0; index < len; index++) { if (IS_EQ(bezt->vec[1][0], selcache[index])) { - delete_icu_key(icu, i, 0); + //delete_icu_key(icu, i, 0); break; } else if (bezt->vec[1][0] > selcache[index]) @@ -2745,31 +2745,13 @@ static void posttrans_icu_clean (IpoCurve *icu) } } - testhandles_ipocurve(icu); + testhandles_fcurve(fcu); } /* free cache */ MEM_freeN(selcache); } -/* Called by special_aftertrans_update to make sure selected keyframes replace - * any other keyframes which may reside on that frame (that is not selected). - * remake_action_ipos should have already been called - */ -static void posttrans_ipo_clean (Ipo *ipo) -{ - IpoCurve *icu; - - if (ipo == NULL) - return; - - /* loop through relevant data, removing keyframes from the ipocurves - * - all keyframes are converted in/out of global time - */ - for (icu= ipo->curve.first; icu; icu= icu->next) { - posttrans_icu_clean(icu); - } -} /* Called by special_aftertrans_update to make sure selected keyframes replace * any other keyframes which may reside on that frame (that is not selected). @@ -2782,7 +2764,7 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act) int filter; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, act, ANIMCONT_ACTION); /* loop through relevant data, removing keyframes from the ipo-blocks that were attached @@ -2792,12 +2774,12 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act) Object *nob= ANIM_nla_mapping_get(ac, ale); if (nob) { - ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1); - posttrans_icu_clean(ale->key_data); - ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1); + //ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1); + posttrans_fcurve_clean(ale->key_data); + //ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1); } else - posttrans_icu_clean(ale->key_data); + posttrans_fcurve_clean(ale->key_data); } /* free temp data */ @@ -2820,16 +2802,16 @@ static short FrameOnMouseSide(char side, float frame, float cframe) } /* fully select selected beztriples, but only include if it's on the right side of cfra */ -static int count_icu_keys(IpoCurve *icu, char side, float cfra) +static int count_fcurve_keys(FCurve *fcu, char side, float cfra) { BezTriple *bezt; int i, count = 0; - if (icu == NULL) + if (fcu == NULL) return count; /* only include points that occur on the right side of cfra */ - for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) { + for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { if (bezt->f2 & SELECT) { /* fully select the other two keys */ bezt->f1 |= SELECT; @@ -2885,15 +2867,15 @@ static void TimeToTransData(TransData *td, float *time, Object *ob) * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data * on the named side are used. */ -static TransData *IcuToTransData(TransData *td, IpoCurve *icu, Object *ob, char side, float cfra) +static TransData *FCurveToTransData(TransData *td, FCurve *fcu, Object *ob, char side, float cfra) { BezTriple *bezt; int i; - if (icu == NULL) + if (fcu == NULL) return td; - for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) { + for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { /* only add selected keyframes (for now, proportional edit is not enabled) */ if (BEZSELECTED(bezt)) { /* only add if on the right 'side' of the current frame */ @@ -2995,7 +2977,7 @@ static void createTransActionData(bContext *C, TransInfo *t) if (ac.datatype == ANIMCONT_GPENCIL) filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU); ANIM_animdata_filter(&anim_data, filter, ac.data, ac.datatype); /* which side of the current frame should be allowed */ @@ -3026,7 +3008,7 @@ static void createTransActionData(bContext *C, TransInfo *t) //if (ale->type == ANIMTYPE_GPLAYER) // count += count_gplayer_frames(ale->data, side, cfra); //else - count += count_icu_keys(ale->key_data, side, cfra); + count += count_fcurve_keys(ale->key_data, side, cfra); } /* stop if trying to build list if nothing selected */ @@ -3067,7 +3049,7 @@ static void createTransActionData(bContext *C, TransInfo *t) //} //else { Object *nob= ANIM_nla_mapping_get(&ac, ale); - IpoCurve *icu= (IpoCurve *)ale->key_data; + FCurve *fcu= (FCurve *)ale->key_data; /* convert current-frame to action-time (slightly less accurate, espcially under * higher scaling ratios, but is faster than converting all points) @@ -3077,7 +3059,7 @@ static void createTransActionData(bContext *C, TransInfo *t) else cfra = (float)CFRA; - td= IcuToTransData(td, icu, nob, side, cfra); + td= FCurveToTransData(td, fcu, nob, side, cfra); //} } @@ -3701,20 +3683,6 @@ void autokeyframe_pose_cb_func(Object *ob, int tmode, short targetless_ik) #endif } -/* very bad call!!! - copied from editnla.c! */ -static void recalc_all_ipos(void) -{ - Ipo *ipo; - IpoCurve *icu; - - /* Go to each ipo */ - for (ipo=G.main->ipo.first; ipo; ipo=ipo->id.next){ - for (icu = ipo->curve.first; icu; icu=icu->next){ - sort_time_ipocurve(icu); - testhandles_ipocurve(icu); - } - } -} /* inserting keys, refresh ipo-keys, pointcache, redraw events... (ton) */ /* note: transdata has been freed already! */ @@ -3761,7 +3729,7 @@ void special_aftertrans_update(TransInfo *t) if (ac.datatype == ANIMCONT_DOPESHEET) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU); + short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU); /* get channels to work on */ ANIM_animdata_filter(&anim_data, filter, ac.data, ac.datatype); @@ -3769,18 +3737,18 @@ void special_aftertrans_update(TransInfo *t) /* these should all be ipo-blocks */ for (ale= anim_data.first; ale; ale= ale->next) { Object *nob= ANIM_nla_mapping_get(&ac, ale); - IpoCurve *icu= (IpoCurve *)ale->key_data; + FCurve *fcu= (FCurve *)ale->key_data; if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { if (nob) { - ANIM_nla_mapping_apply_ipocurve(nob, icu, 0, 1); - posttrans_icu_clean(icu); - ANIM_nla_mapping_apply_ipocurve(nob, icu, 1, 1); + //ANIM_nla_mapping_apply_ipocurve(nob, icu, 0, 1); + posttrans_fcurve_clean(fcu); + //ANIM_nla_mapping_apply_ipocurve(nob, icu, 1, 1); } else - posttrans_icu_clean(icu); + posttrans_fcurve_clean(fcu); } } @@ -3810,6 +3778,7 @@ void special_aftertrans_update(TransInfo *t) /* fix up the Ipocurves and redraw stuff */ Key *key= (Key *)ac.data; +#if 0 // XXX old animation system if (key->ipo) { if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) @@ -3817,6 +3786,7 @@ void special_aftertrans_update(TransInfo *t) posttrans_ipo_clean(key->ipo); } } +#endif // XXX old animation system DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); } @@ -4206,12 +4176,14 @@ void createTransData(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_IPO) { t->flag |= T_POINTS|T_2D_EDIT; - createTransIpoData(C, t); + createTransIpoData(C, t); +#if 0 if (t->data && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 1); sort_trans_data_dist(t); } +#endif } else if(t->spacetype == SPACE_NODE) { t->flag |= T_2D_EDIT|T_POINTS; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index c7e9c06813c..08c4a2ff820 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -63,9 +63,6 @@ //#include "BIF_meshtools.h" #include "BIF_retopo.h" -//#include "BSE_editipo.h" -//#include "BSE_editipo_types.h" - #include "BKE_action.h" #include "BKE_anim.h" #include "BKE_armature.h" @@ -76,7 +73,6 @@ #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_group.h" -#include "BKE_ipo.h" #include "BKE_lattice.h" #include "BKE_key.h" #include "BKE_mesh.h" @@ -585,6 +581,7 @@ void recalcData(TransInfo *t) if(base->flag & BA_HAS_RECALC_DATA) ob->recalc |= OB_RECALC_DATA; +#if 0 // XXX old animation system /* thanks to ob->ctime usage, ipos are not called in where_is_object, unless we edit ipokeys */ if(base->flag & BA_DO_IPO) { @@ -600,6 +597,7 @@ void recalcData(TransInfo *t) } } } +#endif // XXX old animation system /* proxy exception */ if(ob->proxy) |