Added support for loading meta-animations and meta-transitions (yay! animation exclusion doesn't crash anymore!)

This commit is contained in:
parax0
2016-10-27 07:18:59 -06:00
parent 595e4b931e
commit 040caca896
17 changed files with 692 additions and 284 deletions

View File

@@ -186,7 +186,7 @@ EDependencyNodeType CSetCharacterDependency::Type() const
void CSetCharacterDependency::Serialize(IArchive& rArc)
{
rArc << SERIAL("SetIndex", mSetIndex)
rArc << SERIAL("CharSetIndex", mCharSetIndex)
<< SERIAL_ABSTRACT_CONTAINER("Children", mChildren, "Child", &gDependencyNodeFactory);
}
@@ -234,8 +234,8 @@ void CSetAnimationDependency::Serialize(IArchive& rArc)
CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex)
{
const SSetAnimation *pkAnim = pkOwnerSet->Animation(AnimIndex);
CSetAnimationDependency *pTree = new CSetAnimationDependency;
const SAnimation *pkAnim = pkOwnerSet->Animation(AnimIndex);
// Find relevant character indices
for (u32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++)
@@ -246,15 +246,21 @@ CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOw
pTree->mCharacterIndices.insert(iChar);
}
// Add dependencies. In MP2 animation event data is not a standalone resource.
pTree->AddDependency(pkAnim->pAnim);
// Add primitive dependencies. In MP2 animation event data is not a standalone resource.
std::set<CAnimPrimitive> UsedPrimitives;
pkAnim->pMetaAnim->GetUniquePrimitives(UsedPrimitives);
if (pkAnim->pEventData)
for (auto Iter = UsedPrimitives.begin(); Iter != UsedPrimitives.end(); Iter++)
{
if (pkAnim->pEventData->Entry())
pTree->AddDependency(pkAnim->pEventData);
else
pkAnim->pEventData->AddDependenciesToTree(pTree);
const CAnimPrimitive& rkPrim = *Iter;
pTree->AddDependency(rkPrim.Animation());
if (pkOwnerSet->Game() >= eEchoesDemo)
{
CAnimEventData *pEvents = pkOwnerSet->AnimationEventData(rkPrim.ID());
ASSERT(pEvents && !pEvents->Entry());
pEvents->AddDependenciesToTree(pTree);
}
}
return pTree;

View File

@@ -11,7 +11,6 @@ class CScriptObject;
class CPropertyStruct;
class CAnimSet;
struct SSetCharacter;
struct SSetAnimation;
// Group of node classes forming a tree of cached resource dependencies.
enum EDependencyNodeType
@@ -154,17 +153,17 @@ protected:
class CSetCharacterDependency : public CDependencyTree
{
protected:
u32 mSetIndex;
u32 mCharSetIndex;
public:
CSetCharacterDependency() : CDependencyTree() {}
CSetCharacterDependency(u32 SetIndex) : CDependencyTree(), mSetIndex(SetIndex) {}
CSetCharacterDependency(u32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {}
virtual EDependencyNodeType Type() const;
virtual void Serialize(IArchive& rArc);
// Accessors
inline u32 SetIndex() const { return mSetIndex; }
inline u32 CharSetIndex() const { return mCharSetIndex; }
// Static
static CSetCharacterDependency* BuildTree(const CAnimSet *pkOwnerSet, u32 CharIndex);

View File

@@ -268,7 +268,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
else if (Type == eDNT_SetCharacter)
{
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->SetIndex()) || mIsPlayerActor;
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || mIsPlayerActor;
}
// Set animations should only be added if they're being used by at least one used character
@@ -438,8 +438,8 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
const u32 kEmptySuitIndex = (mGame >= eEchoesDemo ? 3 : 5);
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
u32 SetIndex = pChar->SetIndex();
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->SetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
u32 SetIndex = pChar->CharSetIndex();
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
}
else if (Type == eDNT_SetAnimation)