Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_armature.c
| Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if (!autokeyframe_cfra_can_key(scene, id)) { | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| 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 nla_cache = {NULL, NULL}; | ListBase nla_cache = {NULL, NULL}; | ||||
| float cfra = (float)CFRA; | 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; | ||||
| /* flag is initialized from UserPref keyframing settings | /* flag is initialized from UserPref keyframing settings | ||||
| * - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get | * - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get | ||||
| * visual keyframes even if flag not set, as it's not that useful otherwise | * visual keyframes even if flag not set, as it's not that useful otherwise | ||||
| * (for quick animation recording) | * (for quick animation recording) | ||||
| */ | */ | ||||
| flag = ANIM_get_keyframing_flags(scene, true); | flag = ANIM_get_keyframing_flags(scene, true); | ||||
| Show All 14 Lines | for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| pchan->bone->flag &= ~BONE_UNKEYED; | pchan->bone->flag &= ~BONE_UNKEYED; | ||||
| /* add datasource override for the camera object */ | /* add datasource override for the camera object */ | ||||
| ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); | ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); | ||||
| /* only insert into active keyingset? */ | /* only insert into active keyingset? */ | ||||
| if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { | if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { | ||||
| /* run the active Keying Set on the current datasource */ | /* run the active Keying Set on the current datasource */ | ||||
| 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); | |||||
| } | } | ||||
| /* only insert into available channels? */ | /* only insert into available channels? */ | ||||
| else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { | else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { | ||||
| if (act) { | if (act) { | ||||
| for (fcu = act->curves.first; fcu; fcu = fcu->next) { | for (fcu = act->curves.first; fcu; fcu = fcu->next) { | ||||
| /* only insert keyframes for this F-Curve if it affects the current bone */ | /* only insert keyframes for this F-Curve if it affects the current bone */ | ||||
| if (strstr(fcu->rna_path, "bones") == NULL) { | if (strstr(fcu->rna_path, "bones") == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); | char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); | ||||
| /* only if bone name matches too... | /* only if bone name matches too... | ||||
| * NOTE: this will do constraints too, but those are ok to do here too? | * NOTE: this will do constraints too, but those are ok to do here too? | ||||
| */ | */ | ||||
| if (pchanName && STREQ(pchanName, pchan->name)) { | if (pchanName && STREQ(pchanName, pchan->name)) { | ||||
| insert_keyframe(bmain, | insert_keyframe(bmain, | ||||
| reports, | reports, | ||||
| id, | id, | ||||
| act, | act, | ||||
| ((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); | ||||
| } | } | ||||
| if (pchanName) { | if (pchanName) { | ||||
| MEM_freeN(pchanName); | MEM_freeN(pchanName); | ||||
| } | } | ||||
| Show All 34 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; | ||||
| } | } | ||||
| } | } | ||||
| 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); | ||||
| } | } | ||||
| BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); | BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,538 Lines • Show Last 20 Lines | |||||