[Bf-blender-cvs] [36c6cbb] object_nodes: Poll node groups based on node tree datablocks rather than node instances.

Lukas Tönne noreply at git.blender.org
Sun Dec 27 10:31:18 CET 2015


Commit: 36c6cbb9029df601c35e0b2b6f20f4998f708907
Author: Lukas Tönne
Date:   Sun Dec 27 07:28:10 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB36c6cbb9029df601c35e0b2b6f20f4998f708907

Poll node groups based on node tree datablocks rather than node instances.

There is a redundancy in the nodetree/node relationship, since each nodes
is part of exactly one node tree. This means we can test for either trees
or nodes to detect cycles, and because we usually poll for node trees
rather than nodes that would be the natural choice.

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

M	release/scripts/nodes/group_nodes.py

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

diff --git a/release/scripts/nodes/group_nodes.py b/release/scripts/nodes/group_nodes.py
index 8673bdd..6f4c1b6 100644
--- a/release/scripts/nodes/group_nodes.py
+++ b/release/scripts/nodes/group_nodes.py
@@ -270,7 +270,7 @@ def make_node_group_types(prefix, treetype, node_base):
             if index != k:
                 sockets.move(index, k)
 
-    def internal_group_nodes(ntree, visited=None):
+    def internal_group_trees(ntree, visited=None):
         if ntree is None:
             return
         if visited is None:
@@ -278,13 +278,14 @@ def make_node_group_types(prefix, treetype, node_base):
         elif ntree in visited:
             return
         visited.add(ntree)
-        
+
+        yield ntree
+
         for node in ntree.nodes:
             if not isinstance(node, GroupNode):
                 continue
-            yield node
-            for inode in internal_group_nodes(node.id, visited):
-                yield inode
+            for itree in internal_group_trees(node.id, visited):
+                yield itree
 
     class GroupNode(node_base, ObjectNode):
         '''Group of nodes that can be used in other trees'''
@@ -296,8 +297,9 @@ def make_node_group_types(prefix, treetype, node_base):
         def bl_id_property_poll(self, ntree):
             if not isinstance(ntree, treetype):
                 return False
-            for node in internal_group_nodes(ntree):
-                if node == self:
+            parent_tree = self.id_data
+            for itree in internal_group_trees(ntree):
+                if itree == parent_tree:
                     return False
             return True
 
@@ -306,8 +308,8 @@ def make_node_group_types(prefix, treetype, node_base):
                 return False
             if self.id == ntree:
                 return False
-            for node in internal_group_nodes(self.id):
-                if node.id == ntree:
+            for itree in internal_group_trees(self.id):
+                if itree == ntree:
                     return False
             return True




More information about the Bf-blender-cvs mailing list