Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/function/nodes/node_fn_value_to_string.cc
| Show All 15 Lines | |||||
| #include "node_function_util.hh" | #include "node_function_util.hh" | ||||
| #include <iomanip> | #include <iomanip> | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| static void fn_node_value_to_string_declare(NodeDeclarationBuilder &b) | static void fn_node_value_to_string_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Float>("Value"); | b.add_input<decl::Float>(N_("Value")); | ||||
| b.add_input<decl::Int>("Decimals").min(0); | b.add_input<decl::Int>(N_("Decimals")).min(0); | ||||
| b.add_output<decl::String>("String"); | b.add_output<decl::String>(N_("String")); | ||||
| }; | }; | ||||
| static void fn_node_value_to_string_build_multi_function(NodeMultiFunctionBuilder &builder) | static void fn_node_value_to_string_build_multi_function(NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| static fn::CustomMF_SI_SI_SO<float, int, std::string> to_str_fn{ | static fn::CustomMF_SI_SI_SO<float, int, std::string> to_str_fn{ | ||||
| "Value To String", [](float a, int b) { | "Value To String", [](float a, int b) { | ||||
| std::stringstream stream; | std::stringstream stream; | ||||
| stream << std::fixed << std::setprecision(std::max(0, b)) << a; | stream << std::fixed << std::setprecision(std::max(0, b)) << a; | ||||
| Show All 16 Lines | |||||