[Bf-blender-cvs] [7398acb56d2] functions: initial group input node

Jacques Lucke noreply at git.blender.org
Thu Nov 14 13:59:15 CET 2019


Commit: 7398acb56d2b8169e56a3c4e5b1b42ccdf4d4927
Author: Jacques Lucke
Date:   Wed Nov 13 14:55:42 2019 +0100
Branches: functions
https://developer.blender.org/rB7398acb56d2b8169e56a3c4e5b1b42ccdf4d4927

initial group input node

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

M	release/scripts/startup/nodes/base.py
A	release/scripts/startup/nodes/function_nodes/groups.py

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

diff --git a/release/scripts/startup/nodes/base.py b/release/scripts/startup/nodes/base.py
index 4412edf99dc..bcccb0d606f 100644
--- a/release/scripts/startup/nodes/base.py
+++ b/release/scripts/startup/nodes/base.py
@@ -45,11 +45,20 @@ class SocketValueStates:
                 socket.restore_state(self.input_value_storage[storage_id])
 
 
+def get_new_node_identifier():
+    import uuid
+    return str(uuid.uuid4())
+
+
 class BaseNode:
     search_terms = tuple()
     search_terms_only = False
 
+    identifier: StringProperty()
+
     def init(self, context):
+        self.identifier = get_new_node_identifier()
+
         from . sync import skip_syncing
         with skip_syncing():
             builder = self.get_node_builder()
@@ -184,6 +193,8 @@ class BaseNode:
         if self in _decl_map_per_node:
             del _decl_map_per_node[self]
 
+    def copy(self, src_node):
+        self.identifier = get_new_node_identifier()
 
 
 class BaseSocket:
diff --git a/release/scripts/startup/nodes/function_nodes/groups.py b/release/scripts/startup/nodes/function_nodes/groups.py
new file mode 100644
index 00000000000..ff3ccb68ae5
--- /dev/null
+++ b/release/scripts/startup/nodes/function_nodes/groups.py
@@ -0,0 +1,47 @@
+import bpy
+from bpy.props import *
+from .. types import type_infos
+from .. base import BaseNode
+from .. function_tree import FunctionTree
+from .. node_builder import NodeBuilder
+from .. ui import NodeSidebarPanel
+
+class GroupInputNode(BaseNode):
+    sort_index: IntProperty()
+
+class GroupDataInputNode(bpy.types.Node, GroupInputNode):
+    bl_idname = "fn_GroupDataInputNode"
+    bl_label = "Group Data Input"
+
+    data_type: StringProperty(default="Float")
+
+    def declaration(self, builder: NodeBuilder):
+        builder.fixed_output("value", "Value", self.data_type)
+
+    def draw(self, layout):
+        self.invoke_type_selection(layout, "set_type", "Select Type")
+
+    def set_type(self, data_type):
+        self.data_type = data_type
+        self.sync_tree()
+
+
+class GroupInterfacePanel(bpy.types.Panel, NodeSidebarPanel):
+    bl_idname = "FN_PT_group_interface_panel"
+    bl_label = "Group Interface"
+
+    @classmethod
+    def poll(self, context):
+        try: return isinstance(context.space_data.edit_tree, FunctionTree)
+        except: return False
+
+    def draw(self, context):
+        layout = self.layout
+        tree = context.space_data.edit_tree
+
+        input_nodes = [node for node in tree.nodes if isinstance(node, GroupDataInputNode)]
+        input_nodes = sorted(input_nodes, key=lambda node: (node.sort_index, node.name))
+
+        col = layout.column(align=True)
+        for node in input_nodes:
+            layout.label(text=node.name)



More information about the Bf-blender-cvs mailing list