Blender V5.0
depsgraph_eval.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "BKE_scene.hh"
12
13#include "DNA_scene_types.h"
14
15#include "DEG_depsgraph.hh"
18
21
24
25#include "intern/depsgraph.hh"
27
28namespace deg = blender::deg;
29
31 const DepsgraphEvaluateSyncWriteback sync_writeback)
32{
33 /* Update the time on the cow scene. */
34 if (deg_graph->scene_cow) {
35 BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->frame);
36 }
37
41 deg_graph->sync_writeback = sync_writeback;
43
44 if ((deg_graph->sync_writeback == DEG_EVALUATE_SYNC_WRITEBACK_YES) && deg_graph->is_active) {
45 for (std::function<void()> &fn : deg_graph->sync_writeback_callbacks) {
46 fn();
47 }
48 }
51}
52
53void DEG_evaluate_on_refresh(Depsgraph *graph, const DepsgraphEvaluateSyncWriteback sync_writeback)
54{
55 deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
56 const Scene *scene = DEG_get_input_scene(graph);
57 const float frame = BKE_scene_frame_get(scene);
58 const float ctime = BKE_scene_ctime_get(scene);
59
60 if (deg_graph->frame != frame || ctime != deg_graph->ctime) {
61 deg_graph->tag_time_source();
62 deg_graph->frame = frame;
63 deg_graph->ctime = ctime;
64 }
65 else if (scene->id.recalc & ID_RECALC_FRAME_CHANGE) {
66 /* Comparing depsgraph & scene frame fails in the case of undo,
67 * since the undo state is stored before updates from the frame change have been applied.
68 * In this case reading back the undo state will behave as if no updates on frame change
69 * is needed as the #Depsgraph.ctime & frame will match the values in the input scene.
70 * Use #ID_RECALC_FRAME_CHANGE to detect that recalculation is necessary. see: #66913. */
71 deg_graph->tag_time_source();
72 }
73
74 deg_flush_updates_and_refresh(deg_graph, sync_writeback);
75}
76
77void DEG_evaluate_on_framechange(Depsgraph *graph,
78 float frame,
79 const DepsgraphEvaluateSyncWriteback sync_writeback)
80{
81 deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
82 const Scene *scene = DEG_get_input_scene(graph);
83
84 deg_graph->tag_time_source();
85 deg_graph->frame = frame;
86 deg_graph->ctime = BKE_scene_frame_to_ctime(scene, frame);
87 deg_flush_updates_and_refresh(deg_graph, sync_writeback);
88}
float BKE_scene_ctime_get(const Scene *scene)
Definition scene.cc:2370
void BKE_scene_frame_set(Scene *scene, float frame)
Definition scene.cc:2389
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2384
float BKE_scene_frame_to_ctime(const Scene *scene, int frame)
Definition scene.cc:2375
#define BLI_assert(a)
Definition BLI_assert.h:46
DepsgraphEvaluateSyncWriteback
@ DEG_EVALUATE_SYNC_WRITEBACK_YES
@ DEG_EVALUATE_SYNC_WRITEBACK_NO
Scene * DEG_get_input_scene(const Depsgraph *graph)
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1125
bool is_empty() const
void clear()
void DEG_evaluate_on_refresh(Depsgraph *graph, const DepsgraphEvaluateSyncWriteback sync_writeback)
static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph, const DepsgraphEvaluateSyncWriteback sync_writeback)
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame, const DepsgraphEvaluateSyncWriteback sync_writeback)
void graph_tag_ids_for_visible_update(Depsgraph *graph)
void deg_graph_flush_updates(Depsgraph *graph)
void deg_evaluate_on_refresh(Depsgraph *graph)
Definition deg_eval.cc:381
unsigned int recalc
Definition DNA_ID.h:445
Vector< std::function< void()> > sync_writeback_callbacks
Definition depsgraph.hh:194
DepsgraphEvaluateSyncWriteback sync_writeback
Definition depsgraph.hh:189