[Bf-blender-cvs] [707c7de21f0] master: Fix T101628: Correct frame node intersection in add reroute operator
Leon Schittek
noreply at git.blender.org
Thu Oct 6 07:35:41 CEST 2022
Commit: 707c7de21f0bc9a1ca4e71ef4819dafada5542ac
Author: Leon Schittek
Date: Thu Oct 6 07:32:04 2022 +0200
Branches: master
https://developer.blender.org/rB707c7de21f0bc9a1ca4e71ef4819dafada5542ac
Fix T101628: Correct frame node intersection in add reroute operator
Fix reroute nodes added via the cut link gesture being parented to the
wrong frame node.
The frame's bounds that are used for the intersection test with the
newly added reroute are in view space, but the reroute's location was
given in the node tree's coordinate space, when the add reroute
operator was recently refactored (56193eccf646).
Reviewed By: Hans Goudey
Differential Revision: http://developer.blender.org/D16163
===================================================================
M source/blender/editors/space_node/node_add.cc
===================================================================
diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc
index 943fc99a7f6..07eecff320a 100644
--- a/source/blender/editors/space_node/node_add.cc
+++ b/source/blender/editors/space_node/node_add.cc
@@ -194,15 +194,16 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
}
/* Place the new reroute at the average location of all connected cuts. */
- const float2 loc = std::accumulate(cuts.values().begin(), cuts.values().end(), float2(0)) /
- cuts.size() / UI_DPI_FAC;
- reroute->locx = loc.x;
- reroute->locy = loc.y;
+ const float2 insert_point = std::accumulate(
+ cuts.values().begin(), cuts.values().end(), float2(0)) /
+ cuts.size();
+ reroute->locx = insert_point.x / UI_DPI_FAC;
+ reroute->locy = insert_point.y / UI_DPI_FAC;
/* Attach the reroute node to frame nodes behind it. */
for (const int i : frame_nodes.index_range()) {
bNode *frame_node = frame_nodes.last(i);
- if (BLI_rctf_isect_pt_v(&frame_node->totr, loc)) {
+ if (BLI_rctf_isect_pt_v(&frame_node->totr, insert_point)) {
nodeAttachNode(reroute, frame_node);
break;
}
More information about the Bf-blender-cvs
mailing list