Blender  V3.3
depsgraph_tag.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 
10 #include "intern/depsgraph_tag.h"
11 
12 #include <cstdio>
13 #include <cstring> /* required for memset */
14 #include <queue>
15 
16 #include "BLI_math_bits.h"
17 #include "BLI_task.h"
18 #include "BLI_utildefines.h"
19 
20 #include "DNA_anim_types.h"
21 #include "DNA_curve_types.h"
22 #include "DNA_key_types.h"
23 #include "DNA_lattice_types.h"
24 #include "DNA_mesh_types.h"
25 #include "DNA_object_types.h"
26 #include "DNA_particle_types.h"
27 #include "DNA_screen_types.h"
29 
30 #include "BKE_anim_data.h"
31 #include "BKE_global.h"
32 #include "BKE_idtype.h"
33 #include "BKE_node.h"
34 #include "BKE_scene.h"
35 #include "BKE_screen.h"
36 #include "BKE_workspace.h"
37 
38 #include "DEG_depsgraph.h"
39 #include "DEG_depsgraph_debug.h"
40 #include "DEG_depsgraph_query.h"
41 
43 #include "intern/depsgraph.h"
48 #include "intern/node/deg_node.h"
54 
55 namespace deg = blender::deg;
56 
57 /* *********************** */
58 /* Update Tagging/Flushing */
59 
60 namespace blender::deg {
61 
62 namespace {
63 
64 void depsgraph_geometry_tag_to_component(const ID *id, NodeType *component_type)
65 {
67  if (result != NodeType::UNDEFINED) {
68  *component_type = result;
69  }
70 }
71 
72 bool is_selectable_data_id_type(const ID_Type id_type)
73 {
74  return ELEM(id_type, ID_ME, ID_CU_LEGACY, ID_MB, ID_LT, ID_GD, ID_CV, ID_PT, ID_VO);
75 }
76 
77 void depsgraph_select_tag_to_component_opcode(const ID *id,
78  NodeType *component_type,
79  OperationCode *operation_code)
80 {
81  const ID_Type id_type = GS(id->name);
82  if (id_type == ID_SCE) {
83  /* We need to flush base flags to all objects in a scene since we
84  * don't know which ones changed. However, we don't want to update
85  * the whole scene, so pick up some operation which will do as less
86  * as possible.
87  *
88  * TODO(sergey): We can introduce explicit exit operation which
89  * does nothing and which is only used to cascade flush down the
90  * road. */
91  *component_type = NodeType::LAYER_COLLECTIONS;
92  *operation_code = OperationCode::VIEW_LAYER_EVAL;
93  }
94  else if (id_type == ID_OB) {
95  *component_type = NodeType::OBJECT_FROM_LAYER;
97  }
98  else if (id_type == ID_MC) {
99  *component_type = NodeType::BATCH_CACHE;
100  *operation_code = OperationCode::MOVIECLIP_SELECT_UPDATE;
101  }
102  else if (is_selectable_data_id_type(id_type)) {
103  *component_type = NodeType::BATCH_CACHE;
104  *operation_code = OperationCode::GEOMETRY_SELECT_UPDATE;
105  }
106  else {
107  *component_type = NodeType::COPY_ON_WRITE;
108  *operation_code = OperationCode::COPY_ON_WRITE;
109  }
110 }
111 
112 void depsgraph_base_flags_tag_to_component_opcode(const ID *id,
113  NodeType *component_type,
114  OperationCode *operation_code)
115 {
116  const ID_Type id_type = GS(id->name);
117  if (id_type == ID_SCE) {
118  *component_type = NodeType::LAYER_COLLECTIONS;
119  *operation_code = OperationCode::VIEW_LAYER_EVAL;
120  }
121  else if (id_type == ID_OB) {
122  *component_type = NodeType::OBJECT_FROM_LAYER;
123  *operation_code = OperationCode::OBJECT_BASE_FLAGS;
124  }
125 }
126 
127 OperationCode psysTagToOperationCode(IDRecalcFlag tag)
128 {
129  if (tag == ID_RECALC_PSYS_RESET) {
131  }
133 }
134 
135 void depsgraph_tag_to_component_opcode(const ID *id,
136  IDRecalcFlag tag,
137  NodeType *component_type,
138  OperationCode *operation_code)
139 {
140  const ID_Type id_type = GS(id->name);
141  *component_type = NodeType::UNDEFINED;
142  *operation_code = OperationCode::OPERATION;
143  /* Special case for now, in the future we should get rid of this. */
144  if (tag == 0) {
145  *component_type = NodeType::ID_REF;
146  *operation_code = OperationCode::OPERATION;
147  return;
148  }
149  switch (tag) {
150  case ID_RECALC_TRANSFORM:
151  *component_type = NodeType::TRANSFORM;
152  break;
153  case ID_RECALC_GEOMETRY:
154  depsgraph_geometry_tag_to_component(id, component_type);
155  break;
156  case ID_RECALC_ANIMATION:
157  *component_type = NodeType::ANIMATION;
158  break;
159  case ID_RECALC_PSYS_REDO:
162  case ID_RECALC_PSYS_PHYS:
163  if (id_type == ID_PA) {
164  /* NOTES:
165  * - For particle settings node we need to use different
166  * component. Will be nice to get this unified with object,
167  * but we can survive for now with single exception here.
168  * Particles needs reconsideration anyway, */
169  *component_type = NodeType::PARTICLE_SETTINGS;
170  *operation_code = psysTagToOperationCode(tag);
171  }
172  else {
173  *component_type = NodeType::PARTICLE_SYSTEM;
174  }
175  break;
177  *component_type = NodeType::COPY_ON_WRITE;
178  break;
179  case ID_RECALC_SHADING:
180  *component_type = NodeType::SHADING;
181  break;
182  case ID_RECALC_SELECT:
183  depsgraph_select_tag_to_component_opcode(id, component_type, operation_code);
184  break;
186  depsgraph_base_flags_tag_to_component_opcode(id, component_type, operation_code);
187  break;
189  *component_type = NodeType::POINT_CACHE;
190  break;
191  case ID_RECALC_EDITORS:
192  /* There is no such node in depsgraph, this tag is to be handled
193  * separately. */
194  break;
196  *component_type = NodeType::SEQUENCER;
197  break;
199  case ID_RECALC_AUDIO_FPS:
203  case ID_RECALC_AUDIO:
204  *component_type = NodeType::AUDIO;
205  break;
207  *component_type = NodeType::PARAMETERS;
208  break;
209  case ID_RECALC_SOURCE:
210  *component_type = NodeType::PARAMETERS;
211  break;
213  case ID_RECALC_ALL:
214  case ID_RECALC_PSYS_ALL:
215  BLI_assert_msg(0, "Should not happen");
216  break;
218  break; /* Must be ignored by depsgraph. */
220  *component_type = NodeType::NTREE_OUTPUT;
221  *operation_code = OperationCode::NTREE_OUTPUT;
222  break;
223  }
224 }
225 
226 void id_tag_update_ntree_special(
227  Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source)
228 {
229  bNodeTree *ntree = ntreeFromID(id);
230  if (ntree == nullptr) {
231  return;
232  }
233  graph_id_tag_update(bmain, graph, &ntree->id, flag, update_source);
234 }
235 
236 void depsgraph_update_editors_tag(Main *bmain, Depsgraph *graph, ID *id)
237 {
238  /* NOTE: We handle this immediately, without delaying anything, to be
239  * sure we don't cause threading issues with OpenGL. */
240  /* TODO(sergey): Make sure this works for CoW-ed data-blocks as well. */
241  DEGEditorUpdateContext update_ctx = {nullptr};
242  update_ctx.bmain = bmain;
243  update_ctx.depsgraph = (::Depsgraph *)graph;
244  update_ctx.scene = graph->scene;
245  update_ctx.view_layer = graph->view_layer;
246  deg_editors_id_update(&update_ctx, id);
247 }
248 
249 void depsgraph_id_tag_copy_on_write(Depsgraph *graph, IDNode *id_node, eUpdateSource update_source)
250 {
251  ComponentNode *cow_comp = id_node->find_component(NodeType::COPY_ON_WRITE);
252  if (cow_comp == nullptr) {
254  return;
255  }
256  cow_comp->tag_update(graph, update_source);
257 }
258 
259 void depsgraph_tag_component(Depsgraph *graph,
260  IDNode *id_node,
261  NodeType component_type,
262  OperationCode operation_code,
263  eUpdateSource update_source)
264 {
265  ComponentNode *component_node = id_node->find_component(component_type);
266  /* NOTE: Animation component might not be existing yet (which happens when adding new driver or
267  * adding a new keyframe), so the required copy-on-write tag needs to be taken care explicitly
268  * here. */
269  if (component_node == nullptr) {
270  if (component_type == NodeType::ANIMATION) {
272  depsgraph_id_tag_copy_on_write(graph, id_node, update_source);
273  }
274  return;
275  }
276  if (operation_code == OperationCode::OPERATION) {
277  component_node->tag_update(graph, update_source);
278  }
279  else {
280  OperationNode *operation_node = component_node->find_operation(operation_code);
281  if (operation_node != nullptr) {
282  operation_node->tag_update(graph, update_source);
283  }
284  }
285  /* If component depends on copy-on-write, tag it as well. */
286  if (component_node->need_tag_cow_before_update()) {
287  depsgraph_id_tag_copy_on_write(graph, id_node, update_source);
288  }
289  if (component_type == NodeType::COPY_ON_WRITE) {
291  }
292 }
293 
294 /* This is a tag compatibility with legacy code.
295  *
296  * Mainly, old code was tagging object with ID_RECALC_GEOMETRY tag to inform
297  * that object's data data-block changed. Now API expects that ID is given
298  * explicitly, but not all areas are aware of this yet. */
299 void deg_graph_id_tag_legacy_compat(
300  Main *bmain, Depsgraph *depsgraph, ID *id, IDRecalcFlag tag, eUpdateSource update_source)
301 {
302  if (ELEM(tag, ID_RECALC_GEOMETRY, 0)) {
303  switch (GS(id->name)) {
304  case ID_OB: {
305  Object *object = (Object *)id;
306  ID *data_id = (ID *)object->data;
307  if (data_id != nullptr) {
308  graph_id_tag_update(bmain, depsgraph, data_id, 0, update_source);
309  }
310  break;
311  }
312  /* TODO(sergey): Shape keys are annoying, maybe we should find a
313  * way to chain geometry evaluation to them, so we don't need extra
314  * tagging here. */
315  case ID_ME: {
316  Mesh *mesh = (Mesh *)id;
317  if (mesh->key != nullptr) {
318  ID *key_id = &mesh->key->id;
319  if (key_id != nullptr) {
320  graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source);
321  }
322  }
323  break;
324  }
325  case ID_LT: {
326  Lattice *lattice = (Lattice *)id;
327  if (lattice->key != nullptr) {
328  ID *key_id = &lattice->key->id;
329  if (key_id != nullptr) {
330  graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source);
331  }
332  }
333  break;
334  }
335  case ID_CU_LEGACY: {
336  Curve *curve = (Curve *)id;
337  if (curve->key != nullptr) {
338  ID *key_id = &curve->key->id;
339  if (key_id != nullptr) {
340  graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source);
341  }
342  }
343  break;
344  }
345  default:
346  break;
347  }
348  }
349 }
350 
351 void graph_id_tag_update_single_flag(Main *bmain,
352  Depsgraph *graph,
353  ID *id,
354  IDNode *id_node,
355  IDRecalcFlag tag,
356  eUpdateSource update_source)
357 {
358  if (tag == ID_RECALC_EDITORS) {
359  if (graph != nullptr && graph->is_active) {
360  depsgraph_update_editors_tag(bmain, graph, id);
361  }
362  return;
363  }
364  /* Get description of what is to be tagged. */
365  NodeType component_type;
366  OperationCode operation_code;
367  depsgraph_tag_to_component_opcode(id, tag, &component_type, &operation_code);
368  /* Check whether we've got something to tag. */
369  if (component_type == NodeType::UNDEFINED) {
370  /* Given ID does not support tag. */
371  /* TODO(sergey): Shall we raise some panic here? */
372  return;
373  }
374  /* Some sanity checks before moving forward. */
375  if (id_node == nullptr) {
376  /* Happens when object is tagged for update and not yet in the
377  * dependency graph (but will be after relations update). */
378  return;
379  }
380  /* Tag ID recalc flag. */
381  DepsNodeFactory *factory = type_get_factory(component_type);
382  BLI_assert(factory != nullptr);
383  id_node->id_cow->recalc |= factory->id_recalc_tag();
384  /* Tag corresponding dependency graph operation for update. */
385  if (component_type == NodeType::ID_REF) {
386  id_node->tag_update(graph, update_source);
387  }
388  else {
389  depsgraph_tag_component(graph, id_node, component_type, operation_code, update_source);
390  }
391  /* TODO(sergey): Get rid of this once all areas are using proper data ID
392  * for tagging. */
393  deg_graph_id_tag_legacy_compat(bmain, graph, id, tag, update_source);
394 }
395 
396 string stringify_append_bit(const string &str, IDRecalcFlag tag)
397 {
398  const char *tag_name = DEG_update_tag_as_string(tag);
399  if (tag_name == nullptr) {
400  return str;
401  }
402  string result = str;
403  if (!result.empty()) {
404  result += ", ";
405  }
406  result += tag_name;
407  return result;
408 }
409 
410 string stringify_update_bitfield(int flag)
411 {
412  if (flag == 0) {
413  return "LEGACY_0";
414  }
415  string result;
416  int current_flag = flag;
417  /* Special cases to avoid ALL flags form being split into
418  * individual bits. */
419  if ((current_flag & ID_RECALC_PSYS_ALL) == ID_RECALC_PSYS_ALL) {
420  result = stringify_append_bit(result, ID_RECALC_PSYS_ALL);
421  }
422  /* Handle all the rest of the flags. */
423  while (current_flag != 0) {
424  IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(&current_flag));
425  result = stringify_append_bit(result, tag);
426  }
427  return result;
428 }
429 
430 const char *update_source_as_string(eUpdateSource source)
431 {
432  switch (source) {
434  return "TIME";
436  return "USER_EDIT";
438  return "RELATIONS";
440  return "VISIBILITY";
441  }
442  BLI_assert_msg(0, "Should never happen.");
443  return "UNKNOWN";
444 }
445 
446 int deg_recalc_flags_for_legacy_zero()
447 {
450 }
451 
452 int deg_recalc_flags_effective(Depsgraph *graph, int flags)
453 {
454  if (graph != nullptr) {
455  if (!graph->is_active) {
456  return 0;
457  }
458  }
459  if (flags == 0) {
460  return deg_recalc_flags_for_legacy_zero();
461  }
462  return flags;
463 }
464 
465 /* Special tag function which tags all components which needs to be tagged
466  * for update flag=0.
467  *
468  * TODO(sergey): This is something to be avoid in the future, make it more
469  * explicit and granular for users to tag what they really need. */
470 void deg_graph_node_tag_zero(Main *bmain,
471  Depsgraph *graph,
472  IDNode *id_node,
473  eUpdateSource update_source)
474 {
475  if (id_node == nullptr) {
476  return;
477  }
478  ID *id = id_node->id_orig;
479  /* TODO(sergey): Which recalc flags to set here? */
480  id_node->id_cow->recalc |= deg_recalc_flags_for_legacy_zero();
481 
482  for (ComponentNode *comp_node : id_node->components.values()) {
483  if (comp_node->type == NodeType::ANIMATION) {
484  continue;
485  }
486  if (comp_node->type == NodeType::COPY_ON_WRITE) {
488  }
489 
490  comp_node->tag_update(graph, update_source);
491  }
492  deg_graph_id_tag_legacy_compat(bmain, graph, id, (IDRecalcFlag)0, update_source);
493 }
494 
495 void graph_tag_on_visible_update(Depsgraph *graph, const bool do_time)
496 {
499 }
500 
501 } /* namespace */
502 
504 {
506  return;
507  }
508 
510  Main *bmain = graph->bmain;
511 
512  /* NOTE: It is possible to have this function called with `do_time=false` first and later (prior
513  * to evaluation though) with `do_time=true`. This means early output checks should be aware of
514  * this. */
515  for (deg::IDNode *id_node : graph->id_nodes) {
516  const ID_Type id_type = GS(id_node->id_orig->name);
517 
519  /* ID has no components which affects anything visible.
520  * No need bother with it to tag or anything. */
521  continue;
522  }
523  int flag = 0;
525  flag |= ID_RECALC_COPY_ON_WRITE;
526  if (do_time) {
527  if (BKE_animdata_from_id(id_node->id_orig) != nullptr) {
528  flag |= ID_RECALC_ANIMATION;
529  }
530  }
531  }
532  else {
534  /* The ID was already visible and evaluated, all the subsequent
535  * updates and tags are to be done explicitly. */
536  continue;
537  }
538  }
539  /* We only tag components which needs an update. Tagging everything is
540  * not a good idea because that might reset particles cache (or any
541  * other type of cache).
542  *
543  * TODO(sergey): Need to generalize this somehow. */
544  if (id_type == ID_OB) {
546  }
548  if (id_type == ID_SCE) {
549  /* Make sure collection properties are up to date. */
551  }
552  /* Now when ID is updated to the new visibility state, prevent it from
553  * being re-tagged again. Simplest way to do so is to pretend that it
554  * was already updated by the "previous" dependency graph.
555  *
556  * NOTE: Even if the on_visible_update() is called from the state when
557  * dependency graph is tagged for relations update, it will be fine:
558  * since dependency graph builder re-schedules entry tags, all the
559  * tags we request from here will be applied in the updated state of
560  * dependency graph. */
562  }
563 
566 }
567 
569 {
570  const ID_Type id_type = GS(id->name);
571  switch (id_type) {
572  case ID_OB: {
573  const Object *object = (Object *)id;
574  switch (object->type) {
575  case OB_MESH:
576  case OB_CURVES_LEGACY:
577  case OB_SURF:
578  case OB_FONT:
579  case OB_LATTICE:
580  case OB_MBALL:
581  case OB_GPENCIL:
582  case OB_CURVES:
583  case OB_POINTCLOUD:
584  case OB_VOLUME:
585  return NodeType::GEOMETRY;
586  case OB_ARMATURE:
587  return NodeType::EVAL_POSE;
588  /* TODO(sergey): More cases here? */
589  }
590  break;
591  }
592  case ID_ME:
593  case ID_CU_LEGACY:
594  case ID_LT:
595  case ID_MB:
596  case ID_CV:
597  case ID_PT:
598  case ID_VO:
599  case ID_GR:
600  return NodeType::GEOMETRY;
601  case ID_PA: /* Particles */
602  return NodeType::UNDEFINED;
603  case ID_LP:
604  return NodeType::PARAMETERS;
605  case ID_GD:
606  return NodeType::GEOMETRY;
607  case ID_PAL: /* Palettes */
608  return NodeType::PARAMETERS;
609  case ID_MSK:
610  return NodeType::PARAMETERS;
611  default:
612  break;
613  }
614  return NodeType::UNDEFINED;
615 }
616 
617 void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source)
618 {
619  graph_id_tag_update(bmain, nullptr, id, flag, update_source);
621  graph_id_tag_update(bmain, depsgraph, id, flag, update_source);
622  }
623 
624  /* Accumulate all tags for an ID between two undo steps, so they can be
625  * replayed for undo. */
626  id->recalc_after_undo_push |= deg_recalc_flags_effective(nullptr, flag);
627 }
628 
630  Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source)
631 {
632  const int debug_flags = (graph != nullptr) ? DEG_debug_flags_get((::Depsgraph *)graph) : G.debug;
633  if (graph != nullptr && graph->is_evaluating) {
634  if (debug_flags & G_DEBUG_DEPSGRAPH_TAG) {
635  printf("ID tagged for update during dependency graph evaluation.\n");
636  }
637  return;
638  }
639  if (debug_flags & G_DEBUG_DEPSGRAPH_TAG) {
640  printf("%s: id=%s flags=%s source=%s\n",
641  __func__,
642  id->name,
643  stringify_update_bitfield(flag).c_str(),
644  update_source_as_string(update_source));
645  }
646  IDNode *id_node = (graph != nullptr) ? graph->find_id_node(id) : nullptr;
647  if (graph != nullptr) {
648  DEG_graph_id_type_tag(reinterpret_cast<::Depsgraph *>(graph), GS(id->name));
649  }
650  if (flag == 0) {
651  deg_graph_node_tag_zero(bmain, graph, id_node, update_source);
652  }
653  /* Store original flag in the ID.
654  * Allows to have more granularity than a node-factory based flags. */
655  if (id_node != nullptr) {
656  id_node->id_cow->recalc |= flag;
657  }
658  /* When ID is tagged for update based on an user edits store the recalc flags in the original ID.
659  * This way IDs in the undo steps will have this flag preserved, making it possible to restore
660  * all needed tags when new dependency graph is created on redo.
661  * This is the only way to ensure modifications to animation data (such as keyframes i.e.)
662  * properly triggers animation update for the newly constructed dependency graph on redo (while
663  * usually newly created dependency graph skips animation update to avoid loss of unkeyed
664  * changes). */
665  if (update_source == DEG_UPDATE_SOURCE_USER_EDIT) {
666  id->recalc |= deg_recalc_flags_effective(graph, flag);
667  }
668  int current_flag = flag;
669  while (current_flag != 0) {
670  IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(&current_flag));
671  graph_id_tag_update_single_flag(bmain, graph, id, id_node, tag, update_source);
672  }
673  /* Special case for nested node tree data-blocks. */
674  id_tag_update_ntree_special(bmain, graph, id, flag, update_source);
675  /* Direct update tags means that something outside of simulated/cached
676  * physics did change and that cache is to be invalidated.
677  * This is only needed if data changes. If it's just a drawing, we keep the
678  * point cache. */
679  if (update_source == DEG_UPDATE_SOURCE_USER_EDIT && flag != ID_RECALC_SHADING) {
680  graph_id_tag_update_single_flag(
681  bmain, graph, id, id_node, ID_RECALC_POINT_CACHE, update_source);
682  }
683 }
684 
685 } // namespace blender::deg
686 
688 {
689  switch (flag) {
690  case ID_RECALC_TRANSFORM:
691  return "TRANSFORM";
692  case ID_RECALC_GEOMETRY:
693  return "GEOMETRY";
695  return "GEOMETRY_ALL_MODES";
696  case ID_RECALC_ANIMATION:
697  return "ANIMATION";
698  case ID_RECALC_PSYS_REDO:
699  return "PSYS_REDO";
701  return "PSYS_RESET";
703  return "PSYS_CHILD";
704  case ID_RECALC_PSYS_PHYS:
705  return "PSYS_PHYS";
706  case ID_RECALC_PSYS_ALL:
707  return "PSYS_ALL";
709  return "COPY_ON_WRITE";
710  case ID_RECALC_SHADING:
711  return "SHADING";
712  case ID_RECALC_SELECT:
713  return "SELECT";
715  return "BASE_FLAGS";
717  return "POINT_CACHE";
718  case ID_RECALC_EDITORS:
719  return "EDITORS";
721  return "SEQUENCER_STRIPS";
723  return "FRAME_CHANGE";
724  case ID_RECALC_AUDIO_FPS:
725  return "AUDIO_FPS";
727  return "AUDIO_VOLUME";
729  return "AUDIO_MUTE";
731  return "AUDIO_LISTENER";
732  case ID_RECALC_AUDIO:
733  return "AUDIO";
735  return "PARAMETERS";
736  case ID_RECALC_SOURCE:
737  return "SOURCE";
738  case ID_RECALC_ALL:
739  return "ALL";
741  return "TAG_FOR_UNDO";
743  return "ID_RECALC_NTREE_OUTPUT";
744  }
745  return nullptr;
746 }
747 
748 /* Data-Based Tagging. */
749 
750 void DEG_id_tag_update(ID *id, int flag)
751 {
752  DEG_id_tag_update_ex(G.main, id, flag);
753 }
754 
755 void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag)
756 {
757  if (id == nullptr) {
758  /* Ideally should not happen, but old depsgraph allowed this. */
759  return;
760  }
762 }
763 
764 void DEG_graph_id_tag_update(struct Main *bmain,
765  struct Depsgraph *depsgraph,
766  struct ID *id,
767  int flag)
768 {
771 }
772 
773 void DEG_time_tag_update(struct Main *bmain)
774 {
776  DEG_graph_time_tag_update(reinterpret_cast<::Depsgraph *>(depsgraph));
777  }
778 }
779 
781 {
782  deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
783  deg_graph->tag_time_source();
784 }
785 
787 {
788  if (id_type == ID_NT) {
789  /* Stupid workaround so parent data-blocks of nested node-tree get looped
790  * over when we loop over tagged data-block types. */
797  }
798  const int id_type_index = BKE_idtype_idcode_to_index(id_type);
799  deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
800  deg_graph->id_type_updated[id_type_index] = 1;
801 }
802 
803 void DEG_id_type_tag(Main *bmain, short id_type)
804 {
806  DEG_graph_id_type_tag(reinterpret_cast<::Depsgraph *>(depsgraph), id_type);
807  }
808 }
809 
811 {
813  deg::graph_tag_on_visible_update(graph, do_time);
814 }
815 
816 void DEG_tag_on_visible_update(Main *bmain, const bool do_time)
817 {
819  deg::graph_tag_on_visible_update(depsgraph, do_time);
820  }
821 }
822 
824 {
826  graph->use_editors_update = true;
827 }
828 
830 {
832  if (!graph->use_editors_update) {
833  return;
834  }
835 
838  Main *bmain = DEG_get_bmain(depsgraph);
839  bool updated = time || DEG_id_type_any_updated(depsgraph);
840 
841  DEGEditorUpdateContext update_ctx = {nullptr};
842  update_ctx.bmain = bmain;
843  update_ctx.depsgraph = depsgraph;
844  update_ctx.scene = scene;
845  update_ctx.view_layer = view_layer;
846  deg::deg_editors_scene_update(&update_ctx, updated);
847 }
848 
850 {
851  id->recalc &= ~ID_RECALC_ALL;
852  bNodeTree *ntree = ntreeFromID(id);
853  /* Clear embedded node trees too. */
854  if (ntree) {
856  }
857  /* XXX And what about scene's master collection here? */
858 }
859 
861 {
862  deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
863  /* TODO(sergey): Re-implement POST_UPDATE_HANDLER_WORKAROUND using entry_tags
864  * and id_tags storage from the new dependency graph. */
866  return;
867  }
868  /* Go over all ID nodes, clearing tags. */
869  for (deg::IDNode *id_node : deg_graph->id_nodes) {
870  if (backup) {
871  id_node->id_cow_recalc_backup |= id_node->id_cow->recalc;
872  }
873  /* TODO: we clear original ID recalc flags here, but this may not work
874  * correctly when there are multiple depsgraph with others still using
875  * the recalc flag. */
876  id_node->is_user_modified = false;
877  id_node->is_cow_explicitly_tagged = false;
879  if (deg_graph->is_active) {
881  }
882  }
883  memset(deg_graph->id_type_updated, 0, sizeof(deg_graph->id_type_updated));
884 }
885 
887 {
888  deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
889 
890  for (deg::IDNode *id_node : deg_graph->id_nodes) {
891  id_node->id_cow->recalc |= id_node->id_cow_recalc_backup;
892  id_node->id_cow_recalc_backup = 0;
893  }
894 }
struct AnimData * BKE_animdata_from_id(const struct ID *id)
@ G_DEBUG_DEPSGRAPH_TAG
Definition: BKE_global.h:184
int BKE_idtype_idcode_to_index(short idcode)
Definition: idtype.c:324
struct bNodeTree * ntreeFromID(struct ID *id)
Definition: node.cc:3231
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
MINLINE int bitscan_forward_clear_i(int *a)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
int DEG_debug_flags_get(const struct Depsgraph *depsgraph)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph)
struct Main * DEG_get_bmain(const Depsgraph *graph)
struct ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
IDRecalcFlag
Definition: DNA_ID.h:766
@ ID_RECALC_PARAMETERS
Definition: DNA_ID.h:854
@ ID_RECALC_AUDIO_FPS
Definition: DNA_ID.h:843
@ ID_RECALC_PSYS_PHYS
Definition: DNA_ID.h:804
@ ID_RECALC_AUDIO_LISTENER
Definition: DNA_ID.h:846
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_SHADING
Definition: DNA_ID.h:811
@ ID_RECALC_FRAME_CHANGE
Definition: DNA_ID.h:841
@ ID_RECALC_AUDIO
Definition: DNA_ID.h:848
@ ID_RECALC_POINT_CACHE
Definition: DNA_ID.h:822
@ ID_RECALC_SELECT
Definition: DNA_ID.h:818
@ ID_RECALC_PSYS_REDO
Definition: DNA_ID.h:798
@ ID_RECALC_PSYS_CHILD
Definition: DNA_ID.h:802
@ ID_RECALC_SOURCE
Definition: DNA_ID.h:859
@ ID_RECALC_EDITORS
Definition: DNA_ID.h:828
@ ID_RECALC_GEOMETRY_ALL_MODES
Definition: DNA_ID.h:884
@ ID_RECALC_PSYS_ALL
Definition: DNA_ID.h:893
@ ID_RECALC_AUDIO_MUTE
Definition: DNA_ID.h:845
@ ID_RECALC_SEQUENCER_STRIPS
Definition: DNA_ID.h:838
@ ID_RECALC_TAG_FOR_UNDO
Definition: DNA_ID.h:868
@ ID_RECALC_NTREE_OUTPUT
Definition: DNA_ID.h:871
@ ID_RECALC_PSYS_RESET
Definition: DNA_ID.h:800
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:794
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ ID_RECALC_ALL
Definition: DNA_ID.h:891
@ ID_RECALC_AUDIO_VOLUME
Definition: DNA_ID.h:844
@ ID_RECALC_BASE_FLAGS
Definition: DNA_ID.h:821
ID_Type
Definition: DNA_ID_enums.h:44
@ ID_MC
Definition: DNA_ID_enums.h:73
@ ID_TE
Definition: DNA_ID_enums.h:52
@ ID_VO
Definition: DNA_ID_enums.h:83
@ ID_NT
Definition: DNA_ID_enums.h:68
@ ID_LA
Definition: DNA_ID_enums.h:55
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ 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_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_CU_LEGACY
Definition: DNA_ID_enums.h:49
@ ID_ME
Definition: DNA_ID_enums.h:48
@ ID_GR
Definition: DNA_ID_enums.h:65
@ 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
Object is a sort of wrapper for general info.
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_ARMATURE
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES_LEGACY
@ OB_CURVES
@ OB_GPENCIL
Depsgraph * graph
const IDNode * id_node
double time
Scene scene
Curve curve
const Depsgraph * depsgraph
Lattice lattice
AnimationBackup * backup
void DEG_id_type_tag(Main *bmain, short id_type)
const char * DEG_update_tag_as_string(IDRecalcFlag flag)
void DEG_editors_update(Depsgraph *depsgraph, bool time)
void DEG_id_tag_update(ID *id, int flag)
void DEG_enable_editors_update(Depsgraph *depsgraph)
void DEG_ids_clear_recalc(Depsgraph *depsgraph, const bool backup)
void DEG_graph_id_tag_update(struct Main *bmain, struct Depsgraph *depsgraph, struct ID *id, int flag)
void DEG_graph_time_tag_update(struct Depsgraph *depsgraph)
void DEG_time_tag_update(struct Main *bmain)
void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag)
void DEG_tag_on_visible_update(Main *bmain, const bool do_time)
void DEG_graph_tag_on_visible_update(Depsgraph *depsgraph, const bool do_time)
void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type)
void DEG_ids_restore_recalc(Depsgraph *depsgraph)
static void deg_graph_clear_id_recalc_flags(ID *id)
bNodeTree * ntree
#define str(s)
#define GS(x)
Definition: iris.c:225
#define G(x, y, z)
Span< Depsgraph * > get_all_registered_graphs(Main *bmain)
NodeType geometry_tag_to_component(const ID *id)
void deg_editors_id_update(const DEGEditorUpdateContext *update_ctx, ID *id)
void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, bool updated)
void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source)
bool deg_copy_on_write_is_needed(const ID *id_orig)
void graph_tag_ids_for_visible_update(Depsgraph *graph)
DepsNodeFactory * type_get_factory(const NodeType type)
bool deg_copy_on_write_is_expanded(const ID *id_cow)
void graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source)
@ DEG_UPDATE_SOURCE_USER_EDIT
@ DEG_UPDATE_SOURCE_RELATIONS
@ DEG_UPDATE_SOURCE_VISIBILITY
struct Key * key
struct Depsgraph * depsgraph
struct ViewLayer * view_layer
struct Scene * scene
Definition: DNA_ID.h:368
int recalc
Definition: DNA_ID.h:390
char name[66]
Definition: DNA_ID.h:378
ID id
Definition: DNA_key_types.h:63
struct Key * key
Definition: BKE_main.h:121
struct Key * key
void * data
IDNode * find_id_node(const ID *id) const
Definition: depsgraph.cc:101
char id_type_updated[INDEX_ID_MAX]
Definition: depsgraph.h:106
bool need_tag_id_on_graph_visibility_time_update
Definition: depsgraph.h:103
bool need_tag_id_on_graph_visibility_update
Definition: depsgraph.h:102
ViewLayer * view_layer
Definition: depsgraph.h:129
IDDepsNodes id_nodes
Definition: depsgraph.h:86
IDComponentsMask previously_visible_components_mask
Definition: deg_node_id.h:127
IDComponentsMask visible_components_mask
Definition: deg_node_id.h:126
Map< ComponentIDKey, ComponentNode * > components
Definition: deg_node_id.h:80
ComponentNode * find_component(NodeType type, const char *name="") const
Definition: deg_node_id.cc:146
virtual void tag_update(Depsgraph *graph, eUpdateSource source) override
Definition: deg_node_id.cc:167