Merge branch 'master' into blender2.8
[blender.git] / source / blender / depsgraph / DEG_depsgraph_build.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2013 Blender Foundation.
19  * All rights reserved.
20  *
21  * Original Author: Joshua Leung
22  * Contributor(s): Lukas Toenne
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/depsgraph/DEG_depsgraph_build.h
28  *  \ingroup depsgraph
29  *
30  * Public API for Depsgraph
31  */
32
33 #ifndef __DEG_DEPSGRAPH_BUILD_H__
34 #define __DEG_DEPSGRAPH_BUILD_H__
35
36 /* ************************************************* */
37
38 /* Dependency Graph */
39 struct Depsgraph;
40
41 /* ------------------------------------------------ */
42
43 struct CacheFile;
44 struct EffectorWeights;
45 struct EvaluationContext;
46 struct Group;
47 struct Main;
48 struct ModifierData;
49 struct Object;
50 struct Scene;
51 struct ViewLayer;
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 /* Graph Building -------------------------------- */
58
59 /* Build depsgraph for the given scene, and dump results in given
60  * graph container.
61  */
62 void DEG_graph_build_from_view_layer(struct Depsgraph *graph,
63                                       struct Main *bmain,
64                                       struct Scene *scene,
65                                       struct ViewLayer *view_layer);
66
67 /* Tag relations from the given graph for update. */
68 void DEG_graph_tag_relations_update(struct Depsgraph *graph);
69
70 /* Create or update relations in the specified graph. */
71 void DEG_graph_relations_update(struct Depsgraph *graph,
72                                 struct Main *bmain,
73                                 struct Scene *scene,
74                                 struct ViewLayer *view_layer);
75
76 /* Tag all relations in the database for update.*/
77 void DEG_relations_tag_update(struct Main *bmain);
78
79 /* Add Dependencies  ----------------------------- */
80
81 /* Handle for components to define their dependencies from callbacks.
82  * This is generated by the depsgraph and passed to dependency callbacks
83  * as a symbolic reference to the current DepsNode.
84  * All relations will be defined in reference to that node.
85  */
86 struct DepsNodeHandle;
87
88 typedef enum eDepsSceneComponentType {
89         /* Parameters Component - Default when nothing else fits
90          * (i.e. just SDNA property setting).
91          */
92         DEG_SCENE_COMP_PARAMETERS,
93         /* Animation Component
94          * TODO(sergey): merge in with parameters?
95          */
96         DEG_SCENE_COMP_ANIMATION,
97         /* Sequencer Component (Scene Only). */
98         DEG_SCENE_COMP_SEQUENCER,
99 } eDepsSceneComponentType;
100
101 typedef enum eDepsObjectComponentType {
102         /* Parameters Component - Default when nothing else fits
103          * (i.e. just SDNA property setting).
104          */
105         DEG_OB_COMP_PARAMETERS,
106         /* Generic "Proxy-Inherit" Component.
107          * TODO(sergey): Also for instancing of subgraphs?
108          */
109         DEG_OB_COMP_PROXY,
110         /* Animation Component.
111          *
112          * TODO(sergey): merge in with parameters?
113          */
114         DEG_OB_COMP_ANIMATION,
115         /* Transform Component (Parenting/Constraints) */
116         DEG_OB_COMP_TRANSFORM,
117         /* Geometry Component (DerivedMesh/Displist) */
118         DEG_OB_COMP_GEOMETRY,
119
120         /* Evaluation-Related Outer Types (with Subdata) */
121
122         /* Pose Component - Owner/Container of Bones Eval */
123         DEG_OB_COMP_EVAL_POSE,
124         /* Bone Component - Child/Subcomponent of Pose */
125         DEG_OB_COMP_BONE,
126
127         /* Particle Systems Component */
128         DEG_OB_COMP_EVAL_PARTICLES,
129         /* Material Shading Component */
130         DEG_OB_COMP_SHADING,
131         /* Cache Component */
132         DEG_OB_COMP_CACHE,
133 } eDepsObjectComponentType;
134
135 void DEG_add_scene_relation(struct DepsNodeHandle *node,
136                             struct Scene *scene,
137                             eDepsSceneComponentType component,
138                             const char *description);
139 void DEG_add_object_relation(struct DepsNodeHandle *node,
140                              struct Object *object,
141                              eDepsObjectComponentType component,
142                              const char *description);
143 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
144                            struct Object *object,
145                            const char *bone_name,
146                            eDepsObjectComponentType component,
147                            const char *description);
148 void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
149                                    struct CacheFile *cache_file,
150                                    eDepsObjectComponentType component,
151                                    const char *description);
152
153
154 struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle);
155 void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag);
156
157 /* Utility functions for physics modifiers */
158 typedef bool (*DEG_CollobjFilterFunction)(struct Object *obj, struct ModifierData *md);
159
160 void DEG_add_collision_relations(struct DepsNodeHandle *handle,
161                                  struct Scene *scene,
162                                  struct Object *object,
163                                  struct Group *group,
164                                  unsigned int modifier_type,
165                                  DEG_CollobjFilterFunction fn,
166                                  bool dupli,
167                                  const char *name);
168 void DEG_add_forcefield_relations(struct DepsNodeHandle *handle,
169                                   struct Scene *scene,
170                                   struct Object *object,
171                                   struct EffectorWeights *eff,
172                                   bool add_absorption,
173                                   int skip_forcefield,
174                                   const char *name);
175
176 /* ************************************************ */
177
178 #ifdef __cplusplus
179 } /* extern "C" */
180 #endif
181
182 #endif  /* __DEG_DEPSGRAPH_BUILD_H__ */