Blender V4.3
deg_node.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <cstdio>
12
13#include "BLI_utildefines.h"
14
15#include "intern/depsgraph.hh"
23
24namespace blender::deg {
25
26const char *nodeClassAsString(NodeClass node_class)
27{
28 switch (node_class) {
30 return "GENERIC";
32 return "COMPONENT";
34 return "OPERATION";
35 }
36 BLI_assert_msg(0, "Unhandled node class, should never happen.");
37 return "UNKNOWN";
38}
39
40const char *nodeTypeAsString(NodeType type)
41{
42 switch (type) {
44 return "UNDEFINED";
46 return "OPERATION";
47 /* **** Generic Types **** */
49 return "TIMESOURCE";
51 return "ID_REF";
52 /* **** Outer Types **** */
54 return "PARAMETERS";
56 return "ANIMATION";
58 return "TRANSFORM";
60 return "GEOMETRY";
62 return "SEQUENCER";
64 return "LAYER_COLLECTIONS";
66 return "COPY_ON_EVAL";
68 return "OBJECT_FROM_LAYER";
70 return "HIERARCHY";
71 /* **** Evaluation-Related Outer Types (with Sub-data) **** */
73 return "EVAL_POSE";
74 case NodeType::BONE:
75 return "BONE";
77 return "PARTICLE_SYSTEM";
79 return "PARTICLE_SETTINGS";
81 return "SHADING";
82 case NodeType::CACHE:
83 return "CACHE";
85 return "POINT_CACHE";
87 return "IMAGE_ANIMATION";
89 return "BATCH_CACHE";
91 return "INSTANCING";
93 return "SYNCHRONIZATION";
94 case NodeType::AUDIO:
95 return "AUDIO";
97 return "ARMATURE";
99 return "GENERIC_DATABLOCK";
100 case NodeType::SCENE:
101 return "SCENE";
103 return "VISIBILITY";
105 return "NTREE_OUTPUT";
107 return "NTREE_GEOMETRY_PREPROCESS";
108
109 /* Total number of meaningful node types. */
111 return "SpecialCase";
112 }
113 BLI_assert_msg(0, "Unhandled node type, should never happen.");
114 return "UNKNOWN";
115}
116
129
131{
132 switch (type) {
139
142 case NodeType::ID_REF:
147 case NodeType::AUDIO:
150 case NodeType::SCENE:
163 case NodeType::BONE:
165 case NodeType::CACHE:
169
171 BLI_assert_msg(0, "Visibility component is supposed to be only used internally.");
173 }
174 BLI_assert_msg(0, "Unhandled node type, not supposed to happen.");
176}
177
179{
180 switch (component_type) {
181 case DEG_OB_COMP_ANY:
182 return NodeType::UNDEFINED;
186 return NodeType::ANIMATION;
188 return NodeType::TRANSFORM;
190 return NodeType::GEOMETRY;
192 return NodeType::EVAL_POSE;
193 case DEG_OB_COMP_BONE:
194 return NodeType::BONE;
196 return NodeType::SHADING;
198 return NodeType::CACHE;
199 }
200 return NodeType::UNDEFINED;
201}
202
204{
205 switch (type) {
216 case NodeType::BONE:
217 return DEG_OB_COMP_BONE;
219 return DEG_OB_COMP_SHADING;
220 case NodeType::CACHE:
221 return DEG_OB_COMP_CACHE;
222
225 case NodeType::ID_REF:
231 case NodeType::AUDIO:
234 case NodeType::SCENE:
247
249 BLI_assert_msg(0, "Visibility component is supposed to be only used internally.");
251 }
252 BLI_assert_msg(0, "Unhandled node type, not suppsed to happen.");
254}
255
256/*******************************************************************************
257 * Type information.
258 */
259
260Node::TypeInfo::TypeInfo(NodeType type, const char *type_name, int id_recalc_tag)
261 : type(type), type_name(type_name), id_recalc_tag(id_recalc_tag)
262{
263}
264
265/*******************************************************************************
266 * Evaluation statistics.
267 */
268
270{
271 reset();
272}
273
275{
276 current_time = 0.0;
277}
278
280{
281 current_time = 0.0;
282}
283
284/*******************************************************************************
285 * Node itself.
286 */
287
289{
290 name = "";
291}
292
294{
295 /* Free links. */
296 /* NOTE: We only free incoming links. This is to avoid double-free of links
297 * when we're trying to free same link from both its sides. We don't have
298 * dangling links so this is not a problem from memory leaks point of view. */
299 for (Relation *rel : inlinks) {
300 delete rel;
301 }
302}
303
304string Node::identifier() const
305{
306 return string(nodeTypeAsString(type)) + " : " + name;
307}
308
310{
311 if (type == NodeType::OPERATION) {
313 }
314 if (type < NodeType::PARAMETERS) {
315 return NodeClass::GENERIC;
316 }
317
319}
320
321/*******************************************************************************
322 * Generic nodes definition.
323 */
324
327
330
336
337} // namespace blender::deg
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
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
void reset()
clear internal cached data and reset random seed
#define DEG_DEPSNODE_DEFINE(NodeType, type_, tname_)
Definition deg_node.hh:217
void register_node_typeinfo(DepsNodeFactory *factory)
eDepsObjectComponentType nodeTypeToObjectComponent(NodeType type)
Definition deg_node.cc:203
NodeType nodeTypeFromSceneComponent(eDepsSceneComponentType component)
Definition deg_node.cc:117
eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type)
Definition deg_node.cc:130
static DepsNodeFactoryImpl< IDNode > DNTI_ID_REF
Definition deg_node.cc:329
static DepsNodeFactoryImpl< TimeSourceNode > DNTI_TIMESOURCE
Definition deg_node.cc:326
const char * nodeClassAsString(NodeClass node_class)
Definition deg_node.cc:26
NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component_type)
Definition deg_node.cc:178
const char * nodeTypeAsString(NodeType type)
Definition deg_node.cc:40
void deg_register_base_depsnodes()
Definition deg_node.cc:331
TypeInfo(NodeType type, const char *type_name, int id_recalc_tag=0)
Definition deg_node.cc:260
Relations inlinks
Definition deg_node.hh:180
virtual string identifier() const
Definition deg_node.cc:304
virtual NodeClass get_class() const
Definition deg_node.cc:309