From 3ca463aa2196eda31fc8f4c05f26fcc979aacbf6 Mon Sep 17 00:00:00 2001
From: XiaoQiDigipen <72735604+XiaoQiDigipen@users.noreply.github.com>
Date: Tue, 14 Mar 2023 16:47:08 +0800
Subject: [PATCH] Added serialisation of extra time multiplier field in
 animation clip asset

Fixed bug when creating animation clip
---
 ..._RigTest01_SkinningTestAnims.shanimcontainer | Bin 24 -> 28 bytes
 .../Animation Clips/racoonAnims.shanimcontainer | Bin 231 -> 279 bytes
 .../src/Application/SBApplication.cpp           |   4 ++--
 .../Asset Types/SHAnimClipContainerAsset.h      |   2 +-
 .../Assets/Libraries/Loaders/SHBinaryLoader.cpp |   4 ++--
 SHADE_Engine/src/Assets/SHAssetManager.cpp      |   2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Assets/Animation Clips/MD_RigTest01_SkinningTestAnims.shanimcontainer b/Assets/Animation Clips/MD_RigTest01_SkinningTestAnims.shanimcontainer
index 5d6924e2be094865660e35de817f0e71ebd1574b..c14d75f4a06f920f82b7f6a5928a0208999b2462 100644
GIT binary patch
diff --git a/Assets/Animation Clips/racoonAnims.shanimcontainer b/Assets/Animation Clips/racoonAnims.shanimcontainer
index c0b335cf09d328278c77c7263f3e4d57d283dea9..2cd476937aba0f8b186c0e97c724b43c46a946c5 100644
GIT binary patch
diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp
index 3943b34d..42e112b8 100644
--- a/SHADE_Application/src/Application/SBApplication.cpp
+++ b/SHADE_Application/src/Application/SBApplication.cpp
@@ -180,8 +180,8 @@ namespace Sandbox
     // Link up SHDebugDraw
     SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
 
-    auto clip = SHResourceManager::LoadOrGet<SHRawAnimation>(77816045);
-    auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
+    //auto clip = SHResourceManager::LoadOrGet<SHRawAnimation>(77816045);
+    //auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
   }
 
   void SBApplication::Update(void)
diff --git a/SHADE_Engine/src/Assets/Asset Types/SHAnimClipContainerAsset.h b/SHADE_Engine/src/Assets/Asset Types/SHAnimClipContainerAsset.h
index 15fc449d..7a719685 100644
--- a/SHADE_Engine/src/Assets/Asset Types/SHAnimClipContainerAsset.h	
+++ b/SHADE_Engine/src/Assets/Asset Types/SHAnimClipContainerAsset.h	
@@ -25,8 +25,8 @@ namespace SHADE
     std::string name;
     uint32_t firstIndex;
     uint32_t lastIndex;
-    AssetID animRawDataAssetId; // Not serialised, only populated during runtime from parent asset
     float playbackMultiplier = 1.0f;
+    AssetID animRawDataAssetId; // Not serialised, only populated during runtime from parent asset
   };
 
   struct SH_API SHAnimClipContainerAsset final : SHAssetData
diff --git a/SHADE_Engine/src/Assets/Libraries/Loaders/SHBinaryLoader.cpp b/SHADE_Engine/src/Assets/Libraries/Loaders/SHBinaryLoader.cpp
index 119bd9aa..a8663dde 100644
--- a/SHADE_Engine/src/Assets/Libraries/Loaders/SHBinaryLoader.cpp
+++ b/SHADE_Engine/src/Assets/Libraries/Loaders/SHBinaryLoader.cpp
@@ -79,7 +79,7 @@ namespace SHADE
 
       file.write(
         reinterpret_cast<char const*>(&clip->firstIndex),
-        sizeof(uint32_t) * 2
+        sizeof(uint32_t) * 3
       );
     }
   }
@@ -118,7 +118,7 @@ namespace SHADE
 
       file.read(
         reinterpret_cast<char*>(&clip->firstIndex),
-        sizeof(uint32_t) * 2
+        sizeof(uint32_t) * 3
       );
 
       clip->animRawDataAssetId = data->animRawDataAssetId;
diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp
index 8cddaf2c..dc9d9587 100644
--- a/SHADE_Engine/src/Assets/SHAssetManager.cpp
+++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp
@@ -313,7 +313,7 @@ namespace SHADE
           .isSubAsset = true,
           .parent = parent
         };
-        auto& newClip {animContainer->clips.emplace_back()};
+        auto& newClip {animContainer->clips.emplace_back(new SHAnimClipAsset())};
         newClip->name = name;
         assetCollection.emplace(id, asset);
         assetCollection[parent].subAssets.push_back(&assetCollection[id]);
