mirror of https://github.com/AxioDL/metaforce.git
Added binarySize method to DNA implementations
This commit is contained in:
parent
6bd5c42a9e
commit
9529fad78f
|
@ -38,6 +38,8 @@ public:
|
|||
{std::string rs = reader.readString(nullptr); strncpy(fcc, rs.c_str(), 4);}
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
{writer.writeString(nullptr, std::string(fcc, 4));}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{return __isz + 4;}
|
||||
};
|
||||
|
||||
using FourCC = HECL::FourCC;
|
||||
|
@ -57,6 +59,8 @@ public:
|
|||
{m_id = reader.readUint32(nullptr);}
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
{writer.writeUint32(nullptr, m_id);}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{return __isz + 4;}
|
||||
|
||||
bool operator!=(const UniqueID32& other) const {return m_id != other.m_id;}
|
||||
bool operator==(const UniqueID32& other) const {return m_id == other.m_id;}
|
||||
|
@ -84,6 +88,8 @@ public:
|
|||
{m_id = reader.readUint64(nullptr);}
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
{writer.writeUint64(nullptr, m_id);}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{return __isz + 8;}
|
||||
|
||||
bool operator!=(const UniqueID64& other) const {return m_id != other.m_id;}
|
||||
bool operator==(const UniqueID64& other) const {return m_id == other.m_id;}
|
||||
|
@ -135,6 +141,8 @@ public:
|
|||
{
|
||||
writer.writeString(nullptr, toString().c_str());
|
||||
}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{return __isz + 16;}
|
||||
|
||||
bool operator!=(const UniqueID128& other) const
|
||||
{
|
||||
|
@ -210,6 +218,10 @@ public:
|
|||
for (atUint32 word : m_words)
|
||||
writer.writeUint32(word);
|
||||
}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
return __isz + m_words.size() * 4;
|
||||
}
|
||||
size_t getBitCount() const {return m_bitCount;}
|
||||
bool getBit(size_t idx) const
|
||||
{
|
||||
|
|
|
@ -59,6 +59,24 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(
|
|||
}
|
||||
}
|
||||
|
||||
size_t ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 12;
|
||||
switch (DataType(parmType))
|
||||
{
|
||||
case DataType::DTInt32:
|
||||
case DataType::DTUInt32:
|
||||
case DataType::DTEnum:
|
||||
case DataType::DTFloat:
|
||||
__isz += 8;
|
||||
break;
|
||||
case DataType::DTBool:
|
||||
__isz += 2;
|
||||
break;
|
||||
}
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
parmType = reader.readUint32("parmType");
|
||||
|
@ -200,6 +218,32 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(Athena::io
|
|||
}
|
||||
}
|
||||
|
||||
size_t ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 12;
|
||||
__isz = __EnumerateSize(__isz, parmInfos);
|
||||
|
||||
__isz += animInfos.size() * 4;
|
||||
for (const ParmInfo& pi : parmInfos)
|
||||
{
|
||||
switch (ParmInfo::DataType(pi.parmType))
|
||||
{
|
||||
case ParmInfo::DTInt32:
|
||||
case ParmInfo::DTUInt32:
|
||||
case ParmInfo::DTEnum:
|
||||
case ParmInfo::DTFloat:
|
||||
__isz += animInfos.size() * 4;
|
||||
break;
|
||||
case ParmInfo::DTBool:
|
||||
__isz += animInfos.size();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
id = reader.readUint32("id");
|
||||
|
@ -416,6 +460,70 @@ void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer)
|
|||
}
|
||||
}
|
||||
|
||||
size_t ANCS::CharacterSet::CharacterInfo::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 6;
|
||||
|
||||
atUint16 sectionCount;
|
||||
if (partResData.elsc.size())
|
||||
sectionCount = 6;
|
||||
else if (animIdxs.size())
|
||||
sectionCount = 5;
|
||||
else if (cmdlOverlay)
|
||||
sectionCount = 4;
|
||||
else if (effects.size())
|
||||
sectionCount = 3;
|
||||
else if (animAABBs.size())
|
||||
sectionCount = 2;
|
||||
else
|
||||
sectionCount = 1;
|
||||
|
||||
__isz += name.size() + 1;
|
||||
__isz += 12;
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, animations);
|
||||
|
||||
__isz = pasDatabase.binarySize(__isz);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.part);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.swhc);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.unk);
|
||||
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.elsc);
|
||||
}
|
||||
|
||||
__isz += 4;
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, animAABBs);
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, effects);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
__isz += 8;
|
||||
|
||||
if (sectionCount > 4)
|
||||
__isz += 4 + animIdxs.size() * 4;
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
idx = reader.readUint32("idx");
|
||||
|
@ -591,6 +699,13 @@ void ANCS::AnimationSet::MetaAnimFactory::write(Athena::io::IStreamWriter& write
|
|||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
size_t ANCS::AnimationSet::MetaAnimFactory::binarySize(size_t __isz) const
|
||||
{
|
||||
if (!m_anim)
|
||||
return __isz;
|
||||
return m_anim->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
std::string type = reader.readString("type");
|
||||
|
@ -675,6 +790,13 @@ void ANCS::AnimationSet::MetaTransFactory::write(Athena::io::IStreamWriter& writ
|
|||
m_trans->write(writer);
|
||||
}
|
||||
|
||||
size_t ANCS::AnimationSet::MetaTransFactory::binarySize(size_t __isz) const
|
||||
{
|
||||
if (!m_trans)
|
||||
return __isz + 4;
|
||||
return m_trans->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::MetaTransFactory::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
std::string type = reader.readString("type");
|
||||
|
@ -794,6 +916,47 @@ void ANCS::AnimationSet::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t ANCS::AnimationSet::binarySize(size_t __isz) const
|
||||
{
|
||||
atUint16 sectionCount;
|
||||
if (animResources.size())
|
||||
sectionCount = 4;
|
||||
else if (halfTransitions.size())
|
||||
sectionCount = 3;
|
||||
else if (additiveAnims.size())
|
||||
sectionCount = 2;
|
||||
else
|
||||
sectionCount = 1;
|
||||
|
||||
__isz += 6;
|
||||
__isz = __EnumerateSize(__isz, animations);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, transitions);
|
||||
__isz = defaultTransition.binarySize(__isz);
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, additiveAnims);
|
||||
__isz += 8;
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, halfTransitions);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, animResources);
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
atUint16 sectionCount = reader.readUint16("sectionCount");
|
||||
|
|
|
@ -216,6 +216,29 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
|
|||
evnt.write(writer);
|
||||
}
|
||||
|
||||
size_t ANIM::ANIM0::binarySize(size_t __isz) const
|
||||
{
|
||||
Header head;
|
||||
|
||||
atUint32 maxId = 0;
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
maxId = std::max(maxId, bone.first);
|
||||
|
||||
__isz = head.binarySize(__isz);
|
||||
__isz += maxId + 1;
|
||||
__isz += bones.size() + 4;
|
||||
|
||||
__isz += 8;
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
{
|
||||
__isz += head.keyCount * 16;
|
||||
if (bone.second)
|
||||
__isz += head.keyCount * 12;
|
||||
}
|
||||
|
||||
return __isz + 4;
|
||||
}
|
||||
|
||||
void ANIM::ANIM2::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
Header head;
|
||||
|
@ -347,5 +370,30 @@ 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 += 8;
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
{
|
||||
__isz += 17;
|
||||
if (bone.second)
|
||||
__isz += 9;
|
||||
}
|
||||
|
||||
return __isz + DNAANIM::ComputeBitstreamSize(frames.size(), channels);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,13 @@ struct ANIM : BigDNA
|
|||
writer.writeUByte(qTZ);
|
||||
}
|
||||
}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 17;
|
||||
if (keyCount2)
|
||||
__isz += 9;
|
||||
return __isz;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -161,6 +168,11 @@ struct ANIM : BigDNA
|
|||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
return m_anim->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, const CINF& cinf, bool) const
|
||||
{
|
||||
m_anim->sendANIMToBlender(os, cinf);
|
||||
|
|
|
@ -1083,7 +1083,7 @@ MaterialSet::Material::Material(const HECL::Backend::GX& gx,
|
|||
found = true;
|
||||
++uvAnimsCount;
|
||||
uvAnims.emplace_back(tcg);
|
||||
uvAnimsSize += uvAnims.back().binarySize();
|
||||
uvAnimsSize = uvAnims.back().binarySize(uvAnimsSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1101,12 +1101,12 @@ MaterialSet::Material::UVAnimation::UVAnimation(const HECL::Backend::GX::TexCoor
|
|||
else if (!tcg.m_gameFunction.compare("RetroUVMode2Node"))
|
||||
{
|
||||
mode = ANIM_SCROLL;
|
||||
if (tcg.m_gameArgs.size() < 4)
|
||||
Log.report(LogVisor::FatalError, "Mode2 UV anim requires 4 arguments");
|
||||
if (tcg.m_gameArgs.size() < 2)
|
||||
Log.report(LogVisor::FatalError, "Mode2 UV anim requires 2 vector arguments");
|
||||
vals[0] = tcg.m_gameArgs[0].vec[0];
|
||||
vals[1] = tcg.m_gameArgs[1].vec[0];
|
||||
vals[2] = tcg.m_gameArgs[2].vec[0];
|
||||
vals[3] = tcg.m_gameArgs[3].vec[0];
|
||||
vals[1] = tcg.m_gameArgs[0].vec[1];
|
||||
vals[2] = tcg.m_gameArgs[1].vec[0];
|
||||
vals[3] = tcg.m_gameArgs[1].vec[1];
|
||||
}
|
||||
else if (!tcg.m_gameFunction.compare("RetroUVMode3Node"))
|
||||
{
|
||||
|
|
|
@ -320,26 +320,26 @@ struct MaterialSet : BigDNA
|
|||
break;
|
||||
}
|
||||
}
|
||||
atUint32 binarySize() const
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case ANIM_MV_INV_NOTRANS:
|
||||
case ANIM_MV_INV:
|
||||
case ANIM_MODEL:
|
||||
return 4;
|
||||
return __isz + 4;
|
||||
case ANIM_SCROLL:
|
||||
case ANIM_HSTRIP:
|
||||
case ANIM_VSTRIP:
|
||||
return 20;
|
||||
return __isz + 20;
|
||||
break;
|
||||
case ANIM_ROTATION:
|
||||
case ANIM_MODE_WHO_MUST_NOT_BE_NAMED:
|
||||
return 12;
|
||||
return __isz + 12;
|
||||
case ANIM_MODE_8:
|
||||
return 40;
|
||||
return __isz + 40;
|
||||
}
|
||||
return 4;
|
||||
return __isz + 4;
|
||||
}
|
||||
|
||||
UVAnimation() = default;
|
||||
|
|
|
@ -58,8 +58,9 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
writer.writeUint32Big((atUint32)m_nameEntries.size());
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
{
|
||||
((NameEntry&)entry).nameLen = entry.name.size();
|
||||
entry.write(writer);
|
||||
NameEntry copy = entry;
|
||||
copy.nameLen = copy.name.size();
|
||||
copy.write(writer);
|
||||
}
|
||||
|
||||
writer.writeUint32Big(m_entries.size());
|
||||
|
@ -72,6 +73,18 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t PAK::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 12;
|
||||
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
__isz += 12 + entry.name.size();
|
||||
|
||||
__isz += m_entries.size() * 20 + 4;
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
std::unique_ptr<atUint8[]>
|
||||
PAK::Entry::getBuffer(const NOD::Node& pak, atUint64& szOut) const
|
||||
{
|
||||
|
|
|
@ -29,6 +29,13 @@ void SCLY::write(Athena::io::IStreamWriter& ws) const
|
|||
ws.enumerate(layers);
|
||||
}
|
||||
|
||||
size_t SCLY::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 12;
|
||||
__isz += layerSizes.size() * 4;
|
||||
return __EnumerateSize(__isz, layers);
|
||||
}
|
||||
|
||||
void SCLY::exportToLayerDirectories(const PAK::Entry& entry, PAKRouter<PAKBridge> &pakRouter, bool force)
|
||||
{
|
||||
for (atUint32 i = 0; i < layerCount; i++)
|
||||
|
@ -139,6 +146,17 @@ void SCLY::ScriptLayer::write(Athena::io::IStreamWriter& ws) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t SCLY::ScriptLayer::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 5;
|
||||
for (const std::shared_ptr<IScriptObject>& obj : objects)
|
||||
{
|
||||
__isz += 1;
|
||||
__isz = obj->binarySize(__isz);
|
||||
}
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void SCLY::ScriptLayer::toYAML(Athena::io::YAMLDocWriter& ws) const
|
||||
{
|
||||
ws.writeUByte("unknown", unknown);
|
||||
|
|
|
@ -28,11 +28,13 @@ struct SCLY : BigYAML
|
|||
Vector<std::shared_ptr<IScriptObject>, DNA_COUNT(objectCount)> objects;
|
||||
void read(Athena::io::IStreamReader &rs);
|
||||
void write(Athena::io::IStreamWriter &ws) const;
|
||||
size_t binarySize(size_t __isz) const;
|
||||
};
|
||||
Vector<ScriptLayer, DNA_COUNT(layerCount)> layers;
|
||||
|
||||
void read(Athena::io::IStreamReader &rs);
|
||||
void write(Athena::io::IStreamWriter &ws) const;
|
||||
size_t binarySize(size_t __isz) const;
|
||||
|
||||
void exportToLayerDirectories(const PAK::Entry &, PAKRouter<PAKBridge>&, bool);
|
||||
};
|
||||
|
|
|
@ -109,6 +109,28 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t STRG::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 16;
|
||||
__isz += langs.size() * 12;
|
||||
|
||||
size_t strCount = STRG::count();
|
||||
__isz += langs.size() * strCount * 4;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
atUint32 langStrCount = lang.second.size();
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
{
|
||||
if (s < langStrCount)
|
||||
__isz += (lang.second[s].size() + 1) * 2;
|
||||
else
|
||||
__isz += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void STRG::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
const Athena::io::YAMLNode* root = reader.getRootNode();
|
||||
|
|
|
@ -163,6 +163,81 @@ void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer)
|
|||
}
|
||||
}
|
||||
|
||||
size_t ANCS::CharacterSet::CharacterInfo::binarySize(size_t __isz) const
|
||||
{
|
||||
atUint16 sectionCount;
|
||||
if (unk4 || unk5 || extents.size())
|
||||
sectionCount = 10;
|
||||
else if (partResData.elsc.size())
|
||||
sectionCount = 6;
|
||||
else if (animIdxs.size())
|
||||
sectionCount = 5;
|
||||
else if (cmdlOverlay)
|
||||
sectionCount = 4;
|
||||
else if (effects.size())
|
||||
sectionCount = 3;
|
||||
else if (animAABBs.size())
|
||||
sectionCount = 2;
|
||||
else
|
||||
sectionCount = 1;
|
||||
|
||||
__isz += 6;
|
||||
|
||||
__isz += name.size() + 1;
|
||||
__isz += 12;
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, animations);
|
||||
|
||||
__isz = pasDatabase.binarySize(__isz);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.part);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.swhc);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.unk);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.elsc);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.spsc);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, partResData.unk2);
|
||||
|
||||
__isz += 4;
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, animAABBs);
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, effects);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
__isz += 8;
|
||||
|
||||
if (sectionCount > 4)
|
||||
__isz += 4 + animIdxs.size() * 4;
|
||||
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
__isz += 9;
|
||||
__isz = __EnumerateSize(__isz, extents);
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
idx = reader.readUint32("idx");
|
||||
|
@ -400,6 +475,47 @@ void ANCS::AnimationSet::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t ANCS::AnimationSet::binarySize(size_t __isz) const
|
||||
{
|
||||
atUint16 sectionCount;
|
||||
if (evnts.size())
|
||||
sectionCount = 4;
|
||||
else if (halfTransitions.size())
|
||||
sectionCount = 3;
|
||||
else if (additiveAnims.size())
|
||||
sectionCount = 2;
|
||||
else
|
||||
sectionCount = 1;
|
||||
|
||||
__isz += 6;
|
||||
__isz = __EnumerateSize(__isz, animations);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, transitions);
|
||||
__isz = defaultTransition.binarySize(__isz);
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, additiveAnims);
|
||||
__isz += 8;
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, halfTransitions);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, evnts);
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
atUint16 sectionCount = reader.readUint16("sectionCount");
|
||||
|
@ -523,6 +639,28 @@ void ANCS::AnimationSet::EVNT::write(Athena::io::IStreamWriter& writer) const
|
|||
writer.enumerate(sfxEvents);
|
||||
}
|
||||
|
||||
size_t ANCS::AnimationSet::EVNT::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 4;
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, loopEvents);
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, uevtEvents);
|
||||
}
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, effectEvents);
|
||||
|
||||
__isz += 4;
|
||||
__isz = __EnumerateSize(__isz, sfxEvents);
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::EVNT::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
version = reader.readUint32("version");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,6 +165,17 @@ struct ANIM : BigDNA
|
|||
writer.writeUByte(qSZ);
|
||||
}
|
||||
}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 7;
|
||||
if (keyCount1)
|
||||
__isz += 9;
|
||||
if (keyCount2)
|
||||
__isz += 9;
|
||||
if (keyCount3)
|
||||
__isz += 9;
|
||||
return __isz;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -194,6 +205,11 @@ struct ANIM : BigDNA
|
|||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
return m_anim->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, const CINF& cinf, bool) const
|
||||
{
|
||||
m_anim->sendANIMToBlender(os, cinf);
|
||||
|
|
|
@ -137,6 +137,35 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t STRG::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 16;
|
||||
|
||||
__isz += langs.size() * 12;
|
||||
|
||||
__isz += 8;
|
||||
__isz += names.size() * 8;
|
||||
for (const std::pair<std::string, int32_t>& name : names)
|
||||
__isz += name.first.size() + 1;
|
||||
|
||||
size_t strCount = STRG::count();
|
||||
for (const std::pair<DNAFourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
atUint32 langStrCount = lang.second.size();
|
||||
__isz += strCount * 4;
|
||||
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
{
|
||||
if (s < langStrCount)
|
||||
__isz += (lang.second[s].size() + 1) * 2;
|
||||
else
|
||||
__isz += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void STRG::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
const Athena::io::YAMLNode* root = reader.getRootNode();
|
||||
|
|
|
@ -366,6 +366,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;
|
||||
}
|
||||
|
||||
static float ComputeFrames(const std::vector<float>& keyTimes, std::vector<atUint32>& framesOut)
|
||||
{
|
||||
if (keyTimes.size() <= 1)
|
||||
|
@ -500,5 +526,10 @@ void ANIM::ANIM1::write(Athena::io::IStreamWriter& writer) const
|
|||
{
|
||||
}
|
||||
|
||||
size_t ANIM::ANIM1::binarySize(size_t __isz) const
|
||||
{
|
||||
return __isz;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,6 +105,11 @@ struct ANIM : BigDNA
|
|||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
return m_anim->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, const CINF& cinf, bool additive) const
|
||||
{
|
||||
m_anim->sendANIMToBlender(os, cinf, additive);
|
||||
|
|
|
@ -35,6 +35,19 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::write(Athena::io::IStreamWriter& write
|
|||
writer.seek(35, Athena::Current);
|
||||
}
|
||||
|
||||
size_t CHAR::AnimationInfo::EVNT::SFXEvent::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz = EventBase::binarySize(__isz);
|
||||
__isz = caudId.binarySize(__isz);
|
||||
__isz += 16;
|
||||
__isz += unk3Vals.size() * 4;
|
||||
if (extraType == 1)
|
||||
__isz += 4;
|
||||
else if (extraType == 2)
|
||||
__isz += 35;
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void CHAR::AnimationInfo::EVNT::SFXEvent::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
EventBase::fromYAML(reader);
|
||||
|
@ -105,6 +118,13 @@ void CHAR::AnimationInfo::MetaAnimFactory::write(Athena::io::IStreamWriter& writ
|
|||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
size_t CHAR::AnimationInfo::MetaAnimFactory::binarySize(size_t __isz) const
|
||||
{
|
||||
if (!m_anim)
|
||||
return __isz;
|
||||
return m_anim->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void CHAR::AnimationInfo::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
std::string type = reader.readString("type");
|
||||
|
|
|
@ -199,6 +199,10 @@ struct MaterialSet : BigDNA
|
|||
writer.writeUBytes((atUint8*)§ion->m_type, 4);
|
||||
section->write(writer);
|
||||
}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
return section->binarySize(__isz + 4);
|
||||
}
|
||||
};
|
||||
std::vector<SectionFactory> sections;
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
|
@ -218,6 +222,13 @@ struct MaterialSet : BigDNA
|
|||
section.write(writer);
|
||||
writer.writeUBytes((atUint8*)"END ", 4);
|
||||
}
|
||||
size_t binarySize(size_t __isz) const
|
||||
{
|
||||
__isz = header.binarySize(__isz);
|
||||
for (const SectionFactory& section : sections)
|
||||
__isz = section.binarySize(__isz);
|
||||
return __isz + 4;
|
||||
}
|
||||
};
|
||||
Vector<Material, DNA_COUNT(materialCount)> materials;
|
||||
|
||||
|
|
|
@ -97,6 +97,32 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
writer.seek(rshdPad, Athena::Current);
|
||||
}
|
||||
size_t PAK::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz = m_header.binarySize(__isz);
|
||||
|
||||
size_t strgSz = 4;
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
strgSz += entry.name.size() + 13;
|
||||
size_t strgPad = ((strgSz + 63) & ~63) - strgSz;
|
||||
|
||||
size_t rshdSz = 4 + 24 * m_entries.size();
|
||||
size_t rshdPad = ((rshdSz + 63) & ~63) - rshdSz;
|
||||
|
||||
__isz += 60;
|
||||
|
||||
__isz += 4;
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
__isz = entry.binarySize(__isz);
|
||||
__isz += strgPad;
|
||||
|
||||
__isz += 4;
|
||||
for (const Entry& entry : m_entries)
|
||||
__isz = entry.binarySize(__isz);
|
||||
__isz += rshdPad;
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const NOD::Node& pak, atUint64& szOut) const
|
||||
{
|
||||
|
|
|
@ -211,6 +211,38 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t STRG::binarySize(size_t __isz) const
|
||||
{
|
||||
__isz += 24;
|
||||
__isz += names.size() * 8;
|
||||
for (const auto& name : names)
|
||||
__isz += name.first.size() + 1;
|
||||
|
||||
__isz += langs.size() * 4;
|
||||
|
||||
for (const auto& lang : langs)
|
||||
__isz += 4 + lang.second.size() * 4;
|
||||
|
||||
size_t strCount = STRG::count();
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
{
|
||||
for (const auto& lang : langs)
|
||||
{
|
||||
if (s >= lang.second.size())
|
||||
{
|
||||
__isz += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::string& str = lang.second[s];
|
||||
__isz += str.size() + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return __isz;
|
||||
}
|
||||
|
||||
void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
{
|
||||
for (const auto& item : langs)
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 8604f405026cd53774b7dac524badd2a5e0884b5
|
||||
Subproject commit 641d5b17db1e244c565a0c431cb62fb7650db89b
|
Loading…
Reference in New Issue