Fix/Refactor NLA Track library override #105272

Open
opened 2023-02-27 21:25:42 +01:00 by Nate Rupsis · 4 comments
Member

When refactoring the NLA create track methods, some questions came up about library overrides.

Mainly:

  1. What defines an NLA Track as a library override?
  2. What behavior differs when the NLA tracks in the Animation Data are updated (new track added, removed, ordered, etc)

Currently, every newly created NLA track has the NLATRACK_OVERRIDELIBRARY_LOCAL flag set by default. It's not super clear why this flag is set, or how it indicates a library override.

The second open question, is how a library override impacts the NLA tracks. This comment suggests that the library override tracks need to be grouped together at the front of the list, and anything local should be after that. The codes doesn't seem to enforce this however, as tracks can be inserted before/after each other, regardless of library override status.


Next step

@dr.sybren and I decided that we should open this discussion to the larger community for feedback. We'll be discussing this issue in one of the upcoming Animation & Rigging module meetings.

When refactoring the [NLA create track methods](https://projects.blender.org/blender/blender/pulls/104929), some questions came up about library overrides. Mainly: 1. What defines an NLA Track as a library override? 2. What behavior differs when the NLA tracks in the Animation Data are updated (new track added, removed, ordered, etc) Currently, every newly created NLA track has the [NLATRACK_OVERRIDELIBRARY_LOCAL](https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/intern/nla.c#L352) flag set by default. It's not super clear why this flag is set, or how it indicates a library override. The second open question, is how a library override impacts the NLA tracks. [This comment](https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/intern/nla.c#L352) suggests that the library override tracks need to be grouped together at the front of the list, and anything local should be after that. The codes doesn't seem to enforce this however, as tracks can be inserted before/after each other, regardless of library override status. --- ### Next step @dr.sybren and I decided that we should open this discussion to the larger community for feedback. We'll be discussing this issue in one of the upcoming [Animation & Rigging module meetings](https://stuvel.eu/anim-meetings/).
Nate Rupsis added the
Type
Design
label 2023-02-27 21:25:42 +01:00
Nate Rupsis added this to the Animation & Rigging project 2023-02-27 21:25:43 +01:00
Nate Rupsis added the
Module
Animation & Rigging
label 2023-02-27 21:25:53 +01:00

Maybe #105260 could be tackled at the same time, under the umbrella of "properly working with linked data".

Maybe #105260 could be tackled at the same time, under the umbrella of "properly working with linked data".

For context, systematically setting NLATRACK_OVERRIDELIBRARY_LOCAL is done to avoid as much Editor code as possible to need to be aware that it's working on liboverride data. The idea is that:

  • This flag is 100% ignored in purely local data;
  • This flag is 100% cleared in linked data;
    That way, in liboverrides (which are local data), tracks that come from (are copied from) the linked ID do not have that flag, and tracks that have been added in the override have it.

This behavior is shared between all collections of items that support liboverride insertions (constraints, the various modifiers, and so on).

While it may look confusing, it has the key advantages of being both simple, and extremely robust (in the sense that it is almost impossible for a track to be wrongly tagged as linked or local, while only requiring a very few functions to have control over the flag). I would be most happy if a better system could be worked on though, but that would be a liboverride design topic covering all use-cases, not only NLA tracks.

(Added some precisions about this in the liboverride code doc).


Regarding ordering, all 'liboverride-insertable' collections share the same limitation, which is that linked data is not re-orderable. Local data however should be, so you can e.g. move a local-inserted modifier in-between two 'linked' modifiers, but you cannot change the order of these linked modifiers.

NLA tracks have additional limitations due to the fact that their names are not unique currently, which means that override diffing and applying code cannot use these names as reference. Since using indices for that purpose is extremely unreliable (insert local track 2 after track 5, good luck keeping this doing what it is supposed to do if anything changes in the linked data's NLA tracks).

To work around that, the additional limitation is that all linked tracks come first, and local-inserted ones are always kept after all linked ones.

For context, systematically setting `NLATRACK_OVERRIDELIBRARY_LOCAL` is done to avoid as much Editor code as possible to need to be aware that it's working on liboverride data. The idea is that: * This flag is 100% ignored in purely local data; * This flag is 100% cleared in linked data; That way, in liboverrides (which are local data), tracks that come from (are copied from) the linked ID do not have that flag, and tracks that have been added in the override have it. This behavior is shared between all collections of items that support liboverride insertions (constraints, the various modifiers, and so on). While it may look confusing, it has the key advantages of being both simple, and extremely robust (in the sense that it is almost impossible for a track to be wrongly tagged as linked or local, while only requiring a very few functions to have control over the flag). I would be most happy if a better system could be worked on though, but that would be a liboverride design topic covering all use-cases, not only NLA tracks. *(Added some precisions about this in the [liboverride code doc](https://wiki.blender.org/wiki/Source/Architecture/Overrides/Library)).* ------------------- Regarding ordering, all 'liboverride-insertable' collections share the same limitation, which is that linked data is not re-orderable. Local data however should be, so you can e.g. move a local-inserted modifier in-between two 'linked' modifiers, but you cannot change the order of these linked modifiers. NLA tracks have additional limitations due to the fact that their names are not unique currently, which means that override diffing and applying code cannot use these names as reference. Since using indices for that purpose is extremely unreliable (`insert local track 2 after track 5`, good luck keeping this doing what it is supposed to do if anything changes in the linked data's NLA tracks). To work around that, the additional limitation is that all linked tracks come first, and local-inserted ones are always kept after all linked ones.

Thanks for the clarification @mont29.

Thanks for the clarification @mont29.

This was discussed in last week's module meeting, and decided to be put on hold until it blocks other development.

This was discussed in last week's [module meeting](https://devtalk.blender.org/t/2023-03-23-animation-rigging-module-meeting/28313), and decided to be put on hold until it blocks other development.
Sybren A. Stüvel removed this from the Animation & Rigging project 2023-03-30 12:09:11 +02:00
Nate Rupsis added the
Priority
Low
label 2023-03-30 21:29:26 +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 project
No Assignees
3 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#105272
No description provided.