From 070010e203f6cf9ac8fe30c8b60a5394df98e730 Mon Sep 17 00:00:00 2001 From: Fabian Schempp Date: Sun, 14 Mar 2021 23:11:36 +0100 Subject: Nodes: multi-input support for Attribute Remove node This patch adds multi-input support to the Attribute Remove node. Reviewed By: Hans Goudey Differential Revision: https://developer.blender.org/D10698 --- source/blender/modifiers/intern/MOD_nodes.cc | 10 +++--- source/blender/nodes/NOD_geometry_exec.hh | 2 +- .../geometry/nodes/node_geo_attribute_remove.cc | 38 +++++++++++++++------- 3 files changed, 33 insertions(+), 17 deletions(-) (limited to 'source') diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index f8242c87bd3..504dd434b1b 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -304,17 +304,17 @@ class GeometryNodesEvaluator { Vector from_sockets; socket_to_compute.foreach_origin_socket([&](DSocket socket) { from_sockets.append(socket); }); - /* Multi-input sockets contain a vector of inputs. */ - if (socket_to_compute->is_multi_input_socket()) { - return this->get_inputs_from_incoming_links(socket_to_compute, from_sockets); - } - if (from_sockets.is_empty()) { /* The input is not connected, use the value from the socket itself. */ const CPPType &type = *blender::nodes::socket_cpp_type_get(*socket_to_compute->typeinfo()); return {get_unlinked_input_value(socket_to_compute, type)}; } + /* Multi-input sockets contain a vector of inputs. */ + if (socket_to_compute->is_multi_input_socket()) { + return this->get_inputs_from_incoming_links(socket_to_compute, from_sockets); + } + const DSocket from_socket = from_sockets[0]; GMutablePointer value = this->get_input_from_incoming_link(socket_to_compute, from_socket); return {value}; diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 5b123e68fe2..5d1a217db9b 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -129,7 +129,7 @@ class GeoNodeExecParams { if (!input_values_.contains(sub_identifier)) { break; } - values.append(input_values_.extract(sub_identifier)); + values.append(input_values_.extract(sub_identifier)); index++; } return values; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc index bf9bda67045..837f0c3629a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc @@ -18,7 +18,16 @@ static bNodeSocketTemplate geo_node_attribute_remove_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Attribute")}, + {SOCK_STRING, + N_("Attribute"), + 0.0f, + 0.0f, + 0.0f, + 1.0f, + -1.0f, + 1.0f, + PROP_NONE, + SOCK_MULTI_INPUT}, {-1, ""}, }; @@ -29,30 +38,37 @@ static bNodeSocketTemplate geo_node_attribute_remove_out[] = { namespace blender::nodes { -static void remove_attribute(GeometryComponent &component, const GeoNodeExecParams ¶ms) +static void remove_attribute(GeometryComponent &component, + GeoNodeExecParams ¶ms, + Span attribute_names) { - const std::string attribute_name = params.get_input("Attribute"); - if (attribute_name.empty()) { - return; - } + for (std::string attribute_name : attribute_names) { + if (attribute_name.empty()) { + continue; + } - if (!component.attribute_try_delete(attribute_name)) { - params.error_message_add(NodeWarningType::Error, - TIP_("Cannot delete attribute with name \"") + attribute_name + "\""); + if (!component.attribute_try_delete(attribute_name)) { + params.error_message_add(NodeWarningType::Error, + TIP_("Cannot delete attribute with name \"") + attribute_name + + "\""); + } } } static void geo_node_attribute_remove_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); + Vector attribute_names = params.extract_multi_input("Attribute"); geometry_set = geometry_set_realize_instances(geometry_set); if (geometry_set.has()) { - remove_attribute(geometry_set.get_component_for_write(), params); + remove_attribute( + geometry_set.get_component_for_write(), params, attribute_names); } if (geometry_set.has()) { - remove_attribute(geometry_set.get_component_for_write(), params); + remove_attribute( + geometry_set.get_component_for_write(), params, attribute_names); } params.set_output("Geometry", geometry_set); -- cgit v1.2.3