[Bf-blender-cvs] [1242de1b6d0] functions: deduplicate some code

Jacques Lucke noreply at git.blender.org
Sun Apr 28 18:57:43 CEST 2019


Commit: 1242de1b6d0cfa5196bb982726eaef55067e1a7f
Author: Jacques Lucke
Date:   Sun Apr 28 18:38:47 2019 +0200
Branches: functions
https://developer.blender.org/rB1242de1b6d0cfa5196bb982726eaef55067e1a7f

deduplicate some code

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

M	source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp

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

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 7e135762286..982135a39ae 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -315,12 +315,7 @@ class ExecuteFGraph : public TupleCallBody {
                 ctx.stack().pop();
 
                 if (state.is_done()) {
-                  for (uint output_id : m_graph->output_ids_of_node(node_id)) {
-                    if (m_output_info[output_id].is_fn_output) {
-                      uint index = m_fgraph.outputs().index(DFGraphSocket::FromOutput(output_id));
-                      fn_out.copy_in__dynamic(index, storage.output_value_ptr(output_id));
-                    }
-                  }
+                  this->copy_outputs_to_final_output_if_necessary(node_id, storage, fn_out);
                   sockets_to_compute.pop();
                 }
                 else {
@@ -344,12 +339,7 @@ class ExecuteFGraph : public TupleCallBody {
               ctx.stack().pop();
 
               if (state.is_done()) {
-                for (uint output_id : m_graph->output_ids_of_node(node_id)) {
-                  if (m_output_info[output_id].is_fn_output) {
-                    uint index = m_fgraph.outputs().index(DFGraphSocket::FromOutput(output_id));
-                    fn_out.copy_in__dynamic(index, storage.output_value_ptr(output_id));
-                  }
-                }
+                this->copy_outputs_to_final_output_if_necessary(node_id, storage, fn_out);
                 sockets_to_compute.pop();
                 lazy_states.pop();
 
@@ -395,13 +385,7 @@ class ExecuteFGraph : public TupleCallBody {
               body->call__setup_stack(body_in, body_out, ctx, source_info);
               BLI_assert(body_out.all_initialized());
 
-              for (uint output_id : m_graph->output_ids_of_node(node_id)) {
-                if (m_output_info[output_id].is_fn_output) {
-                  uint index = m_fgraph.outputs().index(DFGraphSocket::FromOutput(output_id));
-                  fn_out.copy_in__dynamic(index, storage.output_value_ptr(output_id));
-                }
-              }
-
+              this->copy_outputs_to_final_output_if_necessary(node_id, storage, fn_out);
               sockets_to_compute.pop();
             }
           }
@@ -410,6 +394,18 @@ class ExecuteFGraph : public TupleCallBody {
     }
   }
 
+  void copy_outputs_to_final_output_if_necessary(uint node_id,
+                                                 SocketValueStorage &storage,
+                                                 Tuple &fn_out) const
+  {
+    for (uint output_id : m_graph->output_ids_of_node(node_id)) {
+      if (m_output_info[output_id].is_fn_output) {
+        uint index = m_fgraph.outputs().index(DFGraphSocket::FromOutput(output_id));
+        fn_out.copy_in__dynamic(index, storage.output_value_ptr(output_id));
+      }
+    }
+  }
+
   void forward_output(uint output_id, SocketValueStorage &storage, Tuple &fn_out) const
   {
     BLI_assert(storage.is_output_initialized(output_id));



More information about the Bf-blender-cvs mailing list