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/node/deg_node_component.h
33 #include "intern/node/deg_node.h"
34 #include "intern/node/deg_node_operation.h"
36 #include "BLI_utildefines.h"
37 #include "BLI_string.h"
45 struct BoneComponentNode;
50 /* ID Component - Base type for all components */
51 struct ComponentNode : public Node {
52 /* Key used to look up operations within a component */
60 OperationIDKey(OperationCode opcode);
61 OperationIDKey(OperationCode opcode,
65 string identifier() const;
66 bool operator==(const OperationIDKey &other) const;
69 /* Typedef for container of operations */
73 void init(const ID *id, const char *subdata) override;
75 virtual string identifier() const override;
77 /* Find an existing operation, if requested operation does not exist
78 * NULL will be returned. */
79 OperationNode *find_operation(OperationIDKey key) const;
80 OperationNode *find_operation(OperationCode opcode,
84 /* Find an existing operation, will throw an assert() if it does not exist. */
85 OperationNode *get_operation(OperationIDKey key) const;
86 OperationNode *get_operation(OperationCode opcode,
90 /* Check operation exists and return it. */
91 bool has_operation(OperationIDKey key) const;
92 bool has_operation(OperationCode opcode,
97 * Create a new node for representing an operation and add this to graph
98 * \warning If an existing node is found, it will be modified. This helps
99 * when node may have been partially created earlier (e.g. parent ref before
100 * parent item is added)
102 * \param type: Operation node type (corresponding to context/component that
104 * \param optype: Role that operation plays within component
105 * (i.e. where in eval process)
106 * \param op: The operation to perform
107 * \param name: Identifier for operation - used to find/locate it again */
108 OperationNode *add_operation(const DepsEvalOperationCb& op,
109 OperationCode opcode,
113 /* Entry/exit operations management.
115 * Use those instead of direct set since this will perform sanity checks. */
116 void set_entry_operation(OperationNode *op_node);
117 void set_exit_operation(OperationNode *op_node);
119 void clear_operations();
121 virtual void tag_update(Depsgraph *graph, eUpdateSource source) override;
123 virtual OperationNode *get_entry_operation() override;
124 virtual OperationNode *get_exit_operation() override;
126 void finalize_build(Depsgraph *graph);
130 /* ** Inner nodes for this component ** */
132 /* Operations stored as a hash map, for faster build.
133 * This hash map will be freed when graph is fully built. */
134 GHash *operations_map;
136 /* This is a "normal" list of operations, used by evaluation
137 * and other routines after construction. */
138 vector<OperationNode *> operations;
140 OperationNode *entry_operation;
141 OperationNode *exit_operation;
143 virtual bool depends_on_cow() { return true; }
145 /* Denotes whether COW component is to be tagged when this component
146 * is tagged for update. */
147 virtual bool need_tag_cow_before_update() { return true; }
149 /* Denotes whether this component affects (possibly indirectly) on a
150 * directly visible object. */
151 bool affects_directly_visible;
154 /* ---------------------------------------- */
156 #define DEG_COMPONENT_NODE_DEFINE_TYPEINFO(\
157 NodeType, type_, type_name_, id_recalc_tag) \
158 const Node::TypeInfo NodeType::typeinfo = \
159 Node::TypeInfo(type_, type_name_, id_recalc_tag)
161 #define DEG_COMPONENT_NODE_DECLARE DEG_DEPSNODE_DECLARE
163 #define DEG_COMPONENT_NODE_DEFINE(name, NAME, id_recalc_tag) \
164 DEG_COMPONENT_NODE_DEFINE_TYPEINFO(name ## ComponentNode, \
166 #name " Component", \
168 static DepsNodeFactoryImpl<name ## ComponentNode> DNTI_ ## NAME
170 #define DEG_COMPONENT_NODE_DECLARE_GENERIC(name) \
171 struct name ## ComponentNode : public ComponentNode { \
172 DEG_COMPONENT_NODE_DECLARE; \
175 #define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \
176 struct name ## ComponentNode : public ComponentNode { \
177 DEG_COMPONENT_NODE_DECLARE; \
178 virtual bool need_tag_cow_before_update() { return false; } \
181 DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation);
182 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache);
183 DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache);
184 DEG_COMPONENT_NODE_DECLARE_GENERIC(CopyOnWrite);
185 DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry);
186 DEG_COMPONENT_NODE_DECLARE_GENERIC(LayerCollections);
187 DEG_COMPONENT_NODE_DECLARE_GENERIC(Parameters);
188 DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles);
189 DEG_COMPONENT_NODE_DECLARE_GENERIC(ParticleSettings);
190 DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose);
191 DEG_COMPONENT_NODE_DECLARE_GENERIC(PointCache);
192 DEG_COMPONENT_NODE_DECLARE_GENERIC(Proxy);
193 DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer);
194 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Shading);
195 DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters);
196 DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
197 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
198 DEG_COMPONENT_NODE_DECLARE_GENERIC(Dupli);
199 DEG_COMPONENT_NODE_DECLARE_GENERIC(Synchronize);
200 DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock);
203 struct BoneComponentNode : public ComponentNode {
204 void init(const ID *id, const char *subdata);
206 struct bPoseChannel *pchan; /* the bone that this component represents */
208 DEG_COMPONENT_NODE_DECLARE;
211 void deg_register_component_depsnodes();