Blender V5.3
deg_builder_cache.h
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
9#pragma once
10
11#include "MEM_guardedalloc.h"
12
13#include "RNA_types.hh"
14
15#include "BLI_map.hh"
16#include "BLI_set.hh"
17
18namespace blender {
19
20struct ID;
21struct PointerRNA;
22struct PropertyRNA;
23struct StructRNA;
24
25namespace deg {
26
28
29/* Identifier for animated property. */
31 public:
33 AnimatedPropertyID(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
34 AnimatedPropertyID(const PointerRNA &pointer_rna, const PropertyRNA *property_rna);
35 AnimatedPropertyID(const ID *id, StructRNA *type, const char *property_name);
36 AnimatedPropertyID(const ID *id, StructRNA *type, void *data, const char *property_name);
37
38 uint64_t hash() const;
39 friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b);
40
41 /* Corresponds to PointerRNA.data. */
42 const void *data;
44
45 MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyID");
46};
47
49 public:
51
52 void initializeFromID(DepsgraphBuilderCache *builder_cache, const ID *id);
53
54 void tagPropertyAsAnimated(const AnimatedPropertyID &property_id);
55 void tagPropertyAsAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
56
57 bool isPropertyAnimated(const AnimatedPropertyID &property_id);
58 bool isPropertyAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
59
60 bool isAnyPropertyAnimated(const PointerRNA *pointer_rna);
61
62 /* The storage is fully initialized from all F-Curves from corresponding ID. */
64
65 /* indexed by PointerRNA.data. */
68
69 MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyStorage");
70};
71
72/* Cached data which can be re-used by multiple builders. */
74 public:
76
77 /* Makes sure storage for animated properties exists and initialized for the given ID. */
80
81 /* Shortcuts to go through ensureInitializedAnimatedPropertyStorage and its
82 * isPropertyAnimated.
83 *
84 * NOTE: Avoid using for multiple subsequent lookups, query for the storage once, and then query
85 * the storage.
86 *
87 * TODO(sergey): Technically, this makes this class something else than just a cache, but what is
88 * the better name? */
89 template<typename... Args> bool isPropertyAnimated(const ID *id, Args... args)
90 {
92 id);
93 return animated_property_storage->isPropertyAnimated(args...);
94 }
95
97 {
99 ptr->owner_id);
100 return animated_property_storage->isAnyPropertyAnimated(ptr);
101 }
102
104
105 MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache");
106};
107
108} // namespace deg
109} // namespace blender
Read Blender memory allocation and freeing.
MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyID")
friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b)
Set< AnimatedPropertyID > animated_properties_set
MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyStorage")
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_
bool isPropertyAnimated(const ID *id, Args... args)
bool isAnyPropertyAnimated(const PointerRNA *ptr)
AnimatedPropertyStorage * ensureInitializedAnimatedPropertyStorage(const ID *id)
MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache")
AnimatedPropertyStorage * ensureAnimatedPropertyStorage(const ID *id)
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91