Animation: NLA Vertical Reorder #107990

Merged
Nate Rupsis merged 35 commits from nrupsis/blender:NLA-vertical-shuffle-core into main 2023-06-20 17:10:15 +02:00
Member

Overview

Previously, you could only drag NLA strip vertically through complete clear (no NLA strips) unlocked tracks.

Now, you can vertically drag a NLA though other clips, and locked tracks.

Design Details

  • If a target track is unlocked, then try and place strip in the specified location.
    • If there a strip exists on the destination track, then the horizontal reordering logic places the strip in a valid location withing the track.
  • If a strip is dragged to a locked strip, then the horizontal transformation is applied, but the track is moved back to it's source location.
## Overview Previously, you could only drag NLA strip vertically through complete clear (no NLA strips) unlocked tracks. Now, you can vertically drag a NLA though other clips, and locked tracks. <video controls src="https://projects.blender.org/attachments/0319220e-e8a2-4c6a-babd-fecf416ecb91" > </video> ## Design Details * If a target track is unlocked, then try and place strip in the specified location. * If there a strip exists on the destination track, then the [horizontal reordering](https://projects.blender.org/blender/blender/pulls/105532) logic places the strip in a valid location withing the track. * If a strip is dragged to a locked strip, then the horizontal transformation is applied, but the track is moved back to it's source location.
Nate Rupsis added 23 commits 2023-05-16 22:48:14 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
135c18e906
need to add unsafe, so it shuffles back
buildbot/vexp-code-patch-coordinator Build done. Details
4b34ec77af
fix merge conflict
Nate Rupsis added 1 commit 2023-05-16 22:58:10 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
302d5bd1f2
cleanup
Nate Rupsis requested review from Sybren A. Stüvel 2023-05-16 23:01:29 +02:00
Nate Rupsis requested review from Brad Clark 2023-05-16 23:01:29 +02:00
Nate Rupsis changed title from WIP: NLA-vertical-shuffle-core to Animation: NLA Vertical Reorder 2023-05-16 23:01:36 +02:00
Nate Rupsis added the
Module
Animation & Rigging
label 2023-05-16 23:01:50 +02:00
Nate Rupsis added this to the Animation & Rigging project 2023-05-16 23:01:57 +02:00
Nate Rupsis added 1 commit 2023-05-16 23:36:48 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
2d35560c9f
fixing compiler warning
Nate Rupsis changed title from Animation: NLA Vertical Reorder to WIP: Animation: NLA Vertical Reorder 2023-05-16 23:40:12 +02:00
Brad Clark approved these changes 2023-05-16 23:53:58 +02:00
Brad Clark left a comment
Member

Approved from animation art side of things. Future plans to add options are nice but not core to having this drag and drop functionality this provides, has been asked for for years and had code in the works for at least two years.

Approved from animation art side of things. Future plans to add options are nice but not core to having this drag and drop functionality this provides, has been asked for for years and had code in the works for at least two years.
Nate Rupsis added 1 commit 2023-05-17 00:16:29 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
49c313ebee
remove lower auto expand
Nate Rupsis changed title from WIP: Animation: NLA Vertical Reorder to Animation: NLA Vertical Reorder 2023-05-17 00:18:31 +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/PR107990) when ready.
Sybren A. Stüvel requested changes 2023-05-17 11:33:55 +02:00
@ -56,1 +56,4 @@
int trackIndex;
/** NOTE: This index is relative to the initial first track at the start of transforming and
* thus can be negative when the tracks list grows downward. */

nrupsis marked this conversation as resolved
@ -141,0 +162,4 @@
ListBase *tracks = &BKE_animdata_from_id(
((TransDataNla *)((LinkData *)trans_datas->first)->data)->id)
->nla_tracks;

This you may want to split out a little bit. If you get a NULL dereference it's going to be very hard to figure out which -> caused it. Something like this should work (but do test before committing ;-) )

  LinkData *first_link = trans_datas->first;
  TransDataNla *first_transdata = first_link->data;
  AnimData *adt = BKE_animdata_from_id(first_transdata->id);
  ListBase *tracks = &adt->nla_tracks;
This you may want to split out a little bit. If you get a NULL dereference it's going to be very hard to figure out which `->` caused it. Something like this should work (but do test before committing ;-) ) ```c LinkData *first_link = trans_datas->first; TransDataNla *first_transdata = first_link->data; AnimData *adt = BKE_animdata_from_id(first_transdata->id); ListBase *tracks = &adt->nla_tracks; ```
nrupsis marked this conversation as resolved
@ -141,0 +185,4 @@
continue;
}
offset = shuffle_down ? 1 : -1;

Instead of having a boolean shuffle_down, use an int shuffle_direction which can be either -1 or 1. That way you don't have to do this, and the direction is more clear from the call site of the function.

One thing that's weird, though, is that the shuffle_down == true case selects a positive offset here, but in the code down below you have fabs(offset_down) < offset_up, indicating that the "up" direction is actually positive and the "down" direction is negative.

During testing I haven't been able to get any offset that was non-zero, so I found it tricky to either prove or disprove my own comment.

