Blender  V3.3
deg_builder_nodes.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2013 Blender Foundation. All rights reserved. */
3 
11 
12 #include <cstdio>
13 #include <cstdlib>
14 
15 #include "MEM_guardedalloc.h"
16 
17 #include "BLI_blenlib.h"
18 #include "BLI_string.h"
19 #include "BLI_utildefines.h"
20 
21 #include "DNA_action_types.h"
22 #include "DNA_anim_types.h"
23 #include "DNA_armature_types.h"
24 #include "DNA_cachefile_types.h"
25 #include "DNA_camera_types.h"
26 #include "DNA_collection_types.h"
27 #include "DNA_constraint_types.h"
28 #include "DNA_curve_types.h"
29 #include "DNA_curves_types.h"
30 #include "DNA_effect_types.h"
31 #include "DNA_gpencil_types.h"
32 #include "DNA_key_types.h"
33 #include "DNA_light_types.h"
34 #include "DNA_lightprobe_types.h"
35 #include "DNA_linestyle_types.h"
36 #include "DNA_mask_types.h"
37 #include "DNA_material_types.h"
38 #include "DNA_mesh_types.h"
39 #include "DNA_meta_types.h"
40 #include "DNA_movieclip_types.h"
41 #include "DNA_node_types.h"
42 #include "DNA_object_types.h"
43 #include "DNA_particle_types.h"
44 #include "DNA_rigidbody_types.h"
45 #include "DNA_scene_types.h"
46 #include "DNA_sequence_types.h"
47 #include "DNA_simulation_types.h"
48 #include "DNA_sound_types.h"
49 #include "DNA_speaker_types.h"
50 #include "DNA_texture_types.h"
51 #include "DNA_vfont_types.h"
52 #include "DNA_world_types.h"
53 
54 #include "BKE_action.h"
55 #include "BKE_anim_data.h"
56 #include "BKE_animsys.h"
57 #include "BKE_armature.h"
58 #include "BKE_cachefile.h"
59 #include "BKE_collection.h"
60 #include "BKE_constraint.h"
61 #include "BKE_curve.h"
62 #include "BKE_effect.h"
63 #include "BKE_fcurve_driver.h"
64 #include "BKE_gpencil.h"
65 #include "BKE_gpencil_modifier.h"
66 #include "BKE_idprop.h"
67 #include "BKE_idtype.h"
68 #include "BKE_image.h"
69 #include "BKE_key.h"
70 #include "BKE_lattice.h"
71 #include "BKE_layer.h"
72 #include "BKE_lib_id.h"
73 #include "BKE_lib_query.h"
74 #include "BKE_light.h"
75 #include "BKE_mask.h"
76 #include "BKE_material.h"
77 #include "BKE_mball.h"
78 #include "BKE_mesh.h"
79 #include "BKE_modifier.h"
80 #include "BKE_movieclip.h"
81 #include "BKE_node.h"
82 #include "BKE_node_runtime.hh"
83 #include "BKE_object.h"
84 #include "BKE_particle.h"
85 #include "BKE_pointcache.h"
86 #include "BKE_rigidbody.h"
87 #include "BKE_scene.h"
88 #include "BKE_shader_fx.h"
89 #include "BKE_simulation.h"
90 #include "BKE_sound.h"
91 #include "BKE_tracking.h"
92 #include "BKE_volume.h"
93 #include "BKE_world.h"
94 
95 #include "RNA_access.h"
96 #include "RNA_path.h"
97 #include "RNA_prototypes.h"
98 #include "RNA_types.h"
99 
100 #include "DEG_depsgraph.h"
101 #include "DEG_depsgraph_build.h"
102 
103 #include "SEQ_iterator.h"
104 #include "SEQ_sequencer.h"
105 
108 #include "intern/depsgraph.h"
109 #include "intern/depsgraph_tag.h"
110 #include "intern/depsgraph_type.h"
113 #include "intern/node/deg_node.h"
115 #include "intern/node/deg_node_id.h"
117 
118 namespace blender::deg {
119 
120 /* ************ */
121 /* Node Builder */
122 
123 /* **** General purpose functions **** */
124 
126  Depsgraph *graph,
127  DepsgraphBuilderCache *cache)
128  : DepsgraphBuilder(bmain, graph, cache),
129  scene_(nullptr),
130  view_layer_(nullptr),
131  view_layer_index_(-1),
132  collection_(nullptr),
133  is_parent_collection_visible_(true)
134 {
135 }
136 
138 {
139  for (IDInfo *id_info : id_info_hash_.values()) {
140  if (id_info->id_cow != nullptr) {
141  deg_free_copy_on_write_datablock(id_info->id_cow);
142  MEM_freeN(id_info->id_cow);
143  }
144  MEM_freeN(id_info);
145  }
146 }
147 
149 {
151 
152  const ID_Type id_type = GS(id->name);
153  IDNode *id_node = nullptr;
154  ID *id_cow = nullptr;
155  IDComponentsMask previously_visible_components_mask = 0;
156  uint32_t previous_eval_flags = 0;
157  DEGCustomDataMeshMasks previous_customdata_masks;
158  IDInfo *id_info = id_info_hash_.lookup_default(id->session_uuid, nullptr);
159  if (id_info != nullptr) {
160  id_cow = id_info->id_cow;
161  previously_visible_components_mask = id_info->previously_visible_components_mask;
162  previous_eval_flags = id_info->previous_eval_flags;
163  previous_customdata_masks = id_info->previous_customdata_masks;
164  /* Tag ID info to not free the CoW ID pointer. */
165  id_info->id_cow = nullptr;
166  }
167  id_node = graph_->add_id_node(id, id_cow);
168  id_node->previously_visible_components_mask = previously_visible_components_mask;
169  id_node->previous_eval_flags = previous_eval_flags;
170  id_node->previous_customdata_masks = previous_customdata_masks;
171 
172  /* NOTE: Zero number of components indicates that ID node was just created. */
173  const bool is_newly_created = id_node->components.is_empty();
174 
175  if (is_newly_created) {
176  if (deg_copy_on_write_is_needed(id_type)) {
177  ComponentNode *comp_cow = id_node->add_component(NodeType::COPY_ON_WRITE);
178  OperationNode *op_cow = comp_cow->add_operation(
181  graph_->operations.append(op_cow);
182  }
183 
184  ComponentNode *visibility_component = id_node->add_component(NodeType::VISIBILITY);
185  OperationNode *visibility_operation;
186 
187  /* Optimization: currently only objects need a special visibility evaluation. For the rest ID
188  * types keep the node as a NO-OP so that relations can still be routed, but without penalty
189  * during the graph evaluation. */
190  if (id_type == ID_OB) {
191  visibility_operation = visibility_component->add_operation(
192  [id_node](::Depsgraph *depsgraph) {
194  },
196  }
197  else {
198  visibility_operation = visibility_component->add_operation(nullptr,
200  }
201 
202  /* Pin the node so that it and its relations are preserved by the unused nodes/relations
203  * deletion. This is mainly to make it easier to debug visibility. */
204  visibility_operation->flag |= (OperationFlag::DEPSOP_FLAG_PINNED |
206  graph_->operations.append(visibility_operation);
207  }
208  return id_node;
209 }
210 
212 {
213  return graph_->find_id_node(id);
214 }
215 
217 {
218  return graph_->add_time_source();
219 }
220 
222  NodeType comp_type,
223  const char *comp_name)
224 {
225  IDNode *id_node = add_id_node(id);
226  ComponentNode *comp_node = id_node->add_component(comp_type, comp_name);
227  comp_node->owner = id_node;
228  return comp_node;
229 }
230 
232  OperationCode opcode,
233  const DepsEvalOperationCb &op,
234  const char *name,
235  int name_tag)
236 {
237  OperationNode *op_node = comp_node->find_operation(opcode, name, name_tag);
238  if (op_node == nullptr) {
239  op_node = comp_node->add_operation(op, opcode, name, name_tag);
240  graph_->operations.append(op_node);
241  }
242  else {
243  fprintf(stderr,
244  "add_operation: Operation already exists - %s has %s at %p\n",
245  comp_node->identifier().c_str(),
246  op_node->identifier().c_str(),
247  op_node);
248  BLI_assert_msg(0, "Should not happen!");
249  }
250  return op_node;
251 }
252 
254  NodeType comp_type,
255  const char *comp_name,
256  OperationCode opcode,
257  const DepsEvalOperationCb &op,
258  const char *name,
259  int name_tag)
260 {
261  ComponentNode *comp_node = add_component_node(id, comp_type, comp_name);
262  return add_operation_node(comp_node, opcode, op, name, name_tag);
263 }
264 
266  NodeType comp_type,
267  OperationCode opcode,
268  const DepsEvalOperationCb &op,
269  const char *name,
270  int name_tag)
271 {
272  return add_operation_node(id, comp_type, "", opcode, op, name, name_tag);
273 }
274 
276  NodeType comp_type,
277  const char *comp_name,
278  OperationCode opcode,
279  const DepsEvalOperationCb &op,
280  const char *name,
281  int name_tag)
282 {
283  OperationNode *operation = find_operation_node(id, comp_type, comp_name, opcode, name, name_tag);
284  if (operation != nullptr) {
285  return operation;
286  }
287  return add_operation_node(id, comp_type, comp_name, opcode, op, name, name_tag);
288 }
289 
291  NodeType comp_type,
292  OperationCode opcode,
293  const DepsEvalOperationCb &op,
294  const char *name,
295  int name_tag)
296 {
297  OperationNode *operation = find_operation_node(id, comp_type, opcode, name, name_tag);
298  if (operation != nullptr) {
299  return operation;
300  }
301  return add_operation_node(id, comp_type, opcode, op, name, name_tag);
302 }
303 
305  NodeType comp_type,
306  const char *comp_name,
307  OperationCode opcode,
308  const char *name,
309  int name_tag)
310 {
311  return find_operation_node(id, comp_type, comp_name, opcode, name, name_tag) != nullptr;
312 }
313 
315  NodeType comp_type,
316  const char *comp_name,
317  OperationCode opcode,
318  const char *name,
319  int name_tag)
320 {
321  ComponentNode *comp_node = add_component_node(id, comp_type, comp_name);
322  return comp_node->find_operation(opcode, name, name_tag);
323 }
324 
326  ID *id, NodeType comp_type, OperationCode opcode, const char *name, int name_tag)
327 {
328  return find_operation_node(id, comp_type, "", opcode, name, name_tag);
329 }
330 
331 ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const
332 {
333  return graph_->get_cow_id(id_orig);
334 }
335 
337 {
338  if (id_orig->tag & LIB_TAG_COPIED_ON_WRITE) {
339  /* ID is already remapped to copy-on-write. */
340  return id_orig;
341  }
342  IDNode *id_node = add_id_node(id_orig);
343  return id_node->id_cow;
344 }
345 
346 /* **** Build functions for entity nodes **** */
347 
349 {
350  /* Store existing copy-on-write versions of datablock, so we can re-use
351  * them for new ID nodes. */
352  for (IDNode *id_node : graph_->id_nodes) {
353  /* It is possible that the ID does not need to have CoW version in which case id_cow is the
354  * same as id_orig. Additionally, such ID might have been removed, which makes the check
355  * for whether id_cow is expanded to access freed memory. In order to deal with this we
356  * check whether CoW is needed based on a scalar value which does not lead to access of
357  * possibly deleted memory. */
358  IDInfo *id_info = (IDInfo *)MEM_mallocN(sizeof(IDInfo), "depsgraph id info");
359  if (deg_copy_on_write_is_needed(id_node->id_type) &&
360  deg_copy_on_write_is_expanded(id_node->id_cow) && id_node->id_orig != id_node->id_cow) {
361  id_info->id_cow = id_node->id_cow;
362  }
363  else {
364  id_info->id_cow = nullptr;
365  }
366  id_info->previously_visible_components_mask = id_node->visible_components_mask;
367  id_info->previous_eval_flags = id_node->eval_flags;
368  id_info->previous_customdata_masks = id_node->customdata_masks;
369  BLI_assert(!id_info_hash_.contains(id_node->id_orig_session_uuid));
370  id_info_hash_.add_new(id_node->id_orig_session_uuid, id_info);
371  id_node->id_cow = nullptr;
372  }
373 
374  for (OperationNode *op_node : graph_->entry_tags) {
375  ComponentNode *comp_node = op_node->owner;
376  IDNode *id_node = comp_node->owner;
377 
378  SavedEntryTag entry_tag;
379  entry_tag.id_orig = id_node->id_orig;
380  entry_tag.component_type = comp_node->type;
381  entry_tag.opcode = op_node->opcode;
382  entry_tag.name = op_node->name;
383  entry_tag.name_tag = op_node->name_tag;
384  saved_entry_tags_.append(entry_tag);
385  }
386 
387  /* Make sure graph has no nodes left from previous state. */
390  graph_->entry_tags.clear();
391 }
392 
393 /* Util callbacks for `BKE_library_foreach_ID_link`, used to detect when a COW ID is using ID
394  * pointers that are either:
395  * - COW ID pointers that do not exist anymore in current depsgraph.
396  * - Orig ID pointers that do have now a COW version in current depsgraph.
397  * In both cases, it means the COW ID user needs to be flushed, to ensure its pointers are properly
398  * remapped.
399  *
400  * NOTE: This is split in two, a static function and a public method of the node builder, to allow
401  * the code to access the builder's data more easily. */
402 
404  ID *id_pointer)
405 {
406  if (id_pointer->orig_id == nullptr) {
407  /* `id_cow_self` uses a non-cow ID, if that ID has a COW copy in current depsgraph its owner
408  * needs to be remapped, i.e. COW-flushed. */
409  IDNode *id_node = find_id_node(id_pointer);
410  if (id_node != nullptr && id_node->id_cow != nullptr) {
412  graph_,
413  id_cow_self->orig_id,
416  return IDWALK_RET_STOP_ITER;
417  }
418  }
419  else {
420  /* `id_cow_self` uses a COW ID, if that COW copy is removed from current depsgraph its owner
421  * needs to be remapped, i.e. COW-flushed. */
422  /* NOTE: at that stage, old existing COW copies that are to be removed from current state of
423  * evaluated depsgraph are still valid pointers, they are freed later (typically during
424  * destruction of the builder itself). */
425  IDNode *id_node = find_id_node(id_pointer->orig_id);
426  if (id_node == nullptr) {
428  graph_,
429  id_cow_self->orig_id,
432  return IDWALK_RET_STOP_ITER;
433  }
434  }
435  return IDWALK_RET_NOP;
436 }
437 
439 {
440  ID *id = *cb_data->id_pointer;
441  if (id == nullptr) {
442  return IDWALK_RET_NOP;
443  }
444 
445  DepsgraphNodeBuilder *builder = static_cast<DepsgraphNodeBuilder *>(cb_data->user_data);
446  ID *id_cow_self = cb_data->id_self;
447 
448  return builder->foreach_id_cow_detect_need_for_update_callback(id_cow_self, id);
449 }
450 
452 {
453  /* NOTE: Currently the only ID types that depsgraph may decide to not evaluate/generate COW
454  * copies for, even though they are referenced by other data-blocks, are Collections and Objects
455  * (through their various visibility flags, and the ones from #LayerCollections too). However,
456  * this code is kept generic as it makes it more future-proof, and optimization here would give
457  * negligible performance improvements in typical cases.
458  *
459  * NOTE: This mechanism may also 'fix' some missing update tagging from non-depsgraph code in
460  * some cases. This is slightly unfortunate (as it may hide issues in other parts of Blender
461  * code), but cannot really be avoided currently. */
462 
463  for (const IDNode *id_node : graph_->id_nodes) {
464  if (id_node->previously_visible_components_mask == 0) {
465  /* Newly added node/ID, no need to check it. */
466  continue;
467  }
468  if (ELEM(id_node->id_cow, id_node->id_orig, nullptr)) {
469  /* Node/ID with no COW data, no need to check it. */
470  continue;
471  }
472  if ((id_node->id_cow->recalc & ID_RECALC_COPY_ON_WRITE) != 0) {
473  /* Node/ID already tagged for COW flush, no need to check it. */
474  continue;
475  }
476  if ((id_node->id_cow->flag & LIB_EMBEDDED_DATA) != 0) {
477  /* For now, we assume embedded data are managed by their owner IDs and do not need to be
478  * checked here.
479  *
480  * NOTE: This exception somewhat weak, and ideally should not be needed. Currently however,
481  * embedded data are handled as full local (private) data of their owner IDs in part of
482  * Blender (like read/write code, including undo/redo), while depsgraph generally treat them
483  * as regular independent IDs. This leads to inconsistencies that can lead to bad level
484  * memory accesses.
485  *
486  * E.g. when undoing creation/deletion of a collection directly child of a scene's master
487  * collection, the scene itself is re-read in place, but its master collection becomes a
488  * completely new different pointer, and the existing COW of the old master collection in the
489  * matching deg node is therefore pointing to fully invalid (freed) memory. */
490  continue;
491  }
493  id_node->id_cow,
495  this,
497  }
498 }
499 
501 {
502  for (const SavedEntryTag &entry_tag : saved_entry_tags_) {
503  IDNode *id_node = find_id_node(entry_tag.id_orig);
504  if (id_node == nullptr) {
505  continue;
506  }
507  ComponentNode *comp_node = id_node->find_component(entry_tag.component_type);
508  if (comp_node == nullptr) {
509  continue;
510  }
511  OperationNode *op_node = comp_node->find_operation(
512  entry_tag.opcode, entry_tag.name.c_str(), entry_tag.name_tag);
513  if (op_node == nullptr) {
514  continue;
515  }
516  /* Since the tag is coming from a saved copy of entry tags, this means
517  * that originally node was explicitly tagged for user update. */
519  }
520 }
521 
523 {
526 }
527 
529 {
530  if (id == nullptr) {
531  return;
532  }
533 
534  const ID_Type id_type = GS(id->name);
535  switch (id_type) {
536  case ID_AC:
537  build_action((bAction *)id);
538  break;
539  case ID_AR:
540  build_armature((bArmature *)id);
541  break;
542  case ID_CA:
543  build_camera((Camera *)id);
544  break;
545  case ID_GR:
546  build_collection(nullptr, (Collection *)id);
547  break;
548  case ID_OB:
549  /* TODO(sergey): Get visibility from a "parent" somehow.
550  *
551  * NOTE: Using `false` visibility here should be fine, since if this
552  * driver affects on something invisible we don't really care if the
553  * driver gets evaluated (and even don't want this to force object
554  * to become visible).
555  *
556  * If this happened to be affecting visible object, then it is up to
557  * deg_graph_build_flush_visibility() to ensure visibility of the
558  * object is true. */
559  build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, false);
560  break;
561  case ID_KE:
562  build_shapekeys((Key *)id);
563  break;
564  case ID_LA:
565  build_light((Light *)id);
566  break;
567  case ID_LP:
569  break;
570  case ID_NT:
571  build_nodetree((bNodeTree *)id);
572  break;
573  case ID_MA:
574  build_material((Material *)id);
575  break;
576  case ID_TE:
577  build_texture((Tex *)id);
578  break;
579  case ID_IM:
580  build_image((Image *)id);
581  break;
582  case ID_WO:
583  build_world((World *)id);
584  break;
585  case ID_MSK:
586  build_mask((Mask *)id);
587  break;
588  case ID_LS:
590  break;
591  case ID_MC:
592  build_movieclip((MovieClip *)id);
593  break;
594  case ID_ME:
595  case ID_MB:
596  case ID_CU_LEGACY:
597  case ID_LT:
598  case ID_GD:
599  case ID_CV:
600  case ID_PT:
601  case ID_VO:
603  break;
604  case ID_SPK:
605  build_speaker((Speaker *)id);
606  break;
607  case ID_SO:
608  build_sound((bSound *)id);
609  break;
610  case ID_TXT:
611  /* Not a part of dependency graph. */
612  break;
613  case ID_CF:
614  build_cachefile((CacheFile *)id);
615  break;
616  case ID_SCE:
618  break;
619  case ID_SIM:
621  break;
622  case ID_PA:
624  break;
625 
626  case ID_LI:
627  case ID_IP:
628  case ID_SCR:
629  case ID_VF:
630  case ID_BR:
631  case ID_WM:
632  case ID_PAL:
633  case ID_PC:
634  case ID_WS:
636  build_generic_id(id);
637  break;
638  }
639 }
640 
642 {
643  if (built_map_.checkIsBuiltAndTag(id)) {
644  return;
645  }
646 
648  build_animdata(id);
649  build_parameters(id);
650 }
651 
652 static void build_idproperties_callback(IDProperty *id_property, void *user_data)
653 {
654  DepsgraphNodeBuilder *builder = reinterpret_cast<DepsgraphNodeBuilder *>(user_data);
655  BLI_assert(id_property->type == IDP_ID);
656  builder->build_id(reinterpret_cast<ID *>(id_property->data.pointer));
657 }
658 
660 {
662 }
663 
665  Collection *collection)
666 {
667  const int visibility_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? COLLECTION_HIDE_VIEWPORT :
669  const bool is_collection_restricted = (collection->flag & visibility_flag);
670  const bool is_collection_visible = !is_collection_restricted && is_parent_collection_visible_;
671  IDNode *id_node;
672  if (built_map_.checkIsBuiltAndTag(collection)) {
673  id_node = find_id_node(&collection->id);
674  if (is_collection_visible && id_node->is_visible_on_build == false &&
675  id_node->is_collection_fully_expanded == true) {
676  /* Collection became visible, make sure nested collections and
677  * objects are poked with the new visibility flag, since they
678  * might become visible too. */
679  }
680  else if (from_layer_collection == nullptr && !id_node->is_collection_fully_expanded) {
681  /* Initially collection was built from layer now, and was requested
682  * to not recurse into object. But now it's asked to recurse into all objects. */
683  }
684  else {
685  return;
686  }
687  }
688  else {
689  /* Collection itself. */
690  id_node = add_id_node(&collection->id);
691  id_node->is_visible_on_build = is_collection_visible;
692 
693  build_idproperties(collection->id.properties);
695  }
696  if (from_layer_collection != nullptr) {
697  /* If we came from layer collection we don't go deeper, view layer
698  * builder takes care of going deeper. */
699  return;
700  }
701  /* Backup state. */
702  Collection *current_state_collection = collection_;
703  const bool is_current_parent_collection_visible = is_parent_collection_visible_;
704  /* Modify state as we've entered new collection/ */
705  collection_ = collection;
706  is_parent_collection_visible_ = is_collection_visible;
707  /* Build collection objects. */
708  LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
709  build_object(-1, cob->ob, DEG_ID_LINKED_INDIRECTLY, is_collection_visible);
710  }
711  /* Build child collections. */
712  LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
713  build_collection(nullptr, child->collection);
714  }
715  /* Restore state. */
716  collection_ = current_state_collection;
717  is_parent_collection_visible_ = is_current_parent_collection_visible;
718  id_node->is_collection_fully_expanded = true;
719 }
720 
722  Object *object,
723  eDepsNode_LinkedState_Type linked_state,
724  bool is_visible)
725 {
726  const bool has_object = built_map_.checkIsBuiltAndTag(object);
727 
728  /* When there is already object in the dependency graph accumulate visibility an linked state
729  * flags. Only do it on the object itself (apart from very special cases) and leave dealing with
730  * visibility of dependencies to the visibility flush step which happens at the end of the build
731  * process. */
732  if (has_object) {
733  IDNode *id_node = find_id_node(&object->id);
734  if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) {
735  build_object_flags(base_index, object, linked_state);
736  }
737  id_node->linked_state = max(id_node->linked_state, linked_state);
738  id_node->is_visible_on_build |= is_visible;
739  id_node->has_base |= (base_index != -1);
740 
741  /* There is no relation path which will connect current object with all the ones which come
742  * via the instanced collection, so build the collection again. Note that it will do check
743  * whether visibility update is needed on its own. */
744  build_object_instance_collection(object, is_visible);
745 
746  return;
747  }
748 
749  /* Create ID node for object and begin init. */
750  IDNode *id_node = add_id_node(&object->id);
751  Object *object_cow = get_cow_datablock(object);
752  id_node->linked_state = linked_state;
753  /* NOTE: Scene is nullptr when building dependency graph for render pipeline.
754  * Probably need to assign that to something non-nullptr, but then the logic here will still be
755  * somewhat weird. */
756  if (scene_ != nullptr && object == scene_->camera) {
757  id_node->is_visible_on_build = true;
758  }
759  else {
760  id_node->is_visible_on_build = is_visible;
761  }
762  id_node->has_base |= (base_index != -1);
763  /* Various flags, flushing from bases/collections. */
764  build_object_from_layer(base_index, object, linked_state);
765  /* Transform. */
766  build_object_transform(object);
767  /* Parent. */
768  if (object->parent != nullptr) {
769  build_object(-1, object->parent, DEG_ID_LINKED_INDIRECTLY, is_visible);
770  }
771  /* Modifiers. */
772  if (object->modifiers.first != nullptr) {
774  data.builder = this;
776  }
777  /* Grease Pencil Modifiers. */
778  if (object->greasepencil_modifiers.first != nullptr) {
780  data.builder = this;
782  }
783  /* Shader FX. */
784  if (object->shader_fx.first != nullptr) {
786  data.builder = this;
788  }
789  /* Constraints. */
790  if (object->constraints.first != nullptr) {
792  data.builder = this;
794  }
795  /* Object data. */
796  build_object_data(object);
797  /* Parameters, used by both drivers/animation and also to inform dependency
798  * from object's data. */
799  build_parameters(&object->id);
801  /* Build animation data,
802  *
803  * Do it now because it's possible object data will affect
804  * on object's level animation, for example in case of rebuilding
805  * pose for proxy. */
806  build_animdata(&object->id);
807  /* Particle systems. */
808  if (object->particlesystem.first != nullptr) {
809  build_particle_systems(object, is_visible);
810  }
811  /* Force field Texture. */
812  if ((object->pd != nullptr) && (object->pd->forcefield == PFIELD_TEXTURE) &&
813  (object->pd->tex != nullptr)) {
814  build_texture(object->pd->tex);
815  }
816  /* Object dupligroup. */
817  if (object->instance_collection != nullptr) {
818  build_object_instance_collection(object, is_visible);
822  }
823  /* Synchronization back to original object. */
824  add_operation_node(&object->id,
827  [object_cow](::Depsgraph *depsgraph) {
828  BKE_object_sync_to_original(depsgraph, object_cow);
829  });
830 }
831 
833  Object *object,
834  eDepsNode_LinkedState_Type linked_state)
835 {
836 
837  OperationNode *entry_node = add_operation_node(
839  entry_node->set_as_entry();
840  OperationNode *exit_node = add_operation_node(
842  exit_node->set_as_exit();
843 
844  build_object_flags(base_index, object, linked_state);
845 }
846 
848  Object *object,
849  eDepsNode_LinkedState_Type linked_state)
850 {
851  if (base_index == -1) {
852  return;
853  }
854  Scene *scene_cow = get_cow_datablock(scene_);
855  Object *object_cow = get_cow_datablock(object);
856  const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET);
857  /* TODO(sergey): Is this really best component to be used? */
859  &object->id,
862  [view_layer_index = view_layer_index_, scene_cow, object_cow, base_index, is_from_set](
863  ::Depsgraph *depsgraph) {
864  BKE_object_eval_eval_base_flags(
865  depsgraph, scene_cow, view_layer_index, object_cow, base_index, is_from_set);
866  });
867 }
868 
870 {
871  if (object->instance_collection == nullptr) {
872  return;
873  }
874  const bool is_current_parent_collection_visible = is_parent_collection_visible_;
875  is_parent_collection_visible_ = is_object_visible;
876  build_collection(nullptr, object->instance_collection);
877  is_parent_collection_visible_ = is_current_parent_collection_visible;
878 }
879 
881 {
882  if (object->data == nullptr) {
883  return;
884  }
885  /* type-specific data. */
886  switch (object->type) {
887  case OB_MESH:
888  case OB_CURVES_LEGACY:
889  case OB_FONT:
890  case OB_SURF:
891  case OB_MBALL:
892  case OB_LATTICE:
893  case OB_GPENCIL:
894  case OB_CURVES:
895  case OB_POINTCLOUD:
896  case OB_VOLUME:
898  break;
899  case OB_ARMATURE:
900  build_rig(object);
901  break;
902  case OB_LAMP:
903  build_object_data_light(object);
904  break;
905  case OB_CAMERA:
906  build_object_data_camera(object);
907  break;
908  case OB_LIGHTPROBE:
910  break;
911  case OB_SPEAKER:
913  break;
914  default: {
915  ID *obdata = (ID *)object->data;
916  if (!built_map_.checkIsBuilt(obdata)) {
917  build_animdata(obdata);
918  }
919  break;
920  }
921  }
922  /* Materials. */
923  Material ***materials_ptr = BKE_object_material_array_p(object);
924  if (materials_ptr != nullptr) {
925  short *num_materials_ptr = BKE_object_material_len_p(object);
926  build_materials(*materials_ptr, *num_materials_ptr);
927  }
928 }
929 
931 {
932  Camera *camera = (Camera *)object->data;
934 }
935 
937 {
938  Light *lamp = (Light *)object->data;
939  build_light(lamp);
940 }
941 
943 {
944  LightProbe *probe = (LightProbe *)object->data;
945  build_lightprobe(probe);
947 }
948 
950 {
951  Speaker *speaker = (Speaker *)object->data;
952  build_speaker(speaker);
954 }
955 
957 {
958  OperationNode *op_node;
959  Object *ob_cow = get_cow_datablock(object);
960  /* Transform entry operation. */
962  op_node->set_as_entry();
963  /* Local transforms (from transform channels - loc/rot/scale + deltas). */
965  &object->id,
968  [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_local_transform(depsgraph, ob_cow); });
969  /* Object parent. */
970  if (object->parent != nullptr) {
972  &object->id,
975  [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_parent(depsgraph, ob_cow); });
976  }
977  /* Object constraints. */
978  if (object->constraints.first != nullptr) {
979  build_object_constraints(object);
980  }
981  /* Rest of transformation update. */
983  &object->id,
986  [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_uber_transform(depsgraph, ob_cow); });
987  /* Operation to take of rigid body simulation. soft bodies and other friends
988  * in the context of point cache invalidation. */
990  /* Object transform is done. */
991  op_node = add_operation_node(
992  &object->id,
995  [ob_cow](::Depsgraph *depsgraph) { BKE_object_eval_transform_final(depsgraph, ob_cow); });
996  op_node->set_as_exit();
997 }
998 
1017 {
1018  /* create node for constraint stack */
1019  Scene *scene_cow = get_cow_datablock(scene_);
1020  Object *object_cow = get_cow_datablock(object);
1021  add_operation_node(&object->id,
1024  [scene_cow, object_cow](::Depsgraph *depsgraph) {
1025  BKE_object_eval_constraints(depsgraph, scene_cow, object_cow);
1026  });
1027 }
1028 
1030 {
1031  if (!BKE_ptcache_object_has(scene_, object, 0)) {
1032  return;
1033  }
1034  Scene *scene_cow = get_cow_datablock(scene_);
1035  Object *object_cow = get_cow_datablock(object);
1036  add_operation_node(&object->id,
1039  [scene_cow, object_cow](::Depsgraph *depsgraph) {
1040  BKE_object_eval_ptcache_reset(depsgraph, scene_cow, object_cow);
1041  });
1042 }
1043 
1045 {
1046  /* Special handling for animated images/sequences. */
1048  /* Regular animation. */
1049  AnimData *adt = BKE_animdata_from_id(id);
1050  if (adt == nullptr) {
1051  return;
1052  }
1053  if (adt->action != nullptr) {
1054  build_action(adt->action);
1055  }
1056  /* Make sure ID node exists. */
1057  (void)add_id_node(id);
1058  ID *id_cow = get_cow_id(id);
1059  if (adt->action != nullptr || !BLI_listbase_is_empty(&adt->nla_tracks)) {
1060  OperationNode *operation_node;
1061  /* Explicit entry operation. */
1063  operation_node->set_as_entry();
1064  /* All the evaluation nodes. */
1068  });
1069  /* Explicit exit operation. */
1071  operation_node->set_as_exit();
1072  }
1073  /* NLA strips contain actions. */
1074  LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
1075  build_animdata_nlastrip_targets(&nlt->strips);
1076  }
1077  /* Drivers. */
1078  int driver_index = 0;
1079  LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
1080  /* create driver */
1081  build_driver(id, fcu, driver_index++);
1082  }
1083 }
1084 
1086 {
1087  LISTBASE_FOREACH (NlaStrip *, strip, strips) {
1088  if (strip->act != nullptr) {
1089  build_action(strip->act);
1090  }
1091  else if (strip->strips.first != nullptr) {
1092  build_animdata_nlastrip_targets(&strip->strips);
1093  }
1094  }
1095 }
1096 
1098 {
1099  /* GPU materials might use an animated image. However, these materials have no been built yet so
1100  * we have to check if they might be created during evaluation. */
1101  bool has_image_animation = false;
1102  if (ELEM(GS(id->name), ID_MA, ID_WO)) {
1104  if (ntree != nullptr &&
1106  has_image_animation = true;
1107  }
1108  }
1109 
1110  if (has_image_animation || BKE_image_user_id_has_animation(id)) {
1111  ID *id_cow = get_cow_id(id);
1113  id,
1116  [id_cow](::Depsgraph *depsgraph) { BKE_image_user_id_eval_animation(depsgraph, id_cow); });
1117  }
1118 }
1119 
1121 {
1122  if (built_map_.checkIsBuiltAndTag(action)) {
1123  return;
1124  }
1125  build_idproperties(action->id.properties);
1127 }
1128 
1129 void DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcurve, int driver_index)
1130 {
1131  /* Create data node for this driver */
1132  ID *id_cow = get_cow_id(id);
1133 
1134  /* TODO(sergey): ideally we could pass the COW of fcu, but since it
1135  * has not yet been allocated at this point we can't. As a workaround
1136  * the animation systems allocates an array so we can do a fast lookup
1137  * with the driver index. */
1139  id,
1142  [id_cow, driver_index, fcurve](::Depsgraph *depsgraph) {
1143  BKE_animsys_eval_driver(depsgraph, id_cow, driver_index, fcurve);
1144  },
1145  fcurve->rna_path ? fcurve->rna_path : "",
1146  fcurve->array_index);
1147  build_driver_variables(id, fcurve);
1148 }
1149 
1151 {
1152  build_driver_id_property(id, fcurve->rna_path);
1153  LISTBASE_FOREACH (DriverVar *, dvar, &fcurve->driver->variables) {
1155  if (dtar->id == nullptr) {
1156  continue;
1157  }
1158  build_id(dtar->id);
1159  build_driver_id_property(dtar->id, dtar->rna_path);
1160  }
1162  }
1163 }
1164 
1166 {
1167  if (id == nullptr || rna_path == nullptr) {
1168  return;
1169  }
1170  PointerRNA id_ptr, ptr;
1171  PropertyRNA *prop;
1172  int index;
1173  RNA_id_pointer_create(id, &id_ptr);
1174  if (!RNA_path_resolve_full(&id_ptr, rna_path, &ptr, &prop, &index)) {
1175  return;
1176  }
1177  if (prop == nullptr) {
1178  return;
1179  }
1180  if (!rna_prop_affects_parameters_node(&ptr, prop)) {
1181  return;
1182  }
1183  const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop);
1184  /* Custom properties of bones are placed in their components to improve granularity. */
1185  if (RNA_struct_is_a(ptr.type, &RNA_PoseBone)) {
1186  const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr.data);
1188  id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, nullptr, prop_identifier);
1189  }
1190  else {
1192  id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, nullptr, prop_identifier);
1193  }
1194 }
1195 
1197 {
1198  (void)add_id_node(id);
1199  OperationNode *op_node;
1200  /* Explicit entry. */
1202  op_node->set_as_entry();
1203  /* Generic evaluation node. */
1204 
1206  ID *id_cow = get_cow_id(id);
1208  id,
1211  [id_cow, id](::Depsgraph * /*depsgraph*/) { BKE_id_eval_properties_copy(id_cow, id); });
1212  }
1213  else {
1215  }
1216 
1217  /* Explicit exit operation. */
1219  op_node->set_as_exit();
1220 }
1221 
1223 {
1224  /* Object dimensions (bounding box) node. Will depend on both geometry and transform. */
1226 }
1227 
1228 /* Recursively build graph for world */
1230 {
1232  return;
1233  }
1234  /* World itself. */
1235  add_id_node(&world->id);
1236  World *world_cow = get_cow_datablock(world);
1237  /* Shading update. */
1239  &world->id,
1242  [world_cow](::Depsgraph *depsgraph) { BKE_world_eval(depsgraph, world_cow); });
1244  /* Animation. */
1245  build_animdata(&world->id);
1247  /* World's nodetree. */
1249 }
1250 
1251 /* Rigidbody Simulation - Scene Level */
1253 {
1255  Scene *scene_cow = get_cow_datablock(scene);
1256 
1272  /* Create nodes --------------------------------------------------------- */
1273 
1274  /* XXX: is this the right component, or do we want to use another one
1275  * instead? */
1276 
1277  /* Init/rebuild operation. */
1279  &scene->id,
1282  [scene_cow](::Depsgraph *depsgraph) { BKE_rigidbody_rebuild_sim(depsgraph, scene_cow); });
1283  /* Do-sim operation. */
1284  OperationNode *sim_node = add_operation_node(&scene->id,
1287  [scene_cow](::Depsgraph *depsgraph) {
1288  BKE_rigidbody_eval_simulation(depsgraph,
1289  scene_cow);
1290  });
1291  sim_node->set_as_entry();
1292  sim_node->set_as_exit();
1293  sim_node->owner->entry_operation = sim_node;
1294  /* Objects - simulation participants. */
1295  if (rbw->group != nullptr) {
1296  build_collection(nullptr, rbw->group);
1298  if (object->type != OB_MESH) {
1299  continue;
1300  }
1301  if (object->rigidbody_object == nullptr) {
1302  continue;
1303  }
1304 
1305  if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
1306  continue;
1307  }
1308 
1309  /* Create operation for flushing results. */
1310  /* Object's transform component - where the rigidbody operation
1311  * lives. */
1312  Object *object_cow = get_cow_datablock(object);
1313  add_operation_node(&object->id,
1316  [scene_cow, object_cow](::Depsgraph *depsgraph) {
1317  BKE_rigidbody_object_sync_transforms(depsgraph, scene_cow, object_cow);
1318  });
1319  }
1321  }
1322  /* Constraints. */
1323  if (rbw->constraints != nullptr) {
1325  RigidBodyCon *rbc = object->rigidbody_constraint;
1326  if (rbc == nullptr || rbc->ob1 == nullptr || rbc->ob2 == nullptr) {
1327  /* When either ob1 or ob2 is nullptr, the constraint doesn't work. */
1328  continue;
1329  }
1330  /* Make sure indirectly linked objects are fully built. */
1331  build_object(-1, object, DEG_ID_LINKED_INDIRECTLY, false);
1332  build_object(-1, rbc->ob1, DEG_ID_LINKED_INDIRECTLY, false);
1333  build_object(-1, rbc->ob2, DEG_ID_LINKED_INDIRECTLY, false);
1334  }
1336  }
1337 }
1338 
1339 void DepsgraphNodeBuilder::build_particle_systems(Object *object, bool is_object_visible)
1340 {
1354  /* Component for all particle systems. */
1356 
1357  Object *ob_cow = get_cow_datablock(object);
1358  OperationNode *op_node;
1359  op_node = add_operation_node(
1360  psys_comp, OperationCode::PARTICLE_SYSTEM_INIT, [ob_cow](::Depsgraph *depsgraph) {
1362  });
1363  op_node->set_as_entry();
1364  /* Build all particle systems. */
1365  LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
1366  ParticleSettings *part = psys->part;
1367  /* Build particle settings operations.
1368  *
1369  * NOTE: The call itself ensures settings are only build once. */
1371  /* Particle system evaluation. */
1372  add_operation_node(psys_comp, OperationCode::PARTICLE_SYSTEM_EVAL, nullptr, psys->name);
1373  /* Keyed particle targets. */
1375  LISTBASE_FOREACH (ParticleTarget *, particle_target, &psys->targets) {
1376  if (ELEM(particle_target->ob, nullptr, object)) {
1377  continue;
1378  }
1379  build_object(-1, particle_target->ob, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
1380  }
1381  }
1382  /* Visualization of particle system. */
1383  switch (part->ren_as) {
1384  case PART_DRAW_OB:
1385  if (part->instance_object != nullptr) {
1386  build_object(-1, part->instance_object, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
1387  }
1388  break;
1389  case PART_DRAW_GR:
1390  if (part->instance_collection != nullptr) {
1391  build_collection(nullptr, part->instance_collection);
1392  }
1393  break;
1394  }
1395  }
1397  op_node->set_as_exit();
1398 }
1399 
1401 {
1402  if (built_map_.checkIsBuiltAndTag(particle_settings)) {
1403  return;
1404  }
1405  /* Make sure we've got proper copied ID pointer. */
1406  add_id_node(&particle_settings->id);
1407  ParticleSettings *particle_settings_cow = get_cow_datablock(particle_settings);
1408  /* Animation data. */
1409  build_animdata(&particle_settings->id);
1410  build_parameters(&particle_settings->id);
1411  /* Parameters change. */
1412  OperationNode *op_node;
1413  op_node = add_operation_node(
1415  op_node->set_as_entry();
1416  add_operation_node(&particle_settings->id,
1419  [particle_settings_cow](::Depsgraph *depsgraph) {
1420  BKE_particle_settings_eval_reset(depsgraph, particle_settings_cow);
1421  });
1422  op_node = add_operation_node(
1424  op_node->set_as_exit();
1425  /* Texture slots. */
1426  for (MTex *mtex : particle_settings->mtex) {
1427  if (mtex == nullptr || mtex->tex == nullptr) {
1428  continue;
1429  }
1430  build_texture(mtex->tex);
1431  }
1432 }
1433 
1434 /* Shape-keys. */
1436 {
1437  if (built_map_.checkIsBuiltAndTag(key)) {
1438  return;
1439  }
1441  build_animdata(&key->id);
1442  build_parameters(&key->id);
1443  /* This is an exit operation for the entire key datablock, is what is used
1444  * as dependency for modifiers evaluation. */
1446  /* Create per-key block properties, allowing tricky inter-dependencies for
1447  * drivers evaluation. */
1448  LISTBASE_FOREACH (KeyBlock *, key_block, &key->block) {
1450  &key->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL, nullptr, key_block->name);
1451  }
1452 }
1453 
1454 /* ObData Geometry Evaluation */
1455 /* XXX: what happens if the datablock is shared! */
1457 {
1458  OperationNode *op_node;
1459  Scene *scene_cow = get_cow_datablock(scene_);
1460  Object *object_cow = get_cow_datablock(object);
1461  /* Entry operation, takes care of initialization, and some other
1462  * relations which needs to be run prior actual geometry evaluation. */
1464  op_node->set_as_entry();
1465  /* Geometry evaluation. */
1466  op_node = add_operation_node(&object->id,
1469  [scene_cow, object_cow](::Depsgraph *depsgraph) {
1470  BKE_object_eval_uber_data(depsgraph, scene_cow, object_cow);
1471  });
1472  op_node->set_as_exit();
1473  /* Materials. */
1474  build_materials(object->mat, object->totcol);
1475  /* Point caches. */
1476  build_object_pointcache(object);
1477  /* Geometry. */
1479  build_dimensions(object);
1480  /* Batch cache. */
1482  &object->id,
1485  [object_cow](::Depsgraph *depsgraph) { BKE_object_select_update(depsgraph, object_cow); });
1486 }
1487 
1489 {
1490  if (built_map_.checkIsBuiltAndTag(obdata)) {
1491  return;
1492  }
1493  OperationNode *op_node;
1494  /* Make sure we've got an ID node before requesting CoW pointer. */
1495  (void)add_id_node((ID *)obdata);
1496  ID *obdata_cow = get_cow_id(obdata);
1497  build_idproperties(obdata->properties);
1498  /* Animation. */
1499  build_animdata(obdata);
1500  /* ShapeKeys */
1501  Key *key = BKE_key_from_id(obdata);
1502  if (key) {
1503  build_shapekeys(key);
1504  }
1505  /* Nodes for result of obdata's evaluation, and geometry
1506  * evaluation on object. */
1507  const ID_Type id_type = GS(obdata->name);
1508  switch (id_type) {
1509  case ID_ME: {
1510  op_node = add_operation_node(obdata,
1513  [obdata_cow](::Depsgraph *depsgraph) {
1514  BKE_mesh_eval_geometry(depsgraph, (Mesh *)obdata_cow);
1515  });
1516  op_node->set_as_entry();
1517  break;
1518  }
1519  case ID_MB: {
1521  op_node->set_as_entry();
1522  break;
1523  }
1524  case ID_CU_LEGACY: {
1525  op_node = add_operation_node(obdata,
1528  [obdata_cow](::Depsgraph *depsgraph) {
1529  BKE_curve_eval_geometry(depsgraph, (Curve *)obdata_cow);
1530  });
1531  op_node->set_as_entry();
1532  Curve *cu = (Curve *)obdata;
1533  if (cu->bevobj != nullptr) {
1534  build_object(-1, cu->bevobj, DEG_ID_LINKED_INDIRECTLY, false);
1535  }
1536  if (cu->taperobj != nullptr) {
1538  }
1539  if (cu->textoncurve != nullptr) {
1541  }
1542  break;
1543  }
1544  case ID_LT: {
1545  op_node = add_operation_node(obdata,
1548  [obdata_cow](::Depsgraph *depsgraph) {
1550  });
1551  op_node->set_as_entry();
1552  break;
1553  }
1554 
1555  case ID_GD: {
1556  /* GPencil evaluation operations. */
1557  op_node = add_operation_node(obdata,
1560  [obdata_cow](::Depsgraph *depsgraph) {
1562  (bGPdata *)obdata_cow);
1563  });
1564  op_node->set_as_entry();
1565  break;
1566  }
1567  case ID_CV: {
1568  Curves *curves_id = reinterpret_cast<Curves *>(obdata);
1569 
1571  op_node->set_as_entry();
1572 
1573  if (curves_id->surface != nullptr) {
1574  build_object(-1, curves_id->surface, DEG_ID_LINKED_INDIRECTLY, false);
1575  }
1576  break;
1577  }
1578  case ID_PT: {
1580  op_node->set_as_entry();
1581  break;
1582  }
1583  case ID_VO: {
1584  /* Volume frame update. */
1585  op_node = add_operation_node(obdata,
1588  [obdata_cow](::Depsgraph *depsgraph) {
1589  BKE_volume_eval_geometry(depsgraph, (Volume *)obdata_cow);
1590  });
1591  op_node->set_as_entry();
1592  break;
1593  }
1594  default:
1595  BLI_assert_msg(0, "Should not happen");
1596  break;
1597  }
1599  op_node->set_as_exit();
1600  /* Parameters for driver sources. */
1601  build_parameters(obdata);
1602  /* Batch cache. */
1603  add_operation_node(obdata,
1606  [obdata_cow](::Depsgraph *depsgraph) {
1608  });
1609 }
1610 
1612 {
1613  if (built_map_.checkIsBuiltAndTag(armature)) {
1614  return;
1615  }
1616  build_idproperties(armature->id.properties);
1617  build_animdata(&armature->id);
1618  build_parameters(&armature->id);
1619  /* Make sure pose is up-to-date with armature updates. */
1620  bArmature *armature_cow = (bArmature *)get_cow_id(&armature->id);
1621  add_operation_node(&armature->id,
1624  [armature_cow](::Depsgraph *depsgraph) {
1625  BKE_armature_refresh_layer_used(depsgraph, armature_cow);
1626  });
1627  build_armature_bones(&armature->bonebase);
1628 }
1629 
1631 {
1632  LISTBASE_FOREACH (Bone *, bone, bones) {
1633  build_idproperties(bone->prop);
1634  build_armature_bones(&bone->childbase);
1635  }
1636 }
1637 
1639 {
1641  return;
1642  }
1643  build_idproperties(camera->id.properties);
1644  build_animdata(&camera->id);
1645  build_parameters(&camera->id);
1646  if (camera->dof.focus_object != nullptr) {
1647  build_object(-1, camera->dof.focus_object, DEG_ID_LINKED_INDIRECTLY, false);
1648  }
1649 }
1650 
1652 {
1654  return;
1655  }
1657  build_animdata(&lamp->id);
1659  /* light's nodetree */
1661 
1662  Light *lamp_cow = get_cow_datablock(lamp);
1666  [lamp_cow](::Depsgraph *depsgraph) { BKE_light_eval(depsgraph, lamp_cow); });
1667 }
1668 
1670 {
1671  build_idproperties(socket->prop);
1672 
1673  if (socket->type == SOCK_OBJECT) {
1674  build_id((ID *)((bNodeSocketValueObject *)socket->default_value)->value);
1675  }
1676  else if (socket->type == SOCK_IMAGE) {
1677  build_id((ID *)((bNodeSocketValueImage *)socket->default_value)->value);
1678  }
1679  else if (socket->type == SOCK_COLLECTION) {
1680  build_id((ID *)((bNodeSocketValueCollection *)socket->default_value)->value);
1681  }
1682  else if (socket->type == SOCK_TEXTURE) {
1683  build_id((ID *)((bNodeSocketValueTexture *)socket->default_value)->value);
1684  }
1685  else if (socket->type == SOCK_MATERIAL) {
1686  build_id((ID *)((bNodeSocketValueMaterial *)socket->default_value)->value);
1687  }
1688 }
1689 
1691 {
1692  if (ntree == nullptr) {
1693  return;
1694  }
1696  return;
1697  }
1698  /* nodetree itself */
1699  add_id_node(&ntree->id);
1700  /* General parameters. */
1703  /* Animation, */
1704  build_animdata(&ntree->id);
1705  /* Output update. */
1707  /* nodetree's nodes... */
1708  LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) {
1709  build_idproperties(bnode->prop);
1710  LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->inputs) {
1711  build_nodetree_socket(socket);
1712  }
1713  LISTBASE_FOREACH (bNodeSocket *, socket, &bnode->outputs) {
1714  build_nodetree_socket(socket);
1715  }
1716 
1717  ID *id = bnode->id;
1718  if (id == nullptr) {
1719  continue;
1720  }
1721  ID_Type id_type = GS(id->name);
1722  if (id_type == ID_MA) {
1723  build_material((Material *)id);
1724  }
1725  else if (id_type == ID_TE) {
1726  build_texture((Tex *)id);
1727  }
1728  else if (id_type == ID_IM) {
1729  build_image((Image *)id);
1730  }
1731  else if (id_type == ID_OB) {
1732  /* TODO(sergey): Use visibility of owner of the node tree. */
1733  build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, true);
1734  }
1735  else if (id_type == ID_SCE) {
1736  Scene *node_scene = (Scene *)id;
1737  build_scene_parameters(node_scene);
1738  /* Camera is used by defocus node.
1739  *
1740  * On the one hand it's annoying to always pull it in, but on another hand it's also annoying
1741  * to have hardcoded node-type exception here. */
1742  if (node_scene->camera != nullptr) {
1743  /* TODO(sergey): Use visibility of owner of the node tree. */
1744  build_object(-1, node_scene->camera, DEG_ID_LINKED_INDIRECTLY, true);
1745  }
1746  }
1747  else if (id_type == ID_TXT) {
1748  /* Ignore script nodes. */
1749  }
1750  else if (id_type == ID_MSK) {
1751  build_mask((Mask *)id);
1752  }
1753  else if (id_type == ID_MC) {
1754  build_movieclip((MovieClip *)id);
1755  }
1756  else if (id_type == ID_VF) {
1757  build_vfont((VFont *)id);
1758  }
1759  else if (ELEM(bnode->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
1760  bNodeTree *group_ntree = (bNodeTree *)id;
1761  build_nodetree(group_ntree);
1762  }
1763  else {
1764  BLI_assert_msg(0, "Unknown ID type used for node");
1765  }
1766  }
1767 
1768  LISTBASE_FOREACH (bNodeSocket *, socket, &ntree->inputs) {
1769  build_idproperties(socket->prop);
1770  }
1771  LISTBASE_FOREACH (bNodeSocket *, socket, &ntree->outputs) {
1772  build_idproperties(socket->prop);
1773  }
1774 
1775  /* TODO: link from nodetree to owner_component? */
1776 }
1777 
1778 /* Recursively build graph for material */
1780 {
1782  return;
1783  }
1784  /* Material itself. */
1785  add_id_node(&material->id);
1786  Material *material_cow = get_cow_datablock(material);
1787  /* Shading update. */
1789  &material->id,
1792  [material_cow](::Depsgraph *depsgraph) { BKE_material_eval(depsgraph, material_cow); });
1794  /* Material animation. */
1797  /* Material's nodetree. */
1799 }
1800 
1802 {
1803  for (int i = 0; i < num_materials; i++) {
1804  if (materials[i] == nullptr) {
1805  continue;
1806  }
1808  }
1809 }
1810 
1811 /* Recursively build graph for texture */
1813 {
1814  if (built_map_.checkIsBuiltAndTag(texture)) {
1815  return;
1816  }
1817  /* Texture itself. */
1818  add_id_node(&texture->id);
1819  build_idproperties(texture->id.properties);
1820  build_animdata(&texture->id);
1821  build_parameters(&texture->id);
1822  /* Texture's nodetree. */
1823  build_nodetree(texture->nodetree);
1824  /* Special cases for different IDs which texture uses. */
1825  if (texture->type == TEX_IMAGE) {
1826  if (texture->ima != nullptr) {
1827  build_image(texture->ima);
1828  }
1829  }
1832 }
1833 
1835 {
1837  return;
1838  }
1839  build_parameters(&image->id);
1840  build_idproperties(image->id.properties);
1843 }
1844 
1846 {
1847  if (built_map_.checkIsBuiltAndTag(cache_file)) {
1848  return;
1849  }
1850  ID *cache_file_id = &cache_file->id;
1851  add_id_node(cache_file_id);
1852  CacheFile *cache_file_cow = get_cow_datablock(cache_file);
1853  build_idproperties(cache_file_id->properties);
1854  /* Animation, */
1855  build_animdata(cache_file_id);
1856  build_parameters(cache_file_id);
1857  /* Cache evaluation itself. */
1858  add_operation_node(cache_file_id,
1861  [bmain = bmain_, cache_file_cow](::Depsgraph *depsgraph) {
1862  BKE_cachefile_eval(bmain, depsgraph, cache_file_cow);
1863  });
1864 }
1865 
1867 {
1869  return;
1870  }
1871  ID *mask_id = &mask->id;
1872  Mask *mask_cow = (Mask *)ensure_cow_id(mask_id);
1873  build_idproperties(mask->id.properties);
1874  /* F-Curve based animation. */
1875  build_animdata(mask_id);
1876  build_parameters(mask_id);
1877  /* Animation based on mask's shapes. */
1879  mask_id,
1882  [mask_cow](::Depsgraph *depsgraph) { BKE_mask_eval_animation(depsgraph, mask_cow); });
1883  /* Final mask evaluation. */
1886  BKE_mask_eval_update(depsgraph, mask_cow);
1887  });
1888  /* Build parents. */
1889  LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
1890  LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
1891  for (int i = 0; i < spline->tot_point; i++) {
1892  MaskSplinePoint *point = &spline->points[i];
1893  MaskParent *parent = &point->parent;
1894  if (parent == nullptr || parent->id == nullptr) {
1895  continue;
1896  }
1897  build_id(parent->id);
1898  }
1899  }
1900  }
1901 }
1902 
1904 {
1906  return;
1907  }
1908 
1909  ID *linestyle_id = &linestyle->id;
1910  build_parameters(linestyle_id);
1912  build_animdata(linestyle_id);
1914 }
1915 
1917 {
1918  if (built_map_.checkIsBuiltAndTag(clip)) {
1919  return;
1920  }
1921  ID *clip_id = &clip->id;
1922  MovieClip *clip_cow = (MovieClip *)ensure_cow_id(clip_id);
1923  build_idproperties(clip_id->properties);
1924  /* Animation. */
1925  build_animdata(clip_id);
1926  build_parameters(clip_id);
1927  /* Movie clip evaluation. */
1928  add_operation_node(clip_id,
1931  [bmain = bmain_, clip_cow](::Depsgraph *depsgraph) {
1932  BKE_movieclip_eval_update(depsgraph, bmain, clip_cow);
1933  });
1934 
1935  add_operation_node(clip_id,
1938  [clip_cow](::Depsgraph *depsgraph) {
1940  });
1941 }
1942 
1944 {
1945  if (built_map_.checkIsBuiltAndTag(probe)) {
1946  return;
1947  }
1948  /* Placeholder so we can add relations and tag ID node for update. */
1951  build_animdata(&probe->id);
1952  build_parameters(&probe->id);
1953 }
1954 
1956 {
1957  if (built_map_.checkIsBuiltAndTag(speaker)) {
1958  return;
1959  }
1960  /* Placeholder so we can add relations and tag ID node for update. */
1962  build_idproperties(speaker->id.properties);
1963  build_animdata(&speaker->id);
1964  build_parameters(&speaker->id);
1965  if (speaker->sound != nullptr) {
1966  build_sound(speaker->sound);
1967  }
1968 }
1969 
1971 {
1972  if (built_map_.checkIsBuiltAndTag(sound)) {
1973  return;
1974  }
1975  add_id_node(&sound->id);
1976  bSound *sound_cow = get_cow_datablock(sound);
1977  add_operation_node(&sound->id,
1980  [bmain = bmain_, sound_cow](::Depsgraph *depsgraph) {
1981  BKE_sound_evaluate(depsgraph, bmain, sound_cow);
1982  });
1984  build_animdata(&sound->id);
1985  build_parameters(&sound->id);
1986 }
1987 
1989 {
1991  return;
1992  }
1998 
1999  Simulation *simulation_cow = get_cow_datablock(simulation);
2000  Scene *scene_cow = get_cow_datablock(scene_);
2001 
2005  [scene_cow, simulation_cow](::Depsgraph *depsgraph) {
2006  BKE_simulation_data_update(depsgraph, scene_cow, simulation_cow);
2007  });
2008 }
2009 
2011 {
2012  if (built_map_.checkIsBuiltAndTag(vfont)) {
2013  return;
2014  }
2015  build_parameters(&vfont->id);
2019 }
2020 
2021 static bool seq_node_build_cb(Sequence *seq, void *user_data)
2022 {
2024  nb->build_idproperties(seq->prop);
2025  if (seq->sound != nullptr) {
2026  nb->build_sound(seq->sound);
2027  }
2028  if (seq->scene != nullptr) {
2029  nb->build_scene_parameters(seq->scene);
2030  }
2031  if (seq->type == SEQ_TYPE_SCENE && seq->scene != nullptr) {
2032  if (seq->flag & SEQ_SCENE_STRIPS) {
2033  nb->build_scene_sequencer(seq->scene);
2034  }
2035  ViewLayer *sequence_view_layer = BKE_view_layer_default_render(seq->scene);
2036  nb->build_scene_speakers(seq->scene, sequence_view_layer);
2037  }
2038  /* TODO(sergey): Movie clip, scene, camera, mask. */
2039  return true;
2040 }
2041 
2043 {
2044  if (scene->ed == nullptr) {
2045  return;
2046  }
2048  return;
2049  }
2051  Scene *scene_cow = get_cow_datablock(scene);
2055  [scene_cow](::Depsgraph *depsgraph) {
2056  SEQ_eval_sequences(depsgraph, scene_cow, &scene_cow->ed->seqbase);
2057  });
2058  /* Make sure data for sequences is in the graph. */
2060 }
2061 
2063 {
2065  return;
2066  }
2067 
2068  OperationNode *audio_entry_node = add_operation_node(
2070  audio_entry_node->set_as_entry();
2071 
2073 
2074  Scene *scene_cow = get_cow_datablock(scene);
2078  [scene_cow](::Depsgraph *depsgraph) {
2079  BKE_scene_update_tag_audio_volume(depsgraph, scene_cow);
2080  });
2081 }
2082 
2084 {
2085  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
2086  Object *object = base->object;
2087  if (object->type != OB_SPEAKER || !need_pull_base_into_graph(base)) {
2088  continue;
2089  }
2090  /* NOTE: Can not use base because it does not belong to a current view layer. */
2091  build_object(-1, base->object, DEG_ID_LINKED_INDIRECTLY, true);
2092  }
2093 }
2094 
2095 /* **** ID traversal callbacks functions **** */
2096 
2098  struct Object * /*object*/,
2099  struct ID **idpoin,
2100  int /*cb_flag*/)
2101 {
2103  ID *id = *idpoin;
2104  if (id == nullptr) {
2105  return;
2106  }
2107  switch (GS(id->name)) {
2108  case ID_OB:
2109  data->builder->build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, false);
2110  break;
2111  default:
2112  data->builder->build_id(id);
2113  break;
2114  }
2115 }
2116 
2118  ID **idpoin,
2119  bool /*is_reference*/,
2120  void *user_data)
2121 {
2123  ID *id = *idpoin;
2124  if (id == nullptr) {
2125  return;
2126  }
2127  switch (GS(id->name)) {
2128  case ID_OB:
2129  data->builder->build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY, false);
2130  break;
2131  default:
2132  data->builder->build_id(id);
2133  break;
2134  }
2135 }
2136 
2137 } // namespace blender::deg
Blender kernel action and pose functionality.
struct AnimData * BKE_animdata_from_id(const struct ID *id)
void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id)
Definition: anim_sys.c:4136
void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, int driver_index, struct FCurve *fcu_orig)
Definition: anim_sys.c:4170
void BKE_cachefile_eval(struct Main *bmain, struct Depsgraph *depsgraph, struct CacheFile *cache_file)
Definition: cachefile.c:342
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata)
Definition: constraint.c:5877
void BKE_curve_eval_geometry(struct Depsgraph *depsgraph, struct Curve *curve)
Definition: curve.cc:5506
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
void BKE_gpencil_frame_active_set(struct Depsgraph *depsgraph, struct bGPdata *gpd)
void void BKE_gpencil_modifiers_foreach_ID_link(struct Object *ob, GreasePencilIDWalkFunc walk, void *userData)
void IDP_foreach_property(struct IDProperty *id_property_root, int type_filter, IDPForeachPropertyCallback callback, void *user_data)
Definition: idprop.c:1117
void BKE_image_user_id_eval_animation(struct Depsgraph *depsgraph, struct ID *id)
bool BKE_image_user_id_has_animation(struct ID *id)
struct Key * BKE_key_from_id(struct ID *id)
Definition: key.c:1783
void BKE_lattice_eval_geometry(struct Depsgraph *depsgraph, struct Lattice *latt)
struct ViewLayer * BKE_view_layer_default_render(const struct Scene *scene)
void BKE_id_eval_properties_copy(struct ID *id_cow, struct ID *id)
Definition: lib_id_eval.c:18
#define MAIN_ID_SESSION_UUID_UNSET
Definition: BKE_lib_id.h:82
void BKE_library_foreach_ID_link(struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
Definition: lib_query.c:350
@ IDWALK_READONLY
@ IDWALK_IGNORE_EMBEDDED_ID
@ IDWALK_RET_STOP_ITER
Definition: BKE_lib_query.h:85
@ IDWALK_RET_NOP
Definition: BKE_lib_query.h:83
General operations, lookup, etc. for blender lights.
void BKE_mask_eval_update(struct Depsgraph *depsgraph, struct Mask *mask)
void BKE_mask_eval_animation(struct Depsgraph *depsgraph, struct Mask *mask)
General operations, lookup, etc. for materials.
struct Material *** BKE_object_material_array_p(struct Object *ob)
Definition: material.c:311
short * BKE_object_material_len_p(struct Object *ob)
Definition: material.c:344
void BKE_mesh_eval_geometry(struct Depsgraph *depsgraph, struct Mesh *mesh)
Definition: mesh.cc:2199
void BKE_modifiers_foreach_ID_link(struct Object *ob, IDWalkFunc walk, void *userData)
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, struct Main *bmain, struct MovieClip *clip)
Definition: movieclip.c:2017
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, struct MovieClip *clip)
Definition: movieclip.c:2028
#define NODE_CUSTOM_GROUP
Definition: BKE_node.h:989
struct bNodeTree ** BKE_ntree_ptr_from_id(struct ID *id)
Definition: node.cc:3209
General operations, lookup, etc. for blender objects.
void BKE_object_data_select_update(struct Depsgraph *depsgraph, struct ID *object_data)
void BKE_particle_system_eval_init(struct Depsgraph *depsgraph, struct Object *object)
bool BKE_ptcache_object_has(struct Scene *scene, struct Object *ob, int duplis)
Definition: pointcache.c:1263
API for Blender-side Rigid Body stuff.
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData)
Definition: shader_fx.c:246
Volume data-block.
void BKE_volume_eval_geometry(struct Depsgraph *depsgraph, struct Volume *volume)
Definition: volume.cc:1120
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
#define ELEM(...)
@ DAG_EVAL_VIEWPORT
Definition: DEG_depsgraph.h:45
@ IDP_TYPE_FILTER_ID
Definition: DNA_ID.h:155
@ IDP_ID
Definition: DNA_ID.h:142
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
#define ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type)
Definition: DNA_ID.h:606
@ LIB_TAG_COPIED_ON_WRITE
Definition: DNA_ID.h:720
@ LIB_EMBEDDED_DATA
Definition: DNA_ID.h:635
ID_Type
Definition: DNA_ID_enums.h:44
@ ID_WM
Definition: DNA_ID_enums.h:72
@ ID_CA
Definition: DNA_ID_enums.h:56
@ ID_AR
Definition: DNA_ID_enums.h:66
@ ID_MC
Definition: DNA_ID_enums.h:73
@ ID_CF
Definition: DNA_ID_enums.h:78
@ ID_LI
Definition: DNA_ID_enums.h:46
@ ID_TE
Definition: DNA_ID_enums.h:52
@ ID_IM
Definition: DNA_ID_enums.h:53
@ ID_VO
Definition: DNA_ID_enums.h:83
@ ID_WS
Definition: DNA_ID_enums.h:79
@ ID_NT
Definition: DNA_ID_enums.h:68
@ ID_LA
Definition: DNA_ID_enums.h:55
@ ID_KE
Definition: DNA_ID_enums.h:58
@ ID_TXT
Definition: DNA_ID_enums.h:62
@ ID_SO
Definition: DNA_ID_enums.h:64
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ ID_LS
Definition: DNA_ID_enums.h:75
@ ID_MSK
Definition: DNA_ID_enums.h:74
@ ID_GD
Definition: DNA_ID_enums.h:71
@ ID_CV
Definition: DNA_ID_enums.h:81
@ ID_PAL
Definition: DNA_ID_enums.h:76
@ ID_BR
Definition: DNA_ID_enums.h:69
@ ID_LP
Definition: DNA_ID_enums.h:80
@ ID_WO
Definition: DNA_ID_enums.h:59
@ ID_SIM
Definition: DNA_ID_enums.h:84
@ ID_MA
Definition: DNA_ID_enums.h:51
@ ID_AC
Definition: DNA_ID_enums.h:67
@ ID_SCR
Definition: DNA_ID_enums.h:60
@ ID_CU_LEGACY
Definition: DNA_ID_enums.h:49
@ ID_VF
Definition: DNA_ID_enums.h:61
@ ID_ME
Definition: DNA_ID_enums.h:48
@ ID_IP
Definition: DNA_ID_enums.h:57
@ ID_GR
Definition: DNA_ID_enums.h:65
@ ID_SPK
Definition: DNA_ID_enums.h:63
@ ID_MB
Definition: DNA_ID_enums.h:50
@ ID_LT
Definition: DNA_ID_enums.h:54
@ ID_OB
Definition: DNA_ID_enums.h:47
@ ID_PA
Definition: DNA_ID_enums.h:70
@ ID_PT
Definition: DNA_ID_enums.h:82
@ ID_PC
Definition: DNA_ID_enums.h:77
Object groups, one object can be in many groups at once.
@ COLLECTION_HIDE_RENDER
@ COLLECTION_HIDE_VIEWPORT
@ NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION
@ SOCK_TEXTURE
@ SOCK_MATERIAL
@ SOCK_IMAGE
@ SOCK_COLLECTION
@ SOCK_OBJECT
@ PFIELD_TEXTURE
Object is a sort of wrapper for general info.
@ OB_SPEAKER
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_CAMERA
@ OB_FONT
@ OB_ARMATURE
@ OB_LAMP
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES_LEGACY
@ OB_CURVES
@ OB_GPENCIL
@ OB_LIGHTPROBE
#define PART_PHYS_KEYED
#define PART_DRAW_OB
#define PART_PHYS_BOIDS
#define PART_DRAW_GR
Types and defines for representing Rigid Body entities.
@ RBO_TYPE_PASSIVE
@ SEQ_TYPE_SCENE
@ SEQ_SCENE_STRIPS
Read Guarded memory(de)allocation.
NODE_GROUP
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block TEX_IMAGE
void append(const T &value)
Definition: BLI_vector.hh:433
bool checkIsBuiltAndTag(ID *id, int tag=TAG_COMPLETE)
bool checkIsBuilt(ID *id, int tag=TAG_COMPLETE) const
virtual bool need_pull_base_into_graph(const Base *base)
Definition: deg_builder.cc:67
virtual void build_scene_parameters(Scene *scene)
virtual void build_scene_sequencer(Scene *scene)
virtual void build_object_data_camera(Object *object)
virtual void build_object_data_geometry(Object *object)
virtual void build_object_pointcache(Object *object)
static void modifier_walk(void *user_data, struct Object *object, struct ID **idpoin, int cb_flag)
virtual void build_world(World *world)
virtual void build_object(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state, bool is_visible)
OperationNode * ensure_operation_node(ID *id, NodeType comp_type, const char *comp_name, OperationCode opcode, const DepsEvalOperationCb &op=nullptr, const char *name="", int name_tag=-1)
virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle)
virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer)
virtual void build_cachefile(CacheFile *cache_file)
virtual void build_object_instance_collection(Object *object, bool is_object_visible)
virtual void build_object_data_speaker(Object *object)
OperationNode * add_operation_node(ComponentNode *comp_node, OperationCode opcode, const DepsEvalOperationCb &op=nullptr, const char *name="", int name_tag=-1)
virtual void build_vfont(VFont *vfont)
virtual void build_object_data(Object *object)
virtual void build_particle_settings(ParticleSettings *part)
static void constraint_walk(bConstraint *constraint, ID **idpoin, bool is_reference, void *user_data)
virtual void build_particle_systems(Object *object, bool is_object_visible)
virtual void build_dimensions(Object *object)
virtual void build_armature(bArmature *armature)
virtual void build_scene_audio(Scene *scene)
virtual void build_simulation(Simulation *simulation)
ComponentNode * add_component_node(ID *id, NodeType comp_type, const char *comp_name="")
virtual void build_driver_variables(ID *id, FCurve *fcurve)
virtual void build_action(bAction *action)
virtual void build_animdata_nlastrip_targets(ListBase *strips)
virtual void build_material(Material *ma)
virtual void build_materials(Material **materials, int num_materials)
virtual void build_collection(LayerCollection *from_layer_collection, Collection *collection)
virtual void build_rigidbody(Scene *scene)
virtual void build_object_transform(Object *object)
OperationNode * find_operation_node(ID *id, NodeType comp_type, const char *comp_name, OperationCode opcode, const char *name="", int name_tag=-1)
virtual void build_movieclip(MovieClip *clip)
Vector< SavedEntryTag > saved_entry_tags_
virtual void build_object_data_light(Object *object)
virtual void build_image(Image *image)
virtual void build_speaker(Speaker *speaker)
virtual void build_sound(bSound *sound)
virtual void build_object_data_geometry_datablock(ID *obdata)
DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
virtual void build_object_flags(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state)
ID * get_cow_id(const ID *id_orig) const
virtual void build_rig(Object *object)
virtual void build_driver_id_property(ID *id, const char *rna_path)
virtual void build_lightprobe(LightProbe *probe)
int foreach_id_cow_detect_need_for_update_callback(ID *id_cow_self, ID *id_pointer)
virtual void build_nodetree(bNodeTree *ntree)
virtual void build_idproperties(IDProperty *id_property)
virtual void build_camera(Camera *camera)
virtual void build_light(Light *lamp)
virtual void build_armature_bones(ListBase *bones)
virtual void build_driver(ID *id, FCurve *fcurve, int driver_index)
bool has_operation_node(ID *id, NodeType comp_type, const char *comp_name, OperationCode opcode, const char *name="", int name_tag=-1)
virtual void build_nodetree_socket(bNodeSocket *socket)
virtual void build_object_data_lightprobe(Object *object)
virtual void build_object_constraints(Object *object)
T * get_cow_datablock(const T *orig) const
virtual void build_object_from_layer(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state)
Depsgraph * graph
const IDNode * id_node
Scene scene
FreestyleLineStyle linestyle
World world
Material material
Simulation simulation
Light lamp
const Depsgraph * depsgraph
void * user_data
SyclQueue void void size_t num_bytes void
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
bNodeTree * ntree
smooth(Type::VEC4, "color_mul") .smooth(Type gpFillTexture gpSceneDepthTexture materials[GPENCIL_MATERIAL_BUFFER_LEN]
Definition: gpencil_info.hh:29
#define GS(x)
Definition: iris.c:225
void SEQ_for_each_callback(ListBase *seqbase, SeqForEachFunc callback, void *user_data)
Definition: iterator.c:76
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static bool seq_node_build_cb(Sequence *seq, void *user_data)
bool rna_prop_affects_parameters_node(const PointerRNA *ptr, const PropertyRNA *prop)
void deg_evaluate_object_node_visibility(::Depsgraph *depsgraph, IDNode *id_node)
static void build_idproperties_callback(IDProperty *id_property, void *user_data)
bool deg_copy_on_write_is_needed(const ID *id_orig)
uint64_t IDComponentsMask
Definition: deg_node_id.h:17
eDepsNode_LinkedState_Type
Definition: deg_node_id.h:23
@ DEG_ID_LINKED_INDIRECTLY
Definition: deg_node_id.h:25
@ DEG_ID_LINKED_VIA_SET
Definition: deg_node_id.h:27
bool deg_copy_on_write_is_expanded(const ID *id_cow)
void deg_evaluate_copy_on_write(struct ::Depsgraph *graph, const IDNode *id_node)
void graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source)
static int foreach_id_cow_detect_need_for_update_callback(LibraryIDLinkCallbackData *cb_data)
void deg_free_copy_on_write_datablock(ID *id_cow)
function< void(struct ::Depsgraph *)> DepsEvalOperationCb
@ DEG_UPDATE_SOURCE_USER_EDIT
@ DEG_UPDATE_SOURCE_RELATIONS
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:695
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:112
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1000
bool RNA_path_resolve_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
Definition: rna_path.cc:515
unsigned int uint32_t
Definition: stdint.h:80
bAction * action
ListBase drivers
ListBase nla_tracks
ListBase variables
struct Object * bevobj
struct Object * textoncurve
struct Object * taperobj
struct Object * surface
ListBase seqbase
char * rna_path
ChannelDriver * driver
int array_index
struct bNodeTree * nodetree
void * pointer
Definition: DNA_ID.h:100
IDPropertyData data
Definition: DNA_ID.h:117
char type
Definition: DNA_ID.h:108
Definition: DNA_ID.h:368
int tag
Definition: DNA_ID.h:387
IDProperty * properties
Definition: DNA_ID.h:409
struct ID * orig_id
Definition: DNA_ID.h:419
unsigned int session_uuid
Definition: DNA_ID.h:407
char name[66]
Definition: DNA_ID.h:378
ID id
Definition: DNA_key_types.h:63
ListBase block
Definition: DNA_key_types.h:84
struct bNodeTree * nodetree
void * first
Definition: DNA_listBase.h:31
struct Tex * tex
Definition: BKE_main.h:121
struct bNodeTree * nodetree
ListBase particlesystem
ListBase constraints
struct Collection * instance_collection
ListBase modifiers
ListBase greasepencil_modifiers
struct Material ** mat
struct PartDeflect * pd
ListBase shader_fx
struct Object * parent
void * data
struct Collection * instance_collection
struct MTex * mtex[18]
struct Object * instance_object
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
struct Object * ob1
struct Object * ob2
struct Collection * constraints
struct Collection * group
struct RigidBodyWorld * rigidbody_world
struct Editing * ed
struct Object * camera
struct Scene * scene
struct bSound * sound
struct IDProperty * prop
struct bNodeTree * nodetree
struct bSound * sound
short type
struct bNodeTree * nodetree
struct Image * ima
ListBase object_bases
struct bNodeTree * nodetree
ListBase bonebase
IDProperty * prop
void * default_value
bNodeTreeRuntimeHandle * runtime
ListBase nodes
ListBase inputs
ListBase outputs
OperationNode * find_operation(OperationIDKey key) const
OperationNode * add_operation(const DepsEvalOperationCb &op, OperationCode opcode, const char *name="", int name_tag=-1)
virtual string identifier() const override
ID * get_cow_id(const ID *id_orig) const
Definition: depsgraph.cc:236
IDNode * find_id_node(const ID *id) const
Definition: depsgraph.cc:101
IDNode * add_id_node(ID *id, ID *id_cow_hint=nullptr)
Definition: depsgraph.cc:106
OperationNodes operations
Definition: depsgraph.h:120
eEvaluationMode mode
Definition: depsgraph.h:130
TimeSourceNode * add_time_source()
Definition: depsgraph.cc:82
Set< OperationNode * > entry_tags
Definition: depsgraph.h:114
IDDepsNodes id_nodes
Definition: depsgraph.h:86
virtual void tag_update(Depsgraph *graph, eUpdateSource source) override
virtual string identifier() const override
float max
PointerRNA * ptr
Definition: wm_files.c:3480