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 (56193eccf6
).
Reviewed By: Hans Goudey
Differential Revision: http://developer.blender.org/D16163
This commit is contained in:
parent
c2c31afa92
commit
707c7de21f
Notes:
blender-bot
2023-02-14 08:45:12 +01:00
Referenced by issue #101628, new reroutes become children of existing far off frames
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue