[Bf-blender-cvs] [7e2f02b019b] functions: more generic function to find relevant sockets in a function graph
Jacques Lucke
noreply at git.blender.org
Mon Apr 8 18:57:18 CEST 2019
Commit: 7e2f02b019b82a7c325309e51a5d16632e96f368
Author: Jacques Lucke
Date: Mon Apr 8 18:35:58 2019 +0200
Branches: functions
https://developer.blender.org/rB7e2f02b019b82a7c325309e51a5d16632e96f368
more generic function to find relevant sockets in a function graph
===================================================================
M source/blender/functions/backends/llvm/fgraph_ir_generation.cpp
M source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
M source/blender/functions/core/data_flow_graph.cpp
M source/blender/functions/core/data_flow_graph.hpp
===================================================================
diff --git a/source/blender/functions/backends/llvm/fgraph_ir_generation.cpp b/source/blender/functions/backends/llvm/fgraph_ir_generation.cpp
index 844e47b1721..1fa20007c18 100644
--- a/source/blender/functions/backends/llvm/fgraph_ir_generation.cpp
+++ b/source/blender/functions/backends/llvm/fgraph_ir_generation.cpp
@@ -34,7 +34,7 @@ namespace FN {
continue;
}
}
- m_required_sockets = fgraph.find_required_sockets();
+ m_required_sockets = fgraph.find_used_sockets(false, true);
}
void build_ir(
diff --git a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
index 6675ae25ed3..d644de67b8e 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -87,7 +87,7 @@ namespace FN {
m_inputs(fgraph.inputs()),
m_outputs(fgraph.outputs())
{
- SocketSet required_sockets = fgraph.find_required_sockets();
+ SocketSet required_sockets = fgraph.find_used_sockets(false, true);
NodeSetVector required_nodes;
for (Socket socket : required_sockets) {
@@ -433,7 +433,7 @@ namespace FN {
void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx) const override
{
- SocketSet required_sockets = m_fgraph.find_required_sockets();
+ SocketSet required_sockets = m_fgraph.find_used_sockets(false, true);
for (Socket socket : m_fgraph.inputs()) {
required_sockets.add(socket);
}
diff --git a/source/blender/functions/core/data_flow_graph.cpp b/source/blender/functions/core/data_flow_graph.cpp
index 8f61f41b0bf..f6d41d94ede 100644
--- a/source/blender/functions/core/data_flow_graph.cpp
+++ b/source/blender/functions/core/data_flow_graph.cpp
@@ -54,34 +54,42 @@ namespace FN {
}
- SocketSet FunctionGraph::find_required_sockets() const
+ SocketSet FunctionGraph::find_used_sockets(
+ bool include_inputs,
+ bool include_outputs) const
{
SocketSet found;
SocketSet to_be_checked;
for (Socket socket : m_outputs) {
- to_be_checked.add(socket);
+ to_be_checked.add_new(socket);
}
while (to_be_checked.size() > 0) {
Socket socket = to_be_checked.pop();
- if (m_inputs.contains(socket)) {
+ if (!include_inputs && m_inputs.contains(socket)) {
continue;
}
found.add(socket);
if (socket.is_input()) {
- to_be_checked.add(socket.origin());
+ to_be_checked.add_new(socket.origin());
}
else {
for (Socket input : socket.node()->inputs()) {
- to_be_checked.add(input);
+ to_be_checked.add_new(input);
}
}
}
+ if (!include_outputs) {
+ for (Socket socket : m_outputs) {
+ found.remove(socket);
+ }
+ }
+
return found;
}
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index 40e5e39149f..304c0af0a5a 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -360,7 +360,9 @@ namespace FN {
return Signature(inputs, outputs);
}
- SocketSet find_required_sockets() const;
+ SocketSet find_used_sockets(
+ bool include_inputs,
+ bool include_outputs) const;
private:
SharedDataFlowGraph m_graph;
More information about the Bf-blender-cvs
mailing list