[Bf-blender-cvs] [37ac434] object_nodes: Make node groups work by linking proxy nodes to the external sockets of the parent node graph.
Lukas Tönne
noreply at git.blender.org
Sun Dec 6 13:44:46 CET 2015
Commit: 37ac4345779cbb4c2e6eff756de7eda155993397
Author: Lukas Tönne
Date: Sun Dec 6 13:43:32 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB37ac4345779cbb4c2e6eff756de7eda155993397
Make node groups work by linking proxy nodes to the external sockets of the parent node graph.
===================================================================
M release/scripts/nodes/group_nodes.py
M release/scripts/nodes/node_compiler.py
===================================================================
diff --git a/release/scripts/nodes/group_nodes.py b/release/scripts/nodes/group_nodes.py
index 61cd500..d69bd92 100644
--- a/release/scripts/nodes/group_nodes.py
+++ b/release/scripts/nodes/group_nodes.py
@@ -312,8 +312,8 @@ def make_node_group_types(prefix, treetype, node_base):
self.is_updating_nodegroup = False
def compile(self, compiler):
- # TODO
- pass
+ if self.id is not None:
+ self.id.compile_nodes(compiler)
class GroupInputNode(node_base, ObjectNode):
'''Inputs of the node group inside the tree'''
@@ -332,8 +332,11 @@ def make_node_group_types(prefix, treetype, node_base):
pass
def compile(self, compiler):
- # TODO
- pass
+ gtree = self.id_data
+ for i, item in enumerate(gtree.inputs):
+ proxy = compiler.add_proxy(item.base_type)
+ compiler.map_output(i, proxy.outputs[0])
+ compiler.map_input_external(i, proxy.inputs[0])
class GroupOutputNode(node_base, ObjectNode):
'''Outputs of the node group inside the tree'''
@@ -352,8 +355,11 @@ def make_node_group_types(prefix, treetype, node_base):
pass
def compile(self, compiler):
- # TODO
- pass
+ gtree = self.id_data
+ for i, item in enumerate(gtree.outputs):
+ proxy = compiler.add_proxy(item.base_type)
+ compiler.map_input(i, proxy.inputs[0])
+ compiler.map_output_external(i, proxy.outputs[0])
make_node_group_interface(prefix, treetype, tree_items_update)
diff --git a/release/scripts/nodes/node_compiler.py b/release/scripts/nodes/node_compiler.py
index c306f7a..0584670 100644
--- a/release/scripts/nodes/node_compiler.py
+++ b/release/scripts/nodes/node_compiler.py
@@ -116,7 +116,7 @@ class NodeCompiler:
bnode_inputs = StringDict()
for binput in bnode.inputs:
proxy = self.add_proxy(socket_type_to_bvm(binput))
- bnode_inputs[binput.identifier] = proxy.outputs[0]
+ bnode_inputs[binput.identifier] = proxy
input_map[(bnode, binput)] = proxy.inputs[0]
if hasattr(binput, "default_value"):
@@ -125,7 +125,7 @@ class NodeCompiler:
bnode_outputs = StringDict()
for boutput in bnode.outputs:
proxy = self.add_proxy(socket_type_to_bvm(boutput))
- bnode_outputs[boutput.identifier] = proxy.inputs[0]
+ bnode_outputs[boutput.identifier] = proxy
output_map[(bnode, boutput)] = proxy.outputs[0]
self.bnode_stack.append((bnode, bnode_inputs, bnode_outputs))
@@ -160,13 +160,29 @@ class NodeCompiler:
bnode, bnode_inputs, bnode_outputs = self.bnode_stack[-1]
if key not in bnode_inputs:
raise KeyError("Input %r not found in node %r" % (key, bnode))
- self.link(bnode_inputs[key], socket)
+ self.link(bnode_inputs[key].outputs[0], socket)
def map_output(self, key, socket):
bnode, bnode_inputs, bnode_outputs = self.bnode_stack[-1]
if key not in bnode_outputs:
raise KeyError("Output %r not found in node %r" % (key, bnode))
- self.link(socket, bnode_outputs[key])
+ self.link(socket, bnode_outputs[key].inputs[0])
+
+ def map_input_external(self, key, socket):
+ if len(self.bnode_stack) < 2:
+ return
+ bnode, bnode_inputs, bnode_outputs = self.bnode_stack[-2]
+ if key not in bnode_inputs:
+ raise KeyError("Input %r not found in node %r" % (key, bnode))
+ self.link(bnode_inputs[key].outputs[0], socket)
+
+ def map_output_external(self, key, socket):
+ if len(self.bnode_stack) < 2:
+ return
+ bnode, bnode_inputs, bnode_outputs = self.bnode_stack[-2]
+ if key not in bnode_outputs:
+ raise KeyError("Output %r not found in node %r" % (key, bnode))
+ self.link(socket, bnode_outputs[key].inputs[0])
###############################################################################
More information about the Bf-blender-cvs
mailing list