From 0566ebdebeeb658300e6c45b805075ada9c02c0a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 19 Apr 2021 22:37:39 +0200 Subject: Fix crash with Alembic export after recent persistent data bugfix We weren't clearing the recalc flags for that case. --- source/blender/blenkernel/BKE_scene.h | 1 + source/blender/blenkernel/intern/scene.c | 35 ++++++++++++++++++------ source/blender/depsgraph/DEG_depsgraph.h | 3 +- source/blender/depsgraph/intern/depsgraph_tag.cc | 2 -- source/blender/render/intern/engine.c | 4 +-- 5 files changed, 31 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 66edb00e83c..9792f819bf9 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -152,6 +152,7 @@ void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bma void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain); void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph); +void BKE_scene_graph_update_for_newframe_ex(struct Depsgraph *depsgraph, const bool clear_recalc); void BKE_scene_view_layer_graph_evaluated_ensure(struct Main *bmain, struct Scene *scene, diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 47b6817d429..e1f013eb589 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2682,7 +2682,8 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on } /* Clear recalc flags for second pass, but back them up for editors update. */ - DEG_ids_clear_recalc(depsgraph, true); + const bool backup = true; + DEG_ids_clear_recalc(depsgraph, backup); used_multiple_passes = true; run_callbacks = false; } @@ -2691,7 +2692,11 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on if (used_multiple_passes) { DEG_ids_restore_recalc(depsgraph); } - DEG_editors_update(depsgraph, false); + const bool is_time_update = false; + DEG_editors_update(depsgraph, is_time_update); + + const bool backup = false; + DEG_ids_clear_recalc(depsgraph, backup); } void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain) @@ -2705,10 +2710,9 @@ void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain) } /* applies changes right away, does all sets too */ -void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph) +void BKE_scene_graph_update_for_newframe_ex(Depsgraph *depsgraph, const bool clear_recalc) { Scene *scene = DEG_get_input_scene(depsgraph); - ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); Main *bmain = DEG_get_bmain(depsgraph); bool used_multiple_passes = false; @@ -2755,7 +2759,8 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph) } /* Clear recalc flags for second pass, but back them up for editors update. */ - DEG_ids_clear_recalc(depsgraph, true); + const bool backup = true; + DEG_ids_clear_recalc(depsgraph, backup); used_multiple_passes = true; } @@ -2763,7 +2768,21 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph) if (used_multiple_passes) { DEG_ids_restore_recalc(depsgraph); } - DEG_editors_update(depsgraph, true); + + const bool is_time_update = true; + DEG_editors_update(depsgraph, is_time_update); + + /* Clear recalc flags, can be skipped for e.g. renderers that will read these + * and clear the flags later. */ + if (clear_recalc) { + const bool backup = false; + DEG_ids_clear_recalc(depsgraph, backup); + } +} + +void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph) +{ + BKE_scene_graph_update_for_newframe_ex(depsgraph, true); } /** @@ -3523,8 +3542,8 @@ GHash *BKE_scene_undo_depsgraphs_extract(Main *bmain) for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { if (scene->depsgraph_hash == NULL) { - /* In some cases, e.g. when undo has to perform multiple steps at once, no depsgraph will be - * built so this pointer may be NULL. */ + /* In some cases, e.g. when undo has to perform multiple steps at once, no depsgraph will + * be built so this pointer may be NULL. */ continue; } for (ViewLayer *view_layer = scene->view_layers.first; view_layer != NULL; diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 134e71ecb6a..740124f6113 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -143,8 +143,7 @@ void DEG_id_type_tag(struct Main *bmain, short id_type); * for viewport depsgraphs, but not render or export depsgraph for example. */ void DEG_enable_editors_update(struct Depsgraph *depsgraph); -/* Check if something was changed in the database and inform editors about this, - * then clear recalc flags. */ +/* Check if something was changed in the database and inform editors about this. */ void DEG_editors_update(struct Depsgraph *depsgraph, bool time); /* Clear recalc flags after editors or renderers have handled updates. */ diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 608ec6292f6..b0a8e5d36e6 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -842,8 +842,6 @@ void DEG_editors_update(Depsgraph *depsgraph, bool time) update_ctx.scene = scene; update_ctx.view_layer = view_layer; deg::deg_editors_scene_update(&update_ctx, updated); - - DEG_ids_clear_recalc(depsgraph, false); } static void deg_graph_clear_id_recalc_flags(ID *id) diff --git a/source/blender/render/intern/engine.c b/source/blender/render/intern/engine.c index 2edfaf09358..817f09f5bfe 100644 --- a/source/blender/render/intern/engine.c +++ b/source/blender/render/intern/engine.c @@ -690,7 +690,7 @@ static void engine_depsgraph_init(RenderEngine *engine, ViewLayer *view_layer) } else { /* Go through update with full Python callbacks for regular render. */ - BKE_scene_graph_update_for_newframe(engine->depsgraph); + BKE_scene_graph_update_for_newframe_ex(engine->depsgraph, false); } engine->has_grease_pencil = DRW_render_check_grease_pencil(engine->depsgraph); @@ -725,7 +725,7 @@ void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe) CLAMP(cfra, MINAFRAME, MAXFRAME); BKE_scene_frame_set(re->scene, cfra); - BKE_scene_graph_update_for_newframe(engine->depsgraph); + BKE_scene_graph_update_for_newframe_ex(engine->depsgraph, false); BKE_scene_camera_switch_update(re->scene); } -- cgit v1.2.3