Ensure *all* EVNT resources are extracted

This commit is contained in:
Jack Andersen 2018-05-27 15:54:55 -10:00
parent 7e45600bed
commit 2c151a0f3b
8 changed files with 84 additions and 41 deletions

View File

@ -164,7 +164,7 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn,
/* Get animation primitives */ /* Get animation primitives */
std::map<atUint32, AnimationResInfo<typename PAKRouter::IDType>> animResInfo; std::map<atUint32, AnimationResInfo<typename PAKRouter::IDType>> animResInfo;
ancs.getAnimationResInfo(animResInfo); ancs.getAnimationResInfo(&pakRouter, animResInfo);
for (const auto& id : animResInfo) for (const auto& id : animResInfo)
{ {
typename ANCSDNA::ANIMType anim; typename ANCSDNA::ANIMType anim;

View File

@ -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() const char* ANCS::AnimationSet::DNAType()
{ {
return "urde::DNAMP1::ANCS::AnimationSet"; return "urde::DNAMP1::ANCS::AnimationSet";
@ -1095,7 +1117,7 @@ bool ANCS::Extract(const SpecBase& dataSpec,
/* Extract EVNTs */ /* Extract EVNTs */
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animRes; std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animRes;
ancs.getAnimationResInfo(animRes); ancs.getAnimationResInfo(&pakRouter, animRes);
for (const auto& res : animRes) for (const auto& res : animRes)
{ {
if (res.second.evntId) if (res.second.evntId)

View File

@ -168,7 +168,8 @@ struct ANCS : BigDNA
const char* m_typeStr; const char* m_typeStr;
IMetaAnim(Type type, const char* typeStr) IMetaAnim(Type type, const char* typeStr)
: m_type(type), m_typeStr(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; virtual bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)=0;
}; };
struct MetaAnimFactory : BigDNA struct MetaAnimFactory : BigDNA
@ -188,10 +189,8 @@ struct ANCS : BigDNA
Value<float> unk1; Value<float> unk1;
Value<atUint32> unk2; Value<atUint32> unk2;
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) void gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
{ std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out);
out[animIdx] = {animName, animId, UniqueID32(), false};
}
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func) bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
{ {
@ -209,10 +208,11 @@ struct ANCS : BigDNA
Value<float> unkFloat; Value<float> unkFloat;
Value<atUint8> unk; 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); animA.m_anim->gatherPrimitives(pakRouter, out);
animB.m_anim->gatherPrimitives(out); animB.m_anim->gatherPrimitives(pakRouter, out);
} }
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func) bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
@ -235,10 +235,11 @@ struct ANCS : BigDNA
Value<float> unkFloat; Value<float> unkFloat;
Value<atUint8> unk; 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); animA.m_anim->gatherPrimitives(pakRouter, out);
animB.m_anim->gatherPrimitives(out); animB.m_anim->gatherPrimitives(pakRouter, out);
} }
bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func) bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
@ -264,10 +265,11 @@ struct ANCS : BigDNA
}; };
Vector<Child, AT_DNA_COUNT(animCount)> children; 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) 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) bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
@ -286,10 +288,11 @@ struct ANCS : BigDNA
Value<atUint32> animCount; Value<atUint32> animCount;
Vector<MetaAnimFactory, AT_DNA_COUNT(animCount)> children; 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) 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) bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func)
@ -322,7 +325,8 @@ struct ANCS : BigDNA
const char* m_typeStr; const char* m_typeStr;
IMetaTrans(Type type, const char* typeStr) IMetaTrans(Type type, const char* typeStr)
: m_type(type), m_typeStr(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;} virtual bool enumeratePrimitives(const std::function<bool(MetaAnimPrimitive& prim)>& func) {return true;}
}; };
struct MetaTransFactory : BigDNA struct MetaTransFactory : BigDNA
@ -339,9 +343,10 @@ struct ANCS : BigDNA
AT_DECL_DNAV AT_DECL_DNAV
MetaAnimFactory anim; 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) 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(); out.clear();
for (const AnimationSet::Animation& ai : animationSet.animations) for (const AnimationSet::Animation& ai : animationSet.animations)
if (AnimationSet::IMetaAnim* anim = ai.metaAnim.m_anim.get()) if (AnimationSet::IMetaAnim* anim = ai.metaAnim.m_anim.get())
anim->gatherPrimitives(out); anim->gatherPrimitives(pakRouter, out);
for (const AnimationSet::Transition& ti : animationSet.transitions) for (const AnimationSet::Transition& ti : animationSet.transitions)
if (AnimationSet::IMetaTrans* trans = ti.metaTrans.m_trans.get()) 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()) if (AnimationSet::IMetaTrans* trans = animationSet.defaultTransition.m_trans.get())
trans->gatherPrimitives(out); trans->gatherPrimitives(pakRouter, out);
for (auto& anim : out)
{
for (const AnimationSet::AnimationResources& res : animationSet.animResources)
{
if (res.animId == anim.second.animId)
{
anim.second.evntId = res.evntId;
break;
}
}
}
} }
void enumeratePrimitives(const std::function<bool(AnimationSet::MetaAnimPrimitive& prim)>& func) void enumeratePrimitives(const std::function<bool(AnimationSet::MetaAnimPrimitive& prim)>& func)

View File

@ -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 <> template <>
void ANIM::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) void ANIM::Enumerate<BigDNA::Read>(typename Read::StreamT& reader)
{ {

View File

@ -13,6 +13,8 @@ struct ANIM : BigDNA
{ {
AT_DECL_EXPLICIT_DNA AT_DECL_EXPLICIT_DNA
static UniqueID32 GetEVNTId(athena::io::IStreamReader& r);
struct IANIM : BigDNAV struct IANIM : BigDNAV
{ {
Delete expl; Delete expl;

View File

@ -249,7 +249,7 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter,
} }
} }
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animInfo; std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animInfo;
ancs.getAnimationResInfo(animInfo); ancs.getAnimationResInfo(&pakRouter, animInfo);
for (auto& ae : animInfo) for (auto& ae : animInfo)
{ {
PAK::Entry* animEnt = (PAK::Entry*)m_pak.lookupEntry(ae.second.animId); PAK::Entry* animEnt = (PAK::Entry*)m_pak.lookupEntry(ae.second.animId);

View File

@ -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(); out.clear();
for (const DNAMP1::ANCS::AnimationSet::Animation& ai : animationSet.animations) 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) for (const DNAMP1::ANCS::AnimationSet::Transition& ti : animationSet.transitions)
if (ti.metaTrans.m_trans) if (ti.metaTrans.m_trans)
ti.metaTrans.m_trans->gatherPrimitives(out); ti.metaTrans.m_trans->gatherPrimitives(nullptr, out);
if (animationSet.defaultTransition.m_trans) if (animationSet.defaultTransition.m_trans)
animationSet.defaultTransition.m_trans->gatherPrimitives(out); animationSet.defaultTransition.m_trans->gatherPrimitives(nullptr, out);
} }
static bool Extract(const SpecBase& dataSpec, static bool Extract(const SpecBase& dataSpec,

View File

@ -298,7 +298,8 @@ struct CHAR : BigDNA
chOut.overlays.emplace_back(overlay.type, std::make_pair(overlay.cmdl, overlay.cskr)); 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(); out.clear();
for (const AnimationInfo::Animation& ai : animationInfo.animations) for (const AnimationInfo::Animation& ai : animationInfo.animations)