Freestyle: Properly reconnect links from a UV Along Stroke node to a UV Map node.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 20 Jul 2014 07:21:05 +0000 (16:21 +0900)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Tue, 12 Aug 2014 01:10:42 +0000 (10:10 +0900)
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp

index 5d4a2adad81a972b4be4ddb921d0e70d921bbe79..d0ab6b1a606fa8c26c79031711aed6b1368d69e3 100644 (file)
@@ -346,21 +346,33 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, bNode
                outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 3); // Alpha Fac
 #endif
 
-#if 0
                for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
-                       if (node->type == SH_NODE_TEX_IMAGE) {
+                       if (node->type == SH_NODE_UVALONGSTROKE) {
+                               // UV output of the UV Along Stroke node
+                               bNodeSocket *sock = (bNodeSocket *)BLI_findlink(&node->outputs, 0);
+
+                               // add new UV Map node
                                bNode *input_uvmap = nodeAddStaticNode(C, ntree, SH_NODE_UVMAP);
                                input_uvmap->locx = node->locx - 200.0f;
                                input_uvmap->locy = node->locy;
                                NodeShaderUVMap *storage = (NodeShaderUVMap *)input_uvmap->storage;
-                               BLI_strncpy(storage->uv_map, "along_stroke_tips", sizeof(storage->uv_map));
-
+                               if (node->custom1 & 1) { // use_tips
+                                       BLI_strncpy(storage->uv_map, "along_stroke_tips", sizeof(storage->uv_map));
+                               }
+                               else {
+                                       BLI_strncpy(storage->uv_map, "along_stroke", sizeof(storage->uv_map));
+                               }
                                fromsock = (bNodeSocket *)BLI_findlink(&input_uvmap->outputs, 0); // UV
-                               tosock = (bNodeSocket *)BLI_findlink(&node->inputs, 0); // Vector
-                               nodeAddLink(ntree, input_uvmap, fromsock, node, tosock);
+
+                               // replace links from the UV Along Stroke node by links from the UV Map node
+                               for (bNodeLink *link = (bNodeLink *)ntree->links.first; link; link = link->next) {
+                                       if (link->fromnode == node && link->fromsock == sock) {
+                                               nodeAddLink(ntree, input_uvmap, fromsock, link->tonode, link->tosock);
+                                       }
+                               }
+                               nodeRemSocketLinks(ntree, sock);
                        }
                }
-#endif
        }
 
        nodeSetActive(ntree, shader_mix);