Fix #122490: Snapping with free handles doesn't move the handles #123173

Merged
Christoph Lendenfeld merged 3 commits from ChrisLend/blender:fix_snap_handles into blender-v4.2-release 2024-06-18 16:00:48 +02:00

When snapping keyframes in the Graph Editor, handles
that were set to free didn't move.

The issue was that the snapping code didn't set the handle position.
Instead it relied on the handle recalculation (calchandleNurb_intern) to do the job.
That code doesn't affect free handles though.

The fix is to also offset the handles in the snapping code. The handle recalculation
will still run for all the other handle types so that behavior isn't expected to change.

This does NOT change the behavior of bezier snapping in the 3D viewport.

When snapping keyframes in the Graph Editor, handles that were set to free didn't move. The issue was that the snapping code didn't set the handle position. Instead it relied on the handle recalculation (`calchandleNurb_intern`) to do the job. That code doesn't affect free handles though. The fix is to also offset the handles in the snapping code. The handle recalculation will still run for all the other handle types so that behavior isn't expected to change. This does NOT change the behavior of bezier snapping in the 3D viewport.
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2024-06-13 11:37:27 +02:00
Christoph Lendenfeld added 1 commit 2024-06-13 11:37:32 +02:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2024-06-13 14:12:28 +02:00
Sybren A. Stüvel requested changes 2024-06-18 11:39:49 +02:00
Dismissed
Sybren A. Stüvel left a comment
Member

The code now follows a very similar pattern to rna_FKeyframe_ctrlpoint_ui_set (which is good). There is a subtle difference though.

This PR computes the delta, and then adds that to the key & the handles. This means that the key might not get the exact value that it would have been set to otherwise, due to float rounding. This will become increasingly obvious when the key value is large, and the delta is small.

rna_FKeyframe_ctrlpoint_ui_set side-steps this, by always setting the key itself to the desired value, and applying the delta to the handles only.

It'll probably be a better approach to move the functionality of rna_FKeyframe_ctrlpoint_ui_set() into a "common area", and use it from all the places where it's needed.

The code now follows a very similar pattern to `rna_FKeyframe_ctrlpoint_ui_set` (which is good). There is a subtle difference though. This PR computes the delta, and then adds that to the key & the handles. This means that the key might not get the exact value that it would have been set to otherwise, due to float rounding. This will become increasingly obvious when the key value is large, and the delta is small. `rna_FKeyframe_ctrlpoint_ui_set` side-steps this, by always setting the key itself to the desired value, and applying the delta to the handles only. It'll probably be a better approach to move the functionality of `rna_FKeyframe_ctrlpoint_ui_set()` into a "common area", and use it from all the places where it's needed.
Christoph Lendenfeld added 2 commits 2024-06-18 14:37:32 +02:00
Author
Member

@dr.sybren I realized we already had that function BKE_fcurve_keyframe_move_time_with_handles
I didn't touch rna_FKeyframe_ctrlpoint_ui_set yet because that is outside of the scope of this fix, but I agree that could be refactored as well

@dr.sybren I realized we already had that function `BKE_fcurve_keyframe_move_time_with_handles` I didn't touch `rna_FKeyframe_ctrlpoint_ui_set` yet because that is outside of the scope of this fix, but I agree that could be refactored as well
Christoph Lendenfeld requested review from Sybren A. Stüvel 2024-06-18 14:40:12 +02:00
Sybren A. Stüvel approved these changes 2024-06-18 15:58:03 +02:00
Sybren A. Stüvel left a comment
Member

👍

:+1:
Christoph Lendenfeld merged commit 1070ae46fa into blender-v4.2-release 2024-06-18 16:00:48 +02:00
Christoph Lendenfeld deleted branch fix_snap_handles 2024-06-18 16:00:55 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
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#123173
No description provided.