Implemented Animation Clip asset and animation controller #410

Merged
XiaoQiDigipen merged 66 commits from SP3-22-AnimationController into main 2023-03-09 16:19:40 +08:00
5 changed files with 23 additions and 12 deletions
Showing only changes of commit 2692db1ed3 - Show all commits

View File

@ -164,14 +164,24 @@ namespace SHADE
return AssetType::INVALID;
}
std::optional<SHADE::SHAsset> SHAssetManager::GetAsset(AssetID id) noexcept
SHAsset* SHAssetManager::GetAsset(AssetID id) noexcept
{
if (assetCollection.contains(id))
{
return assetCollection[id];
return &assetCollection[id];
}
return {};
return nullptr;
}
SHAsset const* SHAssetManager::GetAssetConst(AssetID id) noexcept
{
if (assetCollection.contains(id))
{
return &assetCollection[id];
}
return nullptr;
}
AssetID SHAssetManager::GetAssetIDFromPath(AssetPath const& path) noexcept

View File

@ -50,7 +50,8 @@ namespace SHADE
* \return const& to unordered_map<AssetName, AssetID>
****************************************************************************/
static std::vector<SHAsset> GetAllAssets() noexcept;
static std::optional<SHAsset> GetAsset(AssetID id) noexcept;
static SHAsset* GetAsset(AssetID id) noexcept;
static SHAsset const* GetAssetConst(AssetID id) noexcept;
static AssetType GetType(AssetID id) noexcept;

View File

@ -378,9 +378,9 @@ namespace SHADE
// Attempt to get the asset's data for rendering editor
auto asset = SHAssetManager::GetAsset(value);
std::string assetName;
if (asset.has_value())
if (asset)
{
assetName = asset.value().name;
assetName = asset->name;
}
// Editor
@ -391,9 +391,9 @@ namespace SHADE
{
// Check if type matches
auto draggedAsset = SHAssetManager::GetAsset(*payload);
if (draggedAsset.has_value() && draggedAsset.value().type == type)
if (draggedAsset && draggedAsset->type == type)
{
value = draggedAsset.value().id;
value = draggedAsset->id;
changed = true;
}
SHDragDrop::EndTarget();

View File

@ -127,8 +127,8 @@ namespace SHADE
if (assetId.has_value())
{
const auto ASSET_INFO = SHAssetManager::GetAsset(assetId.value());
if (ASSET_INFO.has_value())
return ASSET_INFO.value().name;
if (ASSET_INFO)
return ASSET_INFO->name;
}
return {};
}

View File

@ -162,8 +162,8 @@ namespace SHADE
if (assetId.has_value())
{
const auto ASSET_INFO = SHAssetManager::GetAsset(assetId.value());
if (ASSET_INFO.has_value())
return ASSET_INFO.value().name;
if (ASSET_INFO)
return ASSET_INFO->name;
}
return {};
}