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:
authorBastien Montagne <bastien@blender.org>2020-06-17 18:01:21 +0300
committerBastien Montagne <bastien@blender.org>2020-06-17 18:06:05 +0300
commit13f591d400e2d17633bf7ebba9c7890fd563e4d2 (patch)
tree361374096efc8d2d2258bdec2946c352439680b2 /source/blender/blenkernel/intern/scene.c
parentc84fee1ffeab3842d01779f1a2e5bfd826b48e60 (diff)
ID Duplicate: Factorize a lot the code.
Now that we have a uniform consistent behavior in all our ID duplicate funtions, we can easily factorize it greatly. Code gets cleaner, smaller, and less error-prone. Note that ultimately, this duplicate/deep copy behavior could be added as a callback of IDTypeInfo. We could also rethink the duplicate flags (some data, even some obdata, like Lattice, are not coverred currently). And so on. But at least code should now be much more easily maintainable and extendable.
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r--source/blender/blenkernel/intern/scene.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 82e219e60f0..0537f1a65ad 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -837,7 +837,6 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
if (type == SCE_COPY_FULL) {
/* Scene duplication is always root of duplication currently. */
const bool is_subprocess = false;
- ID *id, *id_new;
if (!is_subprocess) {
BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false);
@@ -848,46 +847,16 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
LISTBASE_FOREACH (ViewLayer *, view_layer_dst, &sce_copy->view_layers) {
LISTBASE_FOREACH (
FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) {
- id = &lineset->linestyle->id;
- if (id && id->newid == NULL) {
- if (is_scene_liboverride && ID_IS_LINKED(id)) {
- continue;
- }
- BKE_id_copy(bmain, id, &id_new);
- id_us_min(id_new);
- ID_NEW_SET(id, id_new);
- if (duplicate_flags & USER_DUP_ACT) {
- BKE_animdata_copy_id_action(bmain, id_new, true);
- }
- }
+ BKE_id_copy_for_duplicate(
+ bmain, &lineset->linestyle->id, is_scene_liboverride, duplicate_flags);
}
}
/* Full copy of world (included animations) */
- id = &sce->world->id;
- if (id && id->newid == NULL) {
- if (!is_scene_liboverride || !ID_IS_LINKED(id)) {
- BKE_id_copy(bmain, id, &id_new);
- id_us_min(id_new);
- ID_NEW_SET(id, id_new);
- if (duplicate_flags & USER_DUP_ACT) {
- BKE_animdata_copy_id_action(bmain, id_new, true);
- }
- }
- }
+ BKE_id_copy_for_duplicate(bmain, &sce->world->id, is_scene_liboverride, duplicate_flags);
/* Full copy of GreasePencil. */
- id = &sce->gpd->id;
- if (id && id->newid == NULL) {
- if (!is_scene_liboverride || !ID_IS_LINKED(id)) {
- BKE_id_copy(bmain, id, &id_new);
- id_us_min(id_new);
- ID_NEW_SET(id, id_new);
- if (duplicate_flags & USER_DUP_ACT) {
- BKE_animdata_copy_id_action(bmain, id_new, true);
- }
- }
- }
+ BKE_id_copy_for_duplicate(bmain, &sce->gpd->id, is_scene_liboverride, duplicate_flags);
/* Deep-duplicate collections and objects (using preferences' settings for which sub-data to
* duplicate along the object itself). */