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.
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.
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.
16 * The Original Code is Copyright (C) 2013 Blender Foundation.
17 * All rights reserved.
20 /** \file blender/depsgraph/DEG_depsgraph.h
23 * Public API for Depsgraph
28 * The dependency graph tracks relations between various pieces of data in
29 * a Blender file, but mainly just those which make up scene data. It is used
30 * to determine the set of operations need to ensure that all data has been
31 * correctly evaluated in response to changes, based on dependencies and visibility
36 * The evaluation takes the operation-nodes the Depsgraph has tagged for updating,
37 * and schedules them up for being evaluated/executed such that the all dependency
38 * relationship constraints are satisfied.
41 /* ************************************************* */
42 /* Forward-defined typedefs for core types
43 * - These are used in all depsgraph code and by all callers of Depsgraph API...
46 #ifndef __DEG_DEPSGRAPH_H__
47 #define __DEG_DEPSGRAPH_H__
51 /* Dependency Graph */
52 typedef struct Depsgraph Depsgraph;
54 /* ------------------------------------------------ */
60 struct RenderEngineType;
64 typedef enum eEvaluationMode {
65 DAG_EVAL_VIEWPORT = 0, /* evaluate for OpenGL viewport */
66 DAG_EVAL_RENDER = 1, /* evaluate for render purposes */
69 /* DagNode->eval_flags */
71 /* Regardless to curve->path animation flag path is to be evaluated anyway,
72 * to meet dependencies with such a things as curve modifier and other guys
73 * who're using curve deform, where_on_path and so. */
74 DAG_EVAL_NEED_CURVE_PATH = (1 << 0),
75 /* A shrinkwrap modifier or constraint targeting this mesh needs information
76 * about non-manifold boundary edges for the Target Normal Project mode. */
77 DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY = (1 << 1),
84 /* ************************************************ */
87 /* CRUD ------------------------------------------- */
89 // Get main depsgraph instance from context!
91 /* Create new Depsgraph instance */
92 // TODO: what args are needed here? What's the building-graph entry point?
93 Depsgraph *DEG_graph_new(struct Scene *scene,
94 struct ViewLayer *view_layer,
95 eEvaluationMode mode);
97 /* Free Depsgraph itself and all its data */
98 void DEG_graph_free(Depsgraph *graph);
100 /* Node Types Registry ---------------------------- */
102 /* Register all node types */
103 void DEG_register_node_types(void);
105 /* Free node type registry on exit */
106 void DEG_free_node_types(void);
108 /* Update Tagging -------------------------------- */
110 /* Update dependency graph when visible scenes/layers changes. */
111 void DEG_graph_on_visible_update(struct Main *bmain, Depsgraph *depsgraph);
113 /* Update all dependency graphs when visible scenes/layers changes. */
114 void DEG_on_visible_update(struct Main *bmain, const bool do_time);
116 const char *DEG_update_tag_as_string(IDRecalcFlag flag);
118 void DEG_id_tag_update(struct ID *id, int flag);
119 void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag);
121 void DEG_graph_id_tag_update(struct Main *bmain,
122 struct Depsgraph *depsgraph,
126 /* Mark a particular datablock type as having changing. This does
127 * not cause any updates but is used by external render engines to detect if for
128 * example a datablock was removed. */
129 void DEG_id_type_tag(struct Main *bmain, short id_type);
131 void DEG_ids_clear_recalc(struct Main *bmain, Depsgraph *depsgraph);
133 /* Update Flushing ------------------------------- */
135 /* Flush updates for IDs in a single scene. */
136 void DEG_graph_flush_update(struct Main *bmain, Depsgraph *depsgraph);
138 /* Check if something was changed in the database and inform
139 * editors about this.
141 void DEG_ids_check_recalc(struct Main *bmain,
142 struct Depsgraph *depsgraph,
144 struct ViewLayer *view_layer,
147 /* ************************************************ */
148 /* Evaluation Engine API */
150 /* Graph Evaluation ----------------------------- */
152 /* Frame changed recalculation entry point
153 * < context_type: context to perform evaluation for
154 * < ctime: (frame) new frame to evaluate values on
156 void DEG_evaluate_on_framechange(struct Main *bmain,
160 /* Data changed recalculation entry point.
161 * < context_type: context to perform evaluation for
163 void DEG_evaluate_on_refresh(Depsgraph *graph);
165 bool DEG_needs_eval(Depsgraph *graph);
167 /* Editors Integration -------------------------- */
169 /* Mechanism to allow editors to be informed of depsgraph updates,
170 * to do their own updates based on changes.
173 typedef struct DEGEditorUpdateContext {
175 struct Depsgraph *depsgraph;
177 struct ViewLayer *view_layer;
178 } DEGEditorUpdateContext;
180 typedef void (*DEG_EditorUpdateIDCb)(
181 const DEGEditorUpdateContext *update_ctx,
183 typedef void (*DEG_EditorUpdateSceneCb)(
184 const DEGEditorUpdateContext *update_ctx, int updated);
186 /* Set callbacks which are being called when depsgraph changes. */
187 void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func,
188 DEG_EditorUpdateSceneCb scene_func);
190 /* Evaluation ----------------------------------- */
192 bool DEG_is_active(const struct Depsgraph *depsgraph);
193 void DEG_make_active(struct Depsgraph *depsgraph);
194 void DEG_make_inactive(struct Depsgraph *depsgraph);
196 /* Evaluation Debug ------------------------------ */
198 bool DEG_debug_is_evaluating(struct Depsgraph *depsgraph);
200 void DEG_debug_print_begin(struct Depsgraph *depsgraph);
202 void DEG_debug_print_eval(struct Depsgraph *depsgraph,
203 const char *function_name,
204 const char *object_name,
205 const void *object_address);
207 void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph,
208 const char *function_name,
209 const char *object_name,
210 const void *object_address,
211 const char *subdata_comment,
212 const char *subdata_name,
213 const void *subdata_address);
215 void DEG_debug_print_eval_subdata_index(struct Depsgraph *depsgraph,
216 const char *function_name,
217 const char *object_name,
218 const void *object_address,
219 const char *subdata_comment,
220 const char *subdata_name,
221 const void *subdata_address,
222 const int subdata_index);
224 void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph,
225 const char *function_name,
226 const char *object_name,
227 const void *object_address,
228 const char *parent_comment,
229 const char *parent_name,
230 const void *parent_address);
232 void DEG_debug_print_eval_time(struct Depsgraph *depsgraph,
233 const char *function_name,
234 const char *object_name,
235 const void *object_address,
242 #endif /* __DEG_DEPSGRAPH_H__ */