Blender  V2.93
deg_node_component.h
Go to the documentation of this file.
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 
24 #pragma once
25 
26 #include "intern/node/deg_node.h"
28 
29 #include "BLI_string.h"
30 #include "BLI_utildefines.h"
31 
32 struct ID;
33 struct bPoseChannel;
34 
35 namespace blender {
36 namespace deg {
37 
38 struct BoneComponentNode;
39 struct Depsgraph;
40 struct IDNode;
41 struct OperationNode;
42 
43 /* ID Component - Base type for all components */
44 struct ComponentNode : public Node {
45  /* Key used to look up operations within a component */
46  struct OperationIDKey {
48  const char *name;
49  int name_tag;
50 
53  OperationIDKey(OperationCode opcode, const char *name, int name_tag);
54 
55  string identifier() const;
56  bool operator==(const OperationIDKey &other) const;
57  uint64_t hash() const;
58  };
59 
60  /* Typedef for container of operations */
61  ComponentNode();
63 
64  void init(const ID *id, const char *subdata) override;
65 
66  virtual string identifier() const override;
67 
68  /* Find an existing operation, if requested operation does not exist
69  * nullptr will be returned. */
71  OperationNode *find_operation(OperationCode opcode, const char *name, int name_tag) const;
72 
73  /* Find an existing operation, will throw an assert() if it does not exist. */
75  OperationNode *get_operation(OperationCode opcode, const char *name, int name_tag) const;
76 
77  /* Check operation exists and return it. */
78  bool has_operation(OperationIDKey key) const;
79  bool has_operation(OperationCode opcode, const char *name, int name_tag) const;
80 
91  OperationCode opcode,
92  const char *name,
93  int name_tag);
94 
95  /* Entry/exit operations management.
96  *
97  * Use those instead of direct set since this will perform sanity checks. */
98  void set_entry_operation(OperationNode *op_node);
99  void set_exit_operation(OperationNode *op_node);
100 
101  void clear_operations();
102 
103  virtual void tag_update(Depsgraph *graph, eUpdateSource source) override;
104 
105  virtual OperationNode *get_entry_operation() override;
106  virtual OperationNode *get_exit_operation() override;
107 
109 
111 
112  /* ** Inner nodes for this component ** */
113 
114  /* Operations stored as a hash map, for faster build.
115  * This hash map will be freed when graph is fully built. */
117 
118  /* This is a "normal" list of operations, used by evaluation
119  * and other routines after construction. */
121 
124 
125  virtual bool depends_on_cow()
126  {
127  return true;
128  }
129 
130  /* Denotes whether COW component is to be tagged when this component
131  * is tagged for update. */
133  {
134  return true;
135  }
136 
137  /* Denotes whether this component affects (possibly indirectly) on a
138  * directly visible object. */
140 };
141 
142 /* ---------------------------------------- */
143 
144 #define DEG_COMPONENT_NODE_DEFINE_TYPEINFO(NodeType, type_, type_name_, id_recalc_tag) \
145  const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, type_name_, id_recalc_tag)
146 
147 #define DEG_COMPONENT_NODE_DECLARE DEG_DEPSNODE_DECLARE
148 
149 #define DEG_COMPONENT_NODE_DEFINE(name, NAME, id_recalc_tag) \
150  DEG_COMPONENT_NODE_DEFINE_TYPEINFO( \
151  name##ComponentNode, NodeType::NAME, #name " Component", id_recalc_tag); \
152  static DepsNodeFactoryImpl<name##ComponentNode> DNTI_##NAME
153 
154 #define DEG_COMPONENT_NODE_DECLARE_GENERIC(name) \
155  struct name##ComponentNode : public ComponentNode { \
156  DEG_COMPONENT_NODE_DECLARE; \
157  }
158 
159 #define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \
160  struct name##ComponentNode : public ComponentNode { \
161  DEG_COMPONENT_NODE_DECLARE; \
162  virtual bool need_tag_cow_before_update() \
163  { \
164  return false; \
165  } \
166  }
167 
192 
193 /* Bone Component */
195  void init(const ID *id, const char *subdata);
196 
197  struct bPoseChannel *pchan; /* the bone that this component represents */
198 
200 };
201 
203 
204 } // namespace deg
205 } // namespace blender
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
Depsgraph * graph
DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation)
void deg_register_component_depsnodes()
DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache)
function< void(struct ::Depsgraph *)> DepsEvalOperationCb
unsigned __int64 uint64_t
Definition: stdint.h:93
Definition: DNA_ID.h:273
void init(const ID *id, const char *subdata)
bool operator==(const OperationIDKey &other) const
virtual bool need_tag_cow_before_update()
virtual OperationNode * get_entry_operation() override
OperationNode * get_operation(OperationIDKey key) const
void init(const ID *id, const char *subdata) override
virtual void tag_update(Depsgraph *graph, eUpdateSource source) override
Vector< OperationNode * > operations
OperationNode * find_operation(OperationIDKey key) const
OperationNode * add_operation(const DepsEvalOperationCb &op, OperationCode opcode, const char *name, int name_tag)
virtual OperationNode * get_exit_operation() override
bool has_operation(OperationIDKey key) const
void set_exit_operation(OperationNode *op_node)
void finalize_build(Depsgraph *graph)
virtual string identifier() const override
Map< ComponentNode::OperationIDKey, OperationNode * > * operations_map
void set_entry_operation(OperationNode *op_node)