Blender  V2.93
deg_node.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "intern/depsgraph_type.h"
29 
30 #include "BLI_utildefines.h"
31 
32 #include "DEG_depsgraph_build.h"
33 
34 struct ID;
35 struct Scene;
36 
37 namespace blender {
38 namespace deg {
39 
40 struct Depsgraph;
41 struct OperationNode;
42 struct Relation;
43 
44 /* Metatype of Nodes - The general "level" in the graph structure
45  * the node serves. */
46 enum class NodeClass {
47  /* Types generally unassociated with user-visible entities,
48  * but needed for graph functioning. */
49  GENERIC = 0,
50  /* [Outer Node] An "aspect" of evaluating/updating an ID-Block, requiring
51  * certain types of evaluation behavior. */
52  COMPONENT = 1,
53  /* [Inner Node] A glorified function-pointer/callback for scheduling up
54  * evaluation operations for components, subject to relationship
55  * requirements. */
56  OPERATION = 2,
57 };
58 const char *nodeClassAsString(NodeClass node_class);
59 
60 /* Types of Nodes */
61 enum class NodeType {
62  /* Fallback type for invalid return value */
63  UNDEFINED = 0,
64  /* Inner Node (Operation) */
65  OPERATION,
66 
67  /* **** Generic Types **** */
68 
69  /* Time-Source */
70  TIMESOURCE,
71  /* ID-Block reference - used as landmarks/collection point for components,
72  * but not usually part of main graph. */
73  ID_REF,
74 
75  /* **** Outer Types **** */
76 
77  /* Parameters Component - Default when nothing else fits
78  * (i.e. just SDNA property setting). */
79  PARAMETERS,
80  /* Generic "Proxy-Inherit" Component. */
81  PROXY,
82  /* Animation Component */
83  ANIMATION,
84  /* Transform Component (Parenting/Constraints) */
85  TRANSFORM,
86  /* Geometry Component (Mesh/Displist) */
87  GEOMETRY,
88  /* Sequencer Component (Scene Only) */
89  SEQUENCER,
90  /* Component which contains all operations needed for layer collections
91  * evaluation. */
93  /* Entry component of majority of ID nodes: prepares CoW pointers for
94  * execution. */
96  /* Used by all operations which are updating object when something is
97  * changed in view layer. */
99  /* Audio-related evaluation. */
100  AUDIO,
101  ARMATURE,
102  /* Un-interesting data-block, which is a part of dependency graph, but does
103  * not have very distinctive update procedure. */
105 
106  /* **** Evaluation-Related Outer Types (with Subdata) **** */
107 
108  /* Pose Component - Owner/Container of Bones Eval */
109  EVAL_POSE,
110  /* Bone Component - Child/Subcomponent of Pose */
111  BONE,
112  /* Particle Systems Component */
115  /* Material Shading Component */
116  SHADING,
118  /* Point cache Component */
119  POINT_CACHE,
120  /* Image Animation Component */
122  /* Cache Component */
123  /* TODO(sergey); Verify that we really need this. */
124  CACHE,
125  /* Batch Cache Component.
126  * TODO(dfelinto/sergey): rename to make it more generic. */
127  BATCH_CACHE,
128  /* Duplication system. Used to force duplicated objects visible when
129  * when duplicator is visible. */
130  DUPLI,
131  /* Synchronization back to original datablock. */
133  /* Simulation component. */
134  SIMULATION,
135 
136  /* Total number of meaningful node types. */
137  NUM_TYPES,
138 };
139 const char *nodeTypeAsString(NodeType type);
140 
143 
146 
147 /* All nodes in Depsgraph are descended from this. */
148 struct Node {
149  /* Helper class for static typeinfo in subclasses. */
150  struct TypeInfo {
151  TypeInfo(NodeType type, const char *type_name, int id_recalc_tag = 0);
153  const char *type_name;
155  };
156  struct Stats {
157  Stats();
158  /* Reset all the counters. Including all stats needed for average
159  * evaluation time calculation. */
160  void reset();
161  /* Reset counters needed for the current graph evaluation, does not
162  * touch averaging accumulators. */
163  void reset_current();
164  /* Time spend on this node during current graph evaluation. */
165  double current_time;
166  };
167  /* Relationships between nodes
168  * The reason why all depsgraph nodes are descended from this type (apart
169  * from basic serialization benefits - from the typeinfo) is that we can
170  * have relationships between these nodes. */
172 
173  string name; /* Identifier - mainly for debugging purposes. */
174  NodeType type; /* Structural type of node. */
175  Relations inlinks; /* Nodes which this one depends on. */
176  Relations outlinks; /* Nodes which depend on this one. */
177  Stats stats; /* Evaluation statistics. */
178 
179  /* Generic tags for traversal algorithms and such.
180  *
181  * Actual meaning of values depends on a specific area. Every area is to
182  * clean this before use. */
184 
185  /* Methods. */
186  Node();
187  virtual ~Node();
188 
189  virtual string identifier() const;
190 
191  virtual void init(const ID * /*id*/, const char * /*subdata*/)
192  {
193  }
194 
195  virtual void tag_update(Depsgraph * /*graph*/, eUpdateSource /*source*/)
196  {
197  }
198 
200  {
201  return nullptr;
202  }
204  {
205  return nullptr;
206  }
207 
208  virtual NodeClass get_class() const;
209 
211 };
212 
213 /* Macros for common static typeinfo. */
214 #define DEG_DEPSNODE_DECLARE static const Node::TypeInfo typeinfo
215 #define DEG_DEPSNODE_DEFINE(NodeType, type_, tname_) \
216  const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, tname_)
217 
219 
220 } // namespace deg
221 } // namespace blender
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
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:211
NodeType nodeTypeFromSceneComponent(eDepsSceneComponentType component)
Definition: deg_node.cc:128
eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type)
Definition: deg_node.cc:141
const char * nodeClassAsString(NodeClass node_class)
Definition: deg_node.cc:41
NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component_type)
Definition: deg_node.cc:184
const char * nodeTypeAsString(NodeType type)
Definition: deg_node.cc:55
void deg_register_base_depsnodes()
Definition: deg_node.cc:336
Definition: DNA_ID.h:273
TypeInfo(NodeType type, const char *type_name, int id_recalc_tag=0)
Definition: deg_node.cc:264
virtual void tag_update(Depsgraph *, eUpdateSource)
Definition: deg_node.h:195
virtual void init(const ID *, const char *)
Definition: deg_node.h:191
Vector< Relation * > Relations
Definition: deg_node.h:171
Relations inlinks
Definition: deg_node.h:175
virtual OperationNode * get_exit_operation()
Definition: deg_node.h:203
Relations outlinks
Definition: deg_node.h:176
MEM_CXX_CLASS_ALLOC_FUNCS("Node")
virtual ~Node()
Definition: deg_node.cc:297
virtual string identifier() const
Definition: deg_node.cc:309
virtual OperationNode * get_entry_operation()
Definition: deg_node.h:199
virtual NodeClass get_class() const
Definition: deg_node.cc:314