From e869ae360ca72749d2d0c9409fa00c54708a6b6e Mon Sep 17 00:00:00 2001 From: Brady Johnston Date: Thu, 25 Sep 2025 14:47:50 +0200 Subject: [PATCH] Nodes: Reroute becomes active if singular When using Shift + RMB drag to create a reroute, the newly created reroute does not become active. If you then rename it will rename the previously active node. This PR sets the newly created reroute to be active if only one is created. If more than one is created the order is not well defined and also unclear whether it would be first or last to become active. Pull Request: https://projects.blender.org/blender/blender/pulls/146774 --- source/blender/editors/space_node/node_add.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 0eb23fcf3a8..bd06ecedd96 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -179,7 +179,10 @@ static wmOperatorStatus add_reroute_exec(bContext *C, wmOperator *op) * Further deduplication using the second map means we only have one cut per link. */ Map cuts_per_socket; + int intersection_count = 0; + LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) { + if (node_link_is_hidden_or_dimmed(region.v2d, *link)) { continue; } @@ -190,6 +193,7 @@ static wmOperatorStatus add_reroute_exec(bContext *C, wmOperator *op) RerouteCutsForSocket &from_cuts = cuts_per_socket.lookup_or_add_default(link->fromsock); from_cuts.from_node = link->fromnode; from_cuts.links.add(link, *cut); + intersection_count++; } for (const auto item : cuts_per_socket.items()) { @@ -197,6 +201,10 @@ static wmOperatorStatus add_reroute_exec(bContext *C, wmOperator *op) bNode *reroute = bke::node_add_static_node(C, ntree, NODE_REROUTE); + if (intersection_count == 1) { + bke::node_set_active(ntree, *reroute); + } + bke::node_add_link(ntree, *item.value.from_node, *item.key,