Animation: Graph Editor Handle Selection #108142
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#108142
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "cgtinker/blender:select_handles_patch"
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?
In a recent module meeting we realised there are no tools to select handles. This patch includes an operator, which (de)selects handles based on the given selection.
As the user may uses the operator to work on b.e. the left handles and the right handles afterwards, the operator acts on any bezt selection. When working with handles, we usually don’t want keyframes to be selected, therefore those get deselected by default. The design of the operator does not include the selection of keyframes based on active handles which may be useful in some cases - this should probably be added as separate operator as user would not expect that handle selection includes keyframe selection.
Another concept could be to remap selections. This could be done with radio buttons so the user can select a certain selection status which he wants to remap to another selection status (b.e. if the left handle is selected, deselect it and select the right handle + key [ Ls | K | R ] -> [ L | Ks | Rs ]) . However this seems like a more special case and is probably confusing.
thanks for the patch. In terms of functionality no complaints
I left a few comments on things to change from a code point of view
@ -195,1 +195,4 @@
layout.separator()
# layout.operator("graph.select_handles", text="All").action = 'SELECT'
layout.operator("graph.select_handles")
I think we should add separate entries for "select left handles" and "select right handles"
this makes it a lot more discoverable for artists and they can easily assign a hotkey by right clicking the menu entry
@ -74,6 +74,13 @@ enum eGraphKeys_LeftRightSelect_Mode {
GRAPHKEYS_LRSEL_RIGHT,
};
/* Defines for handle selection */
comments end with a "."
@ -216,2 +216,3 @@
if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) ||
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)))
{
when running
make format
this gets undonecheck that you have your clang-format pointed to the binary that comes with blender. that should be in "blender-git/lib//llvm/bin"
thanks for the hint, pointed llvm to the wrong binary
@ -2038,0 +2040,4 @@
/* defines for left-right select tool */
static const EnumPropertyItem prop_graphkeys_leftright_handle_select_types[] = {
{GRAPHKEYS_HANDLESEL_LR, "CHECK", 0, "Select Both Handles", ""},
why is the option to select both handles called "CHECK"
"BOTH" would make more sense to me but maybe I am missing something
Also check the code style for the comment above. Comments should start with a capital letter and end with a "."
I think I copied an existing enum and modified it back then, there is no checking. In the 'C' scripts are lots of comments that don't follow this convention which is misleading, probably it would be good to create a small formatter to fix them?
yeah there is quite a bit of old comments floating around that need cleaning up
@ -2038,0 +2046,4 @@
{0, NULL, 0, NULL, NULL},
};
short bezt_sel_left_handles(KeyframeEditData *ked, BezTriple *bezt)
make that
KeyframeEditData *UNUSED(ked)
for all those functionsThis removes the warning you get when compiling
@ -2038,0 +2081,4 @@
return 0;
}
static void graphkeys_de_select_handles(bAnimContext *ac, short mode, const bool desel_kf)
leave a comment on what kind of enum
short mode
isalso can be const
@ -2038,0 +2089,4 @@
KeyframeEditData ked;
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
can be
const int filter = ...
@ -2038,0 +2093,4 @@
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
this can be
LISTBASE_FOREACH(bAnimListElem *, ale, &anim_data)
you then also don't need to have
bAnimListElem *ale;
before@ -2038,0 +2102,4 @@
}
switch (mode) {
case GRAPHKEYS_HANDLESEL_LR: {
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_sel_both_handles, NULL);
I did a test and you can just pass
NULL
instead of&ked
since you are not doing anything withked
afterwards@ -2038,0 +2103,4 @@
switch (mode) {
case GRAPHKEYS_HANDLESEL_LR: {
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_sel_both_handles, NULL);
} break;
so far i've only seen
break
within the curly bracket blockbut I am not sure if this is convention or not. Something to check with sybren
Afaik it does not change anything, I just put them inside
@ -2038,0 +2129,4 @@
return OPERATOR_CANCELLED;
}
short leftright = RNA_enum_get(op->ptr, "mode");
i think calling the variable also
mode
would be clearerand
desel_kf
should bedeselect_keyframe
. in general we try to avoid abbreviations these days to make the code more readable.@ -2038,0 +2156,4 @@
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
ot->prop = RNA_def_enum(ot->srna,
you don't need to assign the
RNA_def
functions to anythingthat way you can also remove
PropertyRNA *prop;
for which I get an unused warning anywayapart from the two minor things that I am unsure about it looks good to me
i'll let sybren be the final judge
@ -2038,0 +2082,4 @@
static void graphkeys_de_select_handles(
bAnimContext *ac,
const short mode, // prop_graphkeys_leftright_handle_select_types
I meant add a comment that this is an enum and which it is.
e.g.
enum eGraphKey_HandleSelect_Mode
also I am not sure we are supposed to use comments with //
sybren can elaborate on that
Nope, see https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments
Also, why use
short
here at all? IMO it should just beenum eGraphKey_HandleSelect_Mode mode
.Yeah it should be
eGraphKey_HandleSelect_Mode
, will change that. Within the file all functions use ashort
instead of the enum prop, thought that had a reason and followed the "convention".@ -2038,0 +2155,4 @@
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
ot->prop = RNA_def_enum(ot->srna,
you don't need to assign the RNA_def to anything
so it can just be
RNA_def...
instead ofot->prop = RNA_def
now I didn't know the operator type had a prop. And I am not sure what it is used for.
Maybe also something for sybren to clear up
It's documented as:
So this means that it can be used for certain interactions as a special property.
@ChrisLend is right in that here the assignment is unnecessary. And if there is a property that should be marked as that special one property, it should only be assigned once, and not assigned and then immediately be overwritten again.
great, thanks for the review!
This is some nice functionality. I feel that there's one thing missing though: for all selected handles, select they keys, optionally deselecting the handles themselves. The addition of that 'mode' would make it possible to quickly move the selection from left handle, to the key itself, to the right handle, etc.
As for the attached video, please stick to formats that are widely supported by webbrowsers (h.264/MP4, or VC9/WebM).
@ -75,2 +75,4 @@
};
/* Defines for handle selection. */
enum eGraphKey_HandleSelect_Mode {
I think 'side' would be a better noun than 'mode' here. IMO the 'mode' should also include whether the keys themselves are selected/deselected or not, which is not part of this enum.
@ -2038,0 +2039,4 @@
/* Defines for handle select tool. */
static const EnumPropertyItem prop_graphkeys_leftright_handle_select_types[] = {
{GRAPHKEYS_HANDLESEL_LR, "BOTH", 0, "Select Both Handles", ""},
Just for consistency, rename
GRAPHKEYS_HANDLESEL_LR
toGRAPHKEYS_HANDLESEL_BOTH
.@ -2038,0 +2080,4 @@
return 0;
}
static void graphkeys_de_select_handles(
Remove the
_de_
, there are many more functions that are called 'select' but also allow deselecting.@ -2038,0 +2083,4 @@
static void graphkeys_de_select_handles(
bAnimContext *ac,
const short mode, // prop_graphkeys_leftright_handle_select_types
const bool deselect_keyframe)
It's not a good idea to have negated booleans (i.e. 'enable to disable' style ones). Just use
const bool select
.Having said that, looking at the code this does something else than I expected, so definitely add a comment above the function that explains what the parameters do.
@ -2038,0 +2092,4 @@
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
Add
BLI_assert(ale->type, ANIMTYPE_FCURVE)
before the cast, just to have a little extra check that the cast is actually valid.@ -2038,0 +2131,4 @@
}
short leftright = RNA_enum_get(op->ptr, "mode");
bool deselect_keyframe = RNA_boolean_get(op->ptr, "deselect_keyframe");
These variables can be
const
.@ -2038,0 +2160,4 @@
prop_graphkeys_leftright_handle_select_types,
GRAPHKEYS_HANDLESEL_LR,
"Mode",
"(De)Select handles based on selection");
"Select handles based on selection" is too vague.
@ -2038,0 +2161,4 @@
GRAPHKEYS_HANDLESEL_LR,
"Mode",
"(De)Select handles based on selection");
ot->prop = RNA_def_boolean(ot->srna, "deselect_keyframe", 1, "Deselect Keyframes", "");
This should have a tooltip that explains what it does.
Thanks!
As mentioned in the PR I'm not sure if the selection of keyframes should be within the selection of handles. Implementing a
select keyframes
option within theselect handles
operator seems confusing, even more while having the option to preserve the keyframe selection.If the keyframe selection is not relevant it would be the easiest to make the bool actually selecting / deselecting the keyframes.ed: Either it should be separated, or an option within the enum.Decided to give selecting keyframes a try. While it feels good to have it within the handle selection and it seems a little out of place. Separating it would also seem wrong.
Besides decided to only draw the "deselect keyframes" bool when selecting handles...
@blender-bot package
Package build started. Download here when ready.
Since @cgtinker is no longer available, I'm continuing this PR in #111143, with code updated to latest main.
Pull request closed