diff options
author | Colin Marmond <Kdaf> | 2022-04-26 13:29:22 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-04-26 13:33:35 +0300 |
commit | 4e57b6ce77b15709d7a76382c2d185f9c845532c (patch) | |
tree | 2ba2d7c1ef368799779fbd3fd484f72077101e36 /source/blender/editors/animation/anim_motion_paths.c | |
parent | 6cf148227b220dd5087241ad01b6d2d6fe9afb80 (diff) |
Animation: Sensible frame range for motion paths
Motion paths can now be initialised to more sensible frame ranges,
rather than simply 1-250:
- Scene Frame Range
- Selected Keyframes
- All Keyframes
Reviewed By: sybren, looch, dfelinto, pablico
Maniphest Tasks: T93047
Differential Revision: https://developer.blender.org/D13687
Diffstat (limited to 'source/blender/editors/animation/anim_motion_paths.c')
-rw-r--r-- | source/blender/editors/animation/anim_motion_paths.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index 539227933cf..b15bd3db678 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -340,6 +340,43 @@ static void motionpath_free_free_tree_data(ListBase *targets) } } +void animviz_motionpath_compute_range(Object *ob, Scene *scene) +{ + bAnimVizSettings *avs = ob->mode == OB_MODE_POSE ? &ob->pose->avs : &ob->avs; + + const bool has_action = ob->adt && ob->adt->action; + if (avs->path_range == MOTIONPATH_RANGE_SCENE || !has_action || + BLI_listbase_is_empty(&ob->adt->action->curves)) { + avs->path_sf = PSFRA; + avs->path_ef = PEFRA; + return; + } + + struct AnimKeylist *keylist = ED_keylist_create(); + LISTBASE_FOREACH (FCurve *, fcu, &ob->adt->action->curves) { + fcurve_to_keylist(ob->adt, fcu, keylist, 0); + } + + Range2f frame_range; + switch (avs->path_range) { + case MOTIONPATH_RANGE_KEYS_SELECTED: + if (ED_keylist_selected_keys_frame_range(keylist, &frame_range)) { + break; + } + ATTR_FALLTHROUGH; // Fall through if there were no selected keys found. + case MOTIONPATH_RANGE_KEYS_ALL: + ED_keylist_all_keys_frame_range(keylist, &frame_range); + break; + case MOTIONPATH_RANGE_SCENE: + BLI_assert_msg(false, "This should not happen, function should have exited earlier."); + }; + + avs->path_sf = frame_range.min; + avs->path_ef = frame_range.max; + + ED_keylist_free(keylist); +} + void animviz_calc_motionpaths(Depsgraph *depsgraph, Main *bmain, Scene *scene, |