Blender V5.0
ANIM_keyframing.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
13#include <array>
14
15#include "BLI_string_ref.hh"
16
17#include "DNA_anim_types.h"
18#include "DNA_userdef_types.h"
19
20#include "BKE_report.hh"
21
22#include "RNA_path.hh"
23#include "RNA_types.hh"
24
25struct ID;
26struct Main;
27struct Scene;
28
31
32namespace blender::animrig {
33
44 /* TODO: remove `UNKNOWN_FAILURE` and replace all usages with proper, specific
45 * cases. This is needed right now as a stop-gap while progressively moving
46 * the keyframing code over to propagate errors properly. */
58 /* Make sure to always keep this at the end of the enum. */
60};
61
67 private:
68 /* The index to the array maps a `SingleKeyingResult` to the number of times this result has
69 * occurred. */
70 std::array<int, size_t(SingleKeyingResult::_KEYING_RESULT_MAX)> result_counter;
71
72 public:
74
78 void add(SingleKeyingResult result, int count = 1);
79
80 /* Add values of the given result to this result. */
81 void merge(const CombinedKeyingResult &other);
82
83 int get_count(const SingleKeyingResult result) const;
84
85 bool has_errors() const;
86
87 void generate_reports(ReportList *reports, eReportType report_level = RPT_ERROR);
88};
89
97std::optional<StringRefNull> default_channel_group_for_path(const PointerRNA *animated_struct,
98 StringRef prop_rna_path);
99
100/* -------------------------------------------------------------------- */
101
110
111/* -------------------------------------------------------------------- */
114
117
153 PointerRNA *struct_pointer,
154 std::optional<StringRefNull> channel_group,
155 const blender::Span<RNAPath> rna_paths,
156 std::optional<float> scene_frame,
157 const AnimationEvalContext &anim_eval_context,
159 eInsertKeyFlags insert_key_flags);
160
179 PropertyRNA *prop,
180 FCurve *fcu,
181 const AnimationEvalContext *anim_eval_context,
183 NlaKeyframingContext *nla_context,
185
193int delete_keyframe(Main *bmain, ReportList *reports, ID *id, const RNAPath &rna_path, float cfra);
194
202int clear_keyframe(Main *bmain, ReportList *reports, ID *id, const RNAPath &rna_path);
203
205bool is_keying_flag(const Scene *scene, eKeying_Flag flag);
206
213bool id_frame_has_keyframe(ID *id, float frame);
214
219
221
222/* -------------------------------------------------------------------- */
231
233bool is_autokey_on(const Scene *scene);
234
236bool is_autokey_mode(const Scene *scene, eAutokey_Mode mode);
237
241bool autokeyframe_cfra_can_key(const Scene *scene, ID *id);
242
248void autokeyframe_object(bContext *C, const Scene *scene, Object *ob, Span<RNAPath> rna_paths);
255bool autokeyframe_object(bContext *C, Scene *scene, Object *ob, KeyingSet *ks);
256bool autokeyframe_pchan(bContext *C, Scene *scene, Object *ob, bPoseChannel *pchan, KeyingSet *ks);
267 Scene *scene,
268 Object *ob,
269 bPoseChannel *pose_channel,
270 Span<RNAPath> rna_paths,
271 short targetless_ik);
279 Scene *scene,
281 PropertyRNA *prop,
282 int rnaindex,
283 float cfra,
284 bool only_if_property_keyed);
285
287
288} // namespace blender::animrig
eReportType
Definition BKE_report.hh:33
@ RPT_ERROR
Definition BKE_report.hh:39
eInsertKeyFlags
eBezTriple_KeyframeType
eAutokey_Mode
PropertyType
Definition RNA_types.hh:161
#define C
Definition RandGen.cpp:29
void merge(const CombinedKeyingResult &other)
int get_count(const SingleKeyingResult result) const
void generate_reports(ReportList *reports, eReportType report_level=RPT_ERROR)
void add(SingleKeyingResult result, int count=1)
int count
std::optional< StringRefNull > default_channel_group_for_path(const PointerRNA *animated_struct, StringRef prop_rna_path)
bool is_autokey_on(const Scene *scene)
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
void update_autoflags_fcurve_direct(FCurve *fcu, PropertyType prop_type)
bool is_autokey_mode(const Scene *scene, eAutokey_Mode mode)
int clear_keyframe(Main *bmain, ReportList *reports, ID *id, const RNAPath &rna_path)
int delete_keyframe(Main *bmain, ReportList *reports, ID *id, const RNAPath &rna_path, float cfra)
Main Delete Key-Framing API call.
bool id_frame_has_keyframe(ID *id, float frame)
CombinedKeyingResult insert_keyframes(Main *bmain, PointerRNA *struct_pointer, std::optional< StringRefNull > channel_group, const blender::Span< RNAPath > rna_paths, std::optional< float > scene_frame, const AnimationEvalContext &anim_eval_context, eBezTriple_KeyframeType key_type, eInsertKeyFlags insert_key_flags)
Main key-frame insertion API.
bool autokeyframe_pchan(bContext *C, Scene *scene, Object *ob, bPoseChannel *pchan, KeyingSet *ks)
bool autokeyframe_property(bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra, bool only_if_property_keyed)
void autokeyframe_object(bContext *C, const Scene *scene, Object *ob, Span< RNAPath > rna_paths)
bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, const AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, NlaKeyframingContext *nla_context, eInsertKeyFlags flag)
Secondary Insert Key-framing API call.
bool is_keying_flag(const Scene *scene, eKeying_Flag flag)
bool key_insertion_may_create_fcurve(eInsertKeyFlags insert_key_flags)
void autokeyframe_pose_channel(bContext *C, Scene *scene, Object *ob, bPoseChannel *pose_channel, Span< RNAPath > rna_paths, short targetless_ik)
eInsertKeyFlags get_keyframing_flags(Scene *scene)
Definition DNA_ID.h:414
PointerRNA * ptr
Definition wm_files.cc:4238
uint8_t flag
Definition wm_window.cc:145