From 65dbeb1d81bff6c5742eb5f503b59207485041a9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 22 Oct 2021 12:33:03 +0200 Subject: Fix T90638: Inconsistent object data behavior when link-duplicating collections. Camera, lattice and speaker object types were missing there own proper `USER_DUP_` flags, leading to not properly handling duplication of their object data. NOTE: We could probably simply opions here, by using categories (like 'GEOMETRY', 'SHADING', etc.) instead of exact object types. But this is beyond bugfix scope. --- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenkernel/intern/object.c | 6 +++--- source/blender/blenloader/intern/versioning_userdef.c | 7 +++++++ source/blender/makesdna/DNA_userdef_types.h | 3 +++ source/blender/makesrna/intern/rna_userdef.c | 15 +++++++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 32b607ecf9b..3f8b56b2736 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -39,7 +39,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 37 +#define BLENDER_FILE_SUBVERSION 38 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3ec7370a47f..e85c6b4c7c5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2760,12 +2760,12 @@ Object *BKE_object_duplicate(Main *bmain, } break; case OB_LATTICE: - if (dupflag != 0) { + if (dupflag & USER_DUP_LATTICE) { id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; case OB_CAMERA: - if (dupflag != 0) { + if (dupflag & USER_DUP_CAMERA) { id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; @@ -2775,7 +2775,7 @@ Object *BKE_object_duplicate(Main *bmain, } break; case OB_SPEAKER: - if (dupflag != 0) { + if (dupflag & USER_DUP_SPEAKER) { id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index b95de52a0cd..170e6be715a 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -916,6 +916,13 @@ void blo_do_versions_userdef(UserDef *userdef) userdef->flag &= ~USER_FLAG_UNUSED_5; } + if (!USER_VERSION_ATLEAST(300, 38)) { + /* Patch to set Dupli Lattice/Camera/Speaker. */ + userdef->dupflag |= USER_DUP_LATTICE; + userdef->dupflag |= USER_DUP_CAMERA; + userdef->dupflag |= USER_DUP_SPEAKER; + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 7e1df5dec36..4f91d6b2fbb 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1248,6 +1248,9 @@ typedef enum eDupli_ID_Flags { USER_DUP_HAIR = (1 << 14), USER_DUP_POINTCLOUD = (1 << 15), USER_DUP_VOLUME = (1 << 16), + USER_DUP_LATTICE = (1 << 17), + USER_DUP_CAMERA = (1 << 18), + USER_DUP_SPEAKER = (1 << 19), USER_DUP_OBDATA = (~0) & ((1 << 24) - 1), diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index c80ba4ef6e6..37d2b711b7d 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -5181,6 +5181,11 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Duplicate Curve", "Causes curve data to be duplicated with the object"); + prop = RNA_def_property(srna, "use_duplicate_lattice", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LATTICE); + RNA_def_property_ui_text( + prop, "Duplicate Lattice", "Causes lattice data to be duplicated with the object"); + prop = RNA_def_property(srna, "use_duplicate_text", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_FONT); RNA_def_property_ui_text( @@ -5196,6 +5201,16 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Duplicate Armature", "Causes armature data to be duplicated with the object"); + prop = RNA_def_property(srna, "use_duplicate_camera", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_CAMERA); + RNA_def_property_ui_text( + prop, "Duplicate Camera", "Causes camera data to be duplicated with the object"); + + prop = RNA_def_property(srna, "use_duplicate_speaker", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_SPEAKER); + RNA_def_property_ui_text( + prop, "Duplicate Speaker", "Causes speaker data to be duplicated with the object"); + prop = RNA_def_property(srna, "use_duplicate_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LAMP); RNA_def_property_ui_text( -- cgit v1.2.3