Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/keyframing.c
| Show First 20 Lines • Show All 1,107 Lines • ▼ Show 20 Lines | static float *get_keyframe_values(ReportList *reports, | ||||
| return values; | return values; | ||||
| } | } | ||||
| /* Insert the specified keyframe value into a single F-Curve. */ | /* Insert the specified keyframe value into a single F-Curve. */ | ||||
| static bool insert_keyframe_value(ReportList *reports, | static bool insert_keyframe_value(ReportList *reports, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| PropertyRNA *prop, | PropertyRNA *prop, | ||||
| FCurve *fcu, | FCurve *fcu, | ||||
| float cfra, | const AnimationEvalContext *anim_eval_context, | ||||
| float curval, | float curval, | ||||
| eBezTriple_KeyframeType keytype, | eBezTriple_KeyframeType keytype, | ||||
| eInsertKeyFlags flag) | eInsertKeyFlags flag) | ||||
| { | { | ||||
| /* F-Curve not editable? */ | /* F-Curve not editable? */ | ||||
| if (BKE_fcurve_is_keyframable(fcu) == 0) { | if (BKE_fcurve_is_keyframable(fcu) == 0) { | ||||
| BKE_reportf( | BKE_reportf( | ||||
| reports, | reports, | ||||
| RPT_ERROR, | RPT_ERROR, | ||||
| "F-Curve with path '%s[%d]' cannot be keyframed, ensure that it is not locked or sampled, " | "F-Curve with path '%s[%d]' cannot be keyframed, ensure that it is not locked or sampled, " | ||||
| "and try removing F-Modifiers", | "and try removing F-Modifiers", | ||||
| fcu->rna_path, | fcu->rna_path, | ||||
| fcu->array_index); | fcu->array_index); | ||||
| return false; | return false; | ||||
| } | } | ||||
| float cfra = anim_eval_context->eval_time; | |||||
| /* adjust frame on which to add keyframe */ | /* adjust frame on which to add keyframe */ | ||||
| if ((flag & INSERTKEY_DRIVER) && (fcu->driver)) { | if ((flag & INSERTKEY_DRIVER) && (fcu->driver)) { | ||||
| PathResolvedRNA anim_rna; | PathResolvedRNA anim_rna; | ||||
| if (RNA_path_resolved_create(ptr, prop, fcu->array_index, &anim_rna)) { | if (RNA_path_resolved_create(ptr, prop, fcu->array_index, &anim_rna)) { | ||||
| /* for making it easier to add corrective drivers... */ | /* for making it easier to add corrective drivers... */ | ||||
| cfra = evaluate_driver(&anim_rna, fcu->driver, fcu->driver, cfra); | cfra = evaluate_driver(&anim_rna, fcu->driver, fcu->driver, anim_eval_context); | ||||
| } | } | ||||
| else { | else { | ||||
| cfra = 0.0f; | cfra = 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| /* adjust coordinates for cycle aware insertion */ | /* adjust coordinates for cycle aware insertion */ | ||||
| if (flag & INSERTKEY_CYCLE_AWARE) { | if (flag & INSERTKEY_CYCLE_AWARE) { | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| * The flag argument is used for special settings that alter the behavior of | * The flag argument is used for special settings that alter the behavior of | ||||
| * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, | * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, | ||||
| * and extra keyframe filtering. | * and extra keyframe filtering. | ||||
| */ | */ | ||||
| bool insert_keyframe_direct(ReportList *reports, | bool insert_keyframe_direct(ReportList *reports, | ||||
| PointerRNA ptr, | PointerRNA ptr, | ||||
| PropertyRNA *prop, | PropertyRNA *prop, | ||||
| FCurve *fcu, | FCurve *fcu, | ||||
| float cfra, | const AnimationEvalContext *anim_eval_context, | ||||
| eBezTriple_KeyframeType keytype, | eBezTriple_KeyframeType keytype, | ||||
| struct NlaKeyframingContext *nla_context, | struct NlaKeyframingContext *nla_context, | ||||
| eInsertKeyFlags flag) | eInsertKeyFlags flag) | ||||
| { | { | ||||
| float curval = 0.0f; | float curval = 0.0f; | ||||
| /* no F-Curve to add keyframe to? */ | /* no F-Curve to add keyframe to? */ | ||||
| if (fcu == NULL) { | if (fcu == NULL) { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | bool insert_keyframe_direct(ReportList *reports, | ||||
| if (index >= 0 && index < value_count) { | if (index >= 0 && index < value_count) { | ||||
| curval = values[index]; | curval = values[index]; | ||||
| } | } | ||||
| if (values != value_buffer) { | if (values != value_buffer) { | ||||
| MEM_freeN(values); | MEM_freeN(values); | ||||
| } | } | ||||
| return insert_keyframe_value(reports, &ptr, prop, fcu, cfra, curval, keytype, flag); | return insert_keyframe_value(reports, &ptr, prop, fcu, anim_eval_context, curval, keytype, flag); | ||||
| } | } | ||||
| /* Find or create the FCurve based on the given path, and insert the specified value into it. */ | /* Find or create the FCurve based on the given path, and insert the specified value into it. */ | ||||
| static bool insert_keyframe_fcurve_value(Main *bmain, | static bool insert_keyframe_fcurve_value(Main *bmain, | ||||
| ReportList *reports, | ReportList *reports, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| PropertyRNA *prop, | PropertyRNA *prop, | ||||
| bAction *act, | bAction *act, | ||||
| const char group[], | const char group[], | ||||
| const char rna_path[], | const char rna_path[], | ||||
| int array_index, | int array_index, | ||||
| float cfra, | const AnimationEvalContext *anim_eval_context, | ||||
| float curval, | float curval, | ||||
| eBezTriple_KeyframeType keytype, | eBezTriple_KeyframeType keytype, | ||||
| eInsertKeyFlags flag) | eInsertKeyFlags flag) | ||||
| { | { | ||||
| /* make sure the F-Curve exists | /* make sure the F-Curve exists | ||||
| * - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet | * - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet | ||||
| * but still try to get the F-Curve if it exists... | * but still try to get the F-Curve if it exists... | ||||
| */ | */ | ||||
| Show All 17 Lines | if ((fcu->totvert == 0) && (flag & INSERTKEY_XYZ2RGB)) { | ||||
| fcu->color_mode = FCURVE_COLOR_AUTO_YRGB; | fcu->color_mode = FCURVE_COLOR_AUTO_YRGB; | ||||
| } | } | ||||
| } | } | ||||
| /* update F-Curve flags to ensure proper behavior for property type */ | /* update F-Curve flags to ensure proper behavior for property type */ | ||||
| update_autoflags_fcurve_direct(fcu, prop); | update_autoflags_fcurve_direct(fcu, prop); | ||||
| /* insert keyframe */ | /* insert keyframe */ | ||||
| return insert_keyframe_value(reports, ptr, prop, fcu, cfra, curval, keytype, flag); | return insert_keyframe_value( | ||||
| reports, ptr, prop, fcu, anim_eval_context, curval, keytype, flag); | |||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static AnimationEvalContext nla_time_remap(const AnimationEvalContext *anim_eval_context, | |||||
| PointerRNA *id_ptr, | |||||
| AnimData *adt, | |||||
| bAction *act, | |||||
| ListBase *nla_cache, | |||||
| NlaKeyframingContext **r_nla_context) | |||||
| { | |||||
| if (adt && adt->action == act) { | |||||
| /* Get NLA context for value remapping. */ | |||||
| *r_nla_context = BKE_animsys_get_nla_keyframing_context( | |||||
| nla_cache, id_ptr, adt, anim_eval_context, false); | |||||
| /* Apply NLA-mapping to frame. */ | |||||
| const float remapped_frame = BKE_nla_tweakedit_remap( | |||||
| adt, anim_eval_context->eval_time, NLATIME_CONVERT_UNMAP); | |||||
| return BKE_animsys_eval_context_construct_at(anim_eval_context, remapped_frame); | |||||
| } | |||||
| *r_nla_context = NULL; | |||||
| return *anim_eval_context; | |||||
| } | |||||
| /** | /** | ||||
| * Main Keyframing API call | * Main Keyframing API call | ||||
| * | * | ||||
| * Use this when validation of necessary animation data is necessary, since it may not exist yet. | * 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 flag argument is used for special settings that alter the behavior of | ||||
| * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, | * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, | ||||
| * and extra keyframe filtering. | * and extra keyframe filtering. | ||||
| * | * | ||||
| * index of -1 keys all array indices | * index of -1 keys all array indices | ||||
| * | * | ||||
| * \return The number of key-frames inserted. | * \return The number of key-frames inserted. | ||||
| */ | */ | ||||
| int insert_keyframe(Main *bmain, | int insert_keyframe(Main *bmain, | ||||
| ReportList *reports, | ReportList *reports, | ||||
| ID *id, | ID *id, | ||||
| bAction *act, | bAction *act, | ||||
| const char group[], | const char group[], | ||||
| const char rna_path[], | const char rna_path[], | ||||
| int array_index, | int array_index, | ||||
| float cfra, | const AnimationEvalContext *anim_eval_context, | ||||
| eBezTriple_KeyframeType keytype, | eBezTriple_KeyframeType keytype, | ||||
| ListBase *nla_cache, | ListBase *nla_cache, | ||||
| eInsertKeyFlags flag) | eInsertKeyFlags flag) | ||||
| { | { | ||||
| PointerRNA id_ptr, ptr; | PointerRNA id_ptr, ptr; | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| AnimData *adt; | AnimData *adt; | ||||
| ListBase tmp_nla_cache = {NULL, NULL}; | ListBase tmp_nla_cache = {NULL, NULL}; | ||||
| Show All 30 Lines | if (act == NULL) { | ||||
| id->name, | id->name, | ||||
| rna_path); | rna_path); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| /* apply NLA-mapping to frame to use (if applicable) */ | /* apply NLA-mapping to frame to use (if applicable) */ | ||||
| adt = BKE_animdata_from_id(id); | adt = BKE_animdata_from_id(id); | ||||
| const AnimationEvalContext remapped_context = nla_time_remap( | |||||
| if (adt && adt->action == act) { | anim_eval_context, &id_ptr, adt, act, nla_cache ? nla_cache : &tmp_nla_cache, &nla_context); | ||||
| /* Get NLA context for value remapping. */ | |||||
| nla_context = BKE_animsys_get_nla_keyframing_context( | |||||
| nla_cache ? nla_cache : &tmp_nla_cache, &id_ptr, adt, cfra, false); | |||||
| /* Apply NLA-mapping to frame. */ | |||||
| cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); | |||||
| } | |||||
| /* Obtain values to insert. */ | /* Obtain values to insert. */ | ||||
| float value_buffer[RNA_MAX_ARRAY_LENGTH]; | float value_buffer[RNA_MAX_ARRAY_LENGTH]; | ||||
| int value_count; | int value_count; | ||||
| bool force_all; | bool force_all; | ||||
| float *values = get_keyframe_values(reports, | float *values = get_keyframe_values(reports, | ||||
| ptr, | ptr, | ||||
| Show All 17 Lines | if (array_index == -1 || force_all) { | ||||
| if (insert_keyframe_fcurve_value(bmain, | if (insert_keyframe_fcurve_value(bmain, | ||||
| reports, | reports, | ||||
| &ptr, | &ptr, | ||||
| prop, | prop, | ||||
| act, | act, | ||||
| group, | group, | ||||
| rna_path, | rna_path, | ||||
| array_index, | array_index, | ||||
| cfra, | &remapped_context, | ||||
| values[array_index], | values[array_index], | ||||
| keytype, | keytype, | ||||
| flag)) { | flag)) { | ||||
| ret++; | ret++; | ||||
| exclude = array_index; | exclude = array_index; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (exclude != -1) { | if (exclude != -1) { | ||||
| flag &= ~(INSERTKEY_REPLACE | INSERTKEY_AVAILABLE); | flag &= ~(INSERTKEY_REPLACE | INSERTKEY_AVAILABLE); | ||||
| for (array_index = 0; array_index < value_count; array_index++) { | for (array_index = 0; array_index < value_count; array_index++) { | ||||
| if (array_index != exclude) { | if (array_index != exclude) { | ||||
| ret += insert_keyframe_fcurve_value(bmain, | ret += insert_keyframe_fcurve_value(bmain, | ||||
| reports, | reports, | ||||
| &ptr, | &ptr, | ||||
| prop, | prop, | ||||
| act, | act, | ||||
| group, | group, | ||||
| rna_path, | rna_path, | ||||
| array_index, | array_index, | ||||
| cfra, | &remapped_context, | ||||
| values[array_index], | values[array_index], | ||||
| keytype, | keytype, | ||||
| flag); | flag); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Simply insert all channels. */ | /* Simply insert all channels. */ | ||||
| else { | else { | ||||
| for (array_index = 0; array_index < value_count; array_index++) { | for (array_index = 0; array_index < value_count; array_index++) { | ||||
| ret += insert_keyframe_fcurve_value(bmain, | ret += insert_keyframe_fcurve_value(bmain, | ||||
| reports, | reports, | ||||
| &ptr, | &ptr, | ||||
| prop, | prop, | ||||
| act, | act, | ||||
| group, | group, | ||||
| rna_path, | rna_path, | ||||
| array_index, | array_index, | ||||
| cfra, | &remapped_context, | ||||
| values[array_index], | values[array_index], | ||||
| keytype, | keytype, | ||||
| flag); | flag); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Key a single index. */ | /* Key a single index. */ | ||||
| else { | else { | ||||
| if (array_index >= 0 && array_index < value_count) { | if (array_index >= 0 && array_index < value_count) { | ||||
| ret += insert_keyframe_fcurve_value(bmain, | ret += insert_keyframe_fcurve_value(bmain, | ||||
| reports, | reports, | ||||
| &ptr, | &ptr, | ||||
| prop, | prop, | ||||
| act, | act, | ||||
| group, | group, | ||||
| rna_path, | rna_path, | ||||
| array_index, | array_index, | ||||
| cfra, | &remapped_context, | ||||
| values[array_index], | values[array_index], | ||||
| keytype, | keytype, | ||||
| flag); | flag); | ||||
| } | } | ||||
| } | } | ||||
| if (values != value_buffer) { | if (values != value_buffer) { | ||||
| MEM_freeN(values); | MEM_freeN(values); | ||||
| ▲ Show 20 Lines • Show All 863 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| PointerRNA ptr = {NULL}; | PointerRNA ptr = {NULL}; | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| char *path; | char *path; | ||||
| uiBut *but; | uiBut *but; | ||||
| float cfra = (float)CFRA; | const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct( | ||||
| CTX_data_depsgraph_pointer(C), (float)CFRA); | |||||
| bool changed = false; | bool changed = false; | ||||
| int index; | int index; | ||||
| const bool all = RNA_boolean_get(op->ptr, "all"); | const bool all = RNA_boolean_get(op->ptr, "all"); | ||||
| eInsertKeyFlags flag = INSERTKEY_NOFLAGS; | eInsertKeyFlags flag = INSERTKEY_NOFLAGS; | ||||
| /* flags for inserting keyframes */ | /* flags for inserting keyframes */ | ||||
| flag = ANIM_get_keyframing_flags(scene, true); | flag = ANIM_get_keyframing_flags(scene, true); | ||||
| Show All 9 Lines | if (ptr.type == &RNA_NlaStrip) { | ||||
| * strips themselves. These are stored separately or else the properties will | * strips themselves. These are stored separately or else the properties will | ||||
| * not have any effect. | * not have any effect. | ||||
| */ | */ | ||||
| NlaStrip *strip = ptr.data; | NlaStrip *strip = ptr.data; | ||||
| FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), index); | FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), index); | ||||
| if (fcu) { | if (fcu) { | ||||
| changed = insert_keyframe_direct( | changed = insert_keyframe_direct( | ||||
| op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); | op->reports, ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, 0); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_report(op->reports, | BKE_report(op->reports, | ||||
| RPT_ERROR, | RPT_ERROR, | ||||
| "This property cannot be animated as it will not get updated correctly"); | "This property cannot be animated as it will not get updated correctly"); | ||||
| } | } | ||||
| } | } | ||||
| else if (UI_but_flag_is_set(but, UI_BUT_DRIVEN)) { | else if (UI_but_flag_is_set(but, UI_BUT_DRIVEN)) { | ||||
| /* Driven property - Find driver */ | /* Driven property - Find driver */ | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| bool driven, special; | bool driven, special; | ||||
| fcu = BKE_fcurve_find_by_rna_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); | fcu = BKE_fcurve_find_by_rna_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); | ||||
| if (fcu && driven) { | if (fcu && driven) { | ||||
| changed = insert_keyframe_direct( | changed = insert_keyframe_direct(op->reports, | ||||
| op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, INSERTKEY_DRIVER); | ptr, | ||||
| prop, | |||||
| fcu, | |||||
| &anim_eval_context, | |||||
| ts->keyframe_type, | |||||
| NULL, | |||||
| INSERTKEY_DRIVER); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* standard properties */ | /* standard properties */ | ||||
| path = RNA_path_from_ID_to_property(&ptr, prop); | path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| if (path) { | if (path) { | ||||
| const char *identifier = RNA_property_identifier(prop); | const char *identifier = RNA_property_identifier(prop); | ||||
| Show All 26 Lines | else { | ||||
| changed = (insert_keyframe(bmain, | changed = (insert_keyframe(bmain, | ||||
| op->reports, | op->reports, | ||||
| ptr.owner_id, | ptr.owner_id, | ||||
| NULL, | NULL, | ||||
| group, | group, | ||||
| path, | path, | ||||
| index, | index, | ||||
| cfra, | &anim_eval_context, | ||||
| ts->keyframe_type, | ts->keyframe_type, | ||||
| NULL, | NULL, | ||||
| flag) != 0); | flag) != 0); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_report(op->reports, | BKE_report(op->reports, | ||||
| ▲ Show 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | if (replace) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Returns whether the current value of a given property differs from the interpolated value. */ | /* Returns whether the current value of a given property differs from the interpolated value. */ | ||||
| bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float frame) | bool fcurve_is_changed(PointerRNA ptr, | ||||
| PropertyRNA *prop, | |||||
| FCurve *fcu, | |||||
| const AnimationEvalContext *anim_eval_context) | |||||
| { | { | ||||
| PathResolvedRNA anim_rna; | PathResolvedRNA anim_rna; | ||||
| anim_rna.ptr = ptr; | anim_rna.ptr = ptr; | ||||
| anim_rna.prop = prop; | anim_rna.prop = prop; | ||||
| anim_rna.prop_index = fcu->array_index; | anim_rna.prop_index = fcu->array_index; | ||||
| float buffer[RNA_MAX_ARRAY_LENGTH]; | float buffer[RNA_MAX_ARRAY_LENGTH]; | ||||
| int count, index = fcu->array_index; | int count, index = fcu->array_index; | ||||
| float *values = setting_get_rna_values(&ptr, prop, buffer, RNA_MAX_ARRAY_LENGTH, &count); | float *values = setting_get_rna_values(&ptr, prop, buffer, RNA_MAX_ARRAY_LENGTH, &count); | ||||
| float fcurve_val = calculate_fcurve(&anim_rna, fcu, frame); | float fcurve_val = calculate_fcurve(&anim_rna, fcu, anim_eval_context); | ||||
| float cur_val = (index >= 0 && index < count) ? values[index] : 0.0f; | float cur_val = (index >= 0 && index < count) ? values[index] : 0.0f; | ||||
| if (values != buffer) { | if (values != buffer) { | ||||
| MEM_freeN(values); | MEM_freeN(values); | ||||
| } | } | ||||
| return !compare_ff_relative(fcurve_val, cur_val, FLT_EPSILON, 64); | return !compare_ff_relative(fcurve_val, cur_val, FLT_EPSILON, 64); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Use for auto-keyframing from the UI. | * Use for auto-keyframing from the UI. | ||||
| */ | */ | ||||
| bool ED_autokeyframe_property( | bool ED_autokeyframe_property( | ||||
| bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra) | bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(depsgraph, | |||||
| cfra); | |||||
| ID *id; | ID *id; | ||||
| bAction *action; | bAction *action; | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| bool driven; | bool driven; | ||||
| bool special; | bool special; | ||||
| bool changed = false; | bool changed = false; | ||||
| fcu = BKE_fcurve_find_by_rna_context_ui( | fcu = BKE_fcurve_find_by_rna_context_ui( | ||||
| C, ptr, prop, rnaindex, NULL, &action, &driven, &special); | C, ptr, prop, rnaindex, NULL, &action, &driven, &special); | ||||
| if (fcu == NULL) { | if (fcu == NULL) { | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| if (special) { | if (special) { | ||||
| /* NLA Strip property */ | /* NLA Strip property */ | ||||
| if (IS_AUTOKEY_ON(scene)) { | if (IS_AUTOKEY_ON(scene)) { | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| changed = insert_keyframe_direct(reports, *ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); | changed = insert_keyframe_direct( | ||||
| reports, *ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, 0); | |||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else if (driven) { | else if (driven) { | ||||
| /* Driver - Try to insert keyframe using the driver's input as the frame, | /* Driver - Try to insert keyframe using the driver's input as the frame, | ||||
| * making it easier to set up corrective drivers | * making it easier to set up corrective drivers | ||||
| */ | */ | ||||
| if (IS_AUTOKEY_ON(scene)) { | if (IS_AUTOKEY_ON(scene)) { | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| changed = insert_keyframe_direct( | changed = insert_keyframe_direct( | ||||
| reports, *ptr, prop, fcu, cfra, ts->keyframe_type, NULL, INSERTKEY_DRIVER); | reports, *ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, INSERTKEY_DRIVER); | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| id = ptr->owner_id; | id = ptr->owner_id; | ||||
| /* TODO: this should probably respect the keyingset only option for anim */ | /* TODO: this should probably respect the keyingset only option for anim */ | ||||
| if (autokeyframe_cfra_can_key(scene, id)) { | if (autokeyframe_cfra_can_key(scene, id)) { | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| const eInsertKeyFlags flag = ANIM_get_keyframing_flags(scene, true); | const eInsertKeyFlags flag = ANIM_get_keyframing_flags(scene, true); | ||||
| /* Note: We use rnaindex instead of fcu->array_index, | /* Note: We use rnaindex instead of fcu->array_index, | ||||
| * because a button may control all items of an array at once. | * because a button may control all items of an array at once. | ||||
| * E.g., color wheels (see T42567). */ | * E.g., color wheels (see T42567). */ | ||||
| BLI_assert((fcu->array_index == rnaindex) || (rnaindex == -1)); | BLI_assert((fcu->array_index == rnaindex) || (rnaindex == -1)); | ||||
| changed = insert_keyframe(bmain, | changed = insert_keyframe(bmain, | ||||
| reports, | reports, | ||||
| id, | id, | ||||
| action, | action, | ||||
| ((fcu->grp) ? (fcu->grp->name) : (NULL)), | ((fcu->grp) ? (fcu->grp->name) : (NULL)), | ||||
| fcu->rna_path, | fcu->rna_path, | ||||
| rnaindex, | rnaindex, | ||||
| cfra, | &anim_eval_context, | ||||
| ts->keyframe_type, | ts->keyframe_type, | ||||
| NULL, | NULL, | ||||
| flag) != 0; | flag) != 0; | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| Show All 34 Lines | |||||