From 013bb713258fafbe46917380763ec0beaf76b05b Mon Sep 17 00:00:00 2001 From: Xiao Qi Date: Mon, 17 Oct 2022 15:04:38 +0800 Subject: [PATCH] Functions to retrieve mesh and texture data --- SHADE_Engine/src/Assets/SHAssetManager.cpp | 20 ++++++++++++++++++++ SHADE_Engine/src/Assets/SHAssetManager.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp index e3578f92..aa9772dd 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.cpp +++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp @@ -255,6 +255,26 @@ namespace SHADE return result; } + SHMeshAsset const* SHAssetManager::GetMesh(AssetID id) noexcept + { + if (meshCollection.find(id) == meshCollection.end()) + { + return nullptr; + } + + return &meshCollection[id]; + } + + SHTextureAsset const* SHAssetManager::GetTexture(AssetID id) noexcept + { + if (textureCollection.find(id) == textureCollection.end()) + { + return nullptr; + } + + return &textureCollection[id]; + } + /**************************************************************************** * \param Path for meta data file * \param Path for asset file diff --git a/SHADE_Engine/src/Assets/SHAssetManager.h b/SHADE_Engine/src/Assets/SHAssetManager.h index 7064d63d..50549e01 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.h +++ b/SHADE_Engine/src/Assets/SHAssetManager.h @@ -75,6 +75,8 @@ namespace SHADE static std::vector GetAllMeshes() noexcept; static std::vector GetAllTextures() noexcept; + static SHMeshAsset const* GetMesh(AssetID id) noexcept; + static SHTextureAsset const* GetTexture(AssetID id) noexcept; private: /**************************************************************************** * \brief Load resource data into memory