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.
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.
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.
16 * The Original Code is Copyright (C) 2013 Blender Foundation.
17 * All rights reserved.
20 /** \file blender/depsgraph/intern/node/deg_node.cc
24 #include "intern/node/deg_node.h"
28 #include "BLI_utildefines.h"
30 #include "intern/depsgraph.h"
31 #include "intern/eval/deg_eval_copy_on_write.h"
32 #include "intern/node/deg_node_component.h"
33 #include "intern/node/deg_node_factory.h"
34 #include "intern/node/deg_node_id.h"
35 #include "intern/node/deg_node_operation.h"
36 #include "intern/node/deg_node_time.h"
40 const char *nodeClassAsString(NodeClass node_class)
43 case NodeClass::GENERIC: return "GENERIC";
44 case NodeClass::COMPONENT: return "COMPONENT";
45 case NodeClass::OPERATION: return "OPERATION";
47 BLI_assert(!"Unhandled node class, should never happen.");
51 const char *nodeTypeAsString(NodeType type)
54 case NodeType::UNDEFINED: return "UNDEFINED";
55 case NodeType::OPERATION: return "OPERATION";
56 /* **** Generic Types **** */
57 case NodeType::TIMESOURCE: return "TIMESOURCE";
58 case NodeType::ID_REF: return "ID_REF";
59 /* **** Outer Types **** */
60 case NodeType::PARAMETERS: return "PARAMETERS";
61 case NodeType::PROXY: return "PROXY";
62 case NodeType::ANIMATION: return "ANIMATION";
63 case NodeType::TRANSFORM: return "TRANSFORM";
64 case NodeType::GEOMETRY: return "GEOMETRY";
65 case NodeType::SEQUENCER: return "SEQUENCER";
66 case NodeType::LAYER_COLLECTIONS: return "LAYER_COLLECTIONS";
67 case NodeType::COPY_ON_WRITE: return "COPY_ON_WRITE";
68 case NodeType::OBJECT_FROM_LAYER: return "OBJECT_FROM_LAYER";
69 /* **** Evaluation-Related Outer Types (with Subdata) **** */
70 case NodeType::EVAL_POSE: return "EVAL_POSE";
71 case NodeType::BONE: return "BONE";
72 case NodeType::PARTICLE_SYSTEM: return "PARTICLE_SYSTEM";
73 case NodeType::PARTICLE_SETTINGS: return "PARTICLE_SETTINGS";
74 case NodeType::SHADING: return "SHADING";
75 case NodeType::SHADING_PARAMETERS: return "SHADING_PARAMETERS";
76 case NodeType::CACHE: return "CACHE";
77 case NodeType::POINT_CACHE: return "POINT_CACHE";
78 case NodeType::BATCH_CACHE: return "BATCH_CACHE";
80 case NodeType::DUPLI: return "DUPLI";
81 /* Synchronization. */
82 case NodeType::SYNCHRONIZATION: return "SYNCHRONIZATION";
83 /* Generic datablock. */
84 case NodeType::GENERIC_DATABLOCK: return "GENERIC_DATABLOCK";
86 /* Total number of meaningful node types. */
87 case NodeType::NUM_TYPES: return "SpecialCase";
89 BLI_assert(!"Unhandled node type, should never happen.");
93 /*******************************************************************************
97 Node::TypeInfo::TypeInfo(NodeType type,
98 const char *type_name,
101 type_name(type_name),
102 id_recalc_tag(id_recalc_tag)
106 /*******************************************************************************
107 * Evaluation statistics.
115 void Node::Stats::reset()
120 void Node::Stats::reset_current()
125 /*******************************************************************************
137 /* NOTE: We only free incoming links. This is to avoid double-free of links
138 * when we're trying to free same link from both it's sides. We don't have
139 * dangling links so this is not a problem from memory leaks point of view. */
140 for (Relation *rel : inlinks) {
141 OBJECT_GUARDED_DELETE(rel, Relation);
146 /* Generic identifier for Depsgraph Nodes. */
147 string Node::identifier() const
149 return string(nodeTypeAsString(type)) + " : " + name;
152 NodeClass Node::get_class() const {
153 if (type == NodeType::OPERATION) {
154 return NodeClass::OPERATION;
156 else if (type < NodeType::PARAMETERS) {
157 return NodeClass::GENERIC;
160 return NodeClass::COMPONENT;
164 /*******************************************************************************
165 * Generic nodes definition.
168 DEG_DEPSNODE_DEFINE(TimeSourceNode, NodeType::TIMESOURCE, "Time Source");
169 static DepsNodeFactoryImpl<TimeSourceNode> DNTI_TIMESOURCE;
171 DEG_DEPSNODE_DEFINE(IDNode, NodeType::ID_REF, "ID Node");
172 static DepsNodeFactoryImpl<IDNode> DNTI_ID_REF;
174 void deg_register_base_depsnodes()
176 register_node_typeinfo(&DNTI_TIMESOURCE);
177 register_node_typeinfo(&DNTI_ID_REF);