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.
This commit is contained in:
Bastien Montagne 2021-10-22 12:33:03 +02:00
parent d092933abb
commit 65dbeb1d81
Notes: blender-bot 2023-02-14 08:38:11 +01:00
Referenced by issue #90638, Inconsistent object data behavior when link-duplicating collections.
7 changed files with 39 additions and 9 deletions

View File

@ -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 = "",

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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.
*

View File

@ -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),

View File

@ -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(