Blender  V3.3
node_fn_value_to_string.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "node_function_util.hh"
4 #include <iomanip>
5 
7 
9 {
10  b.add_input<decl::Float>(N_("Value"));
11  b.add_input<decl::Int>(N_("Decimals")).min(0);
12  b.add_output<decl::String>(N_("String"));
13 }
14 
16 {
18  "Value To String", [](float a, int b) {
19  std::stringstream stream;
20  stream << std::fixed << std::setprecision(std::max(0, b)) << a;
21  return stream.str();
22  }};
23  builder.set_matching_fn(&to_str_fn);
24 }
25 
26 } // namespace blender::nodes::node_fn_value_to_string_cc
27 
29 {
31 
32  static bNodeType ntype;
33 
37  nodeRegisterType(&ntype);
38 }
#define FN_NODE_VALUE_TO_STRING
Definition: BKE_node.h:1525
#define NODE_CLASS_CONVERTER
Definition: BKE_node.h:351
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
void set_matching_fn(const MultiFunction *fn)
static unsigned a[3]
Definition: RandGen.cpp:78
static void fn_node_value_to_string_declare(NodeDeclarationBuilder &b)
static void fn_node_value_to_string_build_multi_function(NodeMultiFunctionBuilder &builder)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_fn_value_to_string()
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
#define min(a, b)
Definition: sort.c:35
Defines a node type.
Definition: BKE_node.h:226
NodeMultiFunctionBuildFunction build_multi_function
Definition: BKE_node.h:313
NodeDeclareFunction declare
Definition: BKE_node.h:324
float max
#define N_(msgid)