Blender  V3.3
depsgraph.h
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 
14 #pragma once
15 
16 #include <stdlib.h>
17 
18 #include "MEM_guardedalloc.h"
19 
20 #include "DNA_ID.h" /* for ID_Type and INDEX_ID_MAX */
21 
22 #include "BLI_threads.h" /* for SpinLock */
23 
24 #include "DEG_depsgraph.h"
25 #include "DEG_depsgraph_physics.h"
26 
27 #include "intern/debug/deg_debug.h"
28 #include "intern/depsgraph_type.h"
29 
30 struct ID;
31 struct Scene;
32 struct ViewLayer;
33 
34 namespace blender::deg {
35 
36 struct IDNode;
37 struct Node;
38 struct OperationNode;
39 struct Relation;
40 struct TimeSourceNode;
41 
42 /* Dependency Graph object */
43 struct Depsgraph {
46 
48  ~Depsgraph();
49 
52  void tag_time_source();
53 
54  IDNode *find_id_node(const ID *id) const;
55  IDNode *add_id_node(ID *id, ID *id_cow_hint = nullptr);
56  void clear_id_nodes();
57 
59  Relation *add_new_relation(Node *from, Node *to, const char *description, int flags = 0);
60 
61  /* Check whether two nodes are connected by relation with given
62  * description. Description might be nullptr to check ANY relation between
63  * given nodes. */
64  Relation *check_nodes_connected(const Node *from, const Node *to, const char *description);
65 
66  /* Tag a specific node as needing updates. */
68 
69  /* Clear storage used by all nodes. */
70  void clear_all_nodes();
71 
72  /* Copy-on-Write Functionality ........ */
73 
74  /* For given original ID get ID which is created by CoW system. */
75  ID *get_cow_id(const ID *id_orig) const;
76 
77  /* Core Graph Functionality ........... */
78 
79  /* <ID : IDNode> mapping from ID blocks to nodes representing these
80  * blocks, used for quick lookups. */
82 
83  /* Ordered list of ID nodes, order matches ID allocation order.
84  * Used for faster iteration, especially for areas which are critical to
85  * keep exact order of iteration. */
87 
88  /* Top-level time source node. */
90 
91  /* The graph contains data-blocks whose visibility depends on evaluation (driven or animated). */
93 
94  /* Indicates whether relations needs to be updated. */
96 
97  /* Indicates whether indirect effect of nodes on a directly visible ones needs to be updated. */
99 
100  /* Indicated whether IDs in this graph are to be tagged as if they first appear visible, with
101  * an optional tag for their animation (time) update. */
104 
105  /* Indicates which ID types were updated. */
107 
108  /* Indicates type of IDs present in the depsgraph. */
110 
111  /* Quick-Access Temp Data ............. */
112 
113  /* Nodes which have been tagged as "directly modified". */
115 
116  /* Convenience Data ................... */
117 
118  /* XXX: should be collected after building (if actually needed?) */
119  /* All operation nodes, sorted in order of single-thread traversal order. */
121 
122  /* Spin lock for threading-critical operations.
123  * Mainly used by graph evaluation. */
125 
126  /* Main, scene, layer, mode this dependency graph is built for. */
131 
132  /* Time at which dependency graph is being or was last evaluated.
133  * frame is the value before, and ctime the value after time remapping. */
134  float frame;
135  float ctime;
136 
137  /* Evaluated version of datablocks we access a lot.
138  * Stored here to save us form doing hash lookup. */
140 
141  /* Active dependency graph is a dependency graph which is used by the
142  * currently active window. When dependency graph is active, it is allowed
143  * for evaluation functions to write animation f-curve result, drivers
144  * result and other selective things (object matrix?) to original object.
145  *
146  * This way we simplify operators, which don't need to worry about where
147  * to read stuff from. */
148  bool is_active;
149 
151 
153 
154  /* Is set to truth for dependency graph which are used for post-processing (compositor and
155  * sequencer).
156  * Such dependency graph needs all view layers (so render pipeline can access names), but it
157  * does not need any bases. */
159 
160  /* Notify editors about changes to IDs in this depsgraph. */
162 
163  /* Cached list of colliders/effectors for collections and the scene
164  * created along with relations, for fast lookup during evaluation. */
166 
168 };
169 
170 } // namespace blender::deg
pthread_spinlock_t SpinLock
Definition: BLI_threads.h:110
eEvaluationMode
Definition: DEG_depsgraph.h:44
@ DEG_PHYSICS_RELATIONS_NUM
ID and Library types, which are fundamental for sdna.
@ INDEX_ID_MAX
Definition: DNA_ID.h:1058
Read Guarded memory(de)allocation.
OperationNode * node
StackEntry * from
Definition: DNA_ID.h:368
Definition: BKE_main.h:121
ID * get_cow_id(const ID *id_orig) const
Definition: depsgraph.cc:236
Map< const ID *, ListBase * > * physics_relations[DEG_PHYSICS_RELATIONS_NUM]
Definition: depsgraph.h:165
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
TimeSourceNode * find_time_source() const
Definition: depsgraph.cc:91
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
bool need_update_nodes_visibility
Definition: depsgraph.h:98
MEM_CXX_CLASS_ALLOC_FUNCS("Depsgraph")
Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
Definition: depsgraph.cc:46
ViewLayer * view_layer
Definition: depsgraph.h:129
Relation * add_new_relation(Node *from, Node *to, const char *description, int flags=0)
Definition: depsgraph.cc:171
char id_type_exist[INDEX_ID_MAX]
Definition: depsgraph.h:109
Map< const ID *, IDNode * > id_hash
Definition: depsgraph.h:81
Vector< OperationNode * > OperationNodes
Definition: depsgraph.h:44
Vector< IDNode * > IDDepsNodes
Definition: depsgraph.h:45
Relation * check_nodes_connected(const Node *from, const Node *to, const char *description)
Definition: depsgraph.cc:197
TimeSourceNode * add_time_source()
Definition: depsgraph.cc:82
DepsgraphDebug debug
Definition: depsgraph.h:150
Set< OperationNode * > entry_tags
Definition: depsgraph.h:114
TimeSourceNode * time_source
Definition: depsgraph.h:89
IDDepsNodes id_nodes
Definition: depsgraph.h:86
void add_entry_tag(OperationNode *node)
Definition: depsgraph.cc:216