diff options
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_shader_fx.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shader_fx.c | 44 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 44 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 18 |
6 files changed, 76 insertions, 57 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index b7015942cb4..60a829ad0aa 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -416,6 +416,11 @@ void BKE_object_to_mesh_clear(struct Object *object); void BKE_object_check_uuids_unique_and_report(const struct Object *object); +void BKE_object_modifiers_lib_link_common(void *userData, + struct Object *ob, + struct ID **idpoin, + int cb_flag); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h index 4b9688f9515..7c2d363be5c 100644 --- a/source/blender/blenkernel/BKE_shader_fx.h +++ b/source/blender/blenkernel/BKE_shader_fx.h @@ -33,6 +33,9 @@ struct ListBase; struct ModifierUpdateDepsgraphContext; struct Object; struct ShaderFxData; +struct BlendWriter; +struct BlendDataReader; +struct BlendLibReader; #define SHADER_FX_ACTIVE(_fx, _is_render) \ ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \ @@ -170,6 +173,10 @@ void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, vo bool BKE_shaderfx_has_gpencil(struct Object *ob); +void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase); +void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb); +void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f658594d878..ca259a9fbd1 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -135,6 +135,8 @@ #include "DRW_engine.h" +#include "BLO_read_write.h" + #include "SEQ_sequencer.h" #ifdef WITH_PYTHON @@ -4807,3 +4809,16 @@ void BKE_object_check_uuids_unique_and_report(const Object *object) BKE_pose_check_uuids_unique_and_report(object->pose); BKE_modifier_check_uuids_unique_and_report(object); } + +void BKE_object_modifiers_lib_link_common(void *userData, + struct Object *ob, + struct ID **idpoin, + int cb_flag) +{ + BlendLibReader *reader = userData; + + BLO_read_id_address(reader, ob->id.lib, idpoin); + if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) { + id_us_plus_no_lib(*idpoin); + } +} diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c index 2ae95492708..3727ec866ca 100644 --- a/source/blender/blenkernel/intern/shader_fx.c +++ b/source/blender/blenkernel/intern/shader_fx.c @@ -50,6 +50,8 @@ #include "FX_shader_types.h" +#include "BLO_read_write.h" + static ShaderFxTypeInfo *shader_fx_types[NUM_SHADER_FX_TYPES] = {NULL}; /* *************************************************** */ @@ -276,3 +278,45 @@ ShaderFxData *BKE_shaderfx_findby_name(Object *ob, const char *name) { return BLI_findstring(&(ob->shader_fx), name, offsetof(ShaderFxData, name)); } + +void BKE_shaderfx_blend_write(BlendWriter *writer, ListBase *fxbase) +{ + if (fxbase == NULL) { + return; + } + + LISTBASE_FOREACH (ShaderFxData *, fx, fxbase) { + const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type); + if (fxi == NULL) { + return; + } + + BLO_write_struct_by_name(writer, fxi->struct_name, fx); + } +} + +void BKE_shaderfx_blend_read_data(BlendDataReader *reader, ListBase *lb) +{ + BLO_read_list(reader, lb); + + LISTBASE_FOREACH (ShaderFxData *, fx, lb) { + fx->error = NULL; + + /* if shader disappear, or for upward compatibility */ + if (NULL == BKE_shaderfx_get_info(fx->type)) { + fx->type = eShaderFxType_None; + } + } +} + +void BKE_shaderfx_blend_read_lib(BlendLibReader *reader, Object *ob) +{ + BKE_shaderfx_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader); + + /* If linking from a library, clear 'local' library override flag. */ + if (ob->id.lib != NULL) { + LISTBASE_FOREACH (ShaderFxData *, fx, &ob->shader_fx) { + fx->flag &= ~eShaderFxFlag_OverrideLibrary_Local; + } + } +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3e394c3d1f5..f33e6f569df 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2746,19 +2746,9 @@ void blo_do_versions_key_uidgen(Key *key) /** \name Read ID: Object * \{ */ -static void lib_link_modifiers_common(void *userData, Object *ob, ID **idpoin, int cb_flag) -{ - BlendLibReader *reader = userData; - - BLO_read_id_address(reader, ob->id.lib, idpoin); - if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) { - id_us_plus_no_lib(*idpoin); - } -} - static void lib_link_modifiers(BlendLibReader *reader, Object *ob) { - BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader); + BKE_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader); /* If linking from a library, clear 'local' library override flag. */ if (ob->id.lib != NULL) { @@ -2770,7 +2760,7 @@ static void lib_link_modifiers(BlendLibReader *reader, Object *ob) static void lib_link_gpencil_modifiers(BlendLibReader *reader, Object *ob) { - BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader); + BKE_gpencil_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader); /* If linking from a library, clear 'local' library override flag. */ if (ob->id.lib != NULL) { @@ -2780,18 +2770,6 @@ static void lib_link_gpencil_modifiers(BlendLibReader *reader, Object *ob) } } -static void lib_link_shaderfxs(BlendLibReader *reader, Object *ob) -{ - BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, reader); - - /* If linking from a library, clear 'local' library override flag. */ - if (ob->id.lib != NULL) { - LISTBASE_FOREACH (ShaderFxData *, fx, &ob->shader_fx) { - fx->flag &= ~eShaderFxFlag_OverrideLibrary_Local; - } - } -} - static void lib_link_object(BlendLibReader *reader, Object *ob) { bool warn = false; @@ -2947,7 +2925,7 @@ static void lib_link_object(BlendLibReader *reader, Object *ob) BKE_particle_system_blend_read_lib(reader, ob, &ob->id, &ob->particlesystem); lib_link_modifiers(reader, ob); lib_link_gpencil_modifiers(reader, ob); - lib_link_shaderfxs(reader, ob); + BKE_shaderfx_blend_read_lib(reader, ob); if (ob->rigidbody_constraint) { BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob1); @@ -3406,20 +3384,6 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) } } -static void direct_link_shaderfxs(BlendDataReader *reader, ListBase *lb) -{ - BLO_read_list(reader, lb); - - LISTBASE_FOREACH (ShaderFxData *, fx, lb) { - fx->error = NULL; - - /* if shader disappear, or for upward compatibility */ - if (NULL == BKE_shaderfx_get_info(fx->type)) { - fx->type = eShaderFxType_None; - } - } -} - static void direct_link_object(BlendDataReader *reader, Object *ob) { PartEff *paf; @@ -3465,7 +3429,7 @@ static void direct_link_object(BlendDataReader *reader, Object *ob) /* do it here, below old data gets converted */ direct_link_modifiers(reader, &ob->modifiers, ob); direct_link_gpencil_modifiers(reader, &ob->greasepencil_modifiers); - direct_link_shaderfxs(reader, &ob->shader_fx); + BKE_shaderfx_blend_read_data(reader, &ob->shader_fx); BLO_read_list(reader, &ob->effect); paf = ob->effect.first; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 9d6af35f623..2bff359c7cc 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1109,22 +1109,6 @@ static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase) } } -static void write_shaderfxs(BlendWriter *writer, ListBase *fxbase) -{ - if (fxbase == NULL) { - return; - } - - LISTBASE_FOREACH (ShaderFxData *, fx, fxbase) { - const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type); - if (fxi == NULL) { - return; - } - - BLO_write_struct_by_name(writer, fxi->struct_name, fx); - } -} - static void write_object(BlendWriter *writer, Object *ob, const void *id_address) { const bool is_undo = BLO_write_is_undo(writer); @@ -1191,7 +1175,7 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address BKE_particle_system_blend_write(writer, &ob->particlesystem); write_modifiers(writer, &ob->modifiers); write_gpencil_modifiers(writer, &ob->greasepencil_modifiers); - write_shaderfxs(writer, &ob->shader_fx); + BKE_shaderfx_blend_write(writer, &ob->shader_fx); BLO_write_struct_list(writer, LinkData, &ob->pc_ids); |