Fix #95855: prioritize selecting keys on active fcurve #107223

Merged
Nathan Vegdahl merged 6 commits from nathanvegdahl/blender:overlapping_key_selection into main 2023-05-04 10:10:41 +02:00
Member

This addresses #95855 by prioritizing the selection of keys in the following order:

  1. Keys on the active curve.
  2. Keys on any selected curve.
  3. Other keys.
This addresses #95855 by prioritizing the selection of keys in the following order: 1. Keys on the active curve. 2. Keys on any selected curve. 3. Other keys.
Nathan Vegdahl added 1 commit 2023-04-21 18:56:15 +02:00
Nathan Vegdahl added this to the Animation & Rigging project 2023-04-21 18:56:33 +02:00
Nathan Vegdahl added the
Module
Animation & Rigging
label 2023-04-21 18:57:56 +02:00
Nathan Vegdahl requested review from Sybren A. Stüvel 2023-04-21 19:05:38 +02:00
Nathan Vegdahl reviewed 2023-04-23 11:03:37 +02:00
@ -291,0 +292,4 @@
/* Try to find the next vert that's on the active fcurve, falling back to the next
* vert on any selected fcurve if that's not found. */
tNearestVertInfo *nvi_to_select = NULL;
for (tNearestVertInfo *nvi = matches->first; nvi != nvi_first_selected; nvi = nvi->next) {
Author
Member

Note to self when I'm back in the office:

Although the nvi != nvi_first_selected check works since nvi_first_selected will be null if no selected vert was found, this isn't immediately obvious skimming the code, and feels delicate and easily breakable by future changes. So perhaps being explicit and doing nvi && nvi != nvi_first_selected would be better here, even though it's functionally unnecessary.

Note to self when I'm back in the office: Although the `nvi != nvi_first_selected` check works since `nvi_first_selected` will be null if no selected vert was found, this isn't immediately obvious skimming the code, and feels delicate and easily breakable by future changes. So perhaps being explicit and doing `nvi && nvi != nvi_first_selected` would be better here, even though it's functionally unnecessary.
Nathan Vegdahl added 1 commit 2023-04-24 13:06:03 +02:00
3a417b467c Cleanup: add explicit null pointer check
Not functionally necessary in this case, but it makes the intent
more obvious and makes the code more resilient to future changes.
Nathan Vegdahl force-pushed overlapping_key_selection from 71b280bf1d to 091d3508f5 2023-04-25 11:55:15 +02:00 Compare
Sybren A. Stüvel reviewed 2023-04-25 16:21:32 +02:00
Sybren A. Stüvel left a comment
Member

I've left a few ideas to test out.

I've left a few ideas to test out.
@ -288,1 +278,3 @@
/* if vert is selected, we've got what we want... */
/* Find the first selected vert in `matches` if one exists. */
tNearestVertInfo *nvi_first_selected = NULL;
for (tNearestVertInfo *nvi = matches->first; nvi; nvi = nvi->next) {

Use the LISTBASE_FOREACH() for such loops, they improve readability.

Use the `LISTBASE_FOREACH()` for such loops, they improve readability.
Author
Member

Yes, much better! Thanks!

Yes, much better! Thanks!
@ -291,0 +293,4 @@
/* Try to find the next vert that's on the active fcurve, falling back to the next
* vert on any selected fcurve if that's not found. */
tNearestVertInfo *nvi_to_select = NULL;
for (tNearestVertInfo *nvi = matches->first; nvi && nvi != nvi_first_selected; nvi = nvi->next) {

Maybe here do a LISTBASE_FOREACH, and put the nvi != nvi_first_selected into the body, something like this (haven't actually tested this):

LISTBASE_FOREACH(tNearestVertInfo *, nvi, matches) {
  if (nvi == nvi_first_selected) break;
  ...
}
Maybe here do a `LISTBASE_FOREACH`, and put the `nvi != nvi_first_selected` into the body, something like this (haven't actually tested this): ```c LISTBASE_FOREACH(tNearestVertInfo *, nvi, matches) { if (nvi == nvi_first_selected) break; ... } ```
Author
Member

Yeah, this and your other comment below helped me flatten things out in a nice way that makes the code much clearer and a little less delicate, I think. Thanks!

Yeah, this and your other comment below helped me flatten things out in a nice way that makes the code much clearer and a little less delicate, I think. Thanks!
@ -291,0 +297,4 @@
if (nvi->fcu->flag & FCURVE_ACTIVE) {
nvi_to_select = nvi;
break;
} else if (nvi->fcu->flag & FCURVE_SELECTED && !nvi_to_select) {

No else after a break. Also this seems like your editor isn't automatically using clang-format yet.

No `else` after a `break`. Also this seems like your editor isn't automatically using clang-format yet.
Author
Member

Also this seems like your editor isn't automatically using clang-format yet.

Ah! Thanks for the reminder. I set it up in vscode, but forgot to do so in Helix as well.

> Also this seems like your editor isn't automatically using clang-format yet. Ah! Thanks for the reminder. I set it up in vscode, but forgot to do so in Helix as well.
Nathan Vegdahl added 1 commit 2023-04-26 10:19:36 +02:00
Nathan Vegdahl added 1 commit 2023-04-26 10:44:51 +02:00
Nathan Vegdahl added 1 commit 2023-04-26 11:13:05 +02:00
Sybren A. Stüvel requested changes 2023-05-02 11:08:34 +02:00
Sybren A. Stüvel left a comment
Member

LGTM!

LGTM!
Sybren A. Stüvel approved these changes 2023-05-02 11:08:43 +02:00
Nathan Vegdahl merged commit 10a93aebf1 into main 2023-05-04 10:10:41 +02:00
Nathan Vegdahl deleted branch overlapping_key_selection 2023-05-04 10:10:42 +02:00
Sybren A. Stüvel removed this from the Animation & Rigging project 2023-05-09 17:22:55 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:42 +02:00
Sign in to join this conversation.
No reviewers
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
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107223
No description provided.