Animation: Add "Frame Channel" operators #104523
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#104523
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChrisLend/blender:frame-channel-operator"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When animating it is often useful to frame the Graph Editor/Dope Sheet to whatever frames are in a given channel.
This patch adds the option to frame on selected channels OR frame on whatever channel is under the cursor.
If a preview range is set it will only focus on keys in that range.
Supports FCurve and keyframe data
Frame to selected is called with
Frame to channel under cursor is done with
ALT + Middle Mouse Button
old patch on phabricator
https://archive.blender.org/developer/D17005
frame channels video demo
Nice addition! Just some small nags.
@ -375,3 +375,3 @@
* Calculate the extents of F-Curve's data.
*/
bool BKE_fcurve_calc_bounds(const struct FCurve *fcu,
bool BKE_fcurve_calc_bounds(struct FCurve *fcu,
AFAICS the
fcu
parameter can remainconst
.@ -382,2 +382,3 @@
bool do_sel_only,
bool include_handles);
bool include_handles,
const float range[2]);
Document what the
range
parameter is for, and what the behaviour is when it'sNULL
.@ -625,3 +626,1 @@
/* Get endpoint keyframes. */
foundvert = get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
if (range == NULL) {
I think it's nicer to have a
const bool use_range = range != NULL;
at the start of the function, and then just useuse_range
in the rest of the code. That limits the 'knowledge' of "NULL means do not use" to a single line of code.This
if
can then be flipped, and becomeif (use_range) ... else ...
to avoid a negation.@ -628,0 +628,4 @@
foundvert = get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
}
else {
/* If a range is passed in find the first and last keyframe within that range. */
IMO this should be a separate function, as finding the first/last keyframes is something different than calculating the bounds (single responsibility principle).
@ -3640,0 +3642,4 @@
/** \name View Channel Operator
* \{ */
static void get_normalized_fcurve_bounds(FCurve *fcu,
I think these three pointers can all be
const
, as this only gets the bounds and shouldn't set anything.only
ale
can be const in this casebecause
ANIM_get_normalization_flags
andANIM_unit_mapping_get_factor
would throw warnings otherwise since they aren't set to const@ -3640,0 +3645,4 @@
static void get_normalized_fcurve_bounds(FCurve *fcu,
bAnimContext *ac,
bAnimListElem *ale,
bool include_handles,
const
@ -3640,0 +3660,4 @@
range);
float unitFac, offset;
short mapping_flag = ANIM_get_normalization_flags(ac);
const
@ -3640,0 +3661,4 @@
float unitFac, offset;
short mapping_flag = ANIM_get_normalization_flags(ac);
unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
Declaring
unitFac
here makes it possible toconst float
it.@ -3640,0 +3665,4 @@
r_bounds->ymin += offset;
r_bounds->ymax += offset;
r_bounds->ymin *= unitFac;
r_bounds->ymax *= unitFac;
I think it's nicer to see the entire formula in one go:
@ -3640,0 +3726,4 @@
}
}
/* Take regions into account, that could block the view.
How can the view be blocked, by taking regions into account?
I think for the right meaning the comma has to be removed.
Having said that, the comment is a bit vague, "take into account" doesn't mean that much until you know where & how the function is used.
It's better to be more descriptive of what it does, rather than about where it is supposed to be used.
let me know if the comment makes more sense now
@ -3640,0 +3733,4 @@
BLI_rctf_scale(bounds, 1.1f);
float pad_top = UI_TIME_SCRUB_MARGIN_Y;
float pad_bottom = BLI_listbase_is_empty(ED_context_get_markers(C)) ? V2D_SCROLL_HANDLE_HEIGHT :
const
@ -3640,0 +3738,4 @@
BLI_rctf_pad_y(bounds, ac->region->winy, pad_bottom, pad_top);
}
/* Iterates through regions because the operator might not have been called from the correct
Within the context of this patch "the operator" can be understood, but once this is in Blender's sources, it's a bit vague. The doc also explains what this code does in terms of what other code didn't do, and that creates a tight coupling that's not wanted.
I hope the comment is better now
@ -3640,0 +3764,4 @@
size_t anim_data_length = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
if (anim_data_length == 0) {
return OPERATOR_CANCELLED;
Use
WM_report
to show a warning that explains why the operator couldn't run.LGTM!
There's one small issue I just noticed, I'll leave it up to you if you want to address that in this patch or in another one.
When alt-middleclicking on a single channel that has no Y-range (so all keys have the same value), the view is a bit jumpy. It seems to zoom out and quickly zoom back in again.
@ -3641,0 +3663,4 @@
const float min_height = 0.01f;
const float height = BLI_rctf_size_y(r_bounds);
if (height < min_height) {
@dr.sybren
fixed the issue with the flat curves with that
The focus is correct in Graph Editor.
But it is not in Timeline/Dopesheet.
When I do a select Frame Select Channels and channel selected is at bottom of channels list, X framing is correctly relative to keyframes.
But Y framing is reset to Top of Dopesheet.
So, user has to scroll down after each alt middle click.