[Bf-blender-cvs] [8e8049fa28a] functions: move VTreeDataGraph to separate file

Jacques Lucke noreply at git.blender.org
Wed Jul 31 18:45:10 CEST 2019


Commit: 8e8049fa28a5f6f8bbe1d3d1edc0c81a40798632
Author: Jacques Lucke
Date:   Wed Jul 31 17:18:29 2019 +0200
Branches: functions
https://developer.blender.org/rB8e8049fa28a5f6f8bbe1d3d1edc0c81a40798632

move VTreeDataGraph to separate file

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

M	source/blender/functions/CMakeLists.txt
M	source/blender/functions/FN_data_flow_nodes.hpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
A	source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp
A	source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp

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

diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 4686e1821c6..6472d3dc1a9 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -153,6 +153,8 @@ set(SRC
   frontends/data_flow_nodes/inserters/conversions.cpp
   frontends/data_flow_nodes/type_mappings.hpp
   frontends/data_flow_nodes/type_mappings.cpp
+  frontends/data_flow_nodes/vtree_data_graph.hpp
+  frontends/data_flow_nodes/vtree_data_graph.cpp
   frontends/data_flow_nodes/data_flow_nodes-c.h
   frontends/data_flow_nodes/data_flow_nodes-c.cpp
 )
diff --git a/source/blender/functions/FN_data_flow_nodes.hpp b/source/blender/functions/FN_data_flow_nodes.hpp
index aafe6478b1f..62e0063b4ea 100644
--- a/source/blender/functions/FN_data_flow_nodes.hpp
+++ b/source/blender/functions/FN_data_flow_nodes.hpp
@@ -3,3 +3,4 @@
 #include "FN_data_flow_nodes-c.h"
 #include "frontends/data_flow_nodes/function_generation.hpp"
 #include "frontends/data_flow_nodes/graph_generation.hpp"
+#include "frontends/data_flow_nodes/vtree_data_graph.hpp"
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
index e00e089f1fe..4abe2d1d62e 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
@@ -1,9 +1,9 @@
-#include "graph_generation.hpp"
-
-#include "inserters.hpp"
-
 #include "DNA_node_types.h"
+
 #include "FN_types.hpp"
+#include "FN_data_flow_nodes.hpp"
+
+#include "inserters.hpp"
 
 namespace FN {
 namespace DataFlowNodes {
@@ -140,71 +140,5 @@ ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree)
       build_mapping_for_original_sockets(builder.socket_map(), build_result.mapping));
 }
 
-VTreeDataGraph::PlaceholderDependencies VTreeDataGraph::find_placeholder_dependencies(
-    ArrayRef<VirtualSocket *> vsockets)
-{
-  Vector<DFGraphSocket> sockets;
-  for (VirtualSocket *vsocket : vsockets) {
-    DFGraphSocket socket = this->lookup_socket(vsocket);
-    sockets.append(socket);
-  }
-  return this->find_placeholder_dependencies(sockets);
-}
-
-VTreeDataGraph::PlaceholderDependencies VTreeDataGraph::find_placeholder_dependencies(
-    ArrayRef<DFGraphSocket> sockets)
-{
-  Stack<DFGraphSocket> to_be_checked = sockets;
-  Set<DFGraphSocket> found = sockets;
-  PlaceholderDependencies dependencies;
-
-  while (!to_be_checked.empty()) {
-    DFGraphSocket socket = to_be_checked.pop();
-    if (socket.is_input()) {
-      DFGraphSocket origin = m_graph->origin_of_input(socket);
-      if (found.add(origin)) {
-        to_be_checked.push(origin);
-      }
-    }
-    else {
-      uint node_id = m_graph->node_id_of_output(socket);
-      SharedFunction &fn = m_graph->function_of_node(node_id);
-      if (fn->has_body<VNodePlaceholderBody>()) {
-        auto &body = fn->body<VNodePlaceholderBody>();
-        VirtualNode *vnode = body.vnode();
-        uint data_output_index = m_graph->index_of_output(socket);
-        VirtualSocket *vsocket = this->find_data_output(vnode, data_output_index);
-        dependencies.sockets.append(socket);
-        dependencies.vsockets.append(vsocket);
-      }
-      else {
-        for (DFGraphSocket input : m_graph->inputs_of_node(node_id)) {
-          if (found.add(input)) {
-            to_be_checked.push(input);
-          }
-        }
-      }
-    }
-  }
-
-  return dependencies;
-}
-
-VirtualSocket *VTreeDataGraph::find_data_output(VirtualNode *vnode, uint index)
-{
-  uint count = 0;
-  for (uint i = 0; i < vnode->outputs().size(); i++) {
-    VirtualSocket *vsocket = vnode->output(i);
-    if (this->uses_socket(vsocket)) {
-      if (index == count) {
-        return vsocket;
-      }
-      count++;
-    }
-  }
-  BLI_assert(false);
-  return nullptr;
-}
-
 }  // namespace DataFlowNodes
 }  // namespace FN
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
index dfe4f4b621d..7f9bf7650bc 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
@@ -5,15 +5,11 @@
 #include "BKE_node_tree.hpp"
 
 #include "builder.hpp"
