Skip to content

Commit

Permalink
Updated animation serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkTreasure1 committed Mar 28, 2024
1 parent 53ff966 commit 1d05f0a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Volt/Volt/src/Volt/Asset/Animation/Animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ namespace Volt
{
uint32_t frame;
std::string name;

static void Serialize(BinaryStreamWriter& streamWriter, const Event& data)
{
streamWriter.Write(data.frame);
streamWriter.Write(data.name);
}

static void Deserialize(BinaryStreamReader& streamReader, Event& outData)
{
streamReader.Read(outData.frame);
streamReader.Read(outData.name);
}
};

const std::vector<glm::mat4> Sample(float aStartTime, Ref<Skeleton> aSkeleton, bool looping);
Expand Down
5 changes: 5 additions & 0 deletions Volt/Volt/src/Volt/Asset/ImportersNew/AnimationSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ namespace Volt
float duration;
uint32_t framesPerSecond;
std::vector<Animation::Pose> frames;
std::vector<Animation::Event> events;

static void Serialize(BinaryStreamWriter& streamWriter, const AnimationSerializationData& data)
{
streamWriter.Write(data.duration);
streamWriter.Write(data.framesPerSecond);
streamWriter.Write(data.frames);
streamWriter.Write(data.events);
}

static void Deserialize(BinaryStreamReader& streamReader, AnimationSerializationData& outData)
{
streamReader.Read(outData.duration);
streamReader.Read(outData.framesPerSecond);
streamReader.Read(outData.frames);
streamReader.Read(outData.events);
}
};

Expand All @@ -37,6 +40,7 @@ namespace Volt
serializationData.duration = animation->m_duration;
serializationData.framesPerSecond = animation->m_framesPerSecond;
serializationData.frames = animation->m_frames;
serializationData.events = animation->m_events;

const size_t compressedDataOffset = AssetSerializer::WriteMetadata(metadata, asset->GetVersion(), streamWriter);
streamWriter.Write(serializationData);
Expand Down Expand Up @@ -76,6 +80,7 @@ namespace Volt
animation->m_duration = serializationData.duration;
animation->m_framesPerSecond = serializationData.framesPerSecond;
animation->m_frames = serializationData.frames;
animation->m_events = serializationData.events;

return true;
}
Expand Down

0 comments on commit 1d05f0a

Please sign in to comment.