Blender V4.3
deg_builder_relations.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <cstdio>
12#include <cstring>
13
15
16#include "DNA_ID.h"
17
18#include "RNA_path.hh"
19
20#include "BLI_span.hh"
21#include "BLI_string.h"
22#include "BLI_utildefines.h"
23
29#include "intern/depsgraph.hh"
34
35struct CacheFile;
36struct Camera;
37struct Collection;
38struct EffectorWeights;
39struct FCurve;
40struct FreestyleLineSet;
42struct ID;
43struct IDProperty;
44struct Image;
45struct Key;
46struct LayerCollection;
47struct Light;
48struct LightProbe;
49struct ListBase;
50struct Main;
51struct Mask;
52struct Material;
53struct MovieClip;
54struct Object;
55struct ParticleSettings;
56struct ParticleSystem;
57struct Scene;
58struct Speaker;
59struct Tex;
60struct VFont;
61struct ViewLayer;
62struct World;
63struct bAction;
64struct bArmature;
65struct bConstraint;
66struct bNodeSocket;
67struct bNodeTree;
68struct bPoseChannel;
69struct bSound;
70
71namespace blender::deg {
72
73struct ComponentNode;
74struct DepsNodeHandle;
75struct Depsgraph;
77struct IDNode;
78struct Node;
79struct OperationNode;
80struct Relation;
81struct RootPChanMap;
82struct TimeSourceNode;
83
85 public:
87
88 void begin_build();
89
90 template<typename KeyFrom, typename KeyTo>
91 Relation *add_relation(const KeyFrom &key_from,
92 const KeyTo &key_to,
93 const char *description,
94 int flags = 0);
95
96 template<typename KeyTo>
97 Relation *add_relation(const TimeSourceKey &key_from,
98 const KeyTo &key_to,
99 const char *description,
100 int flags = 0);
101
102 template<typename KeyType>
103 Relation *add_node_handle_relation(const KeyType &key_from,
104 const DepsNodeHandle *handle,
105 const char *description,
106 int flags = 0);
107
108 template<typename KeyTo>
110 const KeyTo &key_to,
111 const char *description,
112 int flags = 0);
113
114 /* Adds relation from proper transformation operation to the modifier.
115 * Takes care of checking for possible physics solvers modifying position
116 * of this object. */
117 void add_depends_on_transform_relation(const DepsNodeHandle *handle, const char *description);
118
119 void add_customdata_mask(Object *object, const DEGCustomDataMeshMasks &customdata_masks);
121
122 virtual void build_id(ID *id);
123
124 /* Build function for ID types that do not need their own build_xxx() function. */
125 virtual void build_generic_id(ID *id);
126
127 virtual void build_idproperties(IDProperty *id_property);
128
129 virtual void build_scene_camera(Scene *scene);
130 virtual void build_scene_render(Scene *scene, ViewLayer *view_layer);
131 virtual void build_scene_parameters(Scene *scene);
132 virtual void build_scene_compositor(Scene *scene);
133
134 virtual bool build_layer_collection(LayerCollection *layer_collection);
135 virtual void build_view_layer_collections(ViewLayer *view_layer);
136
137 virtual void build_view_layer(Scene *scene,
138 ViewLayer *view_layer,
139 eDepsNode_LinkedState_Type linked_state);
140 virtual void build_collection(LayerCollection *from_layer_collection, Collection *collection);
141 virtual void build_object(Object *object);
142 virtual void build_object_from_view_layer_base(Object *object);
144 virtual void build_object_modifiers(Object *object);
145 virtual void build_object_data(Object *object);
146 virtual void build_object_data_camera(Object *object);
147 virtual void build_object_data_geometry(Object *object);
148 virtual void build_object_data_geometry_datablock(ID *obdata);
149 virtual void build_object_data_light(Object *object);
150 virtual void build_object_data_lightprobe(Object *object);
151 virtual void build_object_data_speaker(Object *object);
152 virtual void build_object_parent(Object *object);
153 virtual void build_object_pointcache(Object *object);
154 virtual void build_object_instance_collection(Object *object);
155
156 virtual void build_object_shading(Object *object);
157
158 virtual void build_object_light_linking(Object *emitter);
159 virtual void build_light_linking_collection(Object *emitter, Collection *collection);
160
161 virtual void build_constraints(ID *id,
162 NodeType component_type,
163 const char *component_subdata,
165 RootPChanMap *root_map);
166 virtual void build_animdata(ID *id);
167 virtual void build_animdata_curves(ID *id);
168 virtual void build_animdata_fcurve_target(ID *id,
169 PointerRNA id_ptr,
170 ComponentKey &adt_key,
171 OperationNode *operation_from,
172 FCurve *fcu);
173 virtual void build_animdata_curves_targets(ID *id,
174 ComponentKey &adt_key,
175 OperationNode *operation_from,
176 ListBase *curves);
177 virtual void build_animdata_action_targets(ID *id,
178 int32_t slot_handle,
179 ComponentKey &adt_key,
180 OperationNode *operation_from,
181 bAction *action);
182 virtual void build_animdata_nlastrip_targets(ID *id,
183 ComponentKey &adt_key,
184 OperationNode *operation_from,
185 ListBase *strips);
186 virtual void build_animdata_drivers(ID *id);
187 virtual void build_animdata_force(ID *id);
188 virtual void build_animation_images(ID *id);
189 virtual void build_action(bAction *action);
190 virtual void build_driver(ID *id, FCurve *fcurve);
191 virtual void build_driver_data(ID *id, FCurve *fcurve);
192 virtual void build_driver_variables(ID *id, FCurve *fcurve);
193
194 virtual void build_driver_scene_camera_variable(const OperationKey &driver_key,
195 const RNAPathKey &self_key,
196 Scene *scene,
197 const char *rna_path);
198 virtual void build_driver_rna_path_variable(const OperationKey &driver_key,
199 const RNAPathKey &self_key,
200 ID *target_id,
201 const PointerRNA &target_prop,
202 const char *rna_path);
203
204 /* Build operations of a property value from which is read by a driver target.
205 *
206 * The driver target points to a data-block (or a sub-data-block like View Layer).
207 * This data-block is presented in the interface as a "Prop" and its resolved RNA pointer is
208 * passed here as `target_prop`.
209 *
210 * The tricky part (and a bit confusing naming) is that the driver target accesses a property of
211 * the `target_prop` to get its value. The property which is read to give an actual target value
212 * is denoted by its RNA path relative to the `target_prop`. In the interface it is called "Path"
213 * and here it is called `rna_path_from_target_prop`. */
214 virtual void build_driver_id_property(const PointerRNA &target_prop,
215 const char *rna_path_from_target_prop);
216
217 virtual void build_parameters(ID *id);
218 virtual void build_dimensions(Object *object);
219 virtual void build_world(World *world);
220 virtual void build_rigidbody(Scene *scene);
221 virtual void build_particle_systems(Object *object);
222 virtual void build_particle_settings(ParticleSettings *part);
224 ParticleSystem *psys,
225 Object *draw_object);
226 virtual void build_ik_pose(Object *object,
227 bPoseChannel *pchan,
228 bConstraint *con,
229 RootPChanMap *root_map);
230 virtual void build_splineik_pose(Object *object,
231 bPoseChannel *pchan,
232 bConstraint *con,
233 RootPChanMap *root_map);
234 virtual void build_inter_ik_chains(Object *object,
235 const OperationKey &solver_key,
236 const bPoseChannel *rootchan,
237 const RootPChanMap *root_map);
238 virtual void build_rig(Object *object);
239 virtual void build_shapekeys(Key *key);
240 virtual void build_armature(bArmature *armature);
241 virtual void build_armature_bones(ListBase *bones);
243 virtual void build_camera(Camera *camera);
244 virtual void build_light(Light *lamp);
245 virtual void build_nodetree(bNodeTree *ntree);
246 virtual void build_nodetree_socket(bNodeSocket *socket);
247 virtual void build_material(Material *ma, ID *owner = nullptr);
248 virtual void build_materials(ID *owner, Material **materials, int num_materials);
249 virtual void build_freestyle_lineset(FreestyleLineSet *fls);
250 virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle);
251 virtual void build_texture(Tex *tex);
252 virtual void build_image(Image *image);
253 virtual void build_cachefile(CacheFile *cache_file);
254 virtual void build_mask(Mask *mask);
255 virtual void build_movieclip(MovieClip *clip);
256 virtual void build_lightprobe(LightProbe *probe);
257 virtual void build_speaker(Speaker *speaker);
258 virtual void build_sound(bSound *sound);
259 virtual void build_scene_sequencer(Scene *scene);
260 virtual void build_scene_audio(Scene *scene);
261 virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer);
262 virtual void build_vfont(VFont *vfont);
263
264 virtual void build_nested_datablock(ID *owner, ID *id, bool flush_cow_changes);
265 virtual void build_nested_nodetree(ID *owner, bNodeTree *ntree);
266 virtual void build_nested_shapekey(ID *owner, Key *key);
267
269 Object *object,
270 Collection *collection,
271 const char *name);
273 Object *object,
274 ParticleSystem *psys,
275 EffectorWeights *eff,
276 bool add_absorption,
277 const char *name);
278
279 virtual void build_copy_on_write_relations();
280 virtual void build_copy_on_write_relations(IDNode *id_node);
281 virtual void build_driver_relations();
282 virtual void build_driver_relations(IDNode *id_node);
283
284 template<typename KeyType> OperationNode *find_operation_node(const KeyType &key);
285
287
288 protected:
289 TimeSourceNode *get_node(const TimeSourceKey &key) const;
290 ComponentNode *get_node(const ComponentKey &key) const;
291 OperationNode *get_node(const OperationKey &key) const;
292 Node *get_node(const RNAPathKey &key);
293
294 OperationNode *find_node(const OperationKey &key) const;
295 ComponentNode *find_node(const ComponentKey &key) const;
296 bool has_node(const ComponentKey &key) const;
297 bool has_node(const OperationKey &key) const;
298
300 Node *node_to,
301 const char *description,
302 int flags = 0);
303
304 /* Add relation which ensures visibility of `id_from` when `id_to` is visible.
305 * For the more detailed explanation see comment for `NodeType::VISIBILITY`. */
306 void add_visibility_relation(ID *id_from, ID *id_to);
307
309 OperationNode *node_to,
310 const char *description,
311 int flags = 0);
312
313 template<typename KeyType>
314 DepsNodeHandle create_node_handle(const KeyType &key, const char *default_name = "");
315
316 /* TODO(sergey): All those is_same* functions are to be generalized. */
317
318 /* Check whether two keys corresponds to the same bone from same armature.
319 *
320 * This is used by drivers relations builder to avoid possible fake
321 * dependency cycle when one bone property drives another property of the
322 * same bone. */
323 template<typename KeyFrom, typename KeyTo>
324 bool is_same_bone_dependency(const KeyFrom &key_from, const KeyTo &key_to);
325
326 /* Similar to above, but used to check whether driver is using node from
327 * the same node tree as a driver variable. */
328 template<typename KeyFrom, typename KeyTo>
329 bool is_same_nodetree_node_dependency(const KeyFrom &key_from, const KeyTo &key_to);
330
331 private:
332 struct BuilderWalkUserData {
334 };
335
336 static void modifier_walk(void *user_data,
337 struct Object *object,
338 struct ID **idpoin,
339 int cb_flag);
340
341 static void constraint_walk(bConstraint *con, ID **idpoin, bool is_reference, void *user_data);
342
343 /* State which demotes currently built entities. */
344 Scene *scene_;
345
346 BuilderMap built_map_;
347 RNANodeQuery rna_node_query_;
348 BuilderStack stack_;
349};
350
364
365} // namespace blender::deg
366
#define BLI_assert(a)
Definition BLI_assert.h:50
ID and Library types, which are fundamental for SDNA.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between world
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
virtual void build_driver_rna_path_variable(const OperationKey &driver_key, const RNAPathKey &self_key, ID *target_id, const PointerRNA &target_prop, const char *rna_path)
void add_particle_collision_relations(const OperationKey &key, Object *object, Collection *collection, const char *name)
virtual void build_animdata_action_targets(ID *id, int32_t slot_handle, ComponentKey &adt_key, OperationNode *operation_from, bAction *action)
Relation * add_depends_on_transform_relation(ID *id, const KeyTo &key_to, const char *description, int flags=0)
virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle)
virtual void build_ik_pose(Object *object, bPoseChannel *pchan, bConstraint *con, RootPChanMap *root_map)
virtual void build_collection(LayerCollection *from_layer_collection, Collection *collection)
virtual void build_driver_id_property(const PointerRNA &target_prop, const char *rna_path_from_target_prop)
virtual void build_object_layer_component_relations(Object *object)
virtual void build_object_from_view_layer_base(Object *object)
virtual void build_driver(ID *id, FCurve *fcurve)
virtual void build_driver_data(ID *id, FCurve *fcurve)
virtual void build_nested_nodetree(ID *owner, bNodeTree *ntree)
virtual void build_nodetree_socket(bNodeSocket *socket)
virtual void build_material(Material *ma, ID *owner=nullptr)
virtual void build_speaker(Speaker *speaker)
TimeSourceNode * get_node(const TimeSourceKey &key) const
bool is_same_nodetree_node_dependency(const KeyFrom &key_from, const KeyTo &key_to)
virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer)
OperationNode * find_node(const OperationKey &key) const
virtual void build_armature(bArmature *armature)
virtual void build_armature_bone_collections(blender::Span< BoneCollection * > collections)
virtual void build_view_layer(Scene *scene, ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state)
virtual void build_armature_bones(ListBase *bones)
virtual void build_object_pointcache(Object *object)
virtual void build_constraints(ID *id, NodeType component_type, const char *component_subdata, ListBase *constraints, RootPChanMap *root_map)
virtual void build_object_modifiers(Object *object)
virtual void build_animdata_curves_targets(ID *id, ComponentKey &adt_key, OperationNode *operation_from, ListBase *curves)
virtual void build_view_layer_collections(ViewLayer *view_layer)
virtual void build_object_data_light(Object *object)
void add_customdata_mask(Object *object, const DEGCustomDataMeshMasks &customdata_masks)
bool is_same_bone_dependency(const KeyFrom &key_from, const KeyTo &key_to)
Relation * add_node_handle_relation(const KeyType &key_from, const DepsNodeHandle *handle, const char *description, int flags=0)
virtual void build_object_data_camera(Object *object)
virtual void build_scene_render(Scene *scene, ViewLayer *view_layer)
virtual void build_object_data_geometry(Object *object)
DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
virtual void build_object_data_lightprobe(Object *object)
virtual void build_particle_settings(ParticleSettings *part)
virtual void build_object_light_linking(Object *emitter)
void add_special_eval_flag(ID *id, uint32_t flag)
virtual void build_driver_scene_camera_variable(const OperationKey &driver_key, const RNAPathKey &self_key, Scene *scene, const char *rna_path)
virtual void build_movieclip(MovieClip *clip)
virtual void build_nodetree(bNodeTree *ntree)
Relation * add_relation(const KeyFrom &key_from, const KeyTo &key_to, const char *description, int flags=0)
virtual void build_object_data_geometry_datablock(ID *obdata)
virtual void build_animdata_fcurve_target(ID *id, PointerRNA id_ptr, ComponentKey &adt_key, OperationNode *operation_from, FCurve *fcu)
void add_particle_forcefield_relations(const OperationKey &key, Object *object, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name)
virtual void build_nested_datablock(ID *owner, ID *id, bool flush_cow_changes)
virtual void build_particle_system_visualization_object(Object *object, ParticleSystem *psys, Object *draw_object)
virtual void build_lightprobe(LightProbe *probe)
void add_visibility_relation(ID *id_from, ID *id_to)
virtual void build_splineik_pose(Object *object, bPoseChannel *pchan, bConstraint *con, RootPChanMap *root_map)
virtual void build_driver_variables(ID *id, FCurve *fcurve)
virtual bool build_layer_collection(LayerCollection *layer_collection)
virtual void build_object_instance_collection(Object *object)
virtual void build_nested_shapekey(ID *owner, Key *key)
virtual void build_object_parent(Object *object)
bool has_node(const ComponentKey &key) const
virtual void build_inter_ik_chains(Object *object, const OperationKey &solver_key, const bPoseChannel *rootchan, const RootPChanMap *root_map)
virtual void build_object_data_speaker(Object *object)
virtual void build_freestyle_lineset(FreestyleLineSet *fls)
virtual void build_light_linking_collection(Object *emitter, Collection *collection)
Relation * add_operation_relation(OperationNode *node_from, OperationNode *node_to, const char *description, int flags=0)
OperationNode * find_operation_node(const KeyType &key)
virtual void build_object_data(Object *object)
virtual void build_idproperties(IDProperty *id_property)
virtual void build_materials(ID *owner, Material **materials, int num_materials)
virtual void build_cachefile(CacheFile *cache_file)
virtual void build_object_shading(Object *object)
DepsNodeHandle create_node_handle(const KeyType &key, const char *default_name="")
virtual void build_animdata_nlastrip_targets(ID *id, ComponentKey &adt_key, OperationNode *operation_from, ListBase *strips)
Relation * add_time_relation(TimeSourceNode *timesrc, Node *node_to, const char *description, int flags=0)
virtual void build_particle_systems(Object *object)
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
unsigned int uint32_t
Definition stdint.h:80
signed int int32_t
Definition stdint.h:77
Definition DNA_ID.h:413
DepsgraphRelationBuilder * builder
DepsNodeHandle(DepsgraphRelationBuilder *builder, OperationNode *node, const char *default_name="")
uint8_t flag
Definition wm_window.cc:138