Geometry Nodes: Filter data-block buttons for tools and modifiers

In the data-block selectors in the node editor and the header,
apply a few rules to increase the separation between tool and
modifier node groups.
1. The modifier accepts non-asset groups or assets marked
   as modifiers (created in the modifier context). Tool node groups
   cannot be used by modifiers.
2. The tool context can only edit node group assets marked as tools
   (created in the tool context).

When switching contexts, the node group is cleared if the state would
be invalid. The tool node group is still stored in the editor's "root node
tree" property. Since it isn't retrieved from the context, the pin button
is useless, so it isn't displayed in the tool mode.

See #101778, #111526.

Pull Request: https://projects.blender.org/blender/blender/pulls/112389
This commit is contained in:
Hans Goudey
2023-09-22 17:45:00 +02:00
committed by Hans Goudey
parent 015bc7ca4d
commit 1c51f74cb4
3 changed files with 66 additions and 4 deletions
+3 -1
View File
@@ -47,6 +47,7 @@ class NODE_HT_header(Header):
# Now expanded via the `ui_type`.
# layout.prop(snode, "tree_type", text="")
display_pin = True
if snode.tree_type == 'ShaderNodeTree':
layout.prop(snode, "shader_type", text="")
@@ -166,6 +167,7 @@ class NODE_HT_header(Header):
layout.template_ID(snode, "node_tree", new="node.new_geometry_node_group_tool")
if snode.node_tree and snode.node_tree.asset_data:
layout.popover(panel="NODE_PT_geometry_node_asset_traits")
display_pin = False
else:
# Custom node tree is edited as independent ID block
NODE_MT_editor_menus.draw_collapsible(context, layout)
@@ -175,7 +177,7 @@ class NODE_HT_header(Header):
layout.template_ID(snode, "node_tree", new="node.new_node_tree")
# Put pin next to ID block
if not is_compositor:
if not is_compositor and display_pin:
layout.prop(snode, "pin", text="", emboss=False)
layout.separator_spacer()