mirror of https://github.com/AxioDL/metaforce.git
Ensure *all* EVNT resources are extracted
This commit is contained in:
parent
7e45600bed
commit
2c151a0f3b
|
@ -164,7 +164,7 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn,
|
|||
|
||||
/* Get animation primitives */
|
||||
std::map<atUint32, AnimationResInfo<typename PAKRouter::IDType>> animResInfo;
|
||||
ancs.getAnimationResInfo(animResInfo);
|
||||
ancs.getAnimationResInfo(&pakRouter, animResInfo);
|
||||
for (const auto& id : animResInfo)
|
||||
{
|
||||
typename ANCSDNA::ANIMType anim;
|
||||
|
|
|
@ -1053,6 +1053,28 @@ void ANCS::AnimationSet::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter&
|
|||
}
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::MetaAnimPrimitive::
|
||||
gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
if (!pakRouter)
|
||||
{
|
||||
out[animIdx] = {animName, animId, UniqueID32(), false};
|
||||
return;
|
||||
}
|
||||
|
||||
const nod::Node* node;
|
||||
const PAK::Entry* entry = pakRouter->lookupEntry(animId, &node, true);
|
||||
if (!entry)
|
||||
{
|
||||
out[animIdx] = {animName, animId, UniqueID32(), false};
|
||||
return;
|
||||
}
|
||||
|
||||
PAKEntryReadStream rs = entry->beginReadStream(*node);
|
||||
out[animIdx] = {animName, animId, ANIM::GetEVNTId(rs), false};
|
||||
}
|
||||
|
||||
const char* ANCS::AnimationSet::DNAType()
|
||||
{
|
||||
return "urde::DNAMP1::ANCS::AnimationSet";
|
||||
|
@ -1095,7 +1117,7 @@ bool ANCS::Extract(const SpecBase& dataSpec,
|
|||
|
||||
/* Extract EVNTs */
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animRes;
|
||||
ancs.getAnimationResInfo(animRes);
|
||||
ancs.getAnimationResInfo(&pakRouter, animRes);
|
||||
for (const auto& res : animRes)
|
||||
{
|
||||
if (res.second.evntId)
|
||||
|
|
|
@ -168,7 +168,8 @@ struct ANCS : BigDNA
|
|||
const char* m_typeStr;
|
||||
IMetaAnim(Type type, const char* typeStr)
|
||||
: m_type(type), m_typeStr(typeStr) {}
|
||||
virtual void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)=0;
|
||||
virtual void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)=0;
|
||||
virtual bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)=0;
|
||||
};
|
||||
struct MetaAnimFactory : BigDNA
|
||||
|
@ -188,10 +189,8 @@ struct ANCS : BigDNA
|
|||
Value<float> unk1;
|
||||
Value<atUint32> unk2;
|
||||
|
||||
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
out[animIdx] = {animName, animId, UniqueID32(), false};
|
||||
}
|
||||
void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out);
|
||||
|
||||
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
|
||||
{
|
||||
|
@ -209,10 +208,11 @@ struct ANCS : BigDNA
|
|||
Value<float> unkFloat;
|
||||
Value<atUint8> unk;
|
||||
|
||||
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
animA.m_anim->gatherPrimitives(out);
|
||||
animB.m_anim->gatherPrimitives(out);
|
||||
animA.m_anim->gatherPrimitives(pakRouter, out);
|
||||
animB.m_anim->gatherPrimitives(pakRouter, out);
|
||||
}
|
||||
|
||||
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
|
||||
|
@ -235,10 +235,11 @@ struct ANCS : BigDNA
|
|||
Value<float> unkFloat;
|
||||
Value<atUint8> unk;
|
||||
|
||||
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
animA.m_anim->gatherPrimitives(out);
|
||||
animB.m_anim->gatherPrimitives(out);
|
||||
animA.m_anim->gatherPrimitives(pakRouter, out);
|
||||
animB.m_anim->gatherPrimitives(pakRouter, out);
|
||||
}
|
||||
|
||||
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
|
||||
|
@ -264,10 +265,11 @@ struct ANCS : BigDNA
|
|||
};
|
||||
Vector<Child, AT_DNA_COUNT(animCount)> children;
|
||||
|
||||
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
for (const auto& child : children)
|
||||
child.anim.m_anim->gatherPrimitives(out);
|
||||
child.anim.m_anim->gatherPrimitives(pakRouter, out);
|
||||
}
|
||||
|
||||
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
|
||||
|
@ -286,10 +288,11 @@ struct ANCS : BigDNA
|
|||
Value<atUint32> animCount;
|
||||
Vector<MetaAnimFactory, AT_DNA_COUNT(animCount)> children;
|
||||
|
||||
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
for (const auto& child : children)
|
||||
child.m_anim->gatherPrimitives(out);
|
||||
child.m_anim->gatherPrimitives(pakRouter, out);
|
||||
}
|
||||
|
||||
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
|
||||
|
@ -322,7 +325,8 @@ struct ANCS : BigDNA
|
|||
const char* m_typeStr;
|
||||
IMetaTrans(Type type, const char* typeStr)
|
||||
: m_type(type), m_typeStr(typeStr) {}
|
||||
virtual void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) {}
|
||||
virtual void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) {}
|
||||
virtual bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func) {return true;}
|
||||
};
|
||||
struct MetaTransFactory : BigDNA
|
||||
|
@ -339,9 +343,10 @@ struct ANCS : BigDNA
|
|||
AT_DECL_DNAV
|
||||
MetaAnimFactory anim;
|
||||
|
||||
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
||||
{
|
||||
anim.m_anim->gatherPrimitives(out);
|
||||
anim.m_anim->gatherPrimitives(pakRouter, out);
|
||||
}
|
||||
|
||||
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
|
||||
|
@ -432,28 +437,18 @@ struct ANCS : BigDNA
|
|||
}
|
||||
}
|
||||
|
||||
void getAnimationResInfo(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) const
|
||||
void getAnimationResInfo(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) const
|
||||
{
|
||||
out.clear();
|
||||
for (const AnimationSet::Animation& ai : animationSet.animations)
|
||||
if (AnimationSet::IMetaAnim* anim = ai.metaAnim.m_anim.get())
|
||||
anim->gatherPrimitives(out);
|
||||
anim->gatherPrimitives(pakRouter, out);
|
||||
for (const AnimationSet::Transition& ti : animationSet.transitions)
|
||||
if (AnimationSet::IMetaTrans* trans = ti.metaTrans.m_trans.get())
|
||||
trans->gatherPrimitives(out);
|
||||
trans->gatherPrimitives(pakRouter, out);
|
||||
if (AnimationSet::IMetaTrans* trans = animationSet.defaultTransition.m_trans.get())
|
||||
trans->gatherPrimitives(out);
|
||||
for (auto& anim : out)
|
||||
{
|
||||
for (const AnimationSet::AnimationResources& res : animationSet.animResources)
|
||||
{
|
||||
if (res.animId == anim.second.animId)
|
||||
{
|
||||
anim.second.evntId = res.evntId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
trans->gatherPrimitives(pakRouter, out);
|
||||
}
|
||||
|
||||
void enumeratePrimitives(const std::function<bool(AnimationSet::MetaAnimPrimitive& prim)>& func)
|
||||
|
|
|
@ -94,6 +94,28 @@ void ANIM::IANIM::sendANIMToBlender(hecl::blender::PyOutStream& os, const DNAANI
|
|||
}
|
||||
}
|
||||
|
||||
UniqueID32 ANIM::GetEVNTId(athena::io::IStreamReader& reader)
|
||||
{
|
||||
atUint32 version = reader.readUint32Big();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
ANIM0 anim0;
|
||||
anim0.read(reader);
|
||||
return anim0.evnt;
|
||||
}
|
||||
case 2:
|
||||
case 3:
|
||||
reader.seek(4);
|
||||
return reader.readUint32Big();
|
||||
default:
|
||||
Log.report(logvisor::Error, "unrecognized ANIM version");
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
void ANIM::Enumerate<BigDNA::Read>(typename Read::StreamT& reader)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@ struct ANIM : BigDNA
|
|||
{
|
||||
AT_DECL_EXPLICIT_DNA
|
||||
|
||||
static UniqueID32 GetEVNTId(athena::io::IStreamReader& r);
|
||||
|
||||
struct IANIM : BigDNAV
|
||||
{
|
||||
Delete expl;
|
||||
|
|
|
@ -249,7 +249,7 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter,
|
|||
}
|
||||
}
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animInfo;
|
||||
ancs.getAnimationResInfo(animInfo);
|
||||
ancs.getAnimationResInfo(&pakRouter, animInfo);
|
||||
for (auto& ae : animInfo)
|
||||
{
|
||||
PAK::Entry* animEnt = (PAK::Entry*)m_pak.lookupEntry(ae.second.animId);
|
||||
|
|
|
@ -204,16 +204,17 @@ struct ANCS : BigDNA
|
|||
}
|
||||
}
|
||||
|
||||
void getAnimationResInfo(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) const
|
||||
void getAnimationResInfo(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) const
|
||||
{
|
||||
out.clear();
|
||||
for (const DNAMP1::ANCS::AnimationSet::Animation& ai : animationSet.animations)
|
||||
ai.metaAnim.m_anim->gatherPrimitives(out);
|
||||
ai.metaAnim.m_anim->gatherPrimitives(nullptr, out);
|
||||
for (const DNAMP1::ANCS::AnimationSet::Transition& ti : animationSet.transitions)
|
||||
if (ti.metaTrans.m_trans)
|
||||
ti.metaTrans.m_trans->gatherPrimitives(out);
|
||||
ti.metaTrans.m_trans->gatherPrimitives(nullptr, out);
|
||||
if (animationSet.defaultTransition.m_trans)
|
||||
animationSet.defaultTransition.m_trans->gatherPrimitives(out);
|
||||
animationSet.defaultTransition.m_trans->gatherPrimitives(nullptr, out);
|
||||
}
|
||||
|
||||
static bool Extract(const SpecBase& dataSpec,
|
||||
|
|
|
@ -298,7 +298,8 @@ struct CHAR : BigDNA
|
|||
chOut.overlays.emplace_back(overlay.type, std::make_pair(overlay.cmdl, overlay.cskr));
|
||||
}
|
||||
|
||||
void getAnimationResInfo(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out) const
|
||||
void getAnimationResInfo(PAKRouter<PAKBridge>* pakRouter,
|
||||
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out) const
|
||||
{
|
||||
out.clear();
|
||||
for (const AnimationInfo::Animation& ai : animationInfo.animations)
|
||||
|
|
Loading…
Reference in New Issue