25 const bNode *node =
b.node_or_null();
26 if (node !=
nullptr) {
28 b.add_output(data_type,
"Value");
36 static auto str_to_float_fn = mf::build::SI1_SO2<std::string, float, int>(
37 "String to Value", [](
const std::string &s,
float &value,
int &
length) ->
void {
38 const auto result = fast_float::from_chars(s.data(), s.data() + s.size(), value);
42 static auto str_to_int_fn = mf::build::SI1_SO2<std::string, int, int>(
43 "String to Value", [](
const std::string &s,
int &value,
int &
length) ->
void {
44 const auto result = std::from_chars(s.data(), s.data() + s.size(), value);
50 return &str_to_float_fn;
52 return &str_to_int_fn;
76 bNode &node =
params.add_node(
"FunctionNodeStringToValue");
77 params.update_and_connect_available_socket(node,
"String");
84 bNode &node =
params.add_node(
"FunctionNodeStringToValue");
86 params.update_and_connect_available_socket(node,
"Value");
89 else if (
params.node_tree().typeinfo->validate_link(
SOCK_FLOAT, socket_type)) {
91 bNode &node =
params.add_node(
"FunctionNodeStringToValue");
93 params.update_and_connect_available_socket(node,
"Value");
99 bNode &node =
params.add_node(
"FunctionNodeStringToValue");
100 params.update_and_connect_available_socket(node,
"Length");
114 {
SOCK_FLOAT,
"FLOAT", ICON_NODE_SOCKET_FLOAT,
"Float",
"Floating-point value"},
115 {
SOCK_INT,
"INT", ICON_NODE_SOCKET_INT,
"Integer",
"32-bit integer"},
116 {0,
nullptr, 0,
nullptr,
nullptr}};
132 ntype.
ui_name =
"String to Value";
133 ntype.
ui_description =
"Derive a numeric value from a given string representation";
#define NODE_CLASS_CONVERTER
#define BLI_assert_unreachable()
size_t size_t BLI_strnlen_utf8(const char *strc, size_t strc_maxlen) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
void set_matching_fn(const mf::MultiFunction *fn)
float length(VecOp< float, D >) RET
void node_register_type(bNodeType &ntype)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_init(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_rna(StructRNA *srna)
static void node_register()
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static const mf::MultiFunction * get_multi_function(const bNode &bnode)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void fn_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)