Commit: 42894aa3df4859252e7eaf00a08f192606c29696
Author: Jacques Lucke
Date:   Sun Oct 13 12:21:00 2019 +0200
Branches: functions-experimental-refactor
https://developer.blender.org/rB42894aa3df4859252e7eaf00a08f192606c29696

don't use old function system for function deform modifier

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

M       source/blender/modifiers/CMakeLists.txt
M       source/blender/modifiers/intern/MOD_functiondeform.c
A       source/blender/modifiers/intern/MOD_functiondeform_cxx.cc

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

diff --git a/source/blender/modifiers/CMakeLists.txt 
b/source/blender/modifiers/CMakeLists.txt
index e508e38546e..f062d99f4fe 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -62,6 +62,7 @@ set(SRC
   intern/MOD_fluidsim.c
   intern/MOD_fluidsim_util.c
   intern/MOD_functiondeform.c
+  intern/MOD_functiondeform_cxx.cc
   intern/MOD_functionpoints.c
   intern/MOD_hook.c
   intern/MOD_laplaciandeform.c
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c 
b/source/blender/modifiers/intern/MOD_functiondeform.c
index 47ee94fa171..3ee0a96ed2c 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -51,55 +51,7 @@
 #include "DEG_depsgraph_query.h"
 #include "time.h"
 
-#include "FN_all-c.h"
-
-static FnFunction get_current_function(FunctionDeformModifierData *fdmd)
-{
-  bNodeTree *tree = (bNodeTree *)DEG_get_original_id((ID 
*)fdmd->function_tree);
-
-  FnType float_ty = FN_type_get_float();
-  FnType int32_ty = FN_type_get_int32();
-  FnType float3_ty = FN_type_get_float3();
-
-  FnType inputs[] = {float3_ty, int32_ty, float_ty, NULL};
-  FnType outputs[] = {float3_ty, NULL};
-
-  return FN_function_get_with_signature(tree, inputs, outputs);
-}
-
-static void do_deformation(FunctionDeformModifierData *fdmd, float 
(*vertexCos)[3], int numVerts)
-{
-  FnFunction fn = get_current_function(fdmd);
-  if (fn == NULL) {
-    modifier_setError(&fdmd->modifier, "Invalid function");
-    return;
-  }
-
-  FnTupleCallBody body = FN_tuple_call_get(fn);
-  BLI_assert(body);
-
-  FN_TUPLE_CALL_PREPARE_STACK(body, fn_in, fn_out);
-
-  clock_t start = clock();
-
-  int seed = fdmd->control2 * 234132;
-
-  for (int i = 0; i < numVerts; i++) {
-    FN_tuple_set_float3(fn_in, 0, vertexCos[i]);
-    FN_tuple_set_int32(fn_in, 1, seed + i);
-    FN_tuple_set_float(fn_in, 2, fdmd->control1);
-
-    FN_tuple_call_invoke(body, fn_in, fn_out, __func__);
-
-    FN_tuple_get_float3(fn_out, 0, vertexCos[i]);
-  }
-
-  clock_t end = clock();
-  printf("Time taken: %f ms\n", (float)(end - start) / (float)CLOCKS_PER_SEC * 
1000.0f);
-
-  FN_TUPLE_CALL_DESTRUCT_STACK(body, fn_in, fn_out);
-  FN_function_free(fn);
-}
+void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float 
(*vertexCos)[3], int numVerts);
 
 static void deformVerts(ModifierData *md,
                         const ModifierEvalContext *UNUSED(ctx),
@@ -107,7 +59,7 @@ static void deformVerts(ModifierData *md,
                         float (*vertexCos)[3],
                         int numVerts)
 {
-  do_deformation((FunctionDeformModifierData *)md, vertexCos, numVerts);
+  MOD_functiondeform_do((FunctionDeformModifierData *)md, vertexCos, numVerts);
 }
 
 static void deformVertsEM(ModifierData *md,
@@ -117,7 +69,7 @@ static void deformVertsEM(ModifierData *md,
                           float (*vertexCos)[3],
                           int numVerts)
 {
-  do_deformation((FunctionDeformModifierData *)md, vertexCos, numVerts);
+  MOD_functiondeform_do((FunctionDeformModifierData *)md, vertexCos, numVerts);
 }
 
 static void initData(ModifierData *md)
@@ -132,15 +84,9 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
   return true;
 }
 
-static void updateDepsgraph(ModifierData *md, const 
ModifierUpdateDepsgraphContext *ctx)
+static void updateDepsgraph(ModifierData *UNUSED(md),
+                            const ModifierUpdateDepsgraphContext *UNUSED(ctx))
 {
-  FunctionDeformModifierData *fdmd = (FunctionDeformModifierData *)md;
-
-  FnFunction fn = get_current_function(fdmd);
-  if (fn) {
-    FN_function_update_dependencies(fn, ctx->node);
-    FN_function_free(fn);
-  }
 }
 
 static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void 
*userData)
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc 
b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
new file mode 100644
index 00000000000..4777f11b619
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -0,0 +1,12 @@
+#include "DNA_modifier_types.h"
+
+extern "C" {
+void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float 
(*vertexCos)[3], int numVerts);
+}
+
+void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float 
(*vertexCos)[3], int numVerts)
+{
+  for (uint i = 0; i < numVerts; i++) {
+    vertexCos[i][2] += 3;
+  }
+}
\ No newline at end of file

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to