Fixed major bug when generating new meta files for materials #254

Merged
XiaoQiDigipen merged 5 commits from SP3-13-Assets-Manager into main 2022-11-22 21:55:22 +08:00
4 changed files with 44 additions and 16 deletions

View File

@ -52,7 +52,7 @@ namespace SHADE
std::ifstream file{ path.string(), std::ios::in | std::ios::binary };
if (!file.is_open())
{
SHLOG_ERROR("Unable to open SHMesh File: {}", path.string());
SHLOG_ERROR("[Model Loader] Unable to open SHModel File: {}", path.string());
return;
}

View File

@ -26,7 +26,7 @@ namespace SHADE
if (!file.is_open())
{
SHLOG_ERROR("Unable to open text File: {}", path.string());
SHLOG_ERROR("[Text Loader] Unable to open text File: {}", path.string());
return nullptr;
}
std::stringstream stream;
@ -70,7 +70,7 @@ namespace SHADE
if (!file.is_open())
{
SHLOG_ERROR("Unable to open text File: {}", path.string());
SHLOG_ERROR("[Text Loader] Unable to open text File: {}", path.string());
return;
}

View File

@ -22,7 +22,7 @@ namespace SHADE
std::ifstream file{ path.string(), std::ios::in | std::ios::binary };
if (!file.is_open())
{
SHLOG_ERROR("Error opening SHTexture file: {}", path.string());
SHLOG_ERROR("[Texture Loader] Error opening SHTexture file: {}", path.string());
}
auto const intBytes{ sizeof(uint32_t) };
@ -61,7 +61,7 @@ namespace SHADE
std::ofstream file{ path, std::ios::out | std::ios::binary };
if (!file.is_open())
{
SHLOG_ERROR("Unable to open file for writing texture file: {}", path.string());
SHLOG_ERROR("[Texture Loader] Unable to open file for writing texture file: {}", path.string());
}
auto asset = *dynamic_cast<SHTextureAsset const*>(data);

View File

@ -220,7 +220,7 @@ namespace SHADE
break;
default:
SHLOG_ERROR("Asset type of {} not an internal asset type, cannot be created", name);
SHLOG_ERROR("[Asset Manager] Asset type of {} not an internal asset type, cannot be created", name);
return 0;
}
@ -272,14 +272,14 @@ namespace SHADE
return true;
}
SHLOG_ERROR("Asset data has not been written into, cannot be saved: {}",
SHLOG_ERROR("[Asset Manager] Asset data has not been written into, cannot be saved: {}",
asset.path.filename().string());
return false;
}
}
SHLOG_WARNING("Asset id: {} not an internal asset type, save cannot be triggered", id);
SHLOG_WARNING("[Asset Manager] Asset id: {} not an internal asset type, save cannot be triggered", id);
return false;
}
@ -297,10 +297,10 @@ namespace SHADE
{
return (DeleteLocalFile(asset.path) && DeleteLocalFile(asset.path.string() + META_EXTENSION.data()));
}
SHLOG_WARNING("Asset id: {} not an internal asset type, file deletion not allowed", id);
SHLOG_WARNING("[Asset Manager] Asset id: {} not an internal asset type, file deletion not allowed", id);
}
SHLOG_WARNING("Asset id does not exist, nothing was deleted: {}", id);
SHLOG_WARNING("[Asset Manager] Asset id does not exist, nothing was deleted: {}", id);
return false;
}
@ -334,7 +334,7 @@ namespace SHADE
std::filesystem::path const newPath{ GenerateLocalPath(path) };
if (newPath.empty())
{
SHLOG_WARNING("Unsupported file format for asset: {}", path.string());
SHLOG_WARNING("[Asset Manager] Unsupported file format for asset: {}", path.string());
return 0;
}
@ -386,7 +386,7 @@ namespace SHADE
{
if (!std::filesystem::exists(path))
{
SHLOG_ERROR("Path provided does not point to a file: {}", path.string());
SHLOG_ERROR("[Asset Manager] Path provided does not point to a file: {}", path.string());
return;
}
AssetPath newPath;
@ -416,7 +416,7 @@ namespace SHADE
auto pathGen = SHTextureCompiler::CompileTextureAsset(path);
if (!pathGen.has_value())
{
SHLOG_ERROR("Texture Compilation Failed for: {}", path.string());
SHLOG_ERROR("[Asset Manager] Texture Compilation Failed for: {}", path.string());
return;
}
newPath = pathGen.value();
@ -433,7 +433,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("File Type compilation not yet Implemented: {}", path.string());
SHLOG_WARNING("[Asset Manager] File Type compilation not yet Implemented: {}", path.string());
return;
}
@ -520,7 +520,7 @@ namespace SHADE
SHAssetData* data = loaders[static_cast<size_t>(asset.type)]->Load(asset.path);
if (data == nullptr)
{
SHLOG_ERROR("Unable to load asset into memory: {}\n", asset.path.string());
SHLOG_ERROR("[Asset Manager] Unable to load asset into memory: {}\n", asset.path.string());
}
else
{
@ -537,7 +537,7 @@ namespace SHADE
if (parentData == nullptr)
{
SHLOG_ERROR("Unable to load asset into memory: {}\n", parent.path.string());
SHLOG_ERROR("[Asset Manager] Unable to load asset into memory: {}\n", parent.path.string());
}
else
{
@ -653,6 +653,34 @@ namespace SHADE
return newAsset.id;
}
else if(ext == MATERIAL_EXTENSION)
{
SHAsset newAsset{
path.stem().string(),
GenerateAssetID(AssetType::MATERIAL),
AssetType::MATERIAL,
path,
false
};
assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
else if (ext == PREFAB_EXTENSION)
{
SHAsset newAsset{
path.stem().string(),
GenerateAssetID(AssetType::PREFAB),
AssetType::PREFAB,
path,
false
};
assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
else if (ext == FONT_EXTENSION)
{
SHAsset newAsset{