[Bf-blender-cvs] [4ade6cdfc09] functions: initialize ids of xnodes

Jacques Lucke noreply at git.blender.org
Tue Nov 26 17:31:46 CET 2019


Commit: 4ade6cdfc0968dbe1fc106a140c28e36fda8c33b
Author: Jacques Lucke
Date:   Tue Nov 26 15:33:38 2019 +0100
Branches: functions
https://developer.blender.org/rB4ade6cdfc0968dbe1fc106a140c28e36fda8c33b

initialize ids of xnodes

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

M	source/blender/blenkernel/BKE_inlined_node_tree.h
M	source/blender/blenkernel/intern/inlined_node_tree.cc

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

diff --git a/source/blender/blenkernel/BKE_inlined_node_tree.h b/source/blender/blenkernel/BKE_inlined_node_tree.h
index 85ce3ce579a..a32eb8462fa 100644
--- a/source/blender/blenkernel/BKE_inlined_node_tree.h
+++ b/source/blender/blenkernel/BKE_inlined_node_tree.h
@@ -22,12 +22,15 @@ class InlinedNodeTree;
 class XSocket : BLI::NonCopyable, BLI::NonMovable {
  protected:
   XNode *m_node;
+
+  /* Input and output sockets share the same id-space. */
   uint m_id;
 
   friend InlinedNodeTree;
 
  public:
   const XNode &node() const;
+  uint id() const;
 };
 
 class XInputSocket : public XSocket {
@@ -61,6 +64,7 @@ class XGroupInput : BLI::NonCopyable, BLI::NonMovable {
   const VInputSocket *m_vsocket;
   XParentNode *m_parent;
   Vector<XInputSocket *> m_linked_sockets;
+  uint m_id;
 
   friend InlinedNodeTree;
 
@@ -68,16 +72,20 @@ class XGroupInput : BLI::NonCopyable, BLI::NonMovable {
   const VInputSocket &vsocket() const;
   const XParentNode *parent() const;
   ArrayRef<const XInputSocket *> linked_sockets() const;
+  uint id() const;
 };
 
 class XNode : BLI::NonCopyable, BLI::NonMovable {
  private:
   const VNode *m_vnode;
   XParentNode *m_parent;
-  uint m_id;
+
   Vector<XInputSocket *> m_inputs;
   Vector<XOutputSocket *> m_outputs;
 
+  /* Uniquely identifies this node in the inlined node tree. */
+  uint m_id;
+
   friend InlinedNodeTree;
 
   void destruct_with_sockets();
@@ -91,18 +99,22 @@ class XNode : BLI::NonCopyable, BLI::NonMovable {
 
   const XInputSocket &input(uint index) const;
   const XOutputSocket &output(uint index) const;
+
+  uint id() const;
 };
 
 class XParentNode : BLI::NonCopyable, BLI::NonMovable {
  private:
   const VNode *m_vnode;
   XParentNode *m_parent;
+  uint m_id;
 
   friend InlinedNodeTree;
 
  public:
   const XParentNode *parent() const;
   const VNode &vnode() const;
+  uint id() const;
 };
 
 using BTreeVTreeMap = Map<bNodeTree *, std::unique_ptr<const VirtualNodeTree>>;
@@ -171,6 +183,11 @@ inline const XOutputSocket &XNode::output(uint index) const
   return *m_outputs[index];
 }
 
+inline uint XNode::id() const
+{
+  return m_id;
+}
+
 inline const XParentNode *XParentNode::parent() const
 {
   return m_parent;
@@ -181,11 +198,21 @@ inline const VNode &XParentNode::vnode() const
   return *m_vnode;
 }
 
+inline uint XParentNode::id() const
+{
+  return m_id;
+}
+
 inline const XNode &XSocket::node() const
 {
   return *m_node;
 }
 
+inline uint XSocket::id() const
+{
+  return m_id;
+}
+
 inline const VInputSocket &XInputSocket::vsocket() const
 {
   return *m_vsocket;
@@ -226,6 +253,11 @@ inline ArrayRef<const XInputSocket *> XGroupInput::linked_sockets() const
   return m_linked_sockets.as_ref();
 }
 
+inline uint XGroupInput::id() const
+{
+  return m_id;
+}
+
 }  // namespace BKE
 
 #endif /* __BKE_INLINED_NODE_TREE_H__ */
diff --git a/source/blender/blenkernel/intern/inlined_node_tree.cc b/source/blender/blenkernel/intern/inlined_node_tree.cc
index 34bb5b6c41a..4596c28641c 100644
--- a/source/blender/blenkernel/intern/inlined_node_tree.cc
+++ b/source/blender/blenkernel/intern/inlined_node_tree.cc
@@ -188,7 +188,7 @@ void InlinedNodeTree::expand_group_node(XNode &group_node,
   const VirtualNodeTree &vtree = get_vtree(vtrees, btree);
 
   XParentNode &sub_parent = *m_allocator.construct<XParentNode>().release();
-  all_parent_nodes.append(&sub_parent);
+  sub_parent.m_id = all_parent_nodes.append_and_get_index(&sub_parent);
   sub_parent.m_parent = group_node.m_parent;
   sub_parent.m_vnode = &group_vnode;
 
@@ -225,7 +225,7 @@ void InlinedNodeTree::expand_group_node(XNode &group_node,
     if (outside_interface.m_linked_sockets.size() == 0 &&
         outside_interface.m_linked_group_inputs.size() == 0) {
       XGroupInput &group_input_dummy = *m_allocator.construct<XGroupInput>().release();
-      all_group_inputs.append(&group_input_dummy);
+      group_input_dummy.m_id = all_group_inputs.append_and_get_index(&group_input_dummy);
       group_input_dummy.m_vsocket = outside_interface.m_vsocket;
       group_input_dummy.m_parent = group_node.m_parent;



More information about the Bf-blender-cvs mailing list