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