Implmented GLTF Compile and Load Overhaul #404

Merged
XiaoQiDigipen merged 17 commits from SP3-13-Assets-Manager into main 2023-03-07 23:27:01 +08:00
1 changed files with 11 additions and 6 deletions
Showing only changes of commit 9855d7e245 - Show all commits

View File

@ -20,11 +20,10 @@ namespace SHADE
/* Constructors */
/*-----------------------------------------------------------------------------------*/
SHAnimationClip::SHAnimationClip(const SHAnimAsset& asset)
: ticksPerSecond { static_cast<int>(asset.ticksPerSecond) }
, totalTime { static_cast<float>(asset.duration) / static_cast<int>(asset.ticksPerSecond) }
{
// Populate keyframes
int channelIdx = 0;
int maxFrames = 0;
totalTime = 0.0f;
for (const auto& channel : asset.nodeChannels)
{
// Create a channel
@ -49,12 +48,18 @@ namespace SHADE
newChannel.MaxFrames = std::max({ newChannel.PositionKeyFrames.size(), newChannel.RotationKeyFrames.size(), newChannel.ScaleKeyFrames.size() });
// Compute max frames
maxFrames = std::max(maxFrames, newChannel.MaxFrames);
// Compute total time
totalTime = std::max({ totalTime, newChannel.PositionKeyFrames.back().TimeStamp, newChannel.RotationKeyFrames.back().TimeStamp, newChannel.ScaleKeyFrames.back().TimeStamp });
// Insert the channel
channels.emplace_back(std::move(newChannel));
// Go to next channel
++channelIdx;
}
// Compute fps
ticksPerSecond = static_cast<int>(maxFrames / totalTime);
}
/*-----------------------------------------------------------------------------------*/