Blender V5.3
ANIM_evaluation.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Developers
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#pragma once
11
12#include "BLI_map.hh"
13#include "BLI_string_ref.hh"
14
15#include "RNA_path.hh"
16
17#include "ANIM_action.hh"
18
19namespace blender::animrig {
20
25 public:
28
29 PropIdentifier() = default;
30
35
36 friend bool operator==(const PropIdentifier &a, const PropIdentifier &b)
37 {
38 return a.array_index == b.array_index && a.rna_path == b.rna_path;
39 }
40
41 uint64_t hash() const
42 {
43 return get_default_hash(this->array_index, this->rna_path);
44 }
45};
46
51 public:
52 float value;
54
56 : value(value), prop_rna(std::move(prop_rna))
57 {
58 }
59};
60
61/* Result of FCurve evaluation for an action slot.
62 * Mapping from property identifier to its float value.
63 *
64 * Can be fed to the evaluation of the next layer, mixed with another strip, or
65 * used to modify actual RNA properties.
66 *
67 * TODO: see if this is efficient, and contains enough info, for mixing. For now
68 * this just captures the FCurve evaluation result, but doesn't have any info
69 * about how to do the mixing (LERP, quaternion SLERP, etc.).
70 */
72 protected:
75
76 public:
77 EvaluationResult() = default;
78
79 operator bool() const
80 {
81 return !this->is_empty();
82 }
83 bool is_empty() const
84 {
85 return result_.is_empty();
86 }
87
92 void reserve(const int64_t size)
93 {
94 result_.reserve(size);
95 };
96
98 const int array_index,
99 const float value,
100 PathResolvedRNA prop_rna)
101 {
103 AnimatedProperty(value, std::move(prop_rna)));
104 }
105
107 {
108 return result_.lookup_ptr(key);
109 }
111 {
112 return result_.lookup_ptr(key);
113 }
114
115 EvaluationMap::ItemIterator items() const
116 {
117 return result_.items();
118 }
119};
120
128 Action &action,
129 slot_handle_t slot_handle,
130 const AnimationEvalContext &anim_eval_context);
131
140void evaluate_and_apply_action(PointerRNA &animated_id_ptr,
141 Action &action,
142 slot_handle_t slot_handle,
143 const AnimationEvalContext &anim_eval_context,
144 bool flush_to_original);
145
146} // namespace blender::animrig
Functions and classes to work with Actions.
const Value * lookup_ptr(const Key &key) const
Definition BLI_map.hh:508
bool add_overwrite(const Key &key, const Value &value)
Definition BLI_map.hh:325
bool is_empty() const
Definition BLI_map.hh:986
void reserve(int64_t n)
Definition BLI_map.hh:1028
ItemIterator items() const &
Definition BLI_map.hh:902
AnimatedProperty(const float value, PathResolvedRNA &&prop_rna)
AnimatedProperty * lookup_ptr(const PropIdentifier &key)
void reserve(const int64_t size)
EvaluationMap::ItemIterator items() const
void store(const ParsedRNAPathRef rna_path, const int array_index, const float value, PathResolvedRNA prop_rna)
Map< PropIdentifier, AnimatedProperty > EvaluationMap
const AnimatedProperty * lookup_ptr(const PropIdentifier &key) const
PropIdentifier(const ParsedRNAPathRef rna_path, const int array_index)
friend bool operator==(const PropIdentifier &a, const PropIdentifier &b)
void evaluate_and_apply_action(PointerRNA &animated_id_ptr, Action &action, slot_handle_t slot_handle, const AnimationEvalContext &anim_eval_context, bool flush_to_original)
Definition evaluation.cc:83
decltype(blender::ActionSlot::handle) slot_handle_t
EvaluationResult evaluate_action(PointerRNA &animated_id_ptr, Action &action, slot_handle_t slot_handle, const AnimationEvalContext &anim_eval_context)
Definition evaluation.cc:48
unsigned __int64 uint64_t
Definition BKE_text.h:91
__int64 int64_t
Definition BKE_text.h:90
Span< rna_path::Item > ParsedRNAPathRef
Definition RNA_path.hh:113
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:252