blob: 09c01b8c627dae815fe12ea4d22c2bddc634d5f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_string_join_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::String>(N_("Delimiter"));
b.add_input<decl::String>(N_("Strings")).multi_input().hide_value();
b.add_output<decl::String>(N_("String"));
}
static void node_geo_exec(GeoNodeExecParams params)
{
Vector<fn::ValueOrField<std::string>> strings =
params.extract_input<Vector<fn::ValueOrField<std::string>>>("Strings");
const std::string delim = params.extract_input<std::string>("Delimiter");
std::string output;
for (const int i : strings.index_range()) {
output += strings[i].as_value();
if (i < (strings.size() - 1)) {
output += delim;
}
}
params.set_output("String", std::move(output));
}
} // namespace blender::nodes::node_geo_string_join_cc
void register_node_type_geo_string_join()
{
namespace file_ns = blender::nodes::node_geo_string_join_cc;
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_STRING_JOIN, "Join Strings", NODE_CLASS_CONVERTER);
ntype.geometry_node_execute = file_ns::node_geo_exec;
ntype.declare = file_ns::node_declare;
nodeRegisterType(&ntype);
}
|