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:
authorJacques Lucke <jacques@blender.org>2020-08-21 16:42:26 +0300
committerJacques Lucke <jacques@blender.org>2020-08-21 16:42:26 +0300
commitbed634c4f96cac7b1afaccc1ff646fc22f3efb29 (patch)
tree95bd87ada9c4fe9e751295e7173788356df8984b /source/blender/blenkernel/intern
parent71634d94ca4ce2b838206144089010a16bb3f1ff (diff)
Refactor: move nla code from blenloader to blenkernel
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/nla.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index e5527ed987a..9f5ca1d9b0e 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -54,6 +54,8 @@
#include "BKE_nla.h"
#include "BKE_sound.h"
+#include "BLO_read_write.h"
+
#include "RNA_access.h"
#include "nla_private.h"
@@ -2190,3 +2192,103 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
adt->actstrip = NULL;
adt->flag &= ~ADT_NLA_EDIT_ON;
}
+
+static void blend_write_nla_strips(BlendWriter *writer, ListBase *strips)
+{
+ BLO_write_struct_list(writer, NlaStrip, strips);
+ LISTBASE_FOREACH (NlaStrip *, strip, strips) {
+ /* write the strip's F-Curves and modifiers */
+ BKE_fcurve_blend_write(writer, &strip->fcurves);
+ BKE_fmodifiers_blend_write(writer, &strip->modifiers);
+
+ /* write the strip's children */
+ blend_write_nla_strips(writer, &strip->strips);
+ }
+}
+
+static void blend_data_read_nla_strips(BlendDataReader *reader, ListBase *strips)
+{
+ LISTBASE_FOREACH (NlaStrip *, strip, strips) {
+ /* strip's child strips */
+ BLO_read_list(reader, &strip->strips);
+ blend_data_read_nla_strips(reader, &strip->strips);
+
+ /* strip's F-Curves */
+ BLO_read_list(reader, &strip->fcurves);
+ BKE_fcurve_blend_data_read(reader, &strip->fcurves);
+
+ /* strip's F-Modifiers */
+ BLO_read_list(reader, &strip->modifiers);
+ BKE_fmodifiers_blend_data_read(reader, &strip->modifiers, NULL);
+ }
+}
+
+static void blend_lib_read_nla_strips(BlendLibReader *reader, ID *id, ListBase *strips)
+{
+ LISTBASE_FOREACH (NlaStrip *, strip, strips) {
+ /* check strip's children */
+ blend_lib_read_nla_strips(reader, id, &strip->strips);
+
+ /* check strip's F-Curves */
+ BKE_fcurve_blend_lib_read(reader, id, &strip->fcurves);
+
+ /* reassign the counted-reference to action */
+ BLO_read_id_address(reader, id->lib, &strip->act);
+ }
+}
+
+static void blend_expand_nla_strips(BlendExpander *expander, ListBase *strips)
+{
+ LISTBASE_FOREACH (NlaStrip *, strip, strips) {
+ /* check child strips */
+ blend_expand_nla_strips(expander, &strip->strips);
+
+ /* check F-Curves */
+ BKE_fcurve_blend_expand(expander, &strip->fcurves);
+
+ /* check F-Modifiers */
+ BKE_fmodifiers_blend_expand(expander, &strip->modifiers);
+
+ /* relink referenced action */
+ BLO_expand(expander, strip->act);
+ }
+}
+
+void BKE_nla_blend_write(BlendWriter *writer, ListBase *tracks)
+{
+ /* write all the tracks */
+ LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
+ /* write the track first */
+ BLO_write_struct(writer, NlaTrack, nlt);
+
+ /* write the track's strips */
+ blend_write_nla_strips(writer, &nlt->strips);
+ }
+}
+
+void BKE_nla_blend_data_read(BlendDataReader *reader, ListBase *tracks)
+{
+ LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
+ /* relink list of strips */
+ BLO_read_list(reader, &nlt->strips);
+
+ /* relink strip data */
+ blend_data_read_nla_strips(reader, &nlt->strips);
+ }
+}
+
+void BKE_nla_blend_lib_read(BlendLibReader *reader, ID *id, ListBase *tracks)
+{
+ /* we only care about the NLA strips inside the tracks */
+ LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
+ blend_lib_read_nla_strips(reader, id, &nlt->strips);
+ }
+}
+
+void BKE_nla_blend_expand(struct BlendExpander *expander, struct ListBase *tracks)
+{
+ /* nla-data - referenced actions */
+ LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
+ blend_expand_nla_strips(expander, &nlt->strips);
+ }
+}