diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-28 12:00:47 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-28 12:00:47 -0500 |
| commit | cf0fac0eab12421f407d3acc1f1c84faead248bc (patch) | |
| tree | c5b174085ebcd1bccaa29d20334e4123ade73f6b /src/asset-manager.cpp | |
| parent | 41b5dafb1a3bf80db48abeb235ce00ec8e1c566f (diff) | |
add asset type for filtering
Diffstat (limited to 'src/asset-manager.cpp')
| -rw-r--r-- | src/asset-manager.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/asset-manager.cpp b/src/asset-manager.cpp index b93a568..77aeffd 100644 --- a/src/asset-manager.cpp +++ b/src/asset-manager.cpp @@ -54,7 +54,7 @@ inline Asset *AM_Get_Inner(AssetKey key) { return nullptr; } -AssetHandle AM_Register(AssetKey key, const void *data, int64_t size, std::size_t alignment) { +AssetHandle AM_Register(AssetKey key, AssetType type, const void *data, int64_t size, std::size_t alignment) { assert(data != nullptr && "Attempt to register invalid asset data"); assert(data != CAFE_BABE(void) && "Attempt to register invalid asset data"); assert(size != 0 && "Attempt to register asset data of size 0"); @@ -73,10 +73,11 @@ AssetHandle AM_Register(AssetKey key, const void *data, int64_t size, std::size_ asset.ptr = Pke_New(size, alignment); memcpy(asset.ptr, data, size); asset.state = PKE_ASSET_LOADING_STATE_LOADED; + asset.type = type; return assetHandle; } -AssetHandle AM_Register(AssetKey key, const char *path) { +AssetHandle AM_Register(AssetKey key, AssetType type, const char *path) { Asset *searchedAsset = AM_Get_Inner(key); if (searchedAsset != nullptr) { return searchedAsset->handle; @@ -93,6 +94,7 @@ AssetHandle AM_Register(AssetKey key, const char *path) { strncpy(copiedPath, path, pathLen); asset.basePath = copiedPath; asset.state = PKE_ASSET_LOADING_STATE_LOADING; + asset.type = type; std::packaged_task<void()> *task = Pke_New<std::packaged_task<void()>>(); new (task) std::packaged_task<void()>( [&asset] { AM_Load_Task(asset); @@ -102,7 +104,7 @@ AssetHandle AM_Register(AssetKey key, const char *path) { return assetHandle; } -AssetHandle AM_Register(const char *path) { +AssetHandle AM_Register(const char *path, AssetType type) { NULL_CHAR_ARR(assetKey, AssetKeyLength); int64_t pathLen = strlen(path); int64_t pathOffset = (pathLen > AssetKeyLength ? pathLen - AssetKeyLength : 0); @@ -124,6 +126,7 @@ AssetHandle AM_Register(const char *path) { strncpy(copiedPath, path, pathLen); asset.basePath = copiedPath; asset.state = PKE_ASSET_LOADING_STATE_LOADING; + asset.type = type; std::packaged_task<void()> *task = Pke_New<std::packaged_task<void()>>(); new (task) std::packaged_task<void()>( [&asset] { AM_Load_Task(asset); |
