ezEngine Release 26.3
Loading...
Searching...
No Matches
ezAssetCurator Class Reference

Classes

struct  ExportResult
 
struct  ReplaceAssetResult
 Result of a bulk asset reference replacement operation. More...
 

Public Member Functions

Setup
void StartInitialize (const ezApplicationFileSystemConfig &cfg)
 Starts init task. Need to call WaitForInitialize to finish before loading docs.
 
void WaitForInitialize ()
 Waits for init task to finish.
 
void Deinitialize ()
 
void MainThreadTick (bool bTopLevel)
 
Asset Platform Configurations
const ezPlatformProfileGetDevelopmentAssetProfile () const
 
const ezPlatformProfileGetActiveAssetProfile () const
 The currently active target platform for asset processing.
 
ezUInt32 GetActiveAssetProfileIndex () const
 Returns the index of the currently active asset platform configuration.
 
ezUInt32 FindAssetProfileByName (const char *szPlatform)
 Returns ezInvalidIndex if no config with the given name exists. Name comparison is case insensitive.
 
ezUInt32 GetNumAssetProfiles () const
 
const ezPlatformProfileGetAssetProfile (ezUInt32 uiIndex) const
 Always returns a valid config. E.g. even if ezInvalidIndex is passed in, it will fall back to the default config (at index 0).
 
ezPlatformProfileGetAssetProfile (ezUInt32 uiIndex)
 Always returns a valid config. E.g. even if ezInvalidIndex is passed in, it will fall back to the default config (at index 0).
 
ezPlatformProfileCreateAssetProfile ()
 Adds a new profile. The name should be set afterwards to a unique name.
 
ezResult DeleteAssetProfile (ezPlatformProfile *pProfile)
 
void SetActiveAssetProfileByIndex (ezUInt32 uiIndex, bool bForceReevaluation=false)
 
ezResult SaveAssetProfiles ()
 Saves the current asset configurations. Returns failure if the output file could not be written to.
 
void SaveRuntimeProfiles ()
 
High Level Functions
ezDateTime GetLastFullTransformDate () const
 
void StoreFullTransformDate ()
 
ezStatus TransformAllAssets (ezBitflags< ezTransformFlags > transformFlags=ezTransformFlags::TriggeredManually, const ezPlatformProfile *pAssetProfile=nullptr)
 
ezTransformStatus TransformAsset (const ezUuid &assetGuid, ezBitflags< ezTransformFlags > transformFlags, const ezPlatformProfile *pAssetProfile=nullptr)
 
ezTransformStatus CreateThumbnail (const ezUuid &assetGuid)
 
void ResaveAllAssets (ezStringView sPrefixPath)
 
void TransformAssetsForSceneExport (const ezPlatformProfile *pAssetProfile=nullptr)
 
ezResult WriteAssetTables (const ezPlatformProfile *pAssetProfile=nullptr, bool bForce=false)
 Writes the asset lookup table for the given platform, or the currently active platform if nullptr is passed.
 
Manual and Automatic Change Notification
void NotifyOfFileChange (ezStringView sAbsolutePath)
 Allows to tell the system of a new or changed file, that might be of interest to the Curator.
 
void NotifyOfAssetChange (const ezUuid &assetGuid)
 Allows to tell the system to re-evaluate an assets status.
 
void UpdateAssetLastAccessTime (const ezUuid &assetGuid)
 
void CheckFileSystem ()
 Checks file system for any changes. Call in case the file system watcher does not pick up certain changes.
 
void NeedsReloadResources (const ezUuid &assetGuid) const
 
void InvalidateAssetsWithTransformState (ezAssetInfo::TransformState state)
 
Utilities
void GenerateTransitiveHull (const ezStringView sAssetOrPath, ezSet< ezString > &inout_deps, ezBitflags< ezDependencyFlags > dependencyTypes) const
 Generates one transitive hull for all the dependencies that are enabled. The set will contain dependencies that are reachable via any combination of enabled reference types.
 
void GenerateTransitiveAssetHull (const ezUuid &assetGuid, ezSet< ezUuid > &inout_deps, ezBitflags< ezDependencyFlags > dependencyTypes)
 Generates one transitive hull for all the asset dependencies that are enabled. The set will contain dependencies that are reachable via any combination of enabled reference types.
 
void GenerateSettingsHashMap (const ezSet< ezString > &deps, ezBitflags< ezDependencyFlags > dependencyType, ezMap< ezString, ezUInt64 > &out_settingsHashMap) const
 Copies each value of deps into out_SettingsHashMap and fills the value of assets with the hash value of the dependencyType. For files, the file hash is used.
 
void GenerateInverseTransitiveHull (const ezAssetInfo *pAssetInfo, ezSet< ezUuid > &inout_inverseDeps, bool bIncludeTransformDeps=false, bool bIncludeThumbnailDeps=false) const
 Generates one inverse transitive hull for all the types dependencies that are enabled. The set will contain inverse dependencies that can reach the given asset (pAssetInfo) via any combination of the enabled reference types. As only assets can have dependencies, the inverse hull is always just asset GUIDs.
 
void WriteDependencyDGML (const ezUuid &guid, ezStringView sOutputFile) const
 Generates a DGML graph of all transform and thumbnail dependencies.
 
ExportResult ExportAssets (ezArrayPtr< ezString > sources, ezStringView sDestinationFolder, ezBitflags< ezDependencyFlags > includeDependencyTypes=ezDependencyFlags::Transform|ezDependencyFlags::Thumbnail|ezDependencyFlags::Package) const
 
void ClearAssetCaches (ezAssetDocumentManager::OutputReliability threshold)
 

Public Attributes

ezEvent< const ezAssetCuratorEvent & > m_Events
 

Friends

class ezUpdateTask
 
class ezAssetProcessor
 
class ezEditorProcessorProcess
 

Asset Access

using ezLockedSubAsset = ezLockedObject< ezMutex, const ezSubAsset >
 
using ezLockedSubAssetTable = ezLockedObject< ezMutex, const ezHashTable< ezUuid, ezSubAsset > >
 
using ezLockedAssetTable = ezLockedObject< ezMutex, const ezHashTable< ezUuid, ezAssetInfo * > >
 
const ezLockedSubAsset FindSubAsset (ezStringView sPathOrGuid, bool bExhaustiveSearch=false) const
 
const ezLockedSubAsset GetSubAsset (const ezUuid &assetGuid) const
 Same as GetAssteInfo, but wraps the return value into a ezLockedSubAsset struct.
 
const ezLockedSubAssetTable GetKnownSubAssets () const
 Returns the table of all known assets in a locked structure.
 
const ezLockedAssetTable GetKnownAssets () const
 Returns the table of all known assets in a locked structure.
 
ezUInt64 GetAssetTransformHash (ezUuid assetGuid)
 Computes the transform hash for the asset and its transform dependencies. Returns 0 if anything went wrong.
 
ezUInt64 GetAssetThumbnailHash (ezUuid assetGuid)
 Computes the thumbnail hash for the asset and its thumbnail dependencies. Returns 0 if anything went wrong.
 
ezAssetInfo::TransformState IsAssetUpToDate (const ezUuid &assetGuid, const ezPlatformProfile *pAssetProfile, const ezAssetDocumentTypeDescriptor *pTypeDescriptor, ezUInt64 &out_uiAssetHash, ezUInt64 &out_uiThumbHash, ezUInt64 &out_uiPackageHash, bool bForce=false)
 
void GetAssetTransformStats (ezUInt32 &out_uiNumAssets, ezHybridArray< ezUInt32, ezAssetInfo::TransformState::COUNT > &out_count)
 Returns the number of assets in the system and how many are in what transform state.
 
ezString FindDataDirectoryForAsset (ezStringView sAbsoluteAssetPath) const
 Iterates over all known data directories and returns the absolute path to the directory in which this asset is located.
 
