Fixed SHAnimationClip not copying name of channels correctly and added extra check for SHRig if an invalid rig is being constructed

This commit is contained in:
Kah Wei 2023-01-10 19:42:43 +08:00
parent 5c14a0829a
commit c0de2d4705
6 changed files with 17 additions and 9 deletions

View File

@ -28,7 +28,7 @@ namespace SHADE
{
// Create a channel
Channel newChannel;
newChannel.Name = channel.name;
newChannel.Name = std::string(channel.name);
newChannel.PositionKeyFrames.reserve(channel.positionKeys.size());
newChannel.RotationKeyFrames.reserve(channel.rotationKeys.size());
newChannel.ScaleKeyFrames.reserve(channel.scaleKeys.size());

View File

@ -11,9 +11,8 @@ of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// STL Includes
// Project Includes
#include "SH_API.h"
#include "Math/SHMatrix.h"
#include "Assets/Asset Types/Models/SHAnimationAsset.h"
@ -36,7 +35,7 @@ namespace SHADE
/// Represents a animation clip of a 3D animation that is made for a specific model
/// rig.
/// </summary>
class SHAnimationClip
class SH_API SHAnimationClip
{
public:
/*---------------------------------------------------------------------------------*/

View File

@ -27,7 +27,10 @@ namespace SHADE
{
// Don't bother if empty
if (asset.root == nullptr)
{
SHLOG_ERROR("[SHRig] Attempted to load an invalid rig with no root.");
return;
}
// Do a recursive depth first traversal to populate the rig
nodeCount = 0;

View File

@ -17,6 +17,7 @@ of DigiPen Institute of Technology is prohibited.
#include <unordered_map>
// Project Includes
#include "SH_API.h"
#include "Math/SHMatrix.h"
#include "Resource/SHHandle.h"
#include "Resource/SHResourceLibrary.h"
@ -32,7 +33,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
class SHRig
class SH_API SHRig
{
public:
/*---------------------------------------------------------------------------------*/

View File

@ -51,8 +51,8 @@ namespace SHADE
template<> struct SHResourceLoader<SHMaterialSpec> { using AssetType = SHMaterialAsset; };
template<> struct SHResourceLoader<SHMaterial> { using AssetType = SHMaterialSpec; };
template<> struct SHResourceLoader<SHFont> { using AssetType = SHFontAsset; };
template<> struct SHResourceLoader<SHAnimationClip> { using AssetType = SHAnimAsset; };
template<> struct SHResourceLoader<SHRig> { using AssetType = SHRigAsset; };
template<> struct SHResourceLoader<SHAnimationClip> { using AssetType = SHModelAsset; };
template<> struct SHResourceLoader<SHRig> { using AssetType = SHModelAsset; };
/// <summary>
/// Static class responsible for loading and caching runtime resources from their

View File

@ -348,10 +348,15 @@ namespace SHADE
return gfxSystem->AddFont(assetData);
}
// Animation Clip and Rig
else
else if constexpr (std::is_same_v<ResourceType, SHRig>)
{
loadedAssetData.emplace_back(assetId);
return resourceHub.Create<ResourceType>(assetData);
return resourceHub.Create<ResourceType>(assetData.rig);
}
else if constexpr (std::is_same_v<ResourceType, SHAnimationClip>)
{
loadedAssetData.emplace_back(assetId);
return resourceHub.Create<ResourceType>(*assetData.anims[0]);
}
}
}