[Bf-blender-cvs] [1faf31f62d9] temp-node-tree-pages-prototype: create paired portal
Jacques Lucke
noreply at git.blender.org
Thu Mar 18 16:40:57 CET 2021
Commit: 1faf31f62d9b8205c54749a6eedafd61389fa7e6
Author: Jacques Lucke
Date: Thu Mar 18 16:16:12 2021 +0100
Branches: temp-node-tree-pages-prototype
https://developer.blender.org/rB1faf31f62d9b8205c54749a6eedafd61389fa7e6
create paired portal
===================================================================
M release/scripts/startup/bl_operators/node.py
M release/scripts/startup/bl_ui/space_node.py
M source/blender/nodes/geometry/nodes/node_geo_portals.cc
===================================================================
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 63d8a475418..56cdfa8007d 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -467,6 +467,41 @@ class NODE_OT_paste_portal(Operator):
copied_portal = None
return {'FINISHED'}
+class NODE_OT_add_portal(Operator):
+ '''Add portal'''
+ bl_idname = "node.add_portal"
+ bl_label = "Add Portal"
+
+ @classmethod
+ def poll(cls, context):
+ if context.space_data.type != 'NODE_EDITOR':
+ return False
+ ntree = context.space_data.node_tree
+ if ntree is None:
+ return False
+ return True
+
+ def invoke(self, context, event):
+ ntree = context.space_data.node_tree
+ bpy.ops.node.add_and_link_node(type="NodePortalIn")
+ portal_in = ntree.nodes[-1]
+ bpy.ops.node.add_and_link_node(type="NodePortalOut")
+ portal_out = ntree.nodes[-1]
+
+ portal_in.location.x -= 200
+ portal_out.location.x += 60
+
+ for node in ntree.nodes:
+ node.select = False
+
+ portal_in.select = True
+ portal_out.select = True
+
+ portal_out.portal_id = portal_in.portal_id
+
+ bpy.ops.node.translate_attach("INVOKE_DEFAULT")
+ return {'FINISHED'}
+
classes = (
NodeSetting,
@@ -479,4 +514,5 @@ classes = (
NODE_OT_goto_page,
NODE_OT_copy_portal,
NODE_OT_paste_portal,
+ NODE_OT_add_portal,
)
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index d8f85eef885..cda255f73a9 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -249,6 +249,8 @@ class NODE_MT_add(bpy.types.Menu):
# actual node submenus are defined by draw functions from node categories
nodeitems_utils.draw_node_categories_menu(self, context)
+ layout.operator("node.add_portal")
+
class NODE_MT_view(Menu):
bl_label = "View"
diff --git a/source/blender/nodes/geometry/nodes/node_geo_portals.cc b/source/blender/nodes/geometry/nodes/node_geo_portals.cc
index abb6b3e77f1..7c0aa39f9c1 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_portals.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_portals.cc
@@ -64,12 +64,24 @@ static void node_portal_in_init(bNodeTree *UNUSED(tree), bNode *node)
NodePortalIn *data = (NodePortalIn *)MEM_callocN(sizeof(NodePortalIn), __func__);
data->portal_id = rand();
node->storage = data;
+
+ LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
+ if (!STREQ(socket->name, "Geometry")) {
+ socket->flag |= SOCK_HIDDEN;
+ }
+ }
}
static void node_portal_out_init(bNodeTree *UNUSED(tree), bNode *node)
{
NodePortalOut *data = (NodePortalOut *)MEM_callocN(sizeof(NodePortalOut), __func__);
node->storage = data;
+
+ LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
+ if (!STREQ(socket->name, "Geometry")) {
+ socket->flag |= SOCK_HIDDEN;
+ }
+ }
}
static void node_portal_in_update(bNodeTree *UNUSED(ntree), bNode *node)
More information about the Bf-blender-cvs
mailing list