Blender  V2.93
Enumerations | Functions
keyframing.c File Reference
#include <float.h>
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "BKE_action.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_fcurve_driver.h"
#include "BKE_global.h"
#include "BKE_idtype.h"
#include "BKE_key.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_nla.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_keyframing.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "anim_intern.h"

Go to the source code of this file.

Enumerations

enum  { KEYNEEDED_DONTADD = 0 , KEYNEEDED_JUSTADD , KEYNEEDED_DELPREV , KEYNEEDED_DELNEXT }
 
enum  { VISUALKEY_NONE = 0 , VISUALKEY_LOC , VISUALKEY_ROT , VISUALKEY_SCA }
 
enum  { COMMONKEY_MODE_INSERT = 0 , COMMONKEY_MODE_DELETE }
 

Functions

eInsertKeyFlags ANIM_get_keyframing_flags (Scene *scene, const bool use_autokey_mode)
 
bActionED_id_action_ensure (Main *bmain, ID *id)
 
FCurveED_action_fcurve_find (struct bAction *act, const char rna_path[], const int array_index)
 
FCurveED_action_fcurve_ensure (struct Main *bmain, struct bAction *act, const char group[], struct PointerRNA *ptr, const char rna_path[], const int array_index)
 
static void update_autoflags_fcurve_direct (FCurve *fcu, PropertyRNA *prop)
 
void update_autoflags_fcurve (FCurve *fcu, bContext *C, ReportList *reports, PointerRNA *ptr)
 
static eFCU_Cycle_Type remap_cyclic_keyframe_location (FCurve *fcu, float *px, float *py)
 
static void replace_bezt_keyframe_ypos (BezTriple *dst, const BezTriple *bezt)
 
int insert_bezt_fcurve (FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
 
static void subdivide_nonauto_handles (const FCurve *fcu, BezTriple *bezt, BezTriple *prev, BezTriple *next)
 
int insert_vert_fcurve (FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag)
 
static short new_key_needed (FCurve *fcu, float cFrame, float nValue)
 
static floatsetting_get_rna_values (PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count)
 
static bool visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop)
 
static floatvisualkey_get_values (PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count)
 
static floatget_keyframe_values (ReportList *reports, PointerRNA ptr, PropertyRNA *prop, int index, struct NlaKeyframingContext *nla_context, eInsertKeyFlags flag, float *buffer, int buffer_size, int *r_count, bool *r_force_all)
 
