[Bf-blender-cvs] [ed4db612f82] functions: new Combine Color node

Jacques Lucke noreply at git.blender.org
Wed Jul 31 18:45:03 CEST 2019


Commit: ed4db612f824fc04463a6a25019a8e26598ec08c
Author: Jacques Lucke
Date:   Wed Jul 31 16:57:04 2019 +0200
Branches: functions
https://developer.blender.org/rBed4db612f824fc04463a6a25019a8e26598ec08c

new Combine Color node

===================================================================

M	release/scripts/startup/nodes/function_nodes/color.py
M	source/blender/functions/frontends/data_flow_nodes/inserters/nodes.cpp
M	source/blender/functions/functions/color.cpp
M	source/blender/functions/functions/color.hpp

===================================================================

diff --git a/release/scripts/startup/nodes/function_nodes/color.py b/release/scripts/startup/nodes/function_nodes/color.py
index fe91a4b082e..fd4cc1f3a2e 100644
--- a/release/scripts/startup/nodes/function_nodes/color.py
+++ b/release/scripts/startup/nodes/function_nodes/color.py
@@ -27,3 +27,31 @@ class SeparateColorNode(bpy.types.Node, FunctionNode):
         builder.vectorized_output(
             "alpha", ["use_list__color"],
             "Alpha", "Alpha", "Float")
+
+
+class CombineColorNode(bpy.types.Node, FunctionNode):
+    bl_idname = "fn_CombineColorNode"
+    bl_label = "Combine Color"
+
+    use_list__red: NodeBuilder.VectorizedProperty()
+    use_list__green: NodeBuilder.VectorizedProperty()
+    use_list__blue: NodeBuilder.VectorizedProperty()
+    use_list__alpha: NodeBuilder.VectorizedProperty()
+
+    def declaration(self, builder: NodeBuilder):
+        builder.vectorized_input(
+            "red", "use_list__red",
+            "Red", "Red", "Float")
+        builder.vectorized_input(
+            "green", "use_list__green",
+            "Green", "Green", "Float")
+        builder.vectorized_input(
+            "blue", "use_list__blue",
+            "Blue", "Blue", "Float")
+        builder.vectorized_input(
+            "alpha", "use_list__alpha",
+            "Alpha", "Alpha", "Float")
+
+        builder.vectorized_output(
+            "color", ["use_list__red", "use_list__green", "use_list__blue", "use_list__alpha"],
+            "Color", "Colors", "Color")
diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters/nodes.cpp b/source/blender/functions/frontends/data_flow_nodes/inserters/nodes.cpp
index 3a3d7ea1904..2a6a348e39b 100644
--- a/source/blender/functions/frontends/data_flow_nodes/inserters/nodes.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/inserters/nodes.cpp
@@ -270,6 +270,19 @@ static void INSERT_separate_color(BTreeGraphBuilder &builder, VirtualNode *vnode
   builder.insert_matching_function(fn, vnode);
 }
 
+static void INSERT_combine_color(BTreeGraphBuilder &builder, VirtualNode *vnode)
+{
+  PointerRNA rna = vnode->rna();
+  SharedFunction fn = get_vectorized_function(
+      Functions::GET_FN_combine_color(),
+      rna,
+      {{"use_list__red", Functions::GET_FN_output_float_0()},
+       {"use_list__green", Functions::GET_FN_output_float_0()},
+       {"use_list__blue", Functions::GET_FN_output_float_0()},
+       {"use_list__alpha", Functions::GET_FN_output_float_1()}});
+  builder.insert_matching_function(fn, vnode);
+}
+
 static SharedFunction &get_compare_function(int operation)
 {
   switch (operation) {
@@ -314,6 +327,7 @@ void register_node_inserters(GraphInserters &inserters)
   inserters.reg_node_inserter("fn_ListLengthNode", INSERT_list_length);
   inserters.reg_node_inserter("fn_CompareNode", INSERT_compare);
   inserters.reg_node_inserter("fn_SeparateColorNode", INSERT_separate_color);
+  inserters.reg_node_inserter("fn_CombineColorNode", INSERT_combine_color);
 }
 
 }  // namespace DataFlowNodes
diff --git a/source/blender/functions/functions/color.cpp b/source/blender/functions/functions/color.cpp
index 4ab223fd5a6..46ba2dfdfee 100644
--- a/source/blender/functions/functions/color.cpp
+++ b/source/blender/functions/functions/color.cpp
@@ -34,5 +34,31 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_separate_color)
   return fn;
 }
 
+class CombineColor : public TupleCallBody {
+  void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &UNUSED(ctx)) const override
+  {
+    rgba_f color;
+    color.r = this->get_input<float>(fn_in, 0, "Red");
+    color.g = this->get_input<float>(fn_in, 1, "Green");
+    color.b = this->get_input<float>(fn_in, 2, "Blue");
+    color.a = this->get_input<float>(fn_in, 3, "Alpha");
+    this->set_output<rgba_f>(fn_out, 0, "Color", color);
+  }
+};
+
+BLI_LAZY_INIT(SharedFunction, GET_FN_combine_color)
+{
+  FunctionBuilder fn_builder;
+  fn_builder.add_input("Red", GET_TYPE_float());
+  fn_builder.add_input("Green", GET_TYPE_float());
+  fn_builder.add_input("Blue", GET_TYPE_float());
+  fn_builder.add_input("Alpha", GET_TYPE_float());
+  fn_builder.add_output("Color", GET_TYPE_rgba_f());
+
+  auto fn = fn_builder.build("Combine Color");
+  fn->add_body<CombineColor>();
+  return fn;
+}
+
 }  // namespace Functions
 }  // namespace FN
diff --git a/source/blender/functions/functions/color.hpp b/source/blender/functions/functions/color.hpp
index 23041e064c8..4a55ea17d8b 100644
--- a/source/blender/functions/functions/color.hpp
+++ b/source/blender/functions/functions/color.hpp
@@ -6,6 +6,7 @@ namespace FN {
 namespace Functions {
 
 SharedFunction &GET_FN_separate_color();
+SharedFunction &GET_FN_combine_color();
 
 }  // namespace Functions
 };  // namespace FN



More information about the Bf-blender-cvs mailing list