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 
20 /** \file
21  * \ingroup depsgraph
22  *
23  * Public API for Depsgraph
24  */
25 
26 #pragma once
27 
28 /* ************************************************* */
29 
30 /* Dependency Graph */
31 struct Depsgraph;
32 
33 /* ------------------------------------------------ */
34 
35 struct CacheFile;
36 struct CustomData_MeshMasks;
37 struct ID;
38 struct Main;
39 struct Object;
40 struct Scene;
41 struct Simulation;
42 struct ViewLayer;
43 struct bNodeTree;
44 
45 #include "BLI_sys_types.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /* Graph Building -------------------------------- */
52 
53 /* Build depsgraph for the given scene, and dump results in given graph container. */
54 void DEG_graph_build_from_view_layer(struct Depsgraph *graph);
55 
56 /* Build depsgraph for all objects (so also invisible ones) in the given view layer. */
57 void DEG_graph_build_for_all_objects(struct Depsgraph *graph);
58 
59 /* Special version of builder which produces dependency graph suitable for the render pipeline.
60  * It will contain sequencer and compositor (if needed) and all their dependencies. */
61 void DEG_graph_build_for_render_pipeline(struct Depsgraph *graph);
62 
63 /* Builds minimal dependency graph for compositor preview.
64  *
65  * Note that compositor editor might have pinned node tree, which is different from scene's node
66  * tree.
67  */
68 void DEG_graph_build_for_compositor_preview(struct Depsgraph *graph, struct bNodeTree *nodetree);
69 
70 void DEG_graph_build_from_ids(struct Depsgraph *graph, struct ID **ids, const int num_ids);
71 
72 /* Tag relations from the given graph for update. */
73 void DEG_graph_tag_relations_update(struct Depsgraph *graph);
74 
75 /* Create or update relations in the specified graph. */
76 void DEG_graph_relations_update(struct Depsgraph *graph);
77 
78 /* Tag all relations in the database for update.*/
79 void DEG_relations_tag_update(struct Main *bmain);
80 
81 /* Add Dependencies  ----------------------------- */
82 
83 /* Handle for components to define their dependencies from callbacks.
84  * This is generated by the depsgraph and passed to dependency callbacks
85  * as a symbolic reference to the current DepsNode.
86  * All relations will be defined in reference to that node.
87  */
88 struct DepsNodeHandle;
89 
90 typedef enum eDepsSceneComponentType {
91   /* Parameters Component - Default when nothing else fits
92    * (i.e. just SDNA property setting). */
93   DEG_SCENE_COMP_PARAMETERS,
94   /* Animation Component
95    * TODO(sergey): merge in with parameters?  */
96   DEG_SCENE_COMP_ANIMATION,
97   /* Sequencer Component (Scene Only). */
98   DEG_SCENE_COMP_SEQUENCER,
99 } eDepsSceneComponentType;
100 
101 typedef enum eDepsObjectComponentType {
102   /* Used in query API, to denote which component caller is interested in. */
103   DEG_OB_COMP_ANY,
104 
105   /* Parameters Component - Default when nothing else fits
106    * (i.e. just SDNA property setting). */
107   DEG_OB_COMP_PARAMETERS,
108   /* Generic "Proxy-Inherit" Component.
109    * TODO(sergey): Also for instancing of subgraphs? */
110   DEG_OB_COMP_PROXY,
111   /* Animation Component.
112    *
113    * TODO(sergey): merge in with parameters? */
114   DEG_OB_COMP_ANIMATION,
115   /* Transform Component (Parenting/Constraints) */
116   DEG_OB_COMP_TRANSFORM,
117   /* Geometry Component (Mesh/Displist) */
118   DEG_OB_COMP_GEOMETRY,
119 
120   /* Evaluation-Related Outer Types (with Sub-data) */
121 
122   /* Pose Component - Owner/Container of Bones Eval */
123   DEG_OB_COMP_EVAL_POSE,
124   /* Bone Component - Child/Sub-component of Pose */
125   DEG_OB_COMP_BONE,
126 
127   /* Material Shading Component */
128   DEG_OB_COMP_SHADING,
129   /* Cache Component */
130   DEG_OB_COMP_CACHE,
131 } eDepsObjectComponentType;
132 
133 void DEG_add_scene_relation(struct DepsNodeHandle *node_handle,
134                             struct Scene *scene,
135                             eDepsSceneComponentType component,
136                             const char *description);
137 void DEG_add_object_relation(struct DepsNodeHandle *node_handle,
138                              struct Object *object,
139                              eDepsObjectComponentType component,
140                              const char *description);
141 void DEG_add_simulation_relation(struct DepsNodeHandle *node_handle,
142                                  struct Simulation *simulation,
143                                  const char *description);
144 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
145                            struct Object *object,
146                            const char *bone_name,
147                            eDepsObjectComponentType component,
148                            const char *description);
149 void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
150                                    struct CacheFile *cache_file,
151                                    eDepsObjectComponentType component,
152                                    const char *description);
153 /* Adds relation from DEG_OPCODE_GENERIC_DATABLOCK_UPDATE of a given ID.
154  * Is used for such entities as textures and images. */
155 void DEG_add_generic_id_relation(struct DepsNodeHandle *node_handle,
156                                  struct ID *id,
157                                  const char *description);
158 
159 /* Special function which is used from modifiers' updateDepsgraph() callback
160  * to indicate that the modifier needs to know transformation of the object
161  * which that modifier belongs to.
162  * This function will take care of checking which operation is required to
163  * have transformation for the modifier, taking into account possible simulation
164  * solvers. */
165 void DEG_add_modifier_to_transform_relation(struct DepsNodeHandle *node_handle,
166                                             const char *description);
167 
168 /* Adds relations from the given component of a given object to the given node
169  * handle AND the component to the point cache component of the node's ID. */
170 void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle,
171                                         struct Object *object,
172                                         eDepsObjectComponentType component,
173                                         const char *description);
174 
175 void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, uint32_t flag);
176 void DEG_add_customdata_mask(struct DepsNodeHandle *handle,
177                              struct Object *object,
178                              const struct CustomData_MeshMasks *masks);
179 
180 struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle);
181 struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle);
182 
183 /* ************************************************ */
184 
185 #ifdef __cplusplus
186 } /* extern "C" */
187 #endif
188