diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-05-04 12:25:03 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-05-04 12:26:29 +0300 |
commit | e778be9e203e71d123e3bdf7418f67861199c899 (patch) | |
tree | 0f7fd0edbcfd5004f44bf1707e0c5e3d20ed3a6b | |
parent | 930f0ba7020eca7a4211a488cbe9dff206c44129 (diff) |
Fix "doversion" of collection settings for collections
For collections we do not need a doversion as granular as the scene one.
However if a new engine settings is added we need to take care of it.
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 55 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 3 |
3 files changed, 47 insertions, 14 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index a54cce73c7f..c5a2eb8351d 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -115,7 +115,8 @@ struct IDProperty *BKE_scene_collection_engine_get(struct Scene *scene, const in void BKE_layer_collection_engine_settings_callback_register(struct Main *bmain, const char *engine_name, CollectionEngineSettingsCB func); void BKE_layer_collection_engine_settings_callback_free(void); void BKE_layer_collection_engine_settings_create(struct IDProperty *root); -void BKE_layer_collection_engine_settings_validate(struct Scene *scene); +void BKE_layer_collection_engine_settings_validate_scene(struct Scene *scene); +void BKE_layer_collection_engine_settings_validate_collection(struct LayerCollection *lc); void BKE_collection_engine_property_add_float(struct IDProperty *props, const char *name, float value); void BKE_collection_engine_property_add_int(struct IDProperty *props, const char *name, int value); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index c2bf9f377d7..8182d7d0706 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -1278,17 +1278,29 @@ void BKE_layer_collection_engine_settings_create(IDProperty *root) * Reference of IDProperty group scene collection settings * Used when reading blendfiles, to see if there is any missing settings. */ -static IDProperty *root_reference = NULL; +static struct { + IDProperty *scene; + IDProperty *layer_collection; +} root_reference = { + .scene = NULL, + .layer_collection = NULL, +}; /** * Free the reference scene collection settings IDProperty group. */ static void layer_collection_engine_settings_validate_init(void) { - if (root_reference == NULL) { - IDPropertyTemplate val = {0}; - root_reference = IDP_New(IDP_GROUP, &val, ROOT_PROP); - BKE_layer_collection_engine_settings_create(root_reference); + IDPropertyTemplate val = {0}; + + if (root_reference.scene == NULL) { + root_reference.scene = IDP_New(IDP_GROUP, &val, ROOT_PROP); + collection_engine_settings_init(root_reference.scene, true); + } + + if (root_reference.layer_collection == NULL) { + root_reference.layer_collection = IDP_New(IDP_GROUP, &val, ROOT_PROP); + collection_engine_settings_init(root_reference.layer_collection, false); } } @@ -1297,19 +1309,25 @@ static void layer_collection_engine_settings_validate_init(void) */ static void layer_collection_engine_settings_validate_free(void) { - if (root_reference != NULL) { - IDP_FreeProperty(root_reference); - MEM_freeN(root_reference); - root_reference = NULL; + if (root_reference.scene != NULL) { + IDP_FreeProperty(root_reference.scene); + MEM_freeN(root_reference.scene); + root_reference.scene = NULL; + } + + if (root_reference.layer_collection != NULL) { + IDP_FreeProperty(root_reference.layer_collection); + MEM_freeN(root_reference.layer_collection); + root_reference.layer_collection = NULL; } } /** * Make sure Scene has all required collection settings. */ -void BKE_layer_collection_engine_settings_validate(Scene *scene) +void BKE_layer_collection_engine_settings_validate_scene(Scene *scene) { - if (root_reference == NULL) { + if (root_reference.scene == NULL) { layer_collection_engine_settings_validate_init(); } @@ -1319,10 +1337,23 @@ void BKE_layer_collection_engine_settings_validate(Scene *scene) BKE_layer_collection_engine_settings_create(scene->collection_properties); } else { - IDP_MergeGroup(scene->collection_properties, root_reference, false); + IDP_MergeGroup(scene->collection_properties, root_reference.scene, false); } } +/** + * Maker sure LayerCollection has all required collection settings. + */ +void BKE_layer_collection_engine_settings_validate_collection(LayerCollection *lc) +{ + if (root_reference.layer_collection == NULL) { + layer_collection_engine_settings_validate_init(); + } + + BLI_assert(lc->properties != NULL); + IDP_MergeGroup(lc->properties, root_reference.layer_collection, false); +} + /* ---------------------------------------------------------------------- */ /* Iterators */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5f533f02bd1..9a85587e2e0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6027,6 +6027,7 @@ static void direct_link_layer_collections(FileData *fd, ListBase *lb) if (lc->properties) { lc->properties = newdataadr(fd, lc->properties); IDP_DirectLinkGroup_OrFree(&lc->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + BKE_layer_collection_engine_settings_validate_collection(lc); } lc->properties_evaluated = NULL; @@ -6313,7 +6314,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->collection_properties = newdataadr(fd, sce->collection_properties); IDP_DirectLinkGroup_OrFree(&sce->collection_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - BKE_layer_collection_engine_settings_validate(sce); + BKE_layer_collection_engine_settings_validate_scene(sce); } /* ************ READ WM ***************** */ |