Refactor: swap handle logic in Graph Editor transform code #121076
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#121076
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChrisLend/blender:fix_swap_handles"
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?
This PR changes the
swap_handles
variable of theBeztMap
fromshort
tobool
.The only reason it was a
short
was so that 0 could be interpreted as "not checked" within the sorting loop.Instead, I moved the checking for swapping to a separate loop. That means the
BeztMap
array needs to be traversed one more time, but given sorting might already do that multiple times that won't be a performance issue (plus we don't have theif
within the sorting loop potentially messing up branch prediction).In addition to that this PR also removes
prev_ipo
andcurrent_ipo
from theBeztMap
struct. Those were never used.This is also partly a fix to restore 3.6 behavior. With the move to C++,
swap_handles
was never initalized, so the logicif (bezm->swap_handles == 0)
would always be false.That resulted in the following behavior when rotating a bunch of keys 180deg around their common center.
As can be seen on those pictures, the swap handles logic isn't perfect. It sometimes misses keys.
Since that is 3.6 behavior though, I think it is out of the scope of this refactor.
I suspect the issue is that handles are swapped based on their current position, which is usually clamped to the key.
So both handles have to cross the key threshold at the same time, else the clamping code will run, meaning they won't be able to cross the threshold later (due to use of
<
and>
).Much better!
Just one note.
@ -769,0 +761,4 @@
for (BeztMap &bezm : bezms) {
/* Handles are only swapped if they are both on the wrong side of the key. Otherwise the one
* handle out of place is just clamped at the key position later. */
if ((bezm.bezt->vec[0][0] > bezm.bezt->vec[1][0]) &&
This can just be:
(but then formatted correctly ;-) )
For me this is easier to reason about, as I don't have to know the previous value for
swap_handles
to understand what the result of the code will be.