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

Added binarySize method to DNA implementations

This commit is contained in:
Jack Andersen
2015-10-17 18:08:45 -10:00
parent 6bd5c42a9e
commit 9529fad78f
21 changed files with 668 additions and 15 deletions

View File

@@ -346,6 +346,32 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
}
}
size_t ANIM::ANIM0::binarySize(size_t __isz) const
{
Header head;
atUint32 maxId = 0;
for (const std::pair<atUint32, std::tuple<bool,bool,bool>>& bone : bones)
maxId = std::max(maxId, bone.first);
__isz = head.binarySize(__isz);
__isz += maxId + 1;
__isz += bones.size() * 3 + 12;
__isz += 12;
for (const std::pair<atUint32, std::tuple<bool,bool,bool>>& bone : bones)
{
if (std::get<0>(bone.second))
__isz += head.keyCount * 16;
if (std::get<1>(bone.second))
__isz += head.keyCount * 12;
if (std::get<2>(bone.second))
__isz += head.keyCount * 12;
}
return __isz;
}
void ANIM::ANIM2::read(Athena::io::IStreamReader& reader)
{
Header head;
@@ -503,5 +529,34 @@ void ANIM::ANIM2::write(Athena::io::IStreamWriter& writer) const
writer.writeUBytes(bsData.get(), bsSize);
}
size_t ANIM::ANIM2::binarySize(size_t __isz) const
{
Header head;
WordBitmap keyBmp;
for (atUint32 frame : frames)
{
while (keyBmp.getBit(frame))
++frame;
keyBmp.setBit(frame);
}
__isz = head.binarySize(__isz);
__isz = keyBmp.binarySize(__isz);
__isz += 4;
for (const std::pair<atUint32, std::tuple<bool,bool,bool>>& bone : bones)
{
__isz += 7;
if (std::get<0>(bone.second))
__isz += 9;
if (std::get<1>(bone.second))
__isz += 9;
if (std::get<2>(bone.second))
__isz += 9;
}
return __isz + DNAANIM::ComputeBitstreamSize(frames.size(), channels);
}
}
}