[Bf-blender-cvs] [e390a51cc71] functions-experimental-refactor: bring back some vector math nodes

Jacques Lucke noreply at git.blender.org
Fri Nov 8 18:31:08 CET 2019


Commit: e390a51cc713c13c4807d66d35afd825078d9e95
Author: Jacques Lucke
Date:   Fri Nov 8 16:12:43 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rBe390a51cc713c13c4807d66d35afd825078d9e95

bring back some vector math nodes

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

M	release/scripts/startup/nodes/function_nodes/float_math.py
M	release/scripts/startup/nodes/function_nodes/vector.py
M	source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc

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

diff --git a/release/scripts/startup/nodes/function_nodes/float_math.py b/release/scripts/startup/nodes/function_nodes/float_math.py
index f08d3edebce..e6cd2affd6b 100644
--- a/release/scripts/startup/nodes/function_nodes/float_math.py
+++ b/release/scripts/startup/nodes/function_nodes/float_math.py
@@ -62,5 +62,10 @@ PowerFloatsNode = create_two_inputs_math_node("Float", "fn_PowerFloatsNode", "Po
 
 SqrtFloatNode = create_single_input_math_node("Float", "fn_SqrtFloatNode", "Sqrt Float")
 AbsFloatNode = create_single_input_math_node("Float", "fn_AbsoluteFloatNode", "Absolute Float")
-SineNode = create_single_input_math_node("Float", "fn_SineNode", "Sine")
-CosineNode = create_single_input_math_node("Float", "fn_CosineNode", "Cosine")
+SineFloatNode = create_single_input_math_node("Float", "fn_SineFloatNode", "Sine")
+CosineFloatNode = create_single_input_math_node("Float", "fn_CosineFloatNode", "Cosine")
+
+AddVectorsNode = create_variadic_math_node("Vector", "fn_AddVectorsNode", "Add Vectors")
+SubtractVectorsNode = create_two_inputs_math_node("Vector", "fn_SubtractVectorsNode", "Subtract Vectors")
+MultiplyVectorsNode = create_variadic_math_node("Vector", "fn_MultiplyVectorsNode", "Multiply Vectors")
+DivideVectorsNode = create_two_inputs_math_node("Vector", "fn_DivideVectorsNode", "Divide Vectors")
diff --git a/release/scripts/startup/nodes/function_nodes/vector.py b/release/scripts/startup/nodes/function_nodes/vector.py
index 50a4b772849..c9824f7128f 100644
--- a/release/scripts/startup/nodes/function_nodes/vector.py
+++ b/release/scripts/startup/nodes/function_nodes/vector.py
@@ -3,7 +3,7 @@ from bpy.props import *
 from .. base import FunctionNode
 from .. node_builder import NodeBuilder
 
-
+'''
 class VectorMathNode(bpy.types.Node, FunctionNode):
     bl_idname = "fn_VectorMathNode"
     bl_label = "Vector Math"
@@ -47,7 +47,7 @@ class VectorMathNode(bpy.types.Node, FunctionNode):
 
     def draw(self, layout):
         layout.prop(self, "operation", text="")
-
+'''
 
 class VectorDistanceNode(bpy.types.Node, FunctionNode):
     bl_idname = "fn_VectorDistanceNode"
diff --git a/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
index 4568308c31b..b853ef199a5 100644
--- a/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
+++ b/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
@@ -3,8 +3,12 @@
 
 #include "FN_multi_functions.h"
 
+#include "BLI_math_cxx.h"
+
 namespace FN {
 
+using BLI::float3;
+
 static void INSERT_vector_math(VTreeMFNetworkBuilder &builder, const VNode &vnode)
 {
   const MultiFunction &fn = builder.construct_fn<FN::MF_AddFloat3s>();
@@ -307,16 +311,36 @@ static void INSERT_abs_float(VTreeMFNetworkBuilder &builder, const VNode &vnode)
   insert_single_input_math_function<float, abs_func_cb<float>>(builder, vnode);
 }
 
-static void INSERT_sine(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+static void INSERT_sine_float(VTreeMFNetworkBuilder &builder, const VNode &vnode)
 {
   insert_single_input_math_function<float, sine_func_cb<float>>(builder, vnode);
 }
 
-static void INSERT_cosine(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+static void INSERT_cosine_float(VTreeMFNetworkBuilder &builder, const VNode &vnode)
 {
   insert_single_input_math_function<float, cosine_func_cb<float>>(builder, vnode);
 }
 
+static void INSERT_add_vectors(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+{
+  insert_simple_math_function<float3, add_func_cb<float3>>(builder, vnode, {0, 0, 0});
+}
+
+static void INSERT_subtract_vectors(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+{
+  insert_two_inputs_math_function<float3, subtract_func_cb<float3>>(builder, vnode);
+}
+
+static void INSERT_multiply_vectors(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+{
+  insert_simple_math_function<float3, mul_func_cb<float3>>(builder, vnode, {1, 1, 1});
+}
+
+static void INSERT_divide_vectors(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+{
+  insert_two_inputs_math_function<float3, float3::safe_divide>(builder, vnode);
+}
+
 void add_vtree_node_mapping_info(VTreeMultiFunctionMappings &mappings)
 {
   mappings.vnode_inserters.add_new("fn_FloatMathNode", INSERT_float_math);
@@ -343,8 +367,13 @@ void add_vtree_node_mapping_info(VTreeMultiFunctionMappings &mappings)
 
   mappings.vnode_inserters.add_new("fn_SqrtFloatNode", INSERT_sqrt_float);
   mappings.vnode_inserters.add_new("fn_AbsoluteFloatNode", INSERT_abs_float);
-  mappings.vnode_inserters.add_new("fn_SineNode", INSERT_sine);
-  mappings.vnode_inserters.add_new("fn_CosineNode", INSERT_cosine);
+  mappings.vnode_inserters.add_new("fn_SineFloatNode", INSERT_sine_float);
+  mappings.vnode_inserters.add_new("fn_CosineFloatNode", INSERT_cosine_float);
+
+  mappings.vnode_inserters.add_new("fn_AddVectorsNode", INSERT_add_vectors);
+  mappings.vnode_inserters.add_new("fn_SubtractVectorsNode", INSERT_subtract_vectors);
+  mappings.vnode_inserters.add_new("fn_MultiplyVectorsNode", INSERT_multiply_vectors);
+  mappings.vnode_inserters.add_new("fn_DivideVectorsNode", INSERT_divide_vectors);
 }
 
 };  // namespace FN



More information about the Bf-blender-cvs mailing list