Blender V5.3
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 blender {
29
31 const DepsgraphEvaluateSyncWriteback sync_writeback)
32{
34
35 /* Update the time on the cow scene. */
36 if (deg_graph->scene_cow) {
37 BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->frame);
38 }
39
43 deg_graph->sync_writeback = sync_writeback;
45
46 if ((deg_graph->sync_writeback == DEG_EVALUATE_SYNC_WRITEBACK_YES) && deg_graph->is_active) {
47 for (std::function<void()> &fn : deg_graph->sync_writeback_callbacks) {
48 fn();
49 }
50 }
53}
54
55void DEG_evaluate_on_refresh(Depsgraph *graph, const DepsgraphEvaluateSyncWriteback sync_writeback)
56{
57 deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
58 const Scene *scene = DEG_get_input_scene(graph);
59 const float frame = BKE_scene_frame_get(scene);
60 const float ctime = BKE_scene_ctime_get(scene);
61
62 if (deg_graph->frame != frame || ctime != deg_graph->ctime) {
63 deg_graph->tag_time_source();
64 deg_graph->frame = frame;
65 deg_graph->ctime = ctime;
66 }
67 else if (scene->id.recalc & ID_RECALC_FRAME_CHANGE) {
68 /* Comparing depsgraph & scene frame fails in the case of undo,
69 * since the undo state is stored before updates from the frame change have been applied.
70 * In this case reading back the undo state will behave as if no updates on frame change
71 * is needed as the #Depsgraph.ctime & frame will match the values in the input scene.
72 * Use #ID_RECALC_FRAME_CHANGE to detect that recalculation is necessary. see: #66913. */
73 deg_graph->tag_time_source();
74 }
75
76 deg_flush_updates_and_refresh(deg_graph, sync_writeback);
77}
78
79void DEG_evaluate_on_framechange(Depsgraph *graph,
80 float frame,
81 const DepsgraphEvaluateSyncWriteback sync_writeback)
82{
83 deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
84 const Scene *scene = DEG_get_input_scene(graph);
85
86 deg_graph->tag_time_source();
87 deg_graph->frame = frame;
88 deg_graph->ctime = BKE_scene_frame_to_ctime(scene, frame);
89 deg_flush_updates_and_refresh(deg_graph, sync_writeback);
90}
91
92} // namespace blender
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:420
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph, const DepsgraphEvaluateSyncWriteback sync_writeback)
float BKE_scene_frame_to_ctime(const Scene *scene, int frame)
Definition scene.cc:2586
void DEG_evaluate_on_refresh(Depsgraph *graph, DepsgraphEvaluateSyncWriteback sync_writeback=DEG_EVALUATE_SYNC_WRITEBACK_NO)
void BKE_scene_frame_set(Scene *scene, float frame)
Definition scene.cc:2600
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2595
float BKE_scene_ctime_get(const Scene *scene)
Definition scene.cc:2581
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1125
Scene * DEG_get_input_scene(const Depsgraph *graph)
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame, DepsgraphEvaluateSyncWriteback sync_writeback=DEG_EVALUATE_SYNC_WRITEBACK_NO)
DepsgraphEvaluateSyncWriteback
@ DEG_EVALUATE_SYNC_WRITEBACK_NO
@ DEG_EVALUATE_SYNC_WRITEBACK_YES
unsigned int recalc
Definition DNA_ID.h:446
Vector< std::function< void()> > sync_writeback_callbacks
Definition depsgraph.hh:198
DepsgraphEvaluateSyncWriteback sync_writeback
Definition depsgraph.hh:193