[Bf-blender-cvs] [975decb5e39] functions: new Vector Length node

Jacques Lucke noreply at git.blender.org
Sun Feb 2 14:27:21 CET 2020


Commit: 975decb5e39cde1f74e6aa8e226867d4106d8d84
Author: Jacques Lucke
Date:   Sun Feb 2 14:16:21 2020 +0100
Branches: functions
https://developer.blender.org/rB975decb5e39cde1f74e6aa8e226867d4106d8d84

new Vector Length node

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

M	release/scripts/startup/nodes/function_nodes/math.py
M	source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc

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

diff --git a/release/scripts/startup/nodes/function_nodes/math.py b/release/scripts/startup/nodes/function_nodes/math.py
index 56075995a82..f8da05f9e3e 100644
--- a/release/scripts/startup/nodes/function_nodes/math.py
+++ b/release/scripts/startup/nodes/function_nodes/math.py
@@ -39,7 +39,7 @@ def create_two_inputs_math_node(input_type1, input_type2, output_type, idname, l
 
     return MathNode
 
-def create_single_input_math_node(data_type, idname, label):
+def create_single_input_math_node(input_type, output_type, idname, label):
 
     class MathNode(bpy.types.Node, FunctionNode):
         bl_idname = idname
@@ -48,8 +48,8 @@ def create_single_input_math_node(data_type, idname, label):
         use_list: NodeBuilder.VectorizedProperty()
 
         def declaration(self, builder: NodeBuilder):
-            builder.vectorized_input("input", "use_list", "Value", "Values", data_type)
-            builder.vectorized_output("output", ["use_list"], "Result", "Result", data_type)
+            builder.vectorized_input("input", "use_list", "Value", "Values", input_type)
+            builder.vectorized_output("output", ["use_list"], "Result", "Result", output_type)
 
     return MathNode
 
@@ -62,13 +62,13 @@ SubtractFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_Subtra
 DivideFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_DivideFloatsNode", "Divide Floats")
 PowerFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_PowerFloatsNode", "Power Floats")
 
-SqrtFloatNode = create_single_input_math_node("Float", "fn_SqrtFloatNode", "Sqrt Float")
-AbsFloatNode = create_single_input_math_node("Float", "fn_AbsoluteFloatNode", "Absolute Float")
-SineFloatNode = create_single_input_math_node("Float", "fn_SineFloatNode", "Sine")
-CosineFloatNode = create_single_input_math_node("Float", "fn_CosineFloatNode", "Cosine")
+SqrtFloatNode = create_single_input_math_node("Float", "Float", "fn_SqrtFloatNode", "Sqrt Float")
+AbsFloatNode = create_single_input_math_node("Float", "Float", "fn_AbsoluteFloatNode", "Absolute Float")
+SineFloatNode = create_single_input_math_node("Float", "Float", "fn_SineFloatNode", "Sine")
+CosineFloatNode = create_single_input_math_node("Float", "Float", "fn_CosineFloatNode", "Cosine")
 
-CeilFloatNode = create_single_input_math_node("Float", "fn_CeilFloatNode", "Ceil Float")
-FloorFloatNode = create_single_input_math_node("Float", "fn_FloorFloatNode", "Floor Float")
+CeilFloatNode = create_single_input_math_node("Float", "Float", "fn_CeilFloatNode", "Ceil Float")
+FloorFloatNode = create_single_input_math_node("Float", "Float", "fn_FloorFloatNode", "Floor Float")
 
 AddVectorsNode = create_variadic_math_node("Vector", "fn_AddVectorsNode", "Add Vectors")
 SubtractVectorsNode = create_single_type_two_inputs_math_node("Vector", "fn_SubtractVectorsNode", "Subtract Vectors")
@@ -81,11 +81,12 @@ VectorReflectNode = create_single_type_two_inputs_math_node("Vector", "fn_Reflec
 VectorProjectNode = create_single_type_two_inputs_math_node("Vector", "fn_ProjectVectorNode", "Project Vector")
 VectorDotProductNode = create_two_inputs_math_node("Vector", "Vector", "Float", "fn_VectorDotProductNode", "Dot Product")
 VectorDistanceNode = create_two_inputs_math_node("Vector", "Vector", "Float", "fn_VectorDistanceNode", "Vector Distance")
-NormalizeVectorNode = create_single_input_math_node("Vector", "fn_NormalizeVectorNode", "Normalize Vector")
+NormalizeVectorNode = create_single_input_math_node("Vector", "Vector", "fn_NormalizeVectorNode", "Normalize Vector")
+VectorLengthNode = create_single_input_math_node("Vector", "Float", "fn_VectorLengthNode", "Vector Length")
 
 BooleanAndNode = create_variadic_math_node("Boolean", "fn_BooleanAndNode", "And")
 BooleanOrNode = create_variadic_math_node("Boolean", "fn_BooleanOrNode", "Or")
-BooleanNotNode = create_single_input_math_node("Boolean", "fn_BooleanNotNode", "Not")
+BooleanNotNode = create_single_input_math_node("Boolean", "Boolean", "fn_BooleanNotNode", "Not")
 
 LessThanFloatNode = create_two_inputs_math_node("Float", "Float", "Boolean", "fn_LessThanFloatNode", "Less Than Float")
 GreaterThanFloatNode = create_two_inputs_math_node("Float", "Float", "Boolean", "fn_GreaterThanFloatNode", "Greater Than Float")
diff --git a/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc
index 8cf2578dfd5..a16db9692bd 100644
--- a/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc
+++ b/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc
@@ -365,6 +365,11 @@ static void INSERT_normalize_vector(FNodeMFBuilder &builder)
                                          [](float3 a) -> float3 { return a.normalized(); });
 }
 
+static void INSERT_vector_length(FNodeMFBuilder &builder)
+{
+  build_math_fn_1in_1out<float3, float>(builder, [](float3 a) -> float { return a.length(); });
+}
+
 static void INSERT_boolean_and(FNodeMFBuilder &builder)
 {
   build_variadic_math_fn(
@@ -614,6 +619,7 @@ void add_function_tree_node_mapping_info(FunctionTreeMFMappings &mappings)
   mappings.fnode_inserters.add_new("fn_MultiplyVectorWithFloatNode",
                                    INSERT_multiply_vector_with_float);
   mappings.fnode_inserters.add_new("fn_NormalizeVectorNode", INSERT_normalize_vector);
+  mappings.fnode_inserters.add_new("fn_VectorLengthNode", INSERT_vector_length);
 
   mappings.fnode_inserters.add_new("fn_BooleanAndNode", INSERT_boolean_and);
   mappings.fnode_inserters.add_new("fn_BooleanOrNode", INSERT_boolean_or);



More information about the Bf-blender-cvs mailing list