11#include <fmt/format.h>
65#include "RNA_prototypes.hh"
82 int old_flag = fcu->
flag;
84 if ((
ptr->owner_id ==
nullptr) && (
ptr->data ==
nullptr)) {
92 const char *idname = (
ptr->owner_id) ?
ptr->owner_id->name :
RPT_(
"<No ID pointer>");
96 "Could not update flags for this F-curve, as RNA path is invalid for the given ID "
97 "(ID = %s, path = %s)",
106 if (old_flag != fcu->
flag) {
116 BLI_assert_msg(num_keys_to_add >= 0,
"cannot remove keyframes with this function");
118 if (num_keys_to_add == 0) {
126 fcu->
totvert += num_keys_to_add;
129 while (num_keys_to_add--) {
158 if (
ELEM(
nullptr, area, scene)) {
172 bool ob_edit_mode =
false;
190 "Keying set '%s' - successfully added %d keyframes",
201 if (num_channels < 0) {
206 if (num_channels > 0) {
213 if (num_channels > 0) {
216 "Successfully added %d keyframes for keying set '%s'",
233 if (
ptr->type == &RNA_PoseBone) {
237 else if (
ptr->type == &RNA_Object) {
248 paths.
append({
"location"});
251 switch (rotation_mode) {
253 paths.
append({
"rotation_quaternion"});
256 paths.
append({
"rotation_axis_angle"});
264 paths.
append({
"rotation_euler"});
273 paths.
append({
"rotation_mode"});
287 switch (context_mode) {
309 if (!found_selection) {
333 ID *selected_id = id_ptr.owner_id;
334 ids.
add(selected_id);
338 "Could not insert keyframe, as this type does not support animation data (ID = "
399 ot->name =
"Insert Keyframe";
400 ot->idname =
"ANIM_OT_keyframe_insert";
402 "Insert keyframes on the current frame using either the active keying set, or the user "
403 "preferences if no keying set is active";
438 ot->name =
"Insert Keyframe (by name)";
439 ot->idname =
"ANIM_OT_keyframe_insert_by_name";
440 ot->description =
"Alternate access to 'Insert Keyframe' for keymaps to use";
451 ot->srna,
"type",
nullptr,
MAX_ID_NAME - 2,
"Keying Set",
"The Keying Set to use");
495 for (
int i = 0;
i < totitem;
i++) {
524 ot->name =
"Insert Keyframe Menu";
525 ot->idname =
"ANIM_OT_keyframe_insert_menu";
527 "Insert Keyframes for specified Keying Set, with menu of available Keying Sets if undefined";
548 prop =
RNA_def_boolean(
ot->srna,
"always_prompt",
false,
"Always Show Menu",
"");
576 printf(
"KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->
name, num_channels);
580 if (num_channels < 0) {
585 if (num_channels > 0) {
591 if (num_channels > 0) {
594 "Successfully removed %d keyframes for keying set '%s'",
610 ot->name =
"Delete Keying-Set Keyframe";
611 ot->idname =
"ANIM_OT_keyframe_delete";
613 "Delete keyframes on the current frame for all properties in the specified Keying Set";
635 ot->name =
"Delete Keying-Set Keyframe (by name)";
636 ot->idname =
"ANIM_OT_keyframe_delete_by_name";
637 ot->description =
"Alternate access to 'Delete Keyframe' for keymaps to use";
648 ot->srna,
"type",
nullptr,
MAX_ID_NAME - 2,
"Keying Set",
"The Keying Set to use");
663 bool can_delete =
false;
669 char bone_name[
sizeof(pchan->
name)];
673 if ((pchan) && (pchan->
bone)) {
694 bool changed =
false;
698 if ((ob->adt) && (ob->adt->action)) {
703 Action &action = dna_action->wrap();
707 if (can_delete_fcurve(&fcurve, ob)) {
708 fcurves_to_delete.append(&fcurve);
711 for (
FCurve *fcurve : fcurves_to_delete) {
719 for (fcu =
static_cast<FCurve *
>(dna_action->curves.first); fcu; fcu = fcn) {
755 IFACE_(
"Remove animation from selected objects?"),
767 ot->name =
"Remove Animation";
768 ot->description =
"Remove all keyframe animation for selected objects";
769 ot->idname =
"ANIM_OT_keyframe_clear_v3d";
788 "Not deleting keyframe for locked F-Curve '%s', object '%s'",
804 char bone_name[
sizeof(pchan->
name)];
811 if ((pchan) && (pchan->
bone)) {
835 int selected_objects_len = 0;
836 int selected_objects_success_len = 0;
837 int success_multi = 0;
844 selected_objects_len += 1;
847 if ((ob->adt) && (ob->adt->action)) {
852 Action &action = act->wrap();
856 if (!can_delete_key(&fcurve, ob, op->reports)) {
860 modified_fcurves.
append(&fcurve);
864 success += modified_fcurves.size();
865 for (
FCurve *fcurve : modified_fcurves) {
873 for (
FCurve *fcu =
static_cast<FCurve *
>(act->curves.first); fcu; fcu = fcn) {
885 if (ob->adt->action) {
894 selected_objects_success_len += 1;
895 success_multi += success;
902 if (selected_objects_success_len) {
909 if (selected_objects_success_len) {
912 "%d object(s) successfully had %d keyframes removed",
913 selected_objects_success_len,
918 op->reports,
RPT_ERROR,
"No keyframes removed from %d object(s)", selected_objects_len);
943 IFACE_(
"Delete keyframes from selected objects?"),
955 ot->name =
"Delete Keyframe";
956 ot->description =
"Remove keyframes on current frame for selected objects and bones";
957 ot->idname =
"ANIM_OT_keyframe_delete_v3d";
983 bool changed =
false;
996 if (
ptr.type == &RNA_NlaStrip) {
1017 "This property cannot be animated as it will not get updated correctly");
1023 bool driven, special;
1026 C, &
ptr, prop, index,
nullptr,
nullptr, &driven, &special);
1028 if (fcu && driven) {
1030 &anim_eval_context, &
ptr, prop, fcu);
1054 const std::optional<int> array_index = (
all || index < 0) ? std::nullopt :
1055 std::optional(index);
1060 {{*path, {}, array_index}},
1070 "Failed to resolve path to property, "
1071 "try manually specifying this using a Keying Set instead");
1079 "\"%s\" property cannot be animated",
1085 "Button doesn't appear to have any property information attached (ptr.data = "
1093 ID *
id =
ptr.owner_id;
1095 if (adt->
action !=
nullptr) {
1113 ot->name =
"Insert Keyframe (Buttons)";
1114 ot->idname =
"ANIM_OT_keyframe_insert_button";
1115 ot->description =
"Insert a keyframe for current UI-active property";
1125 RNA_def_boolean(
ot->srna,
"all",
true,
"All",
"Insert a keyframe for all element of the array");
1137 bool changed =
false;
1146 if (
ptr.owner_id &&
ptr.data && prop) {
1152 ID *
id =
ptr.owner_id;
1161 "Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
1188 RNAPath rna_path = {*path, std::nullopt, index};
1191 rna_path.
index = std::nullopt;
1195 bmain, op->
reports,
ptr.owner_id, rna_path, cfra) != 0;
1198 printf(
"Button Delete-Key: no path to property\n");
1203 printf(
"ptr.data = %p, prop = %p\n",
ptr.data, (
void *)prop);
1220 ot->name =
"Delete Keyframe (Buttons)";
1221 ot->idname =
"ANIM_OT_keyframe_delete_button";
1222 ot->description =
"Delete current keyframe of current UI-active property";
1232 RNA_def_boolean(
ot->srna,
"all",
true,
"All",
"Delete keyframes from all elements of the array");
1242 bool changed =
false;
1251 if (
ptr.owner_id &&
ptr.data && prop) {
1253 RNAPath rna_path = {*path, std::nullopt, index};
1256 rna_path.
index = std::nullopt;
1263 printf(
"Button Clear-Key: no path to property\n");
1267 printf(
"ptr.data = %p, prop = %p\n",
ptr.data, (
void *)prop);
1284 ot->name =
"Clear Keyframe (Buttons)";
1285 ot->idname =
"ANIM_OT_keyframe_clear_button";
1286 ot->description =
"Clear all keyframes on the currently active property";
1296 RNA_def_boolean(
ot->srna,
"all",
true,
"All",
"Clear keyframes from all elements of the array");
1311 anim_rna.
prop = prop;
1318 float cur_val = (index >= 0 && index < values.
size()) ? values[index] : 0.0f;
1335 if (ks ==
nullptr) {
1343 if (
STREQ(type_id,
"__ACTIVE__")) {
1350 if (ks ==
nullptr) {
Functions and classes to work with Actions.
Functionality to iterate an Action in various ways.
Functions to work with AnimData.
Functions to deal with Armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
Functions to work with drivers.
Functions to modify FCurves.
Functions to insert, delete or modify keyframes.
Functionality to interact with keying sets.
Helper functions for animation to interact with the RNA system.
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
bool id_can_have_animdata(const ID *id)
AnimData * BKE_animdata_from_id(const ID *id)
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time) ATTR_WARN_UNUSED_RESULT
#define CTX_DATA_BEGIN(C, Type, instance, member)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
bool CTX_data_selected_objects(const bContext *C, blender::Vector< PointerRNA > *list)
Main * CTX_data_main(const bContext *C)
bool CTX_data_selected_pose_bones(const bContext *C, blender::Vector< PointerRNA > *list)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
void BKE_fcurve_handles_recalc(FCurve *fcu)
FCurve * BKE_fcurve_find_by_rna_context_ui(bContext *C, const PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_animdata, bAction **r_action, bool *r_driven, bool *r_special)
FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index)
bool BKE_fcurve_is_empty(const FCurve *fcu)
bool BKE_fcurve_is_protected(const FCurve *fcu)
float calculate_fcurve(PathResolvedRNA *anim_rna, FCurve *fcu, const AnimationEvalContext *anim_eval_context)
void BKE_fcurve_delete_key(FCurve *fcu, int index)
const char * BKE_idtype_idcode_to_name(short idcode)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
bool BKE_nlastrip_has_curves_for_property(const PointerRNA *ptr, const PropertyRNA *prop)
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, eNlaTime_ConvertModes mode)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
float BKE_scene_frame_get(const Scene *scene)
#define BLI_assert_msg(a, msg)
void BLI_kdtree_nd_ free(KDTree *tree)
MINLINE int compare_ff_relative(float a, float b, float max_diff, int max_ulps)
bool bool BLI_str_quoted_substr(const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxncpy)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
void DEG_id_tag_update(ID *id, unsigned int flags)
ID and Library types, which are fundamental for SDNA.
@ ID_RECALC_ANIMATION_NO_FLUSH
@ USER_ANIM_KEY_CHANNEL_ROTATION_MODE
@ USER_ANIM_KEY_CHANNEL_SCALE
@ USER_ANIM_KEY_CHANNEL_ROTATION
@ USER_ANIM_KEY_CHANNEL_LOCATION
@ USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES
bool ED_operator_areaactive(bContext *C)
Read Guarded memory(de)allocation.
@ PROP_STRING_SEARCH_SUGGESTION
void UI_context_update_anim_flag(const bContext *C)
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
uiBut * UI_context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
bool UI_but_flag_is_set(uiBut *but, int flag)
void ANIM_deselect_keys_in_animation_editors(bContext *C)
BPy_StructRNA * depsgraph
Span< T > as_span() const
void append(const T &value)
void extend(Span< T > array)
bool is_action_layered() const
void merge(const CombinedKeyingResult &other)
int get_count(const SingleKeyingResult result) const
void generate_reports(ReportList *reports, eReportType report_level=RPT_ERROR)
static wmOperatorStatus delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *ks)
void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot)
bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, const AnimationEvalContext *anim_eval_context)
Lesser Keyframe Checking API call.
static wmOperatorStatus insert_key(bContext *C, wmOperator *op)
static wmOperatorStatus delete_key_v3d_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus delete_key_button_exec(bContext *C, wmOperator *op)
static wmOperatorStatus insert_key_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ANIM_OT_keyframe_insert(wmOperatorType *ot)
static wmOperatorStatus clear_anim_v3d_exec(bContext *C, wmOperator *)
void ANIM_OT_keyframe_clear_button(wmOperatorType *ot)
void ANIM_OT_keyframe_insert_by_name(wmOperatorType *ot)
void ANIM_OT_keyframe_delete(wmOperatorType *ot)
void ED_keyframes_add(FCurve *fcu, int num_keys_to_add)
static wmOperatorStatus insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
static bool can_delete_key(FCurve *fcu, Object *ob, ReportList *reports)
void ANIM_OT_keyframe_insert_button(wmOperatorType *ot)
static wmOperatorStatus clear_key_button_exec(bContext *C, wmOperator *op)
static KeyingSet * keyingset_get_from_op_with_error(wmOperator *op, PropertyRNA *prop, Scene *scene)
void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, PointerRNA *ptr)
Lesser Key-framing API call.
static wmOperatorStatus delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
static bool get_selection(bContext *C, blender::Vector< PointerRNA > *r_selection)
static bool modify_key_op_poll(bContext *C)
static wmOperatorStatus delete_key_v3d_exec(bContext *C, wmOperator *op)
static wmOperatorStatus insert_key_with_keyingset(bContext *C, wmOperator *op, KeyingSet *ks)
void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
static blender::Vector< RNAPath > construct_rna_paths(PointerRNA *ptr)
static wmOperatorStatus insert_key_exec(bContext *C, wmOperator *op)
static wmOperatorStatus clear_anim_v3d_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus insert_key_button_exec(bContext *C, wmOperator *op)
static bool can_delete_fcurve(FCurve *fcu, Object *ob)
void ANIM_OT_keyframe_delete_button(wmOperatorType *ot)
static wmOperatorStatus delete_key_exec(bContext *C, wmOperator *op)
void ANIM_OT_keyframe_delete_by_name(wmOperatorType *ot)
static wmOperatorStatus keyframe_insert_with_keyingset_exec(bContext *C, wmOperator *op)
void ANIM_keyingset_visit_for_search_no_poll(const bContext *C, PointerRNA *, PropertyRNA *, const char *, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
KeyingSet * ANIM_keyingset_get_from_idname(Scene *scene, const char *idname)
KeyingSet * ANIM_keyingset_get_from_enum_type(Scene *scene, int type)
const EnumPropertyItem * ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
bool all(VecOp< bool, D >) RET
#define MEM_recallocN(vmemh, len)
void MEM_freeN(void *vmemh)
void foreach_fcurve_in_action_slot(Action &action, slot_handle_t handle, FunctionRef< void(FCurve &fcurve)> callback)
bool action_fcurve_remove(Action &action, FCurve &fcu)
std::optional< StringRefNull > default_channel_group_for_path(const PointerRNA *animated_struct, StringRef prop_rna_path)
void animdata_fcurve_delete(AnimData *adt, FCurve *fcu)
void update_autoflags_fcurve_direct(FCurve *fcu, PropertyType prop_type)
KeyingSet * scene_get_active_keyingset(const Scene *scene)
Vector< RNAPath > get_keyable_id_property_paths(const PointerRNA &ptr)
Vector< float > get_rna_values(PointerRNA *ptr, PropertyRNA *prop)
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 fcurve_delete_keyframe_at_time(FCurve *fcurve, float time)
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 bone_is_visible_pchan(const bArmature *armature, const bPoseChannel *pchan)
bool keyingset_find_id(KeyingSet *keyingset, ID *id)
bool delete_keyframe_fcurve_legacy(AnimData *adt, FCurve *fcu, float cfra)
bool animdata_remove_empty_action(AnimData *adt)
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.
int apply_keyingset(bContext *C, blender::Vector< PointerRNA > *sources, KeyingSet *keyingset, ModifyKeyMode mode, float cfra)
eInsertKeyFlags get_keyframing_flags(Scene *scene)
float evaluate_driver_from_rna_pointer(const AnimationEvalContext *anim_eval_context, PointerRNA *ptr, PropertyRNA *prop, const FCurve *fcu)
bool mode_set(bContext *C, eObjectMode mode)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
PropertyType RNA_property_type(PropertyRNA *prop)
void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
bool RNA_property_anim_editable(const PointerRNA *ptr, PropertyRNA *prop_orig)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
int RNA_enum_get(PointerRNA *ptr, const char *name)
const char * RNA_property_identifier(const PropertyRNA *prop)
PointerRNA RNA_id_pointer_create(ID *id)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_string_search_func_runtime(PropertyRNA *prop, StringPropertySearchFunc search_fn, const eStringPropertySearchFlag search_flag)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
std::optional< int > index
struct ToolSettings * toolsettings
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, wmOperatorCallContext context, eUI_Item_Flag flag)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
wmOperatorStatus(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
std::string WM_operatortype_name(wmOperatorType *ot, PointerRNA *properties)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)