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 <fabianschempp@googlemail.com>2021-03-03 01:09:38 +0300
committerFabian Schempp <fabianschempp@googlemail.com>2021-03-03 01:13:59 +0300
commita4f81c683896b9ed0c7ca8411c7796f7ccfe65f9 (patch)
treebf898c9a69202c9678b90d31952b5318d43d58ac /source/blender/editors/space_node/node_relationships.c
parent6aec6568a0a3756f0b974ea3c8a00a1fb39a354b (diff)
Fix T85966: Wrong link picked when dragging multi-input socket
The socket drag operator stored the index of the last picked socket into RNA in case the mouse cursor leaves the link while dragging. This id was not unique which is why sometimes a link from an other node with the same id is picked. This patch changes the way the last picked link is stored and stores a pointer to the link directly into bNodeLinkDrag struct instead. Differential Revision: https://developer.blender.org/D10590
Diffstat (limited to 'source/blender/editors/space_node/node_relationships.c')
-rw-r--r--source/blender/editors/space_node/node_relationships.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index d6edfcce8e8..218102d2261 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -280,7 +280,7 @@ static void pick_input_link_by_link_intersect(const bContext *C,
float distance = dist_squared_to_line_segment_v2(cursor, l1, l2);
if (distance < cursor_link_touch_distance) {
link_to_pick = link;
- RNA_int_set(op->ptr, "last_picked_link_index", link->multi_input_socket_index);
+ nldrag->last_picked_multi_input_socket_link = link_to_pick;
}
}
}
@@ -290,13 +290,9 @@ static void pick_input_link_by_link_intersect(const bContext *C,
* Not essential for the basic behavior, but can make interaction feel a bit better if
* the mouse moves to the right and loses the "selection." */
if (!link_to_pick) {
- int last_picked_link_index = RNA_int_get(op->ptr, "last_picked_link_index");
- if (last_picked_link_index > -1) {
- LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
- if (link->multi_input_socket_index == last_picked_link_index) {
- link_to_pick = link;
- }
- }
+ bNodeLink *last_picked_link = nldrag->last_picked_multi_input_socket_link;
+ if (last_picked_link) {
+ link_to_pick = last_picked_link;
}
}
@@ -1032,13 +1028,14 @@ 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_int_set(op->ptr, "last_picked_link_index", -1);
RNA_boolean_set(op->ptr, "has_link_picked", false);
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
bNodeLinkDrag *nldrag = node_link_init(bmain, snode, cursor, detach);
+ nldrag->last_picked_multi_input_socket_link = NULL;
+
if (nldrag) {
op->customdata = nldrag;
BLI_addtail(&snode->runtime->linkdrag, nldrag);
@@ -1102,15 +1099,6 @@ void NODE_OT_link(wmOperatorType *ot)
-UI_PRECISION_FLOAT_MAX,
UI_PRECISION_FLOAT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
- RNA_def_int(ot->srna,
- "last_picked_link_index",
- -1,
- -1,
- 4095,
- "Last Picked Link Index",
- "The index of the last picked link on a multi-input socket",
- -1,
- 4095);
RNA_def_property_flag(prop, PROP_HIDDEN);
}