Fix T89040: dependency graph not handling time remapping correctly

In this bug report it resulted in rendering animations stopping too early,
but this affected more areas.

After the previous cleanup commit, it becomes clear that frame and ctime
values were mixed up.
This commit is contained in:
Brecht Van Lommel 2021-07-12 17:07:35 +02:00
parent 2ea565b0ec
commit a072e87e04
Notes: blender-bot 2023-02-13 18:26:16 +01:00
Referenced by issue #89040, Cycles renders only two frames of animation
7 changed files with 18 additions and 10 deletions

View File

@ -2739,8 +2739,8 @@ void BKE_scene_graph_update_for_newframe_ex(Depsgraph *depsgraph, const bool cle
* edits from callback are properly taken into account. Doing a time update on those would
* lose any possible unkeyed changes made by the handler. */
if (pass == 0) {
const float ctime = BKE_scene_ctime_get(scene);
DEG_evaluate_on_framechange(depsgraph, ctime);
const float frame = BKE_scene_frame_get(scene);
DEG_evaluate_on_framechange(depsgraph, frame);
}
else {
DEG_evaluate_on_refresh(depsgraph);

View File

@ -159,7 +159,7 @@ void DEG_ids_restore_recalc(Depsgraph *depsgraph);
/* Graph Evaluation ----------------------------- */
/* Frame changed recalculation entry point. */
void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime);
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame);
/* Data changed recalculation entry point. */
void DEG_evaluate_on_refresh(Depsgraph *graph);

View File

@ -68,6 +68,7 @@ Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluati
scene(scene),
view_layer(view_layer),
mode(mode),
frame(BKE_scene_frame_get(scene)),
ctime(BKE_scene_ctime_get(scene)),
scene_cow(nullptr),
is_active(false),

View File

@ -140,7 +140,9 @@ struct Depsgraph {
ViewLayer *view_layer;
eEvaluationMode mode;
/* Time at which dependency graph is being or was last evaluated. */
/* Time at which dependency graph is being or was last evaluated.
* frame is the value before, and ctime the value after time remapping. */
float frame;
float ctime;
/* Evaluated version of datablocks we access a lot.

View File

@ -51,7 +51,7 @@ static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph)
{
/* Update the time on the cow scene. */
if (deg_graph->scene_cow) {
BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->ctime);
BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->frame);
}
deg::deg_graph_flush_updates(deg_graph);
@ -63,10 +63,12 @@ void DEG_evaluate_on_refresh(Depsgraph *graph)
{
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
const Scene *scene = DEG_get_input_scene(graph);
const float frame = BKE_scene_frame_get(scene);
const float ctime = BKE_scene_ctime_get(scene);
if (ctime != deg_graph->ctime) {
if (deg_graph->frame != frame || ctime != deg_graph->ctime) {
deg_graph->tag_time_source();
deg_graph->frame = frame;
deg_graph->ctime = ctime;
}
@ -74,10 +76,13 @@ void DEG_evaluate_on_refresh(Depsgraph *graph)
}
/* Frame-change happened for root scene that graph belongs to. */
void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime)
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame)
{
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
const Scene *scene = DEG_get_input_scene(graph);
deg_graph->tag_time_source();
deg_graph->ctime = ctime;
deg_graph->frame = frame;
deg_graph->ctime = BKE_scene_frame_to_ctime(scene, frame);
deg_flush_updates_and_refresh(deg_graph);
}

View File

@ -679,7 +679,7 @@ static void engine_depsgraph_init(RenderEngine *engine, ViewLayer *view_layer)
DRW_render_context_enable(engine->re);
}
DEG_evaluate_on_framechange(depsgraph, CFRA);
DEG_evaluate_on_framechange(depsgraph, BKE_scene_frame_get(scene));
if (use_gpu_context) {
DRW_render_context_disable(engine->re);

View File

@ -1828,7 +1828,7 @@ void RE_SetReports(Render *re, ReportList *reports)
static void render_update_depsgraph(Render *re)
{
Scene *scene = re->scene;
DEG_evaluate_on_framechange(re->pipeline_depsgraph, CFRA);
DEG_evaluate_on_framechange(re->pipeline_depsgraph, BKE_scene_frame_get(scene));
BKE_scene_update_sound(re->pipeline_depsgraph, re->main);
}