Fix #101014: Broken mix shader node links when opening particular old file
For some reason, the file in this report had its second mix shader socket with the identifier "Socket.001" instead of the current "Socket_001". The age of the file roughly corresponds to when we switched to the node declaration system. I'm not sure why it has `.` instead of `_`, since the old socket template system also used `_` as the deliminator. I vaguely remember some issue like this but it's been a while and I can't find anything online. The fix is to just manually change the socket identifier. The subversion bump isn't conceptually necessary, it's just to stop the versioning from running more often than necessary once the file is saved again. Pull Request: https://projects.blender.org/blender/blender/pulls/132199
This commit is contained in:
@@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 15
|
||||
#define BLENDER_FILE_SUBVERSION 16
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -5361,6 +5361,24 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
/* Fix incorrect identifier in the shader mix node. */
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 404, 16)) {
|
||||
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
||||
if (ntree->type == NTREE_SHADER) {
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->type == SH_NODE_MIX_SHADER) {
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
||||
if (STREQ(socket->identifier, "Shader.001")) {
|
||||
STRNCPY(socket->identifier, "Shader_001");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
}
|
||||
|
||||
/* Always run this versioning; meshes are written with the legacy format which always needs to
|
||||
* be converted to the new format on file load. Can be moved to a subversion check in a larger
|
||||
* breaking release. */
|
||||
|
||||
Reference in New Issue
Block a user