Blender V4.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
11#include "MEM_guardedalloc.h"
12
13#include "BLI_listbase.h"
14#include "BLI_utildefines.h"
15
16#include "BKE_scene.hh"
17
18#include "DNA_object_types.h"
19#include "DNA_scene_types.h"
20
21#include "DEG_depsgraph.hh"
24
27
31
32#include "intern/depsgraph.hh"
34
35namespace deg = blender::deg;
36
38 const DepsgraphEvaluateSyncWriteback sync_writeback)
39{
40 /* Update the time on the cow scene. */
41 if (deg_graph->scene_cow) {
42 BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->frame);
43 }
44
48
49 if (sync_writeback == DEG_EVALUATE_SYNC_WRITEBACK_YES) {
50 if (deg_graph->is_active) {
51 for (std::function<void()> &fn : deg_graph->sync_writeback_callbacks) {
52 fn();
53 }
54 }
55 }
57}
58
59void DEG_evaluate_on_refresh(Depsgraph *graph, const DepsgraphEvaluateSyncWriteback sync_writeback)
60{
61 deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
62 const Scene *scene = DEG_get_input_scene(graph);
63 const float frame = BKE_scene_frame_get(scene);
64 const float ctime = BKE_scene_ctime_get(scene);
65
66 if (deg_graph->frame != frame || ctime != deg_graph->ctime) {
67 deg_graph->tag_time_source();
68 deg_graph->frame = frame;
69 deg_graph->ctime = ctime;
70 }
71 else if (scene->id.recalc & ID_RECALC_FRAME_CHANGE) {
72 /* Comparing depsgraph & scene frame fails in the case of undo,
73 * since the undo state is stored before updates from the frame change have been applied.
74 * In this case reading back the undo state will behave as if no updates on frame change
75 * is needed as the #Depsgraph.ctime & frame will match the values in the input scene.
76 * Use #ID_RECALC_FRAME_CHANGE to detect that recalculation is necessary. see: #66913. */
77 deg_graph->tag_time_source();
78 }
79
80 deg_flush_updates_and_refresh(deg_graph, sync_writeback);
81}
82
83void DEG_evaluate_on_framechange(Depsgraph *graph,
84 float frame,
85 const DepsgraphEvaluateSyncWriteback sync_writeback)
86{
87 deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
88 const Scene *scene = DEG_get_input_scene(graph);
89
90 deg_graph->tag_time_source();
91 deg_graph->frame = frame;
92 deg_graph->ctime = BKE_scene_frame_to_ctime(scene, frame);
93 deg_flush_updates_and_refresh(deg_graph, sync_writeback);
94}
float BKE_scene_ctime_get(const Scene *scene)
Definition scene.cc:2317
void BKE_scene_frame_set(Scene *scene, float frame)
Definition scene.cc:2336
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2331
float BKE_scene_frame_to_ctime(const Scene *scene, int frame)
Definition scene.cc:2322
DepsgraphEvaluateSyncWriteback
@ DEG_EVALUATE_SYNC_WRITEBACK_YES
Scene * DEG_get_input_scene(const Depsgraph *graph)
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1092
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
Depsgraph * graph
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:382
Vector< std::function< void()> > sync_writeback_callbacks
Definition depsgraph.hh:185