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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/ipo.c')
-rw-r--r--source/blender/blenkernel/intern/ipo.c211
1 files changed, 125 insertions, 86 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index dbde6403226..cd8ab8290e5 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -41,54 +41,33 @@
#include <string.h>
#include <stddef.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
-#include "DNA_action_types.h"
-#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
-#include "DNA_curve_types.h"
#include "DNA_camera_types.h"
#include "DNA_lamp_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_nla_types.h"
-#include "DNA_object_types.h"
-#include "DNA_object_force.h"
-#include "DNA_particle_types.h"
#include "DNA_sequence_types.h"
#include "DNA_scene_types.h"
-#include "DNA_sound_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
+#include "BLI_math.h" /* windows needs for M_PI */
#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "BKE_utildefines.h"
#include "BKE_animsys.h"
#include "BKE_action.h"
-#include "BKE_blender.h"
-#include "BKE_curve.h"
-#include "BKE_constraint.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
-#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "BKE_nla.h"
-#include "BKE_object.h"
-
+#include "BKE_sequencer.h"
/* *************************************************** */
@@ -813,12 +792,12 @@ static char *particle_adrcodes_to_paths (int adrcode, int *array_index)
/* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path
* Input:
* - blocktype, adrcode - determines setting to get
- * - actname, constname - used to build path
+ * - actname, constname,seq - used to build path
* Output:
* - array_index - index in property's array (if applicable) to use
* - return - the allocated path...
*/
-static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], int *array_index)
+static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence * seq, int *array_index)
{
DynStr *path= BLI_dynstr_new();
char *propname=NULL, *rpath=NULL;
@@ -870,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) {
@@ -940,6 +919,11 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
/* Constraint in Object */
sprintf(buf, "constraints[\"%s\"]", constname);
}
+ else if (seq) {
+ /* Sequence names in Scene */
+ sprintf(buf, "sequence_editor.sequences_all[\"%s\"]",
+ seq->name+2);
+ }
else
strcpy(buf, ""); /* empty string */
BLI_dynstr_append(path, buf);
@@ -1051,6 +1035,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
if (idriver->name[0])
BLI_strncpy(dtar->pchan_name, idriver->name, 32);
dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode);
+ dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
}
}
else { /* Object */
@@ -1083,7 +1068,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
bActionGroup *agrp= NULL;
/* init the temp action */
- //memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors
+ memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors
tmp_act.groups.first= groups->first;
tmp_act.groups.last= groups->last;
tmp_act.curves.first= list->first;
@@ -1099,8 +1084,8 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
agrp->flag = AGRP_SELECTED;
- if(muteipo) agrp->flag |= AGRP_MUTED;
-
+ if (muteipo) agrp->flag |= AGRP_MUTED;
+
strncpy(agrp->name, grpname, sizeof(agrp->name));
BLI_addtail(&tmp_act.groups, agrp);
@@ -1112,9 +1097,9 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
/* WARNING: this func should only need to look at the stuff we initialised, if not, things may crash */
action_groups_add_channel(&tmp_act, agrp, fcu);
- if(agrp->flag & AGRP_MUTED) /* flush down */
+ if (agrp->flag & AGRP_MUTED) /* flush down */
fcu->flag |= FCURVE_MUTED;
-
+
/* set the output lists based on the ones in the temp action */
groups->first= tmp_act.groups.first;
groups->last= tmp_act.groups.last;
@@ -1131,8 +1116,9 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
* is not relevant, BUT do not free the IPO-Curve itself...
* 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
+ * seq: sequencer-strip (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, Sequence * seq, int muteipo)
{
AdrBit2Path *abp;
FCurve *fcu;
@@ -1255,7 +1241,7 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha
/* get rna-path
* - we will need to set the 'disabled' flag if no path is able to be made (for now)
*/
- fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, &fcu->array_index);
+ fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index);
if (fcu->rna_path == NULL)
fcu->flag |= FCURVE_DISABLED;
@@ -1297,6 +1283,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
@@ -1313,6 +1313,24 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha
dst->vec[2][0] *= fac;
}
}
+
+ /* correct values for sequencer curves,
+ that were not locked to frame */
+
+ if (seq &&
+ (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
+ double mul= (seq->enddisp-seq->startdisp)/100.0f;
+ double offset= seq->startdisp;
+
+ dst->vec[0][0] *= mul;
+ dst->vec[0][0] += offset;
+
+ dst->vec[1][0] *= mul;
+ dst->vec[1][0] += offset;
+
+ dst->vec[2][0] *= mul;
+ dst->vec[2][0] += offset;
+ }
}
}
else if (icu->bp) {
@@ -1332,7 +1350,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[], Sequence * seq, ListBase *animgroups, ListBase *anim, ListBase *drivers)
{
IpoCurve *icu;
@@ -1363,7 +1381,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, seq, ipo->muteipo);
}
else {
MEM_freeN(icu->driver);
@@ -1371,7 +1389,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, seq, ipo->muteipo);
}
/* if this IPO block doesn't have any users after this one, free... */
@@ -1402,7 +1420,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;
@@ -1423,7 +1441,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, NULL, groups, curves, drivers);
achan->ipo->id.us--;
achan->ipo= NULL;
}
@@ -1435,7 +1453,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, NULL, groups, curves, drivers);
conchan->ipo->id.us--;
conchan->ipo= NULL;
}
@@ -1456,7 +1474,7 @@ static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves,
* This assumes that AnimData has been added already. Separation of drivers
* from animation data is accomplished here too...
*/
-static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[])
+static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq)
{
AnimData *adt= BKE_animdata_from_id(id);
ListBase anim = {NULL, NULL};
@@ -1471,8 +1489,8 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[])
}
if (G.f & G_DEBUG) {
- printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s curves:%d \n",
- id->name+2, ipo->id.name+2, (actname)?actname:"<None>", (constname)?constname:"<None>",
+ printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s curves:%d \n",
+ id->name+2, ipo->id.name+2, (actname)?actname:"<None>", (constname)?constname:"<None>", (seq)?(seq->name+2):"<None>",
BLI_countlist(&ipo->curve));
}
@@ -1480,7 +1498,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, seq, NULL, &anim, &drivers);
/* deal with animation first */
if (anim.first) {
@@ -1522,7 +1540,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);
}
/* ------------------------- */
@@ -1546,7 +1564,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 */
{
@@ -1625,7 +1643,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");
@@ -1633,13 +1650,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 -------------- */
@@ -1659,7 +1675,7 @@ void do_versions_ipos_to_animato(Main *main)
/* IPO first to take into any non-NLA'd Object Animation */
if (ob->ipo) {
- ipo_to_animdata(id, ob->ipo, NULL, NULL);
+ ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
ob->ipo->id.us--;
ob->ipo= NULL;
@@ -1693,7 +1709,7 @@ void do_versions_ipos_to_animato(Main *main)
/* IPO second... */
if (ob->ipo) {
- ipo_to_animdata(id, ob->ipo, NULL, NULL);
+ ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
ob->ipo->id.us--;
ob->ipo= NULL;
}
@@ -1713,7 +1729,7 @@ void do_versions_ipos_to_animato(Main *main)
/* although this was the constraint's local IPO, we still need to provide pchan + con
* so that drivers can be added properly...
*/
- ipo_to_animdata(id, con->ipo, pchan->name, con->name);
+ ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL);
con->ipo->id.us--;
con->ipo= NULL;
}
@@ -1733,7 +1749,7 @@ void do_versions_ipos_to_animato(Main *main)
/* although this was the constraint's local IPO, we still need to provide con
* so that drivers can be added properly...
*/
- ipo_to_animdata(id, con->ipo, NULL, con->name);
+ ipo_to_animdata(id, con->ipo, NULL, con->name, NULL);
con->ipo->id.us--;
con->ipo= NULL;
}
@@ -1753,7 +1769,7 @@ void do_versions_ipos_to_animato(Main *main)
/* convert Constraint Channel's IPO data */
if (conchan->ipo) {
- ipo_to_animdata(id, conchan->ipo, NULL, conchan->name);
+ ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL);
conchan->ipo->id.us--;
conchan->ipo= NULL;
}
@@ -1779,7 +1795,7 @@ void do_versions_ipos_to_animato(Main *main)
adt= BKE_id_add_animdata(id);
/* Convert Shapekey data... */
- ipo_to_animdata(id, key->ipo, NULL, NULL);
+ ipo_to_animdata(id, key->ipo, NULL, NULL, NULL);
key->ipo->id.us--;
key->ipo= NULL;
}
@@ -1797,7 +1813,7 @@ void do_versions_ipos_to_animato(Main *main)
adt= BKE_id_add_animdata(id);
/* Convert Material data... */
- ipo_to_animdata(id, ma->ipo, NULL, NULL);
+ ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL);
ma->ipo->id.us--;
ma->ipo= NULL;
}
@@ -1815,27 +1831,30 @@ void do_versions_ipos_to_animato(Main *main)
adt= BKE_id_add_animdata(id);
/* Convert World data... */
- ipo_to_animdata(id, wo->ipo, NULL, NULL);
+ ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL);
wo->ipo->id.us--;
wo->ipo= NULL;
}
}
/* 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;
+ Editing * ed = scene->ed;
+ if (ed && ed->seqbasep) {
Sequence * seq;
- for(seq = scene->ed->seqbasep->first;
- seq; seq = seq->next) {
+ adt= BKE_id_add_animdata(id);
+
+ SEQ_BEGIN(ed, seq) {
+ 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;
}
@@ -1844,24 +1863,25 @@ 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 *)scene, seq->ipo, NULL, NULL, seq);
seq->ipo->id.us--;
seq->ipo = NULL;
}
+ SEQ_END
}
}
@@ -1878,7 +1898,7 @@ void do_versions_ipos_to_animato(Main *main)
adt= BKE_id_add_animdata(id);
/* Convert Texture data... */
- ipo_to_animdata(id, te->ipo, NULL, NULL);
+ ipo_to_animdata(id, te->ipo, NULL, NULL, NULL);
te->ipo->id.us--;
te->ipo= NULL;
}
@@ -1896,7 +1916,7 @@ void do_versions_ipos_to_animato(Main *main)
adt= BKE_id_add_animdata(id);
/* Convert Camera data... */
- ipo_to_animdata(id, ca->ipo, NULL, NULL);
+ ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL);
ca->ipo->id.us--;
ca->ipo= NULL;
}
@@ -1914,12 +1934,30 @@ void do_versions_ipos_to_animato(Main *main)
adt= BKE_id_add_animdata(id);
/* Convert Lamp data... */
- ipo_to_animdata(id, la->ipo, NULL, NULL);
+ ipo_to_animdata(id, la->ipo, NULL, NULL, NULL);
la->ipo->id.us--;
la->ipo= NULL;
}
}
+ /* 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, 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
@@ -1938,7 +1976,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 */
@@ -1953,7 +1991,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, NULL, &new_act->curves, &drivers);
}
/* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */
@@ -1964,6 +2002,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");
}