diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-28 19:05:52 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 13:01:08 +0300 |
commit | a6b6689c0ab769bfdf4db932e4afd75ac0d42e10 (patch) | |
tree | 7a6b8a135ad7ac8c383b26b1ab330c2f9b594dfc /source/blender/editors/render | |
parent | 6208ce2e0a60fdddc1fb12ae1a2f84dcdcd32d90 (diff) |
Draw manager: Listen to depsgraph's ID update callbacks
This replaces dedicated flag which wasn't clean who sets it and who clears it,
and which was also trying to re-implement existing functionality in a way.
Flushing is not currently very efficient but there are ways to speed this up
a lot, but needs more investigation.
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r-- | source/blender/editors/render/render_update.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index bd2acb1c8bd..a391b13a000 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -539,7 +539,9 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id) return; } Main *bmain = update_ctx->bmain; - + Scene *scene = update_ctx->scene; + ViewLayer *view_layer = update_ctx->view_layer; + /* Internal ID update handlers. */ switch (GS(id->name)) { case ID_MA: material_changed(bmain, (Material *)id); @@ -565,7 +567,42 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id) render_engine_flag_changed(bmain, RE_ENGINE_UPDATE_OTHER); break; } - + /* Inform all draw managers about changes. + * + * TODO(sergey): This code is run for every updated ID, via flushing + * mechanism. How can we avoid iterating over the whole interface for + * every of those IDs? One of the ideas would be to call draw manager's + * ID update which is not bound to any of contexts. + */ + { + wmWindowManager *wm = bmain->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + bScreen *sc = WM_window_get_active_screen(win); + WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); + ViewRender *view_render = BKE_viewrender_get(win->scene, workspace); + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + if (sa->spacetype != SPACE_VIEW3D) { + continue; + } + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype != RGN_TYPE_WINDOW) { + continue; + } + RenderEngineType *engine_type = RE_engines_find(view_render->engine_id); + DRW_notify_id_update( + (&(DRWUpdateContext){ + .bmain = bmain, + .scene = scene, + .view_layer = view_layer, + .ar = ar, + .v3d = (View3D *)sa->spacedata.first, + .engine_type = engine_type + }), + id); + } + } + } + } } |