Fix #120447: Anim/Drivers on Bone Collections created in 4.0 break in 4.1 #120514
|
@ -29,7 +29,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 14
|
||||
#define BLENDER_FILE_SUBVERSION 15
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
|
|
@ -245,6 +245,23 @@ static void version_bonegroups_to_bonecollections(Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change animation/drivers from "collections[..." to "collections_all[..." so
|
||||
* they remain stable when the bone collection hierarchy structure changes.
|
||||
*/
|
||||
static void version_bonecollection_anim(FCurve *fcurve)
|
||||
{
|
||||
const blender::StringRef rna_path(fcurve->rna_path);
|
||||
constexpr char const *rna_path_prefix = "collections[";
|
||||
if (!rna_path.startswith(rna_path_prefix)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string path_remainder(rna_path.drop_known_prefix(rna_path_prefix));
|
||||
MEM_freeN(fcurve->rna_path);
|
||||
fcurve->rna_path = BLI_sprintfN("collections_all[%s", path_remainder.c_str());
|
||||
}
|
||||
|
||||
static void version_principled_bsdf_update_animdata(ID *owner_id, bNodeTree *ntree)
|
||||
{
|
||||
ID *id = &ntree->id;
|
||||
|
@ -495,6 +512,27 @@ void do_versions_after_linking_400(FileData *fd, Main *bmain)
|
|||
version_nla_tweakmode_incomplete(bmain);
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 15)) {
|
||||
/* Change drivers and animation on "armature.collections" to
|
||||
* ".collections_all", so that they are drawn correctly in the tree view,
|
||||
* and keep working when the collection is moved around in the hierarchy. */
|
||||
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
|
||||
AnimData *adt = BKE_animdata_from_id(&arm->id);
|
||||
if (!adt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (FCurve *, fcurve, &adt->drivers) {
|
||||
version_bonecollection_anim(fcurve);
|
||||
}
|
||||
if (adt->action) {
|
||||
LISTBASE_FOREACH (FCurve *, fcurve, &adt->action->curves) {
|
||||
version_bonecollection_anim(fcurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
|
||||
|
|
Loading…
Reference in New Issue