Fix #108049: De-duplicate copied active node #108082
|
@ -42,6 +42,7 @@ struct NodeClipboardItem {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NodeClipboard {
|
struct NodeClipboard {
|
||||||
|
bNode *active_node = nullptr;
|
||||||
Vector<NodeClipboardItem> nodes;
|
Vector<NodeClipboardItem> nodes;
|
||||||
Vector<bNodeLink> links;
|
Vector<bNodeLink> links;
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ struct NodeClipboard {
|
||||||
}
|
}
|
||||||
this->nodes.clear_and_shrink();
|
this->nodes.clear_and_shrink();
|
||||||
this->links.clear_and_shrink();
|
this->links.clear_and_shrink();
|
||||||
|
this->active_node = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,6 +137,10 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator * /*op*/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bNode *active_node = nodeGetActive(&tree)) {
|
||||||
|
clipboard.active_node = node_map.lookup_default(active_node, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
for (bNode *new_node : node_map.values()) {
|
for (bNode *new_node : node_map.values()) {
|
||||||
/* Parent pointer must be redirected to new node or detached if parent is not copied. */
|
/* Parent pointer must be redirected to new node or detached if parent is not copied. */
|
||||||
if (new_node->parent) {
|
if (new_node->parent) {
|
||||||
|
@ -326,6 +332,10 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
|
||||||
update_multi_input_indices_for_removed_links(*new_node);
|
update_multi_input_indices_for_removed_links(*new_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bNode *new_active_node = node_map.lookup_default(clipboard.active_node, nullptr)) {
|
||||||
|
nodeSetActive(&tree, new_active_node);
|
||||||
|
}
|
||||||
|
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
ED_node_tree_propagate_change(C, bmain, &tree);
|
ED_node_tree_propagate_change(C, bmain, &tree);
|
||||||
/* Pasting nodes can create arbitrary new relations because nodes can reference IDs. */
|
/* Pasting nodes can create arbitrary new relations because nodes can reference IDs. */
|
||||||
|
|
|
@ -1295,6 +1295,8 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
|
||||||
Map<const bNodeSocket *, bNodeSocket *> socket_map;
|
Map<const bNodeSocket *, bNodeSocket *> socket_map;
|
||||||
Map<const ID *, ID *> duplicated_node_groups;
|
Map<const ID *, ID *> duplicated_node_groups;
|
||||||
|
|
||||||
|
bNode *active_node = nodeGetActive(ntree);
|
||||||
|
|
||||||
mod_moder marked this conversation as resolved
|
|||||||
for (bNode *node : get_selected_nodes(*ntree)) {
|
for (bNode *node : get_selected_nodes(*ntree)) {
|
||||||
bNode *new_node = bke::node_copy_with_mapping(
|
bNode *new_node = bke::node_copy_with_mapping(
|
||||||
ntree, *node, LIB_ID_COPY_DEFAULT, true, socket_map);
|
ntree, *node, LIB_ID_COPY_DEFAULT, true, socket_map);
|
||||||
|
@ -1370,6 +1372,10 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
remap_pairing(*ntree, node_map);
|
remap_pairing(*ntree, node_map);
|
||||||
|
|
||||||
|
if (bNode *new_active_node = node_map.lookup_default(active_node, nullptr)) {
|
||||||
|
nodeSetActive(ntree, new_active_node);
|
||||||
|
}
|
||||||
|
|
||||||
/* Deselect old nodes, select the copies instead. */
|
/* Deselect old nodes, select the copies instead. */
|
||||||
for (const auto item : node_map.items()) {
|
for (const auto item : node_map.items()) {
|
||||||
bNode *src_node = item.key;
|
bNode *src_node = item.key;
|
||||||
|
|
Loading…
Reference in New Issue
typo: actibe