Depsgraph: More clear name for geometry evaluation
[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  * Original Author: Joshua Leung
20  */
21
22 /** \file blender/depsgraph/intern/node/deg_node_operation.cc
23  *  \ingroup depsgraph
24  */
25
26 #include "intern/node/deg_node_operation.h"
27
28 #include "MEM_guardedalloc.h"
29
30 #include "BLI_utildefines.h"
31 #include "BLI_ghash.h"
32
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"
37
38 namespace DEG {
39
40 const char *operationCodeAsString(OperationCode opcode)
41 {
42         switch (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";
51                 /* Object related. */
52                 case OperationCode::OBJECT_BASE_FLAGS: return "OBJECT_BASE_FLAGS";
53                 /* Transform. */
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";
61                 /* Rigid body. */
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";
66                 /* Geometry. */
67                 case OperationCode::GEOMETRY_EVAL: return "GEOMETRY_EVAL";
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                 /* Pose. */
73                 case OperationCode::POSE_INIT: return "POSE_INIT";
74                 case OperationCode::POSE_INIT_IK: return "POSE_INIT_IK";
75                 case OperationCode::POSE_CLEANUP: return "POSE_CLEANUP";
76                 case OperationCode::POSE_DONE: return "POSE_DONE";
77                 case OperationCode::POSE_IK_SOLVER: return "POSE_IK_SOLVER";
78                 case OperationCode::POSE_SPLINE_IK_SOLVER:
79                         return "POSE_SPLINE_IK_SOLVER";
80                 /* Bone. */
81                 case OperationCode::BONE_LOCAL: return "BONE_LOCAL";
82                 case OperationCode::BONE_POSE_PARENT: return "BONE_POSE_PARENT";
83                 case OperationCode::BONE_CONSTRAINTS: return "BONE_CONSTRAINTS";
84                 case OperationCode::BONE_READY: return "BONE_READY";
85                 case OperationCode::BONE_DONE: return "BONE_DONE";
86                 case OperationCode::BONE_SEGMENTS: return "BONE_SEGMENTS";
87                 /* Particle System. */
88                 case OperationCode::PARTICLE_SYSTEM_INIT: return "PARTICLE_SYSTEM_INIT";
89                 case OperationCode::PARTICLE_SYSTEM_EVAL: return "PARTICLE_SYSTEM_EVAL";
90                 case OperationCode::PARTICLE_SYSTEM_DONE: return "PARTICLE_SYSTEM_DONE";
91                 /* Particles Settings. */
92                 case OperationCode::PARTICLE_SETTINGS_INIT:
93                         return "PARTICLE_SETTINGS_INIT";
94                 case OperationCode::PARTICLE_SETTINGS_EVAL:
95                         return "PARTICLE_SETTINGS_EVAL";
96                 case OperationCode::PARTICLE_SETTINGS_RESET:
97                         return "PARTICLE_SETTINGS_RESET";
98                 /* Point Cache. */
99                 case OperationCode::POINT_CACHE_RESET: return "POINT_CACHE_RESET";
100                 /* Batch cache. */
101                 case OperationCode::GEOMETRY_SELECT_UPDATE:
102                         return "GEOMETRY_SELECT_UPDATE";
103                 /* Masks. */
104                 case OperationCode::MASK_ANIMATION: return "MASK_ANIMATION";
105                 case OperationCode::MASK_EVAL: return "MASK_EVAL";
106                 /* Collections. */
107                 case OperationCode::VIEW_LAYER_EVAL: return "VIEW_LAYER_EVAL";
108                 /* Copy on write. */
109                 case OperationCode::COPY_ON_WRITE: return "COPY_ON_WRITE";
110                 /* Shading. */
111                 case OperationCode::SHADING: return "SHADING";
112                 case OperationCode::MATERIAL_UPDATE: return "MATERIAL_UPDATE";
113                 case OperationCode::WORLD_UPDATE: return "WORLD_UPDATE";
114                 /* Movie clip. */
115                 case OperationCode::MOVIECLIP_EVAL: return "MOVIECLIP_EVAL";
116                 case OperationCode::MOVIECLIP_SELECT_UPDATE:
117                         return "MOVIECLIP_SELECT_UPDATE";
118                 /* Synchronization. */
119                 case OperationCode::SYNCHRONIZE_TO_ORIGINAL:
120                         return "SYNCHRONIZE_TO_ORIGINAL";
121                 /* Generic datablock. */
122                 case OperationCode::GENERIC_DATABLOCK_UPDATE:
123                         return "GENERIC_DATABLOCK_UPDATE";
124         }
125         BLI_assert(!"Unhandled operation code, should never happen.");
126         return "UNKNOWN";
127 }
128
129 OperationNode::OperationNode() :
130     name_tag(-1),
131     flag(0)
132 {
133 }
134
135 OperationNode::~OperationNode()
136 {
137 }
138
139 string OperationNode::identifier() const
140 {
141         return string(operationCodeAsString(opcode)) + "(" + name + ")";
142 }
143
144 /* Full node identifier, including owner name.
145  * used for logging and debug prints. */
146 string OperationNode::full_identifier() const
147 {
148         string owner_str = "";
149         if (owner->type == NodeType::BONE) {
150                 owner_str = string(owner->owner->name) + "." + owner->name;
151         }
152         else {
153                 owner_str = owner->owner->name;
154         }
155         return owner_str + "." + identifier();
156 }
157
158 void OperationNode::tag_update(Depsgraph *graph, eUpdateSource source)
159 {
160         if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) {
161                 graph->add_entry_tag(this);
162         }
163         /* Tag for update, but also note that this was the source of an update. */
164         flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED);
165         switch (source) {
166                 case DEG_UPDATE_SOURCE_TIME:
167                 case DEG_UPDATE_SOURCE_RELATIONS:
168                 case DEG_UPDATE_SOURCE_VISIBILITY:
169                         /* Currently nothing. */
170                         break;
171                 case DEG_UPDATE_SOURCE_USER_EDIT:
172                         flag |= DEPSOP_FLAG_USER_MODIFIED;
173                         break;
174         }
175 }
176
177 void OperationNode::set_as_entry()
178 {
179         BLI_assert(owner != NULL);
180         owner->set_entry_operation(this);
181 }
182
183 void OperationNode::set_as_exit()
184 {
185         BLI_assert(owner != NULL);
186         owner->set_exit_operation(this);
187 }
188
189 DEG_DEPSNODE_DEFINE(OperationNode, NodeType::OPERATION, "Operation");
190 static DepsNodeFactoryImpl<OperationNode> DNTI_OPERATION;
191
192 void deg_register_operation_depsnodes()
193 {
194         register_node_typeinfo(&DNTI_OPERATION);
195 }
196
197 }  // namespace DEG