Fix #89387: improve handling of unavailable links
A link is unavailable when any of its sockets are unavailable. Sometimes such links are in a weird inbetween state between being there and not being there at all. Generally, they should be considered to not be there, but sometimes it's still useful if they automatically come back when toggling the availability of sockets. We don't have a replacement for this functionality yet. This patch changes behavior so that unavailable links are treated as not being there at all in two places: * When deciding whether to draw an input socket value. * When deciding what to do when drawing from a socket (to create a link from it or detach existing links). This is done by simply removing unavailable links when starting to drag from a corresponding socket. This allows all of the existing logic to stay the same. Pull Request: https://projects.blender.org/blender/blender/pulls/132184
This commit is contained in:
@@ -1332,8 +1332,7 @@ static void std_node_socket_draw(
|
||||
}
|
||||
}
|
||||
|
||||
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_HIDE_VALUE) ||
|
||||
(sock->is_directly_linked() && !all_links_muted(*sock)))
|
||||
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_HIDE_VALUE) || sock->is_logically_linked())
|
||||
{
|
||||
draw_node_socket_without_value(layout, sock, text);
|
||||
return;
|
||||
|
||||
@@ -1431,12 +1431,25 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
static void remove_unavailable_links(bNodeTree &tree, bNodeSocket &socket)
|
||||
{
|
||||
tree.ensure_topology_cache();
|
||||
Vector<bNodeLink *> links = socket.directly_linked_links();
|
||||
for (bNodeLink *link : links) {
|
||||
if (!link->is_available()) {
|
||||
bke::node_remove_link(&tree, link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static std::unique_ptr<bNodeLinkDrag> node_link_init(ARegion ®ion,
|
||||
SpaceNode &snode,
|
||||
const float2 cursor,
|
||||
const bool detach)
|
||||
{
|
||||
if (bNodeSocket *sock = node_find_indicated_socket(snode, region, cursor, SOCK_OUT)) {
|
||||
remove_unavailable_links(*snode.edittree, *sock);
|
||||
snode.edittree->ensure_topology_cache();
|
||||
bNode &node = sock->owner_node();
|
||||
|
||||
std::unique_ptr<bNodeLinkDrag> nldrag = std::make_unique<bNodeLinkDrag>();
|
||||
@@ -1468,6 +1481,8 @@ static std::unique_ptr<bNodeLinkDrag> node_link_init(ARegion ®ion,
|
||||
}
|
||||
|
||||
if (bNodeSocket *sock = node_find_indicated_socket(snode, region, cursor, SOCK_IN)) {
|
||||
remove_unavailable_links(*snode.edittree, *sock);
|
||||
snode.edittree->ensure_topology_cache();
|
||||
bNode &node = sock->owner_node();
|
||||
std::unique_ptr<bNodeLinkDrag> nldrag = std::make_unique<bNodeLinkDrag>();
|
||||
nldrag->last_node_hovered_while_dragging_a_link = &node;
|
||||
|
||||
Reference in New Issue
Block a user