[Bf-blender-cvs] [ef8775b6767] functions: allocate VTreeDataGraph on heap

Jacques Lucke noreply at git.blender.org
Wed Sep 11 11:24:49 CEST 2019


Commit: ef8775b676713a69b869f79c4172475e3658b2d0
Author: Jacques Lucke
Date:   Wed Sep 11 10:41:47 2019 +0200
Branches: functions
https://developer.blender.org/rBef8775b676713a69b869f79c4172475e3658b2d0

allocate VTreeDataGraph on heap

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

M	source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
M	source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp
M	source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
M	source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.cpp
M	source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.hpp
M	source/blender/simulations/bparticles/node_frontend.cpp

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

diff --git a/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
index 7c89320bf8d..bfc6dd3578a 100644
--- a/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
@@ -34,18 +34,18 @@ static void find_interface_sockets(VirtualNodeTree &vtree,
 
 static ValueOrError<FunctionGraph> generate_function_graph(VirtualNodeTree &vtree)
 {
-  ValueOrError<VTreeDataGraph> data_graph_or_error = generate_graph(vtree);
+  auto data_graph_or_error = generate_graph(vtree);
   if (data_graph_or_error.is_error()) {
     return data_graph_or_error.error();
   }
 
-  VTreeDataGraph data_graph = data_graph_or_error.extract_value();
+  std::unique_ptr<VTreeDataGraph> data_graph = data_graph_or_error.extract_value();
 
   SetVector<DataSocket> input_sockets;
   SetVector<DataSocket> output_sockets;
-  find_interface_sockets(vtree, data_graph, input_sockets, output_sockets);
+  find_interface_sockets(vtree, *data_graph, input_sockets, output_sockets);
 
-  return FunctionGraph(data_graph.graph(), input_sockets, output_sockets);
+  return FunctionGraph(data_graph->graph(), input_sockets, output_sockets);
 }
 
 ValueOrError<SharedFunction> generate_function(bNodeTree *btree)
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 55d1081915d..d67e897dfa1 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
@@ -69,16 +69,17 @@ static bool insert_unlinked_inputs(VTreeDataGraphBuilder &builder,
   return true;
 }
 
-ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree)
+ValueOrError<std::unique_ptr<VTreeDataGraph>> generate_graph(VirtualNodeTree &vtree)
 {
   GroupByNodeUsage inputs_grouper;
   ConstantInputsHandler inputs_inserter;
   return generate_graph(vtree, inputs_grouper, inputs_inserter);
 }
 
-ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree,
-                                            UnlinkedInputsGrouper &inputs_grouper,
-                                            UnlinkedInputsInserter &inputs_inserter)
+ValueOrError<std::unique_ptr<VTreeDataGraph>> generate_graph(
+    VirtualNodeTree &vtree,
+    UnlinkedInputsGrouper &inputs_grouper,
+    UnlinkedInputsInserter &inputs_inserter)
 {
   VTreeDataGraphBuilder builder(vtree);
 
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 d373ea9b153..3a124def569 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
@@ -21,11 +21,12 @@ class UnlinkedInputsInserter {
                       MutableArrayRef<BuilderOutputSocket *> r_new_origins) = 0;
 };
 
-ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree);
+ValueOrError<std::unique_ptr<VTreeDataGraph>> generate_graph(VirtualNodeTree &vtree);
 
-ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree,
-                                            UnlinkedInputsGrouper &inputs_grouper,
-                                            UnlinkedInputsInserter &inputs_inserter);
+ValueOrError<std::unique_ptr<VTreeDataGraph>> generate_graph(
+    VirtualNodeTree &vtree,
+    UnlinkedInputsGrouper &inputs_grouper,
+    UnlinkedInputsInserter &inputs_inserter);
 
 }  // namespace DataFlowNodes
 }  // namespace FN
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
index 69616abcf31..699dbdfc165 100644
--- a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.cpp
@@ -7,6 +7,13 @@ namespace DataFlowNodes {
 
 using BLI::Stack;
 
+VTreeDataGraph::VTreeDataGraph(VirtualNodeTree &vtree,
+                               SharedDataGraph graph,
+                               Vector<DataSocket> mapping)
+    : m_vtree(vtree), m_graph(std::move(graph)), m_socket_map(std::move(mapping))
+{
+}
+
 Vector<VirtualSocket *> VTreeDataGraph::find_placeholder_dependencies(
     ArrayRef<VirtualSocket *> vsockets)
 {
diff --git a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
index 7c97acf90da..5f2fbb6d371 100644
--- a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph.hpp
@@ -14,14 +14,12 @@ using BLI::ValueOrError;
 
 class VTreeDataGraph {
  private:
+  VirtualNodeTree &m_vtree;
   SharedDataGraph m_graph;
   Vector<DataSocket> m_socket_map;
 
  public:
-  VTreeDataGraph(SharedDataGraph graph, Vector<DataSocket> mapping)
-      : m_graph(std::move(graph)), m_socket_map(std::move(mapping))
-  {
-  }
+  VTreeDataGraph(VirtualNodeTree &vtree, SharedDataGraph graph, Vector<DataSocket> mapping);
 
   SharedDataGraph &graph()
   {
diff --git a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.cpp b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.cpp
index e96fc1b4169..f9b62c6f979 100644
--- a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.cpp
@@ -47,7 +47,7 @@ BLI_NOINLINE void VTreeDataGraphBuilder::initialize_type_by_vsocket_map()
   }
 }
 
-VTreeDataGraph VTreeDataGraphBuilder::build()
+std::unique_ptr<VTreeDataGraph> VTreeDataGraphBuilder::build()
 {
   auto data_graph = m_graph_builder.build();
 
@@ -66,7 +66,8 @@ VTreeDataGraph VTreeDataGraphBuilder::build()
     }
   }
 
-  return VTreeDataGraph(std::move(data_graph), std::move(r_socket_map));
+  auto *vtree = new VTreeDataGraph(m_vtree, std::move(data_graph), std::move(r_socket_map));
+  return std::unique_ptr<VTreeDataGraph>(vtree);
 }
 
 class NodeSource : public SourceInfo {
diff --git a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.hpp b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.hpp
index e5378b0601c..d3f957ba81d 100644
--- a/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/vtree_data_graph_builder.hpp
@@ -29,7 +29,7 @@ class VTreeDataGraphBuilder {
  public:
   VTreeDataGraphBuilder(VirtualNodeTree &vtree);
 
-  VTreeDataGraph build();
+  std::unique_ptr<VTreeDataGraph> build();
 
   Vector<BuilderSocket *> &socket_map()
   {
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index ed39912ce12..8c2cd4338f0 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -637,7 +637,7 @@ static void collect_particle_behaviors(
   if (data_graph_or_error.is_error()) {
     return;
   }
-  VTreeDataGraph vtree_data_graph = data_graph_or_error.extract_value();
+  std::unique_ptr<VTreeDataGraph> vtree_data_graph = data_graph_or_error.extract_value();
 
   StringMap<ParseNodeCallback> &parsers = get_node_parsers();
 
@@ -653,7 +653,7 @@ static void collect_particle_behaviors(
     StringRef idname = vnode->idname();
     ParseNodeCallback *callback = parsers.lookup_ptr(idname);
     if (callback != nullptr) {
-      (*callback)(collector, vtree_data_graph, world_transition, vnode);
+      (*callback)(collector, *vtree_data_graph, world_transition, vnode);
     }
   }



More information about the Bf-blender-cvs mailing list