Merge remote-tracking branch 'origin/main' into SP3-12-SceneGraph

This commit is contained in:
Diren D Bharwani 2022-11-22 22:11:42 +08:00
commit 4277ba10d7
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 }; std::ifstream file{ path.string(), std::ios::in | std::ios::binary };
if (!file.is_open()) 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; return;
} }

View File

@ -26,7 +26,7 @@ namespace SHADE
if (!file.is_open()) 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; return nullptr;
} }
std::stringstream stream; std::stringstream stream;
@ -70,7 +70,7 @@ namespace SHADE
if (!file.is_open()) 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; return;
} }

View File

@ -22,7 +22,7 @@ namespace SHADE
std::ifstream file{ path.string(), std::ios::in | std::ios::binary }; std::ifstream file{ path.string(), std::ios::in | std::ios::binary };
if (!file.is_open()) 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) }; auto const intBytes{ sizeof(uint32_t) };
@ -61,7 +61,7 @@ namespace SHADE
std::ofstream file{ path, std::ios::out | std::ios::binary }; std::ofstream file{ path, std::ios::out | std::ios::binary };
if (!file.is_open()) 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); auto asset = *dynamic_cast<SHTextureAsset const*>(data);

View File

@ -220,7 +220,7 @@ namespace SHADE
break; break;
default: 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; return 0;
} }
@ -272,14 +272,14 @@ namespace SHADE
return true; 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()); asset.path.filename().string());
return false; 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; return false;
} }
@ -297,10 +297,10 @@ namespace SHADE
{ {
return (DeleteLocalFile(asset.path) && DeleteLocalFile(asset.path.string() + META_EXTENSION.data())); 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; return false;
} }
@ -334,7 +334,7 @@ namespace SHADE
std::filesystem::path const newPath{ GenerateLocalPath(path) }; std::filesystem::path const newPath{ GenerateLocalPath(path) };
if (newPath.empty()) 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; return 0;
} }
@ -386,7 +386,7 @@ namespace SHADE
{ {
if (!std::filesystem::exists(path)) 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; return;
} }
AssetPath newPath; AssetPath newPath;
@ -416,7 +416,7 @@ namespace SHADE
auto pathGen = SHTextureCompiler::CompileTextureAsset(path); auto pathGen = SHTextureCompiler::CompileTextureAsset(path);
if (!pathGen.has_value()) if (!pathGen.has_value())
{ {
SHLOG_ERROR("Texture Compilation Failed for: {}", path.string()); SHLOG_ERROR("[Asset Manager] Texture Compilation Failed for: {}", path.string());
return; return;
} }
newPath = pathGen.value(); newPath = pathGen.value();
@ -433,7 +433,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("File Type compilation not yet Implemented: {}", path.string()); SHLOG_WARNING("[Asset Manager] File Type compilation not yet Implemented: {}", path.string());
return; return;
} }
@ -520,7 +520,7 @@ namespace SHADE
SHAssetData* data = loaders[static_cast<size_t>(asset.type)]->Load(asset.path); SHAssetData* data = loaders[static_cast<size_t>(asset.type)]->Load(asset.path);
if (data == nullptr) 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 else
{ {
@ -537,7 +537,7 @@ namespace SHADE
if (parentData == nullptr) 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 else
{ {
@ -653,6 +653,34 @@ namespace SHADE
return newAsset.id; 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) else if (ext == FONT_EXTENSION)
{ {
SHAsset newAsset{ SHAsset newAsset{