diff options
Diffstat (limited to 'source/blender/editors/space_node/node_edit.c')
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 348 |
1 files changed, 174 insertions, 174 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index a26bdfbf037..2d1af3f4578 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -152,7 +152,7 @@ static int compo_get_recalc_flags(const bContext *C) static int compo_breakjob(void *cjv) { CompoJob *cj = cjv; - + /* without G.is_break 'ESC' wont quit - which annoys users */ return (*(cj->stop) #ifdef USE_ESC_COMPO @@ -166,7 +166,7 @@ static int compo_breakjob(void *cjv) static void compo_statsdrawjob(void *cjv, const char *UNUSED(str)) { CompoJob *cj = cjv; - + *(cj->do_update) = true; } @@ -174,7 +174,7 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str)) static void compo_redrawjob(void *cjv) { CompoJob *cj = cjv; - + *(cj->do_update) = true; } @@ -209,7 +209,7 @@ static void compo_updatejob(void *UNUSED(cjv)) static void compo_progressjob(void *cjv, float progress) { CompoJob *cj = cjv; - + *(cj->progress) = progress; } @@ -223,7 +223,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog if (scene->use_nodes == false) return; - + cj->stop = stop; cj->do_update = do_update; cj->progress = progress; @@ -388,7 +388,7 @@ void ED_node_shader_default(const bContext *C, ID *id) bNodeTree *ntree; int output_type, shader_type; float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f }, strength = 1.0f; - + ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname); switch (GS(id->name)) { @@ -435,14 +435,14 @@ void ED_node_shader_default(const bContext *C, ID *id) printf("ED_node_shader_default called on wrong ID type.\n"); return; } - + out = nodeAddStaticNode(C, ntree, output_type); out->locx = 300.0f; out->locy = 300.0f; - + in = nodeAddStaticNode(C, ntree, shader_type); in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(ntree, in); - + /* only a link from color to color */ fromsock = in->outputs.first; tosock = out->inputs.first; @@ -452,7 +452,7 @@ void ED_node_shader_default(const bContext *C, ID *id) PointerRNA sockptr; sock = in->inputs.first; RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr); - + RNA_float_set_array(&sockptr, "default_value", color); if (strength != 0.0f) { @@ -460,7 +460,7 @@ void ED_node_shader_default(const bContext *C, ID *id) RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr); RNA_float_set(&sockptr, "default_value", strength); } - + ntreeUpdateTree(CTX_data_main(C), ntree); } @@ -470,32 +470,32 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - + /* but lets check it anyway */ if (sce->nodetree) { if (G.debug & G_DEBUG) printf("error in composite initialize\n"); return; } - + sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname); - + sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; - + out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE); out->locx = 300.0f; out->locy = 400.0f; - + in = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_R_LAYERS); in->locx = 10.0f; in->locy = 400.0f; nodeSetActive(sce->nodetree, in); - + /* links from color to color */ fromsock = in->outputs.first; tosock = out->inputs.first; nodeAddLink(sce->nodetree, in, fromsock, out, tosock); - + ntreeUpdateTree(CTX_data_main(C), sce->nodetree); } @@ -505,27 +505,27 @@ void ED_node_texture_default(const bContext *C, Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - + /* but lets check it anyway */ if (tx->nodetree) { if (G.debug & G_DEBUG) printf("error in texture initialize\n"); return; } - + tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname); - + out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT); out->locx = 300.0f; out->locy = 300.0f; - + in = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_CHECKER); in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(tx->nodetree, in); - + fromsock = in->outputs.first; tosock = out->inputs.first; nodeAddLink(tx->nodetree, in, fromsock, out, tosock); - + ntreeUpdateTree(CTX_data_main(C), tx->nodetree); } @@ -536,7 +536,7 @@ void snode_set_context(const bContext *C) bNodeTreeType *treetype = ntreeTypeFind(snode->tree_idname); bNodeTree *ntree = snode->nodetree; ID *id = snode->id, *from = snode->from; - + /* check the tree type */ if (!treetype || (treetype->poll && !treetype->poll(C, treetype))) @@ -547,25 +547,25 @@ void snode_set_context(const bContext *C) */ return; } - + if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) { /* current tree does not match selected type, clear tree path */ ntree = NULL; id = NULL; from = NULL; } - + if (!(snode->flag & SNODE_PIN) || ntree == NULL) { if (treetype->get_from_context) { /* reset and update from context */ ntree = NULL; id = NULL; from = NULL; - + treetype->get_from_context(C, treetype, &ntree, &id, &from); } } - + if (snode->nodetree != ntree || snode->id != id || snode->from != from || (snode->treepath.last == NULL && ntree)) { @@ -576,12 +576,12 @@ void snode_set_context(const bContext *C) void snode_update(SpaceNode *snode, bNode *node) { bNodeTreePath *path; - + /* XXX this only updates nodes in the current node space tree path. * The function supposedly should update any potential group node linking to changed tree, * this really requires a working depsgraph ... */ - + /* update all edited group nodes */ path = snode->treepath.last; if (path) { @@ -601,38 +601,38 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0; nodeSetActive(ntree, node); - + if (node->type != NODE_GROUP) { const bool was_output = (node->flag & NODE_DO_OUTPUT) != 0; bool do_update = false; - + /* generic node group output: set node as active output */ if (node->type == NODE_GROUP_OUTPUT) { bNode *tnode; for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == NODE_GROUP_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (!was_output) do_update = 1; } - + /* tree specific activate calls */ if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - + if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE)) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == node->type) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (was_output == 0) ED_node_tag_update_nodetree(bmain, ntree, node); @@ -652,7 +652,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) for (wo = bmain->world.first; wo; wo = wo->id.next) if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) GPU_material_free(&wo->gpumaterial); - + WM_main_add_notifier(NC_IMAGE, NULL); } @@ -662,27 +662,27 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) /* make active viewer, currently only 1 supported... */ if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (was_output == 0) ED_node_tag_update_nodetree(bmain, ntree, node); - + /* addnode() doesnt link this yet... */ node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } else if (node->type == CMP_NODE_COMPOSITE) { if (was_output == 0) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; ED_node_tag_update_nodetree(bmain, ntree, node); } @@ -737,13 +737,13 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op) else RNA_string_set(op->ptr, "node", node->name); } - + if (!RNA_struct_property_is_set(op->ptr, "in_out")) RNA_enum_set(op->ptr, "in_out", SOCK_IN); - + if (!RNA_struct_property_is_set(op->ptr, "socket")) RNA_int_set(op->ptr, "socket", 0); - + return 1; } @@ -754,18 +754,18 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r char nodename[MAX_NAME]; int sockindex; int in_out; - + RNA_string_get(op->ptr, "node", nodename); node = nodeFindNodebyName(ntree, nodename); - + in_out = RNA_enum_get(op->ptr, "in_out"); - + sockindex = RNA_int_get(op->ptr, "socket"); switch (in_out) { case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; } - + if (rnode) *rnode = node; if (rsock) @@ -781,7 +781,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r static bNode *visible_node(SpaceNode *snode, const rctf *rct) { bNode *node; - + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (BLI_rctf_isect(&node->totr, rct, NULL)) break; @@ -803,13 +803,13 @@ typedef struct NodeSizeWidget { static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir) { SpaceNode *snode = CTX_wm_space_node(C); - + NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); - + op->customdata = nsw; nsw->mxstart = snode->cursor[0]; nsw->mystart = snode->cursor[1]; - + /* store old */ nsw->oldlocx = node->locx; nsw->oldlocy = node->locy; @@ -819,7 +819,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( nsw->oldheight = node->height; nsw->oldminiwidth = node->miniwidth; nsw->directions = dir; - + WM_cursor_modal_set(CTX_wm_window(C), node_get_resize_cursor(dir)); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -828,7 +828,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel)) { WM_cursor_modal_restore(CTX_wm_window(C)); - + MEM_freeN(op->customdata); op->customdata = NULL; } @@ -840,14 +840,14 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) bNode *node = nodeGetActive(snode->edittree); NodeSizeWidget *nsw = op->customdata; float mx, my, dx, dy; - + switch (event->type) { case MOUSEMOVE: - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); dx = (mx - nsw->mxstart) / UI_DPI_FAC; dy = (my - nsw->mystart) / UI_DPI_FAC; - + if (node) { /* width can use node->width or node->miniwidth (hidden nodes) */ float *pwidth; @@ -865,7 +865,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) widthmin = node->typeinfo->minwidth; } widthmax = node->typeinfo->maxwidth; - + { if (nsw->directions & NODE_RESIZE_RIGHT) { *pwidth = oldwidth + dx; @@ -873,20 +873,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + oldwidth; - + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); *pwidth = locmax - node->locx; } } - + /* height works the other way round ... */ { float heightmin = UI_DPI_FAC * node->typeinfo->minheight; float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; - + node->locy = nsw->oldlocy + dy; CLAMP(node->locy, locmin + heightmin, locmin + heightmax); node->height = node->locy - locmin; @@ -896,7 +896,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) CLAMP(node->height, heightmin, heightmax); } } - + /* XXX make callback? */ if (node->type == NODE_FRAME) { /* keep the offset symmetric around center point */ @@ -918,21 +918,21 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - + ED_region_tag_redraw(ar); break; - + case LEFTMOUSE: case MIDDLEMOUSE: case RIGHTMOUSE: - + node_resize_exit(C, op, false); ED_node_post_apply_transform(C, snode->edittree); - + return OPERATOR_FINISHED; } - + return OPERATOR_RUNNING_MODAL; } @@ -942,7 +942,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); bNode *node = nodeGetActive(snode->edittree); int dir; - + if (node) { /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], @@ -967,13 +967,13 @@ void NODE_OT_resize(wmOperatorType *ot) ot->name = "Resize Node"; ot->idname = "NODE_OT_resize"; ot->description = "Resize a node"; - + /* api callbacks */ ot->invoke = node_resize_invoke; ot->modal = node_resize_modal; ot->poll = ED_operator_node_active; ot->cancel = node_resize_cancel; - + /* flags */ ot->flag = OPTYPE_BLOCKING; } @@ -984,7 +984,7 @@ void NODE_OT_resize(wmOperatorType *ot) int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; @@ -1025,10 +1025,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so bNode *node; bNodeSocket *sock; rctf rect; - + *nodep = NULL; *sockp = NULL; - + /* check if we click in a socket */ for (node = snode->edittree->nodes.first; node; node = node->next) { @@ -1045,7 +1045,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so rect.xmin -= NODE_SOCKSIZE; } } - + if (in_out & SOCK_IN) { for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { @@ -1073,7 +1073,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } } - + return 0; } @@ -1082,9 +1082,9 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so static void node_duplicate_reparent_recursive(bNode *node) { bNode *parent; - + node->flag |= NODE_TEST; - + /* find first selected parent */ for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { @@ -1110,12 +1110,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) bool do_tag_update = false; ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + lastnode = ntree->nodes.last; for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); - + if (newnode->id) { /* simple id user adjustment, node internal functions don't touch this * but operators and readfile.c do. */ @@ -1124,12 +1124,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_node_tag_update_id(snode->id); } } - + /* make sure we don't copy new nodes again! */ if (node == lastnode) break; } - + /* copy links between selected nodes * NB: this depends on correct node->new_node and sock->new_sock pointers from above copy! */ @@ -1154,15 +1154,15 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) newlink->fromnode = link->fromnode; newlink->fromsock = link->fromsock; } - + BLI_addtail(&ntree->links, newlink); } - + /* make sure we don't copy new links again! */ if (link == lastlink) break; } - + /* clear flags for recursive depth-first iteration */ for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -1170,32 +1170,32 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) for (node = ntree->nodes.first; node; node = node->next) { if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) node_duplicate_reparent_recursive(node); - + /* only has to check old nodes */ if (node == lastnode) break; } - + /* deselect old nodes, select the copies instead */ for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; - + nodeSetSelected(node, false); node->flag &= ~NODE_ACTIVE; nodeSetSelected(newnode, true); do_tag_update |= (do_tag_update || node_connected_to_output(ntree, newnode)); } - + /* make sure we don't copy new nodes again! */ if (node == lastnode) break; } - + ntreeUpdateTree(CTX_data_main(C), snode->edittree); - + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); @@ -1210,14 +1210,14 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Nodes"; ot->description = "Duplicate selected nodes"; ot->idname = "NODE_OT_duplicate"; - + /* api callbacks */ ot->exec = node_duplicate_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes"); } @@ -1264,7 +1264,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + snode_notify(C, snode); snode_dag_update(C, snode); @@ -1273,15 +1273,15 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op)) void NODE_OT_read_viewlayers(wmOperatorType *ot) { - + ot->name = "Read View Layers"; ot->idname = "NODE_OT_read_viewlayers"; ot->description = "Read all render layers of all used scenes"; - + ot->exec = node_read_viewlayers_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1290,7 +1290,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *sce = CTX_data_scene(C); bNode *node; - + for (node = sce->nodetree->nodes.first; node; node = node->next) { if (node->id == (ID *)sce && node->need_exec) { break; @@ -1298,21 +1298,21 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) } if (node) { ViewLayer *view_layer = BLI_findlink(&sce->view_layers, node->custom1); - + if (view_layer) { PointerRNA op_ptr; - + WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); RNA_string_set(&op_ptr, "layer", view_layer->name); RNA_string_set(&op_ptr, "scene", sce->id.name + 2); - + /* to keep keypositions */ sce->r.scemode |= R_NO_FRAME_UPDATE; - + WM_operator_name_call(C, "RENDER_OT_render", WM_OP_INVOKE_DEFAULT, &op_ptr); WM_operator_properties_free(&op_ptr); - + return OPERATOR_FINISHED; } } @@ -1324,11 +1324,11 @@ void NODE_OT_render_changed(wmOperatorType *ot) ot->name = "Render Changed Layer"; ot->idname = "NODE_OT_render_changed"; ot->description = "Render current scene, when input node's layer has been changed"; - + ot->exec = node_render_changed_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1347,12 +1347,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) */ for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; - + if (node->flag & toggle_flag) tot_eq++; else @@ -1361,12 +1361,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) } for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; - + if ((tot_eq && tot_neq) || tot_eq == 0) node->flag |= toggle_flag; else @@ -1378,11 +1378,11 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) return OPERATOR_CANCELLED; - + node_flag_toggle_exec(snode, NODE_HIDDEN); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); @@ -1396,7 +1396,7 @@ void NODE_OT_hide_toggle(wmOperatorType *ot) ot->name = "Hide"; ot->description = "Toggle hiding of selected nodes"; ot->idname = "NODE_OT_hide_toggle"; - + /* callbacks */ ot->exec = node_hide_toggle_exec; ot->poll = ED_operator_node_active; @@ -1489,7 +1489,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, !hidden); @@ -1536,12 +1536,12 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node)); } } - + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + return OPERATOR_FINISHED; } @@ -1551,11 +1551,11 @@ void NODE_OT_mute_toggle(wmOperatorType *ot) ot->name = "Toggle Node Mute"; ot->description = "Toggle muting of the nodes"; ot->idname = "NODE_OT_mute_toggle"; - + /* callbacks */ ot->exec = node_mute_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1580,14 +1580,14 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) nodeFreeNode(snode->edittree, node); } } - + ntreeUpdateTree(CTX_data_main(C), snode->edittree); snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + return OPERATOR_FINISHED; } @@ -1597,11 +1597,11 @@ void NODE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete selected nodes"; ot->idname = "NODE_OT_delete"; - + /* api callbacks */ ot->exec = node_delete_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1666,7 +1666,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) next = node->next; if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); - + /* check id user here, nodeFreeNode is called for free dbase too */ if (node->id) id_us_min(node->id); @@ -1754,7 +1754,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNodeTree *ntree = NULL; bNode *node = NULL; - + if (ptr.data) { node = ptr.data; ntree = ptr.id.data; @@ -1766,12 +1766,12 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U if (!node || node->type != CMP_NODE_OUTPUT_FILE) return OPERATOR_CANCELLED; - + if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) return OPERATOR_CANCELLED; - + snode_notify(C, snode); - + return OPERATOR_FINISHED; } @@ -1781,11 +1781,11 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot) ot->name = "Remove File Node Socket"; ot->description = "Remove active input from a file output node"; ot->idname = "NODE_OT_output_file_remove_active_socket"; - + /* callbacks */ ot->exec = node_output_file_remove_active_socket_exec; ot->poll = composite_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1800,7 +1800,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) NodeImageMultiFile *nimf; bNodeSocket *sock; int direction; - + if (ptr.data) node = ptr.data; else if (snode && snode->edittree) @@ -1810,13 +1810,13 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; nimf = node->storage; - + sock = BLI_findlink(&node->inputs, nimf->active_input); if (!sock) return OPERATOR_CANCELLED; - + direction = RNA_enum_get(op->ptr, "direction"); - + if (direction == 1) { bNodeSocket *before = sock->prev; if (!before) @@ -1833,9 +1833,9 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) BLI_insertlinkafter(&node->inputs, after, sock); nimf->active_input++; } - + snode_notify(C, snode); - + return OPERATOR_FINISHED; } @@ -1846,19 +1846,19 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) {2, "DOWN", 0, "Down", ""}, { 0, NULL, 0, NULL, NULL } }; - + /* identifiers */ ot->name = "Move File Node Socket"; ot->description = "Move the active input of a file output node up or down the list"; ot->idname = "NODE_OT_output_file_move_active_socket"; - + /* callbacks */ ot->exec = node_output_file_move_active_socket_exec; ot->poll = composite_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", ""); } @@ -1869,13 +1869,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNode *node, *tnode; - + if (!ntree) return OPERATOR_CANCELLED; node = nodeGetActive(ntree); if (!node) return OPERATOR_CANCELLED; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { if (node->flag & NODE_CUSTOM_COLOR) { @@ -1934,7 +1934,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op)) for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { bNode *new_node = node->new_node; - + /* ensure valid pointers */ if (new_node->parent) { /* parent pointer must be redirected to new node or detached if parent is not copied */ @@ -2053,7 +2053,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* pasted nodes are selected */ nodeSetSelected(new_node, true); } - + /* reparent copied nodes */ for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = node->new_node; @@ -2108,9 +2108,9 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) PointerRNA ntree_ptr; bNodeSocket *sock, *tsock, *active_sock; const char *default_name; - + RNA_id_pointer_create((ID *)ntree, &ntree_ptr); - + if (in_out == SOCK_IN) { active_sock = ntree_get_active_interface_socket(&ntree->inputs); default_name = "Input"; @@ -2119,7 +2119,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) active_sock = ntree_get_active_interface_socket(&ntree->outputs); default_name = "Output"; } - + if (active_sock) { /* insert a copy of the active socket right after it */ sock = ntreeInsertSocketInterface(ntree, in_out, active_sock->idname, active_sock->next, active_sock->name); @@ -2130,7 +2130,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) /* XXX TODO define default socket type for a tree! */ sock = ntreeAddSocketInterface(ntree, in_out, "NodeSocketFloat", default_name); } - + /* deactivate sockets (has to check both lists) */ for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) tsock->flag &= ~SELECT; @@ -2138,11 +2138,11 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) tsock->flag &= ~SELECT; /* make the new socket active */ sock->flag |= SELECT; - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2152,14 +2152,14 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot) ot->name = "Add Node Tree Interface Socket"; ot->description = "Add an input or output socket to the current node tree"; ot->idname = "NODE_OT_tree_socket_add"; - + /* api callbacks */ ot->exec = ntree_socket_add_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", ""); } @@ -2170,25 +2170,25 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNodeSocket *iosock, *active_sock; - + iosock = ntree_get_active_interface_socket(&ntree->inputs); if (!iosock) iosock = ntree_get_active_interface_socket(&ntree->outputs); if (!iosock) return OPERATOR_CANCELLED; - + /* preferably next socket becomes active, otherwise try previous socket */ active_sock = (iosock->next ? iosock->next : iosock->prev); ntreeRemoveSocketInterface(ntree, iosock); - + /* set active socket */ if (active_sock) active_sock->flag |= SELECT; - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2198,11 +2198,11 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot) ot->name = "Remove Node Tree Interface Socket"; ot->description = "Remove an input or output socket to the current node tree"; ot->idname = "NODE_OT_tree_socket_remove"; - + /* api callbacks */ ot->exec = ntree_socket_remove_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2222,7 +2222,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) int direction = RNA_enum_get(op->ptr, "direction"); bNodeSocket *iosock; ListBase *lb; - + lb = &ntree->inputs; iosock = ntree_get_active_interface_socket(lb); if (!iosock) { @@ -2231,7 +2231,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) } if (!iosock) return OPERATOR_CANCELLED; - + switch (direction) { case 1: { /* up */ @@ -2254,11 +2254,11 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) break; } } - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2268,14 +2268,14 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot) ot->name = "Move Node Tree Socket"; ot->description = "Move a socket up or down in the current node tree's sockets stack"; ot->idname = "NODE_OT_tree_socket_move"; - + /* api callbacks */ ot->exec = ntree_socket_move_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "direction", move_direction_items, 1, "Direction", ""); } @@ -2322,9 +2322,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende { bool found = false; bNode *node; - + ntree->done = true; - + /* update each script that is using this text datablock */ for (node = ntree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP) { @@ -2337,7 +2337,7 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende found = true; } } - + return found; } @@ -2384,7 +2384,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) if (ntree->type == NTREE_SHADER) ntree->done = false; } FOREACH_NODETREE_END - + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { if (!ntree->done) |