Depsgraph: Ensure root pchan is always found
[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 Main;
44 struct Scene;
45 struct Group;
46 struct EffectorWeights;
47 struct ModifierData;
48 struct Object;
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /* Graph Building -------------------------------- */
55
56 /* Build depsgraph for the given scene, and dump results in given
57  * graph container.
58  */
59 void DEG_graph_build_from_scene(struct Depsgraph *graph,
60                                 struct Main *bmain,
61                                 struct Scene *scene);
62
63 /* Tag relations from the given graph for update. */
64 void DEG_graph_tag_relations_update(struct Depsgraph *graph);
65
66 /* Tag all relations in the database for update.*/
67 void DEG_relations_tag_update(struct Main *bmain);
68
69 /* Create new graph if didn't exist yet,
70  * or update relations if graph was tagged for update.
71  */
72 void DEG_scene_relations_update(struct Main *bmain, struct Scene *scene);
73
74 /* Rebuild dependency graph only for a given scene. */
75 void DEG_scene_relations_rebuild(struct Main *bmain,
76                                  struct Scene *scene);
77
78 /* Delete scene graph. */
79 void DEG_scene_graph_free(struct Scene *scene);
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 struct CacheFile;
91 struct Object;
92
93 typedef enum eDepsSceneComponentType {
94         /* Parameters Component - Default when nothing else fits
95          * (i.e. just SDNA property setting).
96          */
97         DEG_SCENE_COMP_PARAMETERS,
98         /* Animation Component
99          * TODO(sergey): merge in with parameters?
100          */
101         DEG_SCENE_COMP_ANIMATION,
102         /* Sequencer Component (Scene Only). */
103         DEG_SCENE_COMP_SEQUENCER,
104 } eDepsSceneComponentType;
105
106 typedef enum eDepsObjectComponentType {
107         /* Parameters Component - Default when nothing else fits
108          * (i.e. just SDNA property setting).
109          */
110         DEG_OB_COMP_PARAMETERS,
111         /* Generic "Proxy-Inherit" Component.
112          * TODO(sergey): Also for instancing of subgraphs?
113          */
114         DEG_OB_COMP_PROXY,
115         /* Animation Component.
116          *
117          * TODO(sergey): merge in with parameters?
118          */
119         DEG_OB_COMP_ANIMATION,
120         /* Transform Component (Parenting/Constraints) */
121         DEG_OB_COMP_TRANSFORM,
122         /* Geometry Component (DerivedMesh/Displist) */
123         DEG_OB_COMP_GEOMETRY,
124
125         /* Evaluation-Related Outer Types (with Subdata) */
126
127         /* Pose Component - Owner/Container of Bones Eval */
128         DEG_OB_COMP_EVAL_POSE,
129         /* Bone Component - Child/Subcomponent of Pose */
130         DEG_OB_COMP_BONE,
131
132         /* Particle Systems Component */
133         DEG_OB_COMP_EVAL_PARTICLES,
134         /* Material Shading Component */
135         DEG_OB_COMP_SHADING,
136         /* Cache Component */
137         DEG_OB_COMP_CACHE,
138 } eDepsObjectComponentType;
139
140 void DEG_add_scene_relation(struct DepsNodeHandle *node,
141                             struct Scene *scene,
142                             eDepsSceneComponentType component,
143                             const char *description);
144 void DEG_add_object_relation(struct DepsNodeHandle *node,
145                              struct Object *object,
146                              eDepsObjectComponentType component,
147                              const char *description);
148 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
149                            struct Object *object,
150                            const char *bone_name,
151                            eDepsObjectComponentType component,
152                            const char *description);
153 void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
154                                    struct CacheFile *cache_file,
155                                    eDepsObjectComponentType component,
156                                    const char *description);
157
158
159 struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle);
160 void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag);
161
162 /* Utility functions for physics modifiers */
163 typedef bool (*DEG_CollobjFilterFunction)(struct Object *obj, struct ModifierData *md);
164
165 void DEG_add_collision_relations(struct DepsNodeHandle *handle,
166                                  struct Scene *scene,
167                                  struct Object *object,
168                                  struct Group *group,
169                                  int layer,
170                                  unsigned int modifier_type,
171                                  DEG_CollobjFilterFunction fn,
172                                  bool dupli,
173                                  const char *name);
174 void DEG_add_forcefield_relations(struct DepsNodeHandle *handle,
175                                   struct Scene *scene,
176                                   struct Object *object,
177                                   struct EffectorWeights *eff,
178                                   bool add_absorption,
179                                   int skip_forcefield,
180                                   const char *name);
181
182 /* ************************************************ */
183
184 #ifdef __cplusplus
185 } /* extern "C" */
186 #endif
187
188 #endif  /* __DEG_DEPSGRAPH_BUILD_H__ */