Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_add.cc
| Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | for (const auto item : cuts_per_socket.items()) { | ||||
| /* Reconnect links from the original output socket to the new reroute. */ | /* Reconnect links from the original output socket to the new reroute. */ | ||||
| for (bNodeLink *link : cuts.keys()) { | for (bNodeLink *link : cuts.keys()) { | ||||
| link->fromnode = reroute; | link->fromnode = reroute; | ||||
| link->fromsock = static_cast<bNodeSocket *>(reroute->outputs.first); | link->fromsock = static_cast<bNodeSocket *>(reroute->outputs.first); | ||||
| BKE_ntree_update_tag_link_changed(&ntree); | BKE_ntree_update_tag_link_changed(&ntree); | ||||
| } | } | ||||
| /* Place the new reroute at the average location of all connected cuts. */ | /* 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)) / | const float2 insert_point = std::accumulate( | ||||
| cuts.size() / UI_DPI_FAC; | cuts.values().begin(), cuts.values().end(), float2(0)) / | ||||
| reroute->locx = loc.x; | cuts.size(); | ||||
| reroute->locy = loc.y; | 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. */ | /* Attach the reroute node to frame nodes behind it. */ | ||||
| for (const int i : frame_nodes.index_range()) { | for (const int i : frame_nodes.index_range()) { | ||||
| bNode *frame_node = frame_nodes.last(i); | 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); | nodeAttachNode(reroute, frame_node); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ED_node_tree_propagate_change(C, CTX_data_main(C), &ntree); | ED_node_tree_propagate_change(C, CTX_data_main(C), &ntree); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| ▲ Show 20 Lines • Show All 635 Lines • Show Last 20 Lines | |||||