Cleanup: remove redundant doxygen \file argument
[blender.git] / source / blender / depsgraph / intern / node / deg_node_operation.cc
1 /*
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.
6  *
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.
11  *
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.
15  *
16  * The Original Code is Copyright (C) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file \ingroup depsgraph
21  */
22
23 #include "intern/node/deg_node_operation.h"
24
25 #include "MEM_guardedalloc.h"
26
27 #include "BLI_utildefines.h"
28 #include "BLI_ghash.h"
29
30 #include "intern/depsgraph.h"
31 #include "intern/node/deg_node_factory.h"
32 #include "intern/node/deg_node_component.h"
33 #include "intern/node/deg_node_id.h"
34
35 namespace DEG {
36
37 const char *operationCodeAsString(OperationCode opcode)
38 {
39         switch (opcode) {
40                 /* Generic Operations. */
41                 case OperationCode::OPERATION: return "OPERATION";
42                 case OperationCode::ID_PROPERTY: return "ID_PROPERTY";
43                 case OperationCode::PARAMETERS_EVAL: return "PARAMETERS_EVAL";
44                 /* Animation, Drivers, etc. */
45                 case OperationCode::ANIMATION: return "ANIMATION";
46                 case OperationCode::DRIVER: return "DRIVER";
47                 /* Scene related. */
48                 case OperationCode::SCENE_EVAL: return "SCENE_EVAL";
49                 /* Object related. */
50                 case OperationCode::OBJECT_BASE_FLAGS: return "OBJECT_BASE_FLAGS";
51                 /* Transform. */
52                 case OperationCode::TRANSFORM_LOCAL: return "TRANSFORM_LOCAL";
53                 case OperationCode::TRANSFORM_PARENT: return "TRANSFORM_PARENT";
54                 case OperationCode::TRANSFORM_CONSTRAINTS:
55                         return "TRANSFORM_CONSTRAINTS";
56                 case OperationCode::TRANSFORM_FINAL: return "TRANSFORM_FINAL";
57                 case OperationCode::TRANSFORM_OBJECT_UBEREVAL:
58                         return "TRANSFORM_OBJECT_UBEREVAL";
59                 /* Rigid body. */
60                 case OperationCode::RIGIDBODY_REBUILD: return "RIGIDBODY_REBUILD";
61                 case OperationCode::RIGIDBODY_SIM: return "RIGIDBODY_SIM";
62                 case OperationCode::RIGIDBODY_TRANSFORM_COPY:
63                         return "RIGIDBODY_TRANSFORM_COPY";
64                 /* Geometry. */
65                 case OperationCode::GEOMETRY_EVAL_INIT: return "GEOMETRY_EVAL_INIT";
66                 case OperationCode::GEOMETRY_EVAL: return "GEOMETRY_EVAL";
67                 case OperationCode::GEOMETRY_EVAL_DONE: return "GEOMETRY_EVAL_DONE";
68                 case OperationCode::GEOMETRY_SHAPEKEY: return "GEOMETRY_SHAPEKEY";
69                 /* Object data. */
70                 case OperationCode::LIGHT_PROBE_EVAL: return "LIGHT_PROBE_EVAL";
71                 case OperationCode::SPEAKER_EVAL: return "SPEAKER_EVAL";
72                 case OperationCode::ARMATURE_EVAL: return "ARMATURE_EVAL";
73                 /* Pose. */
74                 case OperationCode::POSE_INIT: return "POSE_INIT";
75                 case OperationCode::POSE_INIT_IK: return "POSE_INIT_IK";
76                 case OperationCode::POSE_CLEANUP: return "POSE_CLEANUP";
77                 case OperationCode::POSE_DONE: return "POSE_DONE";
78                 case OperationCode::POSE_IK_SOLVER: return "POSE_IK_SOLVER";
79                 case OperationCode::POSE_SPLINE_IK_SOLVER:
80                         return "POSE_SPLINE_IK_SOLVER";
81                 /* Bone. */
82                 case OperationCode::BONE_LOCAL: return "BONE_LOCAL";
83                 case OperationCode::BONE_POSE_PARENT: return "BONE_POSE_PARENT";
84                 case OperationCode::BONE_CONSTRAINTS: return "BONE_CONSTRAINTS";
85                 case OperationCode::BONE_READY: return "BONE_READY";
86                 case OperationCode::BONE_DONE: return "BONE_DONE";
87                 case OperationCode::BONE_SEGMENTS: return "BONE_SEGMENTS";
88                 /* Particle System. */
89                 case OperationCode::PARTICLE_SYSTEM_INIT: return "PARTICLE_SYSTEM_INIT";
90                 case OperationCode::PARTICLE_SYSTEM_EVAL: return "PARTICLE_SYSTEM_EVAL";
91                 case OperationCode::PARTICLE_SYSTEM_DONE: return "PARTICLE_SYSTEM_DONE";
92                 /* Particles Settings. */
93                 case OperationCode::PARTICLE_SETTINGS_INIT:
94                         return "PARTICLE_SETTINGS_INIT";
95                 case OperationCode::PARTICLE_SETTINGS_EVAL:
96                         return "PARTICLE_SETTINGS_EVAL";
97                 case OperationCode::PARTICLE_SETTINGS_RESET:
98                         return "PARTICLE_SETTINGS_RESET";
99                 /* Point Cache. */
100                 case OperationCode::POINT_CACHE_RESET: return "POINT_CACHE_RESET";
101                 /* File cache. */
102                 case OperationCode::FILE_CACHE_UPDATE: return "FILE_CACHE_UPDATE";
103                 /* Batch cache. */
104                 case OperationCode::GEOMETRY_SELECT_UPDATE:
105                         return "GEOMETRY_SELECT_UPDATE";
106                 /* Masks. */
107                 case OperationCode::MASK_ANIMATION: return "MASK_ANIMATION";
108                 case OperationCode::MASK_EVAL: return "MASK_EVAL";
109                 /* Collections. */
110                 case OperationCode::VIEW_LAYER_EVAL: return "VIEW_LAYER_EVAL";
111                 /* Copy on write. */
112                 case OperationCode::COPY_ON_WRITE: return "COPY_ON_WRITE";
113                 /* Shading. */
114                 case OperationCode::SHADING: return "SHADING";
115                 case OperationCode::MATERIAL_UPDATE: return "MATERIAL_UPDATE";
116                 case OperationCode::WORLD_UPDATE: return "WORLD_UPDATE";
117                 /* Movie clip. */
118                 case OperationCode::MOVIECLIP_EVAL: return "MOVIECLIP_EVAL";
119                 case OperationCode::MOVIECLIP_SELECT_UPDATE:
120                         return "MOVIECLIP_SELECT_UPDATE";
121                 /* Synchronization. */
122                 case OperationCode::SYNCHRONIZE_TO_ORIGINAL:
123                         return "SYNCHRONIZE_TO_ORIGINAL";
124                 /* Generic datablock. */
125                 case OperationCode::GENERIC_DATABLOCK_UPDATE:
126                         return "GENERIC_DATABLOCK_UPDATE";
127                 /* instancing/duplication. */
128                 case OperationCode::DUPLI: return "DUPLI";
129         }
130         BLI_assert(!"Unhandled operation code, should never happen.");
131         return "UNKNOWN";
132 }
133
134 OperationNode::OperationNode() :
135     name_tag(-1),
136     flag(0)
137 {
138 }
139
140 OperationNode::~OperationNode()
141 {
142 }
143
144 string OperationNode::identifier() const
145 {
146         return string(operationCodeAsString(opcode)) + "(" + name + ")";
147 }
148
149 /* Full node identifier, including owner name.
150  * used for logging and debug prints. */
151 string OperationNode::full_identifier() const
152 {
153         string owner_str = "";
154         if (owner->type == NodeType::BONE) {
155                 owner_str = string(owner->owner->name) + "." + owner->name;
156         }
157         else {
158                 owner_str = owner->owner->name;
159         }
160         return owner_str + "." + identifier();
161 }
162
163 void OperationNode::tag_update(Depsgraph *graph, eUpdateSource source)
164 {
165         if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) {
166                 graph->add_entry_tag(this);
167         }
168         /* Tag for update, but also note that this was the source of an update. */
169         flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED);
170         switch (source) {
171                 case DEG_UPDATE_SOURCE_TIME:
172                 case DEG_UPDATE_SOURCE_RELATIONS:
173                 case DEG_UPDATE_SOURCE_VISIBILITY:
174                         /* Currently nothing. */
175                         break;
176                 case DEG_UPDATE_SOURCE_USER_EDIT:
177                         flag |= DEPSOP_FLAG_USER_MODIFIED;
178                         break;
179         }
180 }
181
182 void OperationNode::set_as_entry()
183 {
184         BLI_assert(owner != NULL);
185         owner->set_entry_operation(this);
186 }
187
188 void OperationNode::set_as_exit()
189 {
190         BLI_assert(owner != NULL);
191         owner->set_exit_operation(this);
192 }
193
194 DEG_DEPSNODE_DEFINE(OperationNode, NodeType::OPERATION, "Operation");
195 static DepsNodeFactoryImpl<OperationNode> DNTI_OPERATION;
196
197 void deg_register_operation_depsnodes()
198 {
199         register_node_typeinfo(&DNTI_OPERATION);
200 }
201
202 }  // namespace DEG