Blender V5.3
deg_builder_relations.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
12
13#include <cstdio>
14#include <cstdlib>
15#include <cstring> /* required for STREQ later on. */
16#include <optional>
17
18#include "BKE_global.hh"
19#include "DNA_modifier_types.h"
20
21#include "BLI_listbase.hh"
22#include "BLI_span.hh"
23#include "BLI_utildefines.hh"
24
25#include "DNA_action_types.h"
26#include "DNA_anim_types.h"
27#include "DNA_armature_types.h"
28#include "DNA_cachefile_types.h"
29#include "DNA_camera_types.h"
30#include "DNA_cloth_types.h"
33#include "DNA_curve_types.h"
34#include "DNA_curves_types.h"
36#include "DNA_key_types.h"
37#include "DNA_light_types.h"
39#include "DNA_linestyle_types.h"
40#include "DNA_mask_types.h"
41#include "DNA_material_types.h"
42#include "DNA_mesh_types.h"
43#include "DNA_movieclip_types.h"
44#include "DNA_node_types.h"
46#include "DNA_object_types.h"
47#include "DNA_particle_types.h"
48#include "DNA_rigidbody_types.h"
49#include "DNA_scene_types.h"
50#include "DNA_sequence_types.h"
51#include "DNA_sound_types.h"
52#include "DNA_speaker_types.h"
53#include "DNA_texture_types.h"
54#include "DNA_vfont_types.h"
55#include "DNA_volume_types.h"
56#include "DNA_world_types.h"
57
58#include "BKE_action.hh"
59#include "BKE_anim_data.hh"
60#include "BKE_collection.hh"
61#include "BKE_collision.h"
62#include "BKE_constraint.h"
63#include "BKE_effect.h"
64#include "BKE_fcurve_driver.h"
65#include "BKE_grease_pencil.hh"
67#include "BKE_idprop.hh"
68#include "BKE_image.hh"
69#include "BKE_key.hh"
70#include "BKE_layer.hh"
71#include "BKE_lib_query.hh"
72#include "BKE_mask.hh"
73#include "BKE_material.hh"
74#include "BKE_mball.hh"
75#include "BKE_modifier.hh"
76#include "BKE_nla.hh"
77#include "BKE_node.hh"
78#include "BKE_node_runtime.hh"
79#include "BKE_pointcache.h"
80#include "BKE_shader_fx.hh"
81#include "BKE_shrinkwrap.hh"
82
83#include "RNA_access.hh"
84#include "RNA_prototypes.hh"
85#include "RNA_types.hh"
86
87#include "ANIM_action.hh"
88#include "SEQ_iterator.hh"
89
90#include "DEG_depsgraph.hh"
93
100
106
107#include "intern/depsgraph.hh"
110
111namespace blender::deg {
112
113/* ***************** */
114/* Relations Builder */
115
116namespace {
117
118bool is_time_dependent_scene_driver_target(const DriverTarget *target)
119{
120 return target->rna_path != nullptr && STREQ(target->rna_path, "frame_current");
121}
122
123bool driver_target_depends_on_time(const DriverVar *variable, const DriverTarget *target)
124{
125 if (variable->type == DVAR_TYPE_CONTEXT_PROP &&
126 target->context_property == DTAR_CONTEXT_PROPERTY_ACTIVE_SCENE)
127 {
128 return is_time_dependent_scene_driver_target(target);
129 }
130
131 if (target->idtype == ID_SCE) {
132 return is_time_dependent_scene_driver_target(target);
133 }
134
135 return false;
136}
137
138bool driver_variable_depends_on_time(const DriverVar *variable)
139{
140 for (int i = 0; i < variable->num_targets; ++i) {
141 if (driver_target_depends_on_time(variable, &variable->targets[i])) {
142 return true;
143 }
144 }
145 return false;
146}
147
148bool driver_variables_depends_on_time(const ListBaseT<DriverVar> *variables)
149{
150 for (const DriverVar &variable : *variables) {
151 if (driver_variable_depends_on_time(&variable)) {
152 return true;
153 }
154 }
155 return false;
156}
157
158bool driver_depends_on_time(ChannelDriver *driver)
159{
161 return true;
162 }
163 if (driver_variables_depends_on_time(&driver->variables)) {
164 return true;
165 }
166 return false;
167}
168
169bool particle_system_depends_on_time(ParticleSystem *psys)
170{
171 ParticleSettings *part = psys->part;
172 /* Non-hair particles we always consider dependent on time. */
173 if (part->type != PART_HAIR) {
174 return true;
175 }
176 /* Dynamics always depends on time. */
177 if (psys->flag & PSYS_HAIR_DYNAMICS) {
178 return true;
179 }
180 /* TODO(sergey): Check what else makes hair dependent on time. */
181 return false;
182}
183
184bool object_particles_depends_on_time(Object *object)
185{
186 if (object->type != OB_MESH) {
187 return false;
188 }
189 for (ParticleSystem &psys : object->particlesystem) {
190 if (particle_system_depends_on_time(&psys)) {
191 return true;
192 }
193 }
194 return false;
195}
196
197bool check_id_has_anim_component(ID *id)
198{
199 AnimData *adt = BKE_animdata_from_id(id);
200 if (adt == nullptr) {
201 return false;
202 }
203 return (adt->action != nullptr) || !adt->nla_tracks.is_empty();
204}
205
206bool check_id_has_driver_component(ID *id)
207{
208 AnimData *adt = BKE_animdata_from_id(id);
209 if (adt == nullptr) {
210 return false;
211 }
212 return !adt->drivers.is_empty();
213}
214
215OperationCode bone_target_opcode(ID *target,
216 const char *subtarget,
217 ID *id,
218 const char *component_subdata,
219 RootPChanMap *root_map)
220{
221 /* Same armature. root_map will be nullptr when building object-level constraints, and in that
222 * case we don't need to check for the common chains. */
223 if (target == id && root_map != nullptr) {
224 /* Using "done" here breaks in-chain deps, while using
225 * "ready" here breaks most production rigs instead.
226 * So, we do a compromise here, and only do this when an
227 * IK chain conflict may occur. */
228 if (root_map->has_common_root(component_subdata, subtarget)) {
230 }
231 }
233}
234
235bool object_have_geometry_component(const Object *object)
236{
238}
239
240} // namespace
241
242/* **** General purpose functions **** */
243
245 Depsgraph *graph,
247 : DepsgraphBuilder(bmain, graph, cache), scene_(nullptr), rna_node_query_(graph, this)
248{
249}
250
255
257{
258 IDNode *id_node = graph_->find_id_node(key.id);
259 if (!id_node) {
260 fprintf(stderr,
261 "find_node component: Could not find ID %s\n",
262 (key.id != nullptr) ? key.id->name : "<null>");
263 return nullptr;
264 }
265
266 ComponentNode *node = id_node->find_component(key.type, key.name);
267 return node;
268}
269
271{
272 OperationNode *op_node = find_node(key);
273 if (op_node == nullptr) {
274 fprintf(stderr,
275 "find_node_operation: Failed for (%s, '%s')\n",
277 key.name);
278 }
279 return op_node;
280}
281
283{
284 return rna_node_query_.find_node(&key.ptr, key.prop, key.source);
285}
286
288{
289 IDNode *id_node = graph_->find_id_node(key.id);
290 if (!id_node) {
291 return nullptr;
292 }
293 return id_node->find_component(key.type, key.name);
294}
295
297{
298 IDNode *id_node = graph_->find_id_node(key.id);
299 if (!id_node) {
300 return nullptr;
301 }
302 ComponentNode *comp_node = id_node->find_component(key.component_type, key.component_name);
303 if (!comp_node) {
304 return nullptr;
305 }
306 return comp_node->find_operation(key.opcode, key.name, key.name_tag);
307}
308
310{
311 return find_node(key) != nullptr;
312}
313
315{
316 return find_node(key) != nullptr;
317}
318
320 const DepsNodeHandle *handle,
321 const char *description,
322 int flags)
323{
324 TimeSourceNode *time_from = get_node(key_from);
325 OperationNode *op_to = handle->node->get_entry_operation();
326 if (time_from != nullptr && op_to != nullptr) {
327 return add_time_relation(time_from, op_to, description, flags);
328 }
329 return nullptr;
330}
331
333 const char *description)
334{
335 IDNode *id_node = handle->node->owner->owner;
336 ID *id = id_node->id_orig;
337 const OperationKey geometry_key(
338 id, NodeType::GEOMETRY, OperationCode::MODIFIER, handle->node->name.c_str());
339 /* Wire up the actual relation. */
340 add_depends_on_transform_relation(id, geometry_key, description);
341}
342
344 const DEGCustomDataMeshMasks &customdata_masks)
345{
346 if (customdata_masks != DEGCustomDataMeshMasks() && object != nullptr && object->type == OB_MESH)
347 {
348 IDNode *id_node = graph_->find_id_node(&object->id);
349
350 if (id_node == nullptr) {
351 BLI_assert_msg(0, "ID should always be valid");
352 }
353 else {
354 id_node->customdata_masks |= customdata_masks;
355 }
356 }
357}
358
360{
361 IDNode *id_node = graph_->find_id_node(id);
362 if (id_node == nullptr) {
363 BLI_assert_msg(0, "ID should always be valid");
364 }
365 else {
366 id_node->eval_flags |= flag;
367 }
368}
369
371 Node *node_to,
372 const char *description,
373 int flags)
374{
375 if (timesrc && node_to) {
376 return graph_->add_new_relation(timesrc, node_to, description, flags);
377 }
378
379 DEG_DEBUG_PRINTF((blender::Depsgraph *)graph_,
380 BUILD,
381 "add_time_relation(%p = %s, %p = %s, %s) Failed\n",
382 timesrc,
383 (timesrc) ? timesrc->identifier().c_str() : "<None>",
384 node_to,
385 (node_to) ? node_to->identifier().c_str() : "<None>",
386 description);
387
388 return nullptr;
389}
390
392{
393 ComponentKey from_key(id_from, NodeType::VISIBILITY);
394 ComponentKey to_key(id_to, NodeType::VISIBILITY);
395 add_relation(from_key, to_key, "visibility");
396}
397
399 OperationNode *node_to,
400 const char *description,
401 int flags)
402{
403 if (node_from && node_to) {
404 return graph_->add_new_relation(node_from, node_to, description, flags);
405 }
406
407 DEG_DEBUG_PRINTF((blender::Depsgraph *)graph_,
408 BUILD,
409 "add_operation_relation(%p = %s, %p = %s, %s) Failed\n",
410 node_from,
411 (node_from) ? node_from->identifier().c_str() : "<None>",
412 node_to,
413 (node_to) ? node_to->identifier().c_str() : "<None>",
414 description);
415
416 return nullptr;
417}
418
420 Object *object,
421 Collection *collection,
422 const char *name)
423{
424 ListBaseT<CollisionRelation> *relations = build_collision_relations(
425 graph_, collection, eModifierType_Collision);
426
427 for (CollisionRelation &relation : *relations) {
428 if (relation.ob != object) {
429 ComponentKey trf_key(&relation.ob->id, NodeType::TRANSFORM);
430 add_relation(trf_key, key, name);
431
432 ComponentKey coll_key(&relation.ob->id, NodeType::GEOMETRY);
433 add_relation(coll_key, key, name);
434 }
435 }
436}
437
439 Object *object,
440 ParticleSystem *psys,
441 EffectorWeights *eff,
442 bool add_absorption,
443 const char *name)
444{
445 ListBaseT<EffectorRelation> *relations = build_effector_relations(graph_, eff->group);
446
447 /* Make sure physics effects like wind are properly re-evaluating the modifier stack. */
448 if (!relations->is_empty()) {
449 TimeSourceKey time_src_key;
450 ComponentKey geometry_key(&object->id, NodeType::GEOMETRY);
452 time_src_key, geometry_key, "Effector Time -> Particle", RELATION_CHECK_BEFORE_ADD);
453 }
454
455 for (EffectorRelation &relation : *relations) {
456 if (relation.ob != object) {
457 /* Relation to forcefield object, optionally including geometry. */
458 ComponentKey eff_key(&relation.ob->id, NodeType::TRANSFORM);
459 add_relation(eff_key, key, name);
460
461 if (ELEM(relation.pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) ||
462 relation.pd->forcefield == PFIELD_GUIDE)
463 {
464 ComponentKey mod_key(&relation.ob->id, NodeType::GEOMETRY);
465 add_relation(mod_key, key, name);
466 }
467
468 /* Force field Texture. */
469 if ((relation.pd != nullptr) && (relation.pd->forcefield == PFIELD_TEXTURE) &&
470 (relation.pd->tex != nullptr))
471 {
472 ComponentKey tex_key(&relation.pd->tex->id, NodeType::GENERIC_DATABLOCK);
473 add_relation(tex_key, key, "Force field Texture");
474 }
475
476 /* Smoke flow relations. */
477 if (relation.pd->forcefield == PFIELD_FLUIDFLOW && relation.pd->f_source) {
478 ComponentKey trf_key(&relation.pd->f_source->id, NodeType::TRANSFORM);
479 add_relation(trf_key, key, "Smoke Force Domain");
480 ComponentKey eff_key(&relation.pd->f_source->id, NodeType::GEOMETRY);
481 add_relation(eff_key, key, "Smoke Force Domain");
482 }
483
484 /* Absorption forces need collision relation. */
485 if (add_absorption && (relation.pd->flag & PFIELD_VISIBILITY)) {
486 add_particle_collision_relations(key, object, nullptr, "Force Absorption");
487 }
488 }
489
490 if (relation.psys) {
491 if (relation.ob != object) {
492 ComponentKey eff_key(&relation.ob->id, NodeType::PARTICLE_SYSTEM);
493 add_relation(eff_key, key, name);
494 /* TODO: remove this when/if EVAL_PARTICLES is sufficient
495 * for up to date particles. */
496 ComponentKey mod_key(&relation.ob->id, NodeType::GEOMETRY);
497 add_relation(mod_key, key, name);
498 }
499 else if (relation.psys != psys) {
500 OperationKey eff_key(&relation.ob->id,
503 relation.psys->name);
504 add_relation(eff_key, key, name);
505 }
506 }
507 }
508}
509
514
515/* **** Functions to build relations between entities **** */
516
518
520{
521 if (id == nullptr) {
522 return;
523 }
524
525 const ID_Type id_type = id->id_type();
526 switch (id_type) {
527 case ID_AC:
528 build_action(id_cast<bAction *>(id));
529 break;
530 case ID_AR:
531 build_armature(id_cast<bArmature *>(id));
532 break;
533 case ID_CA:
534 build_camera(id_cast<Camera *>(id));
535 break;
536 case ID_GR:
537 build_collection(nullptr, id_cast<Collection *>(id));
538 break;
539 case ID_OB:
540 build_object(id_cast<Object *>(id));
541 break;
542 case ID_KE:
543 build_shapekeys(id_cast<Key *>(id));
544 break;
545 case ID_LA:
546 build_light(id_cast<Light *>(id));
547 break;
548 case ID_LP:
549 build_lightprobe(id_cast<LightProbe *>(id));
550 break;
551 case ID_NT:
552 build_nodetree(id_cast<bNodeTree *>(id));
553 break;
554 case ID_MA:
555 build_material(id_cast<Material *>(id));
556 break;
557 case ID_TE:
558 build_texture(id_cast<Tex *>(id));
559 break;
560 case ID_IM:
561 build_image(id_cast<Image *>(id));
562 break;
563 case ID_WO:
564 build_world(id_cast<World *>(id));
565 break;
566 case ID_MSK:
567 build_mask(id_cast<Mask *>(id));
568 break;
569 case ID_LS:
570 build_freestyle_linestyle(id_cast<FreestyleLineStyle *>(id));
571 break;
572 case ID_MC:
573 build_movieclip(id_cast<MovieClip *>(id));
574 break;
575 case ID_ME:
576 case ID_MB:
577 case ID_CU_LEGACY:
578 case ID_LT:
579 case ID_CV:
580 case ID_PT:
581 case ID_VO:
582 case ID_GD_LEGACY:
583 case ID_GP:
585 break;
586 case ID_SPK:
587 build_speaker(id_cast<Speaker *>(id));
588 break;
589 case ID_SO:
590 build_sound(id_cast<bSound *>(id));
591 break;
592 case ID_TXT:
593 /* Not a part of dependency graph. */
594 break;
595 case ID_CF:
596 build_cachefile(id_cast<CacheFile *>(id));
597 break;
598 case ID_SCE:
599 build_scene_parameters(id_cast<Scene *>(id));
600 break;
601 case ID_PA:
602 build_particle_settings(id_cast<ParticleSettings *>(id));
603 break;
604 case ID_VF:
605 build_vfont((VFont *)id);
606 break;
607
608 case ID_LI:
609 case ID_SCR:
610 case ID_BR:
611 case ID_WM:
612 case ID_PAL:
613 case ID_PC:
614 case ID_WS:
617 break;
618 }
619}
620
622{
623 if (built_map_.check_is_built_and_tag(id)) {
624 return;
625 }
626
627 const BuilderStack::ScopedEntry stack_entry = stack_.trace(*id);
628
629 build_idproperties(id->properties);
630 build_idproperties(id->system_properties);
631 build_animdata(id);
633}
634
636{
637 IDP_foreach_property(id_property, IDP_TYPE_FILTER_ID, [&](IDProperty *id_property) {
638 this->build_id(static_cast<ID *>(id_property->data.pointer));
639 });
640}
641
643 Collection *collection)
644{
645 if (!built_map_.check_is_built_and_tag(collection, BuilderMap::TAG_COLLECTION_PROPERTIES)) {
646 build_idproperties(collection->id.properties);
648 build_parameters(&collection->id);
649 }
650
651 if (from_layer_collection != nullptr) {
652 /* If we came from layer collection we don't go deeper, view layer builder takes care of going
653 * deeper.
654 *
655 * NOTE: Do early output before tagging build as done, so possible subsequent builds from
656 * outside of the layer collection properly recurses into all the nested objects and
657 * collections. */
658
659 if (!built_map_.check_is_built_and_tag(collection,
661 {
662 const ComponentKey collection_hierarchy_key{&collection->id, NodeType::HIERARCHY};
663 OperationNode *collection_hierarchy_exit =
664 this->find_node(collection_hierarchy_key)->get_exit_operation();
665 for (CollectionObject &cob : collection->gobject) {
666 Object *object = cob.ob;
667 const ComponentKey object_hierarchy_key{&object->id, NodeType::HIERARCHY};
668 /* Check whether the object hierarchy node exists, because the view layer builder can skip
669 * bases if they are constantly excluded from the collections. */
670 if (Node *object_hierarchy_node = this->find_node(object_hierarchy_key)) {
671 /* Note that while view layer builder ensures objects are built first and only then layer
672 * collections are built, it is not possible to assert() here: the object might be pulled
673 * into the dependency graph via different indirections, and it might not have been
674 * traversed into at this point.
675 * This build_object() is more of a safety measure, which follows the common rule in the
676 * dependency graph builder: ensure the entity is built when you encounter it. */
677 build_object(object);
678 this->add_operation_relation(collection_hierarchy_exit,
679 object_hierarchy_node->get_entry_operation(),
680 "Collection -> Object hierarchy");
681 }
682 }
683 }
684
685 return;
686 }
687
688 if (built_map_.check_is_built_and_tag(collection)) {
689 return;
690 }
691
692 const BuilderStack::ScopedEntry stack_entry = stack_.trace(collection->id);
693
694 const OperationKey collection_geometry_key{
696
697 const ComponentKey collection_hierarchy_key{&collection->id, NodeType::HIERARCHY};
698 OperationNode *collection_hierarchy_exit =
699 this->find_node(collection_hierarchy_key)->get_exit_operation();
700
701 for (CollectionObject &cob : collection->gobject) {
702 Object *object = cob.ob;
703
704 build_object(object);
705
706 /* Unfortunately this may add duplicates with the hierarchy relations added below above. This
707 * is necessary though, for collections that are built as layer collections and otherwise,
708 * where an object may not be built yet in the layer collection case. */
709 const ComponentKey object_hierarchy_key{&object->id, NodeType::HIERARCHY};
710 Node *object_hierarchy_node = this->find_node(object_hierarchy_key);
711 this->add_operation_relation(collection_hierarchy_exit,
712 object_hierarchy_node->get_entry_operation(),
713 "Collection -> Object hierarchy");
714
715 const OperationKey object_instance_geometry_key{
717 add_relation(object_instance_geometry_key, collection_geometry_key, "Collection Geometry");
718
719 /* An instance is part of the geometry of the collection. */
720 if (object->type == OB_EMPTY) {
721 Collection *collection_instance = cob.ob->instance_collection;
722 if (collection_instance != nullptr) {
723 const OperationKey collection_instance_key{
725 add_relation(collection_instance_key, collection_geometry_key, "Collection Geometry");
726 }
727 }
728 }
729
730 for (CollectionChild &child : collection->children) {
731 build_collection(nullptr, child.collection);
732 const OperationKey child_collection_geometry_key{
734 add_relation(child_collection_geometry_key, collection_geometry_key, "Collection Geometry");
735 }
736}
737
739{
740 if (built_map_.check_is_built_and_tag(object)) {
741 return;
742 }
743
744 const BuilderStack::ScopedEntry stack_entry = stack_.trace(object->id);
745
746 /* Object Transforms. */
747 OperationCode base_op = (object->parent) ? OperationCode::TRANSFORM_PARENT :
749 OperationKey base_op_key(&object->id, NodeType::TRANSFORM, base_op);
751 OperationKey local_transform_key(
753 OperationKey parent_transform_key(
756 OperationKey final_transform_key(
759
760 add_relation(init_transform_key, local_transform_key, "Transform Init");
761
762 /* Various flags, flushing from bases/collections. */
764
765 /* Parenting. */
766 if (object->parent != nullptr) {
767 /* Make sure parent object's relations are built. */
768 build_object(object->parent);
769 /* Parent relationship. */
770 build_object_parent(object);
771 /* Local -> parent. */
772 add_relation(local_transform_key, parent_transform_key, "ObLocal -> ObParent");
773 }
774
777 "Instance Geometry -> Geometry");
778
780 OperationKey{&object->id, NodeType::INSTANCING, OperationCode::INSTANCE_GEOMETRY},
781 "Transform -> Instance Geometry");
782
783 /* Modifiers. */
785
786 /* Grease Pencil Modifiers. */
787 if (object->greasepencil_modifiers.first() != nullptr) {
788 BuilderWalkUserData data;
789 data.builder = this;
790 BKE_grease_pencil_modifiers_foreach_ID_link(object, modifier_walk, &data);
791 }
792
793 /* Shader FX. */
794 if (object->shader_fx.first() != nullptr) {
795 BuilderWalkUserData data;
796 data.builder = this;
797 BKE_shaderfx_foreach_ID_link(object, modifier_walk, &data);
798 }
799
800 /* Constraints. */
801 if (object->constraints.first() != nullptr) {
802 BuilderWalkUserData data;
803 data.builder = this;
804 BKE_constraints_id_loop(&object->constraints, constraint_walk, IDWALK_NOP, &data);
805 }
806
807 /* Object constraints. */
808 OperationKey object_transform_simulation_init_key(
810 if (object->constraints.first() != nullptr) {
811 OperationKey constraint_key(
813 /* Constraint relations. */
814 build_constraints(&object->id, NodeType::TRANSFORM, "", &object->constraints, nullptr);
815 /* operation order */
816 add_relation(base_op_key, constraint_key, "ObBase-> Constraint Stack");
817 add_relation(constraint_key, final_transform_key, "ObConstraints -> Done");
818 add_relation(constraint_key, ob_eval_key, "Constraint -> Transform Eval");
820 ob_eval_key, object_transform_simulation_init_key, "Transform Eval -> Simulation Init");
821 add_relation(object_transform_simulation_init_key,
822 final_transform_key,
823 "Simulation -> Final Transform");
824 }
825 else {
826 add_relation(base_op_key, ob_eval_key, "Eval");
828 ob_eval_key, object_transform_simulation_init_key, "Transform Eval -> Simulation Init");
829 add_relation(object_transform_simulation_init_key,
830 final_transform_key,
831 "Simulation -> Final Transform");
832 }
833
834 build_idproperties(object->id.properties);
835 build_idproperties(object->id.system_properties);
836
837 /* Animation data */
839
840 /* Object data. */
841 build_object_data(object);
842
843 /* Particle systems. */
844 if (object->particlesystem.first() != nullptr) {
846 }
847
848 /* Force field Texture. */
849 if ((object->pd != nullptr) && (object->pd->forcefield == PFIELD_TEXTURE) &&
850 (object->pd->tex != nullptr))
851 {
852 build_texture(object->pd->tex);
853 }
854
857
858 build_object_shading(object);
860
861 /* Synchronization back to original object. */
862 OperationKey synchronize_key(
864 add_relation(final_transform_key, synchronize_key, "Synchronize to Original");
865
866 /* Parameters. */
868
869 /* Visibility.
870 * Evaluate visibility node after the object's base_flags has been updated to the current state
871 * of collections restrict and object's restrict flags. */
872 const ComponentKey object_from_layer_entry_key(&object->id, NodeType::OBJECT_FROM_LAYER);
873 const ComponentKey visibility_key(&object->id, NodeType::VISIBILITY);
874 add_relation(object_from_layer_entry_key, visibility_key, "Object Visibility");
875}
876
877/* NOTE: Implies that the object has base in the current view layer. */
879{
880 /* It is possible to have situation when an object is pulled into the dependency graph in a
881 * few different ways:
882 *
883 * - Indirect driver dependency, which doesn't have a Base (or, Base is unknown).
884 * - Via a base from a view layer (view layer of the graph, or view layer of a set scene).
885 * - Possibly other ways, which are not important for decision making here.
886 *
887 * There needs to be a relation from view layer which has a base with the object so that the
888 * order of flags evaluation is correct (object-level base flags evaluation requires view layer
889 * to be evaluated first).
890 *
891 * This build call handles situation when object comes from a view layer, hence has a base, and
892 * needs a relation from the view layer. Do the relation prior to check of whether the object
893 * relations are built so that the relation is created from every view layer which has a base
894 * with this object. */
895
896 OperationKey view_layer_done_key(
898 OperationKey object_from_layer_entry_key(
900
901 add_relation(view_layer_done_key, object_from_layer_entry_key, "View Layer flags to Object");
902
903 /* Regular object building. */
904 build_object(object);
905}
906
908{
909 OperationKey object_from_layer_entry_key(
911 OperationKey object_from_layer_exit_key(
913 OperationKey object_flags_key(
915
916 if (!has_node(object_flags_key)) {
917 /* Just connect Entry -> Exit if there is no OBJECT_BASE_FLAGS node. */
918 add_relation(object_from_layer_entry_key, object_from_layer_exit_key, "Object from Layer");
919 return;
920 }
921
922 /* Entry -> OBJECT_BASE_FLAGS -> Exit */
923 add_relation(object_from_layer_entry_key, object_flags_key, "Base flags flush Entry");
924 add_relation(object_flags_key, object_from_layer_exit_key, "Base flags flush Exit");
925
926 /* Synchronization back to original object. */
927 OperationKey synchronize_key(
929 add_relation(object_from_layer_exit_key, synchronize_key, "Synchronize to Original");
930}
931
933{
934 if (object->modifiers.is_empty()) {
935 return;
936 }
937
938 const OperationKey eval_init_key(
941
942 const ComponentKey object_visibility_key(&object->id, NodeType::VISIBILITY);
943 const OperationKey modifier_visibility_key(
945 add_relation(modifier_visibility_key,
946 object_visibility_key,
947 "modifier -> object visibility",
949
950 add_relation(modifier_visibility_key, eval_key, "modifier visibility -> geometry eval");
951
953 ctx.scene = scene_;
954 ctx.object = object;
955
956 OperationKey previous_key = eval_init_key;
957 for (ModifierData &modifier : object->modifiers) {
958 const OperationKey modifier_key(
960
961 /* Relation for the modifier stack chain. */
962 add_relation(previous_key, modifier_key, "Modifier");
963
965 if (mti->update_depsgraph) {
966 const BuilderStack::ScopedEntry stack_entry = stack_.trace(modifier);
967
968 DepsNodeHandle handle = create_node_handle(modifier_key);
969 ctx.node = reinterpret_cast<blender::DepsNodeHandle *>(&handle);
970 mti->update_depsgraph(&modifier, &ctx);
971 }
972
973 /* Time dependency. */
975 const TimeSourceKey time_src_key;
976 add_relation(time_src_key, modifier_key, "Time Source -> Modifier");
977 }
978
979 previous_key = modifier_key;
980 }
981 add_relation(previous_key, eval_key, "modifier stack order");
982
983 /* Build IDs referenced by the modifiers. */
984 BuilderWalkUserData data;
985 data.builder = this;
986 BKE_modifiers_foreach_ID_link(object, modifier_walk, &data);
987}
988
990{
991 if (object->type == OB_EMPTY && !BLI_listbase_is_empty(&object->modifiers)) {
993 return;
994 }
995 if (object->data == nullptr) {
996 return;
997 }
998 ID *obdata_id = object->data;
999 /* Object data animation. */
1000 if (!built_map_.check_is_built(obdata_id)) {
1001 build_animdata(obdata_id);
1002 }
1003 /* type-specific data. */
1004 switch (object->type) {
1005 case OB_MESH:
1006 case OB_CURVES_LEGACY:
1007 case OB_FONT:
1008 case OB_SURF:
1009 case OB_MBALL:
1010 case OB_LATTICE:
1011 case OB_CURVES:
1012 case OB_POINTCLOUD:
1013 case OB_VOLUME:
1014 case OB_GREASE_PENCIL: {
1016 /* TODO(sergey): Only for until we support granular
1017 * update of curves. */
1018 if (object->type == OB_FONT) {
1019 Curve *curve = id_cast<Curve *>(object->data);
1020 if (curve->textoncurve) {
1021 ComponentKey geometry_key(object->data, NodeType::GEOMETRY);
1022 ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
1023 add_relation(transform_key, geometry_key, "Text on Curve own Transform");
1025 }
1026 }
1027 break;
1028 }
1029 case OB_ARMATURE:
1030 build_rig(object);
1031 break;
1032 case OB_LAMP:
1034 break;
1035 case OB_CAMERA:
1037 break;
1038 case OB_LIGHTPROBE:
1040 break;
1041 case OB_SPEAKER:
1043 break;
1044 case OB_EMPTY:
1045 case OB_GPENCIL_LEGACY:
1046 case OB_TYPE_MAX:
1047 break;
1048 }
1049 Key *key = BKE_key_from_object(object);
1050 if (key != nullptr) {
1051 ComponentKey geometry_key(object->data, NodeType::GEOMETRY);
1052 ComponentKey key_key(&key->id, NodeType::GEOMETRY);
1053 add_relation(key_key, geometry_key, "Shapekeys");
1054 build_nested_shapekey(&object->id, key);
1055 }
1056 /* Materials. */
1057 Material ***materials_ptr = BKE_object_material_array_p(object);
1058 if (materials_ptr != nullptr) {
1059 short *num_materials_ptr = BKE_object_material_len_p(object);
1060 ID *obdata = object->data;
1061 build_materials(obdata, *materials_ptr, *num_materials_ptr);
1062 }
1063}
1064
1066{
1067 Camera *camera = id_cast<Camera *>(object->data);
1069 ComponentKey object_parameters_key(&object->id, NodeType::PARAMETERS);
1070 ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS);
1071 add_relation(camera_parameters_key, object_parameters_key, "Camera -> Object");
1072}
1073
1075{
1076 Light *lamp = id_cast<Light *>(object->data);
1077 build_light(lamp);
1078 ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
1079 ComponentKey object_parameters_key(&object->id, NodeType::PARAMETERS);
1080 add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object");
1082 add_relation(lamp_parameters_key, object_shading_key, "Light -> Object Shading");
1083}
1084
1086{
1087 LightProbe *probe = id_cast<LightProbe *>(object->data);
1088 build_lightprobe(probe);
1091 add_relation(probe_key, object_key, "LightProbe Update");
1093 add_relation(probe_key, object_shading_key, "LightProbe -> Object Shading");
1094}
1095
1097{
1098 Speaker *speaker = id_cast<Speaker *>(object->data);
1099 build_speaker(speaker);
1100 ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
1101 ComponentKey object_key(&object->id, NodeType::AUDIO);
1102 add_relation(speaker_key, object_key, "Speaker Update");
1103}
1104
1106{
1107 Object *parent = object->parent;
1108 ID *parent_id = &object->parent->id;
1109 ComponentKey object_transform_key(&object->id, NodeType::TRANSFORM);
1110 /* Type-specific links. */
1111 switch (object->partype) {
1112 /* Armature Deform (Virtual Modifier) */
1113 case PARSKEL: {
1114 ComponentKey parent_transform_key(parent_id, NodeType::TRANSFORM);
1115 add_relation(parent_transform_key, object_transform_key, "Parent Armature Transform");
1116
1117 if (parent->type == OB_ARMATURE) {
1118 ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY);
1119 ComponentKey parent_pose_key(parent_id, NodeType::EVAL_POSE);
1121 parent_transform_key, object_geometry_key, "Parent Armature Transform -> Geometry");
1122 add_relation(parent_pose_key, object_geometry_key, "Parent Armature Pose -> Geometry");
1123
1125 &object->id, object_geometry_key, "Virtual Armature Modifier");
1126 }
1127
1128 break;
1129 }
1130
1131 /* Vertex Parent */
1132 case PARVERT1:
1133 case PARVERT3: {
1134 ComponentKey parent_key(parent_id, NodeType::GEOMETRY);
1135 add_relation(parent_key, object_transform_key, "Vertex Parent");
1136 /* Original index is used for optimizations of lookups for subdiv
1137 * only meshes.
1138 * TODO(sergey): This optimization got lost at 2.8, so either verify
1139 * we can get rid of this mask here, or bring the optimization
1140 * back. */
1146 ComponentKey transform_key(parent_id, NodeType::TRANSFORM);
1147 add_relation(transform_key, object_transform_key, "Vertex Parent TFM");
1148 break;
1149 }
1150
1151 /* Bone Parent */
1152 case PARBONE: {
1153 if (object->parsubstr[0] != '\0') {
1154 ComponentKey parent_bone_key(parent_id, NodeType::BONE, object->parsubstr);
1155 OperationKey parent_transform_key(
1157 add_relation(parent_bone_key, object_transform_key, "Bone Parent");
1158 add_relation(parent_transform_key, object_transform_key, "Armature Parent");
1159 }
1160 break;
1161 }
1162
1163 default: {
1164 if (object->parent->type == OB_LATTICE) {
1165 /* Lattice Deform Parent - Virtual Modifier. */
1166 ComponentKey parent_key(parent_id, NodeType::TRANSFORM);
1167 ComponentKey geom_key(parent_id, NodeType::GEOMETRY);
1168 add_relation(parent_key, object_transform_key, "Lattice Deform Parent");
1169 add_relation(geom_key, object_transform_key, "Lattice Deform Parent Geom");
1170 }
1171 else if (object->parent->type == OB_CURVES_LEGACY) {
1172 Curve *cu = id_cast<Curve *>(object->parent->data);
1173
1174 if (cu->flag & CU_PATH) {
1175 /* Follow Path. */
1176 ComponentKey parent_key(parent_id, NodeType::GEOMETRY);
1177 add_relation(parent_key, object_transform_key, "Curve Follow Parent");
1178 ComponentKey transform_key(parent_id, NodeType::TRANSFORM);
1179 add_relation(transform_key, object_transform_key, "Curve Follow TFM");
1180 }
1181 else {
1182 /* Standard Parent. */
1183 ComponentKey parent_key(parent_id, NodeType::TRANSFORM);
1184 add_relation(parent_key, object_transform_key, "Curve Parent");
1185 }
1186 }
1187 else {
1188 /* Standard Parent. */
1189 ComponentKey parent_key(parent_id, NodeType::TRANSFORM);
1190 add_relation(parent_key, object_transform_key, "Parent");
1191 }
1192 break;
1193 }
1194 }
1195 /* Meta-balls are the odd balls here (no pun intended): they will request
1196 * instance-list (formerly known as dupli-list) during evaluation. This is
1197 * their way of interacting with all instanced surfaces, making a nice
1198 * effect when is used form particle system. */
1199 if (object->type == OB_MBALL && parent->transflag & OB_DUPLI) {
1200 ComponentKey parent_geometry_key(parent_id, NodeType::GEOMETRY);
1201 /* NOTE: Meta-balls are evaluating geometry only after their transform,
1202 * so we only hook up to transform channel here. */
1203 add_relation(parent_geometry_key, object_transform_key, "Parent");
1204 }
1205
1206 /* Dupliverts uses original vertex index. */
1207 if (parent->transflag & OB_DUPLIVERTS) {
1209 }
1210}
1211
1212/* Returns the modifier that is last in the modifier stack. */
1213static const ModifierData *get_latter_modifier(const ModifierData *md1, const ModifierData *md2)
1214{
1215 if (md1 == nullptr) {
1216 return md2;
1217 }
1218 if (md2 == nullptr) {
1219 return md1;
1220 }
1221
1222 for (const ModifierData *md = md2->prev; md; md = md->prev) {
1223 if (md == md1) {
1224 return md2;
1225 }
1226 }
1227 return md1;
1228}
1229
1231{
1232 std::optional<ComponentKey> point_cache_key;
1233 bool has_rigid_body_relation = false;
1234 bool has_geometry_eval_relation = false;
1235 const ModifierData *last_input_modifier = nullptr;
1237 *object, *scene_, false, [&](PTCacheID &ptcache_id, ModifierData *md) {
1238 if (!point_cache_key) {
1239 point_cache_key = ComponentKey(&object->id, NodeType::POINT_CACHE);
1240 }
1241
1242 /* Check which components needs the point cache. */
1243 if (!has_geometry_eval_relation) {
1244 has_geometry_eval_relation = true;
1245
1247 add_relation(*point_cache_key, geometry_key, "Point Cache -> Geometry");
1248 }
1249 if (!has_rigid_body_relation && ptcache_id.type == PTCACHE_TYPE_RIGIDBODY) {
1250 if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
1251 return true;
1252 }
1253 has_rigid_body_relation = true;
1254
1255 OperationKey transform_key(
1257 add_relation(*point_cache_key, transform_key, "Point Cache -> Rigid Body");
1258 /* Manual changes to effectors need to invalidate simulation.
1259 *
1260 * Don't add this relation for the render pipeline dependency graph as it does not
1261 * contain rigid body simulation. Good thing is that there are no user edits in such
1262 * dependency graph, so the relation is not really needed in it. */
1264 OperationKey rigidbody_rebuild_key(
1266 add_relation(rigidbody_rebuild_key,
1267 *point_cache_key,
1268 "Rigid Body Rebuild -> Point Cache Reset",
1270 }
1271 }
1272
1273 if (md && md->prev) {
1274 last_input_modifier = get_latter_modifier(last_input_modifier, md->prev);
1275 }
1276
1277 return true;
1278 });
1279
1280 /* Manual edits to any dependency (or self) should reset the point cache. */
1281 if (point_cache_key) {
1282 OperationKey transform_eval_key(
1284 add_relation(transform_eval_key,
1285 *point_cache_key,
1286 "Transform Simulation -> Point Cache",
1288
1289 /* For caches in specific modifiers:
1290 * Input data changes from previous modifiers require a point cache reset. */
1291 if (last_input_modifier != nullptr) {
1292 const OperationKey input_modifier_key(
1293 &object->id, NodeType::GEOMETRY, OperationCode::MODIFIER, last_input_modifier->name);
1294 add_relation(input_modifier_key,
1295 *point_cache_key,
1296 "Previous Modifier -> Point Cache",
1298 }
1299 else {
1300 OperationKey geometry_init_key(
1302 add_relation(geometry_init_key,
1303 *point_cache_key,
1304 "Geometry Init -> Point Cache",
1306 }
1307 }
1308}
1309
1311{
1312 if (object->instance_collection == nullptr) {
1313 return;
1314 }
1315
1316 Collection *instance_collection = object->instance_collection;
1317
1318 build_collection(nullptr, instance_collection);
1319
1320 const OperationKey object_transform_final_key(
1323
1325 const ComponentKey dupli_transform_key(&ob->id, NodeType::TRANSFORM);
1326 add_relation(dupli_transform_key, object_transform_final_key, "Dupligroup");
1327
1328 /* Hook to special component, to ensure proper visibility/evaluation optimizations. */
1330 instancer_key,
1331 "Instance -> Instancer");
1332 }
1334}
1335
1337{
1339
1341 add_relation(shading_key, shading_done_key, "Shading -> Done");
1342
1343 /* Hook up shading component to the instance, so that if the object is instanced by a visible
1344 * object the shading component is ensured to be evaluated.
1345 * Don't to flushing to avoid re-evaluation of geometry when the object is used as part of a
1346 * collection used as a boolean modifier operand. */
1347 add_relation(shading_done_key,
1349 "Light Linking -> Instance",
1351}
1352
1354{
1355 const ComponentKey hierarchy_key(&emitter->id, NodeType::HIERARCHY);
1356 const OperationKey shading_done_key(
1358 const OperationKey light_linking_key(
1360
1361 add_relation(hierarchy_key, light_linking_key, "Light Linking From Layer");
1362 add_relation(light_linking_key, shading_done_key, "Light Linking -> Shading Done");
1363
1364 if (emitter->light_linking) {
1366
1367 build_light_linking_collection(emitter, light_linking.receiver_collection);
1368 build_light_linking_collection(emitter, light_linking.blocker_collection);
1369 }
1370}
1371
1373 Collection *collection)
1374{
1375 if (collection == nullptr) {
1376 return;
1377 }
1378
1379 build_collection(nullptr, collection);
1380
1381 /* TODO(sergey): Avoid duplicate dependencies if multiple emitters are using the same collection.
1382 */
1383
1384 const OperationKey emitter_light_linking_key(
1386
1387 const OperationKey collection_parameters_entry_key(
1389 const OperationKey collection_parameters_exit_key(
1391 const OperationKey collection_hierarchy_key(
1393
1394 const OperationKey collection_light_linking_key(
1396
1397 /* Order of parameters evaluation within the receiver collection. */
1398 /* TODO(sergey): Can optimize this out by explicitly separating the different built tags. This
1399 * needs to be done in all places where the collection is built (is not something that can be
1400 * easily solved from just adding the light linking functionality). */
1401 add_relation(collection_parameters_entry_key,
1402 collection_light_linking_key,
1403 "Entry -> Collection Light Linking",
1405 add_relation(collection_light_linking_key,
1406 collection_parameters_exit_key,
1407 "Collection Light Linking -> Exit",
1409
1410 add_relation(collection_hierarchy_key,
1411 collection_light_linking_key,
1412 "Collection Hierarchy -> Light Linking",
1414
1415 /* Order to ensure the emitter's light linking is only evaluated after the receiver collection.
1416 * This is because light linking runtime data is "cached" om the emitter object for the
1417 * simplicity of access, but the mask is allocated per collection bases (so that if two emitters
1418 * share the same receiving collection they share the same runtime data). */
1419 add_relation(collection_light_linking_key,
1420 emitter_light_linking_key,
1421 "Collection -> Object Light Linking");
1422}
1423
1425 NodeType component_type,
1426 const char *component_subdata,
1427 ListBaseT<bConstraint> *constraints,
1428 RootPChanMap *root_map)
1429{
1430 OperationKey constraint_op_key(id,
1431 component_type,
1432 component_subdata,
1433 (component_type == NodeType::BONE) ?
1436 /* Add dependencies for each constraint in turn. */
1437 for (bConstraint &con : *constraints) {
1439 ListBaseT<bConstraintTarget> targets = {nullptr, nullptr};
1440 /* Invalid constraint type. */
1441 if (cti == nullptr) {
1442 continue;
1443 }
1444
1445 const BuilderStack::ScopedEntry stack_entry = stack_.trace(con);
1446
1447 /* Special case for camera tracking -- it doesn't use targets to
1448 * define relations. */
1449 /* TODO: we can now represent dependencies in a much richer manner,
1450 * so review how this is done. */
1451 if (ELEM(cti->type,
1455 {
1456 bool depends_on_camera = false;
1457 if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
1458 bFollowTrackConstraint *data = static_cast<bFollowTrackConstraint *>(con.data);
1459 if (((data->clip) || (data->flag & FOLLOWTRACK_ACTIVECLIP)) && data->track[0]) {
1460 depends_on_camera = true;
1461 }
1462 if (data->depth_ob) {
1463 ComponentKey depth_transform_key(&data->depth_ob->id, NodeType::TRANSFORM);
1464 ComponentKey depth_geometry_key(&data->depth_ob->id, NodeType::GEOMETRY);
1465 add_relation(depth_transform_key, constraint_op_key, cti->name);
1466 add_relation(depth_geometry_key, constraint_op_key, cti->name);
1467 }
1468 }
1469 else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
1470 depends_on_camera = true;
1471 }
1472 if (depends_on_camera && scene_->camera != nullptr) {
1473 ComponentKey camera_key(&scene_->camera->id, NodeType::TRANSFORM);
1474 add_relation(camera_key, constraint_op_key, cti->name);
1475 }
1476 /* TODO(sergey): This is more a TimeSource -> MovieClip ->
1477 * Constraint dependency chain. */
1478 TimeSourceKey time_src_key;
1479 add_relation(time_src_key, constraint_op_key, "TimeSrc -> Animation");
1480 }
1481 else if (cti->type == CONSTRAINT_TYPE_TRANSFORM_CACHE) {
1482 /* TODO(kevin): This is more a TimeSource -> CacheFile -> Constraint
1483 * dependency chain. */
1484 TimeSourceKey time_src_key;
1485 add_relation(time_src_key, constraint_op_key, "TimeSrc -> Animation");
1486 bTransformCacheConstraint *data = static_cast<bTransformCacheConstraint *>(con.data);
1487 if (data->cache_file) {
1488 ComponentKey cache_key(&data->cache_file->id, NodeType::CACHE);
1489 add_relation(cache_key, constraint_op_key, cti->name);
1490 }
1491 }
1492 else if (BKE_constraint_targets_get(&con, &targets)) {
1493 for (bConstraintTarget &ct : targets) {
1494 if (ct.tar == nullptr) {
1495 continue;
1496 }
1498 /* Ignore IK constraints - these are handled separately
1499 * (on pose level). */
1500 }
1502 /* These constraints require path geometry data. */
1503 ComponentKey target_key(&ct.tar->id, NodeType::GEOMETRY);
1504 add_relation(target_key, constraint_op_key, cti->name);
1505 ComponentKey target_transform_key(&ct.tar->id, NodeType::TRANSFORM);
1506 add_relation(target_transform_key, constraint_op_key, cti->name);
1507 }
1508 else if ((ct.tar->type == OB_ARMATURE) && (ct.subtarget[0])) {
1509 OperationCode opcode;
1510 /* relation to bone */
1511 opcode = bone_target_opcode(&ct.tar->id, ct.subtarget, id, component_subdata, root_map);
1512 /* Armature constraint always wants the final position and chan_mat. */
1513 if (ELEM(con.type, CONSTRAINT_TYPE_ARMATURE)) {
1514 opcode = OperationCode::BONE_DONE;
1515 }
1516 /* if needs bbone shape, reference the segment computation */
1517 if (BKE_constraint_target_uses_bbone(&con, &ct) &&
1518 check_pchan_has_bbone_segments(ct.tar, ct.subtarget))
1519 {
1521 }
1522 OperationKey target_key(&ct.tar->id, NodeType::BONE, ct.subtarget, opcode);
1523 add_relation(target_key, constraint_op_key, cti->name);
1524 }
1525 else if (ELEM(ct.tar->type, OB_MESH, OB_LATTICE) && (ct.subtarget[0])) {
1526 /* Vertex group. */
1527 /* NOTE: Vertex group is likely to be used to get vertices
1528 * in a world space. This requires to know both geometry
1529 * and transformation of the target object. */
1530 ComponentKey target_transform_key(&ct.tar->id, NodeType::TRANSFORM);
1531 ComponentKey target_geometry_key(&ct.tar->id, NodeType::GEOMETRY);
1532 add_relation(target_transform_key, constraint_op_key, cti->name);
1533 add_relation(target_geometry_key, constraint_op_key, cti->name);
1535 }
1536 else if (con.type == CONSTRAINT_TYPE_SHRINKWRAP) {
1537 bShrinkwrapConstraint *scon = static_cast<bShrinkwrapConstraint *>(con.data);
1538
1539 /* Constraints which requires the target object surface. */
1540 ComponentKey target_key(&ct.tar->id, NodeType::GEOMETRY);
1541 add_relation(target_key, constraint_op_key, cti->name);
1542
1543 /* Add dependency on normal layers if necessary. */
1544 if (ct.tar->type == OB_MESH && scon->shrinkType != MOD_SHRINKWRAP_NEAREST_VERTEX) {
1547 }
1548 }
1549
1550 /* NOTE: obdata eval now doesn't necessarily depend on the
1551 * object's transform. */
1552 ComponentKey target_transform_key(&ct.tar->id, NodeType::TRANSFORM);
1553 add_relation(target_transform_key, constraint_op_key, cti->name);
1554 }
1555 else if (con.type == CONSTRAINT_TYPE_GEOMETRY_ATTRIBUTE) {
1556 /* Constraints which require the target object geometry attributes. */
1557 ComponentKey target_key(&ct.tar->id, NodeType::GEOMETRY);
1558 add_relation(target_key, constraint_op_key, cti->name);
1559
1560 /* NOTE: The target object's transform is used when the 'Apply target transform' flag
1561 * is set.*/
1562 ComponentKey target_transform_key(&ct.tar->id, NodeType::TRANSFORM);
1563 add_relation(target_transform_key, constraint_op_key, cti->name);
1564 }
1565 else {
1566 /* Standard object relation. */
1567 /* TODO: loc vs rot vs scale? */
1568 if (&ct.tar->id == id) {
1569 /* Constraint targeting its own object:
1570 * - This case is fine IF we're dealing with a bone
1571 * constraint pointing to its own armature. In that
1572 * case, it's just transform -> bone.
1573 * - If however it is a real self targeting case, just
1574 * make it depend on the previous constraint (or the
1575 * pre-constraint state). */
1576 if ((ct.tar->type == OB_ARMATURE) && (component_type == NodeType::BONE)) {
1577 OperationKey target_key(
1579 add_relation(target_key, constraint_op_key, cti->name);
1580 }
1581 else {
1582 OperationKey target_key(
1584 add_relation(target_key, constraint_op_key, cti->name);
1585 }
1586 }
1587 else {
1588 /* Normal object dependency. */
1589 OperationKey target_key(
1591 add_relation(target_key, constraint_op_key, cti->name);
1592 }
1593 }
1594 /* Constraints which needs world's matrix for transform.
1595 * TODO(sergey): More constraints here? */
1596 if (ELEM(con.type,
1601 {
1602 /* TODO(sergey): Add used space check. */
1603 ComponentKey target_transform_key(&ct.tar->id, NodeType::TRANSFORM);
1604 add_relation(target_transform_key, constraint_op_key, cti->name);
1605 }
1606 }
1607 BKE_constraint_targets_flush(&con, &targets, true);
1608 }
1609 }
1610}
1611
1613{
1614 /* Images. */
1616 /* Animation curves, NLA, and Animation datablock. */
1618 /* Drivers. */
1620
1621 if (check_id_has_anim_component(id)) {
1622 ComponentKey animation_key(id, NodeType::ANIMATION);
1623 ComponentKey parameters_key(id, NodeType::PARAMETERS);
1624 add_relation(animation_key, parameters_key, "Animation -> Parameters");
1626 }
1627}
1628
1630{
1631 AnimData *adt = BKE_animdata_from_id(id);
1632 if (adt == nullptr) {
1633 return;
1634 }
1635 if (adt->action != nullptr) {
1636 build_action(adt->action);
1637 }
1638 if (adt->action == nullptr && adt->nla_tracks.is_empty()) {
1639 return;
1640 }
1641 /* Ensure evaluation order from entry to exit. */
1645 add_relation(animation_entry_key, animation_eval_key, "Init -> Eval");
1646 add_relation(animation_eval_key, animation_exit_key, "Eval -> Exit");
1647 /* Wire up dependency from Actions. */
1648 ComponentKey adt_key(id, NodeType::ANIMATION);
1649 /* Relation from action itself. */
1650 if (adt->action != nullptr) {
1651 ComponentKey action_key(&adt->action->id, NodeType::ANIMATION);
1652 add_relation(action_key, adt_key, "Action -> Animation");
1653 }
1654 /* Get source operations. */
1655 Node *node_from = get_node(adt_key);
1656 BLI_assert(node_from != nullptr);
1657 if (node_from == nullptr) {
1658 return;
1659 }
1660 OperationNode *operation_from = node_from->get_exit_operation();
1661 BLI_assert(operation_from != nullptr);
1662 /* Build relations from animation operation to properties it changes. */
1663 if (adt->action != nullptr) {
1664 build_animdata_action_targets(id, adt->slot_handle, adt_key, operation_from, adt->action);
1665 }
1666 for (NlaTrack &nlt : adt->nla_tracks) {
1667 if (!BKE_nlatrack_is_enabled(*adt, nlt)) {
1668 continue;
1669 }
1670 build_animdata_nlastrip_targets(id, adt_key, operation_from, &nlt.strips);
1671 }
1672}
1673
1675 ID *id, PointerRNA id_ptr, ComponentKey &adt_key, OperationNode *operation_from, FCurve *fcu)
1676{
1677 PointerRNA ptr;
1678 PropertyRNA *prop;
1679 int index;
1680 if (!RNA_path_resolve_full(&id_ptr, fcu->rna_path().c_str(), &ptr, &prop, &index)) {
1681 return;
1682 }
1683 Node *node_to = rna_node_query_.find_node(&ptr, prop, RNAPointerSource::ENTRY);
1684 if (node_to == nullptr) {
1685 return;
1686 }
1687 OperationNode *operation_to = node_to->get_entry_operation();
1688 /* NOTE: Special case for bones, avoid relation from animation to
1689 * each of the bones. Bone evaluation could only start from pose
1690 * init anyway. */
1691 if (operation_to->opcode == OperationCode::BONE_LOCAL) {
1693 add_relation(adt_key, pose_init_key, "Animation -> Prop", RELATION_CHECK_BEFORE_ADD);
1694 return;
1695 }
1697 operation_from, operation_to, "Animation -> Prop", RELATION_CHECK_BEFORE_ADD);
1698 /* It is possible that animation is writing to a nested ID data-block,
1699 * need to make sure animation is evaluated after target ID is copied. */
1700 const IDNode *id_node_from = operation_from->owner->owner;
1701 const IDNode *id_node_to = operation_to->owner->owner;
1702 if (id_node_from != id_node_to) {
1703 ComponentKey cow_key(id_node_to->id_orig, NodeType::COPY_ON_EVAL);
1704 add_relation(cow_key,
1705 adt_key,
1706 "Animated Copy-on-Eval -> Animation",
1708 }
1709}
1710
1712 const int32_t slot_handle,
1713 ComponentKey &adt_key,
1714 OperationNode *operation_from,
1715 bAction *dna_action)
1716{
1717 BLI_assert(id != nullptr);
1718 BLI_assert(operation_from != nullptr);
1719 BLI_assert(dna_action != nullptr);
1720 animrig::Action &action = dna_action->wrap();
1721
1722 if (action.is_empty()) {
1723 return;
1724 }
1725
1726 const animrig::Slot *slot = action.slot_for_handle(slot_handle);
1727 if (slot == nullptr) {
1728 /* If there's no matching slot, there's no Action dependency. */
1729 return;
1730 }
1731
1732 PointerRNA id_ptr = RNA_id_pointer_create(id);
1733
1734 for (animrig::Layer *layer : action.layers()) {
1735 for (animrig::Strip *strip : layer->strips()) {
1736 switch (strip->type()) {
1738 animrig::StripKeyframeData &strip_data = strip->data<animrig::StripKeyframeData>(action);
1739 animrig::Channelbag *channels = strip_data.channelbag_for_slot(*slot);
1740 if (channels == nullptr) {
1741 /* Go to next strip. */
1742 break;
1743 }
1744 for (FCurve *fcu : channels->fcurves()) {
1745 build_animdata_fcurve_target(id, id_ptr, adt_key, operation_from, fcu);
1746 }
1747 break;
1748 }
1749 }
1750 }
1751 }
1752}
1753
1755 ComponentKey &adt_key,
1756 OperationNode *operation_from,
1757 ListBaseT<NlaStrip> *strips)
1758{
1759 for (NlaStrip &strip : *strips) {
1760 if (strip.act != nullptr) {
1761 build_action(strip.act);
1762
1763 ComponentKey action_key(&strip.act->id, NodeType::ANIMATION);
1764 add_relation(action_key, adt_key, "Action -> Animation");
1765
1767 id, strip.action_slot_handle, adt_key, operation_from, strip.act);
1768 }
1769 else if (strip.strips.first() != nullptr) {
1770 build_animdata_nlastrip_targets(id, adt_key, operation_from, &strip.strips);
1771 }
1772 }
1773}
1774
1776{
1777 AnimData *adt = BKE_animdata_from_id(id);
1778 if (adt == nullptr || adt->drivers.is_empty()) {
1779 return;
1780 }
1781 ComponentKey adt_key(id, NodeType::ANIMATION);
1783
1784 for (FCurve &fcu : adt->drivers) {
1785 OperationKey driver_key(
1786 id, NodeType::PARAMETERS, OperationCode::DRIVER, fcu.rna_path().c_str(), fcu.array_index);
1787
1788 /* create the driver's relations to targets */
1789 build_driver(id, &fcu);
1790
1791 /* prevent driver from occurring before its own animation... */
1792 if (adt->action || adt->nla_tracks.first_) {
1793 add_relation(adt_key, driver_key, "AnimData Before Drivers");
1794 }
1795
1796 if (data_path_maybe_shared(*id, fcu.rna_path())) {
1797 add_relation(driver_unshare_key, driver_key, "Un-share shared data before drivers");
1798 }
1799 }
1800
1801 /* Un-sharing writes to the driven properties, which can also be written by the animation. */
1803 if (has_node(animation_exit_key) && has_node(driver_unshare_key)) {
1804 add_relation(animation_exit_key, driver_unshare_key, "AnimData Before Un-share");
1805 }
1806}
1807
1809{
1810 /* See #DepsgraphNodeBuilder::build_animation_images. */
1811 bool has_image_animation = false;
1812 if (ELEM(id->id_type(), ID_MA, ID_WO)) {
1814 if (ntree != nullptr && ntree->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION)
1815 {
1816 has_image_animation = true;
1817 }
1818 }
1819
1820 if (has_image_animation || BKE_image_user_id_has_animation(id)) {
1821 OperationKey image_animation_key(
1823 TimeSourceKey time_src_key;
1824 add_relation(time_src_key, image_animation_key, "TimeSrc -> Image Animation");
1825
1826 /* The image users of these ids may change during evaluation. Make sure that the image
1827 * animation update happens after evaluation. */
1828 if (id->id_type() == ID_MA) {
1830 add_relation(material_update_key, image_animation_key, "Material Update -> Image Animation");
1831 }
1832 else if (id->id_type() == ID_WO) {
1834 add_relation(world_update_key, image_animation_key, "World Update -> Image Animation");
1835 }
1836 else if (id->id_type() == ID_NT) {
1838 add_relation(ntree_output_key, image_animation_key, "NTree Output -> Image Animation");
1839 }
1840 }
1841}
1842
1844{
1845 if (id->id_type() != ID_OB) {
1846 return;
1847 }
1848
1849 const Object *object = id_cast<Object *>(id);
1850 if (object->pd == nullptr || object->pd->forcefield == PFIELD_NULL) {
1851 return;
1852 }
1853
1854 /* Updates to animation data (in the UI, for example by altering FCurve Modifier parameters
1855 * animating force field strength) may need to rebuild the rigid body world. */
1856 ComponentKey animation_key(id, NodeType::ANIMATION);
1858 add_relation(animation_key, rigidbody_key, "Animation -> Rigid Body");
1859}
1860
1862{
1863 if (built_map_.check_is_built_and_tag(dna_action)) {
1864 return;
1865 }
1866
1867 const BuilderStack::ScopedEntry stack_entry = stack_.trace(dna_action->id);
1868
1869 build_parameters(&dna_action->id);
1870 build_idproperties(dna_action->id.properties);
1872
1873 for (TimeMarker &marker : dna_action->markers) {
1874 build_idproperties(marker.prop);
1875 }
1876
1877 animrig::Action &action = dna_action->wrap();
1878 if (!action.is_empty()) {
1879 TimeSourceKey time_src_key;
1880 ComponentKey animation_key(&dna_action->id, NodeType::ANIMATION);
1881 add_relation(time_src_key, animation_key, "TimeSrc -> Animation");
1882 }
1883}
1884
1886{
1887 ChannelDriver *driver = fcu->driver;
1888 OperationKey driver_key(
1889 id, NodeType::PARAMETERS, OperationCode::DRIVER, fcu->rna_path().c_str(), fcu->array_index);
1890 /* Driver -> data components (for interleaved evaluation
1891 * bones/constraints/modifiers). */
1892 build_driver_data(id, fcu);
1893 /* Loop over variables to get the target relationships. */
1894 build_driver_variables(id, fcu);
1895 /* It's quite tricky to detect if the driver actually depends on time or
1896 * not, so for now we'll be quite conservative here about optimization and
1897 * consider all python drivers to be depending on time. */
1898 if (driver_depends_on_time(driver)) {
1899 TimeSourceKey time_src_key;
1900 add_relation(time_src_key, driver_key, "TimeSrc -> Driver");
1901 }
1902}
1903
1905{
1906 /* Validate the RNA path pointer just in case. */
1907 const StringRefNull rna_path = fcu->rna_path();
1908 if (rna_path.is_empty()) {
1909 return;
1910 }
1911 /* Parse the RNA path to find the target property pointer. */
1912 RNAPathKey property_entry_key(id, rna_path.c_str(), RNAPointerSource::ENTRY);
1913 if (!property_entry_key.ptr) {
1914 /* TODO(sergey): This would only mean that driver is broken.
1915 * so we can't create relation anyway. However, we need to avoid
1916 * adding drivers which are known to be buggy to a dependency
1917 * graph, in order to save computational power. */
1918 return;
1919 }
1920 OperationKey driver_key(
1922 /* If the target of the driver is a Bone property, find the Armature data,
1923 * and then link the driver to all pose bone evaluation components that use
1924 * it. This is necessary to provide more granular dependencies specifically for
1925 * Bone objects, because the armature data doesn't have per-bone components,
1926 * and generic add_relation can only add one link. */
1927 ID *id_ptr = property_entry_key.ptr.owner_id;
1928 bool is_bone = id_ptr && property_entry_key.ptr.type == RNA_Bone;
1929 /* If the Bone property is referenced via obj.pose.bones[].bone,
1930 * the RNA pointer refers to the Object ID, so skip to data. */
1931 if (is_bone && id_ptr->id_type() == ID_OB) {
1932 id_ptr = (id_cast<Object *>(id_ptr))->data;
1933 }
1934 if (is_bone && id_ptr->id_type() == ID_AR) {
1935 /* Drivers on armature-level bone settings (i.e. bbone stuff),
1936 * which will affect the evaluation of corresponding pose bones. */
1937 Bone *bone = static_cast<Bone *>(property_entry_key.ptr.data);
1938 if (bone == nullptr) {
1939 fprintf(
1940 stderr, "Couldn't find armature bone name for driver path - '%s'\n", rna_path.c_str());
1941 return;
1942 }
1943
1944 const char *prop_identifier = RNA_property_identifier(property_entry_key.prop);
1945 const bool driver_targets_bbone = STRPREFIX(prop_identifier, "bbone_");
1946
1947 /* Find objects which use this, and make their eval callbacks depend on this. */
1948 for (IDNode *to_node : graph_->id_nodes) {
1949 if (to_node->id_orig->id_type() != ID_OB) {
1950 continue;
1951 }
1952
1953 /* We only care about objects with pose data which use this. */
1954 Object *object = id_cast<Object *>(to_node->id_orig);
1955 if (object->data != id_ptr || object->pose == nullptr) {
1956 continue;
1957 }
1958
1959 bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone->name);
1960 if (pchan == nullptr) {
1961 continue;
1962 }
1963
1965 if (driver_targets_bbone) {
1968 }
1969 OperationKey bone_key(&object->id, NodeType::BONE, pchan->name, target_op);
1970 add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
1971 }
1972 /* Make the driver depend on copy-on-eval, similar to the generic case below. */
1973 if (id_ptr != id) {
1974 ComponentKey cow_key(id_ptr, NodeType::COPY_ON_EVAL);
1976 cow_key, driver_key, "Driven Copy-on-Eval -> Driver", RELATION_CHECK_BEFORE_ADD);
1977 }
1978 }
1979 else {
1980 /* If it's not a Bone, handle the generic single dependency case. */
1981 Node *node_to = get_node(property_entry_key);
1982 if (node_to != nullptr) {
1983 add_relation(driver_key, property_entry_key, "Driver -> Driven Property");
1984 }
1985
1986 /* Similar to the case with f-curves, driver might drive a nested
1987 * data-block, which means driver execution should wait for that
1988 * data-block to be copied. */
1989 {
1990 PointerRNA id_ptr = RNA_id_pointer_create(id);
1991 PointerRNA ptr;
1992 if (RNA_path_resolve_full(&id_ptr, rna_path.c_str(), &ptr, nullptr, nullptr)) {
1993 if (id_ptr.owner_id != ptr.owner_id) {
1996 cow_key, driver_key, "Driven Copy-on-Eval -> Driver", RELATION_CHECK_BEFORE_ADD);
1997 }
1998 }
1999 }
2000 if (rna_prop_affects_parameters_node(&property_entry_key.ptr, property_entry_key.prop)) {
2001 RNAPathKey property_exit_key(property_entry_key.id,
2002 property_entry_key.ptr,
2003 property_entry_key.prop,
2006 add_relation(property_exit_key, parameters_key, "Driven Property -> Properties");
2007 }
2008 }
2009
2010 /* Assume drivers on a node tree affect the evaluated output of the node tree. In theory we could
2011 * check if the driven value actually affects the output, i.e. if it drives a node that is linked
2012 * to the output. */
2013 if (id_ptr->id_type() == ID_NT) {
2014 ComponentKey ntree_output_key(id_ptr, NodeType::NTREE_OUTPUT);
2015 add_relation(driver_key, ntree_output_key, "Drivers -> NTree Output");
2016 if (reinterpret_cast<bNodeTree *>(id_ptr)->type == NTREE_GEOMETRY) {
2017 OperationKey ntree_geo_preprocess_key(
2019 add_relation(driver_key, ntree_geo_preprocess_key, "Drivers -> NTree Geo Preprocess");
2020 }
2021 }
2022}
2023
2025{
2026 ChannelDriver *driver = fcu->driver;
2027 const StringRefNull rna_path = fcu->rna_path();
2028 OperationKey driver_key(
2030
2031 const RNAPathKey self_key(id, rna_path.c_str(), RNAPointerSource::ENTRY);
2032
2033 DriverTargetContext driver_target_context;
2034 driver_target_context.scene = graph_->scene;
2035 driver_target_context.view_layer = graph_->view_layer;
2036
2037 for (DriverVar &dvar : driver->variables) {
2038 /* Only used targets. */
2040 PointerRNA target_prop;
2041 if (!driver_get_target_property(&driver_target_context, &dvar, dtar, &target_prop)) {
2042 continue;
2043 }
2044
2045 /* Property is always expected to be resolved to a non-null RNA property, which is always
2046 * relative to some ID. */
2047 BLI_assert(target_prop.owner_id);
2048
2049 ID *target_id = target_prop.owner_id;
2050
2051 build_id(target_id);
2052 build_driver_id_property(target_prop, dtar->rna_path);
2053
2054 Object *object = nullptr;
2055 if (target_id->id_type() == ID_OB) {
2056 object = id_cast<Object *>(target_id);
2057 }
2058 /* Special handling for directly-named bones. */
2059 if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (object && object->type == OB_ARMATURE) &&
2060 (dtar->pchan_name[0]))
2061 {
2062 bPoseChannel *target_pchan = BKE_pose_channel_find_name(object->pose, dtar->pchan_name);
2063 if (target_pchan == nullptr) {
2064 continue;
2065 }
2066 OperationKey variable_key(
2067 target_id, NodeType::BONE, target_pchan->name, OperationCode::BONE_DONE);
2068 if (is_same_bone_dependency(variable_key, self_key)) {
2069 continue;
2070 }
2071 add_relation(variable_key, driver_key, "Bone Target -> Driver");
2072 }
2073 else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
2074 /* Get node associated with the object's transforms. */
2075 if (target_id == id) {
2076 /* Ignore input dependency if we're driving properties of
2077 * the same ID, otherwise we'll be ending up in a cyclic
2078 * dependency here. */
2079 continue;
2080 }
2082 add_relation(target_key, driver_key, "Target -> Driver");
2083 }
2084 else if (dtar->rna_path != nullptr && dtar->rna_path[0] != '\0') {
2086 driver_key, self_key, target_id, target_prop, dtar->rna_path);
2087
2088 /* Add relations to all other cameras used by the scene timeline if applicable. */
2089 if (const char *camera_path = get_rna_path_relative_to_scene_camera(
2090 scene_, target_prop, dtar->rna_path))
2091 {
2092 build_driver_scene_camera_variable(driver_key, self_key, scene_, camera_path);
2093 }
2094
2095 /* The RNA getter for `object.data` can write to the mesh datablock due
2096 * to the call to `BKE_mesh_wrapper_ensure_subdivision()`. This relation
2097 * ensures it is safe to call when the driver is evaluated.
2098 *
2099 * For the sake of making the code more generic/defensive, the relation
2100 * is added for any geometry type.
2101 *
2102 * See #96289 for more info. */
2103 if (object != nullptr && OB_TYPE_IS_GEOMETRY(object->type)) {
2104 StringRef rna_path(dtar->rna_path);
2105 if (rna_path == "data" || rna_path.startswith("data.")) {
2106 ComponentKey ob_key(target_id, NodeType::GEOMETRY);
2107 add_relation(ob_key, driver_key, "ID -> Driver");
2108 }
2109 }
2110 }
2111 else {
2112 /* If rna_path is nullptr, and DTAR_FLAG_STRUCT_REF isn't set, this
2113 * is an incomplete target reference, so nothing to do here. */
2114 }
2115 }
2117 }
2118}
2119
2121 const RNAPathKey &self_key,
2122 Scene *scene,
2123 const char *rna_path)
2124{
2125 /* First, add relations to all cameras used in the timeline,
2126 * excluding scene->camera which was already handled by the caller. */
2127 bool animated = false;
2128
2129 for (TimeMarker &marker : scene->markers) {
2130 if (!ELEM(marker.camera, nullptr, scene->camera)) {
2131 PointerRNA camera_ptr = RNA_id_pointer_create(&marker.camera->id);
2133 build_driver_rna_path_variable(driver_key, self_key, &scene->id, camera_ptr, rna_path);
2134 animated = true;
2135 }
2136 }
2137
2138 /* If timeline indeed switches the camera, this variable also implicitly depends on time. */
2139 if (animated) {
2140 TimeSourceKey time_src_key;
2141 add_relation(time_src_key, driver_key, "TimeSrc -> Driver Camera Ref");
2142 }
2143}
2144
2146 const RNAPathKey &self_key,
2147 ID *target_id,
2148 const PointerRNA &target_prop,
2149 const char *rna_path)
2150{
2151 RNAPathKey variable_exit_key(target_prop, rna_path, RNAPointerSource::EXIT);
2152 if (!variable_exit_key.ptr) {
2153 return;
2154 }
2155 if (is_same_bone_dependency(variable_exit_key, self_key) ||
2156 is_same_nodetree_node_dependency(variable_exit_key, self_key))
2157 {
2158 return;
2159 }
2160 add_relation(variable_exit_key, driver_key, "RNA Target -> Driver");
2161
2162 /* It is possible that RNA path points to a property of a different ID than the target_id:
2163 * for example, paths like "data" on Object, "camera" on Scene.
2164 *
2165 * For the demonstration purposes lets consider a driver variable uses Scene ID as target
2166 * and "camera.location.x" as its RNA path. If the scene has 2 different cameras at
2167 * 2 different locations changing the active scene camera is expected to immediately be
2168 * reflected in the variable value. In order to achieve this behavior we create a relation
2169 * from the target ID to the driver so that if the ID property of the target ID changes the
2170 * driver is re-evaluated.
2171 *
2172 * The most straightforward (at the moment of writing this comment) way of figuring out
2173 * such relation is to use copy-on-evaluation operation of the target ID. There are two down
2174 * sides of this approach which are considered a design limitation as there is a belief
2175 * that they are not common in practice or are not reliable due to other issues:
2176 *
2177 * - IDs which are not covered with the copy-on-evaluation mechanism.
2178 *
2179 * Such IDs are either do not have ID properties, or are not part of the dependency
2180 * graph.
2181 *
2182 * - Modifications of evaluated IDs from a Python handler.
2183 * Such modifications are not fully integrated in the dependency graph evaluation as it
2184 * has issues with copy-on-evaluation tagging and the fact that relations are defined by the
2185 * original main database status.
2186 *
2187 * The original report for this is #98618.
2188 *
2189 * The not-so-obvious part is that we don't do such relation for the context properties.
2190 * They are resolved at the graph build time and do not change at runtime (#107081).
2191 * Thus scene has to be excluded as a special case; this is OK because changes to
2192 * scene.camera not caused by animation should actually force a dependency graph rebuild.
2193 */
2194 if (target_id != variable_exit_key.ptr.owner_id && target_id->id_type() != ID_SCE) {
2195 if (deg_eval_copy_is_needed(target_id->id_type())) {
2196 ComponentKey target_id_key(target_id, NodeType::COPY_ON_EVAL);
2197 add_relation(target_id_key, driver_key, "Target ID -> Driver");
2198 }
2199 }
2200}
2201
2203 const char *rna_path_from_target_prop)
2204{
2205 if (rna_path_from_target_prop == nullptr || rna_path_from_target_prop[0] == '\0') {
2206 return;
2207 }
2208
2209 PointerRNA ptr;
2210 PropertyRNA *prop;
2211 int index;
2212 if (!RNA_path_resolve_full(&target_prop, rna_path_from_target_prop, &ptr, &prop, &index)) {
2213 return;
2214 }
2215 if (prop == nullptr) {
2216 return;
2217 }
2218 if (!rna_prop_affects_parameters_node(&ptr, prop)) {
2219 return;
2220 }
2221 if (ptr.owner_id) {
2222 build_id(ptr.owner_id);
2223 }
2224 const char *prop_identifier = RNA_property_identifier(prop);
2225 /* Custom properties of bones are placed in their components to improve granularity. */
2226 OperationKey id_property_key;
2227 if (RNA_struct_is_a(ptr.type, RNA_PoseBone)) {
2228 const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr.data);
2229 id_property_key = OperationKey(
2230 ptr.owner_id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, prop_identifier);
2231 /* Create relation from the parameters component so that tagging armature for parameters update
2232 * properly propagates updates to all properties on bones and deeper (if needed). */
2233 OperationKey parameters_init_key(
2236 parameters_init_key, id_property_key, "Init -> ID Property", RELATION_CHECK_BEFORE_ADD);
2237 }
2238 else {
2239 id_property_key = OperationKey(
2241 }
2242 OperationKey parameters_exit_key(
2245 id_property_key, parameters_exit_key, "ID Property -> Done", RELATION_CHECK_BEFORE_ADD);
2246}
2247
2249{
2253 add_relation(parameters_entry_key, parameters_eval_key, "Entry -> Eval");
2254 add_relation(parameters_eval_key, parameters_exit_key, "Entry -> Exit");
2255}
2256
2258{
2260 ComponentKey geometry_key(&object->id, NodeType::GEOMETRY);
2261 ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
2262 add_relation(geometry_key, dimensions_key, "Geometry -> Dimensions");
2263 add_relation(transform_key, dimensions_key, "Transform -> Dimensions");
2264}
2265
2267{
2268 if (built_map_.check_is_built_and_tag(world)) {
2269 return;
2270 }
2271
2272 const BuilderStack::ScopedEntry stack_entry = stack_.trace(world->id);
2273
2274 build_idproperties(world->id.properties);
2275 build_idproperties(world->id.system_properties);
2276 /* animation */
2277 build_animdata(&world->id);
2278 build_parameters(&world->id);
2279
2280 /* Animated / driven parameters (without nodetree). */
2282 ComponentKey parameters_key(&world->id, NodeType::PARAMETERS);
2283 add_relation(parameters_key, world_key, "World's parameters");
2284
2285 /* world's nodetree */
2286 if (world->nodetree != nullptr) {
2287 build_nodetree(world->nodetree);
2288 OperationKey ntree_key(
2290 add_relation(ntree_key, world_key, "World's NTree");
2291 build_nested_nodetree(&world->id, world->nodetree);
2292 }
2293}
2294
2296{
2297 RigidBodyWorld *rbw = scene->rigidbody_world;
2300 /* Simulation depends on time. */
2301 TimeSourceKey time_src_key;
2302 add_relation(time_src_key, rb_init_key, "TimeSrc -> Rigidbody Init");
2303 /* Simulation should always be run after initialization. */
2304 /* NOTE: It is possible in theory to have dependency cycle which involves
2305 * this relation. We never want it to be killed. */
2306 add_relation(rb_init_key, rb_simulate_key, "Rigidbody [Init -> SimStep]", RELATION_FLAG_GODMODE);
2307 /* Effectors should be evaluated at the time simulation is being
2308 * initialized.
2309 * TODO(sergey): Verify that it indeed goes to initialization and not to a
2310 * simulation. */
2311 ListBaseT<EffectorRelation> *effector_relations = build_effector_relations(
2313 for (EffectorRelation &effector_relation : *effector_relations) {
2314 ComponentKey effector_transform_key(&effector_relation.ob->id, NodeType::TRANSFORM);
2315 add_relation(effector_transform_key, rb_init_key, "RigidBody Field");
2316 if (effector_relation.pd != nullptr) {
2317 const short shape = effector_relation.pd->shape;
2319 ComponentKey effector_geometry_key(&effector_relation.ob->id, NodeType::GEOMETRY);
2320 add_relation(effector_geometry_key, rb_init_key, "RigidBody Field");
2321 }
2322 if ((effector_relation.pd->forcefield == PFIELD_TEXTURE) &&
2323 (effector_relation.pd->tex != nullptr))
2324 {
2325 ComponentKey tex_key(&effector_relation.pd->tex->id, NodeType::GENERIC_DATABLOCK);
2326 add_relation(tex_key, rb_init_key, "Force field Texture");
2327 }
2328 }
2329 }
2330 /* Objects. */
2331 if (rbw->group != nullptr) {
2332 build_collection(nullptr, rbw->group);
2334 if (object->type != OB_MESH) {
2335 continue;
2336 }
2337 if (object->rigidbody_object == nullptr) {
2338 continue;
2339 }
2340
2341 if (object->parent != nullptr && object->parent->rigidbody_object != nullptr &&
2342 object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND)
2343 {
2344 /* If we are a child of a compound shape object, the transforms and sim evaluation will be
2345 * handled by the parent compound shape object. Do not add any evaluation triggers
2346 * for the child objects.
2347 */
2348 continue;
2349 }
2350
2351 /* Simulation uses object transformation after parenting and solving constraints. */
2352 OperationKey object_transform_simulation_init_key(
2354 OperationKey object_transform_eval_key(
2356 add_relation(object_transform_simulation_init_key,
2357 rb_simulate_key,
2358 "Object Transform -> Rigidbody Sim Eval");
2359 /* Geometry must be known to create the rigid body. RBO_MESH_BASE
2360 * uses the non-evaluated mesh, so then the evaluation is
2361 * unnecessary. */
2362 if (rigidbody_object_depends_on_evaluated_geometry(object->rigidbody_object)) {
2363 /* NOTE: We prefer this relation to be never killed, to avoid
2364 * access partially evaluated mesh from solver. */
2365 ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY);
2366 add_relation(object_geometry_key,
2367 rb_simulate_key,
2368 "Object Geom Eval -> Rigidbody Sim Eval",
2370 }
2371
2372 /* Final transform is whatever the solver gave to us. */
2373 if (object->rigidbody_object->type == RBO_TYPE_ACTIVE) {
2374 /* We do not have to update the objects final transform after the simulation if it is
2375 * passive or controlled by the animation system in blender.
2376 * (Bullet doesn't move the object at all in these cases).
2377 * But we can't update the depsgraph when the animated property in changed during playback.
2378 * So always assume that active bodies needs updating. */
2379 OperationKey rb_transform_copy_key(
2381 /* Rigid body synchronization depends on the actual simulation. */
2382 add_relation(rb_simulate_key, rb_transform_copy_key, "Rigidbody Sim Eval -> RBO Sync");
2383
2384 OperationKey object_transform_final_key(
2386 add_relation(rb_transform_copy_key,
2387 object_transform_final_key,
2388 "Rigidbody Sync -> Transform Final");
2389 }
2390
2391 /* Relations between colliders and force fields, needed for force field absorption. */
2393 }
2395 }
2396}
2397
2399{
2401 OperationKey eval_init_key(
2403 OperationKey eval_done_key(
2406 if (BKE_ptcache_object_has(scene_, object, 0)) {
2407 ComponentKey point_cache_key(&object->id, NodeType::POINT_CACHE);
2409 eval_key, point_cache_key, "Particle Point Cache", RELATION_FLAG_FLUSH_USER_EDIT_ONLY);
2410 }
2411 /* Particle systems. */
2412 for (ParticleSystem &psys : object->particlesystem) {
2413 ParticleSettings *part = psys.part;
2414 /* Build particle settings relations.
2415 * NOTE: The call itself ensures settings are only build once. */
2417 /* This particle system. */
2418 OperationKey psys_key(
2420 /* Update particle system when settings changes. */
2421 OperationKey particle_settings_key(
2423 add_relation(particle_settings_key, eval_init_key, "Particle Settings Change");
2424 add_relation(eval_init_key, psys_key, "Init -> PSys");
2425 add_relation(psys_key, eval_done_key, "PSys -> Done");
2426 /* TODO(sergey): Currently particle update is just a placeholder,
2427 * hook it to the ubereval node so particle system is getting updated
2428 * on playback. */
2429 add_relation(psys_key, obdata_ubereval_key, "PSys -> UberEval");
2430 /* Collisions. */
2431 if (part->type != PART_HAIR) {
2433 psys_key, object, part->collision_group, "Particle Collision");
2434 }
2435 else if ((psys.flag & PSYS_HAIR_DYNAMICS) && psys.clmd != nullptr &&
2436 psys.clmd->coll_parms != nullptr)
2437 {
2439 psys_key, object, psys.clmd->coll_parms->group, "Hair Collision");
2440 }
2441 /* Effectors. */
2443 object,
2444 &psys,
2445 part->effector_weights,
2446 part->type == PART_HAIR,
2447 "Particle Field");
2448 /* Boids. */
2449 if (part->boids != nullptr) {
2450 for (BoidState &state : part->boids->states) {
2451 for (BoidRule &rule : state.rules) {
2452 Object *ruleob = nullptr;
2453 if (rule.type == eBoidRuleType_Avoid) {
2454 ruleob = (reinterpret_cast<BoidRuleGoalAvoid *>(&rule))->ob;
2455 }
2456 else if (rule.type == eBoidRuleType_FollowLeader) {
2457 ruleob = (reinterpret_cast<BoidRuleFollowLeader *>(&rule))->ob;
2458 }
2459 if (ruleob != nullptr) {
2460 ComponentKey ruleob_key(&ruleob->id, NodeType::TRANSFORM);
2461 add_relation(ruleob_key, psys_key, "Boid Rule");
2462 }
2463 }
2464 }
2465 }
2466 /* Keyed particle targets. */
2468 for (ParticleTarget &particle_target : psys.targets) {
2469 if (ELEM(particle_target.ob, nullptr, object)) {
2470 continue;
2471 }
2472 /* Make sure target object is pulled into the graph. */
2473 build_object(particle_target.ob);
2474 /* Use geometry component, since that's where particles are
2475 * actually evaluated. */
2476 ComponentKey target_key(&particle_target.ob->id, NodeType::GEOMETRY);
2477 add_relation(target_key, psys_key, "Keyed Target");
2478 }
2479 }
2480 /* Visualization. */
2481 switch (part->ren_as) {
2482 case PART_DRAW_OB:
2483 if (part->instance_object != nullptr) {
2484 /* Make sure object's relations are all built. */
2486 /* Build relation for the particle visualization. */
2488 }
2489 break;
2490 case PART_DRAW_GR:
2491 if (part->instance_collection != nullptr) {
2492 build_collection(nullptr, part->instance_collection);
2493 for (CollectionObject &go : part->instance_collection->gobject) {
2495 }
2496 }
2497 break;
2498 default:
2499 break;
2500 }
2501 }
2502 /* Particle depends on the object transform, so that channel is to be ready
2503 * first. */
2504 add_depends_on_transform_relation(&object->id, obdata_ubereval_key, "Particle Eval");
2505}
2506
2508{
2509 if (built_map_.check_is_built_and_tag(part)) {
2510 return;
2511 }
2512
2513 const BuilderStack::ScopedEntry stack_entry = stack_.trace(part->id);
2514
2515 /* Animation data relations. */
2516 build_animdata(&part->id);
2517 build_parameters(&part->id);
2518 OperationKey particle_settings_init_key(
2520 OperationKey particle_settings_eval_key(
2522 OperationKey particle_settings_reset_key(
2525 particle_settings_init_key, particle_settings_eval_key, "Particle Settings Init Order");
2526 add_relation(particle_settings_reset_key, particle_settings_eval_key, "Particle Settings Reset");
2527 /* Texture slots. */
2528 for (MTex *mtex : part->mtex) {
2529 if (mtex == nullptr || mtex->tex == nullptr) {
2530 continue;
2531 }
2532 build_texture(mtex->tex);
2533 ComponentKey texture_key(&mtex->tex->id, NodeType::GENERIC_DATABLOCK);
2534 add_relation(texture_key,
2535 particle_settings_reset_key,
2536 "Particle Texture -> Particle Reset",
2538 add_relation(texture_key, particle_settings_eval_key, "Particle Texture -> Particle Eval");
2539 /* TODO(sergey): Consider moving texture space handling to its own
2540 * function. */
2541 if (mtex->texco == TEXCO_OBJECT && mtex->object != nullptr) {
2542 ComponentKey object_key(&mtex->object->id, NodeType::TRANSFORM);
2543 add_relation(object_key, particle_settings_eval_key, "Particle Texture Space");
2544 }
2545 }
2546 if (check_id_has_anim_component(&part->id)) {
2547 ComponentKey animation_key(&part->id, NodeType::ANIMATION);
2548 add_relation(animation_key, particle_settings_eval_key, "Particle Settings Animation");
2549 }
2550}
2551
2553 ParticleSystem *psys,
2554 Object *draw_object)
2555{
2556 OperationKey psys_key(
2559 ComponentKey dup_ob_key(&draw_object->id, NodeType::TRANSFORM);
2560 add_relation(dup_ob_key, psys_key, "Particle Object Visualization");
2561 if (draw_object->type == OB_MBALL) {
2562 ComponentKey dup_geometry_key(&draw_object->id, NodeType::GEOMETRY);
2563 add_relation(obdata_ubereval_key, dup_geometry_key, "Particle MBall Visualization");
2564 }
2565}
2566
2567/* Shapekeys */
2569{
2570 if (built_map_.check_is_built_and_tag(key)) {
2571 return;
2572 }
2573
2574 const BuilderStack::ScopedEntry stack_entry = stack_.trace(key->id);
2575
2578 /* Attach animdata to geometry. */
2579 build_animdata(&key->id);
2580 build_parameters(&key->id);
2581 /* Connect all blocks properties to the final result evaluation. */
2582 ComponentKey geometry_key(&key->id, NodeType::GEOMETRY);
2584 for (KeyBlock &key_block : key->block) {
2585 OperationKey key_block_key(
2587 add_relation(key_block_key, geometry_key, "Key Block Properties");
2588 add_relation(key_block_key, parameters_eval_key, "Key Block Properties");
2589 }
2590}
2591
2613{
2614 ID *obdata = object->data;
2615 /* Init operation of object-level geometry evaluation. */
2617 /* Get nodes for result of obdata's evaluation, and geometry evaluation
2618 * on object. */
2619 ComponentKey obdata_geom_key(obdata, NodeType::GEOMETRY);
2620 ComponentKey geom_key(&object->id, NodeType::GEOMETRY);
2621 /* Link components to each other. */
2622 add_relation(obdata_geom_key, geom_key, "Object Geometry Base Data");
2624 /* Special case: modifiers evaluation queries scene for various things like
2625 * data mask to be used. We add relation here to ensure object is never
2626 * evaluated prior to Scene's evaluated copy is ready. */
2627 ComponentKey scene_key(&scene_->id, NodeType::SCENE);
2628 add_relation(scene_key, obdata_ubereval_key, "Copy-on-Eval Relation", RELATION_FLAG_NO_FLUSH);
2629 /* Relation to the instance, so that instancer can use geometry of this object. */
2632 "Transform -> Instance Geometry");
2633 /* Shader FX. */
2634 if (object->shader_fx.first() != nullptr) {
2636 ctx.scene = scene_;
2637 ctx.object = object;
2638 for (ShaderFxData &fx : object->shader_fx) {
2640 if (fxi->update_depsgraph) {
2641 DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
2642 ctx.node = reinterpret_cast<blender::DepsNodeHandle *>(&handle);
2643 fxi->update_depsgraph(&fx, &ctx);
2644 }
2645 if (BKE_shaderfx_depends_ontime(&fx)) {
2646 TimeSourceKey time_src_key;
2647 add_relation(time_src_key, obdata_ubereval_key, "Time Source");
2648 }
2649 }
2650 }
2651 /* Materials. */
2652 build_materials(&object->id, object->mat, object->totcol);
2653 /* Geometry collision. */
2655 // add geometry collider relations
2656 }
2657 /* Make sure uber update is the last in the dependencies.
2658 * Only do it here unless there are modifiers. This avoids transitive relations. */
2659 if (object->modifiers.is_empty()) {
2660 OperationKey obdata_ubereval_key(
2662 add_relation(geom_init_key, obdata_ubereval_key, "Object Geometry UberEval");
2663 }
2664 if (object->type == OB_MBALL) {
2665 Object *mom = BKE_mball_basis_find(*bmain_, scene_, object);
2666 ComponentKey mom_geom_key(&mom->id, NodeType::GEOMETRY);
2667 /* motherball - mom depends on children! */
2668 if (mom == object) {
2669 ComponentKey mom_transform_key(&mom->id, NodeType::TRANSFORM);
2670 add_relation(mom_transform_key, mom_geom_key, "Metaball Motherball Transform -> Geometry");
2671 }
2672 else {
2673 ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
2674 add_relation(geom_key, mom_geom_key, "Metaball Motherball");
2675 add_relation(transform_key, mom_geom_key, "Metaball Motherball");
2676 }
2677 }
2678 /* NOTE: This is compatibility code to support particle systems
2679 *
2680 * for viewport being properly rendered in final render mode.
2681 * This relation is similar to what dag_object_time_update_flags()
2682 * was doing for mesh objects with particle system.
2683 *
2684 * Ideally we need to get rid of this relation. */
2685 if (object_particles_depends_on_time(object)) {
2686 TimeSourceKey time_key;
2687 OperationKey obdata_ubereval_key(
2689 add_relation(time_key, obdata_ubereval_key, "Legacy particle time");
2690 }
2691 /* Object data data-block. */
2693 Key *key = BKE_key_from_object(object);
2694 if (key != nullptr) {
2695 if (key->adt != nullptr) {
2696 if (key->adt->action || key->adt->nla_tracks.first_) {
2697 ComponentKey obdata_key(object->data, NodeType::GEOMETRY);
2698 ComponentKey adt_key(&key->id, NodeType::ANIMATION);
2699 add_relation(adt_key, obdata_key, "Animation");
2700 }
2701 }
2702 }
2703 build_dimensions(object);
2704 /* Synchronization back to original object. */
2705 ComponentKey final_geometry_key(&object->id, NodeType::GEOMETRY);
2706 OperationKey synchronize_key(
2708 add_relation(final_geometry_key, synchronize_key, "Synchronize to Original");
2709 /* Batch cache. */
2710 OperationKey object_data_select_key(
2712 OperationKey object_select_key(
2714 add_relation(object_data_select_key, object_select_key, "Data Selection -> Object Selection");
2716 geom_key, object_select_key, "Object Geometry -> Select Update", RELATION_FLAG_NO_FLUSH);
2717 /* Shading. */
2718 ComponentKey geometry_shading_key(obdata, NodeType::SHADING);
2720 add_relation(geometry_shading_key, object_shading_key, "Geometry Shading -> Object Shading");
2721}
2722
2724{
2725 if (built_map_.check_is_built_and_tag(obdata)) {
2726 return;
2727 }
2728
2729 const BuilderStack::ScopedEntry stack_entry = stack_.trace(*obdata);
2730
2733 /* Animation. */
2734 build_animdata(obdata);
2735 build_parameters(obdata);
2736 /* ShapeKeys. */
2737 Key *key = BKE_key_from_id(obdata);
2738 if (key != nullptr) {
2739 build_shapekeys(key);
2740 }
2741 /* Link object data evaluation node to exit operation. */
2742 OperationKey obdata_geom_eval_key(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
2744 add_relation(obdata_geom_eval_key, obdata_geom_done_key, "ObData Geom Eval Done");
2745
2746 /* Link object data evaluation to parameter evaluation. */
2747 ComponentKey parameters_key(obdata, NodeType::PARAMETERS);
2748 add_relation(parameters_key, obdata_geom_eval_key, "ObData Geom Params");
2749
2750 /* Type-specific links. */
2751 const ID_Type id_type = obdata->id_type();
2752 switch (id_type) {
2753 case ID_ME:
2754 break;
2755 case ID_MB:
2756 break;
2757 case ID_CU_LEGACY: {
2758 Curve *cu = id_cast<Curve *>(obdata);
2759 if (cu->bevobj != nullptr) {
2760 ComponentKey bevob_geom_key(&cu->bevobj->id, NodeType::GEOMETRY);
2761 add_relation(bevob_geom_key, obdata_geom_eval_key, "Curve Bevel Geometry");
2762 ComponentKey bevob_key(&cu->bevobj->id, NodeType::TRANSFORM);
2763 add_relation(bevob_key, obdata_geom_eval_key, "Curve Bevel Transform");
2764 build_object(cu->bevobj);
2765 }
2766 if (cu->taperobj != nullptr) {
2767 ComponentKey taperob_key(&cu->taperobj->id, NodeType::GEOMETRY);
2768 add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper");
2770 }
2771 if (cu->textoncurve != nullptr) {
2772 ComponentKey textoncurve_geom_key(&cu->textoncurve->id, NodeType::GEOMETRY);
2773 add_relation(textoncurve_geom_key, obdata_geom_eval_key, "Text on Curve Geometry");
2774 ComponentKey textoncurve_key(&cu->textoncurve->id, NodeType::TRANSFORM);
2775 add_relation(textoncurve_key, obdata_geom_eval_key, "Text on Curve Transform");
2777 }
2778 /* Special relation to ensure active spline index gets properly updated.
2779 *
2780 * The active spline index is stored on the Curve data-block, and the curve evaluation might
2781 * create a new curve data-block for the result, which does not intrinsically sharing the
2782 * active spline index. Hence a special relation is added to ensure the modifier stack is
2783 * evaluated when selection changes. */
2784 {
2785 const OperationKey object_data_select_key(
2787 add_relation(object_data_select_key, obdata_geom_eval_key, "Active Spline Update");
2788 }
2789 break;
2790 }
2791 case ID_LT:
2792 break;
2793 case ID_GD_LEGACY: /* Grease Pencil */
2794 {
2795 bGPdata *gpd = id_cast<bGPdata *>(obdata);
2796
2797 /* Geometry cache needs to be recalculated on frame change
2798 * (e.g. to fix crashes after scrubbing the timeline when
2799 * onion skinning is enabled, since the ghosts need to be
2800 * re-added to the cache once scrubbing ends). */
2801 TimeSourceKey time_key;
2802 ComponentKey geometry_key(obdata, NodeType::GEOMETRY);
2803 add_relation(time_key, geometry_key, "GP Frame Change");
2804
2805 /* Geometry cache also needs to be recalculated when Material
2806 * settings change (e.g. when fill.opacity changes on/off,
2807 * we need to rebuild the bGPDstroke->triangles caches). */
2808 for (int i = 0; i < gpd->totcol; i++) {
2809 Material *ma = gpd->mat[i];
2810 if ((ma != nullptr) && (ma->gp_style != nullptr)) {
2812 add_relation(material_key, geometry_key, "Material -> GP Data");
2813 }
2814 }
2815
2816 /* Layer parenting need react to the parent object transformation. */
2817 for (bGPDlayer &gpl : gpd->layers) {
2818 if (gpl.parent != nullptr) {
2819 ComponentKey gpd_geom_key(&gpd->id, NodeType::GEOMETRY);
2820
2821 if (gpl.partype == PARBONE) {
2822 ComponentKey bone_key(&gpl.parent->id, NodeType::BONE, gpl.parsubstr);
2823 OperationKey armature_key(
2825
2826 add_relation(bone_key, gpd_geom_key, "Bone Parent");
2827 add_relation(armature_key, gpd_geom_key, "Armature Parent");
2828 }
2829 else {
2830 ComponentKey transform_key(&gpl.parent->id, NodeType::TRANSFORM);
2831 add_relation(transform_key, gpd_geom_key, "GPencil Parent Layer");
2832 }
2833 }
2834 }
2835 break;
2836 }
2837 case ID_CV: {
2838 Curves *curves_id = reinterpret_cast<Curves *>(obdata);
2839 if (curves_id->surface != nullptr) {
2840 build_object(curves_id->surface);
2841
2842 ComponentKey surface_geometry_key(&curves_id->surface->id, NodeType::GEOMETRY);
2843 add_relation(surface_geometry_key, obdata_geom_eval_key, "Curves Object Surface");
2844
2845 ComponentKey surface_transform_key(&curves_id->surface->id, NodeType::TRANSFORM);
2846 add_relation(surface_transform_key, obdata_geom_eval_key, "Curves Object Surface");
2847 }
2848 break;
2849 }
2850 case ID_PT:
2851 break;
2852 case ID_VO: {
2853 Volume *volume = id_cast<Volume *>(obdata);
2854 if (volume->is_sequence) {
2855 TimeSourceKey time_key;
2856 ComponentKey geometry_key(obdata, NodeType::GEOMETRY);
2857 add_relation(time_key, geometry_key, "Volume sequence time");
2858 }
2859 break;
2860 }
2861 case ID_GP: {
2862 GreasePencil &grease_pencil = *reinterpret_cast<GreasePencil *>(obdata);
2863
2864 /* Update geometry when time is changed. */
2865 TimeSourceKey time_key;
2867 add_relation(time_key, geometry_key, "Grease Pencil Frame Change");
2868
2869 /* Add relations for layer parents. */
2870 for (const bke::greasepencil::Layer *layer : grease_pencil.layers()) {
2871 Object *parent = layer->parent;
2872 if (parent == nullptr) {
2873 continue;
2874 }
2875 if (parent->type == OB_ARMATURE && !layer->parent_bone_name().is_empty()) {
2876 ComponentKey bone_key(&parent->id, NodeType::BONE, layer->parent_bone_name().c_str());
2877 OperationKey armature_key(
2879
2880 add_relation(bone_key, geometry_key, "Grease Pencil Layer Bone Parent");
2881 add_relation(armature_key, geometry_key, "Grease Pencil Layer Armature Parent");
2882 }
2883 else {
2884 ComponentKey transform_key(&parent->id, NodeType::TRANSFORM);
2885 add_relation(transform_key, geometry_key, "Grease Pencil Layer Object Parent");
2886 }
2887 }
2888 break;
2889 }
2890 default:
2891 BLI_assert_msg(0, "Should not happen");
2892 break;
2893 }
2894}
2895
2896/* Empties can have geometry nodes modifiers which require specific relations to work correctly. */
2898{
2900 /* Special case: modifiers evaluation queries scene for various things like
2901 * data mask to be used. We add relation here to ensure object is never
2902 * evaluated prior to Scene's evaluated copy is ready. */
2903 ComponentKey scene_key(&scene_->id, NodeType::SCENE);
2904 add_relation(scene_key, obdata_ubereval_key, "Copy-on-Eval Relation", RELATION_FLAG_NO_FLUSH);
2905 /* Relation to the instance, so that instancer can use geometry of this object. */
2908 "Transform -> Instance Geometry");
2909 /* Synchronization back to original object. This is needed for the modifier errors to be copied
2910 * back for example. */
2911 ComponentKey final_geometry_key(&object->id, NodeType::GEOMETRY);
2912 OperationKey synchronize_key(
2914 add_relation(final_geometry_key, synchronize_key, "Synchronize to Original");
2915
2916 /* If the empty is an instanced collection, the geometry of the empty depends on the geometry of
2917 * the collection (and hence all the geometry of all contained objects).*/
2918 if (object->instance_collection) {
2919 ComponentKey collection_geometry_key(&object->instance_collection->id, NodeType::GEOMETRY);
2921 collection_geometry_key, final_geometry_key, "Collection Geometry -> Empty Geometry");
2922 }
2923}
2924
2926{
2927 if (built_map_.check_is_built_and_tag(armature)) {
2928 return;
2929 }
2930
2931 const BuilderStack::ScopedEntry stack_entry = stack_.trace(armature->id);
2932
2933 build_idproperties(armature->id.properties);
2935 build_animdata(&armature->id);
2936 build_parameters(&armature->id);
2937 build_armature_bones(&armature->bonebase);
2938 build_armature_bone_collections(armature->collections_span());
2939}
2940
2942{
2943 for (Bone &bone : *bones) {
2944 build_idproperties(bone.prop);
2945 build_idproperties(bone.system_properties);
2946 build_armature_bones(&bone.childbase);
2947 }
2948}
2949
2951{
2952 for (BoneCollection *bcoll : collections) {
2953 build_idproperties(bcoll->prop);
2954 build_idproperties(bcoll->system_properties);
2955 }
2956}
2957
2959{
2960 if (built_map_.check_is_built_and_tag(camera)) {
2961 return;
2962 }
2963
2964 const BuilderStack::ScopedEntry stack_entry = stack_.trace(camera->id);
2965
2966 build_idproperties(camera->id.properties);
2967 build_idproperties(camera->id.system_properties);
2968 build_animdata(&camera->id);
2970 if (camera->dof.focus_object != nullptr) {
2971 build_object(camera->dof.focus_object);
2972 ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS);
2973 ComponentKey dof_ob_key(&camera->dof.focus_object->id, NodeType::TRANSFORM);
2974 add_relation(dof_ob_key, camera_parameters_key, "Camera DOF");
2975 if (camera->dof.focus_object->type == OB_ARMATURE && camera->dof.focus_subtarget[0]) {
2976 OperationKey target_key(&camera->dof.focus_object->id,
2978 camera->dof.focus_subtarget,
2980 add_relation(target_key, camera_parameters_key, "Camera DOF subtarget");
2981 }
2982 }
2983}
2984
2985/* Lights */
2987{
2988 if (built_map_.check_is_built_and_tag(lamp)) {
2989 return;
2990 }
2991
2992 const BuilderStack::ScopedEntry stack_entry = stack_.trace(lamp->id);
2993
2994 build_idproperties(lamp->id.properties);
2995 build_idproperties(lamp->id.system_properties);
2996 build_animdata(&lamp->id);
2997 build_parameters(&lamp->id);
2998
2999 ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
3000
3001 /* For allowing drivers on lamp properties. */
3002 ComponentKey shading_key(&lamp->id, NodeType::SHADING);
3003 add_relation(lamp_parameters_key, shading_key, "Light Shading Parameters");
3004
3005 /* light's nodetree */
3006 if (lamp->nodetree != nullptr) {
3007 build_nodetree(lamp->nodetree);
3008 OperationKey ntree_key(
3010 add_relation(ntree_key, shading_key, "NTree->Light Parameters");
3011 build_nested_nodetree(&lamp->id, lamp->nodetree);
3012 }
3013}
3014
3016{
3017 build_idproperties(socket->prop);
3018
3019 if (socket->type == SOCK_OBJECT) {
3020 Object *object = (static_cast<bNodeSocketValueObject *>(socket->default_value))->value;
3021 if (object != nullptr) {
3022 build_object(object);
3023 }
3024 }
3025 else if (socket->type == SOCK_IMAGE) {
3026 Image *image = (static_cast<bNodeSocketValueImage *>(socket->default_value))->value;
3027 if (image != nullptr) {
3029 }
3030 }
3031 else if (socket->type == SOCK_COLLECTION) {
3032 Collection *collection =
3033 (static_cast<bNodeSocketValueCollection *>(socket->default_value))->value;
3034 if (collection != nullptr) {
3035 build_collection(nullptr, collection);
3036 }
3037 }
3038 else if (socket->type == SOCK_TEXTURE) {
3039 Tex *texture = (static_cast<bNodeSocketValueTexture *>(socket->default_value))->value;
3040 if (texture != nullptr) {
3042 }
3043 }
3044 else if (socket->type == SOCK_MATERIAL) {
3045 Material *material = (static_cast<bNodeSocketValueMaterial *>(socket->default_value))->value;
3046 if (material != nullptr) {
3047 build_material(material);
3048 }
3049 }
3050 else if (socket->type == SOCK_FONT) {
3051 VFont *font = (static_cast<bNodeSocketValueFont *>(socket->default_value))->value;
3052 if (font != nullptr) {
3053 build_vfont(font);
3054 }
3055 }
3056 else if (socket->type == SOCK_SCENE) {
3057 Scene *scene = (static_cast<bNodeSocketValueScene *>(socket->default_value))->value;
3058 if (scene != nullptr) {
3060 }
3061 }
3062 else if (socket->type == SOCK_TEXT_ID) {
3063 /* Text data-blocks don't use the depsgraph. */
3064 }
3065 else if (socket->type == SOCK_MASK) {
3066 Mask *mask = (static_cast<bNodeSocketValueMask *>(socket->default_value))->value;
3067 if (mask != nullptr) {
3069 }
3070 }
3071 else if (socket->type == SOCK_SOUND) {
3072 bSound *sound = (static_cast<bNodeSocketValueSound *>(socket->default_value))->value;
3073 if (sound != nullptr) {
3074 build_sound(sound);
3075 }
3076 }
3077}
3078
3080{
3081 if (ntree == nullptr) {
3082 return;
3083 }
3084 if (built_map_.check_is_built_and_tag(ntree)) {
3085 return;
3086 }
3087
3088 const BuilderStack::ScopedEntry stack_entry = stack_.trace(ntree->id);
3089
3092 build_animdata(&ntree->id);
3093 build_parameters(&ntree->id);
3095 OperationKey ntree_geo_preprocess_key(
3097 if (ntree->type == NTREE_GEOMETRY) {
3099 add_relation(ntree_cow_key, ntree_geo_preprocess_key, "Copy-on-Eval -> Preprocess");
3100 add_relation(ntree_geo_preprocess_key,
3101 ntree_output_key,
3102 "Preprocess -> Output",
3104 }
3105 /* nodetree's nodes... */
3106 for (bNode *bnode : ntree->all_nodes()) {
3107 build_idproperties(bnode->prop);
3108 for (bNodeSocket &socket : bnode->inputs) {
3109 build_nodetree_socket(&socket);
3110 }
3111 for (bNodeSocket &socket : bnode->outputs) {
3112 build_nodetree_socket(&socket);
3113 }
3114
3115 if (ntree->type == NTREE_SHADER && bnode->is_type("ShaderNodeAttribute"_ustr)) {
3116 NodeShaderAttribute *attr = static_cast<NodeShaderAttribute *>(bnode->storage);
3117 if (attr->type == SHD_ATTRIBUTE_VIEW_LAYER && STREQ(attr->name, "frame_current")) {
3118 TimeSourceKey time_src_key;
3119 add_relation(time_src_key, ntree_output_key, "TimeSrc -> Node");
3120 }
3121 }
3122
3123 ID *id = bnode->id;
3124 if (id == nullptr) {
3125 continue;
3126 }
3127 ID_Type id_type = id->id_type();
3128 if (id_type == ID_MA) {
3129 build_material(id_cast<Material *>(id));
3130 ComponentKey material_key(id, NodeType::SHADING);
3131 add_relation(material_key, ntree_output_key, "Material -> Node");
3132 }
3133 else if (id_type == ID_TE) {
3134 build_texture(id_cast<Tex *>(id));
3136 add_relation(texture_key, ntree_output_key, "Texture -> Node");
3137 }
3138 else if (id_type == ID_IM) {
3139 build_image(id_cast<Image *>(id));
3141 add_relation(image_key, ntree_output_key, "Image -> Node");
3142 }
3143 else if (id_type == ID_OB) {
3144 build_object(id_cast<Object *>(id));
3145 ComponentKey object_transform_key(id, NodeType::TRANSFORM);
3146 add_relation(object_transform_key, ntree_output_key, "Object Transform -> Node");
3147 if (object_have_geometry_component(reinterpret_cast<Object *>(id))) {
3148 ComponentKey object_geometry_key(id, NodeType::GEOMETRY);
3149 add_relation(object_geometry_key, ntree_output_key, "Object Geometry -> Node");
3150 }
3151 }
3152 else if (id_type == ID_SCE) {
3153 Scene *node_scene = id_cast<Scene *>(id);
3154 build_scene_parameters(node_scene);
3155 /* Camera is used by defocus node.
3156 *
3157 * On the one hand it's annoying to always pull it in, but on another hand it's also annoying
3158 * to have hardcoded node-type exception here. */
3159 if (node_scene->camera != nullptr) {
3160 build_object(node_scene->camera);
3161 }
3162 }
3163 else if (id_type == ID_TXT) {
3164 /* Ignore script nodes. */
3165 }
3166 else if (id_type == ID_MSK) {
3167 build_mask(id_cast<Mask *>(id));
3169 add_relation(mask_key, ntree_output_key, "Mask -> Node");
3170 }
3171 else if (id_type == ID_MC) {
3172 build_movieclip(id_cast<MovieClip *>(id));
3174 add_relation(clip_key, ntree_output_key, "Clip -> Node");
3175 }
3176 else if (id_type == ID_VF) {
3177 build_vfont(id_cast<VFont *>(id));
3178 ComponentKey vfont_key(id, NodeType::PARAMETERS);
3179 add_relation(vfont_key, ntree_output_key, "VFont -> Node");
3180 }
3181 else if (id_type == ID_GR) {
3182 /* Build relations in the collection itself, but don't hook it up to the tree.
3183 * Relations from the collection to the tree are handled by the modifier's update_depsgraph()
3184 * callback.
3185 *
3186 * Other node trees do not currently support references to collections. Once they do this
3187 * code needs to be reconsidered. */
3188 build_collection(nullptr, reinterpret_cast<Collection *>(id));
3189 }
3190 else if (bnode->is_group()) {
3191 bNodeTree *group_ntree = id_cast<bNodeTree *>(id);
3192 build_nodetree(group_ntree);
3193 ComponentKey group_output_key(&group_ntree->id, NodeType::NTREE_OUTPUT);
3194 /* This relation is not necessary in all cases (e.g. when the group node is not connected to
3195 * the output). Currently, we lack the infrastructure to check for these cases efficiently.
3196 * That can be added later. */
3197 add_relation(group_output_key, ntree_output_key, "Group Node");
3198 if (group_ntree->type == NTREE_GEOMETRY) {
3199 OperationKey group_preprocess_key(&group_ntree->id,
3202 add_relation(group_preprocess_key, ntree_geo_preprocess_key, "Group Node Preprocess");
3203 }
3204 }
3205 else {
3206 /* Ignore this case. It can happen when the node type is not known currently. Either because
3207 * it belongs to an add-on or because it comes from a different Blender version that does
3208 * support the ID type here already. */
3209 }
3210 }
3211
3212 ntree->ensure_interface_cache();
3213 for (bNodeTreeInterfaceSocket *socket : ntree->interface_inputs()) {
3214 build_idproperties(socket->properties);
3215 }
3216 for (bNodeTreeInterfaceSocket *socket : ntree->interface_outputs()) {
3217 build_idproperties(socket->properties);
3218 }
3219
3220 if (check_id_has_anim_component(&ntree->id)) {
3221 ComponentKey animation_key(&ntree->id, NodeType::ANIMATION);
3222 add_relation(animation_key, ntree_output_key, "NTree Shading Parameters");
3223 if (ntree->type == NTREE_GEOMETRY) {
3224 add_relation(animation_key, ntree_geo_preprocess_key, "NTree Animation -> Preprocess");
3225 }
3226 }
3227}
3228
3229/* Recursively build graph for material */
3231{
3232 if (owner) {
3233 ComponentKey material_key(&material->id, NodeType::SHADING);
3234 OperationKey owner_shading_key(owner, NodeType::SHADING, OperationCode::SHADING);
3235 add_relation(material_key, owner_shading_key, "Material -> Owner Shading");
3236 }
3237
3238 if (built_map_.check_is_built_and_tag(material)) {
3239 return;
3240 }
3241
3242 const BuilderStack::ScopedEntry stack_entry = stack_.trace(material->id);
3243
3244 build_idproperties(material->id.properties);
3245 build_idproperties(material->id.system_properties);
3246 /* animation */
3247 build_animdata(&material->id);
3248 build_parameters(&material->id);
3249
3250 /* Animated / driven parameters (without nodetree). */
3252 ComponentKey parameters_key(&material->id, NodeType::PARAMETERS);
3253 add_relation(parameters_key, material_key, "Material's parameters");
3254
3255 /* material's nodetree */
3256 if (material->nodetree != nullptr) {
3257 build_nodetree(material->nodetree);
3258 OperationKey ntree_key(
3259 &material->nodetree->id, NodeType::NTREE_OUTPUT, OperationCode::NTREE_OUTPUT);
3260 add_relation(ntree_key, material_key, "Material's NTree");
3261 build_nested_nodetree(&material->id, material->nodetree);
3262 }
3263}
3264
3265void DepsgraphRelationBuilder::build_materials(ID *owner, Material **materials, int num_materials)
3266{
3267 for (int i = 0; i < num_materials; i++) {
3268 if (materials[i] == nullptr) {
3269 continue;
3270 }
3271 build_material(materials[i], owner);
3272 }
3273}
3274
3275/* Recursively build graph for texture */
3277{
3278 if (built_map_.check_is_built_and_tag(texture)) {
3279 return;
3280 }
3281
3282 const BuilderStack::ScopedEntry stack_entry = stack_.trace(texture->id);
3283
3284 /* texture itself */
3286 build_idproperties(texture->id.properties);
3287 build_idproperties(texture->id.system_properties);
3288 build_animdata(&texture->id);
3290
3291 /* texture's nodetree */
3292 if (texture->nodetree) {
3293 build_nodetree(texture->nodetree);
3294 OperationKey ntree_key(
3296 add_relation(ntree_key, texture_key, "Texture's NTree");
3297 build_nested_nodetree(&texture->id, texture->nodetree);
3298 }
3299
3300 /* Special cases for different IDs which texture uses. */
3301 if (texture->type == TEX_IMAGE) {
3302 if (texture->ima != nullptr) {
3303 build_image(texture->ima);
3304
3305 ComponentKey image_key(&texture->ima->id, NodeType::GENERIC_DATABLOCK);
3306 add_relation(image_key, texture_key, "Texture Image");
3307 }
3308 }
3309
3310 if (check_id_has_anim_component(&texture->id)) {
3311 ComponentKey animation_key(&texture->id, NodeType::ANIMATION);
3312 add_relation(animation_key, texture_key, "Datablock Animation");
3313 }
3314
3316 ComponentKey image_animation_key(&texture->id, NodeType::IMAGE_ANIMATION);
3317 add_relation(image_animation_key, texture_key, "Datablock Image Animation");
3318 }
3319}
3320
3322{
3323 if (built_map_.check_is_built_and_tag(image)) {
3324 return;
3325 }
3326
3327 const BuilderStack::ScopedEntry stack_entry = stack_.trace(image->id);
3328
3329 build_idproperties(image->id.properties);
3330 build_idproperties(image->id.system_properties);
3331 build_parameters(&image->id);
3332}
3333
3335{
3336 if (built_map_.check_is_built_and_tag(cache_file)) {
3337 return;
3338 }
3339
3340 const BuilderStack::ScopedEntry stack_entry = stack_.trace(cache_file->id);
3341
3342 build_idproperties(cache_file->id.properties);
3344 /* Animation. */
3345 build_animdata(&cache_file->id);
3346 build_parameters(&cache_file->id);
3347 if (check_id_has_anim_component(&cache_file->id)) {
3348 ComponentKey animation_key(&cache_file->id, NodeType::ANIMATION);
3349 ComponentKey datablock_key(&cache_file->id, NodeType::CACHE);
3350 add_relation(animation_key, datablock_key, "Datablock Animation");
3351 }
3352 if (check_id_has_driver_component(&cache_file->id)) {
3353 ComponentKey animation_key(&cache_file->id, NodeType::PARAMETERS);
3354 ComponentKey datablock_key(&cache_file->id, NodeType::CACHE);
3355 add_relation(animation_key, datablock_key, "Drivers -> Cache Eval");
3356 }
3357
3358 /* Cache file updates */
3359 if (cache_file->is_sequence) {
3360 OperationKey cache_update_key(
3362 TimeSourceKey time_src_key;
3363 add_relation(time_src_key, cache_update_key, "TimeSrc -> Cache File Eval");
3364 }
3365}
3366
3368{
3369 if (built_map_.check_is_built_and_tag(mask)) {
3370 return;
3371 }
3372
3373 const BuilderStack::ScopedEntry stack_entry = stack_.trace(mask->id);
3374
3375 ID *mask_id = &mask->id;
3378 /* F-Curve animation. */
3379 build_animdata(mask_id);
3380 build_parameters(mask_id);
3381 /* Own mask animation. */
3383 if (BKE_mask_is_animated(*mask)) {
3384 TimeSourceKey time_src_key;
3385 add_relation(time_src_key, mask_animation_key, "TimeSrc -> Mask Animation");
3386 }
3387 /* Final mask evaluation. */
3389 add_relation(mask_animation_key, mask_eval_key, "Mask Animation -> Mask Eval");
3390 /* Build parents. */
3391 for (MaskLayer &mask_layer : mask->masklayers) {
3392 for (MaskSpline &spline : mask_layer.splines) {
3393 for (int i = 0; i < spline.tot_point; i++) {
3394 MaskSplinePoint *point = &spline.points[i];
3395 MaskParent *parent = &point->parent;
3396 if (parent == nullptr || parent->id == nullptr) {
3397 continue;
3398 }
3399 build_id(parent->id);
3400 if (parent->id_type == ID_MC) {
3401 OperationKey movieclip_eval_key(
3403 add_relation(movieclip_eval_key, mask_eval_key, "Movie Clip -> Mask Eval");
3404 }
3405 }
3406 }
3407 }
3408}
3409
3411{
3412 if (built_map_.check_is_built_and_tag(linestyle)) {
3413 return;
3414 }
3415
3416 const BuilderStack::ScopedEntry stack_entry = stack_.trace(linestyle->id);
3417
3418 ID *linestyle_id = &linestyle->id;
3419 build_parameters(linestyle_id);
3420 build_idproperties(linestyle_id->properties);
3422 build_animdata(linestyle_id);
3423 build_nodetree(linestyle->nodetree);
3424}
3425
3427{
3428 if (built_map_.check_is_built_and_tag(clip)) {
3429 return;
3430 }
3431
3432 const BuilderStack::ScopedEntry stack_entry = stack_.trace(clip->id);
3433
3434 /* Animation. */
3437 build_animdata(&clip->id);
3438 build_parameters(&clip->id);
3439}
3440
3442{
3443 if (built_map_.check_is_built_and_tag(probe)) {
3444 return;
3445 }
3446
3447 const BuilderStack::ScopedEntry stack_entry = stack_.trace(probe->id);
3448
3449 build_idproperties(probe->id.properties);
3450 build_idproperties(probe->id.system_properties);
3451 build_animdata(&probe->id);
3452 build_parameters(&probe->id);
3453}
3454
3456{
3457 if (built_map_.check_is_built_and_tag(speaker)) {
3458 return;
3459 }
3460
3461 const BuilderStack::ScopedEntry stack_entry = stack_.trace(speaker->id);
3462
3465 build_animdata(&speaker->id);
3466 build_parameters(&speaker->id);
3467 if (speaker->sound != nullptr) {
3468 build_sound(speaker->sound);
3469 ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
3470 ComponentKey sound_key(&speaker->sound->id, NodeType::AUDIO);
3471 add_relation(sound_key, speaker_key, "Sound -> Speaker");
3472 }
3473}
3474
3476{
3477 if (built_map_.check_is_built_and_tag(sound)) {
3478 return;
3479 }
3480
3481 const BuilderStack::ScopedEntry stack_entry = stack_.trace(sound->id);
3482
3485 build_animdata(&sound->id);
3486 build_parameters(&sound->id);
3487
3488 const ComponentKey parameters_key(&sound->id, NodeType::PARAMETERS);
3489 const ComponentKey audio_key(&sound->id, NodeType::AUDIO);
3490
3491 add_relation(parameters_key, audio_key, "Parameters -> Audio");
3492}
3493
3499
3500static bool strip_build_prop_cb(Strip *strip, void *user_data)
3501{
3502 Seq_build_prop_cb_data *cd = static_cast<Seq_build_prop_cb_data *>(user_data);
3503
3504 cd->builder->build_idproperties(strip->prop);
3505 cd->builder->build_idproperties(strip->system_properties);
3506 if (strip->sound != nullptr) {
3507 cd->builder->build_sound(strip->sound);
3508 ComponentKey sound_key(&strip->sound->id, NodeType::AUDIO);
3509 cd->builder->add_relation(sound_key, cd->sequencer_key, "Sound -> Sequencer");
3510 cd->has_audio_strips = true;
3511 }
3512 if (strip->scene != nullptr) {
3513 cd->builder->build_scene_parameters(strip->scene);
3514 /* This is to support 3D audio. */
3515 cd->has_audio_strips = true;
3516 }
3517 if (strip->type == STRIP_TYPE_SCENE && strip->scene != nullptr) {
3518 BLI_assert(strip->scene_view_layer_name != nullptr);
3519 if (strip->flag & SEQ_SCENE_STRIPS) {
3520 cd->builder->build_scene_sequencer(strip->scene);
3521 ComponentKey sequence_scene_audio_key(&strip->scene->id, NodeType::AUDIO);
3522 cd->builder->add_relation(
3523 sequence_scene_audio_key, cd->sequencer_key, "Sequence Scene Audio -> Sequencer");
3524 ComponentKey sequence_scene_key(&strip->scene->id, NodeType::SEQUENCER);
3525 cd->builder->add_relation(
3526 sequence_scene_key, cd->sequencer_key, "Sequence Scene -> Sequencer");
3527 }
3528 ViewLayer *strip_view_layer = BKE_view_layer_find(strip->scene, strip->scene_view_layer_name);
3529 cd->builder->build_scene_speakers(strip->scene, strip_view_layer);
3530 }
3531 if (strip->type == STRIP_TYPE_COMPOSITOR && strip->effectdata) {
3532 const CompositorEffectVars *comp_data = static_cast<CompositorEffectVars *>(strip->effectdata);
3533 if (comp_data->node_group) {
3534 cd->builder->build_nodetree(comp_data->node_group);
3535 OperationKey node_tree_key(
3537 cd->builder->add_relation(node_tree_key, cd->sequencer_key, "Effect's Node Group");
3538 }
3539 }
3540 for (StripModifierData &modifier : strip->modifiers) {
3542 continue;
3543 }
3544
3545 const SequencerCompositorModifierData *modifier_data =
3546 reinterpret_cast<SequencerCompositorModifierData *>(&modifier);
3547 if (!modifier_data->node_group) {
3548 continue;
3549 }
3550 cd->builder->build_nodetree(modifier_data->node_group);
3551 OperationKey node_tree_key(
3553 cd->builder->add_relation(node_tree_key, cd->sequencer_key, "Modifier's Node Group");
3554 }
3555 /* TODO(sergey): Movie clip, camera, mask. */
3556 return true;
3557}
3558
3560{
3561 if (scene->ed == nullptr) {
3562 return;
3563 }
3564 if (built_map_.check_is_built_and_tag(scene, BuilderMap::TAG_SCENE_SEQUENCER)) {
3565 return;
3566 }
3567
3568 /* TODO(sergey): Trace as a scene sequencer. */
3569
3570 build_scene_audio(scene);
3571 ComponentKey scene_audio_key(&scene->id, NodeType::AUDIO);
3572 /* Make sure dependencies from sequences data goes to the sequencer evaluation. */
3573 ComponentKey sequencer_key(&scene->id, NodeType::SEQUENCER);
3574
3575 Seq_build_prop_cb_data cb_data = {this, sequencer_key, false};
3576
3577 seq::foreach_strip(&scene->ed->seqbase, strip_build_prop_cb, &cb_data);
3578 if (cb_data.has_audio_strips) {
3579 add_relation(sequencer_key, scene_audio_key, "Sequencer -> Audio");
3580 }
3581}
3582
3584{
3585 OperationKey scene_audio_entry_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_ENTRY);
3586 OperationKey scene_audio_volume_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_VOLUME);
3587 OperationKey scene_sound_eval_key(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
3588 add_relation(scene_audio_entry_key, scene_audio_volume_key, "Audio Entry -> Volume");
3589 add_relation(scene_audio_volume_key, scene_sound_eval_key, "Audio Volume -> Sound");
3590
3591 if (scene->audio.flag & AUDIO_VOLUME_ANIMATED) {
3592 ComponentKey scene_anim_key(&scene->id, NodeType::ANIMATION);
3593 add_relation(scene_anim_key, scene_audio_volume_key, "Animation -> Audio Volume");
3594 }
3595}
3596
3598{
3599 BKE_view_layer_synced_ensure(*bmain_, scene, view_layer);
3600 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
3601 Object *object = base.object;
3602 if (object->type != OB_SPEAKER || !need_pull_base_into_graph(&base)) {
3603 continue;
3604 }
3605 build_object(base.object);
3606 }
3607}
3608
3610{
3611 if (built_map_.check_is_built_and_tag(vfont)) {
3612 return;
3613 }
3614
3615 const BuilderStack::ScopedEntry stack_entry = stack_.trace(vfont->id);
3616
3617 build_parameters(&vfont->id);
3620}
3621
3628
3635void DepsgraphRelationBuilder::build_nested_datablock(ID *owner, ID *id, bool flush_cow_changes)
3636{
3637 int relation_flag = 0;
3638 if (!flush_cow_changes) {
3639 relation_flag |= RELATION_FLAG_NO_FLUSH;
3640 }
3641 OperationKey owner_copy_on_write_key(owner, NodeType::COPY_ON_EVAL, OperationCode::COPY_ON_EVAL);
3643 add_relation(id_copy_on_write_key, owner_copy_on_write_key, "Eval Order", relation_flag);
3644}
3645
3647{
3648 if (ntree == nullptr) {
3649 return;
3650 }
3651 /* Don't flush cow changes, because the node tree may change in ways that do not affect the
3652 * owner data block (e.g. when a node is deleted that is not connected to any output).
3653 * Data blocks owning node trees should add a relation to the `NTREE_OUTPUT` node instead. */
3654 build_nested_datablock(owner, &ntree->id, false);
3655}
3656
3658{
3659 if (key == nullptr) {
3660 return;
3661 }
3662 build_nested_datablock(owner, &key->id, true);
3663}
3664
3666{
3667 ID *id_orig = id_node->id_orig;
3668
3669 const ID_Type id_type = id_orig->id_type();
3670
3671 if (!deg_eval_copy_is_needed(id_type)) {
3672 return;
3673 }
3674
3676 /* XXX: This is a quick hack to make Alt-A to work. */
3677 // add_relation(time_source_key, copy_on_write_key, "Fluxgate capacitor hack");
3678 /* Resat of code is using rather low level trickery, so need to get some
3679 * explicit pointers. */
3680 Node *node_cow = find_node(copy_on_write_key);
3681 OperationNode *op_cow = node_cow->get_exit_operation();
3682 /* Plug any other components to this one. */
3683 for (ComponentNode *comp_node : id_node->components.values()) {
3684 if (comp_node->type == NodeType::COPY_ON_EVAL) {
3685 /* Copy-on-eval component never depends on itself. */
3686 continue;
3687 }
3688 if (!comp_node->depends_on_cow()) {
3689 /* Component explicitly requests to not add relation. */
3690 continue;
3691 }
3693 if ((ELEM(id_type, ID_ME, ID_CV, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) ||
3694 (id_type == ID_CF && comp_node->type == NodeType::CACHE))
3695 {
3696 rel_flag &= ~RELATION_FLAG_NO_FLUSH;
3697 }
3698 /* TODO(sergey): Needs better solution for this. */
3699 if (id_type == ID_SO) {
3700 rel_flag &= ~RELATION_FLAG_NO_FLUSH;
3701 }
3702 /* Notes on exceptions:
3703 * - View layers have cached array of bases in them, which is not
3704 * copied by copy-on-evaluation, and not preserved. PROBABLY it is better
3705 * to preserve that cache in copy-on-evaluation, but for the time being
3706 * we allow flush to layer collections component which will ensure
3707 * that cached array of bases exists and is up-to-date. */
3708 if (ELEM(comp_node->type, NodeType::LAYER_COLLECTIONS)) {
3709 rel_flag &= ~RELATION_FLAG_NO_FLUSH;
3710 }
3711 /* Mask evaluation operation is part of parameters, and it needs to be re-evaluated when the
3712 * mask is tagged for copy-on-eval.
3713 *
3714 * TODO(@sergey): This needs to be moved out of here.
3715 * In order to do so, moving mask evaluation out of parameters would be helpful and
3716 * semantically correct. */
3717 if (comp_node->type == NodeType::PARAMETERS && id_type == ID_MSK) {
3718 rel_flag &= ~RELATION_FLAG_NO_FLUSH;
3719 }
3720 /* Compatibility with the legacy tagging: groups are only tagged for Copy-on-Write when their
3721 * hierarchy changes, and it needs to be flushed downstream. */
3722 if (id_type == ID_GR && comp_node->type == NodeType::HIERARCHY) {
3723 rel_flag &= ~RELATION_FLAG_NO_FLUSH;
3724 }
3725 /* All entry operations of each component should wait for a proper
3726 * copy of ID. */
3727 OperationNode *op_entry = comp_node->get_entry_operation();
3728 if (op_entry != nullptr) {
3729 Relation *rel = graph_->add_new_relation(op_cow, op_entry, "Copy-on-Eval Dependency");
3730 rel->flag |= rel_flag;
3731 }
3732 /* All dangling operations should also be executed after copy-on-evaluation. */
3733 for (OperationNode *op_node : comp_node->operations_map->values()) {
3734 if (op_node == op_entry) {
3735 continue;
3736 }
3737 if (op_node->inlinks.is_empty()) {
3738 Relation *rel = graph_->add_new_relation(op_cow, op_node, "Copy-on-Eval Dependency");
3739 rel->flag |= rel_flag;
3740 }
3741 else {
3742 bool has_same_comp_dependency = false;
3743 for (Relation *rel_current : op_node->inlinks) {
3744 if (rel_current->from->type != NodeType::OPERATION) {
3745 continue;
3746 }
3747 OperationNode *op_node_from = static_cast<OperationNode *>(rel_current->from);
3748 if (op_node_from->owner == op_node->owner) {
3749 has_same_comp_dependency = true;
3750 break;
3751 }
3752 }
3753 if (!has_same_comp_dependency) {
3754 Relation *rel = graph_->add_new_relation(op_cow, op_node, "Copy-on-Eval Dependency");
3755 rel->flag |= rel_flag;
3756 }
3757 }
3758 }
3759 /* NOTE: We currently ignore implicit relations to an external
3760 * data-blocks for copy-on-evaluation operations. This means, for example,
3761 * copy-on-evaluation component of Object will not wait for copy-on-evaluation
3762 * component of its Mesh. This is because pointers are all known
3763 * already so remapping will happen all correct. And then If some object
3764 * evaluation step needs geometry, it will have transitive dependency
3765 * to Mesh copy-on-evaluation already. */
3766 }
3767 /* TODO(sergey): This solves crash for now, but causes too many
3768 * updates potentially. */
3769 if (id_orig->id_type() == ID_OB) {
3770 Object *object = id_cast<Object *>(id_orig);
3771 ID *object_data_id = object->data;
3772 if (object_data_id != nullptr) {
3773 if (deg_eval_copy_is_needed(object_data_id)) {
3774 OperationKey data_copy_on_write_key(
3777 data_copy_on_write_key, copy_on_write_key, "Eval Order", RELATION_FLAG_GODMODE);
3778 }
3779 }
3780 else {
3781 BLI_assert(object->type == OB_EMPTY);
3782 }
3783 }
3784
3785#if 0
3786 /* NOTE: Relation is disabled since #AnimationBackup() is disabled.
3787 * See comment in #AnimationBackup:init_from_id(). */
3788
3789 /* Copy-on-eval of write will iterate over f-curves to store current values corresponding
3790 * to their RNA path. This means that action must be copied prior to the ID's copy-on-evaluation,
3791 * otherwise depsgraph might try to access freed data. */
3792 AnimData *animation_data = BKE_animdata_from_id(id_orig);
3793 if (animation_data != nullptr) {
3794 if (animation_data->action != nullptr) {
3795 OperationKey action_copy_on_write_key(
3797 add_relation(action_copy_on_write_key,
3798 copy_on_write_key,
3799 "Eval Order",
3801 }
3802 }
3803#endif
3804}
3805
3806/* **** ID traversal callbacks functions **** */
3807
3808void DepsgraphRelationBuilder::modifier_walk(void *user_data,
3809 Object * /*object*/,
3810 ID **idpoin,
3811 LibraryForeachIDCallbackFlag /*cb_flag*/)
3812{
3813 BuilderWalkUserData *data = static_cast<BuilderWalkUserData *>(user_data);
3814 ID *id = *idpoin;
3815 if (id == nullptr) {
3816 return;
3817 }
3818 data->builder->build_id(id);
3819}
3820
3821void DepsgraphRelationBuilder::constraint_walk(bConstraint * /*con*/,
3822 ID **idpoin,
3823 bool /*is_reference*/,
3824 void *user_data)
3825{
3826 BuilderWalkUserData *data = static_cast<BuilderWalkUserData *>(user_data);
3827 ID *id = *idpoin;
3828 if (id == nullptr) {
3829 return;
3830 }
3831 data->builder->build_id(id);
3832}
3833
3835{
3836 return built_map_.get_ids();
3837}
3838
3839} // namespace blender::deg
Functions and classes to work with Actions.
Blender kernel action and pose functionality.
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(_collection, _object, _mode)
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
#define PTCACHE_TYPE_RIGIDBODY
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
#define OB_TYPE_IS_GEOMETRY(_type)
Types and defines for representing Rigid Body entities.
#define STRPREFIX(a, b)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
#define CD_MASK_ORIGINDEX
#define CD_MASK_MDEFORMVERT
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
Span< const Layer * > layers() const
Slot * slot_for_handle(slot_handle_t handle)
const Channelbag * channelbag_for_slot(const Slot &slot) const
virtual bool check_pchan_has_bbone_segments(const Object *object, const bPoseChannel *pchan)
virtual bool need_pull_base_into_graph(const Base *base)
static const char * get_rna_path_relative_to_scene_camera(const Scene *scene, const PointerRNA &target_prop, const char *rna_path)
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)
Relation * add_node_handle_relation(const KeyType &key_from, const DepsNodeHandle *handle, const char *description, int flags=0)
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_collection(LayerCollection *from_layer_collection, Collection *collection)
virtual void build_constraints(ID *id, NodeType component_type, const char *component_subdata, ListBaseT< bConstraint > *constraints, RootPChanMap *root_map)
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_armature_bone_collections(Span< BoneCollection * > collections)
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_object_pointcache(Object *object)
virtual void build_object_modifiers(Object *object)
virtual void build_object_data_light(Object *object)
void add_customdata_mask(Object *object, const DEGCustomDataMeshMasks &customdata_masks)
virtual Set< const ID * > get_built_ids() const
bool is_same_bone_dependency(const KeyFrom &key_from, const KeyTo &key_to)
virtual void build_object_data_empty(Object *object)
virtual void build_object_data_camera(Object *object)
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_driver_variables(ID *id, FCurve *fcurve)
virtual void build_armature_bones(ListBaseT< Bone > *bones)
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_object_data_speaker(Object *object)
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)
virtual void build_animdata_nlastrip_targets(ID *id, ComponentKey &adt_key, OperationNode *operation_from, ListBaseT< NlaStrip > *strips)
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="")
Relation * add_time_relation(TimeSourceNode *timesrc, Node *node_to, const char *description, int flags=0)
virtual void build_particle_systems(Object *object)
#define DEG_DEBUG_PRINTF(depsgraph, type,...)
Definition deg_debug.h:47
#define layer
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
const int state
bNodeTree ** node_tree_ptr_from_id(ID *id)
Definition node.cc:5312
ListBaseT< CollisionRelation > * build_collision_relations(Depsgraph *graph, Collection *collection, uint modifier_type)
bool rna_prop_affects_parameters_node(const PointerRNA *ptr, const PropertyRNA *prop)
static const ModifierData * get_latter_modifier(const ModifierData *md1, const ModifierData *md2)
static bool strip_build_prop_cb(Strip *strip, void *user_data)
const char * operationCodeAsString(OperationCode opcode)
bool deg_eval_copy_is_needed(const ID *id_orig)
bool data_path_maybe_shared(const ID &id, const StringRef data_path)
ListBaseT< EffectorRelation > * build_effector_relations(Depsgraph *graph, Collection *collection)
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ DVAR_TYPE_CONTEXT_PROP
void BKE_shaderfx_foreach_ID_link(Object *ob, ShaderFxIDWalkFunc walk, void *user_data)
Definition shader_fx.cc:239
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
void BKE_constraint_targets_flush(struct bConstraint *con, ListBaseT< bConstraintTarget > *targets, bool no_copy)
@ NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION
short * BKE_object_material_len_p(Object *ob)
Material *** BKE_object_material_array_p(Object *ob)
@ CONSTRAINT_TYPE_GEOMETRY_ATTRIBUTE
@ CONSTRAINT_TYPE_TRANSFORM_CACHE
PointerRNA RNA_id_pointer_create(ID *id)
const char * RNA_property_identifier(const PropertyRNA *prop)
@ SHD_ATTRIBUTE_VIEW_LAYER
void IDP_foreach_property(IDProperty *id_property_root, int type_filter, FunctionRef< void(IDProperty *id_property)> callback)
void void void BKE_modifiers_foreach_ID_link(Object *ob, IDWalkFunc walk, void *user_data)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
bool BKE_ptcache_object_has(struct Scene *scene, struct Object *ob, int duplis)
bool BKE_shaderfx_depends_ontime(ShaderFxData *fx)
Definition shader_fx.cc:127
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
bool driver_get_target_property(const DriverTargetContext *driver_target_context, struct DriverVar *dvar, struct DriverTarget *dtar, struct PointerRNA *r_prop)
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
unsigned int uint32_t
Definition BKE_text.h:81
Key * BKE_key_from_id(ID *id)
Definition key.cc:1291
@ AUDIO_VOLUME_ANIMATED
bool BKE_nlatrack_is_enabled(const AnimData &adt, const NlaTrack &nlt)
BMesh const char void * data
@ DTAR_CONTEXT_PROPERTY_ACTIVE_SCENE
Object * BKE_mball_basis_find(const Main &bmain, Scene *scene, Object *ob)
Definition mball.cc:417
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
int BKE_constraint_targets_get(struct bConstraint *con, ListBaseT< bConstraintTarget > *r_targets)
bool BKE_constraint_target_uses_bbone(struct bConstraint *con, struct bConstraintTarget *ct)
bool BKE_mask_is_animated(Mask &mask)
@ MOD_SHRINKWRAP_NEAREST_VERTEX
@ MOD_SHRINKWRAP_TARGET_PROJECT
@ DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY
@ DAG_EVAL_NEED_CURVE_PATH
void BKE_ptcache_foreach_object_cache(struct Object &ob, struct Scene &scene, bool duplis, PointCacheIdFn fn)
ViewLayer * BKE_view_layer_find(const Scene *scene, const char *layer_name)
bool BKE_driver_expression_depends_on_time(struct ChannelDriver *driver)
signed int int32_t
Definition BKE_text.h:78
void BKE_grease_pencil_modifiers_foreach_ID_link(struct Object *ob, GreasePencilIDWalkFunc walk, void *user_data)
void BKE_constraints_id_loop(ListBaseT< bConstraint > *list, ConstraintIDFunc func, const int flag, void *userdata)
LibraryForeachIDCallbackFlag
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1311
@ DTAR_FLAG_STRUCT_REF
@ eSeqModifierType_Compositor
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
bool BKE_modifier_depends_ontime(Scene *scene, ModifierData *md)
@ eBoidRuleType_Avoid
@ eBoidRuleType_FollowLeader
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
@ IDP_TYPE_FILTER_ID
const ShaderFxTypeInfo * BKE_shaderfx_get_info(ShaderFxType type)
Definition shader_fx.cc:134
bool RNA_path_resolve_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
Definition rna_path.cc:548
const NodeType * type
Definition graph/node.h:179
ListBaseT< FCurve > drivers
ListBaseT< NlaTrack > nla_tracks
eBoidRuleType type
ListBaseT< BoidState > states
ListBaseT< DriverVar > variables
struct Collection * group
struct ClothCollSettings * coll_parms
ListBaseT< CollectionChild > children
ListBaseT< CollectionObject > gobject
struct Object * textoncurve
struct Object * bevobj
struct Object * taperobj
ListBaseT< Strip > seqbase
ChannelDriver * driver
IDPropertyData data
Definition DNA_ID.h:157
char name[258]
Definition DNA_ID.h:433
IDProperty * system_properties
Definition DNA_ID.h:490
IDProperty * properties
Definition DNA_ID.h:481
ListBaseT< KeyBlock > block
struct AnimData * adt
struct Object * object
ListBaseT< MaskSpline > splines
MaskSplinePoint * points
struct ModifierData * prev
void(*) update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
ListBaseT< NlaStrip > strips
struct Object * parent
LightLinking * light_linking
eObject_TransFlag transflag
struct Collection * instance_collection
struct Collection * collision_group
struct BoidSettings * boids
eParticlePhysicsType phystype
struct Collection * instance_collection
struct EffectorWeights * effector_weights
struct ClothModifierData * clmd
ListBaseT< ParticleTarget > targets
eParticleSystem_Flag flag
StructRNA * type
Definition RNA_types.hh:63
struct EffectorWeights * effector_weights
struct Editing * ed
struct Object * camera
ListBaseT< TimeMarker > markers
struct AudioData audio
struct RigidBodyWorld * rigidbody_world
void(*) update_depsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphContext *ctx)
struct bSound * sound
struct Object * camera
struct IDProperty * prop
ListBaseT< struct TimeMarker > markers
ListBaseT< Bone > bonebase
ListBaseT< bGPDlayer > layers
eNodeSocketDatatype type
eNodeTree_Type type
bke::bNodeTreeRuntime * runtime
OperationNode * find_operation(OperationIDKey key) const
static DEGCustomDataMeshMasks MaskVert(const uint64_t vert_mask)
static DEGCustomDataMeshMasks MaskFace(const uint64_t face_mask)
static DEGCustomDataMeshMasks MaskEdge(const uint64_t edge_mask)
static DEGCustomDataMeshMasks MaskPoly(const uint64_t poly_mask)
IDNode * find_id_node(const ID *id) const
Definition depsgraph.cc:102
eEvaluationMode mode
Definition depsgraph.hh:145
Relation * add_new_relation(Node *from, Node *to, const char *description, int flags=0)
Definition depsgraph.cc:174
TimeSourceNode * time_source
Definition depsgraph.hh:102
DEGCustomDataMeshMasks customdata_masks
Map< ComponentIDKey, ComponentNode * > components
ComponentNode * find_component(NodeType type, StringRef name="") const
virtual OperationNode * get_entry_operation()
Definition deg_node.hh:209
std::string name
Definition deg_node.hh:186
virtual std::string identifier() const
Definition deg_node.cc:297
virtual OperationNode * get_exit_operation()
Definition deg_node.hh:213
OperationNode * get_exit_operation() override
OperationNode * get_entry_operation() override
std::string identifier() const override