Fix #29389: cycles viewport render not updating on frame changes. This sort of
worked by accident before, because of flags that weren't cleared properly. Now moved the call to update render engines into scene_update_* itself.
This commit is contained in:
@@ -121,7 +121,7 @@ void DAG_id_tag_update(struct ID *id, short flag);
|
||||
/* flush all tagged updates */
|
||||
void DAG_ids_flush_tagged(struct Main *bmain);
|
||||
/* check and clear ID recalc flags */
|
||||
void DAG_ids_check_recalc(struct Main *bmain);
|
||||
void DAG_ids_check_recalc(struct Main *bmain, struct Scene *scene, int time);
|
||||
void DAG_ids_clear_recalc(struct Main *bmain);
|
||||
/* test if any of this id type is tagged for update */
|
||||
void DAG_id_type_tag(struct Main *bmain, short idtype);
|
||||
@@ -131,7 +131,8 @@ int DAG_id_type_tagged(struct Main *bmain, short idtype);
|
||||
void DAG_pose_sort(struct Object *ob);
|
||||
|
||||
/* callback for editors module to do updates */
|
||||
void DAG_editors_update_cb(void (*func)(struct Main *bmain, struct ID *id));
|
||||
void DAG_editors_update_cb(void (*id_func)(struct Main *bmain, struct ID *id),
|
||||
void (*scene_func)(struct Main *bmain, struct Scene *scene, int updated));
|
||||
|
||||
/* debugging */
|
||||
void DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob);
|
||||
|
||||
@@ -90,7 +90,6 @@ float BKE_curframe(struct Scene *scene);
|
||||
float BKE_frame_to_ctime(struct Scene *scene, const float frame);
|
||||
|
||||
void scene_update_tagged(struct Main *bmain, struct Scene *sce);
|
||||
void scene_clear_tagged(struct Main *bmain, struct Scene *sce);
|
||||
|
||||
void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay);
|
||||
|
||||
|
||||
@@ -1636,17 +1636,25 @@ void graph_print_adj_list(void)
|
||||
|
||||
/* mechanism to allow editors to be informed of depsgraph updates,
|
||||
to do their own updates based on changes... */
|
||||
static void (*EditorsUpdateCb)(Main *bmain, ID *id)= NULL;
|
||||
static void (*EditorsUpdateIDCb)(Main *bmain, ID *id)= NULL;
|
||||
static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated)= NULL;
|
||||
|
||||
void DAG_editors_update_cb(void (*func)(Main *bmain, ID *id))
|
||||
void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated))
|
||||
{
|
||||
EditorsUpdateCb= func;
|
||||
EditorsUpdateIDCb= id_func;
|
||||
EditorsUpdateSceneCb= scene_func;
|
||||
}
|
||||
|
||||
static void dag_editors_update(Main *bmain, ID *id)
|
||||
static void dag_editors_id_update(Main *bmain, ID *id)
|
||||
{
|
||||
if(EditorsUpdateCb)
|
||||
EditorsUpdateCb(bmain, id);
|
||||
if(EditorsUpdateIDCb)
|
||||
EditorsUpdateIDCb(bmain, id);
|
||||
}
|
||||
|
||||
static void dag_editors_scene_update(Main *bmain, Scene *scene, int updated)
|
||||
{
|
||||
if(EditorsUpdateSceneCb)
|
||||
EditorsUpdateSceneCb(bmain, scene, updated);
|
||||
}
|
||||
|
||||
/* groups with objects in this scene need to be put in the right order as well */
|
||||
@@ -2460,7 +2468,7 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
|
||||
/* no point in trying in this cases */
|
||||
if(id && id->us <= 1) {
|
||||
dag_editors_update(bmain, id);
|
||||
dag_editors_id_update(bmain, id);
|
||||
id= NULL;
|
||||
}
|
||||
}
|
||||
@@ -2572,7 +2580,7 @@ static void dag_id_flush_update(Scene *sce, ID *id)
|
||||
}
|
||||
|
||||
/* update editors */
|
||||
dag_editors_update(bmain, id);
|
||||
dag_editors_id_update(bmain, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2612,10 +2620,10 @@ void DAG_ids_flush_tagged(Main *bmain)
|
||||
DAG_scene_flush_update(bmain, sce, lay, 0);
|
||||
}
|
||||
|
||||
void DAG_ids_check_recalc(Main *bmain)
|
||||
void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)
|
||||
{
|
||||
ListBase *lbarray[MAX_LIBARRAY];
|
||||
int a;
|
||||
int a, updated = 0;
|
||||
|
||||
/* loop over all ID types */
|
||||
a = set_listbasepointers(bmain, lbarray);
|
||||
@@ -2627,13 +2635,13 @@ void DAG_ids_check_recalc(Main *bmain)
|
||||
/* we tag based on first ID type character to avoid
|
||||
looping over all ID's in case there are no tags */
|
||||
if(id && bmain->id_tag_update[id->name[0]]) {
|
||||
/* do editors update */
|
||||
dag_editors_update(bmain, NULL);
|
||||
return;
|
||||
updated= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dag_editors_scene_update(bmain, scene, (updated || time));
|
||||
}
|
||||
|
||||
void DAG_ids_clear_recalc(Main *bmain)
|
||||
{
|
||||
|
||||
@@ -1028,15 +1028,11 @@ void scene_update_tagged(Main *bmain, Scene *scene)
|
||||
if (scene->physics_settings.quick_cache_step)
|
||||
BKE_ptcache_quick_cache_all(bmain, scene);
|
||||
|
||||
/* notify editors about recalc */
|
||||
DAG_ids_check_recalc(bmain);
|
||||
|
||||
/* keep this last */
|
||||
/* notify editors and python about recalc */
|
||||
BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST);
|
||||
}
|
||||
DAG_ids_check_recalc(bmain, scene, FALSE);
|
||||
|
||||
void scene_clear_tagged(Main *bmain, Scene *UNUSED(scene))
|
||||
{
|
||||
/* clear recalc flags */
|
||||
DAG_ids_clear_recalc(bmain);
|
||||
}
|
||||
|
||||
@@ -1081,10 +1077,13 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
|
||||
/* object_handle_update() on all objects, groups and sets */
|
||||
scene_update_tagged_recursive(bmain, sce, sce);
|
||||
|
||||
/* keep this last */
|
||||
/* notify editors and python about recalc */
|
||||
BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST);
|
||||
BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST);
|
||||
|
||||
DAG_ids_check_recalc(bmain, sce, TRUE);
|
||||
|
||||
/* clear recalc flags */
|
||||
DAG_ids_clear_recalc(bmain);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ struct Main;
|
||||
struct MTex;
|
||||
struct Render;
|
||||
struct RenderInfo;
|
||||
struct Scene;
|
||||
|
||||
/* render_ops.c */
|
||||
|
||||
@@ -45,7 +46,7 @@ void ED_operatortypes_render(void);
|
||||
|
||||
void ED_render_id_flush_update(struct Main *bmain, struct ID *id);
|
||||
void ED_render_engine_changed(struct Main *bmain);
|
||||
void ED_render_engine_update_tagged(struct bContext *C, struct Main *bmain);
|
||||
void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated);
|
||||
|
||||
/* render_preview.c */
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
@@ -65,13 +66,25 @@
|
||||
|
||||
/***************************** Render Engines ********************************/
|
||||
|
||||
void ED_render_engine_update_tagged(bContext *C, Main *bmain)
|
||||
void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
|
||||
{
|
||||
/* viewport rendering update on data changes, happens after depsgraph
|
||||
* updates if there was any change. context is set to the 3d view */
|
||||
bScreen *sc, *prev_sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *prev_sa= CTX_wm_area(C);
|
||||
ARegion *ar, *prev_ar= CTX_wm_region(C);
|
||||
bContext *C;
|
||||
bScreen *sc;
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
/* don't do this render engine update if we're updating the scene from
|
||||
other threads doing e.g. rendering or baking jobs */
|
||||
if(!BLI_thread_is_main())
|
||||
return;
|
||||
|
||||
C= CTX_create();
|
||||
CTX_data_main_set(C, bmain);
|
||||
CTX_data_scene_set(C, scene);
|
||||
|
||||
CTX_wm_manager_set(C, bmain->wm.first);
|
||||
|
||||
for(sc=bmain->screen.first; sc; sc=sc->id.next) {
|
||||
for(sa=sc->areabase.first; sa; sa=sa->next) {
|
||||
@@ -88,7 +101,7 @@ void ED_render_engine_update_tagged(bContext *C, Main *bmain)
|
||||
rv3d= ar->regiondata;
|
||||
engine= rv3d->render_engine;
|
||||
|
||||
if(engine && (engine->flag & RE_ENGINE_DO_UPDATE)) {
|
||||
if(engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) {
|
||||
CTX_wm_screen_set(C, sc);
|
||||
CTX_wm_area_set(C, sa);
|
||||
CTX_wm_region_set(C, ar);
|
||||
@@ -100,9 +113,7 @@ void ED_render_engine_update_tagged(bContext *C, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
CTX_wm_screen_set(C, prev_sc);
|
||||
CTX_wm_area_set(C, prev_sa);
|
||||
CTX_wm_region_set(C, prev_ar);
|
||||
CTX_free(C);
|
||||
}
|
||||
|
||||
void ED_render_engine_changed(Main *bmain)
|
||||
@@ -134,32 +145,6 @@ void ED_render_engine_changed(Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
static void tag_render_engines(Main *bmain)
|
||||
{
|
||||
/* tag running render engines for update later on */
|
||||
bScreen *sc;
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
for(sc=bmain->screen.first; sc; sc=sc->id.next) {
|
||||
for(sa=sc->areabase.first; sa; sa=sa->next) {
|
||||
if(sa->spacetype != SPACE_VIEW3D)
|
||||
continue;
|
||||
|
||||
for(ar=sa->regionbase.first; ar; ar=ar->next) {
|
||||
RegionView3D *rv3d;
|
||||
|
||||
if(ar->regiontype != RGN_TYPE_WINDOW)
|
||||
continue;
|
||||
|
||||
rv3d= ar->regiondata;
|
||||
if(rv3d->render_engine)
|
||||
rv3d->render_engine->flag |= RE_ENGINE_DO_UPDATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************** Updates ***********************************
|
||||
* ED_render_id_flush_update gets called from DAG_id_tag_update, to do *
|
||||
* editor level updates when the ID changes. when these ID blocks are in *
|
||||
@@ -357,11 +342,6 @@ static void scene_changed(Main *bmain, Scene *UNUSED(scene))
|
||||
|
||||
void ED_render_id_flush_update(Main *bmain, ID *id)
|
||||
{
|
||||
if(!id) {
|
||||
tag_render_engines(bmain);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(GS(id->name)) {
|
||||
case ID_MA:
|
||||
material_changed(bmain, (Material*)id);
|
||||
|
||||
@@ -69,7 +69,6 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
|
||||
static void rna_Scene_update_tagged(Scene *scene)
|
||||
{
|
||||
scene_update_tagged(G.main, scene);
|
||||
scene_clear_tagged(G.main, scene);
|
||||
}
|
||||
|
||||
static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name)
|
||||
|
||||
@@ -321,10 +321,6 @@ void wm_event_do_notifiers(bContext *C)
|
||||
win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal;
|
||||
|
||||
scene_update_tagged(bmain, win->screen->scene);
|
||||
|
||||
ED_render_engine_update_tagged(C, bmain);
|
||||
|
||||
scene_clear_tagged(bmain, win->screen->scene);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
|
||||
set_free_windowmanager_cb(wm_close_and_free); /* library.c */
|
||||
set_blender_test_break_cb(wm_window_testbreak); /* blender.c */
|
||||
DAG_editors_update_cb(ED_render_id_flush_update); /* depsgraph.c */
|
||||
DAG_editors_update_cb(ED_render_id_flush_update, ED_render_scene_update); /* depsgraph.c */
|
||||
|
||||
ED_spacetypes_init(); /* editors/space_api/spacetype.c */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user