[Bf-blender-cvs] [615b0faa389] soc-2019-cycles-procedural: Revert "Restructure versioning code to avoid duplicate iterations. Pre-linking."

OmarSquircleArt noreply at git.blender.org
Mon Aug 5 12:14:33 CEST 2019


Commit: 615b0faa389b63a70c01d60aea80770941cb99dd
Author: OmarSquircleArt
Date:   Mon Aug 5 12:10:29 2019 +0200
Branches: soc-2019-cycles-procedural
https://developer.blender.org/rB615b0faa389b63a70c01d60aea80770941cb99dd

Revert "Restructure versioning code to avoid duplicate iterations. Pre-linking."

This reverts commit eae462bc89a59ec24e114ea0012ea6cda0defa0c. The previouse structure
was more readable and clear since every function edits the node tree individually.

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

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 48b1b665d0c..3fcec749432 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -400,19 +400,23 @@ static void light_emission_unify(Light *light, const char *engine)
  * 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(bNode *mathNode)
+static void update_math_socket_names_and_identifiers(bNodeTree *ntree)
 {
-  bNodeSocket *sockA = mathNode->inputs.first;
-  bNodeSocket *sockB = sockA->next;
-  bNodeSocket *sockResult = mathNode->outputs.first;
+  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->name, "A");
+      strcpy(sockB->name, "B");
+      strcpy(sockResult->name, "Result");
 
-  strcpy(sockA->identifier, "A");
-  strcpy(sockB->identifier, "B");
-  strcpy(sockResult->identifier, "Result");
+      strcpy(sockA->identifier, "A");
+      strcpy(sockB->identifier, "B");
+      strcpy(sockResult->identifier, "Result");
+    }
+  }
 }
 
 /* The B input of the Math node is no longer used for single-operand operators.
@@ -495,16 +499,20 @@ static void update_math_clamp_option(bNodeTree *ntree)
  * update them here. The sockets' identifiers needs to be updated as well since
  * they are autmatically generated from the name.
  */
-static void update_vector_math_socket_names_and_identifiers(bNode *vectorMathNode)
+static void update_vector_math_socket_names_and_identifiers(bNodeTree *ntree)
 {
-  bNodeSocket *sockA = vectorMathNode->inputs.first;
-  bNodeSocket *sockB = sockA->next;
+  for (bNode *node = ntree->nodes.first; node; node = node->next) {
+    if (node->type == SH_NODE_VECTOR_MATH) {
+      bNodeSocket *sockA = node->inputs.first;
+      bNodeSocket *sockB = sockA->next;
 
-  strcpy(sockA->name, "A");
-  strcpy(sockB->name, "B");
+      strcpy(sockA->name, "A");
+      strcpy(sockB->name, "B");
 
-  strcpy(sockA->identifier, "A");
-  strcpy(sockB->identifier, "B");
+      strcpy(sockA->identifier, "A");
+      strcpy(sockB->identifier, "B");
+    }
+  }
 }
 
 /* The Value output of the Vector Math node is no longer available in the Add
@@ -735,18 +743,22 @@ static void update_vector_normalize_operators(bNodeTree *ntree)
  * NODE_VECTOR_MATH_AVERAGE : 2 -> -1
  *
  */
-static void update_vector_math_operators_enum_mapping(bNode *vectorMathNode)
+static void update_vector_math_operators_enum_mapping(bNodeTree *ntree)
 {
-  switch (vectorMathNode->custom1) {
-    case 2:
-      vectorMathNode->custom1 = -1;
-      break;
-    case 3:
-      vectorMathNode->custom1 = 7;
-      break;
-    case 5:
-      vectorMathNode->custom1 = 11;
-      break;
+  for (bNode *node = ntree->nodes.first; node; node = node->next) {
+    if (node->type == SH_NODE_VECTOR_MATH) {
+      switch (node->custom1) {
+        case 2:
+          node->custom1 = -1;
+          break;
+        case 3:
+          node->custom1 = 7;
+          break;
+        case 5:
+          node->custom1 = 11;
+          break;
+      }
+    }
   }
 }
 
@@ -855,19 +867,12 @@ 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) {
-        for (bNode *node = ntree->nodes.first; node; node = node->next) {
-          switch (node->type) {
-            case SH_NODE_MATH:
-              update_math_socket_names_and_identifiers(node);
-              break;
-            case SH_NODE_VECTOR_MATH:
-              update_vector_math_socket_names_and_identifiers(node);
-              update_vector_math_operators_enum_mapping(node);
-              break;
-          }
-        }
+      if (ntree->type != NTREE_SHADER) {
+        continue;
       }
+      update_math_socket_names_and_identifiers(ntree);
+      update_vector_math_socket_names_and_identifiers(ntree);
+      update_vector_math_operators_enum_mapping(ntree);
     }
     FOREACH_NODETREE_END;
   }



More information about the Bf-blender-cvs mailing list