diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2020-05-25 11:43:44 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2020-05-26 09:29:24 +0300 |
commit | 77fdd189e4b22d2aa2410109a1a514d21f58d865 (patch) | |
tree | 9542e07d9d946ff329038afed6c84681264b82be /source/blender/editors/space_node | |
parent | 39aa122a0e6d8ff744bec9a245b23d8e9eb2387d (diff) |
Fix T76970: Unneccessary update calls viewport
Due to recent changes clicks in the node editor would trigger a
depsgraph update resulting in too many redraws. This patch limits
the updates to when workbench shown in texture mode in any visible
screen.
There are still cases where too many updates are created. For example when
there are a Cycles render viewport and a Workbench texture viewport on the
same screen.
This fix is meant as a workaround. The actual fix should add a mechanism
to the depsgraph and the viewports should check if they need to be redrawn.
Reviewed By: Brecht van Lommel
Differential Revision: https://developer.blender.org/D7830
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 52 |
3 files changed, 58 insertions, 6 deletions
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 1d73937d762..95a37f85828 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -82,7 +82,7 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx nodeSetSelected(node, true); ntreeUpdateTree(bmain, snode->edittree); - ED_node_set_active(bmain, snode->edittree, node); + ED_node_set_active(bmain, snode->edittree, node, NULL); snode_update(snode, node); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index a82acfc4dbe..c4cec52089c 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -642,9 +642,12 @@ void snode_update(SpaceNode *snode, bNode *node) } } -void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) +void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed) { const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0; + if (r_active_texture_changed) { + *r_active_texture_changed = false; + } nodeSetActive(ntree, node); @@ -713,6 +716,9 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) } } + if (r_active_texture_changed) { + *r_active_texture_changed = true; + } ED_node_tag_update_nodetree(bmain, ntree, node); WM_main_add_notifier(NC_IMAGE, NULL); } @@ -1284,7 +1290,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) newnode = node->new_node; nodeSetSelected(node, false); - node->flag &= ~NODE_ACTIVE; + node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_TEXTURE); nodeSetSelected(newnode, true); do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode)); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index e96d03f70f4..fa0ab72c72e 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -24,6 +24,7 @@ #include <stdlib.h> #include "DNA_node_types.h" +#include "DNA_windowmanager_types.h" #include "BLI_lasso_2d.h" #include "BLI_listbase.h" @@ -36,10 +37,12 @@ #include "BKE_context.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_workspace.h" #include "ED_node.h" /* own include */ #include "ED_screen.h" #include "ED_select_utils.h" +#include "ED_view3d.h" #include "RNA_access.h" #include "RNA_define.h" @@ -57,6 +60,36 @@ #include "node_intern.h" /* own include */ +/* Function to detect if there is a visible view3d that uses workbench in texture mode. + * This function is for fixing T76970 for Blender 2.83. The actual fix should add a mechanism in + * the depsgraph that can be used by the draw engines to check if they need to be redrawn. + * + * We don't want to add these risky changes this close before releasing 2.83 without good testing + * hence this workaround. There are still cases were too many updates happen. For example when you + * have both a Cycles and workbench with textures viewport. + * */ +static bool has_workbench_in_texture_color(const wmWindowManager *wm, + const Scene *scene, + const Object *ob) +{ + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { + if (win->scene != scene) { + continue; + } + const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype == SPACE_VIEW3D) { + const View3D *v3d = area->spacedata.first; + + if (ED_view3d_has_workbench_in_texture_color(scene, ob, v3d)) { + return true; + } + } + } + } + return false; +} + /* -------------------------------------------------------------------- */ /** \name Public Node Selection API * \{ */ @@ -415,6 +448,10 @@ void node_select_single(bContext *C, bNode *node) { Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); + const Object *ob = CTX_data_active_object(C); + const Scene *scene = CTX_data_scene(C); + const wmWindowManager *wm = CTX_wm_manager(C); + bool active_texture_changed = false; bNode *tnode; for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) { @@ -424,10 +461,13 @@ void node_select_single(bContext *C, bNode *node) } nodeSetSelected(node, true); - ED_node_set_active(bmain, snode->edittree, node); + ED_node_set_active(bmain, snode->edittree, node, &active_texture_changed); ED_node_set_active_viewer_key(snode); ED_node_sort(snode->edittree); + if (active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) { + DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE); + } WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); } @@ -440,6 +480,9 @@ static int node_mouse_select(bContext *C, Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); ARegion *region = CTX_wm_region(C); + const Object *ob = CTX_data_active_object(C); + const Scene *scene = CTX_data_scene(C); + const wmWindowManager *wm = CTX_wm_manager(C); bNode *node, *tnode; bNodeSocket *sock = NULL; bNodeSocket *tsock; @@ -546,12 +589,15 @@ static int node_mouse_select(bContext *C, /* update node order */ if (ret_value != OPERATOR_CANCELLED) { + bool active_texture_changed = false; if (node != NULL && ret_value != OPERATOR_RUNNING_MODAL) { - ED_node_set_active(bmain, snode->edittree, node); + ED_node_set_active(bmain, snode->edittree, node, &active_texture_changed); } ED_node_set_active_viewer_key(snode); ED_node_sort(snode->edittree); - DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE); + if (active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) { + DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE); + } WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); } |