Geometry Nodes: expose instance transform field as default input for node groups

This commit is contained in:
Jacques Lucke
2024-06-04 19:01:45 +02:00
parent dd6b535521
commit 1604eb9821
4 changed files with 16 additions and 1 deletions

View File

@@ -1564,7 +1564,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) {
if (ELEM(type, SOCK_INT, SOCK_VECTOR)) {
if (ELEM(type, SOCK_INT, SOCK_VECTOR, SOCK_MATRIX)) {
uiItemR(col, &ptr, "default_input", DEFAULT_FLAGS, nullptr, ICON_NONE);
}
}

View File

@@ -134,6 +134,7 @@ typedef enum GeometryNodeDefaultInputType {
GEO_NODE_DEFAULT_FIELD_INPUT_ID_INDEX_FIELD = 2,
GEO_NODE_DEFAULT_FIELD_INPUT_NORMAL_FIELD = 3,
GEO_NODE_DEFAULT_FIELD_INPUT_POSITION_FIELD = 4,
GEO_NODE_DEFAULT_FIELD_INPUT_INSTANCE_TRANSFORM_FIELD = 5,
} GeometryNodeDefaultInputType;
typedef struct bNodeTreeInterfacePanel {

View File

@@ -447,6 +447,15 @@ static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_default_input_itemf(
N_("The position from the context")};
RNA_enum_item_add(&items, &items_count, &position);
}
else if (type->type == SOCK_MATRIX) {
const EnumPropertyItem instance_transform{
GEO_NODE_DEFAULT_FIELD_INPUT_INSTANCE_TRANSFORM_FIELD,
"INSTANCE_TRANSFORM",
0,
N_("Instance Transform"),
N_("Transformation of each instance from the geometry context")};
RNA_enum_item_add(&items, &items_count, &instance_transform);
}
}
RNA_enum_item_end(&items, &items_count);

View File

@@ -451,6 +451,11 @@ static void set_default_input_field(const bNodeTreeInterfaceSocket &input, Socke
decl.hide_value = true;
}
}
else if (decl.socket_type == SOCK_MATRIX) {
decl.implicit_input_fn = std::make_unique<ImplicitInputValueFn>(
implicit_field_inputs::instance_transform);
decl.hide_value = true;
}
}
void node_group_declare(NodeDeclarationBuilder &b)