[Bf-blender-cvs] [c84fee1ffea] master: ID Duplicate: uniformize Action duplication.
Bastien Montagne
noreply at git.blender.org
Wed Jun 17 17:09:16 CEST 2020
Commit: c84fee1ffeab3842d01779f1a2e5bfd826b48e60
Author: Bastien Montagne
Date: Wed Jun 17 15:27:22 2020 +0200
Branches: master
https://developer.blender.org/rBc84fee1ffeab3842d01779f1a2e5bfd826b48e60
ID Duplicate: uniformize Action duplication.
Previously, object (and sub-data) actions would be controlled by the
user preferences flag, collections actions would never be duplicted, and
scenes actions were always duplicated...
Now they all follow the user preferences settings.
===================================================================
M source/blender/blenkernel/intern/anim_data.c
M source/blender/blenkernel/intern/collection.c
M source/blender/blenkernel/intern/object.c
M source/blender/blenkernel/intern/scene.c
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
index cbb34cbee30..841fdaa3b2c 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -399,6 +399,8 @@ void BKE_animdata_copy_id_action(Main *bmain, ID *id, const bool set_newid)
if (ntree) {
BKE_animdata_copy_id_action(bmain, &ntree->id, set_newid);
}
+ /* Note that collections are not animatable currently, so no need to handle scenes' master
+ * collection here. */
}
/* Merge copies of the data from the src AnimData into the destination AnimData */
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 6127ad075f4..f115b9e8b7b 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -28,6 +28,7 @@
#include "BLI_threads.h"
#include "BLT_translation.h"
+#include "BKE_anim_data.h"
#include "BKE_collection.h"
#include "BKE_icons.h"
#include "BKE_idprop.h"
@@ -350,6 +351,11 @@ static Collection *collection_duplicate_recursive(Main *bmain,
id_us_min(&collection_new->id);
ID_NEW_SET(collection_old, collection_new);
+
+ if (duplicate_flags & USER_DUP_ACT) {
+ BKE_animdata_copy_id_action(bmain, &collection_new->id, true);
+ }
+
do_full_process = true;
}
else {
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 15cfe4a1d6a..28f7a9f12d0 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1771,7 +1771,7 @@ Object *BKE_object_duplicate(Main *bmain,
}
Material ***matarar;
- ID *id, *id_new;
+ ID *id, *id_new = NULL;
int a;
const bool is_object_liboverride = ID_IS_OVERRIDE_LIBRARY(ob);
@@ -1958,6 +1958,8 @@ Object *BKE_object_duplicate(Main *bmain,
/* Check if obdata is copied. */
if (duplicated_obdata) {
+ BLI_assert(id_new != NULL);
+
Key *key = BKE_key_from_object(obn);
Key *oldkey = BKE_key_from_object(ob);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 8e1800ad122..82e219e60f0 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -822,10 +822,16 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
return sce_copy;
}
else {
- BKE_id_copy_ex(bmain, (ID *)sce, (ID **)&sce_copy, LIB_ID_COPY_ACTIONS);
+ const eDupli_ID_Flags duplicate_flags = U.dupflag | USER_DUP_OBJECT;
+
+ BKE_id_copy(bmain, (ID *)sce, (ID **)&sce_copy);
id_us_min(&sce_copy->id);
id_us_ensure_real(&sce_copy->id);
+ if (duplicate_flags & USER_DUP_ACT) {
+ BKE_animdata_copy_id_action(bmain, &sce_copy->id, true);
+ }
+
/* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks. */
if (type == SCE_COPY_FULL) {
@@ -847,9 +853,12 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
if (is_scene_liboverride && ID_IS_LINKED(id)) {
continue;
}
- BKE_id_copy_ex(bmain, id, &id_new, LIB_ID_COPY_ACTIONS);
+ 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);
+ }
}
}
}
@@ -858,9 +867,12 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
id = &sce->world->id;
if (id && id->newid == NULL) {
if (!is_scene_liboverride || !ID_IS_LINKED(id)) {
- BKE_id_copy_ex(bmain, id, &id_new, LIB_ID_COPY_ACTIONS);
+ 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);
+ }
}
}
@@ -868,9 +880,12 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
id = &sce->gpd->id;
if (id && id->newid == NULL) {
if (!is_scene_liboverride || !ID_IS_LINKED(id)) {
- BKE_id_copy_ex(bmain, id, &id_new, LIB_ID_COPY_ACTIONS);
+ 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);
+ }
}
}
@@ -879,7 +894,7 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
BKE_collection_duplicate(bmain,
NULL,
sce_copy->master_collection,
- USER_DUP_OBJECT | U.dupflag,
+ duplicate_flags,
LIB_ID_DUPLICATE_IS_SUBPROCESS);
if (!is_subprocess) {
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 49a0121dadb..c18c08a87dc 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -5044,7 +5044,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_duplicate_action", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_ACT);
RNA_def_property_ui_text(
- prop, "Duplicate Action", "Causes actions to be duplicated with the object");
+ prop, "Duplicate Action", "Causes actions to be duplicated with the data-blocks");
prop = RNA_def_property(srna, "use_duplicate_particle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_PSYS);
More information about the Bf-blender-cvs
mailing list