[Bf-blender-cvs] [1b6d1fb1d69] temp-geometry-nodes-evaluator-refactor: move context stacks to separate header

Jacques Lucke noreply at git.blender.org
Wed Sep 7 13:02:57 CEST 2022


Commit: 1b6d1fb1d6988e8b1e03af105f78552e0e13c5c6
Author: Jacques Lucke
Date:   Wed Sep 7 12:49:50 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB1b6d1fb1d6988e8b1e03af105f78552e0e13c5c6

move context stacks to separate header

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

A	source/blender/blenkernel/BKE_context_stack.hh
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/context_stack.cc
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh
M	source/blender/nodes/intern/geometry_nodes_log.cc
M	source/blender/nodes/intern/geometry_nodes_to_lazy_function_graph.cc

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

diff --git a/source/blender/blenkernel/BKE_context_stack.hh b/source/blender/blenkernel/BKE_context_stack.hh
new file mode 100644
index 00000000000..1415a5e21b7
--- /dev/null
+++ b/source/blender/blenkernel/BKE_context_stack.hh
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+#include "BLI_context_stack.hh"
+
+namespace blender::bke {
+
+class ModifierContextStack : public ContextStack {
+ private:
+  static constexpr const char *s_static_type = "MODIFIER";
+
+  std::string modifier_name_;
+
+ public:
+  ModifierContextStack(const ContextStack *parent, std::string modifier_name);
+
+ private:
+  void print_current_in_line(std::ostream &stream) const override;
+};
+
+class NodeGroupContextStack : public ContextStack {
+ private:
+  static constexpr const char *s_static_type = "NODE_GROUP";
+
+  std::string node_name_;
+  std::string debug_group_name_;
+
+ public:
+  NodeGroupContextStack(const ContextStack *parent,
+                        std::string node_name,
+                        std::string debug_group_name = "<unknown>");
+
+  StringRefNull node_name() const;
+
+ private:
+  void print_current_in_line(std::ostream &stream) const override;
+};
+
+}  // namespace blender::bke
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 9521da8417e..228902f5d02 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -100,6 +100,7 @@ set(SRC
   intern/colortools.c
   intern/constraint.c
   intern/context.c
+  intern/context_stack.cc
   intern/crazyspace.cc
   intern/cryptomatte.cc
   intern/curve.cc
@@ -354,6 +355,7 @@ set(SRC
   BKE_colortools.h
   BKE_constraint.h
   BKE_context.h
+  BKE_context_stack.hh
   BKE_crazyspace.h
   BKE_crazyspace.hh
   BKE_cryptomatte.h
diff --git a/source/blender/blenkernel/intern/context_stack.cc b/source/blender/blenkernel/intern/context_stack.cc
new file mode 100644
index 00000000000..3e45bebb52a
--- /dev/null
+++ b/source/blender/blenkernel/intern/context_stack.cc
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "BKE_context_stack.hh"
+
+namespace blender::bke {
+
+ModifierContextStack::ModifierContextStack(const ContextStack *parent, std::string modifier_name)
+    : ContextStack(s_static_type, parent), modifier_name_(std::move(modifier_name))
+{
+  hash_.mix_in(s_static_type, strlen(s_static_type));
+  hash_.mix_in(modifier_name_.data(), modifier_name_.size());
+}
+
+void ModifierContextStack::print_current_in_line(std::ostream &stream) const
+{
+  stream << "Modifier: " << modifier_name_;
+}
+
+NodeGroupContextStack::NodeGroupContextStack(const ContextStack *parent,
+                                             std::string node_name,
+                                             std::string debug_group_name)
+    : ContextStack(s_static_type, parent),
+      node_name_(std::move(node_name)),
+      debug_group_name_(std::move(debug_group_name))
+{
+  hash_.mix_in(s_static_type, strlen(s_static_type));
+  hash_.mix_in(node_name_.data(), node_name_.size());
+}
+
+StringRefNull NodeGroupContextStack::node_name() const
+{
+  return node_name_;
+}
+
+void NodeGroupContextStack::print_current_in_line(std::ostream &stream) const
+{
+  stream << "Node Group: " << debug_group_name_ << " \t Node Name: " << node_name_;
+}
+
+}  // namespace blender::bke
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index f6b6d217fbd..f770e766522 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -31,6 +31,7 @@
 #include "BLT_translation.h"
 
 #include "BKE_context.h"
+#include "BKE_context_stack.hh"
 #include "BKE_idtype.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
@@ -357,14 +358,14 @@ static GeoTreeLog *get_geo_tree_log(SpaceNode &snode)
     return nullptr;
   }
   GeoModifierLog &modifier_log = *static_cast<GeoModifierLog *>(nmd->runtime_eval_log);
-  context_stack_builder.push<ModifierContextStack>(nmd->modifier.name);
+  context_stack_builder.push<bke::ModifierContextStack>(nmd->modifier.name);
   Vector<const bNodeTreePath *> tree_path_vec{snode.treepath};
   if (tree_path_vec.is_empty()) {
     return nullptr;
   }
   for (const bNodeTreePath *path : tree_path_vec.as_span().drop_front(1)) {
-    context_stack_builder.push<NodeGroupContextStack>(path->node_name,
-                                                      path->nodetree->id.name + 2);
+    context_stack_builder.push<bke::NodeGroupContextStack>(path->node_name,
+                                                           path->nodetree->id.name + 2);
   }
 
   return &modifier_log.get_tree_log(context_stack_builder.hash());
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 8b7e5ca6062..c5f55c77c5e 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -5,6 +5,7 @@
 
 #include "BKE_attribute.hh"
 #include "BKE_context.h"
+#include "BKE_context_stack.hh"
 #include "BKE_curves.hh"
 #include "BKE_editmesh.h"
 #include "BKE_geometry_fields.hh"
@@ -448,14 +449,14 @@ static const ViewerNodeLog *try_find_viewer_node_log(const SpaceSpreadsheet &ssp
       static_cast<nodes::geo_eval_log::GeoModifierLog *>(nmd->runtime_eval_log);
 
   ContextStackBuilder context_stack_builder;
-  context_stack_builder.push<nodes::ModifierContextStack>(modifier_context->modifier_name);
+  context_stack_builder.push<bke::ModifierContextStack>(modifier_context->modifier_name);
   for (const SpreadsheetContext *context : context_path.as_span().drop_front(2).drop_back(1)) {
     if (context->type != SPREADSHEET_CONTEXT_NODE) {
       return nullptr;
     }
     const SpreadsheetContextNode &node_context = *reinterpret_cast<const SpreadsheetContextNode *>(
         context);
-    context_stack_builder.push<nodes::NodeGroupContextStack>(node_context.node_name);
+    context_stack_builder.push<bke::NodeGroupContextStack>(node_context.node_name);
   }
   const ContextStackHash context_hash = context_stack_builder.hash();
   nodes::geo_eval_log::GeoTreeLog &tree_log = modifier_log->get_tree_log(context_hash);
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index ab62255d0c7..4360650410e 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -36,6 +36,7 @@
 #include "DNA_windowmanager_types.h"
 
 #include "BKE_attribute_math.hh"
+#include "BKE_context_stack.hh"
 #include "BKE_customdata.h"
 #include "BKE_geometry_fields.hh"
 #include "BKE_geometry_set_instances.hh"
@@ -882,7 +883,7 @@ static void find_side_effect_nodes_for_spreadsheet(
   }
 
   blender::ContextStackBuilder context_stack_builder;
-  context_stack_builder.push<blender::nodes::ModifierContextStack>(nmd.modifier.name);
+  context_stack_builder.push<blender::bke::ModifierContextStack>(nmd.modifier.name);
 
   const Span<SpreadsheetContextNode *> nested_group_contexts =
       context_path.as_span().drop_front(2).drop_back(1).cast<SpreadsheetContextNode *>();
@@ -906,8 +907,8 @@ static void find_side_effect_nodes_for_spreadsheet(
     }
     group_node_stack.push(found_node);
     group = reinterpret_cast<const bNodeTree *>(found_node->id);
-    context_stack_builder.push<blender::nodes::NodeGroupContextStack>(node_context->node_name,
-                                                                      group->id.name + 2);
+    context_stack_builder.push<blender::bke::NodeGroupContextStack>(node_context->node_name,
+                                                                    group->id.name + 2);
   }
 
   const bNode *found_viewer_node = nullptr;
@@ -1161,7 +1162,7 @@ static GeometrySet compute_geometry(const bNodeTree &btree,
   geo_nodes_modifier_data.side_effect_nodes = &r_side_effect_nodes;
   blender::nodes::GeoNodesLFUserData user_data;
   user_data.modifier_data = &geo_nodes_modifier_data;
-  blender::nodes::ModifierContextStack modifier_context_stack{nullptr, nmd->modifier.name};
+  blender::bke::ModifierContextStack modifier_context_stack{nullptr, nmd->modifier.name};
   user_data.context_stack = &modifier_context_stack;
 
   blender::LinearAllocator<> allocator;
@@ -1681,7 +1682,7 @@ static void panel_draw(const bContext *C, Panel *panel)
   /* Draw node warnings. */
   if (nmd->runtime_eval_log != nullptr) {
     GeoModifierLog &modifier_log = *static_cast<GeoModifierLog *>(nmd->runtime_eval_log);
-    blender::nodes::ModifierContextStack context_stack{nullptr, nmd->modifier.name};
+    blender::bke::ModifierContextStack context_stack{nullptr, nmd->modifier.name};
     GeoTreeLog &tree_log = modifier_log.get_tree_log(context_stack.hash());
     tree_log.ensure_node_warnings();
     for (const NodeWarning &warning : tree_log.all_warnings) {
diff --git a/source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh b/source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh
index 3d1810f6f4b..c63f7dbb85f 100644
--- a/source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh
@@ -25,58 +25,6 @@ struct GeoNodesModifierData {
   const MultiValueMap<ContextStackHash, const lf::FunctionNode *> *side_effect_nodes;
 };
 
-class NodeGroupContextStack : public ContextStack {
- private:
-  static constexpr const char *s_static_type = "NODE_GROUP";
-
-  std::string node_name_;
-  std::string debug_group_name_;
-
- public:
-  NodeGroupContextStack(const ContextStack *parent,
-                        std::string node_name,
-                        std::string debug_group_name = "<unknown>")
-      : ContextStack(s_static_type, parent),
-        node_name_(std::move(node_name)),
-        debug_group_name_(std::move(debug_group_name))
-  {
-    hash_.mix_in(s_static_type, strlen(s_static_type));
-    hash_.mix_in(node_name_.data(), node_name_.size());
-  }
-
-  StringRefNull node_name() const
-  {
-    return 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list