diff --git a/SHADE_Engine/src/Assets/SHAssetMacros.h b/SHADE_Engine/src/Assets/SHAssetMacros.h index 31b96724..3b352d4e 100644 --- a/SHADE_Engine/src/Assets/SHAssetMacros.h +++ b/SHADE_Engine/src/Assets/SHAssetMacros.h @@ -45,6 +45,7 @@ enum class AssetType : AssetTypeMeta INVALID = 0, AUDIO = 1, SHADER, + SHADER_BUILT_IN, MATERIAL, IMAGE, TEXTURE, @@ -70,7 +71,8 @@ constexpr std::string_view ASSET_ROOT {"../../Assets"}; constexpr std::string_view META_EXTENSION {".shmeta"}; constexpr std::string_view AUDIO_EXTENSION {".ogg"}; constexpr std::string_view AUDIO_WAV_EXTENSION {".wav"}; -constexpr std::string_view SHADER_EXTENSION{".shshader"}; +constexpr std::string_view SHADER_EXTENSION{ ".shshader" }; +constexpr std::string_view SHADER_BUILT_IN_EXTENSION{".shshaderb"}; constexpr std::string_view SCRIPT_EXTENSION {".cs"}; constexpr std::string_view SCENE_EXTENSION {".shade"}; constexpr std::string_view PREFAB_EXTENSION {".shprefab"}; @@ -81,6 +83,7 @@ constexpr std::string_view MESH_EXTENSION {".shmesh"}; constexpr std::string_view EXTENSIONS[] = { AUDIO_EXTENSION, SHADER_EXTENSION, + SHADER_BUILT_IN_EXTENSION, MATERIAL_EXTENSION, TEXTURE_EXTENSION, MESH_EXTENSION, diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp index 28790dca..3cd4c33c 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.cpp +++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp @@ -46,7 +46,13 @@ namespace SHADE result |= unique; - while (result == 0) + while (result == 0 || + std::ranges::any_of( + assetCollection.begin(), + assetCollection.end(), + [result](SHAsset const& asset) { return asset.id == result; } + ) + ) { result = GenerateAssetID(type); } @@ -278,6 +284,7 @@ namespace SHADE { loaders[static_cast(AssetType::AUDIO)] = nullptr; loaders[static_cast(AssetType::SHADER)] = dynamic_cast(new SHShaderSourceLoader()); + loaders[static_cast(AssetType::SHADER_BUILT_IN)] = loaders[static_cast(AssetType::SHADER)]; loaders[static_cast(AssetType::MATERIAL)] = nullptr; loaders[static_cast(AssetType::TEXTURE)] = dynamic_cast(new SHTextureLoader()); loaders[static_cast(AssetType::MESH)] = dynamic_cast(new SHMeshLoader());