2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2013 Blender Foundation.
19 * All rights reserved.
21 * Original Author: Joshua Leung
22 * Contributor(s): None Yet
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file blender/depsgraph/intern/node/deg_node.cc
31 #include "intern/node/deg_node.h"
35 #include "BLI_utildefines.h"
37 #include "intern/depsgraph.h"
38 #include "intern/eval/deg_eval_copy_on_write.h"
39 #include "intern/node/deg_node_component.h"
40 #include "intern/node/deg_node_factory.h"
41 #include "intern/node/deg_node_id.h"
42 #include "intern/node/deg_node_operation.h"
43 #include "intern/node/deg_node_time.h"
47 const char *nodeClassAsString(NodeClass node_class)
50 case NodeClass::GENERIC: return "GENERIC";
51 case NodeClass::COMPONENT: return "COMPONENT";
52 case NodeClass::OPERATION: return "OPERATION";
54 BLI_assert(!"Unhandled node class, should never happen.");
58 const char *nodeTypeAsString(NodeType type)
61 case NodeType::UNDEFINED: return "UNDEFINED";
62 case NodeType::OPERATION: return "OPERATION";
63 /* **** Generic Types **** */
64 case NodeType::TIMESOURCE: return "TIMESOURCE";
65 case NodeType::ID_REF: return "ID_REF";
66 /* **** Outer Types **** */
67 case NodeType::PARAMETERS: return "PARAMETERS";
68 case NodeType::PROXY: return "PROXY";
69 case NodeType::ANIMATION: return "ANIMATION";
70 case NodeType::TRANSFORM: return "TRANSFORM";
71 case NodeType::GEOMETRY: return "GEOMETRY";
72 case NodeType::SEQUENCER: return "SEQUENCER";
73 case NodeType::LAYER_COLLECTIONS: return "LAYER_COLLECTIONS";
74 case NodeType::COPY_ON_WRITE: return "COPY_ON_WRITE";
75 case NodeType::OBJECT_FROM_LAYER: return "OBJECT_FROM_LAYER";
76 /* **** Evaluation-Related Outer Types (with Subdata) **** */
77 case NodeType::EVAL_POSE: return "EVAL_POSE";
78 case NodeType::BONE: return "BONE";
79 case NodeType::PARTICLE_SYSTEM: return "PARTICLE_SYSTEM";
80 case NodeType::PARTICLE_SETTINGS: return "PARTICLE_SETTINGS";
81 case NodeType::SHADING: return "SHADING";
82 case NodeType::SHADING_PARAMETERS: return "SHADING_PARAMETERS";
83 case NodeType::CACHE: return "CACHE";
84 case NodeType::POINT_CACHE: return "POINT_CACHE";
85 case NodeType::BATCH_CACHE: return "BATCH_CACHE";
87 case NodeType::DUPLI: return "DUPLI";
88 /* Synchronization. */
89 case NodeType::SYNCHRONIZATION: return "SYNCHRONIZATION";
90 /* Generic datablock. */
91 case NodeType::GENERIC_DATABLOCK: return "GENERIC_DATABLOCK";
93 /* Total number of meaningful node types. */
94 case NodeType::NUM_TYPES: return "SpecialCase";
96 BLI_assert(!"Unhandled node type, should never happen.");
100 /*******************************************************************************
104 Node::TypeInfo::TypeInfo(NodeType type,
105 const char *type_name,
108 type_name(type_name),
109 id_recalc_tag(id_recalc_tag)
113 /*******************************************************************************
114 * Evaluation statistics.
122 void Node::Stats::reset()
127 void Node::Stats::reset_current()
132 /*******************************************************************************
144 /* NOTE: We only free incoming links. This is to avoid double-free of links
145 * when we're trying to free same link from both it's sides. We don't have
146 * dangling links so this is not a problem from memory leaks point of view. */
147 for (Relation *rel : inlinks) {
148 OBJECT_GUARDED_DELETE(rel, Relation);
153 /* Generic identifier for Depsgraph Nodes. */
154 string Node::identifier() const
156 return string(nodeTypeAsString(type)) + " : " + name;
159 NodeClass Node::get_class() const {
160 if (type == NodeType::OPERATION) {
161 return NodeClass::OPERATION;
163 else if (type < NodeType::PARAMETERS) {
164 return NodeClass::GENERIC;
167 return NodeClass::COMPONENT;
171 /*******************************************************************************
172 * Generic nodes definition.
175 DEG_DEPSNODE_DEFINE(TimeSourceNode, NodeType::TIMESOURCE, "Time Source");
176 static DepsNodeFactoryImpl<TimeSourceNode> DNTI_TIMESOURCE;
178 DEG_DEPSNODE_DEFINE(IDNode, NodeType::ID_REF, "ID Node");
179 static DepsNodeFactoryImpl<IDNode> DNTI_ID_REF;
181 void deg_register_base_depsnodes()
183 register_node_typeinfo(&DNTI_TIMESOURCE);
184 register_node_typeinfo(&DNTI_ID_REF);