static bool insert_keyframe_value (ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, FCurve *fcu, const AnimationEvalContext *anim_eval_context, float curval, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
 
bool insert_keyframe_direct (ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, const AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, struct NlaKeyframingContext *nla_context, eInsertKeyFlags flag)
 
static bool insert_keyframe_fcurve_value (Main *bmain, ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, bAction *act, const char group[], const char rna_path[], int array_index, const AnimationEvalContext *anim_eval_context, float curval, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
 
static AnimationEvalContext nla_time_remap (const AnimationEvalContext *anim_eval_context, PointerRNA *id_ptr, AnimData *adt, bAction *act, ListBase *nla_cache, NlaKeyframingContext **r_nla_context)
 
int insert_keyframe (Main *bmain, ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, const AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, ListBase *nla_cache, eInsertKeyFlags flag)
 
static bool delete_keyframe_fcurve (AnimData *adt, FCurve *fcu, float cfra)
 
static void deg_tag_after_keyframe_delete (Main *bmain, ID *id, AnimData *adt)
 
int delete_keyframe (Main *bmain, ReportList *reports, ID *id, bAction *act, const char rna_path[], int array_index, float cfra)
 
static int clear_keyframe (Main *bmain, ReportList *reports, ID *id, bAction *act, const char rna_path[], int array_index, eInsertKeyFlags UNUSED(flag))
 
static bool modify_key_op_poll (bContext *C)
 
static int insert_key_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_keyframe_insert (wmOperatorType *ot)
 
void ANIM_OT_keyframe_insert_by_name (wmOperatorType *ot)
 
static int insert_key_menu_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
void ANIM_OT_keyframe_insert_menu (wmOperatorType *ot)
 
static int delete_key_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_keyframe_delete (wmOperatorType *ot)
 
void ANIM_OT_keyframe_delete_by_name (wmOperatorType *ot)
 
static int clear_anim_v3d_exec (bContext *C, wmOperator *UNUSED(op))
 
void ANIM_OT_keyframe_clear_v3d (wmOperatorType *ot)
 
static int delete_key_v3d_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_keyframe_delete_v3d (wmOperatorType *ot)
 
static int insert_key_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_keyframe_insert_button (wmOperatorType *ot)
 
static int delete_key_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_keyframe_delete_button (wmOperatorType *ot)
 
static int clear_key_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_keyframe_clear_button (wmOperatorType *ot)
 
bool autokeyframe_cfra_can_key (const Scene *scene, ID *id)
 
bool fcurve_frame_has_keyframe (FCurve *fcu, float frame, short filter)
 
bool fcurve_is_changed (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, const AnimationEvalContext *anim_eval_context)
 
static bool action_frame_has_keyframe (bAction *act, float frame, short filter)
 
static bool object_frame_has_keyframe (Object *ob, float frame, short filter)
 
bool id_frame_has_keyframe (ID *id, float frame, short filter)
 
bool ED_autokeyframe_object (bContext *C, Scene *scene, Object *ob, KeyingSet *ks)
 
bool ED_autokeyframe_pchan (bContext *C, Scene *scene, Object *ob, bPoseChannel *pchan, KeyingSet *ks)
 
bool ED_autokeyframe_property (bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra)
 
Internal Utilities
static KeyingSetkeyingset_get_from_op_with_error (wmOperator *op, PropertyRNA *prop, Scene *scene)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
KEYNEEDED_DONTADD 
KEYNEEDED_JUSTADD 
KEYNEEDED_DELPREV 
KEYNEEDED_DELNEXT 

Definition at line 655 of file keyframing.c.

◆ anonymous enum

anonymous enum
Enumerator
VISUALKEY_NONE 
VISUALKEY_LOC 
VISUALKEY_ROT 
VISUALKEY_SCA 

Definition at line 847 of file keyframing.c.

◆ anonymous enum

anonymous enum
Enumerator
COMMONKEY_MODE_INSERT 
COMMONKEY_MODE_DELETE 

Definition at line 1847 of file keyframing.c.

Function Documentation

◆ action_frame_has_keyframe()

static bool action_frame_has_keyframe ( bAction act,
float  frame,
short  filter 
)
static

Checks whether an Action has a keyframe for a given frame Since we're only concerned whether a keyframe exists, we can simply loop until a match is found.

Definition at line 2869 of file keyframing.c.

References ACT_MUTED, ANIMFILTER_KEYS_MUTED, FCurve::bezt, bAction::curves, fcurve_frame_has_keyframe(), filter(), ListBase::first, bAction::flag, FCurve::next, NULL, and FCurve::totvert.

Referenced by id_frame_has_keyframe(), and object_frame_has_keyframe().

◆ ANIM_get_keyframing_flags()

eInsertKeyFlags ANIM_get_keyframing_flags ( Scene scene,
const bool  use_autokey_mode 
)

◆ ANIM_OT_keyframe_clear_button()

void ANIM_OT_keyframe_clear_button ( wmOperatorType ot)

◆ ANIM_OT_keyframe_clear_v3d()

void ANIM_OT_keyframe_clear_v3d ( wmOperatorType ot)

◆ ANIM_OT_keyframe_delete()

void ANIM_OT_keyframe_delete ( wmOperatorType ot)

◆ ANIM_OT_keyframe_delete_button()

void ANIM_OT_keyframe_delete_button ( wmOperatorType ot)

◆ ANIM_OT_keyframe_delete_by_name()

void ANIM_OT_keyframe_delete_by_name ( wmOperatorType ot)

◆ ANIM_OT_keyframe_delete_v3d()

void ANIM_OT_keyframe_delete_v3d ( wmOperatorType ot)

◆ ANIM_OT_keyframe_insert()

void ANIM_OT_keyframe_insert ( wmOperatorType ot)

◆ ANIM_OT_keyframe_insert_button()

void ANIM_OT_keyframe_insert_button ( wmOperatorType ot)

◆ ANIM_OT_keyframe_insert_by_name()

void ANIM_OT_keyframe_insert_by_name ( wmOperatorType ot)

◆ ANIM_OT_keyframe_insert_menu()

void ANIM_OT_keyframe_insert_menu ( wmOperatorType ot)

◆ autokeyframe_cfra_can_key()

bool autokeyframe_cfra_can_key ( const Scene scene,
ID id 
)

◆ clear_anim_v3d_exec()

static int clear_anim_v3d_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ clear_key_button_exec()

static int clear_key_button_exec ( bContext C,
wmOperator op 
)
static

◆ clear_keyframe()

static int clear_keyframe ( Main bmain,
ReportList reports,
ID id,
bAction act,
const char  rna_path[],
int  array_index,
eInsertKeyFlags   UNUSEDflag 
)
static

Main Keyframing API call: Use this when validation of necessary animation data isn't necessary as it already exists. It will clear the current buttons fcurve(s).

The flag argument is used for special settings that alter the behavior of the keyframe deletion. These include the quick refresh options.

Returns
The number of f-curves removed.

Definition at line 1749 of file keyframing.c.

References AnimData::action, ANIM_fcurve_delete_from_animdata(), BKE_animdata_from_id(), BKE_fcurve_is_protected(), BKE_idtype_idcode_to_name(), BKE_report(), BKE_reportf(), deg_tag_after_keyframe_delete(), ED_action_fcurve_find(), ELEM, GS, id, ID::name, NULL, ptr, ret, RNA_id_pointer_create(), FCurve::rna_path, RNA_path_resolve_property(), RNA_property_array_length(), RPT_ERROR, and RPT_WARNING.

Referenced by clear_key_button_exec().

◆ deg_tag_after_keyframe_delete()

static void deg_tag_after_keyframe_delete ( Main bmain,
ID id,
AnimData adt 
)
static

◆ delete_key_button_exec()

static int delete_key_button_exec ( bContext C,
wmOperator op 
)
static

◆ delete_key_exec()

static int delete_key_exec ( bContext C,
wmOperator op 
)
static

◆ delete_key_v3d_exec()

static int delete_key_v3d_exec ( bContext C,
wmOperator op 
)
static

◆ delete_keyframe()

int delete_keyframe ( Main bmain,
ReportList reports,
ID id,
bAction act,
const char  rna_path[],
int  array_index,
float  cfra 
)

◆ delete_keyframe_fcurve()

static bool delete_keyframe_fcurve ( AnimData adt,
FCurve fcu,
float  cfra 
)
static
Note
caller needs to run BKE_nla_tweakedit_remap to get NLA relative frame. caller should also check BKE_fcurve_is_protected before keying.

Definition at line 1603 of file keyframing.c.

References ANIM_fcurve_delete_from_animdata(), FCurve::bezt, BKE_fcurve_bezt_binarysearch_index(), BKE_fcurve_is_empty(), delete_fcurve_key(), NULL, and FCurve::totvert.

Referenced by delete_key_v3d_exec(), and delete_keyframe().

◆ ED_action_fcurve_ensure()

FCurve* ED_action_fcurve_ensure ( struct Main bmain,
struct bAction act,
const char  group[],
struct PointerRNA ptr,
const char  rna_path[],
const int  array_index 
)

◆ ED_action_fcurve_find()

FCurve* ED_action_fcurve_find ( struct bAction act,
const char  rna_path[],
const int  array_index 
)

Find the F-Curve from the Active Action, for the given Animation Data block. This assumes that all the destinations are valid.

Definition at line 181 of file keyframing.c.

References BKE_fcurve_find(), bAction::curves, ELEM, and NULL.

Referenced by clear_keyframe(), delete_keyframe(), and insert_keyframe_fcurve_value().

◆ ED_autokeyframe_object()

bool ED_autokeyframe_object ( bContext C,
Scene scene,
Object ob,
KeyingSet ks 
)

◆ ED_autokeyframe_pchan()

bool ED_autokeyframe_pchan ( bContext C,
Scene scene,
Object ob,
bPoseChannel pchan,
KeyingSet ks 
)

◆ ED_autokeyframe_property()

bool ED_autokeyframe_property ( bContext C,
Scene scene,
PointerRNA ptr,
PropertyRNA prop,
int  rnaindex,
float  cfra 
)

◆ ED_id_action_ensure()

bAction* ED_id_action_ensure ( Main bmain,
ID id 
)

◆ fcurve_frame_has_keyframe()

bool fcurve_frame_has_keyframe ( FCurve fcu,
float  frame,
short  filter 
)

◆ fcurve_is_changed()

bool fcurve_is_changed ( PointerRNA  ptr,
PropertyRNA prop,
FCurve fcu,
const AnimationEvalContext anim_eval_context 
)

◆ get_keyframe_values()

static float* get_keyframe_values ( ReportList reports,
PointerRNA  ptr,
PropertyRNA prop,
int  index,
struct NlaKeyframingContext nla_context,
eInsertKeyFlags  flag,
float buffer,
int  buffer_size,
int *  r_count,
bool *  r_force_all 
)
static

Retrieve current property values to keyframe, possibly applying NLA correction when necessary.

Definition at line 1117 of file keyframing.c.

References BKE_animsys_nla_remap_keyframe_values(), BKE_report(), buffer, INSERTKEY_MATRIX, MEM_freeN, NULL, ptr, RPT_ERROR, setting_get_rna_values(), visualkey_can_use(), and visualkey_get_values().

Referenced by insert_keyframe(), and insert_keyframe_direct().

◆ id_frame_has_keyframe()

bool id_frame_has_keyframe ( struct ID id,
float  frame,
short  filter 
)

Main Keyframe Checking API call: Checks whether a keyframe exists for the given ID-block one the given frame.

  • It is recommended to call this method over the other keyframe-checkers directly, in case some detail of the implementation changes...
  • frame: the value of this is quite often result of BKE_scene_frame_get()

Definition at line 2969 of file keyframing.c.

References AnimData::action, action_frame_has_keyframe(), BKE_animdata_from_id(), filter(), GS, id, ID_OB, ID_SCE, ID::name, NULL, and object_frame_has_keyframe().

Referenced by autokeyframe_cfra_can_key(), draw_selected_name(), and object_frame_has_keyframe().

◆ insert_bezt_fcurve()

int insert_bezt_fcurve ( FCurve fcu,
const BezTriple bezt,
eInsertKeyFlags  flag 
)

◆ insert_key_button_exec()

static int insert_key_button_exec ( bContext C,
wmOperator op 
)
static

◆ insert_key_exec()

static int insert_key_exec ( bContext C,
wmOperator op 
)
static

◆ insert_key_menu_invoke()

static int insert_key_menu_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ insert_keyframe()

int insert_keyframe ( Main bmain,
ReportList reports,
ID id,
bAction act,
const char  group[],
const char  rna_path[],
int  array_index,
const AnimationEvalContext anim_eval_context,
eBezTriple_KeyframeType  keytype,
ListBase nla_cache,
eInsertKeyFlags  flag 
)

Main Keyframing API call

Use this when validation of necessary animation data is necessary, since it may not exist yet.

The flag argument is used for special settings that alter the behavior of the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, and extra keyframe filtering.

index of -1 keys all array indices

Returns
The number of key-frames inserted.

Definition at line 1413 of file keyframing.c.

References AnimData::action, BKE_animdata_from_id(), BKE_animsys_free_nla_keyframing_context_cache(), BKE_reportf(), DEG_id_tag_update(), ED_id_action_ensure(), get_keyframe_values(), id, bAction::id, ID_RECALC_ANIMATION_NO_FLUSH, insert_keyframe_fcurve_value(), INSERTKEY_AVAILABLE, INSERTKEY_REPLACE, MEM_freeN, ID::name, nla_time_remap(), NULL, ptr, ret, RNA_id_pointer_create(), RNA_MAX_ARRAY_LENGTH, RNA_path_resolve_property(), RPT_ERROR, and TIP_.

Referenced by ANIM_apply_keyingset(), autokeyframe_object(), autokeyframe_pose(), ED_autokeyframe_property(), insert_action_keys(), insert_graph_keys(), insert_key_button_exec(), and pyrna_struct_keyframe_insert().

◆ insert_keyframe_direct()

bool insert_keyframe_direct ( ReportList reports,
PointerRNA  ptr,
PropertyRNA prop,
FCurve fcu,
const AnimationEvalContext anim_eval_context,
eBezTriple_KeyframeType  keytype,
struct NlaKeyframingContext nla_context,
eInsertKeyFlags  flag 
)

◆ insert_keyframe_fcurve_value()

static bool insert_keyframe_fcurve_value ( Main bmain,
ReportList reports,
PointerRNA ptr,
PropertyRNA prop,
bAction act,
const char  group[],
const char  rna_path[],
int  array_index,
const AnimationEvalContext anim_eval_context,
float  curval,
eBezTriple_KeyframeType  keytype,
eInsertKeyFlags  flag 
)
static

◆ insert_keyframe_value()

static bool insert_keyframe_value ( ReportList reports,
PointerRNA ptr,
PropertyRNA prop,
FCurve fcu,
const AnimationEvalContext anim_eval_context,
float  curval,
eBezTriple_KeyframeType  keytype,
eInsertKeyFlags  flag 
)
static

◆ insert_vert_fcurve()

int insert_vert_fcurve ( FCurve fcu,
float  x,
float  y,
eBezTriple_KeyframeType  keyframe_type,
eInsertKeyFlags  flag 
)

◆ keyingset_get_from_op_with_error()

static KeyingSet * keyingset_get_from_op_with_error ( wmOperator op,
PropertyRNA prop,
Scene scene 
)
static

◆ modify_key_op_poll()

static bool modify_key_op_poll ( bContext C)
static

◆ new_key_needed()

static short new_key_needed ( FCurve fcu,
float  cFrame,
float  nValue 
)
static

◆ nla_time_remap()

static AnimationEvalContext nla_time_remap ( const AnimationEvalContext anim_eval_context,
PointerRNA id_ptr,
AnimData adt,
bAction act,
ListBase nla_cache,
NlaKeyframingContext **  r_nla_context 
)
static

◆ object_frame_has_keyframe()

static bool object_frame_has_keyframe ( Object ob,
float  frame,
short  filter 
)
static

◆ remap_cyclic_keyframe_location()

static eFCU_Cycle_Type remap_cyclic_keyframe_location ( FCurve fcu,
float px,
float py 
)
static

◆ replace_bezt_keyframe_ypos()

static void replace_bezt_keyframe_ypos ( BezTriple dst,
const BezTriple bezt 
)
static

Definition at line 379 of file keyframing.c.

References BezTriple::f1, BezTriple::f2, BezTriple::f3, and BezTriple::vec.

Referenced by insert_bezt_fcurve().

◆ setting_get_rna_values()

static float* setting_get_rna_values ( PointerRNA ptr,
PropertyRNA prop,
float buffer,
int  buffer_size,
int *  r_count 
)
static

◆ subdivide_nonauto_handles()

static void subdivide_nonauto_handles ( const FCurve fcu,
BezTriple bezt,
BezTriple prev,
BezTriple next 
)
static

Update the FCurve to allow insertion of bezt without modifying the curve shape.

Checks whether it is necessary to apply Bezier subdivision due to involvement of non-auto handles. If necessary, changes bezt handles from Auto to Aligned.

Parameters
beztkey being inserted
prevkeyframe before that key
nextkeyframe after that key

Definition at line 496 of file keyframing.c.

References FCurve::auto_smoothing, BEZT_IPO_BEZ, BEZT_IS_AUTOH, BKE_fcurve_bezt_subdivide_handles(), fabsf, FCURVE_SMOOTH_CONT_ACCEL, BezTriple::h1, BezTriple::h2, HD_ALIGN, HD_VECT, BezTriple::ipo, next, and BezTriple::vec.

Referenced by insert_vert_fcurve().

◆ update_autoflags_fcurve()

void update_autoflags_fcurve ( FCurve fcu,
bContext C,
ReportList reports,
PointerRNA ptr 
)

◆ update_autoflags_fcurve_direct()

static void update_autoflags_fcurve_direct ( FCurve fcu,
PropertyRNA prop 
)
static

◆ visualkey_can_use()

static bool visualkey_can_use ( PointerRNA ptr,
PropertyRNA prop 
)
static

◆ visualkey_get_values()

static float* visualkey_get_values ( PointerRNA ptr,
PropertyRNA prop,
float buffer,
int  buffer_size,
int *  r_count 
)
static