---
# System prepended metadata

title: Asset Browser / Pose Library Plan of Attack
tags: [' Pose Library', ' Asset Browser', Assets, ' Animation']

---

---
tags: Assets, Pose Library, Asset Browser, Animation
---
# Asset Browser / Pose Library Plan of Attack

This is a **draft** document. The intention is to expand this document to describe the work & design for the [Asset Browser & Pose Library project](https://developer.blender.org/project/profile/126/), then move the contents of this file into tasks on developer.blender.org.

> [color=#fc7c05] Orange is used to indicate debatable items. This can be in a note like this, or as an orange label (which HackMD doesn't allow me to put here).

![](https://i.imgur.com/EXtrGnG.jpg)


## Create / Edit

- [x] Mock up "Create Pose" button functionality in Python
- [x] Auto-generate thumbnail from viewport capture
- [x] Name the new asset after the rig
- [x] Show just-created asset in asset browser, selected + active
- [x] Pick biggest Asset Browser when there are multiple (see [`editsource_text_edit()`](https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/interface/interface_ops.c$1339-1345))
- [ ] Copy active tags from Asset Browser into new Asset
- [ ] Reset Asset Browser free text search if new Asset doesn't match
- [x] [color=#fc7c05] Use name from active Asset in the Asset Browser as default name ?
- [x] Implement rendering of the thumbnail via the "Refresh Thumbnail" button


### Panel in Dopesheet Editor

This panel is used for **creating a new Pose in the current blend file**.
It is intentionally basic in its functionality.

- It copies the Action data
- of the currently selected pose bones
- as defined by keys on the current frame
- to the same frame of a new Action
- that is marked as Asset.

Panel content:
- "Create Pose Asset" button

The actions it will perform:
- Create the Action datablock,
- copy animation data into it as defined above,
- mark it as Asset.

This button (or the entire panel) should be disabled when the current Action is already marked as Asset.

### Refresh Asset Browser After Pose Creation

After creating the pose per the "Create Pose Asset" button described above:

- Send notifiers so that the Asset Browser refreshes,
- scroll the just-created Asset into view, and
- select the Asset so that it can be further edited by the user.


### Automatic Preview Rendering from Viewport

Render a preview with the 3D Viewport. If there are multiple:

- If there is one viewing the Scene Camera, use that one, otherwise
- if there is one using some Camera object, use that one, otherwise
- use the biggest one?


### Automatic Preview Rendering from Scene Camera

Render a preview with the current scene camera. This makes it possible to set specific render options for preview generation.

- Find the Scene's Camera,
- render a frame at a suitable resolution,
- crop it square, and
- assign it as the selected Action's preview image.

These actions should be performed when the "Refresh Preview" button is pressed in the Asset Browser sidebar.

> [color=#fc7c05] **Dispute**: Using the scene camera is nice when there is a separate pose library blend file, which can be set up specifically for rendering thumbnails. 
> However, using the Pose Library system shouldn't *require* setting up such an elaborate file just to get reasonable thumbnails.

### Automatic Preview Attachment

When creating the pose per the "Create Pose Asset" button:
- render a preview as described above, and
- assign it to the just-created pose datablock, before refreshing the Asset Browser.

### Name the new asset after the rig

Currently this is implemented as follows:
- The "Create Pose Asset" operator has a `pose_name` property
- if that property is non-empty, use it as the pose name
- otherwise, the **active object name** is used.

This allows the current two workflows. Press "Create Pose Asset", then:
- press F9 to name it and *set the default name* for subsequent poses, or
- rename in the Asset Browser to *not influence the default name* for subsequent poses.

> [color=#fc7c05] [name=Sybren A. Stüvel] Not sure if this is a nice way to do this, could be powerful, could be confusing. This is what is implemented in the prototype to figure out, though.
>
> **Alternative:** give the pose name in advance, before pressing the "Create Pose Asset" button. This also makes it possible to enable/disable an "Update Pose Asset" button in case the name refers to an existing pose asset.


## Use / Filter

- [x] Apply Pose with pose asset in work file
- [ ] Allow linking Assets from asset file
- [ ] Allow appending Assets from asset file
- [ ] Add Append/Link switch in Asset Browser
- [x] Create "apply pose" function on Action, and expose via RNA
- [x] Create "apply pose" operator + button in panel
- [x] Add blend percentage to "apply pose" function
- [x] Add blend percentage to "apply pose" operator
- [x] "Select Bones" and "Unselect Bones" buttons
- [ ] Present tags as buttons for filtering
- [ ] Define how selection of tags filter (AND or OR clause)
- [ ] Group category-enriched tags together
- [ ] Define how tags within category filter

### Filtering with Category-Enriched Tags

#### Show Tags

Add a Tags panel to the left-hand sidebar of the Asset Browser.
It should show all tags of all visible assets.

> [color=#fc7c05] **Dispute**: could become unwieldy.

#### Filter by Tags

Tags should be selectable, allowing multi-selection. If any tags are selected, only those Assets that have ALL selected tags should be shown.

The panel should show all tags of those assets that would be visible if tag filtering wouldn't exist.

> [color=#fc7c05] **Dispute**: Could become unwieldy. Alternative is to have explicit "Add Filter" button after tag selection. This would apply the filtering based on the selected tags, then reduce the shown tags to only those on the still-shown Assets.

### Group Tags by Category

- Tags in the form `category:subtag` should be grouped together.
- This group should have a header indicating the category.
- The tags should use only the subtag as a label.

#### Filtering by Category-Enriched Tags

This filtering system should support queries like "Hand-poses only, suitable for Rex and Victoria", or "Poses for Rex only, but both Face and Hand poses".

Update the filtering such that:
- All selected subtags of the same category form an "OR" clause, and 
- all such clauses are "AND"-ed together with eachother and with regular tags.

## Asset View UI Grid

A mini-version of the Asset Browser for browsing a subset of assets in regular layouts (e.g. inside panels, regions or popups).
* A simple template: `uiLayout.template_asset_view(filter_settings)`
* Creates a `UIList`. This already handles stuff like writing the filter and sorting settings to files (which isn't trivial since it's UI data).
* Needs to work fine with parallel loading and generation of assets & previews.



- [ ] `UIList` display type for big previews *(partially done, needs polishing)*.
- [ ] New button type for preview tiles (image + label)
- [ ] Filter by tags, possibly other filtering options
- [ ] Support multi-selection for `UIList`
- [ ] Use `View2D` for `UIList` nicer scrolling and independent zooming


## Asset Data Layer

Provide access to asset lists from outside the Asset/File Browser.
* `AssetList` API/data-structure for storing asset references of a single library.
  * Internally uses `FileList` from the File Browser. This already does a fair amount of heavy lifting (file and recursive directory reading, preview loading, threading, filtering, preview cache, ...)
  * Could lazy-fetch assets, i.e. only read assets of the currently requested category/type. (*Nice-to-have* feature)
* Some runtime storage/cache/data-base to globally store the already fetched asset lists.
* `template_asset_view()` needs access to (a subset of) the asset list as RNA-collection.
* Can we separate the data part better from the display? `FileList` currently mixes data reading/management with things like preview caching based on which previews are in view bounds.

## Future Ideas

### Update Pose in Current File

This workflow should be made possible:
- Open the blend file that contains the Pose to update,
- select the Pose in the Asset Browser,
- apply the pose to the rig,
- update and key the rig,
- press an "Update Pose" button to update the Pose datablock, and
- save the blend file.

This means adding an "Update Pose" button in the Asset Browser's right-hand panel, as that's the only place that has a concept of "currently selected Pose asset". Clicking the button:
- removes all existing keyframes from the Action, and
- copies new keyframes into the action, the same way the "Create Pose" button would.

This means "Update Pose" **only** updates the pose itself, and leaves all Asset metadata as-is.

> [color=#fc7c05] **Dispute**: the location of the "Update Pose" button should be:
> 
> - In the Action editor, because that is where the pose data and the "Create Pose" button are.
> - In the Asset Browser, because that is where the currently-selected pose asset is (i.e. the one to update).
> 
> The latter is probably the best, because the "current rig" is available in the context there too.


### Update Pose in Current File by Copying from Shot File

This matches the *Copy Pose from Shot File to Pose Library* flow described above, except it updates an existing Asset rather than creating a new one.

Create an operator "Paste To Asset", which:
- is only enabled when an existing Asset is selected, that resides in the current blend file,
- loads the temporary blend file that was saved when "Copy as Asset" was clicked,
- performs the same routine as described in "Update Pose in Current File", except that the current bone selection is ignored and all keys from the Action are copied.

### Open Asset-containing Blend File

Right-clicking on an Asset in the Asset Browser should present a context menu with an operator "Open Containing Blend File". The operator should:
- Start a new Blender process,
- open the blend file that contains the selected asset.

### Select Asset When Opening Blend File

When using "Open Containing Blend File" as described above, it would be nice if the Asset Browser automatically selects the Asset of interest.

> [color=#fc7c05] **This is a debatable feature**, because:
> - Blender currently never auto-selects objects for the user.
> - There is no guarantee the opened blend file has a single Asset Browser editor visible, so in theory this feature could be useless (no Asset Browser) or require guesswork (multiple Asset Browsers).

### Create tags from bonegroups

### Pose Editor as special mode of Dopesheet Editor
