diff options
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 156 |
1 files changed, 112 insertions, 44 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 48aa3f6a3b7..af4f61fccc4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1667,10 +1667,26 @@ static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbas /* Data Linking ----------------------------- */ +static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list) +{ + FModifier *fcm; + + for (fcm= list->first; fcm; fcm= fcm->next) { + /* data for specific modifiers */ + switch (fcm->type) { + case FMODIFIER_TYPE_PYTHON: + { + FMod_Python *data= (FMod_Python *)fcm->data; + data->script = newlibadr(fd, id->lib, data->script); + } + break; + } + } +} + static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) { FCurve *fcu; - FModifier *fcm; /* relink ID-block references... */ for (fcu= list->first; fcu; fcu= fcu->next) { @@ -1684,16 +1700,45 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) } /* modifiers */ - for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) { - /* data for specific modifiers */ - switch (fcm->type) { - case FMODIFIER_TYPE_PYTHON: - { - FMod_Python *data= (FMod_Python *)fcm->data; - data->script = newlibadr(fd, id->lib, data->script); - } - break; + lib_link_fmodifiers(fd, id, &fcu->modifiers); + } +} + + +/* NOTE: this assumes that link_list has already been called on the list */ +static void direct_link_fmodifiers(FileData *fd, ListBase *list) +{ + FModifier *fcm; + + for (fcm= list->first; fcm; fcm= fcm->next) { + /* relink general data */ + fcm->data = newdataadr(fd, fcm->data); + fcm->edata= NULL; + + /* do relinking of data for specific types */ + switch (fcm->type) { + case FMODIFIER_TYPE_GENERATOR: + { + FMod_Generator *data= (FMod_Generator *)fcm->data; + + data->coefficients= newdataadr(fd, data->coefficients); + } + break; + case FMODIFIER_TYPE_ENVELOPE: + { + FMod_Envelope *data= (FMod_Envelope *)fcm->data; + + data->data= newdataadr(fd, data->data); } + break; + case FMODIFIER_TYPE_PYTHON: + { + FMod_Python *data= (FMod_Python *)fcm->data; + + data->prop = newdataadr(fd, data->prop); + IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + } + break; } } } @@ -1702,7 +1747,6 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) static void direct_link_fcurves(FileData *fd, ListBase *list) { FCurve *fcu; - FModifier *fcm; /* link F-Curve data to F-Curve again (non ID-libs) */ for (fcu= list->first; fcu; fcu= fcu->next) { @@ -1730,37 +1774,7 @@ static void direct_link_fcurves(FileData *fd, ListBase *list) /* modifiers */ link_list(fd, &fcu->modifiers); - for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) { - /* relink general data */ - fcm->data = newdataadr(fd, fcm->data); - fcm->edata= NULL; - - /* do relinking of data for specific types */ - switch (fcm->type) { - case FMODIFIER_TYPE_GENERATOR: - { - FMod_Generator *data= (FMod_Generator *)fcm->data; - - data->coefficients= newdataadr(fd, data->coefficients); - } - break; - case FMODIFIER_TYPE_ENVELOPE: - { - FMod_Envelope *data= (FMod_Envelope *)fcm->data; - - data->data= newdataadr(fd, data->data); - } - break; - case FMODIFIER_TYPE_PYTHON: - { - FMod_Python *data= (FMod_Python *)fcm->data; - - data->prop = newdataadr(fd, data->prop); - IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - } - break; - } - } + direct_link_fmodifiers(fd, &fcu->modifiers); } } @@ -1812,6 +1826,44 @@ static void direct_link_action(FileData *fd, bAction *act) } } + +static void lib_link_nladata (FileData *fd, ID *id, ListBase *list) +{ + NlaTrack *nlt; + NlaStrip *strip; + + /* we only acare about the NLA strips inside the tracks */ + for (nlt= list->first; nlt; nlt= nlt->next) { + for (strip= nlt->strips.first; strip; strip= strip->next) { + /* reassign the counted-reference to action */ + strip->act = newlibadr_us(fd, id->lib, strip->act); + } + } +} + +/* NOTE: this assumes that link_list has already been called on the list */ +static void direct_link_nladata(FileData *fd, ListBase *list) +{ + NlaTrack *nlt; + NlaStrip *strip; + + for (nlt= list->first; nlt; nlt= nlt->next) { + /* relink list of strips */ + link_list(fd, &nlt->strips); + + /* relink strip data */ + for (strip= nlt->strips.first; strip; strip= strip->next) { + /* strip's F-Curves */ + link_list(fd, &strip->fcurves); + direct_link_fcurves(fd, &strip->fcurves); + + /* strip's F-Modifiers */ + link_list(fd, &strip->modifiers); + direct_link_fcurves(fd, &strip->modifiers); + } + } +} + /* ------- */ static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list) @@ -1854,6 +1906,7 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) /* link action data */ adt->action= newlibadr_us(fd, id->lib, adt->action); + adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact); /* link drivers */ lib_link_fcurves(fd, id, &adt->drivers); @@ -1861,7 +1914,7 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) /* overrides don't have lib-link for now, so no need to do anything */ /* link NLA-data */ - // TODO... + lib_link_nladata(fd, id, &adt->nla_tracks); } static void direct_link_animdata(FileData *fd, AnimData *adt) @@ -1878,7 +1931,8 @@ static void direct_link_animdata(FileData *fd, AnimData *adt) // TODO... /* link NLA-data */ - // TODO... + link_list(fd, &adt->nla_tracks); + direct_link_nladata(fd, &adt->nla_tracks); } /* ************ READ NODE TREE *************** */ @@ -4707,6 +4761,11 @@ static void direct_link_screen(FileData *fd, bScreen *sc) sipo->ads= newdataadr(fd, sipo->ads); sipo->ghostCurves.first= sipo->ghostCurves.last= NULL; } + else if (sl->spacetype==SPACE_NLA) { + SpaceNla *snla= (SpaceNla*)sl; + + snla->ads= newdataadr(fd, snla->ads); + } else if (sl->spacetype==SPACE_OUTLINER) { SpaceOops *soops= (SpaceOops*) sl; @@ -9515,9 +9574,12 @@ static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list) static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt) { FCurve *fcd; + NlaTrack *nlt; + NlaStrip *strip; /* own action */ expand_doit(fd, mainvar, adt->action); + expand_doit(fd, mainvar, adt->tmpact); /* drivers - assume that these F-Curves have driver data to be in this list... */ for (fcd= adt->drivers.first; fcd; fcd= fcd->next) { @@ -9527,6 +9589,12 @@ static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt) for (dtar= driver->targets.first; dtar; dtar= dtar->next) expand_doit(fd, mainvar, dtar->id); } + + /* nla-data - referenced actions */ + for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { + for (strip= nlt->strips.first; strip; strip= strip->next) + expand_doit(fd, mainvar, strip->act); + } } static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part) |