Blender  V2.93
deg_node.cc
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 #include "intern/node/deg_node.h"
25 
26 #include <cstdio>
27 
28 #include "BLI_utildefines.h"
29 
30 #include "intern/depsgraph.h"
38 
39 namespace blender::deg {
40 
41 const char *nodeClassAsString(NodeClass node_class)
42 {
43  switch (node_class) {
44  case NodeClass::GENERIC:
45  return "GENERIC";
47  return "COMPONENT";
49  return "OPERATION";
50  }
51  BLI_assert(!"Unhandled node class, should never happen.");
52  return "UNKNOWN";
53 }
54 
56 {
57  switch (type) {
59  return "UNDEFINED";
61  return "OPERATION";
62  /* **** Generic Types **** */
64  return "TIMESOURCE";
65  case NodeType::ID_REF:
66  return "ID_REF";
67  /* **** Outer Types **** */
69  return "PARAMETERS";
70  case NodeType::PROXY:
71  return "PROXY";
73  return "ANIMATION";
75  return "TRANSFORM";
76  case NodeType::GEOMETRY:
77  return "GEOMETRY";
79  return "SEQUENCER";
81  return "LAYER_COLLECTIONS";
83  return "COPY_ON_WRITE";
85  return "OBJECT_FROM_LAYER";
86  /* **** Evaluation-Related Outer Types (with Subdata) **** */
88  return "EVAL_POSE";
89  case NodeType::BONE:
90  return "BONE";
92  return "PARTICLE_SYSTEM";
94  return "PARTICLE_SETTINGS";
95  case NodeType::SHADING:
96  return "SHADING";
98  return "SHADING_PARAMETERS";
99  case NodeType::CACHE:
100  return "CACHE";
102  return "POINT_CACHE";
104  return "IMAGE_ANIMATION";
106  return "BATCH_CACHE";
107  case NodeType::DUPLI:
108  return "DUPLI";
110  return "SYNCHRONIZATION";
111  case NodeType::AUDIO:
112  return "AUDIO";
113  case NodeType::ARMATURE:
114  return "ARMATURE";
116  return "GENERIC_DATABLOCK";
118  return "SIMULATION";
119 
120  /* Total number of meaningful node types. */
121  case NodeType::NUM_TYPES:
122  return "SpecialCase";
123  }
124  BLI_assert(!"Unhandled node type, should never happen.");
125  return "UNKNOWN";
126 }
127 
129 {
130  switch (component) {
132  return NodeType::PARAMETERS;
134  return NodeType::ANIMATION;
136  return NodeType::SEQUENCER;
137  }
138  return NodeType::UNDEFINED;
139 }
140 
142 {
143  switch (type) {
146  case NodeType::ANIMATION:
148  case NodeType::SEQUENCER:
150 
151  case NodeType::OPERATION:
153  case NodeType::ID_REF:
157  case NodeType::AUDIO:
158  case NodeType::ARMATURE:
166  case NodeType::DUPLI:
168  case NodeType::UNDEFINED:
169  case NodeType::NUM_TYPES:
170  case NodeType::TRANSFORM:
171  case NodeType::GEOMETRY:
172  case NodeType::EVAL_POSE:
173  case NodeType::BONE:
174  case NodeType::SHADING:
175  case NodeType::CACHE:
176  case NodeType::PROXY:
179  }
180  BLI_assert(!"Unhandled node type, not suppsed to happen.");
182 }
183 
185 {
186  switch (component_type) {
187  case DEG_OB_COMP_ANY:
188  return NodeType::UNDEFINED;
190  return NodeType::PARAMETERS;
191  case DEG_OB_COMP_PROXY:
192  return NodeType::PROXY;
194  return NodeType::ANIMATION;
196  return NodeType::TRANSFORM;
198  return NodeType::GEOMETRY;
200  return NodeType::EVAL_POSE;
201  case DEG_OB_COMP_BONE:
202  return NodeType::BONE;
203  case DEG_OB_COMP_SHADING:
204  return NodeType::SHADING;
205  case DEG_OB_COMP_CACHE:
206  return NodeType::CACHE;
207  }
208  return NodeType::UNDEFINED;
209 }
210 
212 {
213  switch (type) {
215  return DEG_OB_COMP_PARAMETERS;
216  case NodeType::PROXY:
217  return DEG_OB_COMP_PROXY;
218  case NodeType::ANIMATION:
219  return DEG_OB_COMP_ANIMATION;
220  case NodeType::TRANSFORM:
221  return DEG_OB_COMP_TRANSFORM;
222  case NodeType::GEOMETRY:
223  return DEG_OB_COMP_GEOMETRY;
224  case NodeType::EVAL_POSE:
225  return DEG_OB_COMP_EVAL_POSE;
226  case NodeType::BONE:
227  return DEG_OB_COMP_BONE;
228  case NodeType::SHADING:
229  return DEG_OB_COMP_SHADING;
230  case NodeType::CACHE:
231  return DEG_OB_COMP_CACHE;
232 
233  case NodeType::OPERATION:
235  case NodeType::ID_REF:
236  case NodeType::SEQUENCER:
240  case NodeType::AUDIO:
241  case NodeType::ARMATURE:
249  case NodeType::DUPLI:
252  case NodeType::UNDEFINED:
253  case NodeType::NUM_TYPES:
254  return DEG_OB_COMP_PARAMETERS;
255  }
256  BLI_assert(!"Unhandled node type, not suppsed to happen.");
257  return DEG_OB_COMP_PARAMETERS;
258 }
259 
260 /*******************************************************************************
261  * Type information.
262  */
263 
264 Node::TypeInfo::TypeInfo(NodeType type, const char *type_name, int id_recalc_tag)
265  : type(type), type_name(type_name), id_recalc_tag(id_recalc_tag)
266 {
267 }
268 
269 /*******************************************************************************
270  * Evaluation statistics.
271  */
272 
274 {
275  reset();
276 }
277 
279 {
280  current_time = 0.0;
281 }
282 
284 {
285  current_time = 0.0;
286 }
287 
288 /*******************************************************************************
289  * Node itself.
290  */
291 
293 {
294  name = "";
295 }
296 
298 {
299  /* Free links. */
300  /* NOTE: We only free incoming links. This is to avoid double-free of links
301  * when we're trying to free same link from both its sides. We don't have
302  * dangling links so this is not a problem from memory leaks point of view. */
303  for (Relation *rel : inlinks) {
304  delete rel;
305  }
306 }
307 
308 /* Generic identifier for Depsgraph Nodes. */
309 string Node::identifier() const
310 {
311  return string(nodeTypeAsString(type)) + " : " + name;
312 }
313 
315 {
316  if (type == NodeType::OPERATION) {
317  return NodeClass::OPERATION;
318  }
319  if (type < NodeType::PARAMETERS) {
320  return NodeClass::GENERIC;
321  }
322 
323  return NodeClass::COMPONENT;
324 }
325 
326 /*******************************************************************************
327  * Generic nodes definition.
328  */
329 
332 
335 
337 {
340 }
341 
342 } // namespace blender::deg
#define BLI_assert(a)
Definition: BLI_assert.h:58
static uint8 component(Color32 c, uint i)
Definition: ColorBlock.cpp:126
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_PROXY
@ 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
void reset()
clear internal cached data and reset random seed
void register_node_typeinfo(DepsNodeFactory *factory)
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
static DepsNodeFactoryImpl< IDNode > DNTI_ID_REF
Definition: deg_node.cc:334
static DepsNodeFactoryImpl< TimeSourceNode > DNTI_TIMESOURCE
Definition: deg_node.cc:331
const char * nodeClassAsString(NodeClass node_class)
Definition: deg_node.cc:41
NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component_type)
Definition: deg_node.cc:184
DEG_DEPSNODE_DEFINE(TimeSourceNode, NodeType::TIMESOURCE, "Time Source")
const char * nodeTypeAsString(NodeType type)
Definition: deg_node.cc:55
void deg_register_base_depsnodes()
Definition: deg_node.cc:336
TypeInfo(NodeType type, const char *type_name, int id_recalc_tag=0)
Definition: deg_node.cc:264
Relations inlinks
Definition: deg_node.h:175
virtual ~Node()
Definition: deg_node.cc:297
virtual string identifier() const
Definition: deg_node.cc:309
virtual NodeClass get_class() const
Definition: deg_node.cc:314