Fix T62348: Cycles - Viewport rendering not update on switching viewlayer
authorDalai Felinto <dfelinto@gmail.com>
Fri, 22 Mar 2019 15:45:42 +0000 (12:45 -0300)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 22 Mar 2019 15:46:39 +0000 (12:46 -0300)
It updates only the main window you edit and the non-main window
children of this main one.

Reviewers: sergey, brecht

Differential Revision: https://developer.blender.org/D4528

source/blender/editors/include/ED_render.h
source/blender/editors/render/render_update.c
source/blender/windowmanager/intern/wm_window.c

index d0deefb..fd6818d 100644 (file)
@@ -34,6 +34,7 @@ struct Render;
 struct Scene;
 struct ScrArea;
 struct bContext;
+struct bScreen;
 struct wmWindowManager;
 
 /* render_ops.c */
@@ -44,6 +45,7 @@ void ED_operatortypes_render(void);
 
 void ED_render_engine_changed(struct Main *bmain);
 void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *sa);
+void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *sc);
 
 /* Callbacks handling data update events coming from depsgraph. */
 
index d99c984..bbd73b5 100644 (file)
@@ -199,6 +199,13 @@ void ED_render_engine_changed(Main *bmain)
        }
 }
 
+void ED_render_view_layer_changed(Main *bmain, bScreen *sc)
+{
+       for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+               ED_render_engine_area_exit(bmain, sa);
+       }
+}
+
 /***************************** Updates ***********************************
  * ED_render_id_flush_update gets called from DEG_id_tag_update, to do   *
  * editor level updates when the ID changes. when these ID blocks are in *
index 89b7e53..3181ee0 100644 (file)
@@ -65,6 +65,7 @@
 #include "wm_event_system.h"
 
 #include "ED_anim_api.h"
+#include "ED_render.h"
 #include "ED_scene.h"
 #include "ED_screen.h"
 #include "ED_fileselect.h"
@@ -2210,16 +2211,17 @@ ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
 void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
 {
        BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL);
+       Main *bmain = G_MAIN;
 
-       wmWindowManager *wm = G_MAIN->wm.first;
+       wmWindowManager *wm = bmain->wm.first;
        wmWindow *win_parent = (win->parent) ? win->parent : win;
 
-       /* Set  view layer in parent and child windows. */
-       STRNCPY(win_parent->view_layer_name, view_layer->name);
-
-       for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
-               if (win_child->parent == win_parent) {
-                       STRNCPY(win_child->view_layer_name, view_layer->name);
+       /* Set view layer in parent and child windows. */
+       for (wmWindow *win_iter = wm->windows.first; win_iter; win_iter = win_iter->next) {
+               if ((win_iter == win_parent) || (win_iter->parent == win_parent)) {
+                       STRNCPY(win_iter->view_layer_name, view_layer->name);
+                       bScreen *screen = BKE_workspace_active_screen_get(win_iter->workspace_hook);
+                       ED_render_view_layer_changed(bmain, screen);
                }
        }
 }