+#include "vtree_data_graph.hpp"
 
 namespace FN {
 namespace DataFlowNodes {
 
-using BKE::VirtualNode;
-using BKE::VirtualNodeTree;
-using BKE::VirtualSocket;
-using BLI::ValueOrError;
-
 class UnlinkedInputsHandler {
  public:
   virtual void insert(VTreeDataGraphBuilder &builder,
@@ -21,55 +17,6 @@ class UnlinkedInputsHandler {
                       ArrayRef<DFGB_Socket> r_new_origins) = 0;
 };
 
-class VTreeDataGraph {
- private:
-  SharedDataFlowGraph m_graph;
-  Map<VirtualSocket *, DFGraphSocket> m_socket_map;
-
- public:
-  VTreeDataGraph(SharedDataFlowGraph graph, Map<VirtualSocket *, DFGraphSocket> mapping)
-      : m_graph(std::move(graph)), m_socket_map(std::move(mapping))
-  {
-  }
-
-  SharedDataFlowGraph &graph()
-  {
-    return m_graph;
-  }
-
-  DFGraphSocket *lookup_socket_ptr(VirtualSocket *vsocket)
-  {
-    return m_socket_map.lookup_ptr(vsocket);
-  }
-
-  DFGraphSocket lookup_socket(VirtualSocket *vsocket)
-  {
-    return m_socket_map.lookup(vsocket);
-  }
-
-  bool uses_socket(VirtualSocket *vsocket)
-  {
-    return m_socket_map.contains(vsocket);
-  }
-
-  struct PlaceholderDependencies {
-    Vector<VirtualSocket *> vsockets;
-    Vector<DFGraphSocket> sockets;
-
-    uint size() const
-    {
-      BLI_assert(this->vsockets.size() == this->sockets.size());
-      return this->vsockets.size();
-    }
-  };
-
-  PlaceholderDependencies find_placeholder_dependencies(ArrayRef<VirtualSocket *> vsockets);
-  PlaceholderDependencies find_placeholder_dependencies(ArrayRef<DFGraphSocket> sockets);
-
- private:
-  VirtualSocket *find_data_output(VirtualNode *vnode, uint index);
-};
-
 class VNodePlaceholderBody : public FunctionBody {
  private:
   VirtualNode *m_vnode;
diff --git a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp
new file mode 100644
index 00000000000..abcbea68a40
--- /dev/null
+++ b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp
@@ -0,0 +1,77 @@
+#include "FN_data_flow_nodes.hpp"
+
+#include "BLI_stack.hpp"
+
+namespace FN {
+namespace DataFlowNodes {
+
+using BLI::Stack;
+
+VTreeDataGraph::PlaceholderDependencies VTreeDataGraph::find_placeholder_dependencies(
+    ArrayRef<VirtualSocket *> vsockets)
+{
+  Vector<DFGraphSocket> sockets;
+  for (VirtualSocket *vsocket : vsockets) {
+    DFGraphSocket socket = this->lookup_socket(vsocket);
+    sockets.append(socket);
+  }
+  return this->find_placeholder_dependencies(sockets);
+}
+
+VTreeDataGraph::PlaceholderDependencies VTreeDataGraph::find_placeholder_dependencies(
+    ArrayRef<DFGraphSocket> sockets)
+{
+  Stack<DFGraphSocket> to_be_checked = sockets;
+  Set<DFGraphSocket> found = sockets;
+  PlaceholderDependencies dependencies;
+
+  while (!to_be_checked.empty()) {
+    DFGraphSocket socket = to_be_checked.pop();
+    if (socket.is_input()) {
+      DFGraphSocket origin = m_graph->origin_of_input(socket);
+      if (found.add(origin)) {
+        to_be_checked.push(origin);
+      }
+    }
+    else {
+      uint node_id = m_graph->node_id_of_output(socket);
+      SharedFunction &fn = m_graph->function_of_node(node_id);
+      if (fn->has_body<VNodePlaceholderBody>()) {
+        auto &body = fn->body<VNodePlaceholderBody>();
+        VirtualNode *vnode = body.vnode();
+        uint data_output_index = m_graph->index_of_output(socket);
+        VirtualSocket *vsocket = this->find_data_output(vnode, data_output_index);
+        dependencies.sockets.append(socket);
+        dependencies.vsockets.append(vsocket);
+      }
+      else {
+        for (DFGraphSocket input : m_graph->inputs_of_node(node_id)) {
+          if (found.add(input)) {
+            to_be_checked.push(input);
+          }
+        }
+      }
+    }
+  }
+
+  return dependencies;
+}
+
+VirtualSocket *VTreeDataGraph::find_data_output(VirtualNode *vnode, uint index)
+{
+  uint count = 0;
+  for (uint i = 0; i < vnode->outputs().size(); i++) {
+    VirtualSocket *vsocket = vnode->output(i);
+    if (this->uses_socket(vsocket)) {
+      if (index == count) {
+        return vsocket;
+      }
+      count++;
+    }
+  }
+  BLI_assert(false);
+  return nullptr;
+}
+
+}  // namespace DataFlowNodes
+}  // namespace FN
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
similarity index 70%
copy from source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
copy to source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
index dfe4f4b621d..40662448599 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
@@ -1,11 +1,8 @@
 #pragma once
 
 #include "FN_core.hpp"
-#include "BLI_value_or_error.hpp"
 #include "BKE_node_tree.hpp"
 
-#include "builder.hpp"
-
 namespace FN {
 namespace DataFlowNodes {
 
@@ -14,13 +11,6 @@ using BKE::VirtualNodeTree;
 using BKE::VirtualSocket;
 using BLI::ValueOrError;
 
-class UnlinkedInputsHandler {
- public:
-  virtual void insert(VTreeDataGraphBuilder &builder,
-                      ArrayRef<VirtualSocket *> unlinked_inputs,
-                      ArrayRef<DFGB_Socket> r_new_origins) = 0;
-};
-
 class VTreeDataGraph {
  private:
   SharedDataFlowGraph m_graph;
@@ -70,24 +60,5 @@ class VTreeDataGraph {
   VirtualSocket *find_data_output(VirtualNode *vnode, uint index);
 };
 
-class VNodePlaceholderBody : public FunctionBody {
- private:
-  VirtualNode *m_vnode;
-
- public:
-  static const uint FUNCTION_BODY_ID = 4;
-
-  VNodePlaceholderBody(VirtualNode *vnode) : m_vnode(vnode)
-  {
-  }
-
-  VirtualNode *vnode()
-  {
-    return m_vnode;
-  }
-};
-
-ValueOrError<VTreeDataGraph> generate_graph

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list