[Bf-blender-cvs] [39f88480bb1] master: Cleanup: improve consistency between function node implementations
Jacques Lucke
noreply at git.blender.org
Fri Oct 22 15:35:01 CEST 2021
Commit: 39f88480bb1fa0db7fda8bacb3c7d5a0b1cf2171
Author: Jacques Lucke
Date: Fri Oct 22 15:34:53 2021 +0200
Branches: master
https://developer.blender.org/rB39f88480bb1fa0db7fda8bacb3c7d5a0b1cf2171
Cleanup: improve consistency between function node implementations
===================================================================
M source/blender/nodes/function/nodes/node_fn_boolean_math.cc
M source/blender/nodes/function/nodes/node_fn_float_compare.cc
M source/blender/nodes/function/nodes/node_fn_float_to_int.cc
M source/blender/nodes/function/nodes/node_fn_input_color.cc
M source/blender/nodes/function/nodes/node_fn_input_string.cc
M source/blender/nodes/function/nodes/node_fn_input_vector.cc
M source/blender/nodes/function/nodes/node_fn_replace_string.cc
M source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
M source/blender/nodes/function/nodes/node_fn_string_length.cc
M source/blender/nodes/function/nodes/node_fn_string_substring.cc
M source/blender/nodes/function/nodes/node_fn_value_to_string.cc
===================================================================
diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
index d10490bb2ee..09caf12e425 100644
--- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
+++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
@@ -34,8 +34,6 @@ static void fn_node_boolean_math_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Bool>("Boolean");
};
-} // namespace blender::nodes
-
static void fn_node_boolean_math_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
@@ -59,13 +57,13 @@ static void node_boolean_math_label(bNodeTree *UNUSED(ntree), bNode *node, char
BLI_strncpy(label, IFACE_(name), maxlen);
}
-static const blender::fn::MultiFunction *get_multi_function(bNode &bnode)
+static const fn::MultiFunction *get_multi_function(bNode &bnode)
{
- static blender::fn::CustomMF_SI_SI_SO<bool, bool, bool> and_fn{
- "And", [](bool a, bool b) { return a && b; }};
- static blender::fn::CustomMF_SI_SI_SO<bool, bool, bool> or_fn{
- "Or", [](bool a, bool b) { return a || b; }};
- static blender::fn::CustomMF_SI_SO<bool, bool> not_fn{"Not", [](bool a) { return !a; }};
+ static fn::CustomMF_SI_SI_SO<bool, bool, bool> and_fn{"And",
+ [](bool a, bool b) { return a && b; }};
+ static fn::CustomMF_SI_SI_SO<bool, bool, bool> or_fn{"Or",
+ [](bool a, bool b) { return a || b; }};
+ static fn::CustomMF_SI_SO<bool, bool> not_fn{"Not", [](bool a) { return !a; }};
switch (bnode.custom1) {
case NODE_BOOLEAN_MATH_AND:
@@ -80,22 +78,23 @@ static const blender::fn::MultiFunction *get_multi_function(bNode &bnode)
return nullptr;
}
-static void fn_node_boolean_math_build_multi_function(
- blender::nodes::NodeMultiFunctionBuilder &builder)
+static void fn_node_boolean_math_build_multi_function(NodeMultiFunctionBuilder &builder)
{
- const blender::fn::MultiFunction *fn = get_multi_function(builder.node());
+ const fn::MultiFunction *fn = get_multi_function(builder.node());
builder.set_matching_fn(fn);
}
+} // namespace blender::nodes
+
void register_node_type_fn_boolean_math()
{
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_BOOLEAN_MATH, "Boolean Math", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::fn_node_boolean_math_declare;
- node_type_label(&ntype, node_boolean_math_label);
- node_type_update(&ntype, node_boolean_math_update);
- ntype.build_multi_function = fn_node_boolean_math_build_multi_function;
- ntype.draw_buttons = fn_node_boolean_math_layout;
+ node_type_label(&ntype, blender::nodes::node_boolean_math_label);
+ node_type_update(&ntype, blender::nodes::node_boolean_math_update);
+ ntype.build_multi_function = blender::nodes::fn_node_boolean_math_build_multi_function;
+ ntype.draw_buttons = blender::nodes::fn_node_boolean_math_layout;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/function/nodes/node_fn_float_compare.cc b/source/blender/nodes/function/nodes/node_fn_float_compare.cc
index 7905419ddb1..bdc4a3c1e02 100644
--- a/source/blender/nodes/function/nodes/node_fn_float_compare.cc
+++ b/source/blender/nodes/function/nodes/node_fn_float_compare.cc
@@ -37,8 +37,6 @@ static void fn_node_float_compare_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Bool>("Result");
};
-} // namespace blender::nodes
-
static void geo_node_float_compare_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
@@ -65,19 +63,19 @@ static void node_float_compare_label(bNodeTree *UNUSED(ntree),
BLI_strncpy(label, IFACE_(name), maxlen);
}
-static const blender::fn::MultiFunction *get_multi_function(bNode &node)
+static const fn::MultiFunction *get_multi_function(bNode &node)
{
- static blender::fn::CustomMF_SI_SI_SO<float, float, bool> less_than_fn{
+ static fn::CustomMF_SI_SI_SO<float, float, bool> less_than_fn{
"Less Than", [](float a, float b) { return a < b; }};
- static blender::fn::CustomMF_SI_SI_SO<float, float, bool> less_equal_fn{
+ static fn::CustomMF_SI_SI_SO<float, float, bool> less_equal_fn{
"Less Equal", [](float a, float b) { return a <= b; }};
- static blender::fn::CustomMF_SI_SI_SO<float, float, bool> greater_than_fn{
+ static fn::CustomMF_SI_SI_SO<float, float, bool> greater_than_fn{
"Greater Than", [](float a, float b) { return a > b; }};
- static blender::fn::CustomMF_SI_SI_SO<float, float, bool> greater_equal_fn{
+ static fn::CustomMF_SI_SI_SO<float, float, bool> greater_equal_fn{
"Greater Equal", [](float a, float b) { return a >= b; }};
- static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, bool> equal_fn{
+ static fn::CustomMF_SI_SI_SI_SO<float, float, float, bool> equal_fn{
"Equal", [](float a, float b, float epsilon) { return std::abs(a - b) <= epsilon; }};
- static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, bool> not_equal_fn{
+ static fn::CustomMF_SI_SI_SI_SO<float, float, float, bool> not_equal_fn{
"Not Equal", [](float a, float b, float epsilon) { return std::abs(a - b) > epsilon; }};
switch (node.custom1) {
@@ -99,22 +97,23 @@ static const blender::fn::MultiFunction *get_multi_function(bNode &node)
return nullptr;
}
-static void fn_node_float_compare_build_multi_function(
- blender::nodes::NodeMultiFunctionBuilder &builder)
+static void fn_node_float_compare_build_multi_function(NodeMultiFunctionBuilder &builder)
{
- const blender::fn::MultiFunction *fn = get_multi_function(builder.node());
+ const fn::MultiFunction *fn = get_multi_function(builder.node());
builder.set_matching_fn(fn);
}
+} // namespace blender::nodes
+
void register_node_type_fn_float_compare()
{
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_COMPARE_FLOATS, "Compare Floats", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::fn_node_float_compare_declare;
- node_type_label(&ntype, node_float_compare_label);
- node_type_update(&ntype, node_float_compare_update);
- ntype.build_multi_function = fn_node_float_compare_build_multi_function;
- ntype.draw_buttons = geo_node_float_compare_layout;
+ node_type_label(&ntype, blender::nodes::node_float_compare_label);
+ node_type_update(&ntype, blender::nodes::node_float_compare_update);
+ ntype.build_multi_function = blender::nodes::fn_node_float_compare_build_multi_function;
+ ntype.draw_buttons = blender::nodes::geo_node_float_compare_layout;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc
index 8bb5dafff8a..5dccd26158b 100644
--- a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc
+++ b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc
@@ -34,8 +34,6 @@ static void fn_node_float_to_int_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Int>("Integer");
};
-} // namespace blender::nodes
-
static void fn_node_float_to_int_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "rounding_mode", 0, "", ICON_NONE);
@@ -51,16 +49,13 @@ static void node_float_to_int_label(bNodeTree *UNUSED(ntree), bNode *node, char
BLI_strncpy(label, IFACE_(name), maxlen);
}
-static const blender::fn::MultiFunction *get_multi_function(bNode &bnode)
+static const fn::MultiFunction *get_multi_function(bNode &bnode)
{
- static blender::fn::CustomMF_SI_SO<float, int> round_fn{"Round",
- [](float a) { return (int)round(a); }};
- static blender::fn::CustomMF_SI_SO<float, int> floor_fn{"Floor",
- [](float a) { return (int)floor(a); }};
- static blender::fn::CustomMF_SI_SO<float, int> ceil_fn{"Ceiling",
- [](float a) { return (int)ceil(a); }};
- static blender::fn::CustomMF_SI_SO<float, int> trunc_fn{"Truncate",
- [](float a) { return (int)trunc(a); }};
+ static fn::CustomMF_SI_SO<float, int> round_fn{"Round", [](float a) { return (int)round(a); }};
+ static fn::CustomMF_SI_SO<float, int> floor_fn{"Floor", [](float a) { return (int)floor(a); }};
+ static fn::CustomMF_SI_SO<float, int> ceil_fn{"Ceiling", [](float a) { return (int)ceil(a); }};
+ static fn::CustomMF_SI_SO<float, int> trunc_fn{"Truncate",
+ [](float a) { return (int)trunc(a); }};
switch (static_cast<FloatToIntRoundingMode>(bnode.custom1)) {
case FN_NODE_FLOAT_TO_INT_ROUND:
@@ -77,21 +72,22 @@ static const blender::fn::MultiFunction *get_multi_function(bNode &bnode)
return nullptr;
}
-static void fn_node_float_to_int_build_multi_function(
- blender::nodes::NodeMultiFunctionBuilder &builder)
+static void fn_node_float_to_int_build_multi_function(NodeMultiFunctionBuilder &builder)
{
- const blender::fn::MultiFunction *fn = get_multi_function(builder.node());
+ const fn::MultiFunction *fn = get_multi_function(builder.node());
builder.set_matching_fn(fn);
}
+} // namespace blender::nodes
+
void register_node_type_fn_float_to_int()
{
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_FLOAT_TO_INT, "Float to Integer", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::fn_node_float_to_int_declare;
- node_type_label(&ntype, node_float_to_int_label);
- ntype.build_multi_function = fn_node_float_to_int_build_multi_function;
- ntype.draw_buttons = fn_node_float_to_int_layout;
+ node_type_label(&ntype, blender::nodes::node_float_to_int_label);
+ ntype.build_multi_function = blender::nodes::fn_node_float_to_int_build_multi_function;
+ ntype.draw_buttons = blender::nodes::fn_node_float_to_int_layout;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/function/nodes/node_fn_input_color.cc b/source/blender/nodes/function/nodes/node_fn_input_color.cc
index 5dc211da1b2..b6079835eae 100644
--- a/so
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list