1 # SPDX-License-Identifier: GPL-2.0-or-later
3 Nodes Simplify Panel [WIP Feature]
5 Disable/Enable certain nodes at a time. Useful to quickly "simplify"
7 This feature is a work in progress, the main issue now is when switching
8 many different kinds one after the other.
10 On the Nodes Editor Properties N panel.
18 ("ALL", "All Types", "", 0),
19 ("BLUR", "Blur", "", 1),
20 ("BOKEHBLUR", "Bokeh Blur", "", 2),
21 ("VECBLUR", "Vector Blur", "", 3),
22 ("DEFOCUS", "Defocus", "", 4),
23 ("R_LAYERS", "Render Layer", "", 5),
26 nodes_compo
= bpy
.types
.CompositorNodeTree
27 nodes_compo
.types
= bpy
.props
.EnumProperty(
28 items
=nodes_compo_types
, name
="Types")
29 nodes_compo
.toggle_mute
= bpy
.props
.BoolProperty(default
=False)
30 node
.status
= bpy
.props
.BoolProperty(default
=False)
34 wm
= bpy
.context
.window_manager
35 for p
in ("types", "toggle_mute", "status"):
40 class AMTH_NODE_PT_simplify(bpy
.types
.Panel
):
42 bl_space_type
= "NODE_EDITOR"
45 bl_options
= {"DEFAULT_CLOSED"}
48 def poll(cls
, context
):
49 space
= context
.space_data
50 return space
.type == "NODE_EDITOR" \
51 and space
.node_tree
is not None \
52 and space
.tree_type
== "CompositorNodeTree"
54 def draw(self
, context
):
56 node_tree
= context
.scene
.node_tree
58 if node_tree
is not None:
59 layout
.prop(node_tree
, "types")
60 layout
.operator(AMTH_NODE_OT_toggle_mute
.bl_idname
,
61 text
="Turn On" if node_tree
.toggle_mute
else "Turn Off",
62 icon
="RESTRICT_VIEW_OFF" if node_tree
.toggle_mute
else "RESTRICT_VIEW_ON")
64 if node_tree
.types
== "VECBLUR":
65 layout
.label(text
="This will also toggle the Vector pass {}".format(
66 "on" if node_tree
.toggle_mute
else "off"), icon
="INFO")
69 class AMTH_NODE_OT_toggle_mute(bpy
.types
.Operator
):
71 bl_idname
= "node.toggle_mute"
72 bl_label
= "Toggle Mute"
74 def execute(self
, context
):
76 node_tree
= scene
.node_tree
77 node_type
= node_tree
.types
78 rlayers
= scene
.render
80 if "amaranth_pass_vector" not in scene
.keys():
81 scene
["amaranth_pass_vector"] = []
83 # can"t extend() the list, so make a dummy one
84 pass_vector
= scene
["amaranth_pass_vector"]
89 if node_tree
.toggle_mute
:
90 for node
in node_tree
.nodes
:
91 if node_type
== "ALL":
92 node
.mute
= node
.status
93 if node
.type == node_type
:
94 node
.mute
= node
.status
95 if node_type
== "VECBLUR":
96 for layer
in rlayers
.layers
:
97 if layer
.name
in pass_vector
:
98 layer
.use_pass_vector
= True
99 pass_vector
.remove(layer
.name
)
101 node_tree
.toggle_mute
= False
104 for node
in node_tree
.nodes
:
105 if node_type
== "ALL":
107 if node
.type == node_type
:
108 node
.status
= node
.mute
110 if node_type
== "VECBLUR":
111 for layer
in rlayers
.layers
:
112 if layer
.use_pass_vector
:
113 pass_vector
.append(layer
.name
)
114 layer
.use_pass_vector
= False
117 node_tree
.toggle_mute
= True
119 # Write back to the custom prop
120 pass_vector
= sorted(set(pass_vector
))
121 scene
["amaranth_pass_vector"] = pass_vector
128 bpy
.utils
.register_class(AMTH_NODE_PT_simplify
)
129 bpy
.utils
.register_class(AMTH_NODE_OT_toggle_mute
)
134 bpy
.utils
.unregister_class(AMTH_NODE_PT_simplify
)
135 bpy
.utils
.unregister_class(AMTH_NODE_OT_toggle_mute
)