[Bf-extensions-cvs] [8f830f44] master: Fix T52714: Dynamic Sky not working with localization enabled

lijenstina noreply at git.blender.org
Mon Sep 18 21:09:52 CEST 2017


Commit: 8f830f44e9a1f118ab60b4eab6e667e9164f8acd
Author: lijenstina
Date:   Mon Sep 18 21:08:56 2017 +0200
Branches: master
https://developer.blender.org/rBA8f830f44e9a1f118ab60b4eab6e667e9164f8acd

Fix T52714: Dynamic Sky not working with localization enabled

Bumped version to 1.0.6
Adress the issue of accessing nodes with string keys
Since they are translated in other UI languages
could cause material generation to fail

Add a poll to the operator as it only works if
Cycles is enabled in add-ons
Improve the tooltip

If possible, to be included in the 2.79a version

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

M	lighting_dynamic_sky.py

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

diff --git a/lighting_dynamic_sky.py b/lighting_dynamic_sky.py
index f5358a45..98d61fd6 100644
--- a/lighting_dynamic_sky.py
+++ b/lighting_dynamic_sky.py
@@ -22,7 +22,7 @@
 bl_info = {
     "name": "Dynamic Sky",
     "author": "Pratik Solanki",
-    "version": (1, 0, 4),
+    "version": (1, 0, 6),
     "blender": (2, 78, 0),
     "location": "View3D > Tools",
     "description": "Creates Dynamic Sky for Cycles",
@@ -71,10 +71,26 @@ def check_world_name(name_id="Dynamic"):
     return name_id
 
 
+def check_cycles():
+    return ('cycles' in bpy.context.user_preferences.addons.keys())
+
+
 class dsky(Operator):
     bl_idname = "sky.dyn"
     bl_label = "Make a Procedural sky"
-    bl_description = "Make a Procedural Sky"
+    bl_description = ("Make a Procedural Sky with parameters in the 3D View\n"
+                      "Note: Available just for Cycles renderer\n"
+                      "Only the last created Dynamic World can be accessed from this panel")
+
+    @classmethod
+    def poll(cls, context):
+        return check_cycles()
+
+    def get_node_types(self, node_tree, node_type):
+        for node in node_tree.nodes:
+            if node.type == node_type:
+                return node
+        return None
 
     def execute(self, context):
         try:
@@ -88,48 +104,67 @@ class dsky(Operator):
             world.use_nodes = True
 
             nt = world.node_tree
-            bg = world.node_tree.nodes['Background']
-
+            # Note: (see T52714) to avoid string localization problems, assign the name for
+            # nodes that will be exposed in the 3D view (pattern UI name with underscore)
+            bg = self.get_node_types(nt, "BACKGROUND")
+            bg.name = "Scene_Brightness"
             bg.inputs[0].default_value[:3] = (0.5, .1, 0.6)
             bg.inputs[1].default_value = 1
+            bg.location = (6708.3, 360)
+
             ntl = nt.links.new
             tcor = nt.nodes.new(type="ShaderNodeTexCoord")
-            map = nt.nodes.new(type="ShaderNodeMapping")
-            map.vector_type = 'NORMAL'
+            tcor.location = (243.729, 1005)
+
+            map1 = nt.nodes.new(type="ShaderNodeMapping")
+            map1.vector_type = 'NORMAL'
+            map1.location = (786.54, 730)
 
             nor = nt.nodes.new(type="ShaderNodeNormal")
+            nor.name = "Sky_normal"
+            nor.location = (1220.16, 685)
 
             cr1 = nt.nodes.new(type="ShaderNodeValToRGB")
             cr1.color_ramp.elements[0].position = 0.969
             cr1.color_ramp.interpolation = 'EASE'
+            cr1.location = (1671.33, 415)
             cr2 = nt.nodes.new(type="ShaderNodeValToRGB")
             cr2.color_ramp.elements[0].position = 0.991
             cr2.color_ramp.elements[1].position = 1
             cr2.color_ramp.interpolation = 'EASE'
+            cr2.location = (2196.6, 415)
             cr3 = nt.nodes.new(type="ShaderNodeValToRGB")
             cr3.color_ramp.elements[0].position = 0.779
             cr3.color_ramp.elements[1].position = 1
             cr3.color_ramp.interpolation = 'EASE'
+            cr3.location = (2196.6, 415)
 
             mat1 = nt.nodes.new(type="ShaderNodeMath")
             mat1.operation = 'MULTIPLY'
             mat1.inputs[1].default_value = 0.2
+            mat1.location = (2196.6, 685)
             mat2 = nt.nodes.new(type="ShaderNodeMath")
             mat2.operation = 'MULTIPLY'
             mat2.inputs[1].default_value = 2
+            mat2.location = (3294, 685)
             mat3 = nt.nodes.new(type="ShaderNodeMath")
             mat3.operation = 'MULTIPLY'
             mat3.inputs[1].default_value = 40.9
+            mat3.location = (2745.24, 415)
             mat4 = nt.nodes.new(type="ShaderNodeMath")
             mat4.operation = 'SUBTRACT'
             mat4.inputs[1].default_value = 1
+            mat4.location = (3294, 415)
             ntl(mat2.inputs[0], mat1.outputs[0])
             ntl(mat4.inputs[0], mat3.outputs[0])
             ntl(mat1.inputs[0], cr3.outputs[0])
             ntl(mat3.inputs[0], cr2.outputs[0])
 
             soft = nt.nodes.new(type="ShaderNodeMixRGB")
+            soft.name = "Soft_hard"
+            soft.location = (3819.3, 550)
             soft_1 = nt.nodes.new(type="ShaderNodeMixRGB")
+            soft_1.location = (3819.3, 185)
             soft.inputs[0].default_value = 1
             soft_1.inputs[0].default_value = 0.466
             ntl(soft.inputs[1], mat2.outputs[0])
@@ -140,12 +175,16 @@ class dsky(Operator):
             mix1 = nt.nodes.new(type="ShaderNodeMixRGB")
             mix1.blend_type = 'MULTIPLY'
             mix1.inputs[0].default_value = 1
+            mix1.location = (4344.3, 630)
             mix1_1 = nt.nodes.new(type="ShaderNodeMixRGB")
             mix1_1.blend_type = 'MULTIPLY'
             mix1_1.inputs[0].default_value = 1
+            mix1_1.location = (4344.3, 90)
 
             mix2 = nt.nodes.new(type="ShaderNodeMixRGB")
+            mix2.location = (4782, 610)
             mix2_1 = nt.nodes.new(type="ShaderNodeMixRGB")
+            mix2_1.location = (5131.8, 270)
             mix2.inputs[1].default_value = (0, 0, 0, 1)
             mix2.inputs[2].default_value = (32, 22, 14, 200)
             mix2_1.inputs[1].default_value = (0, 0, 0, 1)
@@ -158,22 +197,33 @@ class dsky(Operator):
 
             gam = nt.nodes.new(type="ShaderNodeGamma")
             gam.inputs[1].default_value = 2.3
+            gam.location = (5131.8, 610)
+
             gam2 = nt.nodes.new(type="ShaderNodeGamma")
+            gam2.name = "Sun_value"
             gam2.inputs[1].default_value = 1
+            gam2.location = (5524.5, 610)
+
             gam3 = nt.nodes.new(type="ShaderNodeGamma")
+            gam3.name = "Shadow_color_saturation"
             gam3.inputs[1].default_value = 1
+            gam3.location = (5524.5, 880)
 
             sunopa = nt.nodes.new(type="ShaderNodeMixRGB")
             sunopa.blend_type = 'ADD'
             sunopa.inputs[0].default_value = 1
+            sunopa.location = (5940.6, 610)
             sunopa_1 = nt.nodes.new(type="ShaderNodeMixRGB")
             sunopa_1.blend_type = 'ADD'
             sunopa_1.inputs[0].default_value = 1
+            sunopa_1.location = (5524.5, 340)
 
             combine = nt.nodes.new(type="ShaderNodeMixRGB")
+            combine.location = (6313.8, 360)
             ntl(combine.inputs[1], sunopa.outputs[0])
             ntl(combine.inputs[2], sunopa_1.outputs[0])
             lp = nt.nodes.new(type="ShaderNodeLightPath")
+            lp.location = (5940.6, 130)
             ntl(combine.inputs[0], lp.outputs[0])
 
             ntl(gam2.inputs[0], gam.outputs[0])
@@ -184,25 +234,33 @@ class dsky(Operator):
             map2.scale[2] = 6.00
             map2.scale[0] = 1.5
             map2.scale[1] = 1.5
+            map2.location = (2196.6, 1510)
 
             n1 = nt.nodes.new(type="ShaderNodeTexNoise")
             n1.inputs[1].default_value = 3.8
             n1.inputs[2].default_value = 2.4
             n1.inputs[3].default_value = 0.5
+            n1.location = (2745.24, 1780)
 
             n2 = nt.nodes.new(type="ShaderNodeTexNoise")
             n2.inputs[1].default_value = 2.0
             n2.inputs[2].default_value = 10
             n2.inputs[3].default_value = 0.2
+            n2.location = (2745.24, 1510)
 
             ntl(n2.inputs[0], map2.outputs[0])
             ntl(n1.inputs[0], map2.outputs[0])
 
             sc1 = nt.nodes.new(type="ShaderNodeValToRGB")
+            sc1.location = (3294, 1780)
             sc2 = nt.nodes.new(type="ShaderNodeValToRGB")
+            sc2.location = (3294, 1510)
             sc3 = nt.nodes.new(type="ShaderNodeValToRGB")
+            sc3.location = (3819.3, 820)
             sc3_1 = nt.nodes.new(type="ShaderNodeValToRGB")
+            sc3_1.location = (4344.3, 1360)
             sc4 = nt.nodes.new(type="ShaderNodeValToRGB")
+            sc4.location = (3819.3, 1090)
 
             sc1.color_ramp.elements[1].position = 0.649
             sc1.color_ramp.elements[0].position = 0.408
@@ -234,11 +292,24 @@ class dsky(Operator):
             sc3_1.color_ramp.elements[0].position = 0.0
 
             smix1 = nt.nodes.new(type="ShaderNodeMixRGB")
+            smix1.location = (3819.3, 1550)
+            smix1.name = "Cloud_color"
             smix2 = nt.nodes.new(type="ShaderNodeMixRGB")
+            smix2.location = (4344.3, 1630)
+            smix2.name = "Cloud_density"
             smix2_1 = nt.nodes.new(type="ShaderNodeMixRGB")
+            smix2_1.location = (4782, 1360)
+
             smix3 = nt.nodes.new(type="ShaderNodeMixRGB")
+            smix3.location = (4344.3, 1090)
+            smix3.name = "Sky_and_Horizon_colors"
+
             smix4 = nt.nodes.new(type="ShaderNodeMixRGB")
+            smix4.location = (4782, 880)
+
             smix5 = nt.nodes.new(type="ShaderNodeMixRGB")
+            smix5.name = "Cloud_opacity"
+            smix5.location = (5131.8, 880)
 
             smix1.inputs[1].default_value = (1, 1, 1, 1)
             smix1.inputs[2].default_value = (0, 0, 0, 1)
@@ -255,12 +326,18 @@ class dsky(Operator):
             smix5.inputs[0].default_value = 1
 
             srgb = nt.nodes.new(type="ShaderNodeSeparateRGB")
+            srgb.location = (786.54, 1370)
             aniadd = nt.nodes.new(type="ShaderNodeMath")
+            aniadd.location = (1220.16, 1235)
             crgb = nt.nodes.new(type="ShaderNodeCombineRGB")
+            crgb.location = (1671.33, 1510)
             sunrgb = nt.nodes.new(type="ShaderNodeMixRGB")
+            sunrgb.name = "Sun_color"
+
             sunrgb.blend_type = 'MULTIPLY'
             sunrgb.inputs[2].default_value = (32, 30, 30, 200)
             sunrgb.inputs[0].default_value = 1
+            sunrgb.location = (4344.3, 360)
 
             ntl(mix2.inputs[2], sunrgb.outputs[0])
 
@@ -283,6 +360,7 @@ class dsky(Operator):
             ntl(sc2.inputs[0], n2.outputs[0])
 
             skynor = nt.nodes.new(type="ShaderNodeNormal")
+            skynor.location = (3294, 1070)
 
             ntl(sc3.inputs[0], skynor.outputs[1])
             ntl(sc4.inputs[0], skynor.outputs[1])
@@ -299,69 +377,19 @@ class dsky(Operator):
             ntl(cr1.i

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list