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.
19 * Original Author: Joshua Leung
22 /** \file blender/depsgraph/intern/node/deg_node.cc
26 #include "intern/node/deg_node.h"
30 #include "BLI_utildefines.h"
32 #include "intern/depsgraph.h"
33 #include "intern/eval/deg_eval_copy_on_write.h"
34 #include "intern/node/deg_node_component.h"
35 #include "intern/node/deg_node_factory.h"
36 #include "intern/node/deg_node_id.h"
37 #include "intern/node/deg_node_operation.h"
38 #include "intern/node/deg_node_time.h"
42 const char *nodeClassAsString(NodeClass node_class)
45 case NodeClass::GENERIC: return "GENERIC";
46 case NodeClass::COMPONENT: return "COMPONENT";
47 case NodeClass::OPERATION: return "OPERATION";
49 BLI_assert(!"Unhandled node class, should never happen.");
53 const char *nodeTypeAsString(NodeType type)
56 case NodeType::UNDEFINED: return "UNDEFINED";
57 case NodeType::OPERATION: return "OPERATION";
58 /* **** Generic Types **** */
59 case NodeType::TIMESOURCE: return "TIMESOURCE";
60 case NodeType::ID_REF: return "ID_REF";
61 /* **** Outer Types **** */
62 case NodeType::PARAMETERS: return "PARAMETERS";
63 case NodeType::PROXY: return "PROXY";
64 case NodeType::ANIMATION: return "ANIMATION";
65 case NodeType::TRANSFORM: return "TRANSFORM";
66 case NodeType::GEOMETRY: return "GEOMETRY";
67 case NodeType::SEQUENCER: return "SEQUENCER";
68 case NodeType::LAYER_COLLECTIONS: return "LAYER_COLLECTIONS";
69 case NodeType::COPY_ON_WRITE: return "COPY_ON_WRITE";
70 case NodeType::OBJECT_FROM_LAYER: return "OBJECT_FROM_LAYER";
71 /* **** Evaluation-Related Outer Types (with Subdata) **** */
72 case NodeType::EVAL_POSE: return "EVAL_POSE";
73 case NodeType::BONE: return "BONE";
74 case NodeType::PARTICLE_SYSTEM: return "PARTICLE_SYSTEM";
75 case NodeType::PARTICLE_SETTINGS: return "PARTICLE_SETTINGS";
76 case NodeType::SHADING: return "SHADING";
77 case NodeType::SHADING_PARAMETERS: return "SHADING_PARAMETERS";
78 case NodeType::CACHE: return "CACHE";
79 case NodeType::POINT_CACHE: return "POINT_CACHE";
80 case NodeType::BATCH_CACHE: return "BATCH_CACHE";
82 case NodeType::DUPLI: return "DUPLI";
83 /* Synchronization. */
84 case NodeType::SYNCHRONIZATION: return "SYNCHRONIZATION";
85 /* Generic datablock. */
86 case NodeType::GENERIC_DATABLOCK: return "GENERIC_DATABLOCK";
88 /* Total number of meaningful node types. */
89 case NodeType::NUM_TYPES: return "SpecialCase";
91 BLI_assert(!"Unhandled node type, should never happen.");
95 /*******************************************************************************
99 Node::TypeInfo::TypeInfo(NodeType type,
100 const char *type_name,
103 type_name(type_name),
104 id_recalc_tag(id_recalc_tag)
108 /*******************************************************************************
109 * Evaluation statistics.
117 void Node::Stats::reset()
122 void Node::Stats::reset_current()
127 /*******************************************************************************
139 /* NOTE: We only free incoming links. This is to avoid double-free of links
140 * when we're trying to free same link from both it's sides. We don't have
141 * dangling links so this is not a problem from memory leaks point of view. */
142 for (Relation *rel : inlinks) {
143 OBJECT_GUARDED_DELETE(rel, Relation);
148 /* Generic identifier for Depsgraph Nodes. */
149 string Node::identifier() const
151 return string(nodeTypeAsString(type)) + " : " + name;
154 NodeClass Node::get_class() const {
155 if (type == NodeType::OPERATION) {
156 return NodeClass::OPERATION;
158 else if (type < NodeType::PARAMETERS) {
159 return NodeClass::GENERIC;
162 return NodeClass::COMPONENT;
166 /*******************************************************************************
167 * Generic nodes definition.
170 DEG_DEPSNODE_DEFINE(TimeSourceNode, NodeType::TIMESOURCE, "Time Source");
171 static DepsNodeFactoryImpl<TimeSourceNode> DNTI_TIMESOURCE;
173 DEG_DEPSNODE_DEFINE(IDNode, NodeType::ID_REF, "ID Node");
174 static DepsNodeFactoryImpl<IDNode> DNTI_ID_REF;
176 void deg_register_base_depsnodes()
178 register_node_typeinfo(&DNTI_TIMESOURCE);
179 register_node_typeinfo(&DNTI_ID_REF);