Fix #110108: NLA absolute snapping #111984

Merged
Christoph Lendenfeld merged 9 commits from ChrisLend/blender:fix_nla_marker_snap into main 2023-09-15 09:52:48 +02:00

Before this patch the following snapping options were broken

  • snap to markers
  • snap to seconds with "Absolute Time Snap" turned on
  • technically also snap to Frames with "Absolute Time Snap" turned on (but made no real difference)

The issue was that each end of the strip would snap individually. Potentially collapsing the strip.
This would happen e.g. when snapping to markers but with only 1 marker present.

This PR fixes the issue by finding out the closest snap offset and shifting the strip as a whole by that amount.
That means either the start or the end of the strip will snap to the target.
By doing it that way the length of the strip is never changed by snapping.

This means when snapping to Seconds with "Absolute Time Snap" turned on, the start of the strip might not be on a full second when the end is.

Here is a video demo as an example.

Before this patch the following snapping options were broken * snap to markers * snap to seconds with "Absolute Time Snap" turned on * technically also snap to Frames with "Absolute Time Snap" turned on (but made no real difference) The issue was that each end of the strip would snap individually. Potentially collapsing the strip. This would happen e.g. when snapping to markers but with only 1 marker present. This PR fixes the issue by finding out the closest snap offset and shifting the strip as a whole by that amount. That means either the start or the end of the strip will snap to the target. By doing it that way the length of the strip is never changed by snapping. This means when snapping to Seconds with "Absolute Time Snap" turned on, the start of the strip might not be on a full second when the end is. Here is a video demo as an example. <video src="/attachments/2c48fbe8-59ae-43c5-b2b0-cc3e8a35a034" controls></video>
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-09-05 16:43:32 +02:00
Christoph Lendenfeld added 6 commits 2023-09-05 16:43:45 +02:00
Christoph Lendenfeld requested review from Nate Rupsis 2023-09-05 16:43:58 +02:00
Christoph Lendenfeld requested review from Brad Clark 2023-09-05 16:45:14 +02:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111984) when ready.
Christoph Lendenfeld added this to the Animation & Rigging project 2023-09-05 17:21:20 +02:00
Nate Rupsis reviewed 2023-09-06 16:43:20 +02:00
@ -668,0 +671,4 @@
transform_snap_anim_flush_data(t, &td, snap_mode, &snap_value);
/* In order to move the strip in a block and not each end individually, find the minimal snap
* offset and shift the whole strip by that amount. */
Member

Minor: first line in comment is a little long.

/* In order to move the strip in a block and not each end individually,
 * find the minimal snap offset and shift the whole strip by that amount. */

Might read better.

Minor: first line in comment is a little long. ``` /* In order to move the strip in a block and not each end individually, * find the minimal snap offset and shift the whole strip by that amount. */ ``` Might read better.
Nate Rupsis reviewed 2023-09-06 16:44:04 +02:00
@ -668,0 +681,4 @@
for (int i = 0; i < tc->data_len; i++) {
TransData td = tc->data[i];
*td.loc = td.iloc[0] + offset;
Member

is there a reason we update *td.loc in it's own loop? Couldn't that be done at the bottom of the other loop?

is there a reason we update `*td.loc` in it's own loop? Couldn't that be done at the bottom of the other loop?
Author
Member

I need to first find the smallest snap delta of all points, then I can apply that offset to all points.
That gives me the behavior of snapping the whole block to the closest snapping point of either side.

I renamed the variables and added a comment to make that clearer

I need to first find the smallest snap delta of all points, then I can apply that offset to all points. That gives me the behavior of snapping the whole block to the closest snapping point of either side. I renamed the variables and added a comment to make that clearer

I didn't see it in detail, but if it doesn't change the behavior too much, could you use the generic snap solution?
See transform_snap_mixed_apply.
You would only need to edit the callbacks:
t->tsnap.snap_target_fn
t->tsnap.snap_source_fn
t->tsnap.snap_apply_fn

I didn't see it in detail, but if it doesn't change the behavior too much, could you use the generic snap solution? See `transform_snap_mixed_apply`. You would only need to edit the callbacks: `t->tsnap.snap_target_fn` `t->tsnap.snap_source_fn` `t->tsnap.snap_apply_fn`
Brad Clark approved these changes 2023-09-06 17:14:36 +02:00
Brad Clark left a comment
Member

The fix to snap the entire clip is what I was expecting it to do and so while there are other issues to address in other patches (I was reminded) I am happy to see this current result.

The fix to snap the entire clip is what I was expecting it to do and so while there are other issues to address in other patches (I was reminded) I am happy to see this current result.
Author
Member

I didn't see it in detail, but if it doesn't change the behavior too much, could you use the generic snap solution?
See transform_snap_mixed_apply.
You would only need to edit the callbacks:
t->tsnap.snap_target_fn
t->tsnap.snap_source_fn
t->tsnap.snap_apply_fn

Thanks for the hint that those exist. I am not too familiar with the snapping system yet but will definitely have a look at those
I would keep that for a different patch though, that way this PR can be backported to the LTS tasks more easily.
But yeah upgrading to generic snapping is definitely the way to go.

> I didn't see it in detail, but if it doesn't change the behavior too much, could you use the generic snap solution? > See `transform_snap_mixed_apply`. > You would only need to edit the callbacks: > `t->tsnap.snap_target_fn` > `t->tsnap.snap_source_fn` > `t->tsnap.snap_apply_fn` Thanks for the hint that those exist. I am not too familiar with the snapping system yet but will definitely have a look at those I would keep that for a different patch though, that way this PR can be backported to the LTS tasks more easily. But yeah upgrading to generic snapping is definitely the way to go.
Christoph Lendenfeld added 3 commits 2023-09-08 15:26:00 +02:00
Nate Rupsis approved these changes 2023-09-14 22:05:38 +02:00
Christoph Lendenfeld merged commit bd305c8d18 into main 2023-09-15 09:52:48 +02:00
Christoph Lendenfeld deleted branch fix_nla_marker_snap 2023-09-15 09:52:49 +02:00
Christoph Lendenfeld removed this from the Animation & Rigging project 2023-11-23 10:54:03 +01: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
5 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#111984
No description provided.