Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_string_join.cc
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_string_join_cc { | namespace blender::nodes::node_geo_string_join_cc { | ||||
| static void geo_node_string_join_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::String>(N_("Delimiter")); | b.add_input<decl::String>(N_("Delimiter")); | ||||
| b.add_input<decl::String>(N_("Strings")).multi_input().hide_value(); | b.add_input<decl::String>(N_("Strings")).multi_input().hide_value(); | ||||
| b.add_output<decl::String>(N_("String")); | b.add_output<decl::String>(N_("String")); | ||||
| }; | }; | ||||
| static void geo_node_string_join_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| Vector<std::string> strings = params.extract_multi_input<std::string>("Strings"); | Vector<std::string> strings = params.extract_multi_input<std::string>("Strings"); | ||||
| const std::string delim = params.extract_input<std::string>("Delimiter"); | const std::string delim = params.extract_input<std::string>("Delimiter"); | ||||
| std::string output; | std::string output; | ||||
| for (const int i : strings.index_range()) { | for (const int i : strings.index_range()) { | ||||
| output += strings[i]; | output += strings[i]; | ||||
| if (i < (strings.size() - 1)) { | if (i < (strings.size() - 1)) { | ||||
| output += delim; | output += delim; | ||||
| } | } | ||||
| } | } | ||||
| params.set_output("String", std::move(output)); | params.set_output("String", std::move(output)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_string_join_cc | } // namespace blender::nodes::node_geo_string_join_cc | ||||
| void register_node_type_geo_string_join() | void register_node_type_geo_string_join() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_string_join_cc; | namespace file_ns = blender::nodes::node_geo_string_join_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_STRING_JOIN, "Join Strings", NODE_CLASS_CONVERTER, 0); | geo_node_type_base(&ntype, GEO_NODE_STRING_JOIN, "Join Strings", NODE_CLASS_CONVERTER, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_string_join_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.declare = file_ns::geo_node_string_join_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||