Blender  V2.93
deg_node_id.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 "BLI_ghash.h"
27 #include "BLI_sys_types.h"
28 #include "DNA_ID.h"
29 #include "intern/node/deg_node.h"
30 
31 namespace blender {
32 namespace deg {
33 
34 struct ComponentNode;
35 
37 
38 /* NOTE: We use max comparison to mark an id node that is linked more than once
39  * So keep this enum ordered accordingly. */
41  /* Generic indirectly linked id node. */
43  /* Id node present in the set (background) only. */
45  /* Id node directly linked via the SceneLayer. */
47 };
48 const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state);
49 
50 /* ID-Block Reference */
51 struct IDNode : public Node {
52  struct ComponentIDKey {
53  ComponentIDKey(NodeType type, const char *name = "");
54  uint64_t hash() const;
55  bool operator==(const ComponentIDKey &other) const;
56 
58  const char *name;
59  };
60 
61  virtual void init(const ID *id, const char *subdata) override;
62  void init_copy_on_write(ID *id_cow_hint = nullptr);
63  ~IDNode();
64  void destroy();
65 
66  virtual string identifier() const override;
67 
68  ComponentNode *find_component(NodeType type, const char *name = "") const;
69  ComponentNode *add_component(NodeType type, const char *name = "");
70 
71  virtual void tag_update(Depsgraph *graph, eUpdateSource source) override;
72 
74 
76 
77  /* Type of the ID stored separately, so it's possible to perform check whether CoW is needed
78  * without de-referencing the id_cow (which is not safe when ID is NOT covered by CoW and has
79  * been deleted from the main database.) */
81 
82  /* ID Block referenced. */
84 
85  /* Session-wide UUID of the id_orig.
86  * Is used on relations update to map evaluated state from old nodes to the new ones, without
87  * relying on pointers (which are not guaranteed to be unique) and without dereferencing id_orig
88  * which could be "stale" pointer. */
90 
91  /* Evaluated data-block.
92  * Will be covered by the copy-on-write system if the ID Type needs it. */
94 
95  /* Hash to make it faster to look up components. */
97 
98  /* Additional flags needed for scene evaluation.
99  * TODO(sergey): Only needed for until really granular updates
100  * of all the entities. */
103 
104  /* Extra customdata mask which needs to be evaluated for the mesh object. */
107 
109 
110  /* Indicates the data-block is visible in the evaluated scene. */
112 
113  /* For the collection type of ID, denotes whether collection was fully
114  * recursed into. */
116 
117  /* Is used to figure out whether object came to the dependency graph via a base. */
118  bool has_base;
119 
120  /* Accumulated flag from operation. Is initialized and used during updates flush. */
122 
123  /* Accumulate recalc flags from multiple update passes. */
125 
128 
130 };
131 
132 } // namespace deg
133 } // namespace blender
unsigned int uint
Definition: BLI_sys_types.h:83
ID and Library types, which are fundamental for sdna.
ID_Type
Definition: DNA_ID_enums.h:56
Depsgraph * graph
const char * linkedStateAsString(eDepsNode_LinkedState_Type linked_state)
Definition: deg_node_id.cc:46
uint64_t IDComponentsMask
Definition: deg_node_id.h:34
eDepsNode_LinkedState_Type
Definition: deg_node_id.h:40
@ DEG_ID_LINKED_INDIRECTLY
Definition: deg_node_id.h:42
@ DEG_ID_LINKED_VIA_SET
Definition: deg_node_id.h:44
@ DEG_ID_LINKED_DIRECTLY
Definition: deg_node_id.h:46
unsigned int uint32_t
Definition: stdint.h:83
unsigned __int64 uint64_t
Definition: stdint.h:93
Definition: DNA_ID.h:273
bool operator==(const ComponentIDKey &other) const
Definition: deg_node_id.cc:64
ComponentIDKey(NodeType type, const char *name="")
Definition: deg_node_id.cc:60
IDComponentsMask previously_visible_components_mask
Definition: deg_node_id.h:127
void init_copy_on_write(ID *id_cow_hint=nullptr)
Definition: deg_node_id.cc:99
DEGCustomDataMeshMasks customdata_masks
Definition: deg_node_id.h:105
DEGCustomDataMeshMasks previous_customdata_masks
Definition: deg_node_id.h:106
ComponentNode * add_component(NodeType type, const char *name="")
Definition: deg_node_id.cc:168
virtual string identifier() const override
Definition: deg_node_id.cc:152
IDComponentsMask visible_components_mask
Definition: deg_node_id.h:126
bool is_collection_fully_expanded
Definition: deg_node_id.h:115
virtual void init(const ID *id, const char *subdata) override
Definition: deg_node_id.cc:77
Map< ComponentIDKey, ComponentNode * > components
Definition: deg_node_id.h:96
IDComponentsMask get_visible_components_mask() const
Definition: deg_node_id.cc:204
void finalize_build(Depsgraph *graph)
Definition: deg_node_id.cc:195
ComponentNode * find_component(NodeType type, const char *name="") const
Definition: deg_node_id.cc:162
eDepsNode_LinkedState_Type linked_state
Definition: deg_node_id.h:108
virtual void tag_update(Depsgraph *graph, eUpdateSource source) override
Definition: deg_node_id.cc:183
uint32_t previous_eval_flags
Definition: deg_node_id.h:102