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. --- release/datafiles/userdef/userdef_default.c | 6 +++--- release/scripts/startup/bl_ui/space_userpref.py | 9 +++++++-- 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 +++++++++++++++ 7 files changed, 39 insertions(+), 9 deletions(-) diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index b82d78b927e..3cbc6b26b4a 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -35,9 +35,9 @@ const UserDef U_default = { .subversionfile = BLENDER_FILE_SUBVERSION, .flag = (USER_AUTOSAVE | USER_TOOLTIPS | USER_RELPATHS | USER_RELEASECONFIRM | USER_SCRIPT_AUTOEXEC_DISABLE | USER_NONEGFRAMES), - .dupflag = USER_DUP_MESH | USER_DUP_CURVE | USER_DUP_SURF | USER_DUP_FONT | USER_DUP_MBALL | - USER_DUP_LAMP | USER_DUP_ARM | USER_DUP_ACT | USER_DUP_LIGHTPROBE | - USER_DUP_GPENCIL, + .dupflag = USER_DUP_MESH | USER_DUP_CURVE | USER_DUP_SURF | USER_DUP_LATTICE | USER_DUP_FONT | + USER_DUP_MBALL | USER_DUP_LAMP | USER_DUP_ARM | USER_DUP_CAMERA | USER_DUP_SPEAKER | + USER_DUP_ACT | USER_DUP_LIGHTPROBE | USER_DUP_GPENCIL, .pref_flag = USER_PREF_FLAG_SAVE, .savetime = 2, .tempdir = "", diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index e5f6cff79ee..bb3b3fbc23b 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -398,21 +398,26 @@ class USERPREF_PT_edit_objects_duplicate_data(EditingPanel, CenterAlignMixIn, Pa col = flow.column() col.prop(edit, "use_duplicate_action", text="Action") col.prop(edit, "use_duplicate_armature", text="Armature") + col.prop(edit, "use_duplicate_camera", text="Camera") col.prop(edit, "use_duplicate_curve", text="Curve") # col.prop(edit, "use_duplicate_fcurve", text="F-Curve") # Not implemented. col.prop(edit, "use_duplicate_grease_pencil", text="Grease Pencil") if hasattr(edit, "use_duplicate_hair"): col.prop(edit, "use_duplicate_hair", text="Hair") - col.prop(edit, "use_duplicate_light", text="Light") + col = flow.column() + col.prop(edit, "use_duplicate_lattice", text="Lattice") + col.prop(edit, "use_duplicate_light", text="Light") col.prop(edit, "use_duplicate_lightprobe", text="Light Probe") col.prop(edit, "use_duplicate_material", text="Material") col.prop(edit, "use_duplicate_mesh", text="Mesh") col.prop(edit, "use_duplicate_metaball", text="Metaball") - col.prop(edit, "use_duplicate_particle", text="Particle") + col = flow.column() + col.prop(edit, "use_duplicate_particle", text="Particle") if hasattr(edit, "use_duplicate_pointcloud"): col.prop(edit, "use_duplicate_pointcloud", text="Point Cloud") + col.prop(edit, "use_duplicate_speaker", text="Speaker") col.prop(edit, "use_duplicate_surface", text="Surface") col.prop(edit, "use_duplicate_text", text="Text") # col.prop(edit, "use_duplicate_texture", text="Texture") # Not implemented. 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