Blender V5.3
deg_builder_cache.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "DNA_anim_types.h"
12
13#include "BKE_anim_data.hh"
14
15#include "RNA_access.hh"
16#include "RNA_path.hh"
17
18namespace blender::deg {
19
20/* Animated property storage. */
21
23
29
35
36AnimatedPropertyID::AnimatedPropertyID(const ID *id, StructRNA *type, const char *property_name)
37 : data(id)
38{
39 property_rna = RNA_struct_type_find_property(type, property_name);
40}
41
43 StructRNA *type,
44 void *data,
45 const char *property_name)
46 : data(data)
47{
48 property_rna = RNA_struct_type_find_property(type, property_name);
49}
50
52{
53 return a.data == b.data && a.property_rna == b.property_rna;
54}
55
57{
58 uintptr_t ptr1 = uintptr_t(data);
60 return uint64_t(((ptr1 >> 4) * 33) ^ (ptr2 >> 4));
61}
62
64
66{
67 PointerRNA own_pointer_rna = RNA_id_pointer_create(const_cast<ID *>(id));
68 BKE_fcurves_id_cb(const_cast<ID *>(id), [&](ID * /*id*/, FCurve *fcurve) {
69 const StringRefNull rna_path = fcurve->rna_path();
70 if (rna_path.is_empty()) {
71 return;
72 }
73 /* Resolve property. */
74 PointerRNA pointer_rna;
75 PropertyRNA *property_rna = nullptr;
77 &own_pointer_rna, rna_path.c_str(), &pointer_rna, &property_rna))
78 {
79 return;
80 }
81 /* Get storage for the ID.
82 * This is needed to deal with cases when nested datablock is animated by its parent. */
83 AnimatedPropertyStorage *animated_property_storage = this;
84 if (pointer_rna.owner_id != own_pointer_rna.owner_id) {
85 animated_property_storage = builder_cache->ensureAnimatedPropertyStorage(
86 pointer_rna.owner_id);
87 }
88 /* Set the property as animated. */
89 animated_property_storage->tagPropertyAsAnimated(&pointer_rna, property_rna);
90 });
91}
92
98
100 const PropertyRNA *property_rna)
101{
102 tagPropertyAsAnimated(AnimatedPropertyID(pointer_rna, property_rna));
103}
104
106{
107 return animated_properties_set.contains(property_id);
108}
109
111 const PropertyRNA *property_rna)
112{
113 return isPropertyAnimated(AnimatedPropertyID(pointer_rna, property_rna));
114}
115
117{
118 return animated_objects_set.contains(pointer_rna->data);
119}
120
121/* Builder cache itself. */
122
124{
125 for (AnimatedPropertyStorage *animated_property_storage :
127 {
128 delete animated_property_storage;
129 }
130}
131
137
139 const ID *id)
140{
141 AnimatedPropertyStorage *animated_property_storage = ensureAnimatedPropertyStorage(id);
142 if (!animated_property_storage->is_fully_initialized) {
143 animated_property_storage->initializeFromID(this, id);
144 animated_property_storage->is_fully_initialized = true;
145 }
146 return animated_property_storage;
147}
148
149} // namespace blender::deg
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b)
Set< AnimatedPropertyID > animated_properties_set
void initializeFromID(DepsgraphBuilderCache *builder_cache, const ID *id)
bool isAnyPropertyAnimated(const PointerRNA *pointer_rna)
bool isPropertyAnimated(const AnimatedPropertyID &property_id)
void tagPropertyAsAnimated(const AnimatedPropertyID &property_id)
Map< const ID *, AnimatedPropertyStorage * > animated_property_storage_map_
AnimatedPropertyStorage * ensureInitializedAnimatedPropertyStorage(const ID *id)
AnimatedPropertyStorage * ensureAnimatedPropertyStorage(const ID *id)
unsigned __int64 uint64_t
Definition BKE_text.h:91
PointerRNA RNA_id_pointer_create(ID *id)
void BKE_fcurves_id_cb(struct ID *id, FunctionRef< void(ID *, FCurve *)> func)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
_W64 unsigned int uintptr_t
Definition BKE_text.h:120
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:578