Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Schempp <fabian_schempp>2021-02-03 20:02:01 +0300
committerHans Goudey <h.goudey@me.com>2021-02-03 20:03:00 +0300
commitc5514d3a2a03242ddc43f83be4bb72df7f85469f (patch)
treeb7db84dd1f3f8586d287486749b2a812acc9724e /source/blender/editors/space_node/node_relationships.c
parent894cc9c91592041a47c33300d784eac4e6412162 (diff)
Geometry Nodes: Multi-Input Sockets
Normally sockets only have one input link. This commit adds the back-end changes needed to use multiple input links per socket. Multi-input sockets can be defined with a new flag in `bNodeSocketType`. The changes necessary to make the sockets work in the geometry nodes evaluator are generalizing input socket values as a vector of values, and supporting this in the derived node tree structure. This patch should contain no functional changes. Two upcoming patches will use this system for the "Join Geometry" node and expose link picking and updated display in the UI: D10069 and D10181. Reviewed By: Jacques Lucke, Hans Goudey Differential Revision: https://developer.blender.org/D10067
Diffstat (limited to 'source/blender/editors/space_node/node_relationships.c')
-rw-r--r--source/blender/editors/space_node/node_relationships.c64
1 files changed, 47 insertions, 17 deletions
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index ee7c8bca2f8..0744adb1371 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -836,31 +836,38 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
const int num_links = nodeCountSocketLinks(snode->edittree, sock);
- int link_limit = nodeSocketLinkLimit(sock);
- if (num_links > 0 && (num_links >= link_limit || detach)) {
+ if (num_links > 0) {
/* dragged links are fixed on output side */
nldrag->in_out = SOCK_OUT;
/* detach current links and store them in the operator data */
+ bNodeLink *link_to_pick;
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
if (link->tosock == sock) {
- LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
- bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
- linkdata->data = oplink;
- *oplink = *link;
- oplink->next = oplink->prev = NULL;
- oplink->flag |= NODE_LINK_VALID;
- oplink->flag &= ~NODE_LINK_TEST;
- if (node_connected_to_output(bmain, snode->edittree, link->tonode)) {
- oplink->flag |= NODE_LINK_TEST;
+ if (sock->flag & SOCK_MULTI_INPUT) {
+ nldrag->from_multi_input_socket = true;
}
+ link_to_pick = link;
+ }
+ }
- BLI_addtail(&nldrag->links, linkdata);
- nodeRemLink(snode->edittree, link);
+ if (link_to_pick != NULL && !nldrag->from_multi_input_socket) {
+ LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
+ bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
+ linkdata->data = oplink;
+ *oplink = *link_to_pick;
+ oplink->next = oplink->prev = NULL;
+ oplink->flag |= NODE_LINK_VALID;
+ oplink->flag &= ~NODE_LINK_TEST;
+ if (node_connected_to_output(bmain, snode->edittree, link_to_pick->tonode)) {
+ oplink->flag |= NODE_LINK_TEST;
+ }
- /* send changed event to original link->tonode */
- if (node) {
- snode_update(snode, node);
- }
+ BLI_addtail(&nldrag->links, linkdata);
+ nodeRemLink(snode->edittree, link_to_pick);
+
+ /* send changed event to original link->tonode */
+ if (node) {
+ snode_update(snode, node);
}
}
}
@@ -896,6 +903,8 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
float cursor[2];
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &cursor[0], &cursor[1]);
+ RNA_float_set_array(op->ptr, "drag_start", cursor);
+ RNA_boolean_set(op->ptr, "has_link_picked", false);
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
@@ -941,7 +950,28 @@ void NODE_OT_link(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ PropertyRNA *prop;
+
RNA_def_boolean(ot->srna, "detach", false, "Detach", "Detach and redirect existing links");
+ prop = RNA_def_boolean(
+ ot->srna,
+ "has_link_picked",
+ false,
+ "Has Link Picked",
+ "The operation has placed a link. Only used for multi-input sockets, where the "
+ "link is picked later");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+ RNA_def_float_array(ot->srna,
+ "drag_start",
+ 2,
+ 0,
+ -UI_PRECISION_FLOAT_MAX,
+ UI_PRECISION_FLOAT_MAX,
+ "Drag Start",
+ "The position of the mouse cursor at the start of the operation.",
+ -UI_PRECISION_FLOAT_MAX,
+ UI_PRECISION_FLOAT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN);
}
/* ********************** Make Link operator ***************** */