[Bf-blender-cvs] [3e0c405efcf] soc-2019-cycles-procedural: Fix Math node backward compatibility. Update socket names and identifiers.

OmarSquircleArt noreply at git.blender.org
Thu Aug 1 20:20:03 CEST 2019


Commit: 3e0c405efcf9574d7df3fc166c60c8bd6e50419a
Author: OmarSquircleArt
Date:   Thu Aug 1 20:21:01 2019 +0200
Branches: soc-2019-cycles-procedural
https://developer.blender.org/rB3e0c405efcf9574d7df3fc166c60c8bd6e50419a

Fix Math node backward compatibility. Update socket names and identifiers.

===================================================================

M	source/blender/blenloader/intern/versioning_cycles.c

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index 5174da4d1f8..5436eb9a5d5 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -385,6 +385,29 @@ static void light_emission_unify(Light *light, const char *engine)
   }
 }
 
+/* The names of the sockets of the Math node were changed. So we have to update
+ * them here. The sockets' identifiers needs to be updated as well since they
+ * are autmatically generated from the name.
+ */
+static void update_math_socket_names_and_identifiers(bNodeTree *ntree)
+{
+  for (bNode *node = ntree->nodes.first; node; node = node->next) {
+    if (node->type == SH_NODE_MATH) {
+      bNodeSocket *sockA = node->inputs.first;
+      bNodeSocket *sockB = sockA->next;
+      bNodeSocket *sockResult = node->outputs.first;
+
+      strcpy(sockA->name, "A");
+      strcpy(sockB->name, "B");
+      strcpy(sockResult->name, "Result");
+
+      strcpy(sockA->identifier, "A");
+      strcpy(sockB->identifier, "B");
+      strcpy(sockResult->identifier, "Result");
+    }
+  }
+}
+
 void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bmain)
 {
   /* Particle shape shared with Eevee. */
@@ -417,6 +440,16 @@ void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bm
       }
     }
   }
+
+  if (1) {
+    FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+      if (ntree->type != NTREE_SHADER) {
+        continue;
+      }
+      update_math_socket_names_and_identifiers(ntree);
+    }
+    FOREACH_NODETREE_END;
+  }
 }
 
 void do_versions_after_linking_cycles(Main *bmain)



More information about the Bf-blender-cvs mailing list