[Bf-blender-cvs] [393f220f488] functions: setup object dependencies correctly
Jacques Lucke
noreply at git.blender.org
Tue Feb 12 14:32:28 CET 2019
Commit: 393f220f4884a304b15a06b04cb39f0e2aacfdd4
Author: Jacques Lucke
Date: Tue Feb 12 14:32:14 2019 +0100
Branches: functions
https://developer.blender.org/rB393f220f4884a304b15a06b04cb39f0e2aacfdd4
setup object dependencies correctly
===================================================================
M source/blender/functions/CMakeLists.txt
M source/blender/functions/FN_functions.h
M source/blender/functions/c_wrapper.cpp
M source/blender/functions/core/cpu.hpp
A source/blender/functions/core/dependencies.cpp
A source/blender/functions/core/dependencies.hpp
M source/blender/functions/core/graph_to_function.cpp
M source/blender/functions/function_nodes/function_nodes.cpp
M source/blender/modifiers/intern/MOD_functiondeform.c
===================================================================
diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 7ef027faec7..880a5df1bd1 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -4,6 +4,7 @@ set(INC
../makesdna
../makesrna
../blenkernel
+ ../depsgraph
)
set(INC_SYS
@@ -14,10 +15,12 @@ set(SRC
c_wrapper.cpp
core/core.hpp
- core/data_flow_graph.hpp
core/cpu.hpp
core/cpu.cpp
+ core/data_flow_graph.hpp
core/data_flow_graph.cpp
+ core/dependencies.hpp
+ core/dependencies.cpp
core/dot_export.cpp
core/graph_to_function.hpp
core/graph_to_function.cpp
diff --git a/source/blender/functions/FN_functions.h b/source/blender/functions/FN_functions.h
index 0ea3d0defa5..658696a7eba 100644
--- a/source/blender/functions/FN_functions.h
+++ b/source/blender/functions/FN_functions.h
@@ -42,6 +42,11 @@ FnFunction FN_get_generated_function(void);
FnFunction FN_testing(bNodeTree *bnodetree);
+struct DepsNodeHandle;
+void FN_function_update_dependencies(
+ FnFunction fn,
+ struct DepsNodeHandle *deps_node);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/functions/c_wrapper.cpp b/source/blender/functions/c_wrapper.cpp
index 4ae3989c9ee..6c734b8e0a5 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -216,4 +216,14 @@ FnFunction FN_testing(bNodeTree *bnodetree)
BLI::RefCounted<FN::Function> *fn_ref = fn.refcounter();
fn_ref->incref();
return wrap(fn_ref);
+}
+
+void FN_function_update_dependencies(
+ FnFunction fn,
+ struct DepsNodeHandle *deps_node)
+{
+ BLI::RefCounted<FN::Function> *fn_ref = unwrap(fn);
+ FN::Dependencies dependencies;
+ fn_ref->ptr()->body<FN::TupleCallBody>()->dependencies(dependencies);
+ dependencies.update_depsgraph(deps_node);
}
\ No newline at end of file
diff --git a/source/blender/functions/core/cpu.hpp b/source/blender/functions/core/cpu.hpp
index 46754180723..1c45ae638ba 100644
--- a/source/blender/functions/core/cpu.hpp
+++ b/source/blender/functions/core/cpu.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "core.hpp"
+#include "dependencies.hpp"
namespace FN {
@@ -16,6 +17,7 @@ namespace FN {
virtual ~TupleCallBody() {};
virtual void call(const Tuple &fn_in, Tuple &fn_out) const = 0;
+ virtual void dependencies(Dependencies &UNUSED(deps)) const {}
};
class CPPTypeInfo {
diff --git a/source/blender/functions/core/dependencies.cpp b/source/blender/functions/core/dependencies.cpp
new file mode 100644
index 00000000000..f5dd0ff4db4
--- /dev/null
+++ b/source/blender/functions/core/dependencies.cpp
@@ -0,0 +1,14 @@
+#include "dependencies.hpp"
+
+#include "DEG_depsgraph_build.h"
+
+namespace FN {
+
+ void Dependencies::update_depsgraph(DepsNodeHandle *deps_node)
+ {
+ for (struct Object *ob : m_transform_dependencies) {
+ DEG_add_object_relation(deps_node, ob, DEG_OB_COMP_TRANSFORM, __func__);
+ }
+ }
+
+} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/core/dependencies.hpp b/source/blender/functions/core/dependencies.hpp
new file mode 100644
index 00000000000..29ab9a4d585
--- /dev/null
+++ b/source/blender/functions/core/dependencies.hpp
@@ -0,0 +1,22 @@
+#include "BLI_small_set.hpp"
+
+struct Object;
+struct DepsNodeHandle;
+
+namespace FN {
+ using namespace BLI;
+
+ class Dependencies {
+ private:
+ SmallSet<struct Object *> m_transform_dependencies;
+
+ public:
+ void add_object_transform_dependency(struct Object *object)
+ {
+ m_transform_dependencies.add(object);
+ }
+
+ void update_depsgraph(DepsNodeHandle *deps_node);
+ };
+
+} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/core/graph_to_function.cpp b/source/blender/functions/core/graph_to_function.cpp
index 7b5aba05beb..bb686942276 100644
--- a/source/blender/functions/core/graph_to_function.cpp
+++ b/source/blender/functions/core/graph_to_function.cpp
@@ -15,6 +15,14 @@ namespace FN {
m_inputs(function_graph.inputs()),
m_outputs(function_graph.outputs()) {}
+ void dependencies(Dependencies &deps) const override
+ {
+ for (const Node *node : m_graph->all_nodes()) {
+ const TupleCallBody *body = node->function()->body<TupleCallBody>();
+ if (body) body->dependencies(deps);
+ }
+ }
+
void call(const Tuple &fn_in, Tuple &fn_out) const override
{
for (uint i = 0; i < m_outputs.size(); i++) {
diff --git a/source/blender/functions/function_nodes/function_nodes.cpp b/source/blender/functions/function_nodes/function_nodes.cpp
index 509b339b432..215a3299b64 100644
--- a/source/blender/functions/function_nodes/function_nodes.cpp
+++ b/source/blender/functions/function_nodes/function_nodes.cpp
@@ -114,6 +114,11 @@ namespace FN::FunctionNodes {
fn_out.set<Vector>(0, Vector());
}
}
+
+ void dependencies(Dependencies &deps) const override
+ {
+ deps.add_object_transform_dependency(m_object);
+ }
};
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c b/source/blender/modifiers/intern/MOD_functiondeform.c
index aa2cd241a0f..79b93ac4bfb 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -56,12 +56,17 @@ static bNodeTree *get_node_tree(void)
return (bNodeTree *)G.main->nodetree.first;
}
+static FnFunction get_current_function(void)
+{
+ return FN_testing(get_node_tree());
+}
+
static void do_deformation(
FunctionDeformModifierData *fdmd,
float (*vertexCos)[3],
int numVerts)
{
- FnFunction fn = FN_testing(get_node_tree());
+ FnFunction fn = get_current_function();
// FnFunction fn = FN_get_generated_function();
FnCallable fn_call = FN_function_get_callable(fn);
BLI_assert(fn_call);
@@ -117,9 +122,12 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *UNUSED(ctx))
+static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
FunctionDeformModifierData *UNUSED(fdmd) = (FunctionDeformModifierData *)md;
+
+ FnFunction fn = get_current_function();
+ FN_function_update_dependencies(fn, ctx->node);
}
More information about the Bf-blender-cvs
mailing list