Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_channels_defines.c
| Show First 20 Lines • Show All 4,714 Lines • ▼ Show 20 Lines | |||||
| static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin) | static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin) | ||||
| { | { | ||||
| ID *id = (ID *)id_poin; | ID *id = (ID *)id_poin; | ||||
| AnimData *adt = BKE_animdata_from_id(id); | AnimData *adt = BKE_animdata_from_id(id); | ||||
| FCurve *fcu = (FCurve *)fcu_poin; | FCurve *fcu = (FCurve *)fcu_poin; | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| ListBase nla_cache = {NULL, NULL}; | ListBase nla_cache = {NULL, NULL}; | ||||
| PointerRNA id_ptr, ptr; | PointerRNA id_ptr, ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| eInsertKeyFlags flag = 0; | eInsertKeyFlags flag = 0; | ||||
| bool done = false; | bool done = false; | ||||
| float cfra; | float cfra; | ||||
| /* Get RNA pointer */ | /* Get RNA pointer */ | ||||
| RNA_id_pointer_create(id, &id_ptr); | RNA_id_pointer_create(id, &id_ptr); | ||||
| /* Get NLA context for value remapping */ | /* Get NLA context for value remapping */ | ||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context(depsgraph, (float)CFRA); | |||||
| NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( | NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( | ||||
| &nla_cache, &id_ptr, adt, (float)CFRA, false); | &nla_cache, &id_ptr, adt, &anim_eval_context, false); | ||||
| /* get current frame and apply NLA-mapping to it (if applicable) */ | /* get current frame and apply NLA-mapping to it (if applicable) */ | ||||
| cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); | cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); | ||||
| /* Get flags for keyframing. */ | /* Get flags for keyframing. */ | ||||
| flag = ANIM_get_keyframing_flags(scene, true); | flag = ANIM_get_keyframing_flags(scene, true); | ||||
| /* try to resolve the path stored in the F-Curve */ | /* try to resolve the path stored in the F-Curve */ | ||||
| if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { | if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { | ||||
| /* set the special 'replace' flag if on a keyframe */ | /* set the special 'replace' flag if on a keyframe */ | ||||
| if (fcurve_frame_has_keyframe(fcu, cfra, 0)) { | if (fcurve_frame_has_keyframe(fcu, cfra, 0)) { | ||||
| flag |= INSERTKEY_REPLACE; | flag |= INSERTKEY_REPLACE; | ||||
| } | } | ||||
| /* insert a keyframe for this F-Curve */ | /* insert a keyframe for this F-Curve */ | ||||
| done = insert_keyframe_direct( | done = insert_keyframe_direct( | ||||
| reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); | reports, ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, nla_context, flag); | ||||
| if (done) { | if (done) { | ||||
| if (adt->action != NULL) { | if (adt->action != NULL) { | ||||
| DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH); | DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH); | ||||
| } | } | ||||
| DEG_id_tag_update(id, ID_RECALC_ANIMATION_NO_FLUSH); | DEG_id_tag_update(id, ID_RECALC_ANIMATION_NO_FLUSH); | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); | BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); | ||||
| } | } | ||||
| /* callback for shapekey widget sliders - insert keyframes */ | /* callback for shapekey widget sliders - insert keyframes */ | ||||
| static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, void *kb_poin) | static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, void *kb_poin) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Key *key = (Key *)key_poin; | Key *key = (Key *)key_poin; | ||||
| KeyBlock *kb = (KeyBlock *)kb_poin; | KeyBlock *kb = (KeyBlock *)kb_poin; | ||||
| char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); | char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| ListBase nla_cache = {NULL, NULL}; | ListBase nla_cache = {NULL, NULL}; | ||||
| PointerRNA id_ptr, ptr; | PointerRNA id_ptr, ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| eInsertKeyFlags flag = 0; | eInsertKeyFlags flag = 0; | ||||
| bool done = false; | bool done = false; | ||||
| float cfra; | |||||
| /* Get RNA pointer */ | /* Get RNA pointer */ | ||||
| RNA_id_pointer_create((ID *)key, &id_ptr); | RNA_id_pointer_create((ID *)key, &id_ptr); | ||||
| /* Get NLA context for value remapping */ | /* Get NLA context for value remapping */ | ||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context(depsgraph, (float)CFRA); | |||||
| NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( | NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( | ||||
| &nla_cache, &id_ptr, key->adt, (float)CFRA, false); | &nla_cache, &id_ptr, key->adt, &anim_eval_context, false); | ||||
| /* get current frame and apply NLA-mapping to it (if applicable) */ | /* get current frame and apply NLA-mapping to it (if applicable) */ | ||||
| cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP); | const float remapped_frame = BKE_nla_tweakedit_remap( | ||||
| key->adt, anim_eval_context.eval_time, NLATIME_CONVERT_UNMAP); | |||||
| /* get flags for keyframing */ | /* get flags for keyframing */ | ||||
| flag = ANIM_get_keyframing_flags(scene, true); | flag = ANIM_get_keyframing_flags(scene, true); | ||||
| /* try to resolve the path stored in the F-Curve */ | /* try to resolve the path stored in the F-Curve */ | ||||
| if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) { | if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) { | ||||
| /* find or create new F-Curve */ | /* find or create new F-Curve */ | ||||
| // XXX is the group name for this ok? | // XXX is the group name for this ok? | ||||
| bAction *act = ED_id_action_ensure(bmain, (ID *)key); | bAction *act = ED_id_action_ensure(bmain, (ID *)key); | ||||
| FCurve *fcu = ED_action_fcurve_ensure(bmain, act, NULL, &ptr, rna_path, 0); | FCurve *fcu = ED_action_fcurve_ensure(bmain, act, NULL, &ptr, rna_path, 0); | ||||
| /* set the special 'replace' flag if on a keyframe */ | /* set the special 'replace' flag if on a keyframe */ | ||||
| if (fcurve_frame_has_keyframe(fcu, cfra, 0)) { | if (fcurve_frame_has_keyframe(fcu, remapped_frame, 0)) { | ||||
| flag |= INSERTKEY_REPLACE; | flag |= INSERTKEY_REPLACE; | ||||
| } | } | ||||
| /* insert a keyframe for this F-Curve */ | /* insert a keyframe for this F-Curve */ | ||||
| done = insert_keyframe_direct( | const AnimationEvalContext remapped_anim_eval_context = BKE_animsys_eval_context_at( | ||||
| reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); | &anim_eval_context, remapped_frame); | ||||
| done = insert_keyframe_direct(reports, | |||||
| ptr, | |||||
| prop, | |||||
| fcu, | |||||
| &remapped_anim_eval_context, | |||||
| ts->keyframe_type, | |||||
| nla_context, | |||||
| flag); | |||||
| if (done) { | if (done) { | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* free the path */ | /* free the path */ | ||||
| if (rna_path) { | if (rna_path) { | ||||
| Show All 34 Lines | static void achannel_setting_slider_nla_curve_cb(bContext *C, | ||||
| if (fcu && prop) { | if (fcu && prop) { | ||||
| /* set the special 'replace' flag if on a keyframe */ | /* set the special 'replace' flag if on a keyframe */ | ||||
| if (fcurve_frame_has_keyframe(fcu, cfra, 0)) { | if (fcurve_frame_has_keyframe(fcu, cfra, 0)) { | ||||
| flag |= INSERTKEY_REPLACE; | flag |= INSERTKEY_REPLACE; | ||||
| } | } | ||||
| /* insert a keyframe for this F-Curve */ | /* insert a keyframe for this F-Curve */ | ||||
| done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context(depsgraph, cfra); | |||||
| done = insert_keyframe_direct( | |||||
| reports, ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, flag); | |||||
| if (done) { | if (done) { | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Draw a widget for some setting */ | /* Draw a widget for some setting */ | ||||
| ▲ Show 20 Lines • Show All 643 Lines • Show Last 20 Lines | |||||