Blender  V2.93
deg_builder_relations.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19 
27 
28 #include <cstdio>
29 #include <cstdlib>
30 #include <cstring> /* required for STREQ later on. */
31 
32 #include "MEM_guardedalloc.h"
33 
34 #include "BLI_blenlib.h"
35 #include "BLI_utildefines.h"
36 
37 #include "DNA_action_types.h"
38 #include "DNA_anim_types.h"
39 #include "DNA_armature_types.h"
40 #include "DNA_cachefile_types.h"
41 #include "DNA_camera_types.h"
42 #include "DNA_cloth_types.h"
43 #include "DNA_collection_types.h"
44 #include "DNA_constraint_types.h"
45 #include "DNA_curve_types.h"
46 #include "DNA_effect_types.h"
47 #include "DNA_gpencil_types.h"
48 #include "DNA_key_types.h"
49 #include "DNA_light_types.h"
50 #include "DNA_lightprobe_types.h"
51 #include "DNA_linestyle_types.h"
52 #include "DNA_mask_types.h"
53 #include "DNA_material_types.h"
54 #include "DNA_mesh_types.h"
55 #include "DNA_meta_types.h"
56 #include "DNA_movieclip_types.h"
57 #include "DNA_node_types.h"
58 #include "DNA_object_force_types.h"
59 #include "DNA_object_types.h"
60 #include "DNA_particle_types.h"
61 #include "DNA_rigidbody_types.h"
62 #include "DNA_scene_types.h"
63 #include "DNA_sequence_types.h"
64 #include "DNA_simulation_types.h"
65 #include "DNA_sound_types.h"
66 #include "DNA_speaker_types.h"
67 #include "DNA_texture_types.h"
68 #include "DNA_volume_types.h"
69 #include "DNA_world_types.h"
70 
71 #include "BKE_action.h"
72 #include "BKE_anim_data.h"
73 #include "BKE_armature.h"
74 #include "BKE_collection.h"
75 #include "BKE_collision.h"
76 #include "BKE_constraint.h"
77 #include "BKE_curve.h"
78 #include "BKE_effect.h"
79 #include "BKE_fcurve_driver.h"
80 #include "BKE_gpencil_modifier.h"
81 #include "BKE_idprop.h"
82 #include "BKE_image.h"
83 #include "BKE_key.h"
84 #include "BKE_layer.h"
85 #include "BKE_material.h"
86 #include "BKE_mball.h"
87 #include "BKE_modifier.h"
88 #include "BKE_node.h"
89 #include "BKE_object.h"
90 #include "BKE_particle.h"
91 #include "BKE_pointcache.h"
92 #include "BKE_rigidbody.h"
93 #include "BKE_shader_fx.h"
94 #include "BKE_shrinkwrap.h"
95 #include "BKE_sound.h"
96 #include "BKE_tracking.h"
97 #include "BKE_world.h"
98 
99 #include "RNA_access.h"
100 #include "RNA_types.h"
101 
102 #include "SEQ_iterator.h"
103 
104 #include "DEG_depsgraph.h"
105 #include "DEG_depsgraph_build.h"
106 
110 #include "intern/debug/deg_debug.h"
112 #include "intern/depsgraph_tag.h"
114 
115 #include "intern/node/deg_node.h"
117 #include "intern/node/deg_node_id.h"
120 
122 #include "intern/depsgraph_type.h"
123 
124 namespace blender::deg {
125 
126 /* ***************** */
127 /* Relations Builder */
128 
129 namespace {
130 
131 bool driver_target_depends_on_time(const DriverTarget *target)
132 {
133  if (target->idtype == ID_SCE &&
134  (target->rna_path != nullptr && STREQ(target->rna_path, "frame_current"))) {
135  return true;
136  }
137  return false;
138 }
139 
140 bool driver_variable_depends_on_time(const DriverVar *variable)
141 {
142  for (int i = 0; i < variable->num_targets; ++i) {
143  if (driver_target_depends_on_time(&variable->targets[i])) {
144  return true;
145  }
146  }
147  return false;
148 }
149 
150 bool driver_variables_depends_on_time(const ListBase *variables)
151 {
152  LISTBASE_FOREACH (const DriverVar *, variable, variables) {
153  if (driver_variable_depends_on_time(variable)) {
154  return true;
155  }
156  }
157  return false;
158 }
159 
160 bool driver_depends_on_time(ChannelDriver *driver)
161 {
163  return true;
164  }
165  if (driver_variables_depends_on_time(&driver->variables)) {
166  return true;
167  }
168  return false;
169 }
170 
171 bool particle_system_depends_on_time(ParticleSystem *psys)
172 {
173  ParticleSettings *part = psys->part;
174  /* Non-hair particles we always consider dependent on time. */
175  if (part->type != PART_HAIR) {
176  return true;
177  }
178  /* Dynamics always depends on time. */
179  if (psys->flag & PSYS_HAIR_DYNAMICS) {
180  return true;
181  }
182  /* TODO(sergey): Check what else makes hair dependent on time. */
183  return false;
184 }
185 
186 bool object_particles_depends_on_time(Object *object)
187 {
188  if (object->type != OB_MESH) {
189  return false;
190  }
191  LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
192  if (particle_system_depends_on_time(psys)) {
193  return true;
194  }
195  }
196  return false;
197 }
198 
199 bool check_id_has_anim_component(ID *id)
200 {
201  AnimData *adt = BKE_animdata_from_id(id);
202  if (adt == nullptr) {
203  return false;
204  }
205  return (adt->action != nullptr) || (!BLI_listbase_is_empty(&adt->nla_tracks));
206 }
207 
208 bool check_id_has_driver_component(ID *id)
209 {
210  AnimData *adt = BKE_animdata_from_id(id);
211  if (adt == nullptr) {
212  return false;
213  }
214  return !BLI_listbase_is_empty(&adt->drivers);
215 }
216 
217 OperationCode bone_target_opcode(ID *target,
218  const char *subtarget,
219  ID *id,
220  const char *component_subdata,
221  RootPChanMap *root_map)
222 {
223  /* Same armature. */
224  if (target == id) {
225  /* Using "done" here breaks in-chain deps, while using
226  * "ready" here breaks most production rigs instead.
227  * So, we do a compromise here, and only do this when an
228  * IK chain conflict may occur. */
229  if (root_map->has_common_root(component_subdata, subtarget)) {
231  }
232  }
234 }
235 
236 bool object_have_geometry_component(const Object *object)
237 {
239 }
240 
241 } // namespace
242 
243 /* **** General purpose functions **** */
244 
246  Depsgraph *graph,
247  DepsgraphBuilderCache *cache)
248  : DepsgraphBuilder(bmain, graph, cache), scene_(nullptr), rna_node_query_(graph, this)
249 {
250 }
251 
253 {
254  if (key.id) {
255  /* XXX TODO */
256  return nullptr;
257  }
258 
259  return graph_->time_source;
260 }
261 
263 {
265  if (!id_node) {
266  fprintf(stderr,
267  "find_node component: Could not find ID %s\n",
268  (key.id != nullptr) ? key.id->name : "<null>");
269  return nullptr;
270  }
271 
272  ComponentNode *node = id_node->find_component(key.type, key.name);
273  return node;
274 }
275 
277 {
278  OperationNode *op_node = find_node(key);
279  if (op_node == nullptr) {
280  fprintf(stderr,
281  "find_node_operation: Failed for (%s, '%s')\n",
283  key.name);
284  }
285  return op_node;
286 }
287 
289 {
290  return rna_node_query_.find_node(&key.ptr, key.prop, key.source);
291 }
292 
294 {
296  if (!id_node) {
297  return nullptr;
298  }
299  ComponentNode *comp_node = id_node->find_component(key.component_type, key.component_name);
300  if (!comp_node) {
301  return nullptr;
302  }
303  return comp_node->find_operation(key.opcode, key.name, key.name_tag);
304 }
305 
307 {
308  return find_node(key) != nullptr;
309 }
310 
312  const char *description)
313 {
314  IDNode *id_node = handle->node->owner->owner;
315  ID *id = id_node->id_orig;
316  ComponentKey geometry_key(id, NodeType::GEOMETRY);
317  /* Wire up the actual relation. */
318  add_depends_on_transform_relation(id, geometry_key, description);
319 }
320 
322  const DEGCustomDataMeshMasks &customdata_masks)
323 {
324  if (customdata_masks != DEGCustomDataMeshMasks() && object != nullptr &&
325  object->type == OB_MESH) {
326  IDNode *id_node = graph_->find_id_node(&object->id);
327 
328  if (id_node == nullptr) {
329  BLI_assert(!"ID should always be valid");
330  }
331  else {
332  id_node->customdata_masks |= customdata_masks;
333  }
334  }
335 }
336 
338 {
340  if (id_node == nullptr) {
341  BLI_assert(!"ID should always be valid");
342  }
343  else {
344  id_node->eval_flags |= flag;
345  }
346 }
347 
349  Node *node_to,
350  const char *description,
351  int flags)
352 {
353  if (timesrc && node_to) {
354  return graph_->add_new_relation(timesrc, node_to, description, flags);
355  }
356 
358  BUILD,
359  "add_time_relation(%p = %s, %p = %s, %s) Failed\n",
360  timesrc,
361  (timesrc) ? timesrc->identifier().c_str() : "<None>",
362  node_to,
363  (node_to) ? node_to->identifier().c_str() : "<None>",
364  description);
365 
366  return nullptr;
367 }
368 
370  OperationNode *node_to,
371  const char *description,
372  int flags)
373 {
374  if (node_from && node_to) {
375  return graph_->add_new_relation(node_from, node_to, description, flags);
376  }
377 
379  BUILD,
380  "add_operation_relation(%p = %s, %p = %s, %s) Failed\n",
381  node_from,
382  (node_from) ? node_from->identifier().c_str() : "<None>",
383  node_to,
384  (node_to) ? node_to->identifier().c_str() : "<None>",
385  description);
386 
387  return nullptr;
388 }
389 
391  Object *object,
392  Collection *collection,
393  const char *name)
394 {
396 
397  LISTBASE_FOREACH (CollisionRelation *, relation, relations) {
398  if (relation->ob != object) {
399  ComponentKey trf_key(&relation->ob->id, NodeType::TRANSFORM);
400  add_relation(trf_key, key, name);
401 
402  ComponentKey coll_key(&relation->ob->id, NodeType::GEOMETRY);
403  add_relation(coll_key, key, name);
404  }
405  }
406 }
407 
409  Object *object,
410  ParticleSystem *psys,
411  EffectorWeights *eff,
412  bool add_absorption,
413  const char *name)
414 {
415  ListBase *relations = build_effector_relations(graph_, eff->group);
416 
417  /* Make sure physics effects like wind are properly re-evaluating the modifier stack. */
418  if (!BLI_listbase_is_empty(relations)) {
419  TimeSourceKey time_src_key;
420  ComponentKey geometry_key(&object->id, NodeType::GEOMETRY);
421  add_relation(
422  time_src_key, geometry_key, "Effector Time -> Particle", RELATION_CHECK_BEFORE_ADD);
423  }
424 
425  LISTBASE_FOREACH (EffectorRelation *, relation, relations) {
426  if (relation->ob != object) {
427  /* Relation to forcefield object, optionally including geometry. */
428  ComponentKey eff_key(&relation->ob->id, NodeType::TRANSFORM);
429  add_relation(eff_key, key, name);
430 
431  if (ELEM(relation->pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) ||
432  relation->pd->forcefield == PFIELD_GUIDE) {
433  ComponentKey mod_key(&relation->ob->id, NodeType::GEOMETRY);
434  add_relation(mod_key, key, name);
435  }
436 
437  /* Force field Texture. */
438  if ((relation->pd != nullptr) && (relation->pd->forcefield == PFIELD_TEXTURE) &&
439  (relation->pd->tex != nullptr)) {
440  ComponentKey tex_key(&relation->pd->tex->id, NodeType::GENERIC_DATABLOCK);
441  add_relation(tex_key, key, "Force field Texture");
442  }
443 
444  /* Smoke flow relations. */
445  if (relation->pd->forcefield == PFIELD_FLUIDFLOW && relation->pd->f_source) {
446  ComponentKey trf_key(&relation->pd->f_source->id, NodeType::TRANSFORM);
447  add_relation(trf_key, key, "Smoke Force Domain");
448  ComponentKey eff_key(&relation->pd->f_source->id, NodeType::GEOMETRY);
449  add_relation(eff_key, key, "Smoke Force Domain");
450  }
451 
452  /* Absorption forces need collision relation. */
453  if (add_absorption && (relation->pd->flag & PFIELD_VISIBILITY)) {
454  add_particle_collision_relations(key, object, nullptr, "Force Absorption");
455  }
456  }
457 
458  if (relation->psys) {
459  if (relation->ob != object) {
460  ComponentKey eff_key(&relation->ob->id, NodeType::PARTICLE_SYSTEM);
461  add_relation(eff_key, key, name);
462  /* TODO: remove this when/if EVAL_PARTICLES is sufficient
463  * for up to date particles. */
464  ComponentKey mod_key(&relation->ob->id, NodeType::GEOMETRY);
465  add_relation(mod_key, key, name);
466  }
467  else if (relation->psys != psys) {
468  OperationKey eff_key(&relation->ob->id,
471  relation->psys->name);
472  add_relation(eff_key, key, name);
473  }
474  }
475  }
476 }
477 
479 {
480  return graph_;
481 }
482 
483 /* **** Functions to build relations between entities **** */
484 
486 {
487 }
488 
490 {
491  if (id == nullptr) {
492  return;
493  }
494 
495  const ID_Type id_type = GS(id->name);
496  switch (id_type) {
497  case ID_AC:
498  build_action((bAction *)id);
499  break;
500  case ID_AR:
501  build_armature((bArmature *)id);
502  break;
503  case ID_CA:
504  build_camera((Camera *)id);
505  break;
506  case ID_GR:
507  build_collection(nullptr, nullptr, (Collection *)id);
508  break;
509  case ID_OB:
510  build_object((Object *)id);
511  break;
512  case ID_KE:
513  build_shapekeys((Key *)id);
514  break;
515  case ID_LA:
516  build_light((Light *)id);
517  break;
518  case ID_LP:
520  break;
521  case ID_NT:
522  build_nodetree((bNodeTree *)id);
523  break;
524  case ID_MA:
525  build_material((Material *)id);
526  break;
527  case ID_TE:
528  build_texture((Tex *)id);
529  break;
530  case ID_IM:
531  build_image((Image *)id);
532  break;
533  case ID_WO:
534  build_world((World *)id);
535  break;
536  case ID_MSK:
537  build_mask((Mask *)id);
538  break;
539  case ID_LS:
541  break;
542  case ID_MC:
543  build_movieclip((MovieClip *)id);
544  break;
545  case ID_ME:
546  case ID_MB:
547  case ID_CU:
548  case ID_LT:
549  case ID_HA:
550  case ID_PT:
551  case ID_VO:
552  case ID_GD:
554  break;
555  case ID_SPK:
556  build_speaker((Speaker *)id);
557  break;
558  case ID_SO:
559  build_sound((bSound *)id);
560  break;
561  case ID_TXT:
562  /* Not a part of dependency graph. */
563  break;
564  case ID_CF:
565  build_cachefile((CacheFile *)id);
566  break;
567  case ID_SCE:
569  break;
570  case ID_SIM:
572  break;
573  case ID_PA:
575  break;
576 
577  case ID_LI:
578  case ID_IP:
579  case ID_SCR:
580  case ID_VF:
581  case ID_BR:
582  case ID_WM:
583  case ID_PAL:
584  case ID_PC:
585  case ID_WS:
587  build_generic_id(id);
588  break;
589  }
590 }
591 
593 {
594 
595  if (built_map_.checkIsBuiltAndTag(id)) {
596  return;
597  }
598 
600  build_animdata(id);
601  build_parameters(id);
602 }
603 
604 static void build_idproperties_callback(IDProperty *id_property, void *user_data)
605 {
606  DepsgraphRelationBuilder *builder = reinterpret_cast<DepsgraphRelationBuilder *>(user_data);
607  BLI_assert(id_property->type == IDP_ID);
608  builder->build_id(reinterpret_cast<ID *>(id_property->data.pointer));
609 }
610 
612 {
614 }
615 
617  Object *object,
618  Collection *collection)
619 {
620  if (from_layer_collection != nullptr) {
621  /* If we came from layer collection we don't go deeper, view layer
622  * builder takes care of going deeper.
623  *
624  * NOTE: Do early output before tagging build as done, so possible
625  * subsequent builds from outside of the layer collection properly
626  * recurses into all the nested objects and collections. */
627  return;
628  }
629  const bool group_done = built_map_.checkIsBuiltAndTag(collection);
630  OperationKey object_transform_final_key(object != nullptr ? &object->id : nullptr,
633  ComponentKey duplicator_key(object != nullptr ? &object->id : nullptr, NodeType::DUPLI);
634  if (!group_done) {
635  build_idproperties(collection->id.properties);
636  OperationKey collection_geometry_key{
638  LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
639  build_object(cob->ob);
640 
641  /* The geometry of a collection depends on the positions of the elements in it. */
642  OperationKey object_transform_key{
644  add_relation(object_transform_key, collection_geometry_key, "Collection Geometry");
645 
646  /* Only create geometry relations to child objects, if they have a geometry component. */
647  OperationKey object_geometry_key{
649  if (find_node(object_geometry_key) != nullptr) {
650  add_relation(object_geometry_key, collection_geometry_key, "Collection Geometry");
651  }
652 
653  /* An instance is part of the geometry of the collection. */
654  if (cob->ob->type == OB_EMPTY) {
655  Collection *collection_instance = cob->ob->instance_collection;
656  if (collection_instance != nullptr) {
657  OperationKey collection_instance_key{
659  add_relation(collection_instance_key, collection_geometry_key, "Collection Geometry");
660  }
661  }
662  }
663  LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
664  build_collection(nullptr, nullptr, child->collection);
665  OperationKey child_collection_geometry_key{
667  add_relation(child_collection_geometry_key, collection_geometry_key, "Collection Geometry");
668  }
669  }
670  if (object != nullptr) {
672  ComponentKey dupli_transform_key(&ob->id, NodeType::TRANSFORM);
673  add_relation(dupli_transform_key, object_transform_final_key, "Dupligroup");
674  /* Hook to special component, to ensure proper visibility/evaluation
675  * optimizations. */
676  add_relation(dupli_transform_key, duplicator_key, "Dupligroup");
677  const NodeType dupli_geometry_component_type = geometry_tag_to_component(&ob->id);
678  if (dupli_geometry_component_type != NodeType::UNDEFINED) {
679  ComponentKey dupli_geometry_component_key(&ob->id, dupli_geometry_component_type);
680  add_relation(dupli_geometry_component_key, duplicator_key, "Dupligroup");
681  }
682  }
684  }
685 }
686 
688 {
689  if (built_map_.checkIsBuiltAndTag(object)) {
690  return;
691  }
692  /* Object Transforms */
693  OperationCode base_op = (object->parent) ? OperationCode::TRANSFORM_PARENT :
695  OperationKey base_op_key(&object->id, NodeType::TRANSFORM, base_op);
696  OperationKey init_transform_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_INIT);
697  OperationKey local_transform_key(
699  OperationKey parent_transform_key(
701  OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL);
702  OperationKey final_transform_key(
705  add_relation(init_transform_key, local_transform_key, "Transform Init");
706  /* Various flags, flushing from bases/collections. */
708  /* Parenting. */
709  if (object->parent != nullptr) {
710  /* Make sure parent object's relations are built. */
711  build_object(object->parent);
712  /* Parent relationship. */
713  build_object_parent(object);
714  /* Local -> parent. */
715  add_relation(local_transform_key, parent_transform_key, "ObLocal -> ObParent");
716  }
717  /* Modifiers. */
718  if (object->modifiers.first != nullptr) {
719  BuilderWalkUserData data;
720  data.builder = this;
721  BKE_modifiers_foreach_ID_link(object, modifier_walk, &data);
722  }
723  /* Grease Pencil Modifiers. */
724  if (object->greasepencil_modifiers.first != nullptr) {
725  BuilderWalkUserData data;
726  data.builder = this;
727  BKE_gpencil_modifiers_foreach_ID_link(object, modifier_walk, &data);
728  }
729  /* Shader FX. */
730  if (object->shader_fx.first != nullptr) {
731  BuilderWalkUserData data;
732  data.builder = this;
733  BKE_shaderfx_foreach_ID_link(object, modifier_walk, &data);
734  }
735  /* Constraints. */
736  if (object->constraints.first != nullptr) {
737  BuilderWalkUserData data;
738  data.builder = this;
739  BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
740  }
741  /* Object constraints. */
742  OperationKey object_transform_simulation_init_key(
744  if (object->constraints.first != nullptr) {
745  OperationKey constraint_key(
747  /* Constraint relations. */
748  build_constraints(&object->id, NodeType::TRANSFORM, "", &object->constraints, nullptr);
749  /* operation order */
750  add_relation(base_op_key, constraint_key, "ObBase-> Constraint Stack");
751  add_relation(constraint_key, final_transform_key, "ObConstraints -> Done");
752  add_relation(constraint_key, ob_eval_key, "Constraint -> Transform Eval");
753  add_relation(
754  ob_eval_key, object_transform_simulation_init_key, "Transform Eval -> Simulation Init");
755  add_relation(object_transform_simulation_init_key,
756  final_transform_key,
757  "Simulation -> Final Transform");
758  }
759  else {
760  add_relation(base_op_key, ob_eval_key, "Eval");
761  add_relation(
762  ob_eval_key, object_transform_simulation_init_key, "Transform Eval -> Simulation Init");
763  add_relation(object_transform_simulation_init_key,
764  final_transform_key,
765  "Simulation -> Final Transform");
766  }
768  /* Animation data */
769  build_animdata(&object->id);
770  /* Object data. */
771  build_object_data(object);
772  /* Particle systems. */
773  if (object->particlesystem.first != nullptr) {
774  build_particle_systems(object);
775  }
776  /* Force field Texture. */
777  if ((object->pd != nullptr) && (object->pd->forcefield == PFIELD_TEXTURE) &&
778  (object->pd->tex != nullptr)) {
779  build_texture(object->pd->tex);
780  }
781  /* Proxy object to copy from. */
782  build_object_proxy_from(object);
783  build_object_proxy_group(object);
784  /* Object dupligroup. */
785  if (object->instance_collection != nullptr) {
786  build_collection(nullptr, object, object->instance_collection);
787  }
788  /* Point caches. */
789  build_object_pointcache(object);
790  /* Synchronization back to original object. */
791  OperationKey synchronize_key(
793  add_relation(final_transform_key, synchronize_key, "Synchronize to Original");
794  /* Parameters. */
795  build_parameters(&object->id);
796 }
797 
799 {
800  if (object->proxy_from == nullptr) {
801  return;
802  }
803  /* Object is linked here (comes from the library). */
804  build_object(object->proxy_from);
805  ComponentKey ob_transform_key(&object->proxy_from->id, NodeType::TRANSFORM);
806  ComponentKey proxy_transform_key(&object->id, NodeType::TRANSFORM);
807  add_relation(ob_transform_key, proxy_transform_key, "Proxy Transform");
808 }
809 
811 {
812  if (ELEM(object->proxy_group, nullptr, object->proxy)) {
813  return;
814  }
815  /* Object is local here (local in .blend file, users interacts with it). */
816  build_object(object->proxy_group);
817  OperationKey proxy_group_eval_key(
819  OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL);
820  add_relation(proxy_group_eval_key, transform_eval_key, "Proxy Group Transform");
821 }
822 
824 {
825  OperationKey object_from_layer_entry_key(
827  OperationKey object_from_layer_exit_key(
829  OperationKey object_flags_key(
831 
832  if (!has_node(object_flags_key)) {
833  /* Just connect Entry -> Exit if there is no OBJECT_BASE_FLAGS node. */
834  add_relation(object_from_layer_entry_key, object_from_layer_exit_key, "Object from Layer");
835  return;
836  }
837 
838  /* Entry -> OBJECT_BASE_FLAGS -> Exit */
839  add_relation(object_from_layer_entry_key, object_flags_key, "Base flags flush Entry");
840  add_relation(object_flags_key, object_from_layer_exit_key, "Base flags flush Exit");
841 
842  /* Synchronization back to original object. */
843  OperationKey synchronize_key(
845  add_relation(object_from_layer_exit_key, synchronize_key, "Synchronize to Original");
846 
847  OperationKey view_layer_done_key(
849  add_relation(view_layer_done_key, object_from_layer_entry_key, "View Layer flags to Object");
850 }
851 
853 {
854  if (object->data == nullptr) {
855  return;
856  }
857  ID *obdata_id = (ID *)object->data;
858  /* Object data animation. */
859  if (!built_map_.checkIsBuilt(obdata_id)) {
860  build_animdata(obdata_id);
861  }
862  /* type-specific data. */
863  switch (object->type) {
864  case OB_MESH:
865  case OB_CURVE:
866  case OB_FONT:
867  case OB_SURF:
868  case OB_MBALL:
869  case OB_LATTICE:
870  case OB_GPENCIL:
871  case OB_HAIR:
872  case OB_POINTCLOUD:
873  case OB_VOLUME: {
875  /* TODO(sergey): Only for until we support granular
876  * update of curves. */
877  if (object->type == OB_FONT) {
878  Curve *curve = (Curve *)object->data;
879  if (curve->textoncurve) {
880  ComponentKey geometry_key((ID *)object->data, NodeType::GEOMETRY);
881  ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
882  add_relation(transform_key, geometry_key, "Text on Curve own Transform");
884  }
885  }
886  break;
887  }
888  case OB_ARMATURE:
889  if (ID_IS_LINKED(object) && object->proxy_from != nullptr) {
890  build_proxy_rig(object);
891  }
892  else {
893  build_rig(object);
894  }
895  break;
896  case OB_LAMP:
897  build_object_data_light(object);
898  break;
899  case OB_CAMERA:
900  build_object_data_camera(object);
901  break;
902  case OB_LIGHTPROBE:
904  break;
905  case OB_SPEAKER:
907  break;
908  }
909  Key *key = BKE_key_from_object(object);
910  if (key != nullptr) {
911  ComponentKey geometry_key((ID *)object->data, NodeType::GEOMETRY);
912  ComponentKey key_key(&key->id, NodeType::GEOMETRY);
913  add_relation(key_key, geometry_key, "Shapekeys");
914  build_nested_shapekey(&object->id, key);
915  }
916  /* Materials. */
917  Material ***materials_ptr = BKE_object_material_array_p(object);
918  if (materials_ptr != nullptr) {
919  short *num_materials_ptr = BKE_object_material_len_p(object);
920  build_materials(*materials_ptr, *num_materials_ptr);
921  }
922 }
923 
925 {
926  Camera *camera = (Camera *)object->data;
927  build_camera(camera);
928  ComponentKey object_parameters_key(&object->id, NodeType::PARAMETERS);
929  ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS);
930  add_relation(camera_parameters_key, object_parameters_key, "Camera -> Object");
931 }
932 
934 {
935  Light *lamp = (Light *)object->data;
936  build_light(lamp);
937  ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
938  ComponentKey object_parameters_key(&object->id, NodeType::PARAMETERS);
939  add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object");
940 }
941 
943 {
944  LightProbe *probe = (LightProbe *)object->data;
945  build_lightprobe(probe);
948  add_relation(probe_key, object_key, "LightProbe Update");
949 }
950 
952 {
953  Speaker *speaker = (Speaker *)object->data;
954  build_speaker(speaker);
955  ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
956  ComponentKey object_key(&object->id, NodeType::AUDIO);
957  add_relation(speaker_key, object_key, "Speaker Update");
958 }
959 
961 {
962  Object *parent = object->parent;
963  ID *parent_id = &object->parent->id;
964  ComponentKey object_transform_key(&object->id, NodeType::TRANSFORM);
965  /* Type-specific links. */
966  switch (object->partype) {
967  /* Armature Deform (Virtual Modifier) */
968  case PARSKEL: {
969  ComponentKey parent_transform_key(parent_id, NodeType::TRANSFORM);
970  add_relation(parent_transform_key, object_transform_key, "Parent Armature Transform");
971 
972  if (parent->type == OB_ARMATURE) {
973  ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY);
974  ComponentKey parent_pose_key(parent_id, NodeType::EVAL_POSE);
975  add_relation(
976  parent_transform_key, object_geometry_key, "Parent Armature Transform -> Geometry");
977  add_relation(parent_pose_key, object_geometry_key, "Parent Armature Pose -> Geometry");
978 
980  &object->id, object_geometry_key, "Virtual Armature Modifier");
981  }
982 
983  break;
984  }
985 
986  /* Vertex Parent */
987  case PARVERT1:
988  case PARVERT3: {
989  ComponentKey parent_key(parent_id, NodeType::GEOMETRY);
990  add_relation(parent_key, object_transform_key, "Vertex Parent");
991  /* Original index is used for optimizations of lookups for subdiv
992  * only meshes.
993  * TODO(sergey): This optimization got lost at 2.8, so either verify
994  * we can get rid of this mask here, or bring the optimization
995  * back. */
996  add_customdata_mask(object->parent,
1001  ComponentKey transform_key(parent_id, NodeType::TRANSFORM);
1002  add_relation(transform_key, object_transform_key, "Vertex Parent TFM");
1003  break;
1004  }
1005 
1006  /* Bone Parent */
1007  case PARBONE: {
1008  ComponentKey parent_bone_key(parent_id, NodeType::BONE, object->parsubstr);
1009  OperationKey parent_transform_key(
1011  add_relation(parent_bone_key, object_transform_key, "Bone Parent");
1012  add_relation(parent_transform_key, object_transform_key, "Armature Parent");
1013  break;
1014  }
1015 
1016  default: {
1017  if (object->parent->type == OB_LATTICE) {
1018  /* Lattice Deform Parent - Virtual Modifier. */
1019  ComponentKey parent_key(parent_id, NodeType::TRANSFORM);
1020  ComponentKey geom_key(parent_id, NodeType::GEOMETRY);
1021  add_relation(parent_key, object_transform_key, "Lattice Deform Parent");
1022  add_relation(geom_key, object_transform_key, "Lattice Deform Parent Geom");
1023  }
1024  else if (object->parent->type == OB_CURVE) {
1025  Curve *cu = (Curve *)object->parent->data;
1026 
1027  if (cu->flag & CU_PATH) {
1028  /* Follow Path. */
1029  ComponentKey parent_key(parent_id, NodeType::GEOMETRY);
1030  add_relation(parent_key, object_transform_key, "Curve Follow Parent");
1031  ComponentKey transform_key(parent_id, NodeType::TRANSFORM);
1032  add_relation(transform_key, object_transform_key, "Curve Follow TFM");
1033  }
1034  else {
1035  /* Standard Parent. */
1036  ComponentKey parent_key(parent_id, NodeType::TRANSFORM);
1037  add_relation(parent_key, object_transform_key, "Curve Parent");
1038  }
1039  }
1040  else {
1041  /* Standard Parent. */
1042  ComponentKey parent_key(parent_id, NodeType::TRANSFORM);
1043  add_relation(parent_key, object_transform_key, "Parent");
1044  }
1045  break;
1046  }
1047  }
1048  /* Meta-balls are the odd balls here (no pun intended): they will request
1049  * instance-list (formerly known as dupli-list) during evaluation. This is
1050  * their way of interacting with all instanced surfaces, making a nice
1051  * effect when is used form particle system. */
1052  if (object->type == OB_MBALL && parent->transflag & OB_DUPLI) {
1053  ComponentKey parent_geometry_key(parent_id, NodeType::GEOMETRY);
1054  /* NOTE: Meta-balls are evaluating geometry only after their transform,
1055  * so we only hook up to transform channel here. */
1056  add_relation(parent_geometry_key, object_transform_key, "Parent");
1057  }
1058 
1059  /* Dupliverts uses original vertex index. */
1060  if (parent->transflag & OB_DUPLIVERTS) {
1062  }
1063 }
1064 
1066 {
1067  ComponentKey point_cache_key(&object->id, NodeType::POINT_CACHE);
1068  /* Different point caches are affecting different aspects of life of the
1069  * object. We keep track of those aspects and avoid duplicate relations. */
1070  enum {
1071  FLAG_TRANSFORM = (1 << 0),
1072  FLAG_GEOMETRY = (1 << 1),
1073  FLAG_ALL = (FLAG_TRANSFORM | FLAG_GEOMETRY),
1074  };
1075  ListBase ptcache_id_list;
1076  BKE_ptcache_ids_from_object(&ptcache_id_list, object, scene_, 0);
1077  int handled_components = 0;
1078  LISTBASE_FOREACH (PTCacheID *, ptcache_id, &ptcache_id_list) {
1079  /* Check which components needs the point cache. */
1080  int flag = -1;
1081  if (ptcache_id->type == PTCACHE_TYPE_RIGIDBODY) {
1082  if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
1083  continue;
1084  }
1085  flag = FLAG_TRANSFORM;
1086  OperationKey transform_key(
1088  add_relation(point_cache_key, transform_key, "Point Cache -> Rigid Body");
1089  /* Manual changes to effectors need to invalidate simulation. */
1090  OperationKey rigidbody_rebuild_key(
1092  add_relation(rigidbody_rebuild_key,
1093  point_cache_key,
1094  "Rigid Body Rebuild -> Point Cache Reset",
1096  }
1097  else {
1098  flag = FLAG_GEOMETRY;
1100  add_relation(point_cache_key, geometry_key, "Point Cache -> Geometry");
1101  }
1102  BLI_assert(flag != -1);
1103  /* Tag that we did handle that component. */
1104  handled_components |= flag;
1105  if (handled_components == FLAG_ALL) {
1106  break;
1107  }
1108  }
1109  /* Manual edits to any dependency (or self) should reset the point cache. */
1110  if (!BLI_listbase_is_empty(&ptcache_id_list)) {
1111  OperationKey transform_eval_key(
1113  OperationKey geometry_init_key(
1115  add_relation(transform_eval_key,
1116  point_cache_key,
1117  "Transform Simulation -> Point Cache",
1119  add_relation(geometry_init_key,
1120  point_cache_key,
1121  "Geometry Init -> Point Cache",
1123  }
1124  BLI_freelistN(&ptcache_id_list);
1125 }
1126 
1128  NodeType component_type,
1129  const char *component_subdata,
1131  RootPChanMap *root_map)
1132 {
1133  OperationKey constraint_op_key(id,
1134  component_type,
1135  component_subdata,
1136  (component_type == NodeType::BONE) ?
1139  /* Add dependencies for each constraint in turn. */
1140  for (bConstraint *con = (bConstraint *)constraints->first; con; con = con->next) {
1142  /* Invalid constraint type. */
1143  if (cti == nullptr) {
1144  continue;
1145  }
1146  /* Special case for camera tracking -- it doesn't use targets to
1147  * define relations. */
1148  /* TODO: we can now represent dependencies in a much richer manner,
1149  * so review how this is done. */
1150  if (ELEM(cti->type,
1154  bool depends_on_camera = false;
1155  if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
1157  if (((data->clip) || (data->flag & FOLLOWTRACK_ACTIVECLIP)) && data->track[0]) {
1158  depends_on_camera = true;
1159  }
1160  if (data->depth_ob) {
1161  ComponentKey depth_transform_key(&data->depth_ob->id, NodeType::TRANSFORM);
1162  ComponentKey depth_geometry_key(&data->depth_ob->id, NodeType::GEOMETRY);
1163  add_relation(depth_transform_key, constraint_op_key, cti->name);
1164  add_relation(depth_geometry_key, constraint_op_key, cti->name);
1165  }
1166  }
1167  else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
1168  depends_on_camera = true;
1169  }
1170  if (depends_on_camera && scene_->camera != nullptr) {
1171  ComponentKey camera_key(&scene_->camera->id, NodeType::TRANSFORM);
1172  add_relation(camera_key, constraint_op_key, cti->name);
1173  }
1174  /* TODO(sergey): This is more a TimeSource -> MovieClip ->
1175  * Constraint dependency chain. */
1176  TimeSourceKey time_src_key;
1177  add_relation(time_src_key, constraint_op_key, "TimeSrc -> Animation");
1178  }
1179  else if (cti->type == CONSTRAINT_TYPE_TRANSFORM_CACHE) {
1180  /* TODO(kevin): This is more a TimeSource -> CacheFile -> Constraint
1181  * dependency chain. */
1182  TimeSourceKey time_src_key;
1183  add_relation(time_src_key, constraint_op_key, "TimeSrc -> Animation");
1185  if (data->cache_file) {
1186  ComponentKey cache_key(&data->cache_file->id, NodeType::CACHE);
1187  add_relation(cache_key, constraint_op_key, cti->name);
1188  }
1189  }
1190  else if (cti->get_constraint_targets) {
1191  ListBase targets = {nullptr, nullptr};
1192  cti->get_constraint_targets(con, &targets);
1193  LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
1194  if (ct->tar == nullptr) {
1195  continue;
1196  }
1198  /* Ignore IK constraints - these are handled separately
1199  * (on pose level). */
1200  }
1202  /* These constraints require path geometry data. */
1203  ComponentKey target_key(&ct->tar->id, NodeType::GEOMETRY);
1204  add_relation(target_key, constraint_op_key, cti->name);
1205  ComponentKey target_transform_key(&ct->tar->id, NodeType::TRANSFORM);
1206  add_relation(target_transform_key, constraint_op_key, cti->name);
1207  }
1208  else if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) {
1209  OperationCode opcode;
1210  /* relation to bone */
1211  opcode = bone_target_opcode(
1212  &ct->tar->id, ct->subtarget, id, component_subdata, root_map);
1213  /* Armature constraint always wants the final position and chan_mat. */
1214  if (ELEM(con->type, CONSTRAINT_TYPE_ARMATURE)) {
1215  opcode = OperationCode::BONE_DONE;
1216  }
1217  /* if needs bbone shape, reference the segment computation */
1218  if (BKE_constraint_target_uses_bbone(con, ct) &&
1219  check_pchan_has_bbone_segments(ct->tar, ct->subtarget)) {
1221  }
1222  OperationKey target_key(&ct->tar->id, NodeType::BONE, ct->subtarget, opcode);
1223  add_relation(target_key, constraint_op_key, cti->name);
1224  }
1225  else if (ELEM(ct->tar->type, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) {
1226  /* Vertex group. */
1227  /* NOTE: Vertex group is likely to be used to get vertices
1228  * in a world space. This requires to know both geometry
1229  * and transformation of the target object. */
1230  ComponentKey target_transform_key(&ct->tar->id, NodeType::TRANSFORM);
1231  ComponentKey target_geometry_key(&ct->tar->id, NodeType::GEOMETRY);
1232  add_relation(target_transform_key, constraint_op_key, cti->name);
1233  add_relation(target_geometry_key, constraint_op_key, cti->name);
1235  }
1236  else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
1237  bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *)con->data;
1238 
1239  /* Constraints which requires the target object surface. */
1240  ComponentKey target_key(&ct->tar->id, NodeType::GEOMETRY);
1241  add_relation(target_key, constraint_op_key, cti->name);
1242 
1243  /* Add dependency on normal layers if necessary. */
1244  if (ct->tar->type == OB_MESH && scon->shrinkType != MOD_SHRINKWRAP_NEAREST_VERTEX) {
1245  bool track = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0;
1246  if (track || BKE_shrinkwrap_needs_normals(scon->shrinkType, scon->shrinkMode)) {
1247  add_customdata_mask(ct->tar,
1250  }
1253  }
1254  }
1255 
1256  /* NOTE: obdata eval now doesn't necessarily depend on the
1257  * object's transform. */
1258  ComponentKey target_transform_key(&ct->tar->id, NodeType::TRANSFORM);
1259  add_relation(target_transform_key, constraint_op_key, cti->name);
1260  }
1261  else {
1262  /* Standard object relation. */
1263  // TODO: loc vs rot vs scale?
1264  if (&ct->tar->id == id) {
1265  /* Constraint targeting own object:
1266  * - This case is fine IF we're dealing with a bone
1267  * constraint pointing to its own armature. In that
1268  * case, it's just transform -> bone.
1269  * - If however it is a real self targeting case, just
1270  * make it depend on the previous constraint (or the
1271  * pre-constraint state). */
1272  if ((ct->tar->type == OB_ARMATURE) && (component_type == NodeType::BONE)) {
1273  OperationKey target_key(
1275  add_relation(target_key, constraint_op_key, cti->name);
1276  }
1277  else {
1278  OperationKey target_key(
1280  add_relation(target_key, constraint_op_key, cti->name);
1281  }
1282  }
1283  else {
1284  /* Normal object dependency. */
1285  OperationKey target_key(
1287  add_relation(target_key, constraint_op_key, cti->name);
1288  }
1289  }
1290  /* Constraints which needs world's matrix for transform.
1291  * TODO(sergey): More constraints here? */
1292  if (ELEM(con->type,
1297  /* TODO(sergey): Add used space check. */
1298  ComponentKey target_transform_key(&ct->tar->id, NodeType::TRANSFORM);
1299  add_relation(target_transform_key, constraint_op_key, cti->name);
1300  }
1301  }
1302  if (cti->flush_constraint_targets) {
1303  cti->flush_constraint_targets(con, &targets, true);
1304  }
1305  }
1306  }
1307 }
1308 
1310 {
1311  /* Images. */
1313  /* Animation curves and NLA. */
1315  /* Drivers. */
1317 
1318  if (check_id_has_anim_component(id)) {
1319  ComponentKey animation_key(id, NodeType::ANIMATION);
1320  ComponentKey parameters_key(id, NodeType::PARAMETERS);
1321  add_relation(animation_key, parameters_key, "Animation -> Parameters");
1323  }
1324 }
1325 
1327 {
1328  AnimData *adt = BKE_animdata_from_id(id);
1329  if (adt == nullptr) {
1330  return;
1331  }
1332  if (adt->action != nullptr) {
1333  build_action(adt->action);
1334  }
1335  if (adt->action == nullptr && BLI_listbase_is_empty(&adt->nla_tracks)) {
1336  return;
1337  }
1338  /* Ensure evaluation order from entry to exit. */
1342  add_relation(animation_entry_key, animation_eval_key, "Init -> Eval");
1343  add_relation(animation_eval_key, animation_exit_key, "Eval -> Exit");
1344  /* Wire up dependency from action. */
1345  ComponentKey adt_key(id, NodeType::ANIMATION);
1346  /* Relation from action itself. */
1347  if (adt->action != nullptr) {
1348  ComponentKey action_key(&adt->action->id, NodeType::ANIMATION);
1349  add_relation(action_key, adt_key, "Action -> Animation");
1350  }
1351  /* Get source operations. */
1352  Node *node_from = get_node(adt_key);
1353  BLI_assert(node_from != nullptr);
1354  if (node_from == nullptr) {
1355  return;
1356  }
1357  OperationNode *operation_from = node_from->get_exit_operation();
1358  BLI_assert(operation_from != nullptr);
1359  /* Build relations from animation operation to properties it changes. */
1360  if (adt->action != nullptr) {
1361  build_animdata_curves_targets(id, adt_key, operation_from, &adt->action->curves);
1362  }
1363  LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
1364  build_animdata_nlastrip_targets(id, adt_key, operation_from, &nlt->strips);
1365  }
1366 }
1367 
1369  ComponentKey &adt_key,
1370  OperationNode *operation_from,
1371  ListBase *curves)
1372 {
1373  /* Iterate over all curves and build relations. */
1374  PointerRNA id_ptr;
1375  RNA_id_pointer_create(id, &id_ptr);
1376  LISTBASE_FOREACH (FCurve *, fcu, curves) {
1377  PointerRNA ptr;
1378  PropertyRNA *prop;
1379  int index;
1380  if (!RNA_path_resolve_full(&id_ptr, fcu->rna_path, &ptr, &prop, &index)) {
1381  continue;
1382  }
1383  Node *node_to = rna_node_query_.find_node(&ptr, prop, RNAPointerSource::ENTRY);
1384  if (node_to == nullptr) {
1385  continue;
1386  }
1387  OperationNode *operation_to = node_to->get_entry_operation();
1388  /* NOTE: Special case for bones, avoid relation from animation to
1389  * each of the bones. Bone evaluation could only start from pose
1390  * init anyway. */
1391  if (operation_to->opcode == OperationCode::BONE_LOCAL) {
1393  add_relation(adt_key, pose_init_key, "Animation -> Prop", RELATION_CHECK_BEFORE_ADD);
1394  continue;
1395  }
1397  operation_from, operation_to, "Animation -> Prop", RELATION_CHECK_BEFORE_ADD);
1398  /* It is possible that animation is writing to a nested ID data-block,
1399  * need to make sure animation is evaluated after target ID is copied. */
1400  const IDNode *id_node_from = operation_from->owner->owner;
1401  const IDNode *id_node_to = operation_to->owner->owner;
1402  if (id_node_from != id_node_to) {
1403  ComponentKey cow_key(id_node_to->id_orig, NodeType::COPY_ON_WRITE);
1404  add_relation(cow_key,
1405  adt_key,
1406  "Animated CoW -> Animation",
1408  }
1409  }
1410 }
1411 
1413  ComponentKey &adt_key,
1414  OperationNode *operation_from,
1415  ListBase *strips)
1416 {
1417  LISTBASE_FOREACH (NlaStrip *, strip, strips) {
1418  if (strip->act != nullptr) {
1419  build_action(strip->act);
1420 
1421  ComponentKey action_key(&strip->act->id, NodeType::ANIMATION);
1422  add_relation(action_key, adt_key, "Action -> Animation");
1423 
1424  build_animdata_curves_targets(id, adt_key, operation_from, &strip->act->curves);
1425  }
1426  else if (strip->strips.first != nullptr) {
1427  build_animdata_nlastrip_targets(id, adt_key, operation_from, &strip->strips);
1428  }
1429  }
1430 }
1431 
1433 {
1434  AnimData *adt = BKE_animdata_from_id(id);
1435  if (adt == nullptr) {
1436  return;
1437  }
1438  ComponentKey adt_key(id, NodeType::ANIMATION);
1439  LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
1440  OperationKey driver_key(id,
1443  fcu->rna_path ? fcu->rna_path : "",
1444  fcu->array_index);
1445 
1446  /* create the driver's relations to targets */
1447  build_driver(id, fcu);
1448 
1449  /* prevent driver from occurring before own animation... */
1450  if (adt->action || adt->nla_tracks.first) {
1451  add_relation(adt_key, driver_key, "AnimData Before Drivers");
1452  }
1453  }
1454 }
1455 
1457 {
1458  /* TODO: can we check for existence of node for performance? */
1460  OperationKey image_animation_key(
1462  TimeSourceKey time_src_key;
1463  add_relation(time_src_key, image_animation_key, "TimeSrc -> Image Animation");
1464  }
1465 }
1466 
1468 {
1469  if (GS(id->name) != ID_OB) {
1470  return;
1471  }
1472 
1473  const Object *object = (Object *)id;
1474  if (object->pd == nullptr || object->pd->forcefield == PFIELD_NULL) {
1475  return;
1476  }
1477 
1478  /* Updates to animation data (in the UI, for example by altering FCurve Modifier parameters
1479  * animating force field strength) may need to rebuild the rigid body world. */
1480  ComponentKey animation_key(id, NodeType::ANIMATION);
1482  add_relation(animation_key, rigidbody_key, "Animation -> Rigid Body");
1483 }
1484 
1486 {
1487  if (built_map_.checkIsBuiltAndTag(action)) {
1488  return;
1489  }
1490  build_idproperties(action->id.properties);
1491  if (!BLI_listbase_is_empty(&action->curves)) {
1492  TimeSourceKey time_src_key;
1493  ComponentKey animation_key(&action->id, NodeType::ANIMATION);
1494  add_relation(time_src_key, animation_key, "TimeSrc -> Animation");
1495  }
1496 }
1497 
1499 {
1500  ChannelDriver *driver = fcu->driver;
1501  OperationKey driver_key(id,
1504  fcu->rna_path ? fcu->rna_path : "",
1505  fcu->array_index);
1506  /* Driver -> data components (for interleaved evaluation
1507  * bones/constraints/modifiers). */
1508  build_driver_data(id, fcu);
1509  /* Loop over variables to get the target relationships. */
1510  build_driver_variables(id, fcu);
1511  /* It's quite tricky to detect if the driver actually depends on time or
1512  * not, so for now we'll be quite conservative here about optimization and
1513  * consider all python drivers to be depending on time. */
1514  if (driver_depends_on_time(driver)) {
1515  TimeSourceKey time_src_key;
1516  add_relation(time_src_key, driver_key, "TimeSrc -> Driver");
1517  }
1518 }
1519 
1521 {
1522  /* Validate the RNA path pointer just in case. */
1523  const char *rna_path = fcu->rna_path;
1524  if (rna_path == nullptr || rna_path[0] == '\0') {
1525  return;
1526  }
1527  /* Parse the RNA path to find the target property pointer. */
1528  RNAPathKey property_entry_key(id, rna_path, RNAPointerSource::ENTRY);
1529  if (RNA_pointer_is_null(&property_entry_key.ptr)) {
1530  /* TODO(sergey): This would only mean that driver is broken.
1531  * so we can't create relation anyway. However, we need to avoid
1532  * adding drivers which are known to be buggy to a dependency
1533  * graph, in order to save computational power. */
1534  return;
1535  }
1536  OperationKey driver_key(
1538  /* If the target of the driver is a Bone property, find the Armature data,
1539  * and then link the driver to all pose bone evaluation components that use
1540  * it. This is necessary to provide more granular dependencies specifically for
1541  * Bone objects, because the armature data doesn't have per-bone components,
1542  * and generic add_relation can only add one link. */
1543  ID *id_ptr = property_entry_key.ptr.owner_id;
1544  bool is_bone = id_ptr && property_entry_key.ptr.type == &RNA_Bone;
1545  /* If the Bone property is referenced via obj.pose.bones[].bone,
1546  * the RNA pointer refers to the Object ID, so skip to data. */
1547  if (is_bone && GS(id_ptr->name) == ID_OB) {
1548  id_ptr = (ID *)((Object *)id_ptr)->data;
1549  }
1550  if (is_bone && GS(id_ptr->name) == ID_AR) {
1551  /* Drivers on armature-level bone settings (i.e. bbone stuff),
1552  * which will affect the evaluation of corresponding pose bones. */
1553  Bone *bone = (Bone *)property_entry_key.ptr.data;
1554  if (bone == nullptr) {
1555  fprintf(stderr, "Couldn't find armature bone name for driver path - '%s'\n", rna_path);
1556  return;
1557  }
1558 
1559  const char *prop_identifier = RNA_property_identifier(property_entry_key.prop);
1560  const bool driver_targets_bbone = STRPREFIX(prop_identifier, "bbone_");
1561 
1562  /* Find objects which use this, and make their eval callbacks depend on this. */
1563  for (IDNode *to_node : graph_->id_nodes) {
1564  if (GS(to_node->id_orig->name) != ID_OB) {
1565  continue;
1566  }
1567 
1568  /* We only care about objects with pose data which use this. */
1569  Object *object = (Object *)to_node->id_orig;
1570  if (object->data != id_ptr || object->pose == nullptr) {
1571  continue;
1572  }
1573 
1574  bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone->name);
1575  if (pchan == nullptr) {
1576  continue;
1577  }
1578 
1579  OperationCode target_op = driver_targets_bbone ? OperationCode::BONE_SEGMENTS :
1581  OperationKey bone_key(&object->id, NodeType::BONE, pchan->name, target_op);
1582  add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
1583  }
1584  /* Make the driver depend on COW, similar to the generic case below. */
1585  if (id_ptr != id) {
1586  ComponentKey cow_key(id_ptr, NodeType::COPY_ON_WRITE);
1587  add_relation(cow_key, driver_key, "Driven CoW -> Driver", RELATION_CHECK_BEFORE_ADD);
1588  }
1589  }
1590  else {
1591  /* If it's not a Bone, handle the generic single dependency case. */
1592  Node *node_to = get_node(property_entry_key);
1593  if (node_to != nullptr) {
1594  add_relation(driver_key, property_entry_key, "Driver -> Driven Property");
1595  }
1596 
1597  /* Similar to the case with f-curves, driver might drive a nested
1598  * data-block, which means driver execution should wait for that
1599  * data-block to be copied. */
1600  {
1601  PointerRNA id_ptr;
1602  PointerRNA ptr;
1603  RNA_id_pointer_create(id, &id_ptr);
1604  if (RNA_path_resolve_full(&id_ptr, fcu->rna_path, &ptr, nullptr, nullptr)) {
1605  if (id_ptr.owner_id != ptr.owner_id) {
1607  add_relation(cow_key, driver_key, "Driven CoW -> Driver", RELATION_CHECK_BEFORE_ADD);
1608  }
1609  }
1610  }
1611  if (property_entry_key.prop != nullptr && RNA_property_is_idprop(property_entry_key.prop)) {
1612  RNAPathKey property_exit_key(property_entry_key.id,
1613  property_entry_key.ptr,
1614  property_entry_key.prop,
1617  add_relation(property_exit_key, parameters_key, "Driven Property -> Properties");
1618  }
1619  }
1620 }
1621 
1623 {
1624  ChannelDriver *driver = fcu->driver;
1625  OperationKey driver_key(id,
1628  fcu->rna_path ? fcu->rna_path : "",
1629  fcu->array_index);
1630  const char *rna_path = fcu->rna_path ? fcu->rna_path : "";
1631  const RNAPathKey self_key(id, rna_path, RNAPointerSource::ENTRY);
1632  LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
1633  /* Only used targets. */
1635  ID *target_id = dtar->id;
1636  if (target_id == nullptr) {
1637  continue;
1638  }
1639  build_id(target_id);
1640  build_driver_id_property(target_id, dtar->rna_path);
1641  /* Look up the proxy - matches dtar_id_ensure_proxy_from during evaluation. */
1642  Object *object = nullptr;
1643  if (GS(target_id->name) == ID_OB) {
1644  object = (Object *)target_id;
1645  if (object->proxy_from != nullptr) {
1646  /* Redirect the target to the proxy, like in evaluation. */
1647  object = object->proxy_from;
1648  target_id = &object->id;
1649  /* Prepare the redirected target. */
1650  build_id(target_id);
1651  build_driver_id_property(target_id, dtar->rna_path);
1652  }
1653  }
1654  /* Special handling for directly-named bones. */
1655  if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (object && object->type == OB_ARMATURE) &&
1656  (dtar->pchan_name[0])) {
1657  bPoseChannel *target_pchan = BKE_pose_channel_find_name(object->pose, dtar->pchan_name);
1658  if (target_pchan == nullptr) {
1659  continue;
1660  }
1661  OperationKey variable_key(
1662  target_id, NodeType::BONE, target_pchan->name, OperationCode::BONE_DONE);
1663  if (is_same_bone_dependency(variable_key, self_key)) {
1664  continue;
1665  }
1666  add_relation(variable_key, driver_key, "Bone Target -> Driver");
1667  }
1668  else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
1669  /* Get node associated with the object's transforms. */
1670  if (target_id == id) {
1671  /* Ignore input dependency if we're driving properties of
1672  * the same ID, otherwise we'll be ending up in a cyclic
1673  * dependency here. */
1674  continue;
1675  }
1677  add_relation(target_key, driver_key, "Target -> Driver");
1678  }
1679  else if (dtar->rna_path != nullptr && dtar->rna_path[0] != '\0') {
1680  RNAPathKey variable_exit_key(target_id, dtar->rna_path, RNAPointerSource::EXIT);
1681  if (RNA_pointer_is_null(&variable_exit_key.ptr)) {
1682  continue;
1683  }
1684  if (is_same_bone_dependency(variable_exit_key, self_key) ||
1685  is_same_nodetree_node_dependency(variable_exit_key, self_key)) {
1686  continue;
1687  }
1688  add_relation(variable_exit_key, driver_key, "RNA Target -> Driver");
1689  }
1690  else {
1691  /* If rna_path is nullptr, and DTAR_FLAG_STRUCT_REF isn't set, this
1692  * is an incomplete target reference, so nothing to do here. */
1693  }
1694  }
1696  }
1697 }
1698 
1700 {
1701  if (id == nullptr || rna_path == nullptr) {
1702  return;
1703  }
1704  PointerRNA id_ptr, ptr;
1705  PropertyRNA *prop;
1706  int index;
1707  RNA_id_pointer_create(id, &id_ptr);
1708  if (!RNA_path_resolve_full(&id_ptr, rna_path, &ptr, &prop, &index)) {
1709  return;
1710  }
1711  if (prop == nullptr) {
1712  return;
1713  }
1714  if (!RNA_property_is_idprop(prop)) {
1715  return;
1716  }
1717  const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop);
1718  /* Custom properties of bones are placed in their components to improve granularity. */
1719  OperationKey id_property_key;
1721  const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr.data);
1722  id_property_key = OperationKey(
1723  id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, prop_identifier);
1724  }
1725  else {
1726  id_property_key = OperationKey(
1727  id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, prop_identifier);
1728  }
1730  add_relation(
1731  id_property_key, parameters_exit_key, "ID Property -> Done", RELATION_CHECK_BEFORE_ADD);
1732 }
1733 
1735 {
1739  add_relation(parameters_entry_key, parameters_eval_key, "Entry -> Eval");
1740  add_relation(parameters_eval_key, parameters_exit_key, "Entry -> Exit");
1741 }
1742 
1744 {
1746  ComponentKey geometry_key(&object->id, NodeType::GEOMETRY);
1747  ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
1748  add_relation(geometry_key, dimensions_key, "Geometry -> Dimensions");
1749  add_relation(transform_key, dimensions_key, "Transform -> Dimensions");
1750 }
1751 
1753 {
1754  if (built_map_.checkIsBuiltAndTag(world)) {
1755  return;
1756  }
1758  /* animation */
1759  build_animdata(&world->id);
1761 
1762  /* Animated / driven parameters (without nodetree). */
1764  ComponentKey parameters_key(&world->id, NodeType::PARAMETERS);
1765  add_relation(parameters_key, world_key, "World's parameters");
1766 
1767  /* world's nodetree */
1768  if (world->nodetree != nullptr) {
1770  OperationKey ntree_key(
1772  add_relation(ntree_key, world_key, "World's NTree");
1774  }
1775 }
1776 
1778 {
1782  /* Simulation depends on time. */
1783  TimeSourceKey time_src_key;
1784  add_relation(time_src_key, rb_init_key, "TimeSrc -> Rigidbody Init");
1785  /* Simulation should always be run after initialization. */
1786  /* NOTE: It is possible in theory to have dependency cycle which involves
1787  * this relation. We never want it to be killed. */
1788  add_relation(rb_init_key, rb_simulate_key, "Rigidbody [Init -> SimStep]", RELATION_FLAG_GODMODE);
1789  /* Effectors should be evaluated at the time simulation is being
1790  * initialized.
1791  * TODO(sergey): Verify that it indeed goes to initialization and not to a
1792  * simulation. */
1793  ListBase *effector_relations = build_effector_relations(graph_, rbw->effector_weights->group);
1794  LISTBASE_FOREACH (EffectorRelation *, effector_relation, effector_relations) {
1795  ComponentKey effector_transform_key(&effector_relation->ob->id, NodeType::TRANSFORM);
1796  add_relation(effector_transform_key, rb_init_key, "RigidBody Field");
1797  if (effector_relation->pd != nullptr) {
1798  const short shape = effector_relation->pd->shape;
1800  ComponentKey effector_geometry_key(&effector_relation->ob->id, NodeType::GEOMETRY);
1801  add_relation(effector_geometry_key, rb_init_key, "RigidBody Field");
1802  }
1803  if ((effector_relation->pd->forcefield == PFIELD_TEXTURE) &&
1804  (effector_relation->pd->tex != nullptr)) {
1805  ComponentKey tex_key(&effector_relation->pd->tex->id, NodeType::GENERIC_DATABLOCK);
1806  add_relation(tex_key, rb_init_key, "Force field Texture");
1807  }
1808  }
1809  }
1810  /* Objects. */
1811  if (rbw->group != nullptr) {
1812  build_collection(nullptr, nullptr, rbw->group);
1814  if (object->type != OB_MESH) {
1815  continue;
1816  }
1817  if (object->rigidbody_object == nullptr) {
1818  continue;
1819  }
1820 
1821  if (object->parent != nullptr && object->parent->rigidbody_object != nullptr &&
1823  /* If we are a child of a compound shape object, the transforms and sim evaluation will be
1824  * handled by the parent compound shape object. Do not add any evaluation triggers
1825  * for the child objects.
1826  */
1827  continue;
1828  }
1829 
1830  /* Simulation uses object transformation after parenting and solving constraints. */
1831  OperationKey object_transform_simulation_init_key(
1833  OperationKey object_transform_eval_key(
1835  add_relation(object_transform_simulation_init_key,
1836  rb_simulate_key,
1837  "Object Transform -> Rigidbody Sim Eval");
1838  /* Geometry must be known to create the rigid body. RBO_MESH_BASE
1839  * uses the non-evaluated mesh, so then the evaluation is
1840  * unnecessary. */
1842  /* NOTE: We prefer this relation to be never killed, to avoid
1843  * access partially evaluated mesh from solver. */
1844  ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY);
1845  add_relation(object_geometry_key,
1846  rb_simulate_key,
1847  "Object Geom Eval -> Rigidbody Sim Eval",
1849  }
1850 
1851  /* Final transform is whatever the solver gave to us. */
1852  if (object->rigidbody_object->type == RBO_TYPE_ACTIVE) {
1853  /* We do not have to update the objects final transform after the simulation if it is
1854  * passive or controlled by the animation system in blender.
1855  * (Bullet doesn't move the object at all in these cases).
1856  * But we can't update the depgraph when the animated property in changed during playback.
1857  * So always assume that active bodies needs updating.
1858  */
1859  OperationKey rb_transform_copy_key(
1861  /* Rigid body synchronization depends on the actual simulation. */
1862  add_relation(rb_simulate_key, rb_transform_copy_key, "Rigidbody Sim Eval -> RBO Sync");
1863 
1864  OperationKey object_transform_final_key(
1866  add_relation(rb_transform_copy_key,
1867  object_transform_final_key,
1868  "Rigidbody Sync -> Transform Final");
1869  }
1870  }
1872  }
1873 }
1874 
1876 {
1877  TimeSourceKey time_src_key;
1878  OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
1879  OperationKey eval_init_key(
1881  OperationKey eval_done_key(
1883  ComponentKey eval_key(&object->id, NodeType::PARTICLE_SYSTEM);
1884  if (BKE_ptcache_object_has(scene_, object, 0)) {
1885  ComponentKey point_cache_key(&object->id, NodeType::POINT_CACHE);
1886  add_relation(
1887  eval_key, point_cache_key, "Particle Point Cache", RELATION_FLAG_FLUSH_USER_EDIT_ONLY);
1888  }
1889  /* Particle systems. */
1890  LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
1891  ParticleSettings *part = psys->part;
1892  /* Build particle settings relations.
1893  * NOTE: The call itself ensures settings are only build once. */
1895  /* This particle system. */
1896  OperationKey psys_key(
1898  /* Update particle system when settings changes. */
1899  OperationKey particle_settings_key(
1901  add_relation(particle_settings_key, eval_init_key, "Particle Settings Change");
1902  add_relation(eval_init_key, psys_key, "Init -> PSys");
1903  add_relation(psys_key, eval_done_key, "PSys -> Done");
1904  /* TODO(sergey): Currently particle update is just a placeholder,
1905  * hook it to the ubereval node so particle system is getting updated
1906  * on playback. */
1907  add_relation(psys_key, obdata_ubereval_key, "PSys -> UberEval");
1908  /* Collisions. */
1909  if (part->type != PART_HAIR) {
1911  psys_key, object, part->collision_group, "Particle Collision");
1912  }
1913  else if ((psys->flag & PSYS_HAIR_DYNAMICS) && psys->clmd != nullptr &&
1914  psys->clmd->coll_parms != nullptr) {
1916  psys_key, object, psys->clmd->coll_parms->group, "Hair Collision");
1917  }
1918  /* Effectors. */
1920  psys_key, object, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field");
1921  /* Boids .*/
1922  if (part->boids != nullptr) {
1923  LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
1924  LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
1925  Object *ruleob = nullptr;
1926  if (rule->type == eBoidRuleType_Avoid) {
1927  ruleob = ((BoidRuleGoalAvoid *)rule)->ob;
1928  }
1929  else if (rule->type == eBoidRuleType_FollowLeader) {
1930  ruleob = ((BoidRuleFollowLeader *)rule)->ob;
1931  }
1932  if (ruleob != nullptr) {
1933  ComponentKey ruleob_key(&ruleob->id, NodeType::TRANSFORM);
1934  add_relation(ruleob_key, psys_key, "Boid Rule");
1935  }
1936  }
1937  }
1938  }
1939  /* Keyed particle targets. */
1941  LISTBASE_FOREACH (ParticleTarget *, particle_target, &psys->targets) {
1942  if (ELEM(particle_target->ob, nullptr, object)) {
1943  continue;
1944  }
1945  /* Make sure target object is pulled into the graph. */
1946  build_object(particle_target->ob);
1947  /* Use geometry component, since that's where particles are
1948  * actually evaluated. */
1949  ComponentKey target_key(&particle_target->ob->id, NodeType::GEOMETRY);
1950  add_relation(target_key, psys_key, "Keyed Target");
1951  }
1952  }
1953  /* Visualization. */
1954  switch (part->ren_as) {
1955  case PART_DRAW_OB:
1956  if (part->instance_object != nullptr) {
1957  /* Make sure object's relations are all built. */
1959  /* Build relation for the particle visualization. */
1961  }
1962  break;
1963  case PART_DRAW_GR:
1964  if (part->instance_collection != nullptr) {
1965  build_collection(nullptr, nullptr, part->instance_collection);
1967  build_particle_system_visualization_object(object, psys, go->ob);
1968  }
1969  }
1970  break;
1971  }
1972  }
1973  /* Particle depends on the object transform, so that channel is to be ready
1974  * first. */
1975  add_depends_on_transform_relation(&object->id, obdata_ubereval_key, "Particle Eval");
1976 }
1977 
1979 {
1980  if (built_map_.checkIsBuiltAndTag(part)) {
1981  return;
1982  }
1983  /* Animation data relations. */
1984  build_animdata(&part->id);
1985  build_parameters(&part->id);
1986  OperationKey particle_settings_init_key(
1988  OperationKey particle_settings_eval_key(
1990  OperationKey particle_settings_reset_key(
1992  add_relation(
1993  particle_settings_init_key, particle_settings_eval_key, "Particle Settings Init Order");
1994  add_relation(particle_settings_reset_key, particle_settings_eval_key, "Particle Settings Reset");
1995  /* Texture slots. */
1996  for (MTex *mtex : part->mtex) {
1997  if (mtex == nullptr || mtex->tex == nullptr) {
1998  continue;
1999  }
2000  build_texture(mtex->tex);
2001  ComponentKey texture_key(&mtex->tex->id, NodeType::GENERIC_DATABLOCK);
2002  add_relation(texture_key,
2003  particle_settings_reset_key,
2004  "Particle Texture -> Particle Reset",
2006  add_relation(texture_key, particle_settings_eval_key, "Particle Texture -> Particle Eval");
2007  /* TODO(sergey): Consider moving texture space handling to an own
2008  * function. */
2009  if (mtex->texco == TEXCO_OBJECT && mtex->object != nullptr) {
2010  ComponentKey object_key(&mtex->object->id, NodeType::TRANSFORM);
2011  add_relation(object_key, particle_settings_eval_key, "Particle Texture Space");
2012  }
2013  }
2014  if (check_id_has_anim_component(&part->id)) {
2015  ComponentKey animation_key(&part->id, NodeType::ANIMATION);
2016  add_relation(animation_key, particle_settings_eval_key, "Particle Settings Animation");
2017  }
2018 }
2019 
2021  ParticleSystem *psys,
2022  Object *draw_object)
2023 {
2024  OperationKey psys_key(
2026  OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
2027  ComponentKey dup_ob_key(&draw_object->id, NodeType::TRANSFORM);
2028  add_relation(dup_ob_key, psys_key, "Particle Object Visualization");
2029  if (draw_object->type == OB_MBALL) {
2030  ComponentKey dup_geometry_key(&draw_object->id, NodeType::GEOMETRY);
2031  add_relation(obdata_ubereval_key, dup_geometry_key, "Particle MBall Visualization");
2032  }
2033 }
2034 
2035 /* Shapekeys */
2037 {
2038  if (built_map_.checkIsBuiltAndTag(key)) {
2039  return;
2040  }
2042  /* Attach animdata to geometry. */
2043  build_animdata(&key->id);
2044  build_parameters(&key->id);
2045  /* Connect all blocks properties to the final result evaluation. */
2046  ComponentKey geometry_key(&key->id, NodeType::GEOMETRY);
2048  LISTBASE_FOREACH (KeyBlock *, key_block, &key->block) {
2049  OperationKey key_block_key(
2050  &key->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL, key_block->name);
2051  add_relation(key_block_key, geometry_key, "Key Block Properties");
2052  add_relation(key_block_key, parameters_eval_key, "Key Block Properties");
2053  }
2054 }
2055 
2076 {
2077  ID *obdata = (ID *)object->data;
2078  /* Init operation of object-level geometry evaluation. */
2080  /* Get nodes for result of obdata's evaluation, and geometry evaluation
2081  * on object. */
2082  ComponentKey obdata_geom_key(obdata, NodeType::GEOMETRY);
2083  ComponentKey geom_key(&object->id, NodeType::GEOMETRY);
2084  /* Link components to each other. */
2085  add_relation(obdata_geom_key, geom_key, "Object Geometry Base Data");
2086  OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
2087  /* Special case: modifiers evaluation queries scene for various things like
2088  * data mask to be used. We add relation here to ensure object is never
2089  * evaluated prior to Scene's CoW is ready. */
2091  Relation *rel = add_relation(scene_key, obdata_ubereval_key, "CoW Relation");
2092  rel->flag |= RELATION_FLAG_NO_FLUSH;
2093  /* Modifiers */
2094  if (object->modifiers.first != nullptr) {
2096  ctx.scene = scene_;
2097  ctx.object = object;
2098  LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
2099  const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
2100  if (mti->updateDepsgraph) {
2101  DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
2102  ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
2103  mti->updateDepsgraph(md, &ctx);
2104  }
2105  if (BKE_object_modifier_use_time(object, md)) {
2106  TimeSourceKey time_src_key;
2107  add_relation(time_src_key, obdata_ubereval_key, "Time Source");
2108  }
2109  }
2110  }
2111  /* Grease Pencil Modifiers. */
2112  if (object->greasepencil_modifiers.first != nullptr) {
2114  ctx.scene = scene_;
2115  ctx.object = object;
2118  (GpencilModifierType)md->type);
2119  if (mti->updateDepsgraph) {
2120  DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
2121  ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
2122  mti->updateDepsgraph(md, &ctx, graph_->mode);
2123  }
2124  if (BKE_object_modifier_gpencil_use_time(object, md)) {
2125  TimeSourceKey time_src_key;
2126  add_relation(time_src_key, obdata_ubereval_key, "Time Source");
2127  }
2128  }
2129  }
2130  /* Shader FX. */
2131  if (object->shader_fx.first != nullptr) {
2133  ctx.scene = scene_;
2134  ctx.object = object;
2135  LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) {
2136  const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info((ShaderFxType)fx->type);
2137  if (fxi->updateDepsgraph) {
2138  DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
2139  ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
2140  fxi->updateDepsgraph(fx, &ctx);
2141  }
2142  if (BKE_object_shaderfx_use_time(object, fx)) {
2143  TimeSourceKey time_src_key;
2144  add_relation(time_src_key, obdata_ubereval_key, "Time Source");
2145  }
2146  }
2147  }
2148  /* Materials. */
2149  build_materials(object->mat, object->totcol);
2150  /* Geometry collision. */
2151  if (ELEM(object->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
2152  // add geometry collider relations
2153  }
2154  /* Make sure uber update is the last in the dependencies. */
2155  if (object->type != OB_ARMATURE) {
2156  /* Armatures does no longer require uber node. */
2157  OperationKey obdata_ubereval_key(
2159  add_relation(geom_init_key, obdata_ubereval_key, "Object Geometry UberEval");
2160  }
2161  if (object->type == OB_MBALL) {
2162  Object *mom = BKE_mball_basis_find(scene_, object);
2163  ComponentKey mom_geom_key(&mom->id, NodeType::GEOMETRY);
2164  /* motherball - mom depends on children! */
2165  if (mom == object) {
2166  ComponentKey mom_transform_key(&mom->id, NodeType::TRANSFORM);
2167  add_relation(mom_transform_key, mom_geom_key, "Metaball Motherball Transform -> Geometry");
2168  }
2169  else {
2170  ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
2171  add_relation(geom_key, mom_geom_key, "Metaball Motherball");
2172  add_relation(transform_key, mom_geom_key, "Metaball Motherball");
2173  }
2174  }
2175  /* NOTE: This is compatibility code to support particle systems
2176  *
2177  * for viewport being properly rendered in final render mode.
2178  * This relation is similar to what dag_object_time_update_flags()
2179  * was doing for mesh objects with particle system.
2180  *
2181  * Ideally we need to get rid of this relation. */
2182  if (object_particles_depends_on_time(object)) {
2183  TimeSourceKey time_key;
2184  OperationKey obdata_ubereval_key(
2186  add_relation(time_key, obdata_ubereval_key, "Legacy particle time");
2187  }
2188  /* Object data data-block. */
2190  Key *key = BKE_key_from_object(object);
2191  if (key != nullptr) {
2192  if (key->adt != nullptr) {
2193  if (key->adt->action || key->adt->nla_tracks.first) {
2194  ComponentKey obdata_key((ID *)object->data, NodeType::GEOMETRY);
2195  ComponentKey adt_key(&key->id, NodeType::ANIMATION);
2196  add_relation(adt_key, obdata_key, "Animation");
2197  }
2198  }
2199  }
2200  build_dimensions(object);
2201  /* Synchronization back to original object. */
2202  ComponentKey final_geometry_key(&object->id, NodeType::GEOMETRY);
2203  OperationKey synchronize_key(
2205  add_relation(final_geometry_key, synchronize_key, "Synchronize to Original");
2206  /* Batch cache. */
2207  OperationKey object_data_select_key(
2209  OperationKey object_select_key(
2211  add_relation(object_data_select_key, object_select_key, "Data Selection -> Object Selection");
2212  add_relation(
2213  geom_key, object_select_key, "Object Geometry -> Select Update", RELATION_FLAG_NO_FLUSH);
2214 }
2215 
2217 {
2218  if (built_map_.checkIsBuiltAndTag(obdata)) {
2219  return;
2220  }
2221  build_idproperties(obdata->properties);
2222  /* Animation. */
2223  build_animdata(obdata);
2224  build_parameters(obdata);
2225  /* ShapeKeys. */
2226  Key *key = BKE_key_from_id(obdata);
2227  if (key != nullptr) {
2228  build_shapekeys(key);
2229  }
2230  /* Link object data evaluation node to exit operation. */
2231  OperationKey obdata_geom_eval_key(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
2232  OperationKey obdata_geom_done_key(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DONE);
2233  add_relation(obdata_geom_eval_key, obdata_geom_done_key, "ObData Geom Eval Done");
2234  /* Type-specific links. */
2235  const ID_Type id_type = GS(obdata->name);
2236  switch (id_type) {
2237  case ID_ME:
2238  break;
2239  case ID_MB:
2240  break;
2241  case ID_CU: {
2242  Curve *cu = (Curve *)obdata;
2243  if (cu->bevobj != nullptr) {
2244  ComponentKey bevob_geom_key(&cu->bevobj->id, NodeType::GEOMETRY);
2245  add_relation(bevob_geom_key, obdata_geom_eval_key, "Curve Bevel Geometry");
2246  ComponentKey bevob_key(&cu->bevobj->id, NodeType::TRANSFORM);
2247  add_relation(bevob_key, obdata_geom_eval_key, "Curve Bevel Transform");
2248  build_object(cu->bevobj);
2249  }
2250  if (cu->taperobj != nullptr) {
2251  ComponentKey taperob_key(&cu->taperobj->id, NodeType::GEOMETRY);
2252  add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper");
2253  build_object(cu->taperobj);
2254  }
2255  if (cu->textoncurve != nullptr) {
2256  ComponentKey textoncurve_geom_key(&cu->textoncurve->id, NodeType::GEOMETRY);
2257  add_relation(textoncurve_geom_key, obdata_geom_eval_key, "Text on Curve Geometry");
2258  ComponentKey textoncurve_key(&cu->textoncurve->id, NodeType::TRANSFORM);
2259  add_relation(textoncurve_key, obdata_geom_eval_key, "Text on Curve Transform");
2261  }
2262  break;
2263  }
2264  case ID_LT:
2265  break;
2266  case ID_GD: /* Grease Pencil */
2267  {
2268  bGPdata *gpd = (bGPdata *)obdata;
2269 
2270  /* Geometry cache needs to be recalculated on frame change
2271  * (e.g. to fix crashes after scrubbing the timeline when
2272  * onion skinning is enabled, since the ghosts need to be
2273  * re-added to the cache once scrubbing ends). */
2274  TimeSourceKey time_key;
2275  ComponentKey geometry_key(obdata, NodeType::GEOMETRY);
2276  add_relation(time_key, geometry_key, "GP Frame Change");
2277 
2278  /* Geometry cache also needs to be recalculated when Material
2279  * settings change (e.g. when fill.opacity changes on/off,
2280  * we need to rebuild the bGPDstroke->triangles caches). */
2281  for (int i = 0; i < gpd->totcol; i++) {
2282  Material *ma = gpd->mat[i];
2283  if ((ma != nullptr) && (ma->gp_style != nullptr)) {
2285  add_relation(material_key, geometry_key, "Material -> GP Data");
2286  }
2287  }
2288 
2289  /* Layer parenting need react to the parent object transformation. */
2290  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
2291  if (gpl->parent != nullptr) {
2292  ComponentKey gpd_geom_key(&gpd->id, NodeType::GEOMETRY);
2293 
2294  if (gpl->partype == PARBONE) {
2295  ComponentKey bone_key(&gpl->parent->id, NodeType::BONE, gpl->parsubstr);
2296  OperationKey armature_key(
2298 
2299  add_relation(bone_key, gpd_geom_key, "Bone Parent");
2300  add_relation(armature_key, gpd_geom_key, "Armature Parent");
2301  }
2302  else {
2303  ComponentKey transform_key(&gpl->parent->id, NodeType::TRANSFORM);
2304  add_relation(transform_key, gpd_geom_key, "GPencil Parent Layer");
2305  }
2306  }
2307  }
2308  break;
2309  }
2310  case ID_HA:
2311  break;
2312  case ID_PT:
2313  break;
2314  case ID_VO: {
2315  Volume *volume = (Volume *)obdata;
2316  if (volume->is_sequence) {
2317  TimeSourceKey time_key;
2318  ComponentKey geometry_key(obdata, NodeType::GEOMETRY);
2319  add_relation(time_key, geometry_key, "Volume sequence time");
2320  }
2321  break;
2322  }
2323  default:
2324  BLI_assert(!"Should not happen");
2325  break;
2326  }
2327 }
2328 
2330 {
2331  if (built_map_.checkIsBuiltAndTag(armature)) {
2332  return;
2333  }
2334  build_idproperties(armature->id.properties);
2335  build_animdata(&armature->id);
2336  build_parameters(&armature->id);
2337  build_armature_bones(&armature->bonebase);
2338 }
2339 
2341 {
2342  LISTBASE_FOREACH (Bone *, bone, bones) {
2343  build_idproperties(bone->prop);
2344  build_armature_bones(&bone->childbase);
2345  }
2346 }
2347 
2349 {
2350  if (built_map_.checkIsBuiltAndTag(camera)) {
2351  return;
2352  }
2353  build_idproperties(camera->id.properties);
2354  build_animdata(&camera->id);
2355  build_parameters(&camera->id);
2356  if (camera->dof.focus_object != nullptr) {
2357  build_object(camera->dof.focus_object);
2358  ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS);
2359  ComponentKey dof_ob_key(&camera->dof.focus_object->id, NodeType::TRANSFORM);
2360  add_relation(dof_ob_key, camera_parameters_key, "Camera DOF");
2361  }
2362 }
2363 
2364 /* Lights */
2366 {
2367  if (built_map_.checkIsBuiltAndTag(lamp)) {
2368  return;
2369  }
2371  build_animdata(&lamp->id);
2373 
2374  ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
2375 
2376  /* light's nodetree */
2377  if (lamp->nodetree != nullptr) {
2379  ComponentKey nodetree_key(&lamp->nodetree->id, NodeType::SHADING);
2380  add_relation(nodetree_key, lamp_parameters_key, "NTree->Light Parameters");
2382  }
2383 
2384  /* For allowing drivers on lamp properties. */
2385  ComponentKey shading_key(&lamp->id, NodeType::SHADING);
2386  add_relation(lamp_parameters_key, shading_key, "Light Shading Parameters");
2387 }
2388 
2390 {
2391  build_idproperties(socket->prop);
2392 
2393  if (socket->type == SOCK_OBJECT) {
2394  Object *object = ((bNodeSocketValueObject *)socket->default_value)->value;
2395  if (object != nullptr) {
2396  build_object(object);
2397  }
2398  }
2399  else if (socket->type == SOCK_IMAGE) {
2400  Image *image = ((bNodeSocketValueImage *)socket->default_value)->value;
2401  if (image != nullptr) {
2402  build_image(image);
2403  }
2404  }
2405  else if (socket->type == SOCK_COLLECTION) {
2406  Collection *collection = ((bNodeSocketValueCollection *)socket->default_value)->value;
2407  if (collection != nullptr) {
2408  build_collection(nullptr, nullptr, collection);
2409  }
2410  }
2411 }
2412 
2414 {
2415  if (ntree == nullptr) {
2416  return;
2417  }
2418  if (built_map_.checkIsBuiltAndTag(ntree)) {
2419  return;
2420  }
2422  build_animdata(&ntree->id);
2424  ComponentKey shading_key(&ntree->id, NodeType::SHADING);
2425  /* nodetree's nodes... */
2426  LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) {
2427  build_idproperties(bnode->prop);
2428  LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->inputs) {
2429  build_nodetree_socket(socket);
2430  }
2431  LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->outputs) {
2432  build_nodetree_socket(socket);
2433  }
2434 
2435  ID *id = bnode->id;
2436  if (id == nullptr) {
2437  continue;
2438  }
2439  ID_Type id_type = GS(id->name);
2440  if (id_type == ID_MA) {
2441  build_material((Material *)bnode->id);
2442  ComponentKey material_key(id, NodeType::SHADING);
2443  add_relation(material_key, shading_key, "Material -> Node");
2444  }
2445  else if (id_type == ID_TE) {
2446  build_texture((Tex *)bnode->id);
2447  ComponentKey texture_key(id, NodeType::GENERIC_DATABLOCK);
2448  add_relation(texture_key, shading_key, "Texture -> Node");
2449  }
2450  else if (id_type == ID_IM) {
2451  build_image((Image *)bnode->id);
2453  add_relation(image_key, shading_key, "Image -> Node");
2454  }
2455  else if (id_type == ID_OB) {
2456  build_object((Object *)id);
2457  ComponentKey object_transform_key(id, NodeType::TRANSFORM);
2458  add_relation(object_transform_key, shading_key, "Object Transform -> Node");
2459  if (object_have_geometry_component(reinterpret_cast<Object *>(id))) {
2460  ComponentKey object_geometry_key(id, NodeType::GEOMETRY);
2461  add_relation(object_geometry_key, shading_key, "Object Geometry -> Node");
2462  }
2463  }
2464  else if (id_type == ID_SCE) {
2465  Scene *node_scene = (Scene *)id;
2466  build_scene_parameters(node_scene);
2467  /* Camera is used by defocus node.
2468  *
2469  * On the one hand it's annoying to always pull it in, but on another hand it's also annoying
2470  * to have hardcoded node-type exception here. */
2471  if (node_scene->camera != nullptr) {
2472  build_object(node_scene->camera);
2473  }
2474  }
2475  else if (id_type == ID_TXT) {
2476  /* Ignore script nodes. */
2477  }
2478  else if (id_type == ID_MSK) {
2479  build_mask((Mask *)id);
2481  add_relation(mask_key, shading_key, "Mask -> Node");
2482  }
2483  else if (id_type == ID_MC) {
2484  build_movieclip((MovieClip *)id);
2486  add_relation(clip_key, shading_key, "Clip -> Node");
2487  }
2488  else if (ELEM(bnode->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
2489  bNodeTree *group_ntree = (bNodeTree *)id;
2490  build_nodetree(group_ntree);
2491  ComponentKey group_shading_key(&group_ntree->id, NodeType::SHADING);
2492  add_relation(group_shading_key, shading_key, "Group Node");
2493  }
2494  else {
2495  BLI_assert(!"Unknown ID type used for node");
2496  }
2497  }
2498 
2499  LISTBASE_FOREACH (bNodeSocket *, socket, &ntree->inputs) {
2500  build_idproperties(socket->prop);
2501  }
2502  LISTBASE_FOREACH (bNodeSocket *, socket, &ntree->outputs) {
2503  build_idproperties(socket->prop);
2504  }
2505 
2507  OperationKey shading_parameters_key(
2509  add_relation(shading_parameters_key, shading_update_key, "NTree Shading Parameters");
2510 
2511  if (check_id_has_anim_component(&ntree->id)) {
2512  ComponentKey animation_key(&ntree->id, NodeType::ANIMATION);
2513  add_relation(animation_key, shading_parameters_key, "NTree Shading Parameters");
2514  }
2515  ComponentKey parameters_key(&ntree->id, NodeType::PARAMETERS);
2516  add_relation(parameters_key, shading_parameters_key, "NTree Shading Parameters");
2517 }
2518 
2519 /* Recursively build graph for material */
2521 {
2522  if (built_map_.checkIsBuiltAndTag(material)) {
2523  return;
2524  }
2526  /* animation */
2529 
2530  /* Animated / driven parameters (without nodetree). */
2532  ComponentKey parameters_key(&material->id, NodeType::PARAMETERS);
2533  add_relation(parameters_key, material_key, "Material's parameters");
2534 
2535  /* material's nodetree */
2536  if (material->nodetree != nullptr) {
2538  OperationKey ntree_key(
2540  add_relation(ntree_key, material_key, "Material's NTree");
2542  }
2543 }
2544 
2545 void DepsgraphRelationBuilder::build_materials(Material **materials, int num_materials)
2546 {
2547  for (int i = 0; i < num_materials; i++) {
2548  if (materials[i] == nullptr) {
2549  continue;
2550  }
2551  build_material(materials[i]);
2552  }
2553 }
2554 
2555 /* Recursively build graph for texture */
2557 {
2558  if (built_map_.checkIsBuiltAndTag(texture)) {
2559  return;
2560  }
2561  /* texture itself */
2563  build_idproperties(texture->id.properties);
2564  build_animdata(&texture->id);
2565  build_parameters(&texture->id);
2566 
2567  /* texture's nodetree */
2568  build_nodetree(texture->nodetree);
2569  build_nested_nodetree(&texture->id, texture->nodetree);
2570 
2571  /* Special cases for different IDs which texture uses. */
2572  if (texture->type == TEX_IMAGE) {
2573  if (texture->ima != nullptr) {
2574  build_image(texture->ima);
2575 
2576  ComponentKey image_key(&texture->ima->id, NodeType::GENERIC_DATABLOCK);
2577  add_relation(image_key, texture_key, "Texture Image");
2578  }
2579  }
2580 
2581  if (check_id_has_anim_component(&texture->id)) {
2582  ComponentKey animation_key(&texture->id, NodeType::ANIMATION);
2583  add_relation(animation_key, texture_key, "Datablock Animation");
2584  }
2585 
2587  ComponentKey image_animation_key(&texture->id, NodeType::IMAGE_ANIMATION);
2588  add_relation(image_animation_key, texture_key, "Datablock Image Animation");
2589  }
2590 }
2591 
2593 {
2594  if (built_map_.checkIsBuiltAndTag(image)) {
2595  return;
2596  }
2598  build_parameters(&image->id);
2599 }
2600 
2602 {
2603  if (built_map_.checkIsBuiltAndTag(cache_file)) {
2604  return;
2605  }
2606  build_idproperties(cache_file->id.properties);
2607  /* Animation. */
2608  build_animdata(&cache_file->id);
2609  build_parameters(&cache_file->id);
2610  if (check_id_has_anim_component(&cache_file->id)) {
2611  ComponentKey animation_key(&cache_file->id, NodeType::ANIMATION);
2612  ComponentKey datablock_key(&cache_file->id, NodeType::CACHE);
2613  add_relation(animation_key, datablock_key, "Datablock Animation");
2614  }
2615  if (check_id_has_driver_component(&cache_file->id)) {
2616  ComponentKey animation_key(&cache_file->id, NodeType::PARAMETERS);
2617  ComponentKey datablock_key(&cache_file->id, NodeType::CACHE);
2618  add_relation(animation_key, datablock_key, "Drivers -> Cache Eval");
2619  }
2620 
2621  /* Cache file updates */
2622  if (cache_file->is_sequence) {
2623  OperationKey cache_update_key(
2625  TimeSourceKey time_src_key;
2626  add_relation(time_src_key, cache_update_key, "TimeSrc -> Cache File Eval");
2627  }
2628 }
2629 
2631 {
2632  if (built_map_.checkIsBuiltAndTag(mask)) {
2633  return;
2634  }
2635  ID *mask_id = &mask->id;
2636  build_idproperties(mask_id->properties);
2637  /* F-Curve animation. */
2638  build_animdata(mask_id);
2639  build_parameters(mask_id);
2640  /* Own mask animation. */
2641  OperationKey mask_animation_key(mask_id, NodeType::ANIMATION, OperationCode::MASK_ANIMATION);
2642  TimeSourceKey time_src_key;
2643  add_relation(time_src_key, mask_animation_key, "TimeSrc -> Mask Animation");
2644  /* Final mask evaluation. */
2646  add_relation(mask_animation_key, mask_eval_key, "Mask Animation -> Mask Eval");
2647  /* Build parents. */
2648  LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
2649  LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
2650  for (int i = 0; i < spline->tot_point; i++) {
2651  MaskSplinePoint *point = &spline->points[i];
2652  MaskParent *parent = &point->parent;
2653  if (parent == nullptr || parent->id == nullptr) {
2654  continue;
2655  }
2656  build_id(parent->id);
2657  if (parent->id_type == ID_MC) {
2658  OperationKey movieclip_eval_key(
2660  add_relation(movieclip_eval_key, mask_eval_key, "Movie Clip -> Mask Eval");
2661  }
2662  }
2663  }
2664  }
2665 }
2666 
2668 {
2669  if (built_map_.checkIsBuiltAndTag(linestyle)) {
2670  return;
2671  }
2672 
2673  ID *linestyle_id = &linestyle->id;
2674  build_parameters(linestyle_id);
2675  build_idproperties(linestyle_id->properties);
2676  build_animdata(linestyle_id);
2678 }
2679 
2681 {
2682  if (built_map_.checkIsBuiltAndTag(clip)) {
2683  return;
2684  }
2685  /* Animation. */
2687  build_animdata(&clip->id);
2688  build_parameters(&clip->id);
2689 }
2690 
2692 {
2693  if (built_map_.checkIsBuiltAndTag(probe)) {
2694  return;
2695  }
2697  build_animdata(&probe->id);
2698  build_parameters(&probe->id);
2699 }
2700 
2702 {
2703  if (built_map_.checkIsBuiltAndTag(speaker)) {
2704  return;
2705  }
2706  build_idproperties(speaker->id.properties);
2707  build_animdata(&speaker->id);
2708  build_parameters(&speaker->id);
2709  if (speaker->sound != nullptr) {
2710  build_sound(speaker->sound);
2711  ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
2712  ComponentKey sound_key(&speaker->sound->id, NodeType::AUDIO);
2713  add_relation(sound_key, speaker_key, "Sound -> Speaker");
2714  }
2715 }
2716 
2718 {
2719  if (built_map_.checkIsBuiltAndTag(sound)) {
2720  return;
2721  }
2723  build_animdata(&sound->id);
2724  build_parameters(&sound->id);
2725 }
2726 
2728 {
2729  if (built_map_.checkIsBuiltAndTag(simulation)) {
2730  return;
2731  }
2735 
2738 
2739  OperationKey simulation_eval_key(
2741  TimeSourceKey time_src_key;
2742  add_relation(time_src_key, simulation_eval_key, "TimeSrc -> Simulation");
2743 
2744  OperationKey nodetree_key(
2746  add_relation(nodetree_key, simulation_eval_key, "NodeTree -> Simulation", 0);
2747 }
2748 
2750 {
2751  if (scene->ed == nullptr) {
2752  return;
2753  }
2755  return;
2756  }
2758  ComponentKey scene_audio_key(&scene->id, NodeType::AUDIO);
2759  /* Make sure dependencies from sequences data goes to the sequencer evaluation. */
2760  ComponentKey sequencer_key(&scene->id, NodeType::SEQUENCER);
2761  Sequence *seq;
2762  bool has_audio_strips = false;
2763  SEQ_ALL_BEGIN (scene->ed, seq) {
2764  build_idproperties(seq->prop);
2765  if (seq->sound != nullptr) {
2766  build_sound(seq->sound);
2767  ComponentKey sound_key(&seq->sound->id, NodeType::AUDIO);
2768  add_relation(sound_key, sequencer_key, "Sound -> Sequencer");
2769  has_audio_strips = true;
2770  }
2771  if (seq->scene != nullptr) {
2773  /* This is to support 3D audio. */
2774  has_audio_strips = true;
2775  }
2776  if (seq->type == SEQ_TYPE_SCENE && seq->scene != nullptr) {
2777  if (seq->flag & SEQ_SCENE_STRIPS) {
2779  ComponentKey sequence_scene_audio_key(&seq->scene->id, NodeType::AUDIO);
2780  add_relation(sequence_scene_audio_key, sequencer_key, "Sequence Scene Audio -> Sequencer");
2781  ComponentKey sequence_scene_key(&seq->scene->id, NodeType::SEQUENCER);
2782  add_relation(sequence_scene_key, sequencer_key, "Sequence Scene -> Sequencer");
2783  }
2784  ViewLayer *sequence_view_layer = BKE_view_layer_default_render(seq->scene);
2785  build_scene_speakers(seq->scene, sequence_view_layer);
2786  }
2787  /* TODO(sergey): Movie clip, camera, mask. */
2788  }
2789  SEQ_ALL_END;
2790  if (has_audio_strips) {
2791  add_relation(sequencer_key, scene_audio_key, "Sequencer -> Audio");
2792  }
2793 }
2794 
2796 {
2797  OperationKey scene_audio_entry_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_ENTRY);
2798  OperationKey scene_audio_volume_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_VOLUME);
2800  add_relation(scene_audio_entry_key, scene_audio_volume_key, "Audio Entry -> Volume");
2801  add_relation(scene_audio_volume_key, scene_sound_eval_key, "Audio Volume -> Sound");
2802 
2804  ComponentKey scene_anim_key(&scene->id, NodeType::ANIMATION);
2805  add_relation(scene_anim_key, scene_audio_volume_key, "Animation -> Audio Volume");
2806  }
2807 }
2808 
2810 {
2811  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
2812  Object *object = base->object;
2813  if (object->type != OB_SPEAKER || !need_pull_base_into_graph(base)) {
2814  continue;
2815  }
2816  build_object(base->object);
2817  }
2818 }
2819 
2821 {
2822  for (IDNode *id_node : graph_->id_nodes) {
2824  }
2825 }
2826 
2827 /* Nested datablocks (node trees, shape keys) requires special relation to
2828  * ensure owner's datablock remapping happens after node tree itself is ready.
2829  *
2830  * This is similar to what happens in ntree_hack_remap_pointers().
2831  */
2833 {
2834  OperationKey owner_copy_on_write_key(
2837  add_relation(id_copy_on_write_key, owner_copy_on_write_key, "Eval Order");
2838 }
2839 
2841 {
2842  if (ntree == nullptr) {
2843  return;
2844  }
2845  build_nested_datablock(owner, &ntree->id);
2846 }
2847 
2849 {
2850  if (key == nullptr) {
2851  return;
2852  }
2853  build_nested_datablock(owner, &key->id);
2854 }
2855 
2857 {
2858  ID *id_orig = id_node->id_orig;
2859 
2860  const ID_Type id_type = GS(id_orig->name);
2861 
2862  if (!deg_copy_on_write_is_needed(id_type)) {
2863  return;
2864  }
2865 
2866  TimeSourceKey time_source_key;
2868  /* XXX: This is a quick hack to make Alt-A to work. */
2869  // add_relation(time_source_key, copy_on_write_key, "Fluxgate capacitor hack");
2870  /* Resat of code is using rather low level trickery, so need to get some
2871  * explicit pointers. */
2872  Node *node_cow = find_node(copy_on_write_key);
2873  OperationNode *op_cow = node_cow->get_exit_operation();
2874  /* Plug any other components to this one. */
2875  for (ComponentNode *comp_node : id_node->components.values()) {
2876  if (comp_node->type == NodeType::COPY_ON_WRITE) {
2877  /* Copy-on-write component never depends on itself. */
2878  continue;
2879  }
2880  if (!comp_node->depends_on_cow()) {
2881  /* Component explicitly requests to not add relation. */
2882  continue;
2883  }
2884  int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE);
2885  if ((ELEM(id_type, ID_ME, ID_HA, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) ||
2886  (id_type == ID_CF && comp_node->type == NodeType::CACHE)) {
2887  rel_flag &= ~RELATION_FLAG_NO_FLUSH;
2888  }
2889  /* TODO(sergey): Needs better solution for this. */
2890  if (id_type == ID_SO) {
2891  rel_flag &= ~RELATION_FLAG_NO_FLUSH;
2892  }
2893  /* Notes on exceptions:
2894  * - Parameters component is where drivers are living. Changing any
2895  * of the (custom) properties in the original datablock (even the
2896  * ones which do not imply other component update) need to make
2897  * sure drivers are properly updated.
2898  * This way, for example, changing ID property will properly poke
2899  * all drivers to be updated.
2900  *
2901  * - View layers have cached array of bases in them, which is not
2902  * copied by copy-on-write, and not preserved. PROBABLY it is better
2903  * to preserve that cache in copy-on-write, but for the time being
2904  * we allow flush to layer collections component which will ensure
2905  * that cached array of bases exists and is up-to-date. */
2906  if (ELEM(comp_node->type, NodeType::PARAMETERS, NodeType::LAYER_COLLECTIONS)) {
2907  rel_flag &= ~RELATION_FLAG_NO_FLUSH;
2908  }
2909  /* All entry operations of each component should wait for a proper
2910  * copy of ID. */
2911  OperationNode *op_entry = comp_node->get_entry_operation();
2912  if (op_entry != nullptr) {
2913  Relation *rel = graph_->add_new_relation(op_cow, op_entry, "CoW Dependency");
2914  rel->flag |= rel_flag;
2915  }
2916  /* All dangling operations should also be executed after copy-on-write. */
2917  for (OperationNode *op_node : comp_node->operations_map->values()) {
2918  if (op_node == op_entry) {
2919  continue;
2920  }
2921  if (op_node->inlinks.is_empty()) {
2922  Relation *rel = graph_->add_new_relation(op_cow, op_node, "CoW Dependency");
2923  rel->flag |= rel_flag;
2924  }
2925  else {
2926  bool has_same_comp_dependency = false;
2927  for (Relation *rel_current : op_node->inlinks) {
2928  if (rel_current->from->type != NodeType::OPERATION) {
2929  continue;
2930  }
2931  OperationNode *op_node_from = (OperationNode *)rel_current->from;
2932  if (op_node_from->owner == op_node->owner) {
2933  has_same_comp_dependency = true;
2934  break;
2935  }
2936  }
2937  if (!has_same_comp_dependency) {
2938  Relation *rel = graph_->add_new_relation(op_cow, op_node, "CoW Dependency");
2939  rel->flag |= rel_flag;
2940  }
2941  }
2942  }
2943  /* NOTE: We currently ignore implicit relations to an external
2944  * data-blocks for copy-on-write operations. This means, for example,
2945  * copy-on-write component of Object will not wait for copy-on-write
2946  * component of its Mesh. This is because pointers are all known
2947  * already so remapping will happen all correct. And then If some object
2948  * evaluation step needs geometry, it will have transitive dependency
2949  * to Mesh copy-on-write already. */
2950  }
2951  /* TODO(sergey): This solves crash for now, but causes too many
2952  * updates potentially. */
2953  if (GS(id_orig->name) == ID_OB) {
2954  Object *object = (Object *)id_orig;
2955  ID *object_data_id = (ID *)object->data;
2956  if (object_data_id != nullptr) {
2957  if (deg_copy_on_write_is_needed(object_data_id)) {
2958  OperationKey data_copy_on_write_key(
2960  add_relation(
2961  data_copy_on_write_key, copy_on_write_key, "Eval Order", RELATION_FLAG_GODMODE);
2962  }
2963  }
2964  else {
2965  BLI_assert(object->type == OB_EMPTY);
2966  }
2967  }
2968 
2969 #if 0
2970  /* NOTE: Relation is disabled since AnimationBackup() is disabled.
2971  * See comment in AnimationBackup:init_from_id(). */
2972 
2973  /* Copy-on-write of write will iterate over f-curves to store current values corresponding
2974  * to their RNA path. This means that action must be copied prior to the ID's copy-on-write,
2975  * otherwise depsgraph might try to access freed data. */
2976  AnimData *animation_data = BKE_animdata_from_id(id_orig);
2977  if (animation_data != nullptr) {
2978  if (animation_data->action != nullptr) {
2979  OperationKey action_copy_on_write_key(
2981  add_relation(action_copy_on_write_key,
2982  copy_on_write_key,
2983  "Eval Order",
2985  }
2986  }
2987 #endif
2988 }
2989 
2990 /* **** ID traversal callbacks functions **** */
2991 
2992 void DepsgraphRelationBuilder::modifier_walk(void *user_data,
2993  struct Object * /*object*/,
2994  struct ID **idpoin,
2995  int /*cb_flag*/)
2996 {
2997  BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
2998  ID *id = *idpoin;
2999  if (id == nullptr) {
3000  return;
3001  }
3002  data->builder->build_id(id);
3003 }
3004 
3005 void DepsgraphRelationBuilder::constraint_walk(bConstraint * /*con*/,
3006  ID **idpoin,
3007  bool /*is_reference*/,
3008  void *user_data)
3009 {
3010  BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
3011  ID *id = *idpoin;
3012  if (id == nullptr) {
3013  return;
3014  }
3015  data->builder->build_id(id);
3016 }
3017 
3018 } // namespace blender::deg
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
struct AnimData * BKE_animdata_from_id(struct ID *id)
Definition: anim_data.c:96
#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
void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata)
Definition: constraint.c:5680
bool BKE_constraint_target_uses_bbone(struct bConstraint *con, struct bConstraintTarget *ct)
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
Definition: constraint.c:5435
bool BKE_driver_expression_depends_on_time(struct ChannelDriver *driver)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
void void BKE_gpencil_modifiers_foreach_ID_link(struct Object *ob, GreasePencilIDWalkFunc walk, void *userData)
const GpencilModifierTypeInfo * BKE_gpencil_modifier_get_info(GpencilModifierType type)
void IDP_foreach_property(struct IDProperty *id_property_root, const int type_filter, IDPForeachPropertyCallback callback, void *user_data)
Definition: idprop.c:1072
bool BKE_image_user_id_has_animation(struct ID *id)
Definition: image.c:5413
struct Key * BKE_key_from_id(struct ID *id)
Definition: key.c:1786
struct Key * BKE_key_from_object(const struct Object *ob)
struct ViewLayer * BKE_view_layer_default_render(const struct Scene *scene)
General operations, lookup, etc. for materials.
struct Material *** BKE_object_material_array_p(struct Object *ob)
Definition: material.c:323
short * BKE_object_material_len_p(struct Object *ob)
Definition: material.c:356
struct Object * BKE_mball_basis_find(struct Scene *scene, struct Object *ob)
This function finds the basis MetaBall.
Definition: mball.c:511
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
void BKE_modifiers_foreach_ID_link(struct Object *ob, IDWalkFunc walk, void *userData)
#define NODE_CUSTOM_GROUP
Definition: BKE_node.h:876
General operations, lookup, etc. for blender objects.
bool BKE_object_modifier_gpencil_use_time(struct Object *ob, struct GpencilModifierData *md)
Definition: object.c:5443
bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md)
Definition: object.c:5397
bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *md)
Definition: object.c:5481
void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis)
Definition: pointcache.c:1278
bool BKE_ptcache_object_has(struct Scene *scene, struct Object *ob, int duplis)
Definition: pointcache.c:1291
#define PTCACHE_TYPE_RIGIDBODY
API for Blender-side Rigid Body stuff.
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData)
Definition: shader_fx.c:264
const ShaderFxTypeInfo * BKE_shaderfx_get_info(ShaderFxType type)
Definition: shader_fx.c:157
bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode)
Definition: shrinkwrap.c:105
#define BLI_assert(a)
Definition: BLI_assert.h:58
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
#define STRPREFIX(a, b)
#define ELEM(...)
#define STREQ(a, b)
@ DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY
Definition: DEG_depsgraph.h:73
@ DAG_EVAL_NEED_CURVE_PATH
Definition: DEG_depsgraph.h:70
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
@ IDP_ID
Definition: DNA_ID.h:102
@ IDP_TYPE_FILTER_ID
Definition: DNA_ID.h:115
ID_Type
Definition: DNA_ID_enums.h:56
@ ID_WM
Definition: DNA_ID_enums.h:84
@ ID_CA
Definition: DNA_ID_enums.h:68
@ ID_AR
Definition: DNA_ID_enums.h:78
@ ID_MC
Definition: DNA_ID_enums.h:85
@ ID_CF
Definition: DNA_ID_enums.h:90
@ ID_LI
Definition: DNA_ID_enums.h:58
@ ID_TE
Definition: DNA_ID_enums.h:64
@ ID_IM
Definition: DNA_ID_enums.h:65
@ ID_VO
Definition: DNA_ID_enums.h:95
@ ID_WS
Definition: DNA_ID_enums.h:91
@ ID_NT
Definition: DNA_ID_enums.h:80
@ ID_LA
Definition: DNA_ID_enums.h:67
@ ID_KE
Definition: DNA_ID_enums.h:70
@ ID_TXT
Definition: DNA_ID_enums.h:74
@ ID_SO
Definition: DNA_ID_enums.h:76
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_LS
Definition: DNA_ID_enums.h:87
@ ID_MSK
Definition: DNA_ID_enums.h:86
@ ID_GD
Definition: DNA_ID_enums.h:83
@ ID_PAL
Definition: DNA_ID_enums.h:88
@ ID_BR
Definition: DNA_ID_enums.h:81
@ ID_LP
Definition: DNA_ID_enums.h:92
@ ID_HA
Definition: DNA_ID_enums.h:93
@ ID_WO
Definition: DNA_ID_enums.h:71
@ ID_SIM
Definition: DNA_ID_enums.h:96
@ ID_MA
Definition: DNA_ID_enums.h:63
@ ID_AC
Definition: DNA_ID_enums.h:79
@ ID_SCR
Definition: DNA_ID_enums.h:72
@ ID_VF
Definition: DNA_ID_enums.h:73
@ ID_ME
Definition: DNA_ID_enums.h:60
@ ID_IP
Definition: DNA_ID_enums.h:69
@ ID_GR
Definition: DNA_ID_enums.h:77
@ ID_SPK
Definition: DNA_ID_enums.h:75
@ ID_MB
Definition: DNA_ID_enums.h:62
@ ID_LT
Definition: DNA_ID_enums.h:66
@ ID_OB
Definition: DNA_ID_enums.h:59
@ ID_PA
Definition: DNA_ID_enums.h:82
@ ID_PT
Definition: DNA_ID_enums.h:94
@ ID_CU
Definition: DNA_ID_enums.h:61
@ ID_PC
Definition: DNA_ID_enums.h:89
@ DTAR_FLAG_STRUCT_REF
@ eBoidRuleType_Avoid
@ eBoidRuleType_FollowLeader
Object groups, one object can be in many groups at once.
@ CONSTRAINT_TYPE_FOLLOWTRACK
@ CONSTRAINT_TYPE_OBJECTSOLVER
@ CONSTRAINT_TYPE_ARMATURE
@ CONSTRAINT_TYPE_LOCLIKE
@ CONSTRAINT_TYPE_SHRINKWRAP
@ CONSTRAINT_TYPE_CAMERASOLVER
@ CONSTRAINT_TYPE_ROTLIKE
@ CONSTRAINT_TYPE_SPLINEIK
@ CONSTRAINT_TYPE_KINEMATIC
@ CONSTRAINT_TYPE_TRANSLIKE
@ CONSTRAINT_TYPE_CLAMPTO
@ CONSTRAINT_TYPE_FOLLOWPATH
@ CONSTRAINT_TYPE_SIZELIKE
@ CONSTRAINT_TYPE_TRANSFORM_CACHE
@ FOLLOWTRACK_ACTIVECLIP
@ CON_SHRINKWRAP_TRACK_NORMAL
@ CU_PATH
#define CD_MASK_NORMAL
#define CD_MASK_ORIGINDEX
#define CD_MASK_MDEFORMVERT
#define CD_MASK_CUSTOMLOOPNORMAL
#define TEXCO_OBJECT
@ MOD_SHRINKWRAP_TARGET_PROJECT
@ MOD_SHRINKWRAP_NEAREST_VERTEX
ModifierType
@ eModifierType_Collision
@ SOCK_IMAGE
@ SOCK_COLLECTION
@ SOCK_OBJECT
#define PFIELD_SHAPE_SURFACE
#define PFIELD_VISIBILITY
@ PFIELD_FLUIDFLOW
@ PFIELD_GUIDE
@ PFIELD_TEXTURE
#define PFIELD_SHAPE_POINTS
Object is a sort of wrapper for general info.
@ OB_DUPLI
@ OB_DUPLIVERTS
@ PARVERT1
@ PARSKEL
@ PARVERT3
@ PARBONE
@ OB_SPEAKER
@ OB_LATTICE
@ OB_MBALL
@ OB_EMPTY
@ OB_SURF
@ OB_CAMERA
@ OB_FONT
@ OB_ARMATURE
@ OB_LAMP
@ OB_MESH
@ OB_POINTCLOUD
@ OB_HAIR
@ OB_VOLUME
@ OB_CURVE
@ OB_GPENCIL
@ OB_LIGHTPROBE
#define PART_PHYS_KEYED
#define PART_DRAW_OB
#define PART_PHYS_BOIDS
#define PSYS_HAIR_DYNAMICS
#define PART_DRAW_GR
@ PART_HAIR
Types and defines for representing Rigid Body entities.
@ RBO_TYPE_ACTIVE
@ RBO_TYPE_PASSIVE
@ RB_SHAPE_COMPOUND
#define AUDIO_VOLUME_ANIMATED
@ SEQ_SCENE_STRIPS
@ SEQ_TYPE_SCENE
ShaderFxType
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume TEX_IMAGE
NODE_GROUP
StructRNA RNA_Bone
StructRNA RNA_PoseBone
#define SEQ_ALL_END
Definition: SEQ_iterator.h:48
#define SEQ_ALL_BEGIN(ed, _seq)
Definition: SEQ_iterator.h:41
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
bool checkIsBuiltAndTag(ID *id, int tag=TAG_COMPLETE)
bool checkIsBuilt(ID *id, int tag=TAG_COMPLETE) const
virtual bool check_pchan_has_bbone_segments(Object *object, const bPoseChannel *pchan)
Definition: deg_builder.cc:126
virtual bool need_pull_base_into_graph(Base *base)
Definition: deg_builder.cc:80
bool has_node(const OperationKey &key) const
void add_particle_collision_relations(const OperationKey &key, Object *object, Collection *collection, const char *name)
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_driver(ID *id, FCurve *fcurve)
virtual void build_dimensions(Object *object)
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_action(bAction *action)
virtual void build_collection(LayerCollection *from_layer_collection, Object *object, Collection *collection)
virtual void build_speaker(Speaker *speaker)
TimeSourceNode * get_node(const TimeSourceKey &key) const
bool is_same_nodetree_node_dependency(const KeyFrom &key_from, const KeyTo &key_to)
virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer)
OperationNode * find_node(const OperationKey &key) const
virtual void build_armature(bArmature *armature)
virtual void build_armature_bones(ListBase *bones)
virtual void build_object_pointcache(Object *object)
virtual void build_constraints(ID *id, NodeType component_type, const char *component_subdata, ListBase *constraints, RootPChanMap *root_map)
virtual void build_animdata_curves_targets(ID *id, ComponentKey &adt_key, OperationNode *operation_from, ListBase *curves)
virtual void build_object_data_light(Object *object)
void add_customdata_mask(Object *object, const DEGCustomDataMeshMasks &customdata_masks)
bool is_same_bone_dependency(const KeyFrom &key_from, const KeyTo &key_to)
virtual void build_driver_id_property(ID *id, const char *rna_path)
virtual void build_scene_sequencer(Scene *scene)
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_proxy_from(Object *object)
void add_special_eval_flag(ID *id, uint32_t flag)
virtual void build_object_from_layer_relations(Object *object)
virtual void build_movieclip(MovieClip *clip)
virtual void build_nodetree(bNodeTree *ntree)
virtual void build_nested_datablock(ID *owner, ID *id)
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)
void add_particle_forcefield_relations(const OperationKey &key, Object *object, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name)
virtual void build_particle_system_visualization_object(Object *object, ParticleSystem *psys, Object *draw_object)
virtual void build_lightprobe(LightProbe *probe)
virtual void build_driver_variables(ID *id, FCurve *fcurve)
virtual void build_nested_shapekey(ID *owner, Key *key)
virtual void build_object_parent(Object *object)
virtual void build_object_proxy_group(Object *object)
virtual void build_simulation(Simulation *simulation)
virtual void build_materials(Material **materials, int num_materials)
virtual void build_object_data_speaker(Object *object)
Relation * add_operation_relation(OperationNode *node_from, OperationNode *node_to, const char *description, int flags=0)
virtual void build_object_data(Object *object)
virtual void build_idproperties(IDProperty *id_property)
virtual void build_cachefile(CacheFile *cache_file)
DepsNodeHandle create_node_handle(const KeyType &key, const char *default_name="")
void add_modifier_to_transform_relation(const DepsNodeHandle *handle, const char *description)
virtual void build_animdata_nlastrip_targets(ID *id, ComponentKey &adt_key, OperationNode *operation_from, ListBase *strips)
Relation * add_time_relation(TimeSourceNode *timesrc, Node *node_to, const char *description, int flags=0)
virtual void build_particle_systems(Object *object)
Node * find_node(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source)
OperationNode * node
Depsgraph * graph
#define DEG_DEBUG_PRINTF(depsgraph, type,...)
Definition: deg_debug.h:68
const IDNode * id_node
Scene scene
Curve curve
FreestyleLineStyle linestyle
World world
Material material
Simulation simulation
Light lamp
void * user_data
bNodeTree * ntree
#define GS(x)
Definition: iris.c:241
static ulong state[N]
NodeType geometry_tag_to_component(const ID *id)
@ RELATION_FLAG_FLUSH_USER_EDIT_ONLY
ListBase * build_collision_relations(Depsgraph *graph, Collection *collection, unsigned int modifier_type)
static void build_idproperties_callback(IDProperty *id_property, void *user_data)
bool deg_copy_on_write_is_needed(const ID *id_orig)
static bool rigidbody_object_depends_on_evaluated_geometry(const RigidBodyOb *rbo)
ListBase * build_effector_relations(Depsgraph *graph, Collection *collection)
const char * operationCodeAsString(OperationCode opcode)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
bool RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
Definition: rna_access.c:5416
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1145
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:174
bool RNA_property_is_idprop(const PropertyRNA *prop)
Definition: rna_access.c:6706
unsigned int uint32_t
Definition: stdint.h:83
bAction * action
ListBase drivers
ListBase nla_tracks
struct ListBase states
char name[64]
struct Object * focus_object
struct CameraDOFSettings dof
ListBase variables
struct Collection * group
struct ClothCollSettings * coll_parms
struct Object * bevobj
struct Object * textoncurve
struct Object * taperobj
char num_targets
DriverTarget targets[8]
struct Collection * group
char * rna_path
ChannelDriver * driver
int array_index
struct bNodeTree * nodetree
void(* updateDepsgraph)(struct GpencilModifierData *md, const struct ModifierUpdateDepsgraphContext *ctx, const int mode)
void * pointer
Definition: DNA_ID.h:63
IDPropertyData data
Definition: DNA_ID.h:80
char type
Definition: DNA_ID.h:71
Definition: DNA_ID.h:273
IDProperty * properties
Definition: DNA_ID.h:314
char name[66]
Definition: DNA_ID.h:283
ID id
Definition: DNA_key_types.h:79
struct AnimData * adt
Definition: DNA_key_types.h:81
ListBase block
struct bNodeTree * nodetree
void * first
Definition: DNA_listBase.h:47
short texco
struct Object * object
struct Tex * tex
Definition: BKE_main.h:116
MaskParent parent
struct bNodeTree * nodetree
struct MaterialGPencilStyle * gp_style
void(* updateDepsgraph)(struct ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
Definition: BKE_modifier.h:319
struct DepsNodeHandle * node
Definition: BKE_modifier.h:147
struct Object * proxy_group
short partype
ListBase particlesystem
short transflag
ListBase constraints
struct Collection * instance_collection
struct bPose * pose
ListBase modifiers
struct Object * proxy_from
struct RigidBodyOb * rigidbody_object
ListBase greasepencil_modifiers
struct Material ** mat
struct Object * proxy
struct PartDeflect * pd
ListBase shader_fx
struct Object * parent
void * data
char parsubstr[64]
struct Collection * collision_group
struct Collection * instance_collection
struct BoidSettings * boids
struct EffectorWeights * effector_weights
struct MTex * mtex[18]
struct Object * instance_object
struct ListBase targets
ParticleSettings * part
struct ClothModifierData * clmd
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
struct Collection * group
struct EffectorWeights * effector_weights
struct RigidBodyWorld * rigidbody_world
struct Editing * ed
struct Object * camera
struct AudioData audio
struct Scene * scene
struct bSound * sound
struct IDProperty * prop
void(* updateDepsgraph)(struct ShaderFxData *fx, const struct ModifierUpdateDepsgraphContext *ctx)
struct bNodeTree * nodetree
struct bSound * sound
ListBase object_bases
char is_sequence
struct bNodeTree * nodetree
ListBase curves
ListBase bonebase
int(* get_constraint_targets)(struct bConstraint *con, struct ListBase *list)
void(* flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy)
ListBase layers
struct Material ** mat
IDProperty * prop
void * default_value
ListBase nodes
ListBase inputs
ListBase outputs
OperationNode * find_operation(OperationIDKey key) const
static DEGCustomDataMeshMasks MaskVert(const uint64_t vert_mask)
static DEGCustomDataMeshMasks MaskFace(const uint64_t face_mask)
static DEGCustomDataMeshMasks MaskLoop(const uint64_t loop_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:112
eEvaluationMode mode
Definition: depsgraph.h:136
Relation * add_new_relation(Node *from, Node *to, const char *description, int flags=0)
Definition: depsgraph.cc:183
TimeSourceNode * time_source
Definition: depsgraph.h:106
IDDepsNodes id_nodes
Definition: depsgraph.h:103
virtual OperationNode * get_exit_operation()
Definition: deg_node.h:203
virtual string identifier() const
Definition: deg_node.cc:309
virtual OperationNode * get_entry_operation()
Definition: deg_node.h:199
virtual string identifier() const override
virtual OperationNode * get_entry_operation() override
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
PointerRNA * ptr
Definition: wm_files.c:3157