Geometry Nodes: Add option to force inputs to be single values
Add a checkbox to node group inputs to force inputs to be single values and not accept varying fields. While this could also be done more automatically, and it could be argued that requiring the flexibility is helpful for users who want to use attributes, there are cases where the field inferencing doesn't work, or the "use attribute" option is just unhelpful. People use workarounds with primitive nodes to get the same behavior anyway. Pull Request: https://projects.blender.org/blender/blender/pulls/112745
This commit is contained in:
@@ -508,6 +508,9 @@ static void determine_group_input_states(
|
||||
if (!is_field_socket_type(type)) {
|
||||
new_inferencing_interface.inputs[index] = InputSocketFieldType::None;
|
||||
}
|
||||
else if (group_input->flag & NODE_INTERFACE_SOCKET_SINGLE_VALUE_ONLY) {
|
||||
new_inferencing_interface.inputs[index] = InputSocketFieldType::None;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check if group inputs are required to be single values, because they are (indirectly)
|
||||
|
||||
@@ -1512,6 +1512,7 @@ static void std_node_socket_interface_draw(ID *id,
|
||||
const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(id);
|
||||
if (interface_socket->flag & NODE_INTERFACE_SOCKET_INPUT && node_tree->type == NTREE_GEOMETRY) {
|
||||
uiItemR(col, &ptr, "hide_in_modifier", DEFAULT_FLAGS, nullptr, ICON_NONE);
|
||||
uiItemR(col, &ptr, "force_non_field", DEFAULT_FLAGS, nullptr, ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,9 @@ typedef enum NodeTreeInterfaceSocketFlag {
|
||||
NODE_INTERFACE_SOCKET_HIDE_VALUE = 1 << 2,
|
||||
NODE_INTERFACE_SOCKET_HIDE_IN_MODIFIER = 1 << 3,
|
||||
NODE_INTERFACE_SOCKET_COMPACT = 1 << 4,
|
||||
NODE_INTERFACE_SOCKET_SINGLE_VALUE_ONLY = 1 << 5,
|
||||
} NodeTreeInterfaceSocketFlag;
|
||||
ENUM_OPERATORS(NodeTreeInterfaceSocketFlag, NODE_INTERFACE_SOCKET_HIDE_IN_MODIFIER);
|
||||
ENUM_OPERATORS(NodeTreeInterfaceSocketFlag, NODE_INTERFACE_SOCKET_SINGLE_VALUE_ONLY);
|
||||
|
||||
typedef struct bNodeTreeInterfaceSocket {
|
||||
bNodeTreeInterfaceItem item;
|
||||
|
||||
@@ -912,6 +912,13 @@ static void rna_def_node_interface_socket(BlenderRNA *brna)
|
||||
"Don't show the input value in the geometry nodes modifier interface");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_update");
|
||||
|
||||
prop = RNA_def_property(srna, "force_non_field", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", NODE_INTERFACE_SOCKET_SINGLE_VALUE_ONLY);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Single Value", "Only allow single value inputs rather than fields");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeTreeInterfaceItem_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(
|
||||
|
||||
Reference in New Issue
Block a user