Blender  V3.3
deg_node.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2013 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "intern/depsgraph_type.h"
13 
14 #include "BLI_utildefines.h"
15 
16 #include "DEG_depsgraph_build.h"
17 
18 struct ID;
19 struct Scene;
20 
21 namespace blender::deg {
22 
23 struct Depsgraph;
24 struct OperationNode;
25 struct Relation;
26 
27 /* Metatype of Nodes - The general "level" in the graph structure
28  * the node serves. */
29 enum class NodeClass {
30  /* Types generally unassociated with user-visible entities,
31  * but needed for graph functioning. */
32  GENERIC = 0,
33  /* [Outer Node] An "aspect" of evaluating/updating an ID-Block, requiring
34  * certain types of evaluation behavior. */
35  COMPONENT = 1,
36  /* [Inner Node] A glorified function-pointer/callback for scheduling up
37  * evaluation operations for components, subject to relationship
38  * requirements. */
39  OPERATION = 2,
40 };
41 const char *nodeClassAsString(NodeClass node_class);
42 
43 /* Types of Nodes */
44 enum class NodeType {
45  /* Fallback type for invalid return value */
46  UNDEFINED = 0,
47  /* Inner Node (Operation) */
48  OPERATION,
49 
50  /* **** Generic Types **** */
51 
52  /* Time-Source */
53  TIMESOURCE,
54  /* ID-Block reference - used as landmarks/collection point for components,
55  * but not usually part of main graph. */
56  ID_REF,
57 
58  /* **** Outer Types **** */
59 
60  /* Parameters Component - Default when nothing else fits
61  * (i.e. just SDNA property setting). */
62  PARAMETERS,
63  /* Animation Component */
64  ANIMATION,
65  /* Transform Component (Parenting/Constraints) */
66  TRANSFORM,
67  /* Geometry Component (#Mesh / #DispList) */
68  GEOMETRY,
69  /* Sequencer Component (Scene Only) */
70  SEQUENCER,
71  /* Component which contains all operations needed for layer collections
72  * evaluation. */
74  /* Entry component of majority of ID nodes: prepares CoW pointers for
75  * execution. */
77  /* Used by all operations which are updating object when something is
78  * changed in view layer. */
80  /* Audio-related evaluation. */
81  AUDIO,
82  ARMATURE,
83  /* Un-interesting data-block, which is a part of dependency graph, but does
84  * not have very distinctive update procedure. */
86 
87  /* Component which is used to define visibility relation between IDs, on the ID level.
88  *
89  * Consider two ID nodes NodeA and NodeB, with the relation between visibility components going
90  * as NodeA -> NodeB. If NodeB is considered visible on screen, then the relation will ensure
91  * that NodeA is also visible. The way how relation is oriented could be seen as a inverted from
92  * visibility dependency point of view, but it follows the same direction as data dependency
93  * which simplifies common algorithms which are dealing with relations and visibility.
94  *
95  * The fact that the visibility operates on the ID level basically means that all components in
96  * the NodeA will be considered as affecting directly visible when NodeB's visibility is
97  * affecting directly visible ID.
98  *
99  * This is the way to ensure objects needed for visualization without any actual data dependency
100  * properly evaluated. Example of this is custom shapes for bones. */
101  VISIBILITY,
102 
103  /* **** Evaluation-Related Outer Types (with Subdata) **** */
104 
105  /* Pose Component - Owner/Container of Bones Eval */
106  EVAL_POSE,
107  /* Bone Component - Child/Subcomponent of Pose */
108  BONE,
109  /* Particle Systems Component */
112  /* Material Shading Component */
113  SHADING,
114  /* Point cache Component */
115  POINT_CACHE,
116  /* Image Animation Component */
118  /* Cache Component */
119  /* TODO(sergey); Verify that we really need this. */
120  CACHE,
121  /* Batch Cache Component.
122  * TODO(dfelinto/sergey): rename to make it more generic. */
123  BATCH_CACHE,
124  /* Duplication system. Used to force duplicated objects visible when
125  * when duplicator is visible. */
126  DUPLI,
127  /* Synchronization back to original datablock. */
129  /* Simulation component. */
130  SIMULATION,
131  /* Node tree output component. */
132  NTREE_OUTPUT,
133 
134  /* Total number of meaningful node types. */
135  NUM_TYPES,
136 };
137 const char *nodeTypeAsString(NodeType type);
138 
141 
144 
145 /* All nodes in Depsgraph are descended from this. */
146 struct Node {
147  /* Helper class for static typeinfo in subclasses. */
148  struct TypeInfo {
149  TypeInfo(NodeType type, const char *type_name, int id_recalc_tag = 0);
151  const char *type_name;
153  };
154  struct Stats {
155  Stats();
156  /* Reset all the counters. Including all stats needed for average
157  * evaluation time calculation. */
158  void reset();
159  /* Reset counters needed for the current graph evaluation, does not
160  * touch averaging accumulators. */
161  void reset_current();
162  /* Time spend on this node during current graph evaluation. */
163  double current_time;
164  };
165  /* Relationships between nodes
166  * The reason why all depsgraph nodes are descended from this type (apart
167  * from basic serialization benefits - from the typeinfo) is that we can
168  * have relationships between these nodes. */
170 
171  string name; /* Identifier - mainly for debugging purposes. */
172  NodeType type; /* Structural type of node. */
173  Relations inlinks; /* Nodes which this one depends on. */
174  Relations outlinks; /* Nodes which depend on this one. */
175  Stats stats; /* Evaluation statistics. */
176 
177  /* Generic tags for traversal algorithms and such.
178  *
179  * Actual meaning of values depends on a specific area. Every area is to
180  * clean this before use. */
182 
183  /* Methods. */
184  Node();
185  virtual ~Node();
186 
188  virtual string identifier() const;
189 
190  virtual void init(const ID * /*id*/, const char * /*subdata*/)
191  {
192  }
193 
194  virtual void tag_update(Depsgraph * /*graph*/, eUpdateSource /*source*/)
195  {
196  }
197 
199  {
200  return nullptr;
201  }
203  {
204  return nullptr;
205  }
206 
207  virtual NodeClass get_class() const;
208 
210 };
211 
212 /* Macros for common static typeinfo. */
213 #define DEG_DEPSNODE_DECLARE static const Node::TypeInfo typeinfo
214 #define DEG_DEPSNODE_DEFINE(NodeType, type_, tname_) \
215  const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, tname_)
216 
218 
219 } // namespace blender::deg
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
eDepsSceneComponentType
eDepsObjectComponentType
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
eDepsObjectComponentType nodeTypeToObjectComponent(NodeType type)
Definition: deg_node.cc:196
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:25
NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component_type)
Definition: deg_node.cc:171
const char * nodeTypeAsString(NodeType type)
Definition: deg_node.cc:39
void deg_register_base_depsnodes()
Definition: deg_node.cc:322
Definition: DNA_ID.h:368
TypeInfo(NodeType type, const char *type_name, int id_recalc_tag=0)
Definition: deg_node.cc:251
virtual void tag_update(Depsgraph *, eUpdateSource)
Definition: deg_node.h:194
virtual void init(const ID *, const char *)
Definition: deg_node.h:190
Vector< Relation * > Relations
Definition: deg_node.h:169
Relations inlinks
Definition: deg_node.h:173
virtual OperationNode * get_exit_operation()
Definition: deg_node.h:202
Relations outlinks
Definition: deg_node.h:174
MEM_CXX_CLASS_ALLOC_FUNCS("Node")
virtual ~Node()
Definition: deg_node.cc:284
virtual string identifier() const
Definition: deg_node.cc:295
virtual OperationNode * get_entry_operation()
Definition: deg_node.h:198
virtual NodeClass get_class() const
Definition: deg_node.cc:300