2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 02:27:43 +00:00

Proper scratch size computation for ANIM2/3

This commit is contained in:
Jack Andersen
2016-08-28 15:18:49 -10:00
parent 127b754691
commit 7953ca4828
4 changed files with 27 additions and 5 deletions

View File

@@ -404,8 +404,30 @@ void ANIM::ANIM2::write(athena::io::IStreamWriter& writer) const
m_version == 3 ? 0x7fffff : 0x7fff,
head.rotDiv, head.translationMult, scaleMult, bsSize);
/* TODO: Figure out proper scratch size computation */
head.scratchSize = keyframeCount * channels.size() * 16;
/* Tally up buffer size */
head.scratchSize = head.binarySize(0) + keyBmp.binarySize(0) + bsSize;
if (m_version == 3)
{
for (const std::pair<atUint32, bool>& bone : bones)
{
ChannelDescPC desc;
desc.keyCount1 = keyframeCount;
if (bone.second)
desc.keyCount2 = keyframeCount;
head.scratchSize = desc.binarySize(head.scratchSize);
}
}
else
{
for (const std::pair<atUint32, bool>& bone : bones)
{
ChannelDesc desc;
desc.keyCount1 = keyframeCount;
if (bone.second)
desc.keyCount2 = keyframeCount;
head.scratchSize = desc.binarySize(head.scratchSize);
}
}
head.write(writer);
keyBmp.write(writer);