Instead of having a boolean `shuffle_down`, use an `int shuffle_direction` which can be either `-1` or `1`. That way you don't have to do this, and the direction is more clear from the call site of the function. One thing that's weird, though, is that the `shuffle_down == true` case selects a **positive** offset here, but in the code down below you have `fabs(offset_down) < offset_up`, indicating that the "up" direction is actually positive and the "down" direction is negative. During testing I haven't been able to get any offset that was non-zero, so I found it tricky to either prove or disprove my own comment.

During testing I haven't been able to get any offset that was non-zero, so I found it tricky to either prove or disprove my own comment.

Got it, it required me to lock some tracks. So yes, the offset_down is positive, and offset_up is negative, and thus the fabs() is on the wrong one.

> During testing I haven't been able to get any offset that was non-zero, so I found it tricky to either prove or disprove my own comment. Got it, it required me to lock some tracks. So yes, the `offset_down` is positive, and `offset_up` is negative, and thus the `fabs()` is on the wrong one.
nrupsis marked this conversation as resolved
@ -141,0 +212,4 @@
const bool up_valid = transdata_get_track_shuffle_offset_side(trans_datas, false, &offset_up);
if (down_valid && up_valid) {
if (abs(offset_down) < offset_up) {

Not for this patch, but for future reference: we may want to have a function series minabs_ff(float a, float b) (with more _fff and also _dd and _ii just like the min_... and max_... functions) that return the value for which the absolute value is the smallest.

Not for this patch, but for future reference: we may want to have a function series `minabs_ff(float a, float b)` (with more `_fff` and also `_dd` and `_ii` just like the `min_...` and `max_...` functions) that return the value for which the absolute value is the smallest.
nrupsis marked this conversation as resolved
@ -141,0 +241,4 @@
bAnimListElem *ale;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {

use LISTBASE_FOREACH

use `LISTBASE_FOREACH`
nrupsis marked this conversation as resolved
Sybren A. Stüvel added 2 commits 2023-05-17 11:35:52 +02:00

I'm seeing some strange behaviour in this PR. With the attached file, do this:

  • Press 'G' to grab the strip, and drag it to track Locked 1
  • It ends up at Below Locked 1, even though the closest available unlocked track is Above 2
  • Drag the track from Below Locked 1 to Locked 1 again
  • It now ends up at Below Locked 2, even though the closest available unlocked track is Above 2 and earlier it picked Below Locked 1.
I'm seeing some strange behaviour in this PR. With [the attached file](/attachments/0e969e98-512b-4ebd-be63-8d39b28bd84f), do this: - Press 'G' to grab the strip, and drag it to track _Locked 1_ - It ends up at _Below Locked 1_, even though the closest available unlocked track is _Above 2_ - Drag the track from _Below Locked 1_ to _Locked 1_ again - It now ends up at _Below Locked 2_, even though the closest available unlocked track is _Above 2_ and earlier it picked _Below Locked 1_.
Nate Rupsis added 3 commits 2023-05-23 23:02:58 +02:00
Nate Rupsis added 1 commit 2023-05-23 23:04:21 +02:00
Author
Member

@dr.sybren Thanks for blend file! Should be working now.

@dr.sybren Thanks for blend file! Should be working now.
Nate Rupsis requested review from Sybren A. Stüvel 2023-05-23 23:06:37 +02:00
Nate Rupsis added 1 commit 2023-06-11 22:23:18 +02:00

This is working better, as it feels more consistent / predictable. However, it just prevents the entire operation when one of the selected strips lands on a locked track. This could be an ok approach, but then there should be a warning issued that the operation could not be performed, and that explains why.

Also please update the PR description to include these design choices. How the system behaves when it cannot fully perform a transformation is something that should be an explicit part of the proposed design, and not something that flows out of the current implementation.

Update: going back to the main branch and seeing how it behaves there (not even being able to drag through locked tracks), I think this PR is already a huge improvement. Just add a warning when landing on a locked track, and include this in the patch description, and I think (at least behaviour-wise) it's good to land.

This is working better, as it feels more consistent / predictable. However, it just prevents the entire operation when one of the selected strips lands on a locked track. This could be an ok approach, but then there should be a warning issued that the operation could not be performed, and that explains why. Also please update the PR description to include these design choices. How the system behaves when it cannot fully perform a transformation is something that should be an explicit part of the proposed design, and not something that flows out of the current implementation. **Update:** going back to the `main` branch and seeing how it behaves there (not even being able to drag through locked tracks), I think this PR is already a huge improvement. Just add a warning when landing on a locked track, and include this in the patch description, and I think (at least behaviour-wise) it's good to land.
Nate Rupsis added 2 commits 2023-06-20 15:32:41 +02:00
Sybren A. Stüvel approved these changes 2023-06-20 17:06:57 +02:00
Sybren A. Stüvel left a comment
Member

LGTM!

LGTM!
Nate Rupsis merged commit 4268ac0ed9 into main 2023-06-20 17:10:15 +02:00
Nate Rupsis deleted branch NLA-vertical-shuffle-core 2023-06-20 17:10:16 +02:00
Sign in to join this conversation.
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 Assignees
4 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#107990
No description provided.