Asset Browser
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Catalogs Plan of Attack **Context:** [2021-08-20 Asset Browser and 3.0](https://devtalk.blender.org/t/2021-08-20-asset-browser-and-3-0/19730) meeting. This is a draft planning for tasks regarding the Catalogs. **UPDATE:** This document is superseded by [T90066: Design Catalog system](https://developer.blender.org/T90066) ## Design Considerations ### C vs C++ The asset catalog system will be C++ with a C interface where necessary. Since all the catalog information is runtime-only, there is no need for DNA. ### File Format A **catalog definition file (CDF)** is a plain text (UTF-8) file. - Empty lines are ignored. - Lines starting with `#` are ignored. - The file should start with a declaration of what it is (human-readable), and a version number indicating the file format revision (human- and machine-readable). Any other line should contain a catalog definition: ``` CATALOG_ID posix/style/path ``` The `CATALOG_ID` may not contain spaces, as a space is used as separator between it and the path. The path can contain spaces. ### Multiple definitions A library could have zero, one, or multiple catalog definition files. - **One CDF: simple configuration.** All new catalogs are stored here. - **Zero CDFs: unexpected configuration.** Should not break Blender. - Maybe show assets under a *${CATALOGID} (unknown catalog)* label? Renaming that catalog should create its path. This could also work for other cases where unknown catalog IDs are used. - **Multiple CDFs: complex configuration.** Renames could influence multiple CDFs simultaneously. Changed catalogs should be written back to the file they came from. ### Deduplication Multiple definitions of a `CATALOG_ID` in one file should be avoided. A warning could be logged (on the terminal, for example) and the first occurrence of the catalog wins. Defining the same catalog in multiple files is fine, as long as they don't confict. In case of conflict, the one defined in the top-most file wins, and the rest is synchronized when it changes (i.e. when a write is triggered). ### File Locations Multiple locations are supported: - Top level: `${ASSET_LIBRARY_ROOT}/blender-asset-library.cats.txt` - Per blend file: `blendfile-path-without-extension.cats.txt` - Maaaaybe arbitrary locations? Like a `blender-asset-library.cats.txt` in each subdirectory? Will become relevant when subdirs are possible with the Asset Browser. ## Big chunks to do ### Decide on line endings What happens when writing the file? Probably best to keep the line ending that's in use (to stay friendly with versioning systems). - First step: use platform-native line endings when writing. - Second step: remember line endings used, and use those when writing. ### Decide how to keep track of which catalog is defined in which CDF A catalog can be defined in multiple files, and when updated should be written to all those files. This can be done by keeping track of a `set<AssetCatalogDefinitionFile *>` in each catalog. ### Decide UX for editing catalog IDs The *catalog paths* are what users will be primarily interacting with. The catalog IDs allow for nifty tricks (like moving assets without updating their blend file), but do make things harder to explain/use. This should be clear in the UI. ### Decide UX for creating new Catalogs Users have to choose a *catalog ID*, which could default to the slugified last element of the catalog path. Something (user or Blender) has to choose where to save the catalog info: - If there is a CDF for the current blend file, store there, otherwise - if there is a top-level CDF, store there, otherwise - if the current blend file is in an asset library, create a top-level CDF, otherwise - create a CDF for the current blend file. ### Add Catalog ID to `AssetMetaData` A symbolic identifier of which catalog path this asset is stored in. ```c typedef struct AssetMetaData { ... char catalog_id[64]; } ``` **TBD: the max length.** 64 was just chosen arbitrarily. ### Add `AssetLibraryCatalogs` class Manages catalogs of a single asset library. - Given a Catalog ID, can look up the path. - Can give the Catalog ID of a given path (f.e. when moving assets) - Can rename paths (keeping track of other paths to change as well, when the changed part is shared by other paths). - Can read CDFs. - Can write CDFs. - Maybe: can work as back-end for tree view. **TBD: this needs to be split up into smaller TODOs.** #### Reading, writing, tracking ```c++ using CatalogID = std::string; using CatalogPath = std::string; using CatalogPathComponent = std::string; using CatalogFilePath = std::string; class AssetCatalogDefinitionFile; class AssetCatalogTreeNode { /* Pointer to the parent tree node. */ AssetCatalogTreeNode *parent = nullptr; /* Child nodes, ordered by their name. */ std::set<AssetCatalogTreeNode *> children; /* Catalogs that have this path. */ Map<CatalogID, AssetCatalog *> catalogs; /* The path component that is associated with this catalog. Note that this may contain separators * when ancestors don't exist. This can happen when there are catalog definitions like this: * * PARENT parent -> name = "parent" * THIS_CATALOG parent/nonexistant/thisone -> name = "nonexistant/thisone" */ CatalogPathComponent name; /* Set the catalog path to `parent->catalog_path() + separator + node_name` and update all child catalogs. */ void set_catalog_name(const CatalogPathComponent &node_name); /* Return the full catalog path, defined as the name of this catalog prefixed by the full * catalog path of its parent and a separator. */ std::string catalog_path() const; }; class AssetCatalog { /* Symbolic ID, "THIS_CATALOG" in the above example. */ CatalogID catalog_id; /* Return the full catalog path, defined as the name of this catalog prefixed by the full * catalog path of its parent and a separator. */ std::string catalog_path /* Which definition files this catalog was defined in. Can be multiple, which means that multiple * files will have to be updated when this catalog is edited. */ Set<AssetCatalogDefinitionFile *> defined_in; }; class AssetCatalogDefinitionFile { CatalogFilePath file_path; Map<CatalogID, AssetCatalog *> catalogs; VectorSet<AssetCatalog *> root_catalogs; void write_to_disk() const; // Defined here instead of on AssetCatalog itself for reasons: // - Caller doesn't have to know whether this catalog is even defined in this file. // - Allows for keeping track of dirty files (i.e. where write_to_disk() has to // actually do something). // - Allows for keeping the internal bookkeeping up to date. // - Allows for path changes to be reflected in more than one catalog. // No-op if this file doesn't have this catalog. void change_catalog_path(const CatalogID &catalog_id, const CatalogPath &new_catalog_path); void change_catalog_id(const CatalogID &catalog_id, const CatalogID &new_catalog_id); // Return nullptr if not found. AssetCatalog *find_catalog(const CatalogID &catalog_id); }; ``` **TBD: internal data structure.** What is written above is just one simple idea. It's probably better to have the internal structure stored in a tree, such that a rename of a path just requires moving some elements of the tree around. Might be over-engineered though, as the catalogs are meant to be human-manageable and thus there won't be thousands of them anyway. ### Add Tree view of available catalogs Make things collapsible, selectable, determines which assets are shown in the asset browser. Allows renaming and moving of catalogs. These operations are the same from the CDF perspective, but are different operations for the user interface. ### Add current catalog (ID or path) to asset browser The asset browser should be able to show assets from a single catalog path + its children.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully