Navigation
API > API/Plugins > API/Plugins/USDClasses
This class is an asset that can be created via the Content Browser and assigned to AUsdStageActors.
Its main purpose is to track generated assets based on the hash of the source prim data: Whenever the AUsdStageActor needs to generate e.g. a MaterialInstance, it will first hash the Material prim, and check whether its UUsdAssetCache3 already has an asset of that class for the resulting hash.
The cache can then be shared by multiple AUsdStageActors to prevent recreating UObjects from identical, already translated prim data.
A "Default Asset Cache" can be set on the project settings, and will be automatically used for any AUsdStageActor that hasn't had an asset cache manually set beforehand.
| Name | UUsdAssetCache3 |
| Type | class |
| Header File | /Engine/Plugins/Runtime/USDCore/Source/USDClasses/Public/USDAssetCache3.h |
| Include Path | #include "USDAssetCache3.h" |
Syntax
UCLASS (MinimalAPI, BlueprintType, Blueprintable,
Meta=(DisplayName="USD Asset Cache", ScriptName="UsdAssetCache"))
class UUsdAssetCache3 : public UObject
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UUsdAssetCache3
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UUsdAssetCache3() |
USDAssetCache3.h |
Structs
| Name | Remarks |
|---|---|
| FUsdScopedReferencer | The UUsdAssetCache3 can track all the UObjects that are referencing assets, so that it knows when to discard an unreferenced asset. |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AssetDirectory | FDirectoryPath | Content directory where the asset cache will place newly created assets. | USDAssetCache3.h |
|
| bCleanUpUnreferencedAssets | bool | If this is true, every time a UsdStageActor using this asset cache closes a stage or swaps asset caches it will attempt to call DeleteUnreferencedAssets, potentially dropping any unreferenced asset, due to this operation or previous ones. | USDAssetCache3.h |
|
| bOnlyHandleAssetsWithinAssetDirectory | bool | When true, it means the asset cache will only ever return assets that are currently inside of the AssetDirectory folder. | USDAssetCache3.h |
|
| HashToAssetPaths | TMap< FString, FSoftObjectPath > | This is the main internal property that maps hashes to asset paths. | USDAssetCache3.h |
|
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ActiveAssets | TSet< FSoftObjectPath > | This member is mostly used by the UsdStageImporter: Assets are added to it whenever they are cached or fetched, and reset by calling MarkAssetsAsStale(). | USDAssetCache3.h | |
| AssetPathToHashes | TMap< FSoftObjectPath, FString > | Reverse map, to speed up queries like GetHashForAsset and IsAssetTrackedByCache. Should always match HashToAssetPaths. | USDAssetCache3.h | |
| bPendingCleanup | bool | USDAssetCache3.h | ||
| CurrentScopedReferencer | const UObject * | When this is set to something, we will automatically flag it as a referencer of any cached/touched asset. | USDAssetCache3.h | |
| DeletableAssetKeys | TSet< FObjectKey > | USDAssetCache3.h | ||
| HashToReferencer | TMap< FString, TArray< FObjectKey > > | USDAssetCache3.h | ||
| ReferencerToHash | TMap< FObjectKey, TArray< FString > > | USDAssetCache3.h | ||
| RWLock | FRWLock | USDAssetCache3.h | ||
| TransientObjectStorage | TMap< FString, TObjectPtr< UObject > > | If we're a transient asset cache, our assets will be placed on the transient package and there wouldn't necessarily be anything holding a strong reference to them. | USDAssetCache3.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool AddAssetReferencer
(
const UObject* Asset, |
Adds a new UObject referencer to a particular asset, returning true if the operation succeeded. | USDAssetCache3.h |
|
void CacheAsset
(
const FString& Hash, |
Adds an existing asset to the cache attached to a particular hash, and optionally registering a referencer | USDAssetCache3.h |
|
void DeleteUnreferencedAssets
(
const bool bShowConfirmation |
Deletes all assets that: | USDAssetCache3.h |
|
| This is the same as calling DeleteUnreferencedAssets and providing true for bShowConfirmation. | USDAssetCache3.h |
|
|
TSet< FSoftObjectPath > GetActiveAssets() |
USDAssetCache3.h | ||
TMap< FString, FSoftObjectPath > GetAllTrackedAssets() |
Returns a copy of the internal mapping between hashes and asset paths | USDAssetCache3.h |
|
T * GetCachedAsset
(
const FString& Hash |
Templated version of GetCachedAsset for convenience | USDAssetCache3.h | |
UObject * GetCachedAsset
(
const FString& Hash |
Returns the asset associated with a particular Hash, if any. | USDAssetCache3.h |
|
FSoftObjectPath GetCachedAssetPath
(
const FString& Hash |
Returns the internal FSoftObjectPath associated with Hash, without trying to load the asset. | USDAssetCache3.h |
|
FString GetHashForAsset
(
const FSoftObjectPath& AssetPath |
Returns the hash associated with a particular asset, or the empty string if there isn't any. | USDAssetCache3.h |
|
int32 GetNumAssets() |
Returns the total number of cached asset paths, whether these resolve to assets or not | USDAssetCache3.h |
|
| Returns the cached UObject of the provided Class for the provided Hash if one exists. | USDAssetCache3.h |
|
|
T * GetOrCreateCachedAsset
(
const FString& Hash, |
Templated version of GetOrCreateCachedAsset for convenience | USDAssetCache3.h | |
T * GetOrCreateCustomCachedAsset
(
const FString& Hash, |
Templated version of GetOrCreateCachedAsset for convenience | USDAssetCache3.h | |
UObject * GetOrCreateCustomCachedAsset
(
const FString& Hash, |
For most asset types GetOrCreateCachedAsset should suffice: It will internally call NewObject |
USDAssetCache3.h | |
bool IsAssetDeletable
(
const UObject* Asset |
Returns whether a particular asset is currently marked as deletable or not | USDAssetCache3.h |
|
bool IsAssetTrackedByCache
(
const FSoftObjectPath& AssetPath |
Returns true if this asset is currently tracked by the asset cache's main hash to asset maps | USDAssetCache3.h |
|
TMap< FString, UObject * > LoadAndGetAllTrackedAssets () |
The same as GetAllTrackedAssets, except that it will automatically try loading all the asset paths before returning, which should be convenient for Python or Blueprint callers. | USDAssetCache3.h |
|
void MarkAssetsAsStale() |
USDAssetCache3.h | ||
void OnRegistryAssetRenamed
(
const FAssetData& NewAssetData, |
USDAssetCache3.h | ||
bool RemoveAllAssetReferencers() |
Removes all UObject referencer from all tracked assets, returning true if anything was removed. | USDAssetCache3.h |
|
bool RemoveAllReferencerAssets
(
const UObject* Referencer |
Removes a particular UObject referencer from all tracked assets, returning true if anything was removed. | USDAssetCache3.h |
|
bool RemoveAllReferencersForAsset
(
const UObject* Asset |
Removes all UObject referencers from a particular asset, returning true if anything was removed. | USDAssetCache3.h |
|
bool RemoveAssetReferencer
(
const UObject* Asset, |
Removes an UObject referencer from a particular asset, returning true if anything was removed. | USDAssetCache3.h |
|
void RequestDelayedAssetAutoCleanup() |
USDAssetCache3.h | ||
void RescanAssetDirectory () |
Checks the current AssetDirectory for any new assets that were generated from USD, and automatically caches them if possible. | USDAssetCache3.h |
|
void SetAssetDeletable
(
const UObject* Asset, |
Sets a particular asset as deletable or not. | USDAssetCache3.h |
|
| USDAssetCache3.h | |||
FSoftObjectPath StopTrackingAsset
(
const FString& Hash |
Removes all info about the asset associated with Hash from this cache, if there is any. | USDAssetCache3.h |
|
| USDAssetCache3.h | |||
void TouchAssetPath
(
const FSoftObjectPath& AssetPath, |
USDAssetCache3.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void BeginDestroy() |
USDAssetCache3.h | ||
virtual void PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
USDAssetCache3.h | ||
virtual void PostLoad() |
USDAssetCache3.h | ||
virtual void Serialize
(
FArchive& Ar |
USDAssetCache3.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| USDAssetCache3.h | |||
void ForceValidAssetDirectoryInternal
(
bool bEmitWarning |
USDAssetCache3.h | ||
bool IsTransientCache() |
USDAssetCache3.h | ||
bool RemoveAllAssetReferencersInternal
(
const FString& Hash |
USDAssetCache3.h | ||
FSoftObjectPath StopTrackingAssetInternal
(
const FString& Hash |
USDAssetCache3.h | ||
void TouchAssetInternal
(
const FSoftObjectPath& AssetPath, |
USDAssetCache3.h | ||
void TryCachingAssetFromAssetUserData
(
const FAssetData& NewAssetData |
USDAssetCache3.h |