From 9896bbdb4e2f786a2bb3c649a17a9659471140c1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Mar 2020 08:53:39 +0100 Subject: [PATCH] Fix T73882, T74420: node wrangler operations only working for Cycles and Eevee There were legacy checks remaining for Blender Internal, however now we can assume that any renderer using the native shader node tree is also using Cycles and Eevee shading nodes. Custom shader nodes will have a different type of node tree. --- node_wrangler.py | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/node_wrangler.py b/node_wrangler.py index 0fad2ccad..df761b4ee 100644 --- a/node_wrangler.py +++ b/node_wrangler.py @@ -544,9 +544,6 @@ } -def is_cycles_or_eevee(context): - return context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'} - def is_visible_socket(socket): return not socket.hide and socket.enabled @@ -1583,10 +1580,9 @@ class NWEmissionViewer(Operator, NWBase): @classmethod def poll(cls, context): - is_cycles = is_cycles_or_eevee(context) if nw_check(context): space = context.space_data - if space.tree_type == 'ShaderNodeTree' and is_cycles: + if space.tree_type == 'ShaderNodeTree': if context.active_node: if context.active_node.type != "OUTPUT_MATERIAL" or context.active_node.type != "OUTPUT_WORLD": return True @@ -2583,7 +2579,7 @@ def poll(cls, context): valid = False if nw_check(context): space = context.space_data - if space.tree_type == 'ShaderNodeTree' and is_cycles_or_eevee(context): + if space.tree_type == 'ShaderNodeTree': valid = True return valid @@ -2687,7 +2683,7 @@ def poll(cls, context): valid = False if nw_check(context): space = context.space_data - if space.tree_type == 'ShaderNodeTree' and is_cycles_or_eevee(context): + if space.tree_type == 'ShaderNodeTree': valid = True return valid @@ -3261,10 +3257,7 @@ def execute(self, context): if not output_node: bpy.ops.node.select_all(action="DESELECT") if tree_type == 'ShaderNodeTree': - if is_cycles_or_eevee(context): - output_node = nodes.new('ShaderNodeOutputMaterial') - else: - output_node = nodes.new('ShaderNodeOutput') + output_node = nodes.new('ShaderNodeOutputMaterial') elif tree_type == 'CompositorNodeTree': output_node = nodes.new('CompositorNodeComposite') elif tree_type == 'TextureNodeTree': @@ -3282,7 +3275,7 @@ def execute(self, context): break out_input_index = 0 - if tree_type == 'ShaderNodeTree' and is_cycles_or_eevee(context): + if tree_type == 'ShaderNodeTree': if active.outputs[output_index].name == 'Volume': out_input_index = 1 elif active.outputs[output_index].type != 'SHADER': # connect to displacement if not a shader @@ -3730,7 +3723,7 @@ def drawlayout(context, layout, mode='non-panel'): col.menu(NWSwitchNodeTypeMenu.bl_idname, text="Switch Node Type") col.separator() - if tree_type == 'ShaderNodeTree' and is_cycles_or_eevee(context): + if tree_type == 'ShaderNodeTree': col = layout.column(align=True) col.operator(NWAddTextureSetup.bl_idname, text="Add Texture Setup", icon='NODE_SEL') col.operator(NWAddPrincipledSetup.bl_idname, text="Add Principled Setup", icon='NODE_SEL') @@ -3815,7 +3808,7 @@ class NWMergeNodesMenu(Menu, NWBase): def draw(self, context): type = context.space_data.tree_type layout = self.layout - if type == 'ShaderNodeTree' and is_cycles_or_eevee(context): + if type == 'ShaderNodeTree': layout.menu(NWMergeShadersMenu.bl_idname, text="Use Shaders") layout.menu(NWMergeMixMenu.bl_idname, text="Use Mix Nodes") layout.menu(NWMergeMathMenu.bl_idname, text="Use Math Nodes") @@ -4039,7 +4032,7 @@ def poll(cls, context): valid = False if nw_check(context): snode = context.space_data - valid = snode.tree_type == 'ShaderNodeTree' and is_cycles_or_eevee(context) + valid = snode.tree_type == 'ShaderNodeTree' return valid def draw(self, context): @@ -4074,22 +4067,14 @@ def draw(self, context): layout = self.layout tree = context.space_data.node_tree if tree.type == 'SHADER': - if is_cycles_or_eevee(context): - layout.menu(NWSwitchShadersInputSubmenu.bl_idname) - layout.menu(NWSwitchShadersOutputSubmenu.bl_idname) - layout.menu(NWSwitchShadersShaderSubmenu.bl_idname) - layout.menu(NWSwitchShadersTextureSubmenu.bl_idname) - layout.menu(NWSwitchShadersColorSubmenu.bl_idname) - layout.menu(NWSwitchShadersVectorSubmenu.bl_idname) - layout.menu(NWSwitchShadersConverterSubmenu.bl_idname) - layout.menu(NWSwitchShadersLayoutSubmenu.bl_idname) - else: - layout.menu(NWSwitchMatInputSubmenu.bl_idname) - layout.menu(NWSwitchMatOutputSubmenu.bl_idname) - layout.menu(NWSwitchMatColorSubmenu.bl_idname) - layout.menu(NWSwitchMatVectorSubmenu.bl_idname) - layout.menu(NWSwitchMatConverterSubmenu.bl_idname) - layout.menu(NWSwitchMatLayoutSubmenu.bl_idname) + layout.menu(NWSwitchShadersInputSubmenu.bl_idname) + layout.menu(NWSwitchShadersOutputSubmenu.bl_idname) + layout.menu(NWSwitchShadersShaderSubmenu.bl_idname) + layout.menu(NWSwitchShadersTextureSubmenu.bl_idname) + layout.menu(NWSwitchShadersColorSubmenu.bl_idname) + layout.menu(NWSwitchShadersVectorSubmenu.bl_idname) + layout.menu(NWSwitchShadersConverterSubmenu.bl_idname) + layout.menu(NWSwitchShadersLayoutSubmenu.bl_idname) if tree.type == 'COMPOSITING': layout.menu(NWSwitchCompoInputSubmenu.bl_idname) layout.menu(NWSwitchCompoOutputSubmenu.bl_idname)