Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_add.c
| Show All 35 Lines | |||||
| #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_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_texture.h" | #include "BKE_texture.h" | ||||
| #include "DEG_depsgraph_build.h" | |||||
| #include "ED_node.h" /* own include */ | #include "ED_node.h" /* own include */ | ||||
| #include "ED_render.h" | #include "ED_render.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| ▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| char name[MAX_ID_NAME - 2]; | char name[MAX_ID_NAME - 2]; | ||||
| RNA_string_get(op->ptr, "name", name); | RNA_string_get(op->ptr, "name", name); | ||||
| bNodeTree *node_group = (bNodeTree *)BKE_libblock_find_name(bmain, ID_NT, name); | bNodeTree *node_group = (bNodeTree *)BKE_libblock_find_name(bmain, ID_NT, name); | ||||
| if (!node_group) { | if (!node_group) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if ((node_group->type != ntree->type) || !nodeGroupPoll(ntree, node_group)) { | |||||
| const char *disabled_hint = NULL; | |||||
| if ((node_group->type != ntree->type) || !nodeGroupPoll(ntree, node_group, &disabled_hint)) { | |||||
| if (disabled_hint) { | |||||
| BKE_reportf(op->reports, | |||||
| RPT_ERROR, | |||||
| "Can not add node group '%s' to '%s':\n %s", | |||||
| node_group->id.name + 2, | |||||
| ntree->id.name + 2, | |||||
| disabled_hint); | |||||
| } | |||||
| else { | |||||
| BKE_reportf(op->reports, | |||||
| RPT_ERROR, | |||||
| "Can not add node group '%s' to '%s'", | |||||
| node_group->id.name + 2, | |||||
| ntree->id.name + 2); | |||||
| } | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| return node_group; | return node_group; | ||||
| } | } | ||||
| static int node_add_group_exec(bContext *C, wmOperator *op) | static int node_add_group_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | static int node_add_object_exec(bContext *C, wmOperator *op) | ||||
| nodeSetActive(ntree, object_node); | nodeSetActive(ntree, object_node); | ||||
| ntreeUpdateTree(bmain, ntree); | ntreeUpdateTree(bmain, ntree); | ||||
| snode_notify(C, snode); | snode_notify(C, snode); | ||||
| snode_dag_update(C, snode); | snode_dag_update(C, snode); | ||||
| ED_node_tag_update_nodetree(bmain, ntree, object_node); | ED_node_tag_update_nodetree(bmain, ntree, object_node); | ||||
| DEG_relations_tag_update(bmain); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| SpaceNode *snode = CTX_wm_space_node(C); | SpaceNode *snode = CTX_wm_space_node(C); | ||||
| ▲ Show 20 Lines • Show All 515 Lines • Show Last 20 Lines | |||||