Blender V5.0
depsgraph.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#pragma once
16
17#include <cstdlib>
18#include <functional>
19
20#include "MEM_guardedalloc.h"
21
22#include "DNA_ID.h" /* for ID_Type and INDEX_ID_MAX */
23
25#include "BLI_mutex.hh"
26#include "BLI_set.hh"
27#include "BLI_threads.h" /* for SpinLock */
28
29#include "DEG_depsgraph.hh"
31
34
35struct ID;
36struct Scene;
37struct ViewLayer;
38
39namespace blender::deg {
40
41struct IDNode;
42struct Node;
43struct OperationNode;
44struct Relation;
45struct TimeSourceNode;
46
47/* Dependency Graph object */
48struct Depsgraph {
51
53 ~Depsgraph();
54
57 void tag_time_source();
58
59 IDNode *find_id_node(const ID *id) const;
60 IDNode *add_id_node(ID *id, ID *id_cow_hint = nullptr);
61 void clear_id_nodes();
62
64 Relation *add_new_relation(Node *from, Node *to, const char *description, int flags = 0);
65
66 /* Check whether two nodes are connected by relation with given
67 * description. Description might be nullptr to check ANY relation between
68 * given nodes. */
69 Relation *check_nodes_connected(const Node *from, const Node *to, const char *description);
70
71 /* Tag a specific node as needing updates. */
72 void add_entry_tag(OperationNode *node);
73
74 /* Clear storage used by all nodes. */
75 void clear_all_nodes();
76
77 /* Copy-on-Write Functionality ........ */
78
79 /* For given original ID get ID which is created by copy-on-evaluation system. */
80 ID *get_cow_id(const ID *id_orig) const;
81
82 /* Core Graph Functionality ........... */
83
89
90 /* <ID : IDNode> mapping from ID blocks to nodes representing these
91 * blocks, used for quick lookups. */
93
94 /* Ordered list of ID nodes, order matches ID allocation order.
95 * Used for faster iteration, especially for areas which are critical to
96 * keep exact order of iteration. */
98
99 /* Top-level time source node. */
101
102 /* The graph contains data-blocks whose visibility depends on evaluation (driven or animated). */
104
105 /* Indicates whether relations needs to be updated. */
107
108 /* Indicates whether indirect effect of nodes on a directly visible ones needs to be updated. */
110
111 /* Indicated whether IDs in this graph are to be tagged as if they first appear visible, with
112 * an optional tag for their animation (time) update. */
115
116 /* Indicates which ID types were updated. */
118 /* Accumulate id type updates from multiple update passes. */
120
121 /* Indicates type of IDs present in the depsgraph. */
123
124 /* Quick-Access Temp Data ............. */
125
126 /* Nodes which have been tagged as "directly modified". */
128
129 /* Convenience Data ................... */
130
131 /* XXX: should be collected after building (if actually needed?) */
132 /* All operation nodes, sorted in order of single-thread traversal order. */
134
135 /* Spin lock for threading-critical operations.
136 * Mainly used by graph evaluation. */
138
139 /* Main, scene, layer, mode this dependency graph is built for. */
144
145 /* Time at which dependency graph is being or was last evaluated.
146 * frame is the value before, and ctime the value after time remapping. */
147 float frame;
148 float ctime;
149
150 /* Evaluated version of datablocks we access a lot.
151 * Stored here to save us form doing hash lookup. */
153
154 /* Active dependency graph is a dependency graph which is used by the
155 * currently active window. When dependency graph is active, it is allowed
156 * for evaluation functions to write animation f-curve result, drivers
157 * result and other selective things (object matrix?) to original object.
158 *
159 * This way we simplify operators, which don't need to worry about where
160 * to read stuff from. */
162
163 /* Optimize out evaluation of operations which affect hidden objects or disabled modifiers. */
165
167
169
170 /* Is set to truth for dependency graph which are used for post-processing (compositor and
171 * sequencer).
172 * Such dependency graph needs all view layers (so render pipeline can access names), but it
173 * does not need any bases. */
175
176 /* Notify editors about changes to IDs in this depsgraph. */
178
179 /* Cached list of colliders/effectors for collections and the scene
180 * created along with relations, for fast lookup during evaluation. */
182
184
185 /* The number of times this graph has been evaluated. */
187
188 /* If this mode does not allow writing back to original data any callbacks will be discarded. */
194 Vector<std::function<void()>> sync_writeback_callbacks;
197
199};
200
201} // namespace blender::deg
pthread_spinlock_t SpinLock
DepsgraphEvaluateSyncWriteback
eEvaluationMode
@ DEG_PHYSICS_RELATIONS_NUM
ID and Library types, which are fundamental for SDNA.
#define INDEX_ID_MAX
Definition DNA_ID.h:1360
Read Guarded memory(de)allocation.
unsigned long long int uint64_t
std::mutex Mutex
Definition BLI_mutex.hh:47
Definition DNA_ID.h:414
Vector< std::function< void()> > sync_writeback_callbacks
Definition depsgraph.hh:194
ID * get_cow_id(const ID *id_orig) const
Definition depsgraph.cc:247
Map< const ID *, ListBase * > * physics_relations[DEG_PHYSICS_RELATIONS_NUM]
Definition depsgraph.hh:181
IDNode * find_id_node(const ID *id) const
Definition depsgraph.cc:101
char id_type_updated[INDEX_ID_MAX]
Definition depsgraph.hh:117
bool need_tag_id_on_graph_visibility_time_update
Definition depsgraph.hh:114
LinearAllocator build_allocator
Definition depsgraph.hh:88
light_linking::Cache light_linking_cache
Definition depsgraph.hh:183
bool need_tag_id_on_graph_visibility_update
Definition depsgraph.hh:113
TimeSourceNode * find_time_source() const
Definition depsgraph.cc:91
IDNode * add_id_node(ID *id, ID *id_cow_hint=nullptr)
Definition depsgraph.cc:106
Vector< IDNode * > IDDepsNodes
Definition depsgraph.hh:50
OperationNodes operations
Definition depsgraph.hh:133
eEvaluationMode mode
Definition depsgraph.hh:143
char id_type_updated_backup[INDEX_ID_MAX]
Definition depsgraph.hh:119
MEM_CXX_CLASS_ALLOC_FUNCS("Depsgraph")
Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
Definition depsgraph.cc:42
DepsgraphEvaluateSyncWriteback sync_writeback
Definition depsgraph.hh:189
Vector< OperationNode * > OperationNodes
Definition depsgraph.hh:49
Relation * add_new_relation(Node *from, Node *to, const char *description, int flags=0)
Definition depsgraph.cc:173
char id_type_exist[INDEX_ID_MAX]
Definition depsgraph.hh:122
Map< const ID *, IDNode * > id_hash
Definition depsgraph.hh:92
Relation * check_nodes_connected(const Node *from, const Node *to, const char *description)
Definition depsgraph.cc:205
TimeSourceNode * add_time_source()
Definition depsgraph.cc:82
DepsgraphDebug debug
Definition depsgraph.hh:166
Set< OperationNode * > entry_tags
Definition depsgraph.hh:127
TimeSourceNode * time_source
Definition depsgraph.hh:100
void add_entry_tag(OperationNode *node)
Definition depsgraph.cc:224