Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-11-01 20:50:34 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-11-01 20:51:55 +0300
commit4ed1e19d2f30f2b4ba4313feeaa7c4e56f96b891 (patch)
treeb4cd48b44600212b692c5cc1c8e539cc51c1b984 /source/blender/blenloader/intern/versioning_290.c
parent2f667c2bc949b31e7e80a67905394e1e5a0bd762 (diff)
Cleanup: extract versioning code for remapping node socket animation
When node input sockets are animated, they target the socket by index. As a result, animation data needs to be updated whenever new sockets are added (except when they're added at the end of the list). The code for this is now extracted into its own versioning function, so that it can be used for other versioning steps as well. No functional changes.
Diffstat (limited to 'source/blender/blenloader/intern/versioning_290.c')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index def14768ec6..f82b7970a60 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -605,34 +605,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
*
* To play safe we move all the inputs beyond 18 to their rightful new place.
* In case users are doing unexpected things with not-really supported keyframeable channels.
- *
- * The for loop for the input ids is at the top level otherwise we lose the animation
- * keyframe data.
*/
- for (int input_id = 21; input_id >= 18; input_id--) {
- FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type != SH_NODE_BSDF_PRINCIPLED) {
- continue;
- }
-
- const size_t node_name_length = strlen(node->name);
- const size_t node_name_escaped_max_length = (node_name_length * 2);
- char *node_name_escaped = MEM_mallocN(node_name_escaped_max_length + 1,
- "escaped name");
- BLI_str_escape(node_name_escaped, node->name, node_name_escaped_max_length);
- char *rna_path_prefix = BLI_sprintfN("nodes[\"%s\"].inputs", node_name_escaped);
-
- BKE_animdata_fix_paths_rename_all_ex(
- bmain, id, rna_path_prefix, NULL, NULL, input_id, input_id + 1, false);
- MEM_freeN(rna_path_prefix);
- MEM_freeN(node_name_escaped);
- }
- }
- }
- FOREACH_NODETREE_END;
- }
+ version_node_socket_index_animdata(bmain, NTREE_SHADER, SH_NODE_BSDF_PRINCIPLED, 18, 1, 22);
}
/* Convert all Multires displacement to Catmull-Clark subdivision limit surface. */