Reload of recompiled data

This commit is contained in:
Xiao Qi 2023-02-23 13:49:21 +08:00
parent a391d9373e
commit 5d3e755b9b
2 changed files with 23 additions and 11 deletions

View File

@ -41,7 +41,7 @@ namespace SHADE
std::vector<SHAssetLoader*> SHAssetManager::loaders(TYPE_COUNT); std::vector<SHAssetLoader*> SHAssetManager::loaders(TYPE_COUNT);
std::unordered_map<AssetID, SHAsset> SHAssetManager::assetCollection; std::unordered_map<AssetID, SHAsset> SHAssetManager::assetCollection;
std::unordered_map<AssetID, SHAssetData * const> SHAssetManager::assetData; std::unordered_map<AssetID, SHAssetData *> SHAssetManager::assetData;
/**************************************************************************** /****************************************************************************
@ -460,18 +460,30 @@ namespace SHADE
else else
{ {
target = GetAssetIDFromPath(path); target = GetAssetIDFromPath(path);
// send compile asset event
SHCompileAssetEvent compileShaderEvent //Reload data
auto result = GetAsset(target);
if (result.has_value())
{ {
.assetName = newPath.filename().stem().string(), auto const& asset{ result.value() };
.assetID = target, auto newData = loaders[static_cast<size_t>(asset.type)]->Load(asset.path);
.assetType = AssetType::SHADER, delete assetData[target];
}; assetData[target] = newData;
SHEventManager::BroadcastEvent<SHCompileAssetEvent>(compileShaderEvent, SH_ASSET_COMPILE_EVENT); }
else
{
SHLOG_ERROR("[Asset Manager] Critical: reload of existing compiled data failed");
}
} }
//TODO SEND EVENT HERE // send compile asset event
SHCompileAssetEvent compileShaderEvent
{
.assetName = newPath.filename().stem().string(),
.assetID = target,
.assetType = AssetType::SHADER,
};
SHEventManager::BroadcastEvent<SHCompileAssetEvent>(compileShaderEvent, SH_ASSET_COMPILE_EVENT);
} }
FolderPointer SHAssetManager::GetRootFolder() noexcept FolderPointer SHAssetManager::GetRootFolder() noexcept

View File

@ -123,7 +123,7 @@ namespace SHADE
// For all resources // For all resources
static std::unordered_map<AssetID, SHAsset> assetCollection; static std::unordered_map<AssetID, SHAsset> assetCollection;
static std::unordered_map<AssetID, SHAssetData * const> assetData; static std::unordered_map<AssetID, SHAssetData *> assetData;
}; };
} }