diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-17 19:52:05 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-17 23:53:13 +0300 |
commit | df96455c55110da00f0543c5895376ffbc66313b (patch) | |
tree | d1fc0a55f44d4b931362d84eea77a7662c1955a6 /intern/cycles/blender | |
parent | f79ad428085edd8289f37027ba3d5ed3a52bce67 (diff) |
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.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 80 |
1 files changed, 29 insertions, 51 deletions
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), ) |