Merge pull request #190 from SHADE-DP/SP3-13-Assets-Manager

Assets bugfix

Fixed asset type conversion bug when loading from meta files
Removed compile all function
Set parent id to 0 for non sub assets
This commit is contained in:
XiaoQiDigipen 2022-11-11 10:07:19 +08:00 committed by GitHub
commit 6e98776165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 48 deletions

View File

@ -51,8 +51,8 @@ enum class AssetType : AssetTypeMeta
SCENE, SCENE,
PREFAB, PREFAB,
MATERIAL, MATERIAL,
SCRIPT,
MESH, MESH,
SCRIPT,
MAX_COUNT MAX_COUNT
}; };
constexpr size_t TYPE_COUNT{ static_cast<size_t>(AssetType::MAX_COUNT) }; constexpr size_t TYPE_COUNT{ static_cast<size_t>(AssetType::MAX_COUNT) };
@ -97,6 +97,7 @@ constexpr std::string_view EXTENSIONS[] = {
SCENE_EXTENSION, SCENE_EXTENSION,
PREFAB_EXTENSION, PREFAB_EXTENSION,
MATERIAL_EXTENSION, MATERIAL_EXTENSION,
"dummy",
SCRIPT_EXTENSION, SCRIPT_EXTENSION,
AUDIO_WAV_EXTENSION, AUDIO_WAV_EXTENSION,
}; };

View File

@ -405,51 +405,6 @@ namespace SHADE
return result; return result;
} }
void SHAssetManager::CompileAll() noexcept
{
std::vector<AssetPath> paths;
for (auto const& dir : std::filesystem::recursive_directory_iterator{ ASSET_ROOT })
{
if (dir.is_regular_file())
{
for (auto const& ext : EXTERNALS)
{
if (dir.path().extension().string() == ext.data())
{
paths.push_back(dir.path());
}
}
}
}
for (auto const& path : paths)
{
AssetPath newPath;
auto const ext{ path.extension().string() };
if (ext == GLSL_EXTENSION.data())
{
newPath = SHShaderSourceCompiler::LoadAndCompileShader(path).value();
}
else if (ext == DDS_EXTENSION.data())
{
newPath = SHTextureCompiler::CompileTextureAsset(path).value();
}
else if (ext == GLTF_EXTENSION.data() || ext == FBX_EXTENSION.data())
{
std::string command = MODEL_COMPILER_EXE.data();
command += " " + path.string();
std::system(command.c_str());
std::string modelPath = path.string().substr(0, path.string().find_last_of('.'));
modelPath += MODEL_EXTENSION;
newPath = modelPath;
}
GenerateNewMeta(newPath);
}
}
bool SHAssetManager::DeleteLocalFile(AssetPath path) noexcept bool SHAssetManager::DeleteLocalFile(AssetPath path) noexcept
{ {
//TODO Move this to dedicated library //TODO Move this to dedicated library

View File

@ -107,8 +107,6 @@ namespace SHADE
static SHAsset CreateAssetFromPath(AssetPath path) noexcept; static SHAsset CreateAssetFromPath(AssetPath path) noexcept;
static void CompileAll() noexcept;
static bool DeleteLocalFile(AssetPath path) noexcept; static bool DeleteLocalFile(AssetPath path) noexcept;
//TODO use this function to create asset data internall at all calls to generate id //TODO use this function to create asset data internall at all calls to generate id

View File

@ -98,6 +98,7 @@ namespace SHADE
meta.type = static_cast<AssetType>(type); meta.type = static_cast<AssetType>(type);
meta.isSubAsset = false; meta.isSubAsset = false;
meta.parent = 0;
// Burn Line // Burn Line
if (std::getline(metaFile, line)) if (std::getline(metaFile, line))