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.

Pull Request #104517
This commit is contained in:
Hans Goudey
2023-02-11 16:11:10 +01:00
committed by Jacques Lucke
parent 19ea673260
commit 158f809dcb
4 changed files with 20 additions and 1 deletions

View File

@@ -1465,6 +1465,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<const bNodeTree *>(ptr->owner_id);
if (sock->in_out == SOCK_IN && node_tree->type == NTREE_GEOMETRY) {
uiItemR(col, ptr, "hide_in_modifier", DEFAULT_FLAGS, nullptr, 0);
}
}
static void node_socket_virtual_draw_color(bContext * /*C*/,

View File

@@ -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 {

View File

@@ -11219,6 +11219,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(

View File

@@ -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);
}
}
}