[Bf-blender-cvs] [df96455c551] master: UI: add light/world settings in shader node editor.

Brecht Van Lommel noreply at git.blender.org
Sun Mar 17 21:56:00 CET 2019


Commit: df96455c55110da00f0543c5895376ffbc66313b
Author: Brecht Van Lommel
Date:   Sun Mar 17 17:52:05 2019 +0100
Branches: master
https://developer.blender.org/rBdf96455c55110da00f0543c5895376ffbc66313b

UI: add light/world settings in shader node editor.

Material was already there. Implementation was changed so it's just a
single line of code to adapt a panel to the node editor.

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

M	intern/cycles/blender/addon/ui.py
M	release/scripts/startup/bl_ui/properties_data_light.py
M	release/scripts/startup/bl_ui/properties_material.py
M	release/scripts/startup/bl_ui/space_node.py
M	source/blender/editors/space_node/space_node.c

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

diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index e0de3031466..a3ee5533fe7 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -50,14 +50,18 @@ class CyclesButtonsPanel:
         return context.engine in cls.COMPAT_ENGINES
 
 
-class CyclesNodeButtonsPanel:
-    bl_space_type = "NODE_EDITOR"
-    bl_region_type = "UI"
-    COMPAT_ENGINES = {'CYCLES'}
+# Adapt properties editor panel to display in node editor. We have to
+# copy the class rather than inherit due to the way bpy registration works.
+def node_panel(cls):
+    node_cls = type('NODE_' + cls.__name__, cls.__bases__, dict(cls.__dict__))
 
-    @classmethod
-    def poll(cls, context):
-        return context.engine in cls.COMPAT_ENGINES
+    node_cls.bl_space_type = 'NODE_EDITOR'
+    node_cls.bl_region_type = 'UI'
+    node_cls.bl_category = "Node"
+    if hasattr(node_cls, 'bl_parent_id'):
+        node_cls.bl_parent_id = 'NODE_' + node_cls.bl_parent_id
+
+    return node_cls
 
 
 def get_device_type(context):
@@ -1328,13 +1332,16 @@ class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
 
         light = context.light
         clamp = light.cycles
-        # cscene = context.scene.cycles
-
-        layout.prop(light, "type", expand=True)
 
-        layout.use_property_split = True
         layout.use_property_decorate = False
 
+        if self.bl_space_type == 'PROPERTIES':
+            layout.row().prop(light, "type", expand=True)
+            layout.use_property_split = True
+        else:
+            layout.use_property_split = True
+            layout.row().prop(light, "type")
+
         col = layout.column()
 
         if light.type in {'POINT', 'SUN', 'SPOT'}:
@@ -2035,43 +2042,6 @@ class CYCLES_RENDER_PT_simplify_culling(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "distance_cull_margin", text="Distance")
 
 
-class CYCLES_NODE_PT_settings(CyclesNodeButtonsPanel, Panel):
-    bl_label = "Settings"
-    bl_category = "Node"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        snode = context.space_data
-        return CyclesNodeButtonsPanel.poll(context) and \
-               snode.tree_type == 'ShaderNodeTree' and snode.id and \
-               snode.id.bl_rna.identifier == 'Material'
-
-    def draw(self, context):
-        material = context.space_data.id
-        CYCLES_MATERIAL_PT_settings.draw_shared(self, material)
-
-
-class CYCLES_NODE_PT_settings_surface(CyclesNodeButtonsPanel, Panel):
-    bl_label = "Surface"
-    bl_category = "Node"
-    bl_parent_id = "CYCLES_NODE_PT_settings"
-
-    def draw(self, context):
-        material = context.space_data.id
-        CYCLES_MATERIAL_PT_settings_surface.draw_shared(self, material)
-
-
-class CYCLES_NODE_PT_settings_volume(CyclesNodeButtonsPanel, Panel):
-    bl_label = "Volume"
-    bl_category = "Node"
-    bl_parent_id = "CYCLES_NODE_PT_settings"
-
-    def draw(self, context):
-        material = context.space_data.id
-        CYCLES_MATERIAL_PT_settings_volume.draw_shared(self, context, material)
-
-
 def draw_device(self, context):
     scene = context.scene
     layout = self.layout
@@ -2118,6 +2088,8 @@ def get_panels():
         'DATA_PT_spot',
         'MATERIAL_PT_context_material',
         'MATERIAL_PT_preview',
+        'NODE_DATA_PT_light',
+        'NODE_DATA_PT_spot',
         'VIEWLAYER_PT_filter',
         'VIEWLAYER_PT_layer_passes',
         'RENDER_PT_post_processing',
@@ -2203,9 +2175,15 @@ classes = (
     CYCLES_RENDER_PT_bake_selected_to_active,
     CYCLES_RENDER_PT_bake_output,
     CYCLES_RENDER_PT_debug,
-    CYCLES_NODE_PT_settings,
-    CYCLES_NODE_PT_settings_surface,
-    CYCLES_NODE_PT_settings_volume,
+    node_panel(CYCLES_MATERIAL_PT_settings),
+    node_panel(CYCLES_MATERIAL_PT_settings_surface),
+    node_panel(CYCLES_MATERIAL_PT_settings_volume),
+    node_panel(CYCLES_WORLD_PT_ray_visibility),
+    node_panel(CYCLES_WORLD_PT_settings),
+    node_panel(CYCLES_WORLD_PT_settings_surface),
+    node_panel(CYCLES_WORLD_PT_settings_volume),
+    node_panel(CYCLES_LIGHT_PT_light),
+    node_panel(CYCLES_LIGHT_PT_spot),
 )
 
 
diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py
index d6f37245d96..acda015f8d4 100644
--- a/release/scripts/startup/bl_ui/properties_data_light.py
+++ b/release/scripts/startup/bl_ui/properties_data_light.py
@@ -69,7 +69,13 @@ class DATA_PT_light(DataButtonsPanel, Panel):
 
         light = context.light
 
-        layout.row().prop(light, "type", expand=True)
+        # Compact layout for node editor.
+        if self.bl_space_type == 'PROPERTIES':
+            layout.row().prop(light, "type", expand=True)
+            layout.use_property_split = True
+        else:
+            layout.use_property_split = True
+            layout.row().prop(light, "type")
 
 
 class DATA_PT_EEVEE_light(DataButtonsPanel, Panel):
@@ -80,9 +86,13 @@ class DATA_PT_EEVEE_light(DataButtonsPanel, Panel):
         layout = self.layout
         light = context.light
 
-        layout.row().prop(light, "type", expand=True)
-
-        layout.use_property_split = True
+        # Compact layout for node editor.
+        if self.bl_space_type == 'PROPERTIES':
+            layout.row().prop(light, "type", expand=True)
+            layout.use_property_split = True
+        else:
+            layout.use_property_split = True
+            layout.row().prop(light, "type")
 
         col = layout.column()
         col.prop(light, "color")
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 6e21fba51f2..260e57c4b1c 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -206,11 +206,12 @@ class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
     bl_context = "material"
     COMPAT_ENGINES = {'BLENDER_EEVEE'}
 
-    @staticmethod
-    def draw_shared(self, mat):
+    def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
 
+        mat = context.material
+
         layout.prop(mat, "blend_method")
 
         if mat.blend_method != 'OPAQUE':
@@ -228,9 +229,6 @@ class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
         layout.prop(mat, "use_sss_translucency")
         layout.prop(mat, "pass_index")
 
-    def draw(self, context):
-        self.draw_shared(self, context.material)
-
 
 class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
     bl_label = "Viewport Display"
@@ -242,19 +240,17 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
         mat = context.material
         return mat and not mat.grease_pencil
 
-    @staticmethod
-    def draw_shared(self, mat):
+    def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
 
+        mat = context.material
+
         col = layout.column()
         col.prop(mat, "diffuse_color", text="Color")
         col.prop(mat, "metallic")
         col.prop(mat, "roughness")
 
-    def draw(self, context):
-        self.draw_shared(self, context.material)
-
 
 classes = (
     MATERIAL_MT_context_menu,
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index e6765d59723..31451d7eedf 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -30,6 +30,13 @@ from .properties_material import (
     EEVEE_MATERIAL_PT_settings,
     MATERIAL_PT_viewport
 )
+from .properties_world import (
+    WORLD_PT_viewport_display
+)
+from .properties_data_light import (
+    DATA_PT_light,
+    DATA_PT_EEVEE_light,
+)
 
 
 class NODE_HT_header(Header):
@@ -569,49 +576,22 @@ class NODE_PT_grease_pencil_tools(GreasePencilToolsPanel, Panel):
     # toolbar, but which may not necessarily be open
 
 
-class EEVEE_NODE_PT_material_settings(Panel):
-    bl_space_type = 'NODE_EDITOR'
-    bl_region_type = 'UI'
-    bl_category = "Node"
-    bl_label = "Settings"
-    COMPAT_ENGINES = {'BLENDER_EEVEE'}
-
-    @classmethod
-    def poll(cls, context):
-        snode = context.space_data
-        return (
-            (context.engine in cls.COMPAT_ENGINES) and
-            (snode.tree_type == 'ShaderNodeTree' and snode.id) and
-            (snode.id.bl_rna.identifier == 'Material')
-        )
-
-    def draw(self, context):
-        material = context.space_data.id
-        EEVEE_MATERIAL_PT_settings.draw_shared(self, material)
-
-
-class NODE_PT_material_viewport(Panel):
-    bl_space_type = 'NODE_EDITOR'
-    bl_region_type = 'UI'
-    bl_category = "Node"
-    bl_label = "Viewport Display"
-    bl_options = {'DEFAULT_CLOSED'}
+def node_draw_tree_view(layout, context):
+    pass
 
-    @classmethod
-    def poll(cls, context):
-        snode = context.space_data
-        return (
-            (snode.tree_type == 'ShaderNodeTree' and snode.id) and
-            (snode.id.bl_rna.identifier == "Material")
-        )
 
-    def draw(self, context):
-        material = context.space_data.id
-        MATERIAL_PT_viewport.draw_shared(self, material)
+# Adapt properties editor panel to display in node editor. We have to
+# copy the class rather than inherit due to the way bpy registration works.
+def node_panel(cls):
+    node_cls = type('NODE_' + cls.__name__, cls.__bases__, dict(cls.__dict__))
 
+    node_cls.bl_space_type = 'NODE_EDITOR'
+    node_cls.bl_region_type = 'UI'
+    node_cls.bl_category = "Node"
+    if hasattr(node_cls, 'bl_parent_id'):
+        node_cls.bl_parent_id = 'NODE_' + node_cls.bl_parent_id
 
-def node_draw_tree_view(layout, context):
-    pass
+    return node_cls
 
 
 classes = (
@@ -632,8 +612,11 @@ classes = (
     NODE_UL_interface_sockets,
     NODE_PT_grease_pencil,
     NODE_PT_grease_pencil_tools,
-    EEVEE_NODE_PT_material_settings,
-    NODE_PT_material_viewport,
+    node_panel(EEVEE_MATERIAL_PT_settings),
+    node_panel(MATERIAL_PT_viewport),
+    node_panel(WORLD_PT_viewport_display),
+    node_panel(DATA_PT_light),
+    node_panel(DATA_PT_EEVEE_light),
 )
 
 
diff --git a/source/blender/

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list