[Bf-blender-cvs] [f4455b442c0] functions-experimental-refactor: separate vector function

Jacques Lucke noreply at git.blender.org
Tue Oct 15 15:57:45 CEST 2019


Commit: f4455b442c0d0afe71b4d8a0421485a7cf89ae9f
Author: Jacques Lucke
Date:   Tue Oct 15 15:52:53 2019 +0200
Branches: functions-experimental-refactor
https://developer.blender.org/rBf4455b442c0d0afe71b4d8a0421485a7cf89ae9f

separate vector function

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

M	source/blender/blenkernel/BKE_multi_functions.h
M	source/blender/blenkernel/intern/multi_functions.cc
M	source/blender/modifiers/intern/MOD_functiondeform_cxx.cc

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

diff --git a/source/blender/blenkernel/BKE_multi_functions.h b/source/blender/blenkernel/BKE_multi_functions.h
index 75ceef1cb97..e0655fd5231 100644
--- a/source/blender/blenkernel/BKE_multi_functions.h
+++ b/source/blender/blenkernel/BKE_multi_functions.h
@@ -23,6 +23,12 @@ class MultiFunction_CombineVector final : public MultiFunction {
   void call(ArrayRef<uint> mask_indices, Params &params) const override;
 };
 
+class MultiFunction_SeparateVector final : public MultiFunction {
+ public:
+  MultiFunction_SeparateVector();
+  void call(ArrayRef<uint> mask_indices, Params &params) const override;
+};
+
 class MultiFunction_VectorDistance final : public MultiFunction {
  public:
   MultiFunction_VectorDistance();
diff --git a/source/blender/blenkernel/intern/multi_functions.cc b/source/blender/blenkernel/intern/multi_functions.cc
index 53a926147e7..0241c3c2422 100644
--- a/source/blender/blenkernel/intern/multi_functions.cc
+++ b/source/blender/blenkernel/intern/multi_functions.cc
@@ -74,6 +74,31 @@ void MultiFunction_CombineVector::call(ArrayRef<uint> mask_indices, Params &para
   }
 }
 
+MultiFunction_SeparateVector::MultiFunction_SeparateVector()
+{
+  SignatureBuilder signature;
+  signature.readonly_single_input<float3>("Vector");
+  signature.single_output<float>("X");
+  signature.single_output<float>("Y");
+  signature.single_output<float>("Z");
+  this->set_signature(signature);
+}
+
+void MultiFunction_SeparateVector::call(ArrayRef<uint> mask_indices, Params &params) const
+{
+  auto vector = params.readonly_single_input<float3>(0, "Vector");
+  auto x = params.single_output<float>(1, "X");
+  auto y = params.single_output<float>(2, "Y");
+  auto z = params.single_output<float>(3, "Z");
+
+  for (uint i : mask_indices) {
+    float3 v = vector[i];
+    x[i] = v.x;
+    y[i] = v.y;
+    z[i] = v.z;
+  }
+}
+
 MultiFunction_VectorDistance::MultiFunction_VectorDistance()
 {
   SignatureBuilder signature;
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
index 991ec85670f..558ce0a7e06 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -6,6 +6,8 @@
 
 #include "BLI_math_cxx.h"
 
+#include "DEG_depsgraph_query.h"
+
 using BKE::CPPType;
 using BKE::TupleRef;
 using BKE::VirtualLink;
@@ -50,6 +52,9 @@ static std::unique_ptr<BKE::MultiFunction> get_multi_function_by_node(VirtualNod
   else if (idname == "fn_CombineVectorNode") {
     return BLI::make_unique<BKE::MultiFunction_CombineVector>();
   }
+  else if (idname == "fn_SeparateVectorNode") {
+    return BLI::make_unique<BKE::MultiFunction_SeparateVector>();
+  }
   else {
     BLI_assert(false);
     return {};
@@ -239,8 +244,9 @@ void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float (*vertexCos)[
     return;
   }
 
+  bNodeTree *tree = (bNodeTree *)DEG_get_original_id((ID *)fdmd->function_tree);
   VirtualNodeTree vtree;
-  vtree.add_all_of_tree(fdmd->function_tree);
+  vtree.add_all_of_tree(tree);
   vtree.freeze_and_index();
 
   MultiFunction_FunctionTree function{*vtree.nodes_with_idname("fn_FunctionInputNode")[0],



More information about the Bf-blender-cvs mailing list