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