void GetAllAssetsInFolder (ezStringView sFolderPath, ezDynamicArray< ezString > &out_assetGuids) const
 
ezResult FindBestMatchForFile (ezStringBuilder &ref_sFile, ezArrayPtr< ezString > allowedFileExtensions) const
 
void FindAllUses (ezUuid assetGuid, ezSet< ezUuid > &ref_uses, bool bTransitive) const
 
void FindAllUses (ezStringView sAbsolutePath, ezSet< ezUuid > &ref_uses) const
 
bool IsReferenced (ezStringView sAbsolutePath) const
 

Asset Reference Replacement

ezUInt32 ReplaceAssetReferenceInObject (ezObjectAccessorBase *pAccessor, const ezDocumentObject *pObject, ezStringView sOldReference, ezStringView sNewReference, ezDynamicArray< ezString > &out_errors)
 
ezUInt32 ReplaceAssetReferenceInDocument (ezDocument *pDocument, ezStringView sOldReference, ezStringView sNewReference, ezDynamicArray< ezString > &out_errors)
 
ReplaceAssetResult ReplaceAssetReferenceInUses (ezUuid assetToReplace, ezStringView sOldReference, ezStringView sNewReference)
 

Member Function Documentation

◆ ClearAssetCaches()

void ezAssetCurator::ClearAssetCaches ( ezAssetDocumentManager::OutputReliability  threshold)

Deletes all files in all asset caches, except for the asset outputs that exceed the threshold.

-> OutputReliability::Perfect -> deletes everything -> OutputReliability::Good -> keeps the 'Perfect' files -> OutputReliability::Unknown -> keeps the 'Good' and 'Perfect' files

◆ DeleteAssetProfile()

ezResult ezAssetCurator::DeleteAssetProfile ( ezPlatformProfile pProfile)

Deletes the given asset profile, if possible.

The function fails when the given profile is the main profile (at index 0), or it is the currently active profile.

◆ ExportAssets()

ezAssetCurator::ExportResult ezAssetCurator::ExportAssets ( ezArrayPtr< ezString sources,
ezStringView  sDestinationFolder,
ezBitflags< ezDependencyFlags includeDependencyTypes = ezDependencyFlags::Transform | ezDependencyFlags::Thumbnail | ezDependencyFlags::Package 
) const

Exports assets and their dependencies to a destination folder.

Takes an array of source paths (asset GUIDs as strings or file paths) and exports them along with all their dependencies to the destination folder. Files are copied preserving their relative paths from the data directories. Each file is copied only once, even if it appears in multiple dependency trees.

◆ FindAllUses() [1/2]

void ezAssetCurator::FindAllUses ( ezStringView  sAbsolutePath,
ezSet< ezUuid > &  ref_uses 
) const

Returns all assets that use a file for transform. Use this to e.g. figure which assets still reference a .tga file in the project.

Parameters
sAbsolutePathAbsolute path to any file inside a data directory.
ref_usesList of assets that use 'sAbsolutePath'. Any previous content of the set is not removed.

◆ FindAllUses() [2/2]

void ezAssetCurator::FindAllUses ( ezUuid  assetGuid,
ezSet< ezUuid > &  ref_uses,
bool  bTransitive 
) const

Finds all uses, either as transform or thumbnail dependencies to a given asset.

Technically this finds all dependencies to this asset but in practice there are no uses of transform dependencies between assets right now so the result is a list of thumbnail dependencies and can be referred to as simply a list of asset references.

Parameters
assetGuidThe asset to find use cases for.
usesList of assets that use 'assetGuid'. Any previous content of the set is not removed.
transitiveIf set, will also find indirect uses of the asset.

◆ FindBestMatchForFile()

ezResult ezAssetCurator::FindBestMatchForFile ( ezStringBuilder ref_sFile,
ezArrayPtr< ezString allowedFileExtensions 
) const

Uses knowledge about all existing files on disk to find the best match for a file. Very slow.

Parameters
sFileFile name (may include a path) to search for. Will be modified both on success and failure to give a 'reasonable' result.

◆ FindSubAsset()

const ezAssetCurator::ezLockedSubAsset ezAssetCurator::FindSubAsset ( ezStringView  sPathOrGuid,
bool  bExhaustiveSearch = false 
) const

Tries to find the asset information for an asset identified through a string.

The string may be a stringyfied asset GUID or a relative or absolute path. The function will try all possibilities. If no asset can be found, an empty/invalid ezAssetInfo is returned. If bExhaustiveSearch is set the function will go through all known assets and find the closest match.

◆ GetAllAssetsInFolder()

void ezAssetCurator::GetAllAssetsInFolder ( ezStringView  sFolderPath,
ezDynamicArray< ezString > &  out_assetGuids 
) const

Collects all main asset GUIDs located within the specified folder path.

Searches through all known assets and adds the string representation of their GUID to the output array if their absolute path starts with the given folder path. Only main assets are included (not sub-assets).

◆ GetDevelopmentAssetProfile()

const ezPlatformProfile * ezAssetCurator::GetDevelopmentAssetProfile ( ) const

The main platform on which development happens. E.g. "Default".

TODO: review this concept

◆ IsReferenced()

bool ezAssetCurator::IsReferenced ( ezStringView  sAbsolutePath) const

Returns whether a file is referenced, i.e. used for transforming an asset. Use this to e.g. figure out whether a .tga file is still in use by any asset.

Parameters
sAbsolutePathAbsolute path to any file inside a data directory.
Returns
True, if at least one asset references the given file.

◆ ReplaceAssetReferenceInDocument()

ezUInt32 ezAssetCurator::ReplaceAssetReferenceInDocument ( ezDocument pDocument,
ezStringView  sOldReference,
ezStringView  sNewReference,
ezDynamicArray< ezString > &  out_errors 
)

Replaces all asset references in a document, wrapped in a transaction.

Returns
The number of properties that were successfully replaced.

◆ ReplaceAssetReferenceInObject()

ezUInt32 ezAssetCurator::ReplaceAssetReferenceInObject ( ezObjectAccessorBase pAccessor,
const ezDocumentObject pObject,
ezStringView  sOldReference,
ezStringView  sNewReference,
ezDynamicArray< ezString > &  out_errors 
)

Recursively replaces asset references in all properties of a document object and its children.

Returns
The number of properties that were successfully replaced.

◆ ReplaceAssetReferenceInUses()

ezAssetCurator::ReplaceAssetResult ezAssetCurator::ReplaceAssetReferenceInUses ( ezUuid  assetToReplace,
ezStringView  sOldReference,
ezStringView  sNewReference 
)

Replaces asset references in all documents that directly use the specified asset.

Opens each referencing document, replaces all occurrences, and saves it. Documents are opened without a window. Errors are collected but do not abort the operation.

◆ SetActiveAssetProfileByIndex()

void ezAssetCurator::SetActiveAssetProfileByIndex ( ezUInt32  uiIndex,
bool  bForceReevaluation = false 
)

Switches the currently active asset target platform.

Broadcasts ezAssetCuratorEvent::Type::ActivePlatformChanged on change.

◆ TransformAllAssets()

ezStatus ezAssetCurator::TransformAllAssets ( ezBitflags< ezTransformFlags transformFlags = ezTransformFlags::TriggeredManually,
const ezPlatformProfile pAssetProfile = nullptr 
)

Transforms all assets and writes the lookup tables. If the given platform is empty, the active platform is used.

Pass ezTransformFlags::TriggeredManually to make sure that all assets get transformed, even the ones that should not be transformed by background processors (mainly scenes).

◆ TransformAssetsForSceneExport()

void ezAssetCurator::TransformAssetsForSceneExport ( const ezPlatformProfile pAssetProfile = nullptr)

Some assets are not automatically updated by the asset dependency detection (mainly Collections) because of their transitive data dependencies. So we must update them when the user does something 'significant' like doing TransformAllAssets or a scene export.


The documentation for this class was generated from the following files: