Blender  V2.93
DEG_depsgraph.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19 
41 /* ************************************************* */
42 /* Forward-defined typedefs for core types
43  * - These are used in all depsgraph code and by all callers of Depsgraph API...
44  */
45 
46 #pragma once
47 
48 #include "DNA_ID.h"
49 
50 /* Dependency Graph */
51 typedef struct Depsgraph Depsgraph;
52 
53 /* ------------------------------------------------ */
54 
55 struct Main;
56 
57 struct Scene;
58 struct ViewLayer;
59 
60 typedef enum eEvaluationMode {
61  DAG_EVAL_VIEWPORT = 0, /* evaluate for OpenGL viewport */
62  DAG_EVAL_RENDER = 1, /* evaluate for render purposes */
64 
65 /* DagNode->eval_flags */
66 enum {
67  /* Regardless to curve->path animation flag path is to be evaluated anyway,
68  * to meet dependencies with such a things as curve modifier and other guys
69  * who're using curve deform, where_on_path and so. */
71  /* A shrinkwrap modifier or constraint targeting this mesh needs information
72  * about non-manifold boundary edges for the Target Normal Project mode. */
74 };
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 /* ************************************************ */
81 /* Depsgraph API */
82 
83 /* CRUD ------------------------------------------- */
84 
85 // Get main depsgraph instance from context!
86 
87 /* Create new Depsgraph instance */
88 // TODO: what args are needed here? What's the building-graph entry point?
89 Depsgraph *DEG_graph_new(struct Main *bmain,
90  struct Scene *scene,
91  struct ViewLayer *view_layer,
92  eEvaluationMode mode);
93 
95  struct Main *bmain,
96  struct Scene *scene,
97  struct ViewLayer *view_layer);
98 
99 /* Free Depsgraph itself and all its data */
101 
102 /* Node Types Registry ---------------------------- */
103 
104 /* Register all node types */
105 void DEG_register_node_types(void);
106 
107 /* Free node type registry on exit */
108 void DEG_free_node_types(void);
109 
110 /* Update Tagging -------------------------------- */
111 
112 /* Update dependency graph when visible scenes/layers changes. */
113 void DEG_graph_on_visible_update(struct Main *bmain, Depsgraph *depsgraph, const bool do_time);
114 
115 /* Update all dependency graphs when visible scenes/layers changes. */
116 void DEG_on_visible_update(struct Main *bmain, const bool do_time);
117 
118 /* NOTE: Will return NULL if the flag is not known, allowing to gracefully handle situations
119  * when recalc flag has been removed. */
121 
122 void DEG_id_tag_update(struct ID *id, int flag);
123 void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag);
124 
125 void DEG_graph_id_tag_update(struct Main *bmain,
126  struct Depsgraph *depsgraph,
127  struct ID *id,
128  int flag);
129 
130 /* Tag all dependency graphs when time has changed. */
131 void DEG_time_tag_update(struct Main *bmain);
132 
133 /* Tag a dependency graph when time has changed. */
135 
136 /* Mark a particular datablock type as having changing. This does
137  * not cause any updates but is used by external render engines to detect if for
138  * example a datablock was removed. */
139 void DEG_graph_id_type_tag(struct Depsgraph *depsgraph, short id_type);
140 void DEG_id_type_tag(struct Main *bmain, short id_type);
141 
142 /* Set a depsgraph to flush updates to editors. This would be done
143  * for viewport depsgraphs, but not render or export depsgraph for example. */
145 
146 /* Check if something was changed in the database and inform editors about this. */
147 void DEG_editors_update(struct Depsgraph *depsgraph, bool time);
148 
149 /* Clear recalc flags after editors or renderers have handled updates. */
151 
152 /* Restore recalc flags, backed up by a previous call to DEG_ids_clear_recalc.
153  * This also clears the backup. */
155 
156 /* ************************************************ */
157 /* Evaluation Engine API */
158 
159 /* Graph Evaluation ----------------------------- */
160 
161 /* Frame changed recalculation entry point. */
162 void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime);
163 
164 /* Data changed recalculation entry point. */
166 
167 /* Editors Integration -------------------------- */
168 
169 /* Mechanism to allow editors to be informed of depsgraph updates,
170  * to do their own updates based on changes.
171  */
172 
173 typedef struct DEGEditorUpdateContext {
174  struct Main *bmain;
176  struct Scene *scene;
179 
180 typedef void (*DEG_EditorUpdateIDCb)(const DEGEditorUpdateContext *update_ctx, struct ID *id);
181 typedef void (*DEG_EditorUpdateSceneCb)(const DEGEditorUpdateContext *update_ctx,
182  const bool updated);
183 
184 /* Set callbacks which are being called when depsgraph changes. */
186 
187 /* Evaluation ----------------------------------- */
188 
189 bool DEG_is_evaluating(const struct Depsgraph *depsgraph);
190 
191 bool DEG_is_active(const struct Depsgraph *depsgraph);
192 void DEG_make_active(struct Depsgraph *depsgraph);
194 
195 /* Evaluation Debug ------------------------------ */
196 
198 
200  const char *function_name,
201  const char *object_name,
202  const void *object_address);
203 
205  const char *function_name,
206  const char *object_name,
207  const void *object_address,
208  const char *subdata_comment,
209  const char *subdata_name,
210  const void *subdata_address);
211 
213  const char *function_name,
214  const char *object_name,
215  const void *object_address,
216  const char *subdata_comment,
217  const char *subdata_name,
218  const void *subdata_address,
219  const int subdata_index);
220 
222  const char *function_name,
223  const char *object_name,
224  const void *object_address,
225  const char *parent_comment,
226  const char *parent_name,
227  const void *parent_address);
228 
230  const char *function_name,
231  const char *object_name,
232  const void *object_address,
233  float time);
234 
235 #ifdef __cplusplus
236 } /* extern "C" */
237 #endif
void(* DEG_EditorUpdateSceneCb)(const DEGEditorUpdateContext *update_ctx, const bool updated)
void DEG_evaluate_on_refresh(Depsgraph *graph)
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
Definition: depsgraph.cc:281
void DEG_on_visible_update(struct Main *bmain, const bool do_time)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
struct DEGEditorUpdateContext DEGEditorUpdateContext
void DEG_editors_update(struct Depsgraph *depsgraph, bool time)
const char * DEG_update_tag_as_string(IDRecalcFlag flag)
bool DEG_is_active(const struct Depsgraph *depsgraph)
Definition: depsgraph.cc:331
void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, DEG_EditorUpdateSceneCb scene_func)
void DEG_debug_print_eval_time(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address, float time)
void DEG_ids_clear_recalc(Depsgraph *depsgraph, const bool backup)
void DEG_enable_editors_update(struct Depsgraph *depsgraph)
void DEG_graph_id_tag_update(struct Main *bmain, struct Depsgraph *depsgraph, struct ID *id, int flag)
void DEG_make_active(struct Depsgraph *depsgraph)
Definition: depsgraph.cc:344
void DEG_graph_time_tag_update(struct Depsgraph *depsgraph)
eEvaluationMode
Definition: DEG_depsgraph.h:60
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:62
@ DAG_EVAL_VIEWPORT
Definition: DEG_depsgraph.h:61
@ DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY
Definition: DEG_depsgraph.h:73
@ DAG_EVAL_NEED_CURVE_PATH
Definition: DEG_depsgraph.h:70
void DEG_debug_print_eval(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address)
void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime)
void DEG_id_type_tag(struct Main *bmain, short id_type)
void DEG_free_node_types(void)
void(* DEG_EditorUpdateIDCb)(const DEGEditorUpdateContext *update_ctx, struct ID *id)
void DEG_time_tag_update(struct Main *bmain)
void DEG_graph_replace_owners(struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
Definition: depsgraph.cc:292
void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag)
void DEG_graph_on_visible_update(struct Main *bmain, Depsgraph *depsgraph, const bool do_time)
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:314
void DEG_register_node_types(void)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_make_inactive(struct Depsgraph *depsgraph)
Definition: depsgraph.cc:351
void DEG_ids_restore_recalc(Depsgraph *depsgraph)
void DEG_debug_print_begin(struct Depsgraph *depsgraph)
void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address, const char *subdata_comment, const char *subdata_name, const void *subdata_address)
bool DEG_is_evaluating(const struct Depsgraph *depsgraph)
Definition: depsgraph.cc:325
void DEG_debug_print_eval_subdata_index(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address, const char *subdata_comment, const char *subdata_name, const void *subdata_address, const int subdata_index)
void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address, const char *parent_comment, const char *parent_name, const void *parent_address)
void DEG_graph_id_type_tag(struct Depsgraph *depsgraph, short id_type)
ID and Library types, which are fundamental for sdna.
IDRecalcFlag
Definition: DNA_ID.h:594
Depsgraph * graph
double time
Scene scene
const Depsgraph * depsgraph
AnimationBackup * backup
struct Depsgraph * depsgraph
struct ViewLayer * view_layer
struct Scene * scene
Definition: DNA_ID.h:273
Definition: BKE_main.h:116