Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_object.c
| Show First 20 Lines • Show All 788 Lines • ▼ Show 20 Lines | static void autokeyframe_object( | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| // TODO: this should probably be done per channel instead... | // TODO: this should probably be done per channel instead... | ||||
| 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; | ||||
| KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); | KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); | ||||
| ListBase dsources = {NULL, NULL}; | ListBase dsources = {NULL, NULL}; | ||||
| float cfra = (float)CFRA; // xxx this will do for now | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context(depsgraph, | |||||
| (float)CFRA); | |||||
| eInsertKeyFlags flag = 0; | eInsertKeyFlags flag = 0; | ||||
| /* Get flags used for inserting keyframes. */ | /* Get flags used for inserting keyframes. */ | ||||
| flag = ANIM_get_keyframing_flags(scene, true); | flag = ANIM_get_keyframing_flags(scene, true); | ||||
| /* add datasource override for the object */ | /* add datasource override for the object */ | ||||
| ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL); | ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL); | ||||
| if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { | if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { | ||||
| /* Only insert into active keyingset | /* Only insert into active keyingset | ||||
| * NOTE: we assume here that the active Keying Set | * NOTE: we assume here that the active Keying Set | ||||
| * does not need to have its iterator overridden. | * does not need to have its iterator overridden. | ||||
| */ | */ | ||||
| ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); | ANIM_apply_keyingset( | ||||
| C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, anim_eval_context.eval_time); | |||||
| } | } | ||||
| else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { | else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { | ||||
| AnimData *adt = ob->adt; | AnimData *adt = ob->adt; | ||||
| /* only key on available channels */ | /* only key on available channels */ | ||||
| if (adt && adt->action) { | if (adt && adt->action) { | ||||
| ListBase nla_cache = {NULL, NULL}; | ListBase nla_cache = {NULL, NULL}; | ||||
| for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { | for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { | ||||
| insert_keyframe(bmain, | insert_keyframe(bmain, | ||||
| reports, | reports, | ||||
| id, | id, | ||||
| adt->action, | adt->action, | ||||
| (fcu->grp ? fcu->grp->name : NULL), | (fcu->grp ? fcu->grp->name : NULL), | ||||
| fcu->rna_path, | fcu->rna_path, | ||||
| fcu->array_index, | fcu->array_index, | ||||
| cfra, | &anim_eval_context, | ||||
| ts->keyframe_type, | ts->keyframe_type, | ||||
| &nla_cache, | &nla_cache, | ||||
| flag); | flag); | ||||
| } | } | ||||
| BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); | BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); | ||||
| } | } | ||||
| } | } | ||||
| Show All 31 Lines | else if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) { | ||||
| if ((scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) == 0) { | if ((scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) == 0) { | ||||
| do_scale = true; | do_scale = true; | ||||
| } | } | ||||
| } | } | ||||
| /* insert keyframes for the affected sets of channels using the builtin KeyingSets found */ | /* insert keyframes for the affected sets of channels using the builtin KeyingSets found */ | ||||
| if (do_loc) { | if (do_loc) { | ||||
| KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID); | KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID); | ||||
| ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); | ANIM_apply_keyingset( | ||||
| C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, anim_eval_context.eval_time); | |||||
| } | } | ||||
| if (do_rot) { | if (do_rot) { | ||||
| KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID); | KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID); | ||||
| ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); | ANIM_apply_keyingset( | ||||
| C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, anim_eval_context.eval_time); | |||||
| } | } | ||||
| if (do_scale) { | if (do_scale) { | ||||
| KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID); | KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID); | ||||
| ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); | ANIM_apply_keyingset( | ||||
| C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, anim_eval_context.eval_time); | |||||
| } | } | ||||
| } | } | ||||
| /* insert keyframe in all (transform) channels */ | /* insert keyframe in all (transform) channels */ | ||||
| else { | else { | ||||
| KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); | KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); | ||||
| ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); | ANIM_apply_keyingset( | ||||
| C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, anim_eval_context.eval_time); | |||||
| } | } | ||||
| /* free temp info */ | /* free temp info */ | ||||
| BLI_freelistN(&dsources); | BLI_freelistN(&dsources); | ||||
| } | } | ||||
| } | } | ||||
| /* Return if we need to update motion paths, only if they already exist, | /* Return if we need to update motion paths, only if they already exist, | ||||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||