Blender  V3.3
deg_node.cc
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 #include "intern/node/deg_node.h"
9 
10 #include <cstdio>
11 
12 #include "BLI_utildefines.h"
13 
14 #include "intern/depsgraph.h"
22 
23 namespace blender::deg {
24 
25 const char *nodeClassAsString(NodeClass node_class)
26 {
27  switch (node_class) {
28  case NodeClass::GENERIC:
29  return "GENERIC";
31  return "COMPONENT";
33  return "OPERATION";
34  }
35  BLI_assert_msg(0, "Unhandled node class, should never happen.");
36  return "UNKNOWN";
37 }
38 
40 {
41  switch (type) {
43  return "UNDEFINED";
45  return "OPERATION";
46  /* **** Generic Types **** */
48  return "TIMESOURCE";
49  case NodeType::ID_REF:
50  return "ID_REF";
51  /* **** Outer Types **** */
53  return "PARAMETERS";
55  return "ANIMATION";
57  return "TRANSFORM";
58  case NodeType::GEOMETRY:
59  return "GEOMETRY";
61  return "SEQUENCER";
63  return "LAYER_COLLECTIONS";
65  return "COPY_ON_WRITE";
67  return "OBJECT_FROM_LAYER";
68  /* **** Evaluation-Related Outer Types (with Subdata) **** */
70  return "EVAL_POSE";
71  case NodeType::BONE:
72  return "BONE";
74  return "PARTICLE_SYSTEM";
76  return "PARTICLE_SETTINGS";
77  case NodeType::SHADING:
78  return "SHADING";
79  case NodeType::CACHE:
80  return "CACHE";
82  return "POINT_CACHE";
84  return "IMAGE_ANIMATION";
86  return "BATCH_CACHE";
87  case NodeType::DUPLI:
88  return "DUPLI";
90  return "SYNCHRONIZATION";
91  case NodeType::AUDIO:
92  return "AUDIO";
93  case NodeType::ARMATURE:
94  return "ARMATURE";
96  return "GENERIC_DATABLOCK";
98  return "VISIBILITY";
100  return "SIMULATION";
102  return "NTREE_OUTPUT";
103 
104  /* Total number of meaningful node types. */
105  case NodeType::NUM_TYPES:
106  return "SpecialCase";
107  }
108  BLI_assert_msg(0, "Unhandled node type, should never happen.");
109  return "UNKNOWN";
110 }
111 
113 {
114  switch (component) {
116  return NodeType::PARAMETERS;
118  return NodeType::ANIMATION;
120  return NodeType::SEQUENCER;
121  }
122  return NodeType::UNDEFINED;
123 }
124 
126 {
127  switch (type) {
130  case NodeType::ANIMATION:
132  case NodeType::SEQUENCER:
134 
135  case NodeType::OPERATION:
137  case NodeType::ID_REF:
141  case NodeType::AUDIO:
142  case NodeType::ARMATURE:
149  case NodeType::DUPLI:
151  case NodeType::UNDEFINED:
152  case NodeType::NUM_TYPES:
153  case NodeType::TRANSFORM:
154  case NodeType::GEOMETRY:
155  case NodeType::EVAL_POSE:
156  case NodeType::BONE:
157  case NodeType::SHADING:
158  case NodeType::CACHE:
162 
164  BLI_assert_msg(0, "Visibility component is supposed to be only used internally.");
166  }
167  BLI_assert_msg(0, "Unhandled node type, not supposed to happen.");
169 }
170 
172 {
173  switch (component_type) {
174  case DEG_OB_COMP_ANY:
175  return NodeType::UNDEFINED;
177  return NodeType::PARAMETERS;
179  return NodeType::ANIMATION;
181  return NodeType::TRANSFORM;
183  return NodeType::GEOMETRY;
185  return NodeType::EVAL_POSE;
186  case DEG_OB_COMP_BONE:
187  return NodeType::BONE;
188  case DEG_OB_COMP_SHADING:
189  return NodeType::SHADING;
190  case DEG_OB_COMP_CACHE:
191  return NodeType::CACHE;
192  }
193  return NodeType::UNDEFINED;
194 }
195 
197 {
198  switch (type) {
200  return DEG_OB_COMP_PARAMETERS;
201  case NodeType::ANIMATION:
202  return DEG_OB_COMP_ANIMATION;
203  case NodeType::TRANSFORM:
204  return DEG_OB_COMP_TRANSFORM;
205  case NodeType::GEOMETRY:
206  return DEG_OB_COMP_GEOMETRY;
207  case NodeType::EVAL_POSE:
208  return DEG_OB_COMP_EVAL_POSE;
209  case NodeType::BONE:
210  return DEG_OB_COMP_BONE;
211  case NodeType::SHADING:
212  return DEG_OB_COMP_SHADING;
213  case NodeType::CACHE:
214  return DEG_OB_COMP_CACHE;
215 
216  case NodeType::OPERATION:
218  case NodeType::ID_REF:
219  case NodeType::SEQUENCER:
223  case NodeType::AUDIO:
224  case NodeType::ARMATURE:
231  case NodeType::DUPLI:
235  case NodeType::UNDEFINED:
236  case NodeType::NUM_TYPES:
237  return DEG_OB_COMP_PARAMETERS;
238 
240  BLI_assert_msg(0, "Visibility component is supposed to be only used internally.");
241  return DEG_OB_COMP_PARAMETERS;
242  }
243  BLI_assert_msg(0, "Unhandled node type, not suppsed to happen.");
244  return DEG_OB_COMP_PARAMETERS;
245 }
246 
247 /*******************************************************************************
248  * Type information.
249  */
250 
251 Node::TypeInfo::TypeInfo(NodeType type, const char *type_name, int id_recalc_tag)
252  : type(type), type_name(type_name), id_recalc_tag(id_recalc_tag)
253 {
254 }
255 
256 /*******************************************************************************
257  * Evaluation statistics.
258  */
259 
261 {
262  reset();
263 }
264 
266 {
267  current_time = 0.0;
268 }
269 
271 {
272  current_time = 0.0;
273 }
274 
275 /*******************************************************************************
276  * Node itself.
277  */
278 
280 {
281  name = "";
282 }
283 
285 {
286  /* Free links. */
287  /* NOTE: We only free incoming links. This is to avoid double-free of links
288  * when we're trying to free same link from both its sides. We don't have
289  * dangling links so this is not a problem from memory leaks point of view. */
290  for (Relation *rel : inlinks) {
291  delete rel;
292  }
293 }
294 
295 string Node::identifier() const
296 {
297  return string(nodeTypeAsString(type)) + " : " + name;
298 }
299 
301 {
302  if (type == NodeType::OPERATION) {
303  return NodeClass::OPERATION;
304  }
305  if (type < NodeType::PARAMETERS) {
306  return NodeClass::GENERIC;
307  }
308 
309  return NodeClass::COMPONENT;
310 }
311 
312 /*******************************************************************************
313  * Generic nodes definition.
314  */
315 
318 
321 
323 {
326 }
327 
328 } // namespace blender::deg
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
static uint8 component(Color32 c, uint i)
Definition: ColorBlock.cpp:108
eDepsSceneComponentType
@ DEG_SCENE_COMP_ANIMATION
@ DEG_SCENE_COMP_PARAMETERS
@ DEG_SCENE_COMP_SEQUENCER
eDepsObjectComponentType
@ DEG_OB_COMP_ANY
@ DEG_OB_COMP_EVAL_POSE
@ DEG_OB_COMP_GEOMETRY
@ DEG_OB_COMP_ANIMATION
@ DEG_OB_COMP_TRANSFORM
@ DEG_OB_COMP_SHADING
@ DEG_OB_COMP_PARAMETERS
@ DEG_OB_COMP_CACHE
@ DEG_OB_COMP_BONE
_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
ccl_gpu_kernel_postfix ccl_global float int int int int float bool reset
clear internal cached data and reset random seed
void register_node_typeinfo(DepsNodeFactory *factory)
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
static DepsNodeFactoryImpl< IDNode > DNTI_ID_REF
Definition: deg_node.cc:320
static DepsNodeFactoryImpl< TimeSourceNode > DNTI_TIMESOURCE
Definition: deg_node.cc:317
const char * nodeClassAsString(NodeClass node_class)
Definition: deg_node.cc:25
NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component_type)
Definition: deg_node.cc:171
DEG_DEPSNODE_DEFINE(TimeSourceNode, NodeType::TIMESOURCE, "Time Source")
const char * nodeTypeAsString(NodeType type)
Definition: deg_node.cc:39
void deg_register_base_depsnodes()
Definition: deg_node.cc:322
TypeInfo(NodeType type, const char *type_name, int id_recalc_tag=0)
Definition: deg_node.cc:251
Relations inlinks
Definition: deg_node.h:173
virtual ~Node()
Definition: deg_node.cc:284
virtual string identifier() const
Definition: deg_node.cc:295
virtual NodeClass get_class() const
Definition: deg_node.cc:300