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