From 089383a53a05baf80501a9610d0c66dfb0729c96 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Mon, 11 Dec 2023 10:54:34 +0100 Subject: [PATCH] Cleanup: rename bArmature.collections -> bArmature.collections_legacy And leave a TODO to remove it entirely in Blender 5.0. Pull Request: https://projects.blender.org/blender/blender/pulls/115931 --- source/blender/blenkernel/intern/armature.cc | 16 ++++++++-------- source/blender/makesdna/DNA_armature_types.h | 10 ++++++---- source/blender/makesdna/intern/dna_rename_defs.h | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.cc b/source/blender/blenkernel/intern/armature.cc index 595a2142b55..af782a5413b 100644 --- a/source/blender/blenkernel/intern/armature.cc +++ b/source/blender/blenkernel/intern/armature.cc @@ -320,8 +320,8 @@ static void armature_blend_write(BlendWriter *writer, ID *id, const void *id_add arm->collection_array[i]->next = arm->collection_array[i + 1]; arm->collection_array[i + 1]->prev = arm->collection_array[i]; } - arm->collections.first = arm->collection_array[0]; - arm->collections.last = arm->collection_array[arm->collection_array_num - 1]; + arm->collections_legacy.first = arm->collection_array[0]; + arm->collections_legacy.last = arm->collection_array[arm->collection_array_num - 1]; arm->collection_array = nullptr; } @@ -333,7 +333,7 @@ static void armature_blend_write(BlendWriter *writer, ID *id, const void *id_add write_bone(writer, bone); } - LISTBASE_FOREACH (BoneCollection *, bcoll, &arm->collections) { + LISTBASE_FOREACH (BoneCollection *, bcoll, &arm->collections_legacy) { write_bone_collection(writer, bcoll); } @@ -343,7 +343,7 @@ static void armature_blend_write(BlendWriter *writer, ID *id, const void *id_add arm->collection_array[i]->next = nullptr; arm->collection_array[i + 1]->prev = nullptr; } - BLI_listbase_clear(&arm->collections); + BLI_listbase_clear(&arm->collections_legacy); arm->runtime = runtime_backup; } @@ -382,13 +382,13 @@ static void direct_link_bone_collection(BlendDataReader *reader, BoneCollection static void read_bone_collections(BlendDataReader *reader, bArmature *arm) { /* Read as listbase, but convert to an array on the armature. */ - BLO_read_list(reader, &arm->collections); - arm->collection_array_num = BLI_listbase_count(&arm->collections); + BLO_read_list(reader, &arm->collections_legacy); + arm->collection_array_num = BLI_listbase_count(&arm->collections_legacy); arm->collection_array = (BoneCollection **)MEM_malloc_arrayN( arm->collection_array_num, sizeof(BoneCollection *), __func__); { int i; - LISTBASE_FOREACH_INDEX (BoneCollection *, bcoll, &arm->collections, i) { + LISTBASE_FOREACH_INDEX (BoneCollection *, bcoll, &arm->collections_legacy, i) { arm->collection_array[i] = bcoll; } } @@ -399,7 +399,7 @@ static void read_bone_collections(BlendDataReader *reader, bArmature *arm) arm->collection_array[i]->next = nullptr; arm->collection_array[i + 1]->prev = nullptr; } - BLI_listbase_clear(&arm->collections); + BLI_listbase_clear(&arm->collections_legacy); /* Bone collections added via an override can be edited, but ones that already exist in another diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 4a11fc47bc5..b3397d7a490 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -189,10 +189,12 @@ typedef struct bArmature { short pathflag; /** This is used only for reading/writing BoneCollections in blend - * files, for forwards/backwards compatibility with Blender 4.0. It - * should always be empty at runtime. - * Use collection_array for everything other than file reading/writing. */ - ListBase collections; /* BoneCollection. */ + * files, for forwards/backwards compatibility with Blender 4.0. It + * should always be empty at runtime. Use collection_array for + * everything other than file reading/writing. + * TODO: remove this in Blender 5.0, and instead write the contents of + * collection_array to blend files directly. */ + ListBase collections_legacy; /* BoneCollection. */ struct BoneCollection **collection_array; /* Array of `collection_array_num` BoneCollections. */ int collection_array_num; diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index a51f65b2735..f35dc9c663a 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -182,6 +182,7 @@ DNA_STRUCT_RENAME_ELEM(View3D, near, clip_start) DNA_STRUCT_RENAME_ELEM(View3D, ob_centre, ob_center) DNA_STRUCT_RENAME_ELEM(View3D, ob_centre_bone, ob_center_bone) DNA_STRUCT_RENAME_ELEM(View3D, ob_centre_cursor, ob_center_cursor) +DNA_STRUCT_RENAME_ELEM(bArmature, collections, collections_legacy) DNA_STRUCT_RENAME_ELEM(bGPDstroke, gradient_f, hardness) DNA_STRUCT_RENAME_ELEM(bGPDstroke, gradient_s, aspect_ratio) DNA_STRUCT_RENAME_ELEM(bNodeTree, inputs, inputs_legacy)