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/depsgraph_type_defines.cc
30 * Defines and code for core node types.
33 #include <cstdlib> // for BLI_assert()
36 #include "BLI_utildefines.h"
37 #include "BLI_ghash.h"
39 #include "DEG_depsgraph.h"
41 #include "intern/nodes/deg_node.h"
42 #include "intern/nodes/deg_node_component.h"
43 #include "intern/nodes/deg_node_operation.h"
45 #include "intern/depsgraph_intern.h"
52 /* Global type registry */
54 static DepsNodeFactory *depsnode_typeinfo_registry[NUM_DEG_NODE_TYPES] = {NULL};
56 /* Registration ------------------------------------------- */
58 /* Register node type */
59 void deg_register_node_typeinfo(DepsNodeFactory *factory)
61 BLI_assert(factory != NULL);
62 depsnode_typeinfo_registry[factory->type()] = factory;
65 /* Getters ------------------------------------------------- */
67 /* Get typeinfo for specified type */
68 DepsNodeFactory *deg_type_get_factory(const eDepsNode_Type type)
70 /* look up type - at worst, it doesn't exist in table yet, and we fail */
71 return depsnode_typeinfo_registry[type];
74 /* Stringified opcodes ------------------------------------- */
76 DepsOperationStringifier DEG_OPNAMES;
78 static const char *stringify_opcode(eDepsOperation_Code opcode)
81 #define STRINGIFY_OPCODE(name) case DEG_OPCODE_##name: return #name
82 /* Generic Operations. */
83 STRINGIFY_OPCODE(OPERATION);
84 STRINGIFY_OPCODE(PARAMETERS_EVAL);
85 STRINGIFY_OPCODE(PLACEHOLDER);
86 /* Animation, Drivers, etc. */
87 STRINGIFY_OPCODE(ANIMATION);
88 STRINGIFY_OPCODE(DRIVER);
90 STRINGIFY_OPCODE(OBJECT_BASE_FLAGS);
92 STRINGIFY_OPCODE(TRANSFORM_LOCAL);
93 STRINGIFY_OPCODE(TRANSFORM_PARENT);
94 STRINGIFY_OPCODE(TRANSFORM_CONSTRAINTS);
95 STRINGIFY_OPCODE(TRANSFORM_FINAL);
96 STRINGIFY_OPCODE(TRANSFORM_OBJECT_UBEREVAL);
98 STRINGIFY_OPCODE(RIGIDBODY_REBUILD);
99 STRINGIFY_OPCODE(RIGIDBODY_SIM);
100 STRINGIFY_OPCODE(RIGIDBODY_TRANSFORM_COPY);
102 STRINGIFY_OPCODE(GEOMETRY_UBEREVAL);
103 STRINGIFY_OPCODE(GEOMETRY_CLOTH_MODIFIER);
104 STRINGIFY_OPCODE(GEOMETRY_SHAPEKEY);
106 STRINGIFY_OPCODE(POSE_INIT);
107 STRINGIFY_OPCODE(POSE_INIT_IK);
108 STRINGIFY_OPCODE(POSE_DONE);
109 STRINGIFY_OPCODE(POSE_IK_SOLVER);
110 STRINGIFY_OPCODE(POSE_SPLINE_IK_SOLVER);
112 STRINGIFY_OPCODE(BONE_LOCAL);
113 STRINGIFY_OPCODE(BONE_POSE_PARENT);
114 STRINGIFY_OPCODE(BONE_CONSTRAINTS);
115 STRINGIFY_OPCODE(BONE_READY);
116 STRINGIFY_OPCODE(BONE_DONE);
118 STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL_INIT);
119 STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL);
120 STRINGIFY_OPCODE(PARTICLE_SETTINGS_EVAL);
121 STRINGIFY_OPCODE(PARTICLE_SETTINGS_RECALC_CLEAR);
123 STRINGIFY_OPCODE(GEOMETRY_SELECT_UPDATE);
125 STRINGIFY_OPCODE(MASK_ANIMATION);
126 STRINGIFY_OPCODE(MASK_EVAL);
128 STRINGIFY_OPCODE(VIEW_LAYER_INIT);
129 STRINGIFY_OPCODE(VIEW_LAYER_EVAL);
130 STRINGIFY_OPCODE(VIEW_LAYER_DONE);
132 STRINGIFY_OPCODE(COPY_ON_WRITE);
134 STRINGIFY_OPCODE(SHADING);
135 STRINGIFY_OPCODE(MATERIAL_UPDATE);
136 STRINGIFY_OPCODE(WORLD_UPDATE);
138 STRINGIFY_OPCODE(MOVIECLIP_EVAL);
140 case DEG_NUM_OPCODES: return "SpecialCase";
141 #undef STRINGIFY_OPCODE
146 DepsOperationStringifier::DepsOperationStringifier()
148 for (int i = 0; i < DEG_NUM_OPCODES; ++i) {
149 names_[i] = stringify_opcode((eDepsOperation_Code)i);
153 const char *DepsOperationStringifier::operator[](eDepsOperation_Code opcode)
155 BLI_assert((opcode >= 0) && (opcode < DEG_NUM_OPCODES));
156 if (opcode >= 0 && opcode < DEG_NUM_OPCODES) {
157 return names_[opcode];
159 return "UnknownOpcode";
164 /* Register all node types */
165 void DEG_register_node_types(void)
167 /* register node types */
168 DEG::deg_register_base_depsnodes();
169 DEG::deg_register_component_depsnodes();
170 DEG::deg_register_operation_depsnodes();
173 /* Free registry on exit */
174 void DEG_free_node_types(void)