Refactor: Anim selectmode flags #118554
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118554
Loading…
Reference in New Issue
No description provided.
Delete Branch "PratikPB2123/blender:anim-selectmode-refactor"
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?
Use
eEditKeyframes_Select
enum variable type forselectmode
.This was discussed in !118429
Good job, I'm glad to see the
/* eEditKeyframes_Select or -1 */
go!Right now, having worked through this code the way you have, I'm guessing you're the person with the most knowledge on the planet about what these flags actually do. I'm hoping we can capture as much of that knowledge as possible and get it into comments & code clarity. That's the context for my remaining comments :)
Please edit the PR description so that it's a complete commit message, including whether this introduces (or at least is expected to introduce) functional changes or not. I can imagine that changing
(selectmode == SELECT_INVERT)
to(selectmode & SELECT_INVERT)
can produce some subtle unintended changes. Having it written down what the intent is of this PR/commit will help debugging things when these do show up (but oh boy do I hope they don't).@ -49,6 +49,7 @@ enum eEditKeyframes_Validate {
/* select modes */
enum eEditKeyframes_Select {
SELECT_NONE = 0,
I think a better name would be
SELECT_NOOP
, to drive the fact home that this is actually a no-op (otherwise it could be a "deselect everything" flag too).@ -58,7 +59,9 @@ enum eEditKeyframes_Select {
/* flip ok status of keyframes based on key status */
SELECT_INVERT = (1 << 3),
SELECT_EXTEND_RANGE = (1 << 4),
SELECT_CHILDREN_ONLY = (1 << 5),
This should get some documentation as to what it means.
A possible confusion: the name suggests it only selects children (so I'd expect non-children to remain untouched), yet it's used in the code with a comment
/* select all in group (and deselect everything else) */
, so that means it causes only children to be selected, and the rest to be deselected. It's a subtle but important difference.Also when reading the enum name I don't know what "children" means, so that might be nice to describe as well. I understand it reflects the RNA property, so the name itself is fine. Something like this would help:
/* Special case for ActionGroups, which selects the channels underneath it, and deselects the rest. */
If that is indeed what it does ;-)
Thinking about this a bit more, especially with @ChrisLend 's comment about invalid combinations, I think maybe we should drop the whole enum, and turn the "select mode" into a class by itself. It's purely runtime data anwyay, so there's nothing in the blend file we need to stay compatible with.
One of the red flags is that when you search for
select mode is either replace (deselect all, then add) or add/extend
you can find it repeated 8× across 5 files in 4 different directories. And then there is this code:So the RNA concept "extend" maps to the C++ concept "invert".
Some things that come to mind when making such a
AnimSelectionMode
class:selectmode
while doing the selection operation.The last point is because I found this code:
This is IMO quite sane: if the selection needs to be replaced, deselect what needs deselecting, and then just continue as if an additive selection mode was chosen. This could also be modeled in the
AnimSelectMode
class, by having functionsshould_deselect()
andshould_select()
. A replace could just returntrue
for both, and other modes could result in other return values. That way the code would never have to "fake" that the function received a different selection mode than it actually did.@PratikPB2123 with all this feedback, and this PR getting a bigger (and also slightly less well-defined) scope, do you still feel comfortable working on this? Otherwise @ChrisLend or me could take over. I do feel that this change would be a welcome one, as it will make implementing selection operations in the new layered animation editor more straight-forward as well.
@dr.sybren , thanks for the review 🙂
I'll continue this refactor.
I didn't quite understand this.
🙏
I mean something that replaces this:
with something like:
where the
from_rna
function then can do the whole mapping from the boolean properties in RNA to someSelectMode
instance.Checkout
From your project repository, check out a new branch and test the changes.