diff --git a/.gitignore b/.gitignore index c7fefb6e..1fbf8160 100644 --- a/.gitignore +++ b/.gitignore @@ -359,3 +359,5 @@ MigrationBackup/ *.vcxproj.filters *.sln *.csproj + +*.filters diff --git a/SHADE_Engine/SHADE_Engine.vcxproj b/SHADE_Engine/SHADE_Engine.vcxproj deleted file mode 100644 index d1739037..00000000 --- a/SHADE_Engine/SHADE_Engine.vcxproj +++ /dev/null @@ -1,346 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {3F92E998-2BF5-783D-D47A-B1F3C0BC44C0} - true - Win32Proj - SHADE_Engine - 10.0 - - - - DynamicLibrary - true - Unicode - v142 - - - DynamicLibrary - false - Unicode - v142 - - - - - - - - - - - - - true - ..\bin\Debug\ - ..\bin_int\Debug\SHADE_Engine\ - SHADE_Engine - .dll - ..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\SDL\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\Dependencies\dotnet\include;..\Dependencies\tinyddsloader;$(IncludePath) - - - false - ..\bin\Release\ - ..\bin_int\Release\SHADE_Engine\ - SHADE_Engine - .dll - ..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\SDL\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\Dependencies\dotnet\include;..\Dependencies\tinyddsloader;$(IncludePath) - - - - Use - SHpch.h - Level4 - 4251;%(DisableSpecificWarnings) - _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;SH_API_EXPORT;_DEBUG;%(PreprocessorDefinitions) - src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebugDLL - true - stdcpp20 - - - Windows - true - vulkan-1.lib;SDL2.lib;SDL2main.lib;shaderc_shared.lib;shlwapi.lib;assimp-vc142-mtd.lib;librttr_core_d.lib;spdlogd.lib;%(AdditionalDependencies) - libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\SDL\lib;..\Dependencies\spdlog\lib;%(AdditionalLibraryDirectories) - ..\bin\Debug\SHADE_Engine.lib - - - xcopy /s /r /y /q "$(SolutionDir)/Dependencies/spdlog/bin" "$(OutDir)" -xcopy /r /y /q "$(SolutionDir)/Dependencies/SDL/lib/SDL2.dll" "$(OutDir)" -xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)" - - - - - Use - SHpch.h - Level4 - 4251;%(DisableSpecificWarnings) - _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;SH_API_EXPORT;_RELEASE;%(PreprocessorDefinitions) - src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreadedDLL - true - stdcpp20 - - - Windows - true - true - vulkan-1.lib;SDL2.lib;SDL2main.lib;shaderc_shared.lib;shlwapi.lib;assimp-vc142-mt.lib;librttr_core.lib;spdlog.lib;%(AdditionalDependencies) - libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\SDL\lib;..\Dependencies\spdlog\lib;%(AdditionalLibraryDirectories) - ..\bin\Release\SHADE_Engine.lib - - - xcopy /s /r /y /q "$(SolutionDir)/Dependencies/spdlog/bin" "$(OutDir)" -xcopy /r /y /q "$(SolutionDir)/Dependencies/SDL/lib/SDL2.dll" "$(OutDir)" -xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - {88F1A057-74BE-FB62-9DD7-E90A890331F1} - - - {8900D8DD-F5DF-5679-FEF7-E14F6A56BDDA} - - - {38BD587B-248B-4C81-0D1F-BDA7F98B28E6} - - - {2ECAB41A-1A98-A820-032C-1947EF988485} - - - {C0FF640D-2C14-8DBE-F595-301E616989EF} - - - - - - \ No newline at end of file diff --git a/SHADE_Engine/SHADE_Engine.vcxproj.filters b/SHADE_Engine/SHADE_Engine.vcxproj.filters deleted file mode 100644 index 46dceac0..00000000 --- a/SHADE_Engine/SHADE_Engine.vcxproj.filters +++ /dev/null @@ -1,745 +0,0 @@ - - - - - {3824E0A7-24C6-0A7E-0D81-1ED2F9C191CE} - - - {8EEA3EAC-7A8C-6982-6347-7DD64F88F0D2} - - - {1AB26817-067F-C322-2F98-B1CA1BC4F8B0} - - - {EFD23933-5B34-1741-E4A1-5DF350024E00} - - - {261D0942-92A8-7606-9BB9-F9FA07C4D206} - - - {BEBC9142-2A48-FF06-3359-82FB9F635B07} - - - {07FEB307-F3F6-D259-1C29-B8DE0881B265} - - - {37718753-A387-85E9-ECFE-100B58545671} - - - {EE037863-5A8F-E527-63A0-681CCFAA4128} - - - {078AA1A3-F318-2B6D-9C37-3F6888A53B13} - - - {DBC7D3B0-C769-FE86-B024-12DB9C6585D7} - - - {3A8963B1-262B-8E87-0FE6-A1DBFB2615D8} - - - {80E7870B-ECF0-877C-756C-9E7CE174937C} - - - {8A8E2B37-7646-6D84-DF4D-46E0CB240875} - - - {1653CE33-0220-293F-2B39-17E717655ECD} - - - {92C817CE-7EC1-3620-A7F3-1BA5934B162C} - - - {17C745C0-83DD-4356-CC54-CF7738AA14DE} - - - {51443AC7-3D28-FB1C-A688-F56F928BE59E} - - - {573A6CF2-43C9-F5BB-ECE7-09B7D8550662} - - - {08DBDC43-F4D3-FB95-1D06-E11A095EDBA1} - - - {4AD5CA42-3664-540C-DF82-6807CBF064B2} - - - {FB5EE099-67EA-4D5E-70FB-D052DC05AA5E} - - - {BA26540B-263D-52A1-6FB4-DDC2DB092329} - - - {4B204703-3704-0859-A064-02AC8C67F2DA} - - - {EBA1D3FF-D75C-C3AB-8014-3CF66CAE0D3C} - - - {8CDBA7C9-F8E8-D5AF-81CF-D19AEDDBA166} - - - {2460C057-1070-6C28-7929-D14665585BC1} - - - {FBD334F8-67EA-328E-B061-BEAF1CB70316} - - - {1DD51CAD-8960-8A71-9271-0D66FE7BE671} - - - {57DAB30C-4369-3DD6-EC87-51D1D8F54D7C} - - - {9C0DAFD9-086F-8CE7-91DC-D299FD3CC3A6} - - - {EF2D07CC-DB26-261E-0459-0BA3F0B0052A} - - - {3AEF06DD-A6D2-151D-AFD5-43591B38DC6D} - - - {245F5AB0-1085-2417-F9CA-A9E2E58F49E3} - - - {03DB39DE-EFBE-FA33-581F-F5864422E5B5} - - - {576DF841-4392-47C2-6CDD-2C52586146E0} - - - {75F29FE5-6102-4CB6-CABB-B0D4B6EA3A4F} - - - {5BAB2A92-478F-EBE7-B0EF-E53A9CF2D569} - - - {B3B14D12-9FC1-F9E2-087B-5E01F4A9E87B} - - - {AFF4887C-9B2B-8A0D-4418-7010302E060F} - - - {F1B75745-5D6D-D03A-E661-CA115216C73E} - - - {AC05897C-983C-8A0D-4129-70102D3F060F} - - - {ED6CDF9B-D939-3AA7-0253-284FEE7E6F35} - - - {B3F7140E-1F0C-3DBF-E88D-E01E546139F0} - - - {985A7358-04C5-27CF-4D03-D974B9AC0524} - - - {16CF2D0E-82E3-55BF-4B65-F91EB73852F0} - - - - - Assets - - - Assets - - - Assets - - - Assets - - - Common - - - ECS_Base\Components - - - ECS_Base\Components - - - ECS_Base\Entity - - - ECS_Base\Events - - - ECS_Base\Events - - - ECS_Base\General - - - ECS_Base\General - - - ECS_Base\General - - - ECS_Base\General - - - ECS_Base\General - - - ECS_Base\Managers - - - ECS_Base\Managers - - - ECS_Base\Managers - - - ECS_Base - - - ECS_Base\System - - - ECS_Base\System - - - ECS_Base\System - - - ECS_Base\System - - - ECS_Base\UnitTesting - - - ECS_Base\UnitTesting - - - ECS_Base\UnitTesting - - - Engine - - - Events - - - Events - - - Events - - - Events - - - FRC - - - Filesystem - - - Graphics\Buffers - - - Graphics\Commands - - - Graphics\Commands - - - Graphics\Commands - - - Graphics\Debugging - - - Graphics\Debugging - - - Graphics\Debugging - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Devices - - - Graphics\Devices - - - Graphics\Devices - - - Graphics\Framebuffer - - - Graphics\Images - - - Graphics\Images - - - Graphics\Images - - - Graphics\Images - - - Graphics\Instance - - - Graphics\MiddleEnd\Interface - - - Graphics\MiddleEnd\Interface - - - Graphics\MiddleEnd\PerFrame - - - Graphics\MiddleEnd\PerFrame - - - Graphics\MiddleEnd\Shaders - - - Graphics\MiddleEnd\Shaders - - - Graphics\MiddleEnd\Shaders - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Queues - - - Graphics\RenderGraph - - - Graphics\Renderpass - - - Graphics\Renderpass - - - Graphics\Renderpass - - - Graphics\Renderpass - - - Graphics\Renderpass - - - Graphics - - - Graphics - - - Graphics - - - Graphics\Shaders\BlockInterface - - - Graphics\Shaders - - - Graphics\Shaders - - - Graphics\Shaders\spirv-reflect - - - Graphics\Swapchain - - - Graphics\Swapchain - - - Graphics\Synchronization - - - Graphics\Synchronization - - - Graphics\VertexDescriptors - - - Graphics\Windowing - - - Graphics\Windowing - - - Graphics\Windowing\Surface - - - Math - - - Math - - - Math - - - Math - - - Math - - - Math\Vector - - - Math\Vector - - - Math\Vector - - - Meta - - - Resource - - - Resource - - - Resource - - - Resource - - - Resource - - - Resource - - - - - - Scene - - - Scene - - - Scene - - - Scripting - - - Scripting - - - Scripting - - - Tools - - - Tools - - - Tools - - - Tools - - - Tools - - - Tools - - - Tools - - - Tools - - - - - Assets - - - Assets - - - Assets - - - ECS_Base\Components - - - ECS_Base\Components - - - ECS_Base\Entity - - - ECS_Base\Managers - - - ECS_Base\Managers - - - ECS_Base\Managers - - - ECS_Base\System - - - ECS_Base\System - - - ECS_Base\UnitTesting - - - Engine - - - FRC - - - Filesystem - - - Graphics\Buffers - - - Graphics\Commands - - - Graphics\Commands - - - Graphics\Debugging - - - Graphics\Debugging - - - Graphics\Debugging - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Descriptors - - - Graphics\Devices - - - Graphics\Devices - - - Graphics\Devices - - - Graphics\Framebuffer - - - Graphics\Images - - - Graphics\Images - - - Graphics\Images - - - Graphics\Instance - - - Graphics\MiddleEnd\Interface - - - Graphics\MiddleEnd\Interface - - - Graphics\MiddleEnd\PerFrame - - - Graphics\MiddleEnd\PerFrame - - - Graphics\MiddleEnd\Shaders - - - Graphics\MiddleEnd\Shaders - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Pipeline - - - Graphics\Queues - - - Graphics\RenderGraph - - - Graphics\Renderpass - - - Graphics\Renderpass - - - Graphics\Renderpass - - - Graphics - - - Graphics - - - Graphics\Shaders\BlockInterface - - - Graphics\Shaders - - - Graphics\Shaders - - - Graphics\Shaders\spirv-reflect - - - Graphics\Swapchain - - - Graphics\Synchronization - - - Graphics\Synchronization - - - Graphics\VertexDescriptors - - - Graphics\Windowing - - - Graphics\Windowing - - - Graphics\Windowing\Surface - - - Math - - - Math - - - Math - - - Math\Vector - - - Math\Vector - - - Math\Vector - - - Resource - - - - Scene - - - Scene - - - Scripting - - - Scripting - - - Tools - - - Tools - - - Tools - - - Tools - - - Tools - - - \ No newline at end of file diff --git a/SHADE_Engine/src/Assets/Libraries/SHMeshLoader.cpp b/SHADE_Engine/src/Assets/Libraries/SHMeshLoader.cpp new file mode 100644 index 00000000..9a1a4599 --- /dev/null +++ b/SHADE_Engine/src/Assets/Libraries/SHMeshLoader.cpp @@ -0,0 +1,31 @@ +#include "SHpch.h" +#include "SHMeshLoader.h" +#include +#include + +namespace SHADE +{ + Assimp::Importer SHMeshLoader::aiImporter; + + bool SHMeshLoader::LoadMesh(AssetPath path) + { + const aiScene* scene = aiImporter.ReadFile(path.string().c_str(), + aiProcess_Triangulate + // Make sure we get triangles rather than nvert polygons + | aiProcess_GenUVCoords // Convert any type of mapping to uv mapping + | aiProcess_TransformUVCoords + // preprocess UV transformations (scaling, translation ...) + | aiProcess_FindInstances + // search for instanced meshes and remove them by references to one master + | aiProcess_CalcTangentSpace + // calculate tangents and bitangents if possible + | aiProcess_JoinIdenticalVertices + // join identical vertices/ optimize indexing + | aiProcess_RemoveRedundantMaterials // remove redundant materials + | aiProcess_FindInvalidData + // detect invalid model data, such as invalid normal vectors + | aiProcess_PreTransformVertices // pre-transform all vertices + | aiProcess_FlipUVs // flip the V to match the Vulkans way of doing UVs + ); + } +} diff --git a/SHADE_Engine/src/Assets/Libraries/SHMeshLoader.h b/SHADE_Engine/src/Assets/Libraries/SHMeshLoader.h new file mode 100644 index 00000000..32f295df --- /dev/null +++ b/SHADE_Engine/src/Assets/Libraries/SHMeshLoader.h @@ -0,0 +1,15 @@ +#pragma once +#include "../SHAssetMacros.h" +#include + +namespace SHADE +{ + class SHMeshLoader + { + private: + static Assimp::Importer aiImporter; + + public: + static bool LoadMesh(AssetPath path); + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Assets/SHAsset.h b/SHADE_Engine/src/Assets/SHAsset.h new file mode 100644 index 00000000..1f05b742 --- /dev/null +++ b/SHADE_Engine/src/Assets/SHAsset.h @@ -0,0 +1,16 @@ +#pragma once + +#include "Filesystem/SHFileSystem.h" +#include "SHAssetMacros.h" + +namespace SHADE +{ + struct SHAsset + { + AssetName name; + AssetID ID; + AssetType type; + AssetPath path; + FolderLocation location; + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp index aaaa78ab..98c019ce 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.cpp +++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp @@ -13,6 +13,7 @@ #include "SHAssetManager.h" #include "SHAssetMetaHandler.h" #include "Filesystem/SHFileSystem.h" +#include namespace SHADE { @@ -20,12 +21,7 @@ namespace SHADE std::unordered_map* SHAssetManager::audioSoundList; std::vector SHAssetManager::metaCollection; - std::unordered_map SHAssetManager::pathRegistry; - std::unordered_map SHAssetManager::typeRegistry; - std::unordered_map SHAssetManager::nameIDRegistry; - std::unordered_map SHAssetManager::idNameRegistry; - std::unordered_map SHAssetManager::filenameRegistry; - std::unordered_map SHAssetManager::filenameReverse; + std::unordered_map SHAssetManager::assetRegistry; /**************************************************************************** * \brief Static function to generate resource ID. @@ -50,25 +46,7 @@ namespace SHADE { for (auto const& meta : metaCollection) { - SHAssetMetaHandler::WriteMetaData(meta, pathRegistry[meta.GetID()].string().append(META_EXTENSION)); - } - } - - /**************************************************************************** - * \param Name of resource - - * \brief Gets resource ID - ****************************************************************************/ - AssetID SHAssetManager::GetIDFromName(AssetName const& name) noexcept - { - if (nameIDRegistry.find(name) == nameIDRegistry.end()) - { - // Error resource does not exist - return 0; - } - else - { - return nameIDRegistry[name]; + SHAssetMetaHandler::WriteMetaData(meta, pathRegistry[meta.id].string().append(META_EXTENSION)); } } @@ -92,89 +70,6 @@ namespace SHADE return std::filesystem::path(ASSET_ROOT + folder + path.filename().string()); } - std::vector SHAssetManager::GetIDFromNames(std::initializer_list const& files) noexcept - { - std::vector result; - for (auto const& file : files) - { - result.push_back(GetIDFromName(file)); - } - - return result; - } - - /**************************************************************************** - * \param file name - - * \brief Returns resource ID from provided file name - ****************************************************************************/ - AssetID SHAssetManager::GetIDFromFilename(std::string const& name) noexcept - { - if (filenameRegistry.find(name) == filenameRegistry.end()) - { - // Error resource does not exist - return 0; - } - else - { - return filenameRegistry[name]; - } - } - - /**************************************************************************** - * \brief Get filename from resource ID. - * - * \param id - id of asset - * \return std::string - ****************************************************************************/ - std::string SHAssetManager::GetFilenameFromID(AssetID id) noexcept - { - if (filenameReverse.find(id) == filenameReverse.end()) - { - // Error resource does not exist - return FILE_NOT_FOUND_ERR; - } - else - { - return filenameReverse[id]; - } - } - - /**************************************************************************** - * \brief Get asset name from resource ID. - * - * \param id - resource id - * \return - std::string - ****************************************************************************/ - AssetName SHAssetManager::GetNameFromID(AssetID id) noexcept - { - if (idNameRegistry.find(id) == idNameRegistry.end()) - { - // Error - return "INVALID"; - } - else - { - return idNameRegistry[id]; - } - } - - /**************************************************************************** - * \param list of file names - - * \brief Returns vector of resource IDs - ****************************************************************************/ - std::vector SHAssetManager::GetIDFromFilenames(std::initializer_list const& files) noexcept - { - std::vector result; - for (auto const& file : files) - { - result.push_back(GetIDFromFilename(file)); - } - - return result; - } - /**************************************************************************** * \brief Get record of all resources currently loaded with name and id. * @@ -185,28 +80,6 @@ namespace SHADE return nameIDRegistry; } - /**************************************************************************** - * \brief Get type of asset from ID - * - * \param resource id of file - * \return AssetType enum class value - ****************************************************************************/ - AssetType SHAssetManager::GetTypeFromID(AssetID id) noexcept - { - return typeRegistry[id]; - } - - /**************************************************************************** - * \brief Get registered path of asset. - * - * \param resource id of file - * \return std::filesystem::path - ****************************************************************************/ - AssetPath SHAssetManager::GetPathFromID(AssetID id) noexcept - { - return pathRegistry[id]; - } - /**************************************************************************** * \brief Create record for new resource. CAN ONLY CREATE FOR CUSTOM * ASSETS CREATED BY THE ENGINE. @@ -219,9 +92,8 @@ namespace SHADE { AssetID id{ GenerateAssetID() }; SHAssetMeta meta; - meta.SetID(id); - meta.SetType(type); - meta.SetVersion(ASSET_META_VER); + meta.id = id; + meta.type = type; std::string folder; switch (type) @@ -340,12 +212,12 @@ namespace SHADE SHAssetMeta meta = SHAssetMetaHandler::RetrieveMetaData(metaPath); metaCollection.push_back(meta); - pathRegistry.emplace(meta.GetID(), path); - typeRegistry.emplace(meta.GetID(), meta.GetType()); - nameIDRegistry.emplace(GetNameFromPath(path), meta.GetID()); - idNameRegistry.emplace(meta.GetID(), GetNameFromPath(path)); - filenameRegistry.emplace(path.filename().string(), meta.GetID()); - filenameReverse.emplace(meta.GetID(), path.filename().string()); + pathRegistry.emplace(meta.id, path); + typeRegistry.emplace(meta.id, meta.type); + nameIDRegistry.emplace(GetNameFromPath(path), meta.id); + idNameRegistry.emplace(meta.id, GetNameFromPath(path)); + filenameRegistry.emplace(path.filename().string(), meta.id); + filenameReverse.emplace(meta.id, path.filename().string()); } /**************************************************************************** @@ -356,24 +228,36 @@ namespace SHADE SHAssetMeta SHAssetManager::RegisterAssetNew(AssetPath const& resource) noexcept { SHAssetMeta meta; - meta.SetID(GenerateAssetID()); - meta.SetType(SHAssetMetaHandler::GetTypeFromExtension(resource.extension().string())); - meta.SetVersion(ASSET_META_VER); + meta.id = GenerateAssetID(); + meta.type = SHAssetMetaHandler::GetTypeFromExtension(resource.extension().string()); metaCollection.push_back(meta); - pathRegistry.emplace(meta.GetID(), resource); - typeRegistry.emplace(meta.GetID(), meta.GetType()); - nameIDRegistry.emplace(GetNameFromPath(resource), meta.GetID()); - idNameRegistry.emplace(meta.GetID(), GetNameFromPath(resource)); - filenameRegistry.emplace(resource.filename().string(), meta.GetID()); - filenameReverse.emplace(meta.GetID(), resource.filename().string()); + pathRegistry.emplace(meta.id, resource); + typeRegistry.emplace(meta.id, meta.type); + nameIDRegistry.emplace(GetNameFromPath(resource), meta.id); + idNameRegistry.emplace(meta.id, GetNameFromPath(resource)); + filenameRegistry.emplace(resource.filename().string(), meta.id); + filenameReverse.emplace(meta.id, resource.filename().string()); - //LoadData(meta.GetID()); + //LoadData(meta.id); SHAssetMetaHandler::WriteMetaData(meta, resource.string() + META_EXTENSION); return metaCollection.back(); } + bool SHAssetManager::IsRecognised(char const* ext) noexcept + { + for (auto const& e : EXTENSIONS) + { + if (strcmp(ext, e.c_str()) == 0) + { + return true; + } + } + + return false; + } + /**************************************************************************** * \brief Load all resources that are in the folder ****************************************************************************/ @@ -448,7 +332,7 @@ namespace SHADE { SHAssetMeta const& meta{ RegisterAssetNew(p) }; SHAssetMetaHandler::WriteMetaData(meta, p.string() + META_EXTENSION); - return meta.GetID(); + return meta.id; } else { diff --git a/SHADE_Engine/src/Assets/SHAssetManager.h b/SHADE_Engine/src/Assets/SHAssetManager.h index 8db008c9..5b57c91c 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.h +++ b/SHADE_Engine/src/Assets/SHAssetManager.h @@ -16,6 +16,7 @@ #include #include "SHAssetMeta.h" #include "tinyddsloader.h" +#include "SHAsset.h" #include @@ -43,51 +44,6 @@ namespace SHADE ****************************************************************************/ static void Load() noexcept; - // General------------------------------------------------------------------/ - /**************************************************************************** - * \param Name of resource - - * \brief Gets resource ID - ****************************************************************************/ - static AssetID GetIDFromName(AssetName const&) noexcept; - - /**************************************************************************** - * \param Name of resource - - * \brief Gets resource ID - ****************************************************************************/ - static std::vector GetIDFromNames(std::initializer_list const&) noexcept; - - /**************************************************************************** - * \brief Get asset name from resource ID. - * - * \param id - resource id - * \return - std::string - ****************************************************************************/ - static AssetName GetNameFromID(AssetID) noexcept; - - /**************************************************************************** - * \param file name - - * \brief Returns resource ID from provided file name - ****************************************************************************/ - static AssetID GetIDFromFilename(std::string const&) noexcept; - - /**************************************************************************** - * \brief Get filename from resource ID. - * - * \param id - id of asset - * \return std::string - ****************************************************************************/ - static std::string GetFilenameFromID(AssetID id) noexcept; - - /**************************************************************************** - * \param list of file names - - * \brief Returns vector of resource IDs - ****************************************************************************/ - static std::vector GetIDFromFilenames(std::initializer_list const&) noexcept; - /**************************************************************************** * \brief Get record of all resources currently loaded with name and id. * @@ -182,12 +138,7 @@ namespace SHADE // For all resources static std::vector metaCollection; - static std::unordered_map pathRegistry; - static std::unordered_map typeRegistry; - static std::unordered_map idNameRegistry; - static std::unordered_map nameIDRegistry; - static std::unordered_map filenameRegistry; - static std::unordered_map filenameReverse; + static std::unordered_map assetRegistry; }; } diff --git a/SHADE_Engine/src/Assets/SHAssetMeta.cpp b/SHADE_Engine/src/Assets/SHAssetMeta.cpp deleted file mode 100644 index 60fc45d0..00000000 --- a/SHADE_Engine/src/Assets/SHAssetMeta.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * \file SHAssetMeta.cpp - * \author Loh Xiao Qi - * \brief Implementation for SHAssetMeta.h - * - * \copyright Copyright (c) 2021 Digipen Institute of Technology. Reproduction - * or disclosure of this file or its contents without the prior - * written consent of Digipen Institute of Technology is prohibited - ******************************************************************************/ -#include "SHpch.h" -#include "SHAssetMeta.h" - -namespace SHADE -{ - /**************************************************************************** - * \brief Default constructor - ****************************************************************************/ - SHAssetMeta::SHAssetMeta() noexcept : id{ 0 }, type{AssetType::INVALID} - { - - } - - /**************************************************************************** - * \param copy - - * \brief copy constructor - ****************************************************************************/ - SHAssetMeta::SHAssetMeta(SHAssetMeta const& ref) noexcept - { - ver = ref.ver; - id = ref.id; - type = ref.type; - } - - /**************************************************************************** - * \param reference - - * \brief copy assignment operator overload - ****************************************************************************/ - SHAssetMeta& SHAssetMeta::operator=(SHAssetMeta const& ref) noexcept - { - ver = ref.ver; - id = ref.id; - type = ref.type; - - return *this; - } - - /**************************************************************************** - * \param std::string representation for meta resource file version - - * \brief Set meta version for data file - ****************************************************************************/ - void SHAssetMeta::SetVersion(AssetMetaVersion vers) noexcept - { - ver = vers; - } - - /**************************************************************************** - * \param ID of resource - - * \brief Set ID - ****************************************************************************/ - void SHAssetMeta::SetID(AssetID idin) noexcept - { - this->id = idin; - } - - /**************************************************************************** - * \param Enum class value - - * \brief Set Asset Type - ****************************************************************************/ - void SHAssetMeta::SetType(AssetType rType) noexcept - { - this->type = rType; - } - - /**************************************************************************** - * \brief Get version - ****************************************************************************/ - AssetMetaVersion SHAssetMeta::GetVersion() const noexcept - { - return ver; - } - - /**************************************************************************** - * \brief Get ID - ****************************************************************************/ - AssetID SHAssetMeta::GetID() const noexcept - { - return id; - } - - /**************************************************************************** - * \brief Get resource type - ****************************************************************************/ - AssetType SHAssetMeta::GetType() const noexcept - { - return type; - } -} diff --git a/SHADE_Engine/src/Assets/SHAssetMeta.h b/SHADE_Engine/src/Assets/SHAssetMeta.h index 9f2e6b5c..c591e0dd 100644 --- a/SHADE_Engine/src/Assets/SHAssetMeta.h +++ b/SHADE_Engine/src/Assets/SHAssetMeta.h @@ -14,66 +14,8 @@ namespace SHADE { - class SHAssetMeta + struct SHAssetMeta { - public: - /**************************************************************************** - * \brief Default constructor - ****************************************************************************/ - SHAssetMeta() noexcept; - - /**************************************************************************** - * \param copy - - * \brief copy constructor - ****************************************************************************/ - SHAssetMeta(SHAssetMeta const&) noexcept; - - /**************************************************************************** - * \param reference - - * \brief copy assignment operator overload - ****************************************************************************/ - SHAssetMeta& operator=(SHAssetMeta const&) noexcept; - - /**************************************************************************** - * \param std::string representation for meta resource file version - - * \brief Set meta version for data file - ****************************************************************************/ - void SetVersion(AssetMetaVersion) noexcept; - - /**************************************************************************** - * \param ID of resource - - * \brief Set ID - ****************************************************************************/ - void SetID(AssetID) noexcept; - - /**************************************************************************** - * \param Enum class value - - * \brief Set Asset Type - ****************************************************************************/ - void SetType(AssetType) noexcept; - - /**************************************************************************** - * \brief Get version - ****************************************************************************/ - AssetMetaVersion GetVersion() const noexcept; - - /**************************************************************************** - * \brief Get ID - ****************************************************************************/ - AssetID GetID() const noexcept; - - /**************************************************************************** - * \brief Get resouce type - ****************************************************************************/ - AssetType GetType() const noexcept; - - private: - AssetMetaVersion ver; AssetID id; AssetType type; }; diff --git a/SHADE_Engine/src/Assets/SHAssetMetaHandler.cpp b/SHADE_Engine/src/Assets/SHAssetMetaHandler.cpp index d18869a9..ae5eab2a 100644 --- a/SHADE_Engine/src/Assets/SHAssetMetaHandler.cpp +++ b/SHADE_Engine/src/Assets/SHAssetMetaHandler.cpp @@ -70,23 +70,19 @@ namespace SHADE std::string line; SHAssetMeta meta; - // Get file version - GetFieldValue(metaFile, line); - meta.SetVersion(line); - // Get resource id GetFieldValue(metaFile, line); std::stringstream idStream{ line }; AssetID id; idStream >> id; - meta.SetID(id); + meta.id = id; // Get resource type GetFieldValue(metaFile, line); std::stringstream typeStream{ line }; AssetTypeMeta type; typeStream >> type; - meta.SetType(static_cast(type)); + meta.type = static_cast(type); metaFile.close(); @@ -107,10 +103,9 @@ namespace SHADE { // Log error } - - metaFile << "Meta Version: " << meta.GetVersion() << "\n"; - metaFile << "ID: " << meta.GetID() << "\n"; - metaFile << "Type: " << static_cast(meta.GetType()) << std::endl; + + metaFile << "ID: " << meta.id << "\n"; + metaFile << "Type: " << static_cast(meta.type) << std::endl; metaFile.close(); }