diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-04-26 10:33:04 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-04-26 10:33:04 +0400 |
commit | b5d28306d029acbeecc48afcabff7fdb321abdd8 (patch) | |
tree | d8ecfd493ce797813b35eea3a26173e0aa8870fb /source | |
parent | 7bf3add0a533c6efb291757bd5db3135092f4f0d (diff) |
Bugfix [#22069] Speed-Ipos are not imported correctly from 2.49 to 2.5
- IPO-blocks for curves were not getting handled correctly (i.e. no conversion and relinking was taking place) when converting from 2.4x to 2.5
- Old 'speed' IPO's now have their values multiplied by the path length when they are loaded from old 2.4x files so that they work correctly in 2.5.
Also...
- Cleaned up a few instances of scruffy code formatted in some weird ad-hoc way.
- Debug prints for the start/end of the file conversion process are now all hidden behind debug-only checks. Unless the way the conversions are done is significantly changed at some point, this should be sufficient...
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 113 |
1 files changed, 72 insertions, 41 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 50574f1ef7b..f96100bad06 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -849,19 +849,19 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co case ID_WO: /* world */ propname= world_adrcodes_to_paths(adrcode, &dummy_index); break; - + case ID_PA: /* particle */ propname= particle_adrcodes_to_paths(adrcode, &dummy_index); break; - /* XXX problematic blocktypes */ case ID_CU: /* curve */ /* this used to be a 'dummy' curve which got evaluated on the fly... * now we've got real var for this! */ propname= "eval_time"; break; - + + /* XXX problematic blocktypes */ case ID_SEQ: /* sequencer strip */ //SEQ_FAC1: switch (adrcode) { @@ -1112,7 +1112,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, int muteipo) +static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, int muteipo) { AdrBit2Path *abp; FCurve *fcu; @@ -1277,6 +1277,20 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha dst->vec[2][1] *= fac; } + /* correct values for path speed curves + * - their values were 0-1 + * - we now need as 'frames' + */ + if ( (id) && (icu->blocktype == GS(id->name)) && + (fcu->rna_path && strcmp(fcu->rna_path, "eval_time")==0) ) + { + Curve *cu = (Curve *)id; + + dst->vec[0][1] *= cu->pathlen; + dst->vec[1][1] *= cu->pathlen; + dst->vec[2][1] *= cu->pathlen; + } + /* correct times for rotation drivers * - need to go from degrees to radians... * - there's only really 1 target to worry about @@ -1312,7 +1326,7 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1343,7 +1357,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase if (icu->driver) { /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */ if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) { - icu_to_fcurves(NULL, drivers, icu, actname, constname, ipo->muteipo); + icu_to_fcurves(id, NULL, drivers, icu, actname, constname, ipo->muteipo); } else { MEM_freeN(icu->driver); @@ -1351,7 +1365,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase } } else - icu_to_fcurves(animgroups, anim, icu, actname, constname, ipo->muteipo); + icu_to_fcurves(id, animgroups, anim, icu, actname, constname, ipo->muteipo); } /* if this IPO block doesn't have any users after this one, free... */ @@ -1382,7 +1396,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase * to Objects, where ob->ipo and ob->action need to be combined). * NOTE: we need to be careful here, as same data-structs are used for new system too! */ -static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) +static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) { bActionChannel *achan, *achann; bConstraintChannel *conchan, *conchann; @@ -1403,7 +1417,7 @@ static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves, /* convert Action Channel's IPO data */ if (achan->ipo) { - ipo_to_animato(achan->ipo, achan->name, NULL, groups, curves, drivers); + ipo_to_animato(id, achan->ipo, achan->name, NULL, groups, curves, drivers); achan->ipo->id.us--; achan->ipo= NULL; } @@ -1415,7 +1429,7 @@ static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves, /* convert Constraint Channel's IPO data */ if (conchan->ipo) { - ipo_to_animato(conchan->ipo, achan->name, conchan->name, groups, curves, drivers); + ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, groups, curves, drivers); conchan->ipo->id.us--; conchan->ipo= NULL; } @@ -1460,7 +1474,7 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[]) * and the try to put these lists in the right places, but do not free the lists here */ // XXX there shouldn't be any need for the groups, so don't supply pointer for that now... - ipo_to_animato(ipo, actname, constname, NULL, &anim, &drivers); + ipo_to_animato(id, ipo, actname, constname, NULL, &anim, &drivers); /* deal with animation first */ if (anim.first) { @@ -1502,7 +1516,7 @@ static void action_to_animdata (ID *id, bAction *act) } /* convert Action data */ - action_to_animato(act, &adt->action->groups, &adt->action->curves, &adt->drivers); + action_to_animato(id, act, &adt->action->groups, &adt->action->curves, &adt->drivers); } /* ------------------------- */ @@ -1526,7 +1540,7 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) /* this old strip is only worth something if it had an action... */ if (as->act) { /* convert Action data (if not yet converted), storing the results in the same Action */ - action_to_animato(as->act, &as->act->groups, &as->act->curves, &adt->drivers); + action_to_animato(id, as->act, &as->act->groups, &as->act->curves, &adt->drivers); /* create a new-style NLA-strip which references this Action, then copy over relevant settings */ { @@ -1605,7 +1619,6 @@ void do_versions_ipos_to_animato(Main *main) ListBase drivers = {NULL, NULL}; ID *id; AnimData *adt; - Scene *scene; if (main == NULL) { printf("Argh! Main is NULL in do_versions_ipos_to_animato() \n"); @@ -1613,13 +1626,12 @@ void do_versions_ipos_to_animato(Main *main) } /* only convert if version is right */ - // XXX??? if (main->versionfile >= 250) { printf("WARNING: Animation data too new to convert (Version %d) \n", main->versionfile); return; } - else - printf("INFO: Converting to Animato... \n"); // xxx debug + else if (G.f & G_DEBUG) + printf("INFO: Converting to Animato... \n"); /* ----------- Animation Attached to Data -------------- */ @@ -1802,20 +1814,20 @@ void do_versions_ipos_to_animato(Main *main) } /* sequence strips */ - for(scene = main->scene.first; scene; scene = scene->id.next) { - if(scene->ed && scene->ed->seqbasep) { + for (id= main->scene.first; id; id= id->next) { + Scene *scene = (Scene *)id; + if (scene->ed && scene->ed->seqbasep) { Sequence * seq; - for(seq = scene->ed->seqbasep->first; - seq; seq = seq->next) { + for(seq = scene->ed->seqbasep->first; seq; seq = seq->next) { + IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; if (G.f & G_DEBUG) printf("\tconverting sequence strip %s \n", seq->name+2); - if (!seq->ipo || !seq->ipo->curve.first) { - seq->flag |= - SEQ_USE_EFFECT_DEFAULT_FADE; + if (ELEM(NULL, seq->ipo, icu)) { + seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; continue; } @@ -1824,21 +1836,21 @@ void do_versions_ipos_to_animato(Main *main) (semi-hack (tm) ) */ switch(seq->type) { - case SEQ_IMAGE: - case SEQ_META: - case SEQ_SCENE: - case SEQ_MOVIE: - case SEQ_COLOR: - adrcode = SEQ_FAC_OPACITY; - break; - case SEQ_SPEED: - adrcode = SEQ_FAC_SPEED; - break; + case SEQ_IMAGE: + case SEQ_META: + case SEQ_SCENE: + case SEQ_MOVIE: + case SEQ_COLOR: + adrcode = SEQ_FAC_OPACITY; + break; + case SEQ_SPEED: + adrcode = SEQ_FAC_SPEED; + break; } - ((IpoCurve*) seq->ipo->curve.first) - ->adrcode = adrcode; - ipo_to_animdata((ID*) seq, seq->ipo, - NULL, NULL); + icu->adrcode = adrcode; + + /* convert IPO */ + ipo_to_animdata((ID *)seq, seq->ipo, NULL, NULL); seq->ipo->id.us--; seq->ipo = NULL; } @@ -1900,6 +1912,24 @@ void do_versions_ipos_to_animato(Main *main) } } + /* curves */ + for (id= main->curve.first; id; id= id->next) { + Curve *cu= (Curve *)id; + + if (G.f & G_DEBUG) printf("\tconverting curve %s \n", id->name+2); + + /* we're only interested in the IPO */ + if (cu->ipo) { + /* Add AnimData block */ + adt= BKE_id_add_animdata(id); + + /* Convert Curve data... */ + ipo_to_animdata(id, cu->ipo, NULL, NULL); + cu->ipo->id.us--; + cu->ipo= NULL; + } + } + /* --------- Unconverted Animation Data ------------------ */ /* For Animation data which may not be directly connected (i.e. not linked) to any other * data, we need to perform a separate pass to make sure that they are converted to standalone @@ -1918,7 +1948,7 @@ void do_versions_ipos_to_animato(Main *main) if (G.f & G_DEBUG) printf("\tconverting action %s \n", id->name+2); /* be careful! some of the actions we encounter will be converted ones... */ - action_to_animato(act, &act->groups, &act->curves, &drivers); + action_to_animato(NULL, act, &act->groups, &act->curves, &drivers); } /* ipo's */ @@ -1933,7 +1963,7 @@ void do_versions_ipos_to_animato(Main *main) /* add a new action for this, and convert all data into that action */ new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name... - ipo_to_animato(ipo, NULL, NULL, NULL, &new_act->curves, &drivers); + ipo_to_animato(NULL, ipo, NULL, NULL, NULL, &new_act->curves, &drivers); } /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */ @@ -1944,6 +1974,7 @@ void do_versions_ipos_to_animato(Main *main) /* free unused drivers from actions + ipos */ free_fcurves(&drivers); - printf("INFO: Animato convert done \n"); // xxx debug + if (G.f & G_DEBUG) + printf("INFO: Animato convert done \n"); } |