Blender V4.3
blender::ed::asset::index Namespace Reference

Classes

class  AbstractFile
 
struct  AssetIndex
 
class  AssetIndexFile
 
struct  AssetLibraryIndex
 References the asset library directory. More...
 
class  BlendFile
 Reference to a blend file that can be indexed. More...
 

Functions

constexpr StringRef ATTRIBUTE_VERSION ("version")
 Indexer for asset libraries.
 
constexpr StringRef ATTRIBUTE_ENTRIES ("entries")
 
constexpr StringRef ATTRIBUTE_ENTRIES_NAME ("name")
 
constexpr StringRef ATTRIBUTE_ENTRIES_CATALOG_ID ("catalog_id")
 
constexpr StringRef ATTRIBUTE_ENTRIES_CATALOG_NAME ("catalog_name")
 
constexpr StringRef ATTRIBUTE_ENTRIES_DESCRIPTION ("description")
 
constexpr StringRef ATTRIBUTE_ENTRIES_AUTHOR ("author")
 
constexpr StringRef ATTRIBUTE_ENTRIES_COPYRIGHT ("copyright")
 
constexpr StringRef ATTRIBUTE_ENTRIES_LICENSE ("license")
 
constexpr StringRef ATTRIBUTE_ENTRIES_TAGS ("tags")
 
constexpr StringRef ATTRIBUTE_ENTRIES_PROPERTIES ("properties")
 
static void add_id_name (DictionaryValue &result, const short idcode, const StringRefNull name)
 add id + name to the attributes.
 
static void init_value_from_file_indexer_entry (DictionaryValue &result, const FileIndexerEntry *indexer_entry)
 
static void init_value_from_file_indexer_entries (DictionaryValue &result, const FileIndexerEntries &indexer_entries)
 
static void init_indexer_entry_from_value (FileIndexerEntry &indexer_entry, const DictionaryValue &entry)
 
static int init_indexer_entries_from_value (FileIndexerEntries &indexer_entries, const DictionaryValue &value)
 
static eFileIndexerResult read_index (const char *filename, FileIndexerEntries *entries, int *r_read_entries_len, void *user_data)
 
static void update_index (const char *filename, FileIndexerEntries *entries, void *user_data)
 
static void * init_user_data (const char *root_directory, size_t root_directory_maxncpy)
 
static void free_user_data (void *user_data)
 
static void filelist_finished (void *user_data)
 
constexpr FileIndexerType asset_indexer ()
 

Variables

const FileIndexerType file_indexer_asset = asset_indexer()
 

Function Documentation

◆ add_id_name()

static void blender::ed::asset::index::add_id_name ( DictionaryValue & result,
const short idcode,
const StringRefNull name )
static

add id + name to the attributes.

NOTE: id and name are encoded like ID.name

Definition at line 143 of file asset_indexer.cc.

References ATTRIBUTE_ENTRIES_NAME().

Referenced by init_value_from_file_indexer_entry().

◆ asset_indexer()

◆ ATTRIBUTE_ENTRIES()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES ( "entries" )
constexpr

◆ ATTRIBUTE_ENTRIES_AUTHOR()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_AUTHOR ( "author" )
constexpr

◆ ATTRIBUTE_ENTRIES_CATALOG_ID()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_CATALOG_ID ( "catalog_id" )
constexpr

◆ ATTRIBUTE_ENTRIES_CATALOG_NAME()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_CATALOG_NAME ( "catalog_name" )
constexpr

◆ ATTRIBUTE_ENTRIES_COPYRIGHT()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_COPYRIGHT ( "copyright" )
constexpr

◆ ATTRIBUTE_ENTRIES_DESCRIPTION()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_DESCRIPTION ( "description" )
constexpr

◆ ATTRIBUTE_ENTRIES_LICENSE()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_LICENSE ( "license" )
constexpr

◆ ATTRIBUTE_ENTRIES_NAME()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_NAME ( "name" )
constexpr

◆ ATTRIBUTE_ENTRIES_PROPERTIES()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_PROPERTIES ( "properties" )
constexpr

◆ ATTRIBUTE_ENTRIES_TAGS()

StringRef blender::ed::asset::index::ATTRIBUTE_ENTRIES_TAGS ( "tags" )
constexpr

◆ ATTRIBUTE_VERSION()

StringRef blender::ed::asset::index::ATTRIBUTE_VERSION ( "version" )
constexpr

Indexer for asset libraries.

Indexes are stored per input file. Each index can contain zero to multiple asset entries. The indexes are grouped together per asset library. They are stored in BKE_appdir_folder_caches + /asset-library-indices/<asset-library-hash>/<asset-index-hash>_<asset_file>.index.json.

The structure of an index file is

{
"version": <file version number>,
"entries": [{
"name": "<asset name>",
"catalog_id": "<catalog_id>",
"catalog_name": "<catalog_name>",
"description": "<description>",
"author": "<author>",
"copyright": "<copyright>",
"license": "<license>",
"tags": ["<tag>"],
"properties": [..]
}]
}

NOTE: entries, author, description, copyright, license, tags and properties are optional attributes.

NOTE: File browser uses name and idcode separate. Inside the index they are joined together like ID.name. NOTE: File browser group name isn't stored in the index as it is a translatable name.

Referenced by blender::ed::asset::index::AssetIndex::AssetIndex(), and blender::ed::asset::index::AssetIndex::get_version().

◆ filelist_finished()

static void blender::ed::asset::index::filelist_finished ( void * user_data)
static

◆ free_user_data()

static void blender::ed::asset::index::free_user_data ( void * user_data)
static

Definition at line 733 of file asset_indexer.cc.

Referenced by asset_indexer().

◆ init_indexer_entries_from_value()

static int blender::ed::asset::index::init_indexer_entries_from_value ( FileIndexerEntries & indexer_entries,
const DictionaryValue & value )
static

◆ init_indexer_entry_from_value()

◆ init_user_data()

static void * blender::ed::asset::index::init_user_data ( const char * root_directory,
size_t root_directory_maxncpy )
static

◆ init_value_from_file_indexer_entries()

static void blender::ed::asset::index::init_value_from_file_indexer_entries ( DictionaryValue & result,
const FileIndexerEntries & indexer_entries )
static

◆ init_value_from_file_indexer_entry()

◆ read_index()

◆ update_index()

static void blender::ed::asset::index::update_index ( const char * filename,
FileIndexerEntries * entries,
void * user_data )
static

Variable Documentation

◆ file_indexer_asset

const FileIndexerType blender::ed::asset::index::file_indexer_asset = asset_indexer()

File Indexer Service for indexing asset files.

Opening and parsing a large collection of asset files inside a library can take a lot of time. To reduce the time it takes the files are indexed.

  • Index files are created for each blend file in the asset library, even when the blend file doesn't contain any assets.
  • Indexes are stored in an persistent cache folder (BKE_appdir_folder_caches + asset_library_indexes/{asset_library_dir}/{asset_index_file.json}).
  • The content of the indexes are used when:
    • Index exists and can be opened
    • Last modification date is earlier than the file it represents.
    • The index file version is the latest.
  • Blend files without any assets can be determined by the size of the index file for some additional performance.

Definition at line 758 of file asset_indexer.cc.

Referenced by blender::ed::asset::list::AssetList::setup().