[Bf-blender-cvs] [a1653184c0a] temp-derived-node-tree-refactor: cleanup context

Jacques Lucke noreply at git.blender.org
Wed Mar 3 16:25:21 CET 2021


Commit: a1653184c0a36a547920e4340f3328deaf88c95c
Author: Jacques Lucke
Date:   Wed Mar 3 16:24:05 2021 +0100
Branches: temp-derived-node-tree-refactor
https://developer.blender.org/rBa1653184c0a36a547920e4340f3328deaf88c95c

cleanup context

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

M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/nodes/NOD_XXX_node_tree.hh
M	source/blender/nodes/intern/xxx_node_tree.cc

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

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index e06d6199cb8..c4afa8cfc64 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -368,7 +368,7 @@ class GeometryNodesEvaluator {
       const NodeRef &linked_node = linked_socket->node();
       XXXOutputSocket linked_xxx_socket{to_socket.context, linked_socket};
       if (linked_node.is_group_input_node()) {
-        if (to_socket.context.info().is_root()) {
+        if (to_socket.context->is_root()) {
           callback(linked_xxx_socket);
         }
         else {
@@ -604,7 +604,7 @@ class GeometryNodesEvaluator {
       const NodeRef &linked_node = linked_socket->node();
       XXXInputSocket linked_xxx_socket{from_socket.context, linked_socket};
       if (linked_node.is_group_output_node()) {
-        if (from_socket.context.info().is_root()) {
+        if (from_socket.context->is_root()) {
           callback(linked_xxx_socket);
         }
         else {
@@ -1058,7 +1058,7 @@ static void fill_data_handle_map(const NodesModifierSettings &settings,
 {
   Set<ID *> used_ids;
   find_used_ids_from_settings(settings, used_ids);
-  find_used_ids_from_nodes(*tree.root_context_info().tree().btree(), used_ids);
+  find_used_ids_from_nodes(*tree.root_context().tree().btree(), used_ids);
 
   int current_handle = 0;
   for (ID *id : used_ids) {
@@ -1101,7 +1101,7 @@ static GeometrySet compute_geometry(const XXXNodeTree &tree,
 
   Map<XXXOutputSocket, GMutablePointer> group_inputs;
 
-  XXXNodeTreeContext root_context{&tree.root_context_info()};
+  const XXXNodeTreeContext *root_context = &tree.root_context();
   if (group_input_sockets.size() > 0) {
     Span<const OutputSocketRef *> remaining_input_sockets = group_input_sockets;
 
@@ -1209,7 +1209,7 @@ static void modifyGeometry(ModifierData *md,
     return;
   }
 
-  const NodeTreeRef &root_tree_ref = xxx_tree.root_context_info().tree();
+  const NodeTreeRef &root_tree_ref = xxx_tree.root_context().tree();
   Span<const NodeRef *> input_nodes = root_tree_ref.nodes_by_type("NodeGroupInput");
   Span<const NodeRef *> output_nodes = root_tree_ref.nodes_by_type("NodeGroupOutput");
 
diff --git a/source/blender/nodes/NOD_XXX_node_tree.hh b/source/blender/nodes/NOD_XXX_node_tree.hh
index 675784c858b..a9d8d99c34f 100644
--- a/source/blender/nodes/NOD_XXX_node_tree.hh
+++ b/source/blender/nodes/NOD_XXX_node_tree.hh
@@ -22,7 +22,6 @@
 
 namespace blender::nodes {
 
-class XXXNodeTreeContextInfo;
 class XXXNodeTreeContext;
 class XXXNodeTree;
 
@@ -31,47 +30,29 @@ struct XXXSocket;
 struct XXXInputSocket;
 struct XXXOutputSocket;
 
-class XXXNodeTreeContextInfo {
+class XXXNodeTreeContext {
  private:
-  XXXNodeTreeContextInfo *parent_context_info_;
+  XXXNodeTreeContext *parent_context_;
   const NodeRef *parent_node_;
   const NodeTreeRef *tree_;
-  Map<const NodeRef *, XXXNodeTreeContextInfo *> children_;
+  Map<const NodeRef *, XXXNodeTreeContext *> children_;
 
   friend XXXNodeTree;
 
  public:
   const NodeTreeRef &tree() const;
-  const XXXNodeTreeContextInfo *parent_context_info() const;
+  const XXXNodeTreeContext *parent_context() const;
   const NodeRef *parent_node() const;
-  const XXXNodeTreeContextInfo *child_context_info(const NodeRef &node) const;
+  const XXXNodeTreeContext *child_context(const NodeRef &node) const;
   bool is_root() const;
 };
 
-class XXXNodeTreeContext {
- private:
-  const XXXNodeTreeContextInfo *context_info_ = nullptr;
-
-  friend XXXNodeTree;
-
- public:
-  XXXNodeTreeContext() = default;
-  XXXNodeTreeContext(const XXXNodeTreeContextInfo *context_info);
-
-  friend bool operator==(const XXXNodeTreeContext &a, const XXXNodeTreeContext &b);
-  friend bool operator!=(const XXXNodeTreeContext &a, const XXXNodeTreeContext &b);
-
-  uint64_t hash() const;
-
-  const XXXNodeTreeContextInfo &info() const;
-};
-
 struct XXXNode {
-  XXXNodeTreeContext context;
+  const XXXNodeTreeContext *context = nullptr;
   const NodeRef *node = nullptr;
 
   XXXNode() = default;
-  XXXNode(XXXNodeTreeContext context, const NodeRef *node);
+  XXXNode(const XXXNodeTreeContext *context, const NodeRef *node);
 
   friend bool operator==(const XXXNode &a, const XXXNode &b);
   friend bool operator!=(const XXXNode &a, const XXXNode &b);
@@ -83,11 +64,11 @@ struct XXXNode {
 };
 
 struct XXXSocket {
-  XXXNodeTreeContext context;
-  const SocketRef *socket;
+  const XXXNodeTreeContext *context = nullptr;
+  const SocketRef *socket = nullptr;
 
   XXXSocket() = default;
-  XXXSocket(XXXNodeTreeContext context, const SocketRef *socket);
+  XXXSocket(const XXXNodeTreeContext *context, const SocketRef *socket);
   XXXSocket(const XXXInputSocket &input_socket);
   XXXSocket(const XXXOutputSocket &output_socket);
 
@@ -101,11 +82,11 @@ struct XXXSocket {
 };
 
 struct XXXInputSocket {
-  XXXNodeTreeContext context;
+  const XXXNodeTreeContext *context = nullptr;
   const InputSocketRef *socket = nullptr;
 
   XXXInputSocket() = default;
-  XXXInputSocket(XXXNodeTreeContext context, const InputSocketRef *socket);
+  XXXInputSocket(const XXXNodeTreeContext *context, const InputSocketRef *socket);
   explicit XXXInputSocket(const XXXSocket &base_socket);
 
   friend bool operator==(const XXXInputSocket &a, const XXXInputSocket &b);
@@ -123,11 +104,11 @@ struct XXXInputSocket {
 };
 
 struct XXXOutputSocket {
-  XXXNodeTreeContext context;
+  const XXXNodeTreeContext *context = nullptr;
   const OutputSocketRef *socket = nullptr;
 
   XXXOutputSocket() = default;
-  XXXOutputSocket(XXXNodeTreeContext context, const OutputSocketRef *socket);
+  XXXOutputSocket(const XXXNodeTreeContext *context, const OutputSocketRef *socket);
   explicit XXXOutputSocket(const XXXSocket &base_socket);
 
   friend bool operator==(const XXXOutputSocket &a, const XXXOutputSocket &b);
@@ -145,21 +126,20 @@ struct XXXOutputSocket {
 class XXXNodeTree {
  private:
   LinearAllocator<> allocator_;
-  XXXNodeTreeContextInfo *root_context_info_;
+  XXXNodeTreeContext *root_context_;
 
  public:
   XXXNodeTree(bNodeTree &btree, NodeTreeRefMap &node_tree_refs);
   ~XXXNodeTree();
 
-  const XXXNodeTreeContextInfo &root_context_info() const;
+  const XXXNodeTreeContext &root_context() const;
 
  private:
-  XXXNodeTreeContextInfo &construct_context_info_recursively(
-      XXXNodeTreeContextInfo *parent_context_info,
-      const NodeRef *parent_node,
-      bNodeTree &btree,
-      NodeTreeRefMap &node_tree_refs);
-  void destruct_context_info_recursively(XXXNodeTreeContextInfo *context_info);
+  XXXNodeTreeContext &construct_context_recursively(XXXNodeTreeContext *parent_context,
+                                                    const NodeRef *parent_node,
+                                                    bNodeTree &btree,
+                                                    NodeTreeRefMap &node_tree_refs);
+  void destruct_context_recursively(XXXNodeTreeContext *context);
 };
 
 namespace xxx_node_tree_types {
@@ -168,78 +148,47 @@ using nodes::XXXInputSocket;
 using nodes::XXXNode;
 using nodes::XXXNodeTree;
 using nodes::XXXNodeTreeContext;
-using nodes::XXXNodeTreeContextInfo;
 using nodes::XXXOutputSocket;
 using nodes::XXXSocket;
 }  // namespace xxx_node_tree_types
 
 /* --------------------------------------------------------------------
- * XXXNodeTreeContextInfo inline methods.
+ * XXXNodeTreeContext inline methods.
  */
 
-inline const NodeTreeRef &XXXNodeTreeContextInfo::tree() const
+inline const NodeTreeRef &XXXNodeTreeContext::tree() const
 {
   return *tree_;
 }
 
-inline const XXXNodeTreeContextInfo *XXXNodeTreeContextInfo::parent_context_info() const
+inline const XXXNodeTreeContext *XXXNodeTreeContext::parent_context() const
 {
-  return parent_context_info_;
+  return parent_context_;
 }
 
-inline const NodeRef *XXXNodeTreeContextInfo::parent_node() const
+inline const NodeRef *XXXNodeTreeContext::parent_node() const
 {
   return parent_node_;
 }
 
-inline const XXXNodeTreeContextInfo *XXXNodeTreeContextInfo::child_context_info(
-    const NodeRef &node) const
+inline const XXXNodeTreeContext *XXXNodeTreeContext::child_context(const NodeRef &node) const
 {
   return children_.lookup_default(&node, nullptr);
 }
 
-inline bool XXXNodeTreeContextInfo::is_root() const
-{
-  return parent_context_info_ == nullptr;
-}
-
-/* --------------------------------------------------------------------
- * XXXNodeTreeContext inline methods.
- */
-
-inline XXXNodeTreeContext::XXXNodeTreeContext(const XXXNodeTreeContextInfo *context_info)
-    : context_info_(context_info)
-{
-}
-
-inline bool operator==(const XXXNodeTreeContext &a, const XXXNodeTreeContext &b)
-{
-  return a.context_info_ == b.context_info_;
-}
-
-inline bool operator!=(const XXXNodeTreeContext &a, const XXXNodeTreeContext &b)
-{
-  return !(a == b);
-}
-
-inline uint64_t XXXNodeTreeContext::hash() const
-{
-  return DefaultHash<XXXNodeTreeContextInfo *>{}(context_info_);
-}
-
-inline const XXXNodeTreeContextInfo &XXXNodeTreeContext::info() const
+inline bool XXXNodeTreeContext::is_root() const
 {
-  return *context_info_;
+  return parent_context_ == nullptr;
 }
 
 /* --------------------------------------------------------------------
  * XXXNode inline methods.
  */
 
-inline XXXNode::XXXNode(XXXNodeTreeContext context, const NodeRef *node)
+inline XXXNode::XXXNode(const XXXNodeTreeContext *context, const NodeRef *node)
     : context(context), node(node)
 {
-  BLI_assert(node == nullptr || &node->tree() == &context.info().tree());
+  BLI_assert(node == nullptr || &node->tree() == &context->tree());
 }
 
 inline bool operator==(const XXXNode &a, const XXXNode &b)
@@ -264,17 +213,17 @@ inline const NodeRef *XXXNode::operator->() const
 
 inline uint64_t XXXNode::hash() const
 {
-  return DefaultHash<XXXNodeTreeContext>{}(context) ^ DefaultHash<const NodeRef *>{}(node);
+  return DefaultHash<const XXXNodeTreeContext *>{}(context) ^ DefaultHash<const NodeRef *>{}(node);
 }
 
 /* --------------------------------------------------------------------
  * XXXSocket inline methods.
  */
 
-inline XXXSocket::XXXSocket(XXXNodeTreeContext context, const SocketRef *socket)
+inline XXXSocket::XXX

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list