diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-06 20:33:33 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-06 20:33:33 +0300 |
commit | 1762d5f43a4086b4492efb507c6085b0d841aaac (patch) | |
tree | 693c7a99fb92a903f656d8025cc1e1d92a7a0d2e /source/blender/blenkernel/intern/ipo.c | |
parent | 638913a3c08990697e08195e00f5f9cf472c04be (diff) |
Refactor: move Ipo .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source/blender/blenkernel/intern/ipo.c')
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5d2defa3030..9696d920640 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -52,6 +52,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_endian_switch.h" #include "BLI_string_utils.h" #include "BLI_utildefines.h" @@ -75,6 +76,8 @@ #include "SEQ_sequencer.h" +#include "BLO_read_write.h" + #ifdef WIN32 # include "BLI_math_base.h" /* M_PI */ #endif @@ -110,6 +113,69 @@ static void ipo_free_data(ID *id) } } +static void ipo_blend_read_data(BlendDataReader *reader, ID *id) +{ + Ipo *ipo = (Ipo *)id; + + BLO_read_list(reader, &(ipo->curve)); + + LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { + BLO_read_data_address(reader, &icu->bezt); + BLO_read_data_address(reader, &icu->bp); + BLO_read_data_address(reader, &icu->driver); + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&icu->blocktype); + if (icu->driver != NULL) { + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&icu->blocktype); + if (icu->driver != NULL) { + BLI_endian_switch_int16(&icu->driver->blocktype); + } + } + } + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&ipo->blocktype); + if (icu->driver != NULL) { + BLI_endian_switch_int16(&icu->driver->blocktype); + } + } + } + } + + /* Undo generic endian switching. */ + if (BLO_read_requires_endian_switch(reader)) { + BLI_endian_switch_int16(&ipo->blocktype); + } +} + +static void ipo_blend_read_lib(BlendLibReader *reader, ID *id) +{ + Ipo *ipo = (Ipo *)id; + + LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { + if (icu->driver) { + BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob); + } + } +} + +static void ipo_blend_read_expand(BlendExpander *expander, ID *id) +{ + Ipo *ipo = (Ipo *)id; + + LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { + if (icu->driver) { + BLO_expand(expander, icu->driver->ob); + } + } +} + IDTypeInfo IDType_ID_IP = { .id_code = ID_IP, .id_filter = 0, @@ -129,9 +195,9 @@ IDTypeInfo IDType_ID_IP = { .foreach_cache = NULL, .blend_write = NULL, - .blend_read_data = NULL, - .blend_read_lib = NULL, - .blend_read_expand = NULL, + .blend_read_data = ipo_blend_read_data, + .blend_read_lib = ipo_blend_read_lib, + .blend_read_expand = ipo_blend_read_expand, .blend_read_undo_preserve = NULL, }; |