diff options
author | Jacques Lucke <jacques@blender.org> | 2020-10-29 21:28:21 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-10-29 21:34:15 +0300 |
commit | b85504337e71a180362ad7fbc402dc7a25d5a564 (patch) | |
tree | c52c4e8bb3d96799b543ea5cc40ed3031630aaef /source/blender/blenloader/intern/writefile.c | |
parent | 7bf0682aa98ac020dc7c55e3298a5cdccc665509 (diff) |
Refactor: move Collection .blend I/O to IDTypeInfo callbacks
This one was a bit more tricky, because the file loading is
mixed with versioning code and because collections are
embedded into scenes.
All tests that passed before, still pass.
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a37ec2d9f0a..10671ce6586 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1384,37 +1384,6 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address } } -static void write_collection_nolib(BlendWriter *writer, Collection *collection) -{ - /* Shared function for collection data-blocks and scene master collection. */ - BKE_previewimg_blend_write(writer, collection->preview); - - LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { - BLO_write_struct(writer, CollectionObject, cob); - } - - LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { - BLO_write_struct(writer, CollectionChild, child); - } -} - -static void write_collection(BlendWriter *writer, Collection *collection, const void *id_address) -{ - if (collection->id.us > 0 || BLO_write_is_undo(writer)) { - /* Clean up, important in undo case to reduce false detection of changed data-blocks. */ - collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; - collection->tag = 0; - BLI_listbase_clear(&collection->object_cache); - BLI_listbase_clear(&collection->parents); - - /* write LibData */ - BLO_write_id_struct(writer, Collection, id_address, &collection->id); - BKE_id_blend_write(writer, &collection->id); - - write_collection_nolib(writer, collection); - } -} - static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase) { LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) { @@ -1745,7 +1714,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) if (sce->master_collection) { BLO_write_struct(writer, Collection, sce->master_collection); - write_collection_nolib(writer, sce->master_collection); + BKE_collection_blend_write_nolib(writer, sce->master_collection); } /* Eevee Lightcache */ @@ -2335,15 +2304,13 @@ static bool write_file_handle(Main *mainvar, case ID_SCE: write_scene(&writer, (Scene *)id_buffer, id); break; - case ID_GR: - write_collection(&writer, (Collection *)id_buffer, id); - break; case ID_OB: write_object(&writer, (Object *)id_buffer, id); break; case ID_PA: write_particlesettings(&writer, (ParticleSettings *)id_buffer, id); break; + case ID_GR: case ID_ME: case ID_LT: case ID_AC: |