Blender V4.3
deg_node.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
9#pragma once
10
11#include "MEM_guardedalloc.h"
12
14
15#include "BLI_utildefines.h"
16
18
19struct ID;
20struct Scene;
21
22namespace blender::deg {
23
24struct Depsgraph;
25struct OperationNode;
26struct Relation;
27
28/* Meta-type of Nodes - The general "level" in the graph structure
29 * the node serves. */
30enum class NodeClass {
31 /* Types generally unassociated with user-visible entities,
32 * but needed for graph functioning. */
33 GENERIC = 0,
34 /* [Outer Node] An "aspect" of evaluating/updating an ID-Block, requiring
35 * certain types of evaluation behavior. */
36 COMPONENT = 1,
37 /* [Inner Node] A glorified function-pointer/callback for scheduling up
38 * evaluation operations for components, subject to relationship
39 * requirements. */
40 OPERATION = 2,
41};
42const char *nodeClassAsString(NodeClass node_class);
43
44/* Types of Nodes */
45enum class NodeType {
46 /* Fallback type for invalid return value */
47 UNDEFINED = 0,
48 /* Inner Node (Operation) */
50
51 /* **** Generic Types **** */
52
53 /* Time-Source */
55 /* ID-Block reference - used as landmarks/collection point for components,
56 * but not usually part of main graph. */
57 ID_REF,
58
59 /* **** Outer Types **** */
60
61 /* Parameters Component - Default when nothing else fits
62 * (i.e. just SDNA property setting). */
64 /* Animation Component */
66 /* Transform Component (Parenting/Constraints) */
68 /* Geometry Component (#Mesh, #Curves, etc.) */
70 /* Sequencer Component (Scene Only) */
72 /* Component which contains all operations needed for layer collections
73 * evaluation. */
75 /* Entry component of majority of ID nodes: prepares evaluated pointers for
76 * execution. */
78 /* Used by all operations which are updating object when something is
79 * changed in view layer. */
81 /* Hierarchy of objects and collections */
83 /* Audio-related evaluation. */
84 AUDIO,
86 /* Un-interesting data-block, which is a part of dependency graph, but does
87 * not have very distinctive update procedure. */
89
90 /* Scene evaluation, for dependencies to other evaluation which might require accumulated custom
91 * data masks. */
92 SCENE,
93
94 /* Component which is used to define visibility relation between IDs, on the ID level.
95 *
96 * Consider two ID nodes NodeA and NodeB, with the relation between visibility components going
97 * as NodeA -> NodeB. If NodeB is considered visible on screen, then the relation will ensure
98 * that NodeA is also visible. The way how relation is oriented could be seen as a inverted from
99 * visibility dependency point of view, but it follows the same direction as data dependency
100 * which simplifies common algorithms which are dealing with relations and visibility.
101 *
102 * The fact that the visibility operates on the ID level basically means that all components in
103 * the NodeA will be considered as affecting directly visible when NodeB's visibility is
104 * affecting directly visible ID.
105 *
106 * This is the way to ensure objects needed for visualization without any actual data dependency
107 * properly evaluated. Example of this is custom shapes for bones. */
109
110 /* **** Evaluation-Related Outer Types (with Sub-data) **** */
111
112 /* Pose Component - Owner/Container of Bones Eval */
113 EVAL_POSE,
114 /* Bone Component - Child/Subcomponent of Pose */
115 BONE,
116 /* Particle Systems Component */
119 /* Material Shading Component */
120 SHADING,
121 /* Point cache Component */
123 /* Image Animation Component */
125 /* Cache Component */
126 /* TODO(sergey); Verify that we really need this. */
127 CACHE,
128 /* Batch Cache Component.
129 * TODO(dfelinto/sergey): rename to make it more generic. */
131 /* Instancing system.
132 * Used to control visibility flags of dependencies. */
134 /* Synchronization back to original datablock. */
136 /* Node tree output component. */
138 /* Preprocessing for geometry node trees before they can be evaluated. */
140
141 /* Total number of meaningful node types. */
142 NUM_TYPES,
143};
144const char *nodeTypeAsString(NodeType type);
145
148
151
152/* All nodes in Depsgraph are descended from this. */
153struct Node {
154 /* Helper class for static typeinfo in subclasses. */
155 struct TypeInfo {
156 TypeInfo(NodeType type, const char *type_name, int id_recalc_tag = 0);
158 const char *type_name;
160 };
161 struct Stats {
162 Stats();
163 /* Reset all the counters. Including all stats needed for average
164 * evaluation time calculation. */
165 void reset();
166 /* Reset counters needed for the current graph evaluation, does not
167 * touch averaging accumulators. */
168 void reset_current();
169 /* Time spent on this node during current graph evaluation. */
171 };
172 /* Relationships between nodes
173 * The reason why all depsgraph nodes are descended from this type (apart
174 * from basic serialization benefits - from the typeinfo) is that we can
175 * have relationships between these nodes. */
177
178 string name; /* Identifier - mainly for debugging purposes. */
179 NodeType type; /* Structural type of node. */
180 Relations inlinks; /* Nodes which this one depends on. */
181 Relations outlinks; /* Nodes which depend on this one. */
182 Stats stats; /* Evaluation statistics. */
183
184 /* Generic tags for traversal algorithms and such.
185 *
186 * Actual meaning of values depends on a specific area. Every area is to
187 * clean this before use. */
189
190 /* Methods. */
191 Node();
192 virtual ~Node();
193
195 virtual string identifier() const;
196
197 virtual void init(const ID * /*id*/, const char * /*subdata*/) {}
198
199 virtual void tag_update(Depsgraph * /*graph*/, eUpdateSource /*source*/) {}
200
202 {
203 return nullptr;
204 }
206 {
207 return nullptr;
208 }
209
210 virtual NodeClass get_class() const;
211
213};
214
215/* Macros for common static typeinfo. */
216#define DEG_DEPSNODE_DECLARE static const Node::TypeInfo typeinfo
217#define DEG_DEPSNODE_DEFINE(NodeType, type_, tname_) \
218 const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, tname_)
219
221
222} // namespace blender::deg
eDepsSceneComponentType
eDepsObjectComponentType
Read Guarded memory(de)allocation.
eDepsObjectComponentType nodeTypeToObjectComponent(NodeType type)
Definition deg_node.cc:203
NodeType nodeTypeFromSceneComponent(eDepsSceneComponentType component)
Definition deg_node.cc:117
eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type)
Definition deg_node.cc:130
const char * nodeClassAsString(NodeClass node_class)
Definition deg_node.cc:26
NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component_type)
Definition deg_node.cc:178
const char * nodeTypeAsString(NodeType type)
Definition deg_node.cc:40
void deg_register_base_depsnodes()
Definition deg_node.cc:331
Definition DNA_ID.h:413
TypeInfo(NodeType type, const char *type_name, int id_recalc_tag=0)
Definition deg_node.cc:260
virtual OperationNode * get_entry_operation()
Definition deg_node.hh:201
virtual void tag_update(Depsgraph *, eUpdateSource)
Definition deg_node.hh:199
virtual void init(const ID *, const char *)
Definition deg_node.hh:197
Relations inlinks
Definition deg_node.hh:180
Relations outlinks
Definition deg_node.hh:181
MEM_CXX_CLASS_ALLOC_FUNCS("Node")
virtual string identifier() const
Definition deg_node.cc:304
virtual NodeClass get_class() const
Definition deg_node.cc:309
virtual OperationNode * get_exit_operation()
Definition deg_node.hh:205