[Bf-blender-cvs] [844c2c8a796] functions: new Project operation in vector math node

Jacques Lucke noreply at git.blender.org
Tue Sep 10 12:10:54 CEST 2019


Commit: 844c2c8a7966b3208e01ba5a9c02238bc7e7a027
Author: Jacques Lucke
Date:   Tue Sep 10 12:10:40 2019 +0200
Branches: functions
https://developer.blender.org/rB844c2c8a7966b3208e01ba5a9c02238bc7e7a027

new Project operation in vector math node

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

M	release/scripts/startup/nodes/function_nodes/vector.py
M	source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
M	source/blender/functions/functions/vectors.cpp
M	source/blender/functions/functions/vectors.hpp

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

diff --git a/release/scripts/startup/nodes/function_nodes/vector.py b/release/scripts/startup/nodes/function_nodes/vector.py
index 609256759fd..6581b2f973c 100644
--- a/release/scripts/startup/nodes/function_nodes/vector.py
+++ b/release/scripts/startup/nodes/function_nodes/vector.py
@@ -15,6 +15,7 @@ class VectorMathNode(bpy.types.Node, FunctionNode):
         ("DIV", "Divide", "", "", 4),
         ("CROSS", "Cross Product", "", "", 5),
         ("REFLECT", "Reflect", "", "", 6),
+        ("PROJECT", "Project", "", "", 7),
     ]
 
     operation: EnumProperty(
diff --git a/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
index ca370466f27..3d24e32ab47 100644
--- a/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
@@ -160,7 +160,9 @@ static SharedFunction &get_vector_math_function(int operation)
     case 5:
       return Functions::GET_FN_cross_vectors();
     case 6:
-      return Functions::GET_FN_reflect_vectors();
+      return Functions::GET_FN_reflect_vector();
+    case 7:
+      return Functions::GET_FN_project_vector();
     default:
       BLI_assert(false);
       return Functions::GET_FN_none();
diff --git a/source/blender/functions/functions/vectors.cpp b/source/blender/functions/functions/vectors.cpp
index e6668b955c1..d30929d30cc 100644
--- a/source/blender/functions/functions/vectors.cpp
+++ b/source/blender/functions/functions/vectors.cpp
@@ -252,7 +252,7 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_cross_vectors)
   return fn;
 }
 
-class ReflectVectors : public TupleCallBody {
+class ReflectVector : public TupleCallBody {
   void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &UNUSED(ctx)) const override
   {
     float3 a = fn_in.get<float3>(0);
@@ -261,10 +261,29 @@ class ReflectVectors : public TupleCallBody {
   }
 };
 
-BLI_LAZY_INIT(SharedFunction, GET_FN_reflect_vectors)
+BLI_LAZY_INIT(SharedFunction, GET_FN_reflect_vector)
 {
-  auto fn = get_math_function__two_inputs("Reflect Vectors");
-  fn->add_body<ReflectVectors>();
+  auto fn = get_math_function__two_inputs("Reflect Vector");
+  fn->add_body<ReflectVector>();
+  return fn;
+}
+
+class ProjectVector : public TupleCallBody {
+  void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &UNUSED(ctx)) const override
+  {
+    float3 a = fn_in.get<float3>(0);
+    float3 b = fn_in.get<float3>(1);
+
+    float3 result;
+    project_v3_v3v3(result, a, b);
+    fn_out.set<float3>(0, result);
+  }
+};
+
+BLI_LAZY_INIT(SharedFunction, GET_FN_project_vector)
+{
+  auto fn = get_math_function__two_inputs("Project Vector");
+  fn->add_body<ProjectVector>();
   return fn;
 }
 
diff --git a/source/blender/functions/functions/vectors.hpp b/source/blender/functions/functions/vectors.hpp
index d27a13b6deb..980bfa3d1bb 100644
--- a/source/blender/functions/functions/vectors.hpp
+++ b/source/blender/functions/functions/vectors.hpp
@@ -12,8 +12,9 @@ SharedFunction &GET_FN_add_vectors();
 SharedFunction &GET_FN_sub_vectors();
 SharedFunction &GET_FN_mul_vectors();
 SharedFunction &GET_FN_div_vectors();
-SharedFunction &GET_FN_cross_vectors();
-SharedFunction &GET_FN_reflect_vectors();
+SharedFunction &GET_FN_cross_vectors();
+SharedFunction &GET_FN_reflect_vector();
+SharedFunction &GET_FN_project_vector();
 
 }  // namespace Functions
 }  // namespace FN



More information about the Bf-blender-cvs mailing list