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.
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user