|
Blender V5.3
|
#include <AS_asset_representation.hh>
Inherits blender::blender::NonCopyable, and blender::blender::NonMovable.
Friends | |
| class | AssetLibrary |
Definition at line 44 of file AS_asset_representation.hh.
| blender::asset_system::AssetRepresentation::AssetRepresentation | ( | StringRef | relative_asset_path, |
| StringRef | name, | ||
| int | id_type, | ||
| std::unique_ptr< AssetMetaData > | metadata, | ||
| AssetLibrary & | owner_asset_library ) |
Constructs an asset representation for an external ID stored on disk. The asset will not be editable.
For online assets, use the version with #online_info below.
Definition at line 30 of file asset_representation.cc.
| blender::asset_system::AssetRepresentation::AssetRepresentation | ( | StringRef | relative_asset_path, |
| StringRef | name, | ||
| int | id_type, | ||
| std::unique_ptr< AssetMetaData > | metadata, | ||
| AssetLibrary & | owner_asset_library, | ||
| OnlineAssetInfo | online_info ) |
Constructs an asset representation for an external ID stored online (requiring download).
Definition at line 41 of file asset_representation.cc.
| blender::asset_system::AssetRepresentation::AssetRepresentation | ( | ID & | id, |
| AssetLibrary & | owner_asset_library ) |
Constructs an asset representation for an ID stored in the current file. This makes the asset local and fully editable.
Definition at line 59 of file asset_representation.cc.
Definition at line 67 of file asset_representation.cc.
| void blender::asset_system::AssetRepresentation::ensure_previewable | ( | const bContext & | C, |
| ReportList * | reports = nullptr ) |
Makes sure the asset ready to load a preview, if necessary.
For local IDs it calls BKE_previewimg_id_get(). For others, this sets loading information to the preview but doesn't actually load it. To load it, attach its #PreviewImageRuntime::icon_id to a UI button (UI loads it asynchronously then) or call BKE_previewimg_ensure() (not asynchronous).
For online assets this triggers downloading of the preview.
Definition at line 81 of file asset_representation.cc.
| std::string blender::asset_system::AssetRepresentation::full_library_path | ( | ) | const |
Return the absolute path of the blend file that contains this asset.
Note that this performs a file-system check to see whether the blend file actually exists. If it does not, an empty string is returned. This generally shouldn't be an issue, but can happen, for example when the blend file is deleted and the asset browser not refreshed.
This check is a necessity because data-blocks may have .blend and slashes in their name, and directory names may also end in .blend, resulting in an identifier like directory.blend/Objects/filename.blend/Actions/hand/wave.blend/Actions/hi.blend. Here the file is directory.blend/Objects/filename.blend and the asset is an Action named hand/wave.blend/Actions/hi.blend.
Definition at line 181 of file asset_representation.cc.
| std::string blender::asset_system::AssetRepresentation::full_path | ( | ) | const |
Definition at line 171 of file asset_representation.cc.
Definition at line 142 of file asset_representation.cc.
| std::optional< eAssetImportMethod > blender::asset_system::AssetRepresentation::get_import_method | ( | ) | const |
Get the import method to use for this asset. A different one may be used if may_override_import_method() returns true, otherwise, the returned value must be used. If there is no import method predefined for this asset no value is returned.
Definition at line 253 of file asset_representation.cc.
Definition at line 150 of file asset_representation.cc.
Definition at line 134 of file asset_representation.cc.
Get the preview of this asset.
This will only return a preview for local ID assets or after ensure_previewable() was called.
Definition at line 125 of file asset_representation.cc.
Definition at line 270 of file asset_representation.cc.
| bool blender::asset_system::AssetRepresentation::is_local_id | ( | ) | const |
Returns if this asset is stored inside this current file, and as such fully editable.
Definition at line 280 of file asset_representation.cc.
| bool blender::asset_system::AssetRepresentation::is_online_only | ( | ) | const |
The asset is purely stored online, there is no local file on disk for this.
Regardless of what this function returns, there may be 'online info' (information from a remote asset listing) available, even when the file is on disk and this function returns false.
Definition at line 285 of file asset_representation.cc.
Returns whether the asset is stored in a probably-editable .asset.blend file.
NOTE: This is suitable for poll functions (which should not open other files). The actual operator should still check that G_FILE_ASSET_EDIT_FILE / Main::is_asset_edit_file is set on the .asset.blend file (no utility function for this exists yet).
NOTE: this function does cause some disk I/O, as it checks one (or more) paths for existence. See #AssetRepresentation::full_library_path() for more info.
If the asset is already imported, this check can be done via bke::asset_edit_id_is_editable(asset_id) and bke::asset_edit_id_is_writable(asset_id).
Definition at line 303 of file asset_representation.cc.
Definition at line 158 of file asset_representation.cc.
If this asset is stored inside this current file (is_local_id() is true), this returns the ID's pointer, otherwise null.
Definition at line 275 of file asset_representation.cc.
Create a weak reference for this asset that can be written to files, but can break under a number of conditions. A weak reference can only be created if an asset representation is owned by an asset library.
Definition at line 76 of file asset_representation.cc.
Returns if this asset may be imported with an import method other than the one returned by get_import_method(). Also returns true if there is no predefined import method (when get_import_method() returns no value).
Definition at line 262 of file asset_representation.cc.
| bool blender::asset_system::AssetRepresentation::needs_download | ( | ) | const |
Return whether this asset requires (re-)downloading before it can be used.
True for online-only assets (is_online_only()) and for on-disk assets whose files no longer match the remote listing (e.g. #AssetFileStatus::NO_MATCH).
Definition at line 340 of file asset_representation.cc.
For online assets (see is_online_only()), the files that make up this asset.
Will return an empty span if this is not an online asset.
Definition at line 193 of file asset_representation.cc.
| std::optional< int64_t > blender::asset_system::AssetRepresentation::online_asset_files_combined_size_in_bytes | ( | ) | const |
Return the sum of sizes of all files associated with this asset, according to the listing.
Definition at line 202 of file asset_representation.cc.
Turn the online asset into a normal asset. This removes the online data, and the "is online" marking, turning it into a regular on-disk asset.
No-op if this is not an online asset.
Definition at line 241 of file asset_representation.cc.
| std::optional< StringRefNull > blender::asset_system::AssetRepresentation::online_asset_preview_hash | ( | ) | const |
For online assets (see is_online_only()), the hash of the asset's preview.
Will return an empty value if this is not an online asset.
Definition at line 228 of file asset_representation.cc.
| std::optional< StringRefNull > blender::asset_system::AssetRepresentation::online_asset_preview_url | ( | ) | const |
For online assets (see is_online_only()), the URL the asset's preview should be requested from.
Will return an empty value if this is not an online asset.
Definition at line 215 of file asset_representation.cc.
Store the remote listings online info on an on-disk asset so it can be re-downloaded. Replaces any previously set online info.
Definition at line 322 of file asset_representation.cc.
Definition at line 345 of file asset_representation.cc.
Status of this asset's on-disk file(s) compared to the remote listing. Returns #AssetFileStatus::UNSET if the asset has not been checked against a listing. For on-disk assets this reflects the status stamped after listing comparison. For online-only assets this reflects the status from OnlineAssetInfo.
Definition at line 313 of file asset_representation.cc.
| void blender::asset_system::AssetRepresentation::remote_file_status_set | ( | RemoteAssetFileStatus | status | ) |
Set the file status for on-disk assets. No-op for online-only assets.
Definition at line 331 of file asset_representation.cc.
|
friend |
Definition at line 83 of file AS_asset_representation.hh.