4edf616961cef9d373a4ace30d721c04fa891a66
[blender.git] / source / blender / depsgraph / intern / depsgraph_type_defines.cc
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
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.
8  *
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.
13  *
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.
17  *
18  * The Original Code is Copyright (C) 2013 Blender Foundation.
19  * All rights reserved.
20  *
21  * Original Author: Joshua Leung
22  * Contributor(s): None Yet
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/depsgraph/intern/depsgraph_type_defines.cc
28  *  \ingroup depsgraph
29  *
30  * Defines and code for core node types.
31  */
32
33 #include <cstdlib>  // for BLI_assert()
34
35
36 #include "BLI_utildefines.h"
37 #include "BLI_ghash.h"
38
39 #include "DEG_depsgraph.h"
40
41 #include "intern/nodes/deg_node.h"
42 #include "intern/nodes/deg_node_component.h"
43 #include "intern/nodes/deg_node_operation.h"
44
45 #include "intern/depsgraph_intern.h"
46
47 namespace DEG {
48
49 /* ************ */
50 /* External API */
51
52 /* Global type registry */
53
54 static DepsNodeFactory *depsnode_typeinfo_registry[NUM_DEG_NODE_TYPES] = {NULL};
55
56 /* Registration ------------------------------------------- */
57
58 /* Register node type */
59 void deg_register_node_typeinfo(DepsNodeFactory *factory)
60 {
61         BLI_assert(factory != NULL);
62         depsnode_typeinfo_registry[factory->type()] = factory;
63 }
64
65 /* Getters ------------------------------------------------- */
66
67 /* Get typeinfo for specified type */
68 DepsNodeFactory *deg_type_get_factory(const eDepsNode_Type type)
69 {
70         /* look up type - at worst, it doesn't exist in table yet, and we fail */
71         return depsnode_typeinfo_registry[type];
72 }
73
74 /* Stringified node types ---------------------------------- */
75
76 const char *nodeTypeAsString(eDepsNode_Type type)
77 {
78         switch (type) {
79 #define STRINGIFY_TYPE(name) case DEG_NODE_TYPE_##name: return #name
80
81                 STRINGIFY_TYPE(UNDEFINED);
82                 STRINGIFY_TYPE(OPERATION);
83                 /* **** Generic Types **** */
84                 STRINGIFY_TYPE(TIMESOURCE);
85                 STRINGIFY_TYPE(ID_REF);
86                 /* **** Outer Types **** */
87                 STRINGIFY_TYPE(PARAMETERS);
88                 STRINGIFY_TYPE(PROXY);
89                 STRINGIFY_TYPE(ANIMATION);
90                 STRINGIFY_TYPE(TRANSFORM);
91                 STRINGIFY_TYPE(GEOMETRY);
92                 STRINGIFY_TYPE(SEQUENCER);
93                 STRINGIFY_TYPE(LAYER_COLLECTIONS);
94                 STRINGIFY_TYPE(COPY_ON_WRITE);
95                 STRINGIFY_TYPE(OBJECT_FROM_LAYER);
96                 /* **** Evaluation-Related Outer Types (with Subdata) **** */
97                 STRINGIFY_TYPE(EVAL_POSE);
98                 STRINGIFY_TYPE(BONE);
99                 STRINGIFY_TYPE(EVAL_PARTICLES);
100                 STRINGIFY_TYPE(SHADING);
101                 STRINGIFY_TYPE(SHADING_PARAMETERS);
102                 STRINGIFY_TYPE(CACHE);
103                 STRINGIFY_TYPE(POINT_CACHE);
104                 STRINGIFY_TYPE(BATCH_CACHE);
105                 /* Duplication. */
106                 STRINGIFY_TYPE(DUPLI);
107                 /* Synchronization. */
108                 STRINGIFY_TYPE(SYNCHRONIZE);
109                 /* Generic datablock. */
110                 STRINGIFY_TYPE(GENERIC_DATABLOCK);
111
112                 /* Total number of meaningful node types. */
113                 case NUM_DEG_NODE_TYPES: return "SpecialCase";
114 #undef STRINGIFY_TYPE
115         }
116         return "UNKNOWN";
117 }
118
119 /* Stringified opcodes ------------------------------------- */
120
121 const char *operationCodeAsString(eDepsOperation_Code opcode)
122 {
123         switch (opcode) {
124 #define STRINGIFY_OPCODE(name) case DEG_OPCODE_##name: return #name
125                 /* Generic Operations. */
126                 STRINGIFY_OPCODE(OPERATION);
127                 STRINGIFY_OPCODE(ID_PROPERTY);
128                 STRINGIFY_OPCODE(PARAMETERS_EVAL);
129                 STRINGIFY_OPCODE(PLACEHOLDER);
130                 /* Animation, Drivers, etc. */
131                 STRINGIFY_OPCODE(ANIMATION);
132                 STRINGIFY_OPCODE(DRIVER);
133                 /* Object related. */
134                 STRINGIFY_OPCODE(OBJECT_BASE_FLAGS);
135                 /* Transform. */
136                 STRINGIFY_OPCODE(TRANSFORM_LOCAL);
137                 STRINGIFY_OPCODE(TRANSFORM_PARENT);
138                 STRINGIFY_OPCODE(TRANSFORM_CONSTRAINTS);
139                 STRINGIFY_OPCODE(TRANSFORM_FINAL);
140                 STRINGIFY_OPCODE(TRANSFORM_OBJECT_UBEREVAL);
141                 /* Rigid body. */
142                 STRINGIFY_OPCODE(RIGIDBODY_REBUILD);
143                 STRINGIFY_OPCODE(RIGIDBODY_SIM);
144                 STRINGIFY_OPCODE(RIGIDBODY_TRANSFORM_COPY);
145                 /* Geometry. */
146                 STRINGIFY_OPCODE(GEOMETRY_UBEREVAL);
147                 STRINGIFY_OPCODE(GEOMETRY_SHAPEKEY);
148                 /* Object data. */
149                 STRINGIFY_OPCODE(LIGHT_PROBE_EVAL);
150                 STRINGIFY_OPCODE(SPEAKER_EVAL);
151                 /* Pose. */
152                 STRINGIFY_OPCODE(POSE_INIT);
153                 STRINGIFY_OPCODE(POSE_INIT_IK);
154                 STRINGIFY_OPCODE(POSE_CLEANUP);
155                 STRINGIFY_OPCODE(POSE_DONE);
156                 STRINGIFY_OPCODE(POSE_IK_SOLVER);
157                 STRINGIFY_OPCODE(POSE_SPLINE_IK_SOLVER);
158                 /* Bone. */
159                 STRINGIFY_OPCODE(BONE_LOCAL);
160                 STRINGIFY_OPCODE(BONE_POSE_PARENT);
161                 STRINGIFY_OPCODE(BONE_CONSTRAINTS);
162                 STRINGIFY_OPCODE(BONE_READY);
163                 STRINGIFY_OPCODE(BONE_DONE);
164                 STRINGIFY_OPCODE(BONE_SEGMENTS);
165                 /* Particles. */
166                 STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL_INIT);
167                 STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL);
168                 STRINGIFY_OPCODE(PARTICLE_SETTINGS_EVAL);
169                 /* Point Cache. */
170                 STRINGIFY_OPCODE(POINT_CACHE_RESET);
171                 /* Batch cache. */
172                 STRINGIFY_OPCODE(GEOMETRY_SELECT_UPDATE);
173                 /* Masks. */
174                 STRINGIFY_OPCODE(MASK_ANIMATION);
175                 STRINGIFY_OPCODE(MASK_EVAL);
176                 /* Collections. */
177                 STRINGIFY_OPCODE(VIEW_LAYER_EVAL);
178                 /* Copy on write. */
179                 STRINGIFY_OPCODE(COPY_ON_WRITE);
180                 /* Shading. */
181                 STRINGIFY_OPCODE(SHADING);
182                 STRINGIFY_OPCODE(MATERIAL_UPDATE);
183                 STRINGIFY_OPCODE(WORLD_UPDATE);
184                 /* Movie clip. */
185                 STRINGIFY_OPCODE(MOVIECLIP_EVAL);
186                 STRINGIFY_OPCODE(MOVIECLIP_SELECT_UPDATE);
187                 /* Synchronization. */
188                 STRINGIFY_OPCODE(SYNCHRONIZE_TO_ORIGINAL);
189                 /* Generic datablock. */
190                 STRINGIFY_OPCODE(GENERIC_DATABLOCK_UPDATE);
191
192                 case DEG_NUM_OPCODES: return "SpecialCase";
193 #undef STRINGIFY_OPCODE
194         }
195         return "UNKNOWN";
196 }
197
198 }  // namespace DEG
199
200 /* Register all node types */
201 void DEG_register_node_types(void)
202 {
203         /* register node types */
204         DEG::deg_register_base_depsnodes();
205         DEG::deg_register_component_depsnodes();
206         DEG::deg_register_operation_depsnodes();
207 }
208
209 /* Free registry on exit */
210 void DEG_free_node_types(void)
211 {
212 }