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_operation.cc
26 #include "intern/node/deg_node_operation.h"
28 #include "MEM_guardedalloc.h"
30 #include "BLI_utildefines.h"
31 #include "BLI_ghash.h"
33 #include "intern/depsgraph.h"
34 #include "intern/node/deg_node_factory.h"
35 #include "intern/node/deg_node_component.h"
36 #include "intern/node/deg_node_id.h"
40 const char *operationCodeAsString(OperationCode opcode)
43 /* Generic Operations. */
44 case OperationCode::OPERATION: return "OPERATION";
45 case OperationCode::ID_PROPERTY: return "ID_PROPERTY";
46 case OperationCode::PARAMETERS_EVAL: return "PARAMETERS_EVAL";
47 case OperationCode::PLACEHOLDER: return "PLACEHOLDER";
48 /* Animation, Drivers, etc. */
49 case OperationCode::ANIMATION: return "ANIMATION";
50 case OperationCode::DRIVER: return "DRIVER";
52 case OperationCode::OBJECT_BASE_FLAGS: return "OBJECT_BASE_FLAGS";
54 case OperationCode::TRANSFORM_LOCAL: return "TRANSFORM_LOCAL";
55 case OperationCode::TRANSFORM_PARENT: return "TRANSFORM_PARENT";
56 case OperationCode::TRANSFORM_CONSTRAINTS:
57 return "TRANSFORM_CONSTRAINTS";
58 case OperationCode::TRANSFORM_FINAL: return "TRANSFORM_FINAL";
59 case OperationCode::TRANSFORM_OBJECT_UBEREVAL:
60 return "TRANSFORM_OBJECT_UBEREVAL";
62 case OperationCode::RIGIDBODY_REBUILD: return "RIGIDBODY_REBUILD";
63 case OperationCode::RIGIDBODY_SIM: return "RIGIDBODY_SIM";
64 case OperationCode::RIGIDBODY_TRANSFORM_COPY:
65 return "RIGIDBODY_TRANSFORM_COPY";
67 case OperationCode::GEOMETRY_EVAL_INIT: return "GEOMETRY_EVAL_INIT";
68 case OperationCode::GEOMETRY_EVAL: return "GEOMETRY_EVAL";
69 case OperationCode::GEOMETRY_EVAL_DONE: return "GEOMETRY_EVAL_DONE";
70 case OperationCode::GEOMETRY_SHAPEKEY: return "GEOMETRY_SHAPEKEY";
72 case OperationCode::LIGHT_PROBE_EVAL: return "LIGHT_PROBE_EVAL";
73 case OperationCode::SPEAKER_EVAL: return "SPEAKER_EVAL";
75 case OperationCode::POSE_INIT: return "POSE_INIT";
76 case OperationCode::POSE_INIT_IK: return "POSE_INIT_IK";
77 case OperationCode::POSE_CLEANUP: return "POSE_CLEANUP";
78 case OperationCode::POSE_DONE: return "POSE_DONE";
79 case OperationCode::POSE_IK_SOLVER: return "POSE_IK_SOLVER";
80 case OperationCode::POSE_SPLINE_IK_SOLVER:
81 return "POSE_SPLINE_IK_SOLVER";
83 case OperationCode::BONE_LOCAL: return "BONE_LOCAL";
84 case OperationCode::BONE_POSE_PARENT: return "BONE_POSE_PARENT";
85 case OperationCode::BONE_CONSTRAINTS: return "BONE_CONSTRAINTS";
86 case OperationCode::BONE_READY: return "BONE_READY";
87 case OperationCode::BONE_DONE: return "BONE_DONE";
88 case OperationCode::BONE_SEGMENTS: return "BONE_SEGMENTS";
89 /* Particle System. */
90 case OperationCode::PARTICLE_SYSTEM_INIT: return "PARTICLE_SYSTEM_INIT";
91 case OperationCode::PARTICLE_SYSTEM_EVAL: return "PARTICLE_SYSTEM_EVAL";
92 case OperationCode::PARTICLE_SYSTEM_DONE: return "PARTICLE_SYSTEM_DONE";
93 /* Particles Settings. */
94 case OperationCode::PARTICLE_SETTINGS_INIT:
95 return "PARTICLE_SETTINGS_INIT";
96 case OperationCode::PARTICLE_SETTINGS_EVAL:
97 return "PARTICLE_SETTINGS_EVAL";
98 case OperationCode::PARTICLE_SETTINGS_RESET:
99 return "PARTICLE_SETTINGS_RESET";
101 case OperationCode::POINT_CACHE_RESET: return "POINT_CACHE_RESET";
103 case OperationCode::GEOMETRY_SELECT_UPDATE:
104 return "GEOMETRY_SELECT_UPDATE";
106 case OperationCode::MASK_ANIMATION: return "MASK_ANIMATION";
107 case OperationCode::MASK_EVAL: return "MASK_EVAL";
109 case OperationCode::VIEW_LAYER_EVAL: return "VIEW_LAYER_EVAL";
111 case OperationCode::COPY_ON_WRITE: return "COPY_ON_WRITE";
113 case OperationCode::SHADING: return "SHADING";
114 case OperationCode::MATERIAL_UPDATE: return "MATERIAL_UPDATE";
115 case OperationCode::WORLD_UPDATE: return "WORLD_UPDATE";
117 case OperationCode::MOVIECLIP_EVAL: return "MOVIECLIP_EVAL";
118 case OperationCode::MOVIECLIP_SELECT_UPDATE:
119 return "MOVIECLIP_SELECT_UPDATE";
120 /* Synchronization. */
121 case OperationCode::SYNCHRONIZE_TO_ORIGINAL:
122 return "SYNCHRONIZE_TO_ORIGINAL";
123 /* Generic datablock. */
124 case OperationCode::GENERIC_DATABLOCK_UPDATE:
125 return "GENERIC_DATABLOCK_UPDATE";
126 /* instancing/duplication. */
127 case OperationCode::DUPLI: return "DUPLI";
129 BLI_assert(!"Unhandled operation code, should never happen.");
133 OperationNode::OperationNode() :
139 OperationNode::~OperationNode()
143 string OperationNode::identifier() const
145 return string(operationCodeAsString(opcode)) + "(" + name + ")";
148 /* Full node identifier, including owner name.
149 * used for logging and debug prints. */
150 string OperationNode::full_identifier() const
152 string owner_str = "";
153 if (owner->type == NodeType::BONE) {
154 owner_str = string(owner->owner->name) + "." + owner->name;
157 owner_str = owner->owner->name;
159 return owner_str + "." + identifier();
162 void OperationNode::tag_update(Depsgraph *graph, eUpdateSource source)
164 if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) {
165 graph->add_entry_tag(this);
167 /* Tag for update, but also note that this was the source of an update. */
168 flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED);
170 case DEG_UPDATE_SOURCE_TIME:
171 case DEG_UPDATE_SOURCE_RELATIONS:
172 case DEG_UPDATE_SOURCE_VISIBILITY:
173 /* Currently nothing. */
175 case DEG_UPDATE_SOURCE_USER_EDIT:
176 flag |= DEPSOP_FLAG_USER_MODIFIED;
181 void OperationNode::set_as_entry()
183 BLI_assert(owner != NULL);
184 owner->set_entry_operation(this);
187 void OperationNode::set_as_exit()
189 BLI_assert(owner != NULL);
190 owner->set_exit_operation(this);
193 DEG_DEPSNODE_DEFINE(OperationNode, NodeType::OPERATION, "Operation");
194 static DepsNodeFactoryImpl<OperationNode> DNTI_OPERATION;
196 void deg_register_operation_depsnodes()
198 register_node_typeinfo(&DNTI_OPERATION);