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