Blender V4.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
10
11#include "MEM_guardedalloc.h"
12
13#include "DNA_anim_types.h"
14
15#include "BLI_utildefines.h"
16
17#include "BKE_anim_data.hh"
18
19#include "RNA_path.hh"
20
21namespace blender::deg {
22
23/* Animated property storage. */
24
25AnimatedPropertyID::AnimatedPropertyID() : data(nullptr), property_rna(nullptr) {}
26
28 const PropertyRNA *property_rna)
29 : AnimatedPropertyID(*pointer_rna, property_rna)
30{
31}
32
34 const PropertyRNA *property_rna)
35 : data(pointer_rna.data), property_rna(property_rna)
36{
37}
38
39AnimatedPropertyID::AnimatedPropertyID(const ID *id, StructRNA *type, const char *property_name)
40 : data(id)
41{
42 property_rna = RNA_struct_type_find_property(type, property_name);
43}
44
46 StructRNA *type,
47 void *data,
48 const char *property_name)
49 : data(data)
50{
51 property_rna = RNA_struct_type_find_property(type, property_name);
52}
53
55{
56 return a.data == b.data && a.property_rna == b.property_rna;
57}
58
60{
61 uintptr_t ptr1 = uintptr_t(data);
63 return uint64_t(((ptr1 >> 4) * 33) ^ (ptr2 >> 4));
64}
65
67
69{
70 PointerRNA own_pointer_rna = RNA_id_pointer_create(const_cast<ID *>(id));
71 BKE_fcurves_id_cb(const_cast<ID *>(id), [&](ID * /*id*/, FCurve *fcurve) {
72 if (fcurve->rna_path == nullptr || fcurve->rna_path[0] == '\0') {
73 return;
74 }
75 /* Resolve property. */
76 PointerRNA pointer_rna;
77 PropertyRNA *property_rna = nullptr;
79 &own_pointer_rna, fcurve->rna_path, &pointer_rna, &property_rna))
80 {
81 return;
82 }
83 /* Get storage for the ID.
84 * This is needed to deal with cases when nested datablock is animated by its parent. */
85 AnimatedPropertyStorage *animated_property_storage = this;
86 if (pointer_rna.owner_id != own_pointer_rna.owner_id) {
87 animated_property_storage = builder_cache->ensureAnimatedPropertyStorage(
88 pointer_rna.owner_id);
89 }
90 /* Set the property as animated. */
91 animated_property_storage->tagPropertyAsAnimated(&pointer_rna, property_rna);
92 });
93}
94
100
102 const PropertyRNA *property_rna)
103{
104 tagPropertyAsAnimated(AnimatedPropertyID(pointer_rna, property_rna));
105}
106
108{
109 return animated_properties_set.contains(property_id);
110}
111
113 const PropertyRNA *property_rna)
114{
115 return isPropertyAnimated(AnimatedPropertyID(pointer_rna, property_rna));
116}
117
119{
120 return animated_objects_set.contains(pointer_rna->data);
121}
122
123/* Builder cache itself. */
124
126{
127 for (AnimatedPropertyStorage *animated_property_storage :
129 {
130 delete animated_property_storage;
131 }
132}
133
139
141 const ID *id)
142{
143 AnimatedPropertyStorage *animated_property_storage = ensureAnimatedPropertyStorage(id);
144 if (!animated_property_storage->is_fully_initialized) {
145 animated_property_storage->initializeFromID(this, id);
146 animated_property_storage->is_fully_initialized = true;
147 }
148 return animated_property_storage;
149}
150
151} // namespace blender::deg
void BKE_fcurves_id_cb(struct ID *id, blender::FunctionRef< void(ID *, FCurve *)> func)
Read Guarded memory(de)allocation.
bool contains(const Key &key) const
Definition BLI_set.hh:291
bool add(const Key &key)
Definition BLI_set.hh:248
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)
local_group_size(16, 16) .push_constant(Type b
bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
PointerRNA RNA_id_pointer_create(ID *id)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:553
_W64 unsigned int uintptr_t
Definition stdint.h:119
unsigned __int64 uint64_t
Definition stdint.h:90
char * rna_path
Definition DNA_ID.h:413
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42