Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_edit.c
| Show All 35 Lines | |||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "RE_pipeline.h" | #include "RE_pipeline.h" | ||||
| ▲ Show 20 Lines • Show All 1,259 Lines • ▼ Show 20 Lines | static int node_duplicate_exec(bContext *C, wmOperator *op) | ||||
| LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| if (node->flag & SELECT) { | if (node->flag & SELECT) { | ||||
| /* has been set during copy above */ | /* has been set during copy above */ | ||||
| bNode *newnode = node->new_node; | bNode *newnode = node->new_node; | ||||
| nodeSetSelected(node, false); | nodeSetSelected(node, false); | ||||
| node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_TEXTURE); | node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_TEXTURE); | ||||
| nodeSetSelected(newnode, true); | nodeSetSelected(newnode, true); | ||||
| newnode->flag &= ~NODE_ACTIVE_PREVIEW; | |||||
| do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode)); | do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode)); | ||||
| } | } | ||||
| /* make sure we don't copy new nodes again! */ | /* make sure we don't copy new nodes again! */ | ||||
| if (node == lastnode) { | if (node == lastnode) { | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 858 Lines • ▼ Show 20 Lines | if (is_clipboard_valid == false) { | ||||
| BKE_report(op->reports, | BKE_report(op->reports, | ||||
| RPT_WARNING, | RPT_WARNING, | ||||
| "Some nodes references could not be restored, will be left empty"); | "Some nodes references could not be restored, will be left empty"); | ||||
| } | } | ||||
| /* make sure all clipboard nodes would be valid in the target tree */ | /* make sure all clipboard nodes would be valid in the target tree */ | ||||
| bool all_nodes_valid = true; | bool all_nodes_valid = true; | ||||
| LISTBASE_FOREACH (bNode *, node, clipboard_nodes_lb) { | LISTBASE_FOREACH (bNode *, node, clipboard_nodes_lb) { | ||||
| if (!node->typeinfo->poll_instance || !node->typeinfo->poll_instance(node, ntree)) { | const char *disabled_hint = NULL; | ||||
| if (!node->typeinfo->poll_instance || | |||||
| !node->typeinfo->poll_instance(node, ntree, &disabled_hint)) { | |||||
| all_nodes_valid = false; | all_nodes_valid = false; | ||||
| if (disabled_hint) { | |||||
| BKE_reportf(op->reports, | |||||
| RPT_ERROR, | |||||
| "Cannot add node %s into node tree %s:\n %s", | |||||
| node->name, | |||||
| ntree->id.name + 2, | |||||
| disabled_hint); | |||||
| } | |||||
| else { | |||||
| BKE_reportf(op->reports, | BKE_reportf(op->reports, | ||||
| RPT_ERROR, | RPT_ERROR, | ||||
| "Cannot add node %s into node tree %s", | "Cannot add node %s into node tree %s", | ||||
| node->name, | node->name, | ||||
| ntree->id.name + 2); | ntree->id.name + 2); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| if (!all_nodes_valid) { | if (!all_nodes_valid) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); | ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); | ||||
| /* deselect old nodes */ | /* deselect old nodes */ | ||||
| node_deselect_all(snode); | node_deselect_all(snode); | ||||
| ▲ Show 20 Lines • Show All 615 Lines • Show Last 20 Lines | |||||