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.
20 /** \file blender/depsgraph/intern/node/deg_node_component.h
26 #include "intern/node/deg_node.h"
27 #include "intern/node/deg_node_operation.h"
29 #include "BLI_utildefines.h"
30 #include "BLI_string.h"
38 struct BoneComponentNode;
43 /* ID Component - Base type for all components */
44 struct ComponentNode : public Node {
45 /* Key used to look up operations within a component */
53 OperationIDKey(OperationCode opcode);
54 OperationIDKey(OperationCode opcode,
58 string identifier() const;
59 bool operator==(const OperationIDKey &other) const;
62 /* Typedef for container of operations */
66 void init(const ID *id, const char *subdata) override;
68 virtual string identifier() const override;
70 /* Find an existing operation, if requested operation does not exist
71 * NULL will be returned. */
72 OperationNode *find_operation(OperationIDKey key) const;
73 OperationNode *find_operation(OperationCode opcode,
77 /* Find an existing operation, will throw an assert() if it does not exist. */
78 OperationNode *get_operation(OperationIDKey key) const;
79 OperationNode *get_operation(OperationCode opcode,
83 /* Check operation exists and return it. */
84 bool has_operation(OperationIDKey key) const;
85 bool has_operation(OperationCode opcode,
90 * Create a new node for representing an operation and add this to graph
91 * \warning If an existing node is found, it will be modified. This helps
92 * when node may have been partially created earlier (e.g. parent ref before
93 * parent item is added)
95 * \param type: Operation node type (corresponding to context/component that
97 * \param optype: Role that operation plays within component
98 * (i.e. where in eval process)
99 * \param op: The operation to perform
100 * \param name: Identifier for operation - used to find/locate it again */
101 OperationNode *add_operation(const DepsEvalOperationCb& op,
102 OperationCode opcode,
106 /* Entry/exit operations management.
108 * Use those instead of direct set since this will perform sanity checks. */
109 void set_entry_operation(OperationNode *op_node);
110 void set_exit_operation(OperationNode *op_node);
112 void clear_operations();
114 virtual void tag_update(Depsgraph *graph, eUpdateSource source) override;
116 virtual OperationNode *get_entry_operation() override;
117 virtual OperationNode *get_exit_operation() override;
119 void finalize_build(Depsgraph *graph);
123 /* ** Inner nodes for this component ** */
125 /* Operations stored as a hash map, for faster build.
126 * This hash map will be freed when graph is fully built. */
127 GHash *operations_map;
129 /* This is a "normal" list of operations, used by evaluation
130 * and other routines after construction. */
131 vector<OperationNode *> operations;
133 OperationNode *entry_operation;
134 OperationNode *exit_operation;
136 virtual bool depends_on_cow() { return true; }
138 /* Denotes whether COW component is to be tagged when this component
139 * is tagged for update. */
140 virtual bool need_tag_cow_before_update() { return true; }
142 /* Denotes whether this component affects (possibly indirectly) on a
143 * directly visible object. */
144 bool affects_directly_visible;
147 /* ---------------------------------------- */
149 #define DEG_COMPONENT_NODE_DEFINE_TYPEINFO(\
150 NodeType, type_, type_name_, id_recalc_tag) \
151 const Node::TypeInfo NodeType::typeinfo = \
152 Node::TypeInfo(type_, type_name_, id_recalc_tag)
154 #define DEG_COMPONENT_NODE_DECLARE DEG_DEPSNODE_DECLARE
156 #define DEG_COMPONENT_NODE_DEFINE(name, NAME, id_recalc_tag) \
157 DEG_COMPONENT_NODE_DEFINE_TYPEINFO(name ## ComponentNode, \
159 #name " Component", \
161 static DepsNodeFactoryImpl<name ## ComponentNode> DNTI_ ## NAME
163 #define DEG_COMPONENT_NODE_DECLARE_GENERIC(name) \
164 struct name ## ComponentNode : public ComponentNode { \
165 DEG_COMPONENT_NODE_DECLARE; \
168 #define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \
169 struct name ## ComponentNode : public ComponentNode { \
170 DEG_COMPONENT_NODE_DECLARE; \
171 virtual bool need_tag_cow_before_update() { return false; } \
174 DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation);
175 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache);
176 DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache);
177 DEG_COMPONENT_NODE_DECLARE_GENERIC(CopyOnWrite);
178 DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry);
179 DEG_COMPONENT_NODE_DECLARE_GENERIC(LayerCollections);
180 DEG_COMPONENT_NODE_DECLARE_GENERIC(Parameters);
181 DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles);
182 DEG_COMPONENT_NODE_DECLARE_GENERIC(ParticleSettings);
183 DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose);
184 DEG_COMPONENT_NODE_DECLARE_GENERIC(PointCache);
185 DEG_COMPONENT_NODE_DECLARE_GENERIC(Proxy);
186 DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer);
187 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Shading);
188 DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters);
189 DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
190 DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
191 DEG_COMPONENT_NODE_DECLARE_GENERIC(Dupli);
192 DEG_COMPONENT_NODE_DECLARE_GENERIC(Synchronization);
193 DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock);
196 struct BoneComponentNode : public ComponentNode {
197 void init(const ID *id, const char *subdata);
199 struct bPoseChannel *pchan; /* the bone that this component represents */
201 DEG_COMPONENT_NODE_DECLARE;
204 void deg_register_component_depsnodes();