Blender  V2.93
deg_builder_rna.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) 2019 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "intern/node/deg_node.h"
28 
29 struct ID;
30 struct PointerRNA;
31 struct PropertyRNA;
32 
33 namespace blender {
34 namespace deg {
35 
36 struct Depsgraph;
37 struct Node;
38 class RNANodeQueryIDData;
39 class DepsgraphBuilder;
40 
41 /* For queries which gives operation node or key defines whether we are
42  * interested in a result of the given property or whether we are linking some
43  * dependency to that property. */
44 enum class RNAPointerSource {
45  /* Query will return pointer to an entry operation of component which is
46  * responsible for evaluation of the given property. */
47  ENTRY,
48  /* Query will return pointer to an exit operation of component which is
49  * responsible for evaluation of the given property.
50  * More precisely, it will return operation at which the property is known
51  * to be evaluated. */
52  EXIT,
53 };
54 
55 /* A helper structure which wraps all fields needed to find a node inside of
56  * the dependency graph. */
58  public:
60 
61  /* Check whether this identifier is valid and usable. */
62  bool is_valid() const;
63 
64  ID *id;
66  const char *component_name;
68  const char *operation_name;
70 };
71 
72 /* Helper class which performs optimized lookups of a node within a given
73  * dependency graph which satisfies given RNA pointer or RAN path. */
74 class RNANodeQuery {
75  public:
78 
79  Node *find_node(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source);
80 
81  protected:
84 
85  /* Indexed by an ID, returns RNANodeQueryIDData associated with that ID. */
87 
88  /* Construct identifier of the node which corresponds given configuration
89  * of RNA property. */
91  const PropertyRNA *prop,
92  RNAPointerSource source);
93 
94  /* Make sure ID data exists for the given ID, and returns it. */
96 
97  /* Check whether prop_identifier contains rna_path_component.
98  *
99  * This checks more than a sub-string:
100  *
101  * prop_identifier contains(prop_identifier, "location")
102  * ------------------------ -------------------------------------
103  * location true
104  * ["test_location"] false
105  * pose["bone"].location true
106  * pose["bone"].location.x true
107  */
108  static bool contains(const char *prop_identifier, const char *rna_path_component);
109 };
110 
111 } // namespace deg
112 } // namespace blender
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
Node * find_node(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source)
RNANodeIdentifier construct_node_identifier(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source)
static bool contains(const char *prop_identifier, const char *rna_path_component)
DepsgraphBuilder * builder_
RNANodeQuery(Depsgraph *depsgraph, DepsgraphBuilder *builder)
RNANodeQueryIDData * ensure_id_data(const ID *id)
Map< const ID *, unique_ptr< RNANodeQueryIDData > > id_data_map_
const Depsgraph * depsgraph
Definition: DNA_ID.h:273
Definition: node.h:98
PointerRNA * ptr
Definition: wm_files.c:3157