diff options
author | Julian Eisel <julian@blender.org> | 2020-08-07 14:04:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-08-07 14:04:31 +0300 |
commit | 0d2d4a6d4a75ac38c41f872c88255eab70e88ab7 (patch) | |
tree | b7a7518af86dddba48e05a98b3c2be55e8804721 /source/blender/editors/space_node | |
parent | 9b416c66fb714bdfd15a481489dbf650d0f389ea (diff) | |
parent | cfc6f9eb18e701f5be601b95c45004e8cf7fbc81 (diff) |
Merge branch 'master' into temp-ui-button-type-refactortemp-ui-button-type-refactor
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 48 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_group.c | 137 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_relationships.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_templates.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_view.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 20 |
11 files changed, 162 insertions, 142 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 234ca5d5ce6..207f67aed1b 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -284,23 +284,21 @@ static int node_resize_area_default(bNode *node, int x, int y) if (BLI_rctf_isect_pt(&totr, x, y)) { return NODE_RESIZE_RIGHT; } - else { - return 0; - } + + return 0; } - else { - const float size = NODE_RESIZE_MARGIN; - rctf totr = node->totr; - int dir = 0; - if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) { - dir |= NODE_RESIZE_RIGHT; - } - if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) { - dir |= NODE_RESIZE_LEFT; - } - return dir; + const float size = NODE_RESIZE_MARGIN; + rctf totr = node->totr; + int dir = 0; + + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) { + dir |= NODE_RESIZE_RIGHT; + } + if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) { + dir |= NODE_RESIZE_LEFT; } + return dir; } /* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */ @@ -862,11 +860,13 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NISHITA) { uiItemR(layout, ptr, "sun_disc", DEFAULT_FLAGS, NULL, 0); + uiLayout *col; if (RNA_boolean_get(ptr, "sun_disc")) { - uiItemR(layout, ptr, "sun_size", DEFAULT_FLAGS, NULL, ICON_NONE); + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "sun_size", DEFAULT_FLAGS, NULL, ICON_NONE); + uiItemR(col, ptr, "sun_intensity", DEFAULT_FLAGS, NULL, ICON_NONE); } - uiLayout *col; col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "sun_elevation", DEFAULT_FLAGS, NULL, ICON_NONE); uiItemR(col, ptr, "sun_rotation", DEFAULT_FLAGS, NULL, ICON_NONE); @@ -1015,7 +1015,8 @@ static void node_shader_buts_vertex_color(uiLayout *layout, bContext *C, Pointer if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); - if (RNA_collection_length(&dataptr, "sculpt_vertex_colors")) { + if (U.experimental.use_sculpt_vertex_colors && + RNA_collection_length(&dataptr, "sculpt_vertex_colors")) { uiItemPointerR( layout, ptr, "layer_name", &dataptr, "sculpt_vertex_colors", "", ICON_GROUP_VCOL); } @@ -3575,6 +3576,8 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout break; } } + + uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, NULL, 0); } void ED_init_standard_node_socket_type(bNodeSocketType *stype) @@ -3675,9 +3678,8 @@ void draw_nodespace_back_pix(const bContext *C, y, ibuf->x, ibuf->y, - GL_RGBA, - GL_UNSIGNED_BYTE, - GL_NEAREST, + GPU_RGBA8, + false, display_buffer, snode->zoom, snode->zoom, @@ -3690,12 +3692,12 @@ void draw_nodespace_back_pix(const bContext *C, GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - ED_draw_imbuf_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); + ED_draw_imbuf_ctx(C, ibuf, x, y, false, snode->zoom, snode->zoom); GPU_blend(false); } else { - ED_draw_imbuf_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); + ED_draw_imbuf_ctx(C, ibuf, x, y, false, snode->zoom, snode->zoom); } if (cache_handle) { @@ -3833,7 +3835,7 @@ static bool node_link_bezier_handles(View2D *v2d, if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) { return 0; /* clipped */ } - else if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) { + if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) { return 0; /* clipped */ } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 95a37f85828..037fe575973 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -382,9 +382,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even RNA_struct_property_is_set(op->ptr, "name")) { return node_add_file_exec(C, op); } - else { - return WM_operator_filesel(C, op, event); - } + return WM_operator_filesel(C, op, event); } void NODE_OT_add_file(wmOperatorType *ot) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c3823d8eb27..52bd4d68649 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -97,9 +97,7 @@ static bNodeTree *node_tree_from_ID(ID *id) if (GS(id->name) == ID_NT) { return (bNodeTree *)id; } - else { - return ntreeFromID(id); - } + return ntreeFromID(id); } return NULL; @@ -217,7 +215,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) { return 0; } - else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) { + if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) { return 1; } @@ -225,7 +223,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) if (!b_active && a_active) { return 1; } - else if (!b_select && (a_active || a_select)) { + if (!b_select && (a_active || a_select)) { return 1; } @@ -949,9 +947,8 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) draw_rect.ymin, preview->xsize, preview->ysize, - GL_RGBA, - GL_UNSIGNED_BYTE, - GL_LINEAR, + GPU_RGBA8, + true, preview->rect, scale, scale, @@ -1558,15 +1555,13 @@ int node_get_resize_cursor(int directions) if (directions == 0) { return WM_CURSOR_DEFAULT; } - else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) { + if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) { return WM_CURSOR_Y_MOVE; } - else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) { + if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) { return WM_CURSOR_X_MOVE; } - else { - return WM_CURSOR_EDIT; - } + return WM_CURSOR_EDIT; } void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 11d87148713..c88b6a1b297 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -238,7 +238,12 @@ static void compo_progressjob(void *cjv, float progress) } /* only this runs inside thread */ -static void compo_startjob(void *cjv, short *stop, short *do_update, float *progress) +static void compo_startjob(void *cjv, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *progress) { CompoJob *cj = cjv; bNodeTree *ntree = cj->localtree; @@ -1692,6 +1697,8 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) } } + do_tag_update |= ED_node_is_simulation(snode); + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); @@ -1734,6 +1741,8 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) } } + do_tag_update |= ED_node_is_simulation(snode); + ntreeUpdateTree(CTX_data_main(C), snode->edittree); snode_notify(C, snode); @@ -2734,7 +2743,7 @@ static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op)) void NODE_OT_clear_viewer_border(wmOperatorType *ot) { /* identifiers */ - ot->name = "Clear Viewer Border"; + ot->name = "Clear Viewer Region"; ot->description = "Clear the boundaries for viewer operations"; ot->idname = "NODE_OT_clear_viewer_border"; diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 2617384d046..7894fade517 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -56,6 +56,7 @@ #include "UI_resources.h" #include "NOD_common.h" +#include "NOD_socket.h" #include "node_intern.h" /* own include */ static bool node_group_operator_active(bContext *C) @@ -107,13 +108,13 @@ static const char *group_node_idname(bContext *C) if (ED_node_is_shader(snode)) { return "ShaderNodeGroup"; } - else if (ED_node_is_compositor(snode)) { + if (ED_node_is_compositor(snode)) { return "CompositorNodeGroup"; } - else if (ED_node_is_texture(snode)) { + if (ED_node_is_texture(snode)) { return "TextureNodeGroup"; } - else if (ED_node_is_simulation(snode)) { + if (ED_node_is_simulation(snode)) { return "SimulationNodeGroup"; } @@ -128,9 +129,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname) if (node && STREQ(node->idname, node_idname)) { return node; } - else { - return NULL; - } + return NULL; } /* ***************** Edit Group operator ************* */ @@ -181,6 +180,26 @@ void NODE_OT_group_edit(wmOperatorType *ot) /* ******************** Ungroup operator ********************** */ +/* The given paths will be owned by the returned instance. Both pointers are allowed to point to + * the same string. */ +static AnimationBasePathChange *animation_basepath_change_new(const char *src_basepath, + const char *dst_basepath) +{ + AnimationBasePathChange *basepath_change = MEM_callocN(sizeof(*basepath_change), AT); + basepath_change->src_basepath = src_basepath; + basepath_change->dst_basepath = dst_basepath; + return basepath_change; +} + +static void animation_basepath_change_free(AnimationBasePathChange *basepath_change) +{ + if (basepath_change->src_basepath != basepath_change->dst_basepath) { + MEM_freeN((void *)basepath_change->src_basepath); + } + MEM_freeN((void *)basepath_change->dst_basepath); + MEM_freeN(basepath_change); +} + /* returns 1 if its OK */ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) { @@ -219,16 +238,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node */ + const char *old_animation_basepath = NULL; if (wgroup->adt) { PointerRNA ptr; - char *path; - RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr); - path = RNA_path_from_ID_to_struct(&ptr); - - if (path) { - BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); - } + old_animation_basepath = RNA_path_from_ID_to_struct(&ptr); } /* migrate node */ @@ -238,6 +252,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) /* ensure unique node name in the node tree */ nodeUniqueName(ntree, node); + if (wgroup->adt) { + PointerRNA ptr; + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); + const char *new_animation_basepath = RNA_path_from_ID_to_struct(&ptr); + BLI_addtail(&anim_basepaths, + animation_basepath_change_new(old_animation_basepath, new_animation_basepath)); + } + if (!node->parent) { node->locx += gnode->locx; node->locy += gnode->locy; @@ -260,7 +282,6 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) /* and copy across the animation, * note that the animation data's action can be NULL here */ if (wgroup->adt) { - LinkData *ld, *ldn = NULL; bAction *waction; /* firstly, wgroup needs to temporary dummy action @@ -268,14 +289,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) waction = wgroup->adt->action = BKE_action_copy(bmain, wgroup->adt->action); /* now perform the moving */ - BKE_animdata_separate_by_basepath(bmain, &wgroup->id, &ntree->id, &anim_basepaths); + BKE_animdata_transfer_by_basepath(bmain, &wgroup->id, &ntree->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ldn) { - ldn = ld->next; - - MEM_freeN(ld->data); - BLI_freelinkN(&anim_basepaths, ld); + LISTBASE_FOREACH_MUTABLE (AnimationBasePathChange *, basepath_change, &anim_basepaths) { + animation_basepath_change_free(basepath_change); } /* free temp action too */ @@ -460,7 +478,7 @@ static int node_group_separate_selected( path = RNA_path_from_ID_to_struct(&ptr); if (path) { - BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + BLI_addtail(&anim_basepaths, animation_basepath_change_new(path, path)); } } @@ -513,17 +531,12 @@ static int node_group_separate_selected( /* and copy across the animation, * note that the animation data's action can be NULL here */ if (ngroup->adt) { - LinkData *ld, *ldn = NULL; - /* now perform the moving */ - BKE_animdata_separate_by_basepath(bmain, &ngroup->id, &ntree->id, &anim_basepaths); + BKE_animdata_transfer_by_basepath(bmain, &ngroup->id, &ntree->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ldn) { - ldn = ld->next; - - MEM_freeN(ld->data); - BLI_freelinkN(&anim_basepaths, ld); + LISTBASE_FOREACH_MUTABLE (AnimationBasePathChange *, basepath_change, &anim_basepaths) { + animation_basepath_change_free(basepath_change); } } @@ -687,7 +700,8 @@ static bool node_group_make_test_selected(bNodeTree *ntree, return true; } -static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, float *max) +static int node_get_selected_minmax( + bNodeTree *ntree, bNode *gnode, float *min, float *max, bool use_size) { bNode *node; float loc[2]; @@ -698,6 +712,11 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, if (node_group_make_use_node(node, gnode)) { nodeToView(node, 0.0f, 0.0f, &loc[0], &loc[1]); minmax_v2v2_v2(min, max, loc); + if (use_size) { + loc[0] += node->width; + loc[1] -= node->height; + minmax_v2v2_v2(min, max, loc); + } totselect++; } } @@ -715,10 +734,10 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, Main *bmain = CTX_data_main(C); bNodeTree *ngroup = (bNodeTree *)gnode->id; bNodeLink *link, *linkn; - bNode *node, *nextn; - bNodeSocket *sock; + bNode *node, *nextn, *link_node; + bNodeSocket *sock, *link_sock; ListBase anim_basepaths = {NULL, NULL}; - float min[2], max[2], center[2]; + float min[2], max[2], real_min[2], real_max[2], center[2]; int totselect; bool expose_visible = false; bNode *input_node, *output_node; @@ -732,10 +751,12 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, nodeSetSelected(node, false); } - totselect = node_get_selected_minmax(ntree, gnode, min, max); + totselect = node_get_selected_minmax(ntree, gnode, min, max, false); add_v2_v2v2(center, min, max); mul_v2_fl(center, 0.5f); + node_get_selected_minmax(ntree, gnode, real_min, real_max, true); + /* auto-add interface for "solo" nodes */ if (totselect == 1) { expose_visible = true; @@ -756,7 +777,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, path = RNA_path_from_ID_to_struct(&ptr); if (path) { - BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + BLI_addtail(&anim_basepaths, animation_basepath_change_new(path, path)); } } @@ -776,16 +797,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, /* move animation data over */ if (ntree->adt) { - LinkData *ld, *ldn = NULL; - - BKE_animdata_separate_by_basepath(bmain, &ntree->id, &ngroup->id, &anim_basepaths); + BKE_animdata_transfer_by_basepath(bmain, &ntree->id, &ngroup->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ldn) { - ldn = ld->next; - - MEM_freeN(ld->data); - BLI_freelinkN(&anim_basepaths, ld); + LISTBASE_FOREACH_MUTABLE (AnimationBasePathChange *, basepath_change, &anim_basepaths) { + animation_basepath_change_free(basepath_change); } } @@ -794,12 +810,12 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, /* create input node */ input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT); - input_node->locx = min[0] - center[0] - offsetx; + input_node->locx = real_min[0] - center[0] - offsetx; input_node->locy = -offsety; /* create output node */ output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT); - output_node->locx = max[0] - center[0] + offsetx; + output_node->locx = real_max[0] - center[0] + offsetx * 0.25f; output_node->locy = -offsety; /* relink external sockets */ @@ -815,12 +831,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, */ nodeRemLink(ntree, link); } - else if (fromselect && toselect) { - BLI_remlink(&ntree->links, link); - BLI_addtail(&ngroup->links, link); - } - else if (toselect) { - bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock); + else if (toselect && !fromselect) { + node_socket_skip_reroutes(&ntree->links, link->tonode, link->tosock, &link_node, &link_sock); + bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock); bNodeSocket *input_sock; /* update the group node and interface node sockets, @@ -837,7 +850,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, link->tonode = gnode; link->tosock = node_group_find_input_socket(gnode, iosock->identifier); } - else if (fromselect) { + else if (fromselect && !toselect) { /* First check whether the source of this link is already connected to an output. * If yes, reuse that output instead of duplicating it. */ bool connected = false; @@ -853,8 +866,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, } if (!connected) { - bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket( - ngroup, link->fromnode, link->fromsock); + node_socket_skip_reroutes( + &ntree->links, link->fromnode, link->fromsock, &link_node, &link_sock); + bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock); bNodeSocket *output_sock; /* update the group node and interface node sockets, @@ -874,6 +888,19 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, } } + /* move internal links */ + for (link = ntree->links.first; link; link = linkn) { + int fromselect = node_group_make_use_node(link->fromnode, gnode); + int toselect = node_group_make_use_node(link->tonode, gnode); + + linkn = link->next; + + if (fromselect && toselect) { + BLI_remlink(&ntree->links, link); + BLI_addtail(&ngroup->links, link); + } + } + /* move nodes in the group to the center */ for (node = ngroup->nodes.first; node; node = node->next) { if (node_group_make_use_node(node, gnode) && !node->parent) { @@ -955,7 +982,7 @@ static bNode *node_group_make_from_selected(const bContext *C, float min[2], max[2]; int totselect; - totselect = node_get_selected_minmax(ntree, NULL, min, max); + totselect = node_get_selected_minmax(ntree, NULL, min, max, false); /* don't make empty group */ if (totselect == 0) { return NULL; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 04186c3a727..9461892360e 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -21,8 +21,7 @@ * \ingroup spnode */ -#ifndef __NODE_INTERN_H__ -#define __NODE_INTERN_H__ +#pragma once #include "BKE_node.h" #include "UI_interface.h" @@ -301,5 +300,3 @@ enum eNodeSpace_ButEvents { B_NODE_LOADIMAGE, B_NODE_SETIMAGE, }; - -#endif /* __NODE_INTERN_H__ */ diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 144e3bd3506..9110d82fb84 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -76,10 +76,9 @@ static bool ntree_check_nodes_connected_dfs(bNodeTree *ntree, bNode *from, bNode if (link->tonode == to) { return true; } - else { - if (ntree_check_nodes_connected_dfs(ntree, link->tonode, to)) { - return true; - } + + if (ntree_check_nodes_connected_dfs(ntree, link->tonode, to)) { + return true; } } } @@ -191,9 +190,7 @@ static int sort_nodes_locx(const void *a, const void *b) if (node1->locx > node2->locx) { return 1; } - else { - return 0; - } + return 0; } static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used) @@ -254,6 +251,12 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, } } + /* Always allow linking to an reroute node. The socket type of the reroute sockets might change + * after the link has been created. */ + if (node->type == NODE_REROUTE) { + return node->outputs.first; + } + return NULL; } @@ -667,6 +670,8 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) } ntree->is_updating = false; + do_tag_update |= ED_node_is_simulation(snode); + ntreeUpdateTree(bmain, ntree); snode_notify(C, snode); if (do_tag_update) { @@ -921,9 +926,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } - else { - return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; - } + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static void node_link_cancel(bContext *C, wmOperator *op) @@ -1069,6 +1072,8 @@ static int cut_links_exec(bContext *C, wmOperator *op) } } + do_tag_update |= ED_node_is_simulation(snode); + if (found) { ntreeUpdateTree(CTX_data_main(C), snode->edittree); snode_notify(C, snode); @@ -1078,9 +1083,8 @@ static int cut_links_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + + return OPERATOR_CANCELLED; } return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; @@ -1473,9 +1477,7 @@ static bool ed_node_link_conditions(ScrArea *area, if (select) { break; } - else { - select = node; - } + select = node; } } /* only one selected */ diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 06f568c80f3..90b824811d9 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -1097,9 +1097,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) if (node->type == active->type) { break; } - else { - node = NULL; - } + node = NULL; } if (node) { active = node; @@ -1184,7 +1182,7 @@ static void node_find_update_fn(const struct bContext *C, else { BLI_strncpy(name, node->name, 256); } - if (!UI_search_item_add(items, name, node, ICON_NONE, 0)) { + if (!UI_search_item_add(items, name, node, ICON_NONE, 0, 0)) { break; } } diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 87b1f662b59..4f15cec8c84 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -71,9 +71,7 @@ static bool node_link_item_compare(bNode *node, NodeLinkItem *item) if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { return (node->id == (ID *)item->ngroup); } - else { - return true; - } + return true; } static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item) diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index e879e01ecc4..ce66740dc60 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -133,9 +133,7 @@ static int node_view_all_exec(bContext *C, wmOperator *op) if (space_node_view_flag(C, snode, region, 0, smooth_viewtx)) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void NODE_OT_view_all(wmOperatorType *ot) @@ -162,9 +160,7 @@ static int node_view_selected_exec(bContext *C, wmOperator *op) if (space_node_view_flag(C, snode, region, NODE_SELECT, smooth_viewtx)) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void NODE_OT_view_selected(wmOperatorType *ot) @@ -423,7 +419,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info) * And here we've got recursion in the comments tips... */ bool ED_space_node_color_sample( - Main *bmain, SpaceNode *snode, ARegion *region, int mval[2], float r_col[3]) + Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3]) { void *lock; Image *ima; @@ -460,7 +456,7 @@ bool ED_space_node_color_sample( if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - /* IB_PROFILE_NONE is default but infact its linear */ + /* #IB_PROFILE_NONE is default but in fact its linear. */ copy_v3_v3(r_col, fp); ret = true; } diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 562aa6b078c..6d570001347 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -244,7 +244,7 @@ void snode_group_offset(SpaceNode *snode, float *x, float *y) /* ******************** default callbacks for node space ***************** */ -static SpaceLink *node_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) +static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { ARegion *region; SpaceNode *snode; @@ -641,9 +641,7 @@ static bool node_ima_drop_poll(bContext *UNUSED(C), /* rule might not work? */ return (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE)); } - else { - return WM_drag_ID(drag, ID_IM) != NULL; - } + return WM_drag_ID(drag, ID_IM) != NULL; } static bool node_mask_drop_poll(bContext *UNUSED(C), @@ -787,7 +785,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_dir_set(result, node_context_dir); return 1; } - else if (CTX_data_equals(member, "selected_nodes")) { + if (CTX_data_equals(member, "selected_nodes")) { bNode *node; if (snode->edittree) { @@ -800,7 +798,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } - else if (CTX_data_equals(member, "active_node")) { + if (CTX_data_equals(member, "active_node")) { if (snode->edittree) { bNode *node = nodeGetActive(snode->edittree); CTX_data_pointer_set(result, &snode->edittree->id, &RNA_Node, node); @@ -809,7 +807,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_POINTER); return 1; } - else if (CTX_data_equals(member, "node_previews")) { + if (CTX_data_equals(member, "node_previews")) { if (snode->nodetree) { CTX_data_pointer_set( result, &snode->nodetree->id, &RNA_NodeInstanceHash, snode->nodetree->previews); @@ -818,19 +816,19 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_POINTER); return 1; } - else if (CTX_data_equals(member, "material")) { + if (CTX_data_equals(member, "material")) { if (snode->id && GS(snode->id->name) == ID_MA) { CTX_data_id_pointer_set(result, snode->id); } return 1; } - else if (CTX_data_equals(member, "light")) { + if (CTX_data_equals(member, "light")) { if (snode->id && GS(snode->id->name) == ID_LA) { CTX_data_id_pointer_set(result, snode->id); } return 1; } - else if (CTX_data_equals(member, "world")) { + if (CTX_data_equals(member, "world")) { if (snode->id && GS(snode->id->name) == ID_WO) { CTX_data_id_pointer_set(result, snode->id); } @@ -956,7 +954,7 @@ void ED_spacetype_node(void) st->spaceid = SPACE_NODE; strncpy(st->name, "Node", BKE_ST_MAXNAME); - st->new = node_new; + st->create = node_create; st->free = node_free; st->init = node_init; st->duplicate = node_duplicate; |