[Bf-blender-cvs] [edad5721899] functions: FunctionGraph - a graph with specified inputs and outputs

Jacques Lucke noreply at git.blender.org
Sun Feb 10 20:27:02 CET 2019


Commit: edad5721899219fd0f0fdd7950762df92e2b689c
Author: Jacques Lucke
Date:   Sun Feb 10 13:09:01 2019 +0100
Branches: functions
https://developer.blender.org/rBedad5721899219fd0f0fdd7950762df92e2b689c

FunctionGraph - a graph with specified inputs and outputs

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

M	source/blender/functions/c_wrapper.cpp
M	source/blender/functions/core/data_flow_graph.hpp
M	source/blender/functions/core/graph_to_function.cpp
M	source/blender/functions/core/graph_to_function.hpp
M	source/blender/modifiers/intern/MOD_functiondeform.c

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

diff --git a/source/blender/functions/c_wrapper.cpp b/source/blender/functions/c_wrapper.cpp
index 20be9d0f0a7..f0037b9d8aa 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -193,14 +193,16 @@ FnFunction FN_get_generated_function()
 	graph->link(npass->output(0), n1->input(1));
 	graph->link(npass->output(0), n2->input(1));
 
-	auto fn = FN::function_from_data_flow(graph,
+	graph->freeze();
+
+	auto fn = FN::function_from_data_flow(FN::FunctionGraph(graph,
 	{
 		n1->input(0),
 		npass->input(0)
 	},
 	{
 		n2->output(0)
-	});
+	}));
 
 	BLI::RefCounted<FN::Function> *fn_ref = fn.refcounter();
 	fn_ref->incref();
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index 99f67fd04c2..bf206ccdc82 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -286,4 +286,36 @@ namespace FN {
 		return this->graph()->m_links.get_linked(*this).size() > 0;
 	}
 
+	class FunctionGraph {
+	public:
+		FunctionGraph(
+			const SharedDataFlowGraph &graph,
+			const SmallSocketVector &inputs,
+			const SmallSocketVector &outputs)
+			: m_graph(graph), m_inputs(inputs), m_outputs(outputs)
+		{
+			BLI_assert(graph->frozen());
+		}
+
+		const SharedDataFlowGraph &graph() const
+		{
+			return m_graph;
+		}
+
+		const SmallSocketVector &inputs() const
+		{
+			return m_inputs;
+		}
+
+		const SmallSocketVector &outputs() const
+		{
+			return m_outputs;
+		}
+
+	private:
+		SharedDataFlowGraph m_graph;
+		SmallSocketVector m_inputs;
+		SmallSocketVector m_outputs;
+	};
+
 } /* 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 0272f823532..0479a8ecddb 100644
--- a/source/blender/functions/core/graph_to_function.cpp
+++ b/source/blender/functions/core/graph_to_function.cpp
@@ -5,16 +5,15 @@ namespace FN {
 
 	class ExecuteGraph : public TupleCallBody {
 	private:
-		const SharedDataFlowGraph m_graph;
-		const SmallSocketSetVector m_inputs;
-		const SmallSocketSetVector m_outputs;
+		SharedDataFlowGraph m_graph;
+		SmallSocketSetVector m_inputs;
+		SmallSocketSetVector m_outputs;
 
 	public:
-		ExecuteGraph(
-			const SharedDataFlowGraph &graph,
-			const SmallSocketVector &inputs,
-			const SmallSocketVector &outputs)
-			: m_graph(graph), m_inputs(inputs), m_outputs(outputs) {}
+		ExecuteGraph(const FunctionGraph &function_graph)
+			: m_graph(function_graph.graph()),
+			  m_inputs(function_graph.inputs()),
+			  m_outputs(function_graph.outputs()) {}
 
 		void call(const Tuple &fn_in, Tuple &fn_out) const override
 		{
@@ -68,14 +67,11 @@ namespace FN {
 		return Signature(inputs, outputs);
 	}
 
-	SharedFunction function_from_data_flow(
-		const SharedDataFlowGraph &graph,
-		const SmallSocketVector &inputs,
-		const SmallSocketVector &outputs)
+	SharedFunction function_from_data_flow(const FunctionGraph &function_graph)
 	{
-		Signature signature = signature_from_sockets(inputs, outputs);
+		Signature signature = signature_from_sockets(function_graph.inputs(), function_graph.outputs());
 		SharedFunction fn = SharedFunction::New(signature);
-		fn->add_body<TupleCallBody>(new ExecuteGraph(graph, inputs, outputs));
+		fn->add_body<TupleCallBody>(new ExecuteGraph(function_graph));
 		return fn;
 	}
 
diff --git a/source/blender/functions/core/graph_to_function.hpp b/source/blender/functions/core/graph_to_function.hpp
index 69784c06683..39e3c74706c 100644
--- a/source/blender/functions/core/graph_to_function.hpp
+++ b/source/blender/functions/core/graph_to_function.hpp
@@ -4,9 +4,6 @@
 
 namespace FN {
 
-	SharedFunction function_from_data_flow(
-		const SharedDataFlowGraph &graph,
-		const SmallSocketVector &inputs,
-		const SmallSocketVector &outputs);
+	SharedFunction function_from_data_flow(const FunctionGraph &graph_function);
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c b/source/blender/modifiers/intern/MOD_functiondeform.c
index 50be3583323..6609d0dbf3e 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -56,9 +56,8 @@ static void do_deformation(
         float (*vertexCos)[3],
         int numVerts)
 {
-	FN_testing((bNodeTree *)G.main->nodetree.first);
+	// FN_testing((bNodeTree *)G.main->nodetree.first);
 	FnFunction fn = FN_get_generated_function();
-	// FnFunction fn = FN_get_deform_function(fdmd->control2);
 	FnCallable fn_call = FN_function_get_callable(fn);
 	BLI_assert(fn_call);



More information about the Bf-blender-cvs mailing list