From 329b8e8eeb839cc918139cdd4f2598624710205a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 8 Feb 2023 10:07:32 -0500 Subject: [PATCH 1/3] Geometry Nodes: Add option to hide input in modifier When building a node group that's meant to be used directly in the node editor as well as in the modifier, it's useful to be able to have some inputs that are only meant for the node editor, like inputs that only make sense when combined with other nodes. In the future we might have the ability to only display certain assets in the modifier and the node editor, but until then this simple solution allows a bit more customization. --- source/blender/editors/space_node/drawnode.cc | 10 +++++++++- source/blender/makesdna/DNA_node_types.h | 4 ++++ source/blender/makesrna/intern/rna_nodetree.c | 8 ++++++++ source/blender/modifiers/intern/MOD_nodes.cc | 4 +++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 34b5ba3ab22..8a9a88c0a60 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1463,7 +1463,15 @@ static void std_node_socket_interface_draw(bContext * /*C*/, uiLayout *layout, P } } - uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, nullptr, 0); + const bNodeTree *node_tree = reinterpret_cast(ptr->owner_id); + if (sock->in_out == SOCK_IN && node_tree->type == NTREE_GEOMETRY) { + col = uiLayoutColumnWithHeading(col, false, IFACE_("Hide")); + uiItemR(col, ptr, "hide_value", DEFAULT_FLAGS, IFACE_("Default Value"), 0); + uiItemR(col, ptr, "hide_in_modifier", DEFAULT_FLAGS, IFACE_("In Modifier"), 0); + } + else { + uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, nullptr, 0); + } } static void node_socket_virtual_draw_color(bContext * /*C*/, diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 8f9ae28b441..a2e4c0a0991 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -282,6 +282,10 @@ typedef enum eNodeSocketFlag { * type is obvious and the name takes up too much space. */ SOCK_HIDE_LABEL = (1 << 12), + /** + * Only used for geometry nodes. Don't show the socket value in the modifier interface. + */ + SOCK_HIDE_IN_MODIFIER = (1 << 13), } eNodeSocketFlag; typedef struct bNode { diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 7ba3971b4ea..2504a8a3218 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -11203,6 +11203,14 @@ static void rna_def_node_socket_interface(BlenderRNA *brna) prop, "Hide Value", "Hide the socket input value even when the socket is not connected"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update"); + prop = RNA_def_property(srna, "hide_in_modifier", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_HIDE_IN_MODIFIER); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, + "Hide in Modifier", + "Don't show the input value in the geometry nodes modifier interface"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update"); + prop = RNA_def_property(srna, "attribute_domain", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_attribute_domain_items); RNA_def_property_ui_text( diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 6ecd2c74462..15aab38bed7 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -1736,7 +1736,9 @@ static void panel_draw(const bContext *C, Panel *panel) int socket_index; LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &nmd->node_group->inputs, socket_index) { - draw_property_for_socket(*C, layout, nmd, &bmain_ptr, ptr, *socket, socket_index); + if (!(socket->flag & SOCK_HIDE_IN_MODIFIER)) { + draw_property_for_socket(*C, layout, nmd, &bmain_ptr, ptr, *socket, socket_index); + } } } -- 2.30.2 From cdff0889bdfcd5ef7ff27b17c8e84f7093e09dfd Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 9 Feb 2023 10:10:10 -0500 Subject: [PATCH 2/3] Uve "Value" instead of "Default Value" --- source/blender/editors/space_node/drawnode.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 8a9a88c0a60..fcab642d00b 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1466,7 +1466,7 @@ static void std_node_socket_interface_draw(bContext * /*C*/, uiLayout *layout, P const bNodeTree *node_tree = reinterpret_cast(ptr->owner_id); if (sock->in_out == SOCK_IN && node_tree->type == NTREE_GEOMETRY) { col = uiLayoutColumnWithHeading(col, false, IFACE_("Hide")); - uiItemR(col, ptr, "hide_value", DEFAULT_FLAGS, IFACE_("Default Value"), 0); + uiItemR(col, ptr, "hide_value", DEFAULT_FLAGS, IFACE_("Value"), 0); uiItemR(col, ptr, "hide_in_modifier", DEFAULT_FLAGS, IFACE_("In Modifier"), 0); } else { -- 2.30.2 From 732b8b4982f33daeaba4b760a7abc75c13fb77bd Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 10 Feb 2023 13:31:39 -0500 Subject: [PATCH 3/3] Avoid changing UI layout, just add new "Hide in Modifier" item --- source/blender/editors/space_node/drawnode.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 3f4f51bb9f9..319ec71cb54 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1464,14 +1464,11 @@ static void std_node_socket_interface_draw(bContext * /*C*/, uiLayout *layout, P } } + uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, nullptr, 0); + const bNodeTree *node_tree = reinterpret_cast(ptr->owner_id); if (sock->in_out == SOCK_IN && node_tree->type == NTREE_GEOMETRY) { - col = uiLayoutColumnWithHeading(col, false, IFACE_("Hide")); - uiItemR(col, ptr, "hide_value", DEFAULT_FLAGS, IFACE_("Value"), 0); - uiItemR(col, ptr, "hide_in_modifier", DEFAULT_FLAGS, IFACE_("In Modifier"), 0); - } - else { - uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, nullptr, 0); + uiItemR(col, ptr, "hide_in_modifier", DEFAULT_FLAGS, nullptr, 0); } } -- 2.30.2