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
This commit is contained in:
Nathan Vegdahl 2023-12-11 10:54:34 +01:00 committed by Nathan Vegdahl
parent 1b99987043
commit 089383a53a
3 changed files with 15 additions and 12 deletions

View File

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

View File

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

View File

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