mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 08:57:09 +00:00
Added support for tracking event character indices in the dependency tree
This commit is contained in:
@@ -42,6 +42,14 @@ void CDependencyTree::AddDependency(CResource *pRes, bool AvoidDuplicates /*= tr
|
||||
AddDependency(pRes->ID(), AvoidDuplicates);
|
||||
}
|
||||
|
||||
void CDependencyTree::AddEventDependency(const CAssetID& rkID, u32 CharIndex)
|
||||
{
|
||||
// Note: No duplicate check because there might be multiple events using the same asset ID with different character indices
|
||||
if (!rkID.IsValid()) return;
|
||||
CAnimEventDependency *pDepend = new CAnimEventDependency(rkID, CharIndex);
|
||||
mChildren.push_back(pDepend);
|
||||
}
|
||||
|
||||
void CDependencyTree::AddDependency(const CAssetID& rkID, bool AvoidDuplicates /*= true*/)
|
||||
{
|
||||
if (!rkID.IsValid() || (AvoidDuplicates && HasDependency(rkID))) return;
|
||||
@@ -172,6 +180,18 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
|
||||
}
|
||||
}
|
||||
|
||||
// ************ CAnimEventDependency ************
|
||||
EDependencyNodeType CAnimEventDependency::Type() const
|
||||
{
|
||||
return eDNT_AnimEvent;
|
||||
}
|
||||
|
||||
void CAnimEventDependency::Serialize(IArchive& rArc)
|
||||
{
|
||||
CResourceDependency::Serialize(rArc);
|
||||
rArc << SERIAL("CharacterIndex", mCharIndex);
|
||||
}
|
||||
|
||||
// ************ CAnimSetDependencyTree ************
|
||||
EDependencyNodeType CAnimSetDependencyTree::Type() const
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ enum EDependencyNodeType
|
||||
eDNT_ScriptInstance = FOURCC_CONSTEXPR('S', 'C', 'I', 'N'),
|
||||
eDNT_ScriptProperty = FOURCC_CONSTEXPR('S', 'C', 'P', 'R'),
|
||||
eDNT_CharacterProperty = FOURCC_CONSTEXPR('C', 'R', 'P', 'R'),
|
||||
eDNT_AnimEvent = FOURCC_CONSTEXPR('E', 'V', 'N', 'T'),
|
||||
eDNT_AnimSet = FOURCC_CONSTEXPR('A', 'N', 'C', 'S'),
|
||||
eDNT_Area = FOURCC_CONSTEXPR('A', 'R', 'E', 'A'),
|
||||
};
|
||||
@@ -55,6 +56,7 @@ public:
|
||||
|
||||
void AddDependency(const CAssetID& rkID, bool AvoidDuplicates = true);
|
||||
void AddDependency(CResource *pRes, bool AvoidDuplicates = true);
|
||||
void AddEventDependency(const CAssetID& rkID, u32 CharIndex);
|
||||
|
||||
// Accessors
|
||||
inline void SetID(const CAssetID& rkID) { mRootID = rkID; }
|
||||
@@ -145,6 +147,24 @@ protected:
|
||||
static void ParseStructDependencies(CScriptInstanceDependency *pTree, CPropertyStruct *pStruct);
|
||||
};
|
||||
|
||||
// Node representing an animation event.
|
||||
class CAnimEventDependency : public CResourceDependency
|
||||
{
|
||||
protected:
|
||||
u32 mCharIndex;
|
||||
|
||||
public:
|
||||
CAnimEventDependency() : CResourceDependency() {}
|
||||
CAnimEventDependency(const CAssetID& rkID, u32 CharIndex)
|
||||
: CResourceDependency(rkID), mCharIndex(CharIndex) {}
|
||||
|
||||
virtual EDependencyNodeType Type() const;
|
||||
virtual void Serialize(IArchive& rArc);
|
||||
|
||||
// Accessors
|
||||
inline u32 CharIndex() const { return mCharIndex; }
|
||||
};
|
||||
|
||||
// Node representing an animset resource; allows for lookup of dependencies of a particular character in the set.
|
||||
class CAnimSetDependencyTree : public CDependencyTree
|
||||
{
|
||||
@@ -200,9 +220,10 @@ public:
|
||||
case eDNT_ScriptInstance: return new CScriptInstanceDependency;
|
||||
case eDNT_ScriptProperty: return new CPropertyDependency;
|
||||
case eDNT_CharacterProperty: return new CCharPropertyDependency;
|
||||
case eDNT_AnimEvent: return new CAnimEventDependency;
|
||||
case eDNT_AnimSet: return new CAnimSetDependencyTree;
|
||||
case eDNT_Area: return new CAreaDependencyTree;
|
||||
default: return nullptr;
|
||||
default: ASSERT(false); return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -108,7 +108,11 @@ void CResourceStore::LoadResourceDatabase()
|
||||
mpDatabaseRoot = new CVirtualDirectory();
|
||||
|
||||
CXMLReader Reader(Path);
|
||||
if (!mpProj) mGame = Reader.Game();
|
||||
|
||||
if (mpProj)
|
||||
ASSERT(mpProj->Game() == Reader.Game());
|
||||
|
||||
mGame = Reader.Game();
|
||||
SerializeResourceDatabase(Reader);
|
||||
LoadCacheFile();
|
||||
}
|
||||
|
||||
@@ -200,10 +200,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||
mAreaUsedAssets.clear();
|
||||
mCurrentAreaHasDuplicates = false;
|
||||
|
||||
if (!mEnableDuplicates)
|
||||
mCurrentAreaHasDuplicates = false;
|
||||
|
||||
else
|
||||
if (mEnableDuplicates)
|
||||
{
|
||||
for (u32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
|
||||
{
|
||||
@@ -216,10 +213,18 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||
}
|
||||
}
|
||||
|
||||
// Animset - keep track of the current animset ID
|
||||
else if (ResType == eAnimSet)
|
||||
mCurrentAnimSetID = rkID;
|
||||
|
||||
// Evaluate dependencies of this entry
|
||||
CDependencyTree *pTree = pEntry->Dependencies();
|
||||
EvaluateDependencyNode(pEntry, pTree, rOut);
|
||||
rOut.push_back(rkID);
|
||||
|
||||
// Revert current animset ID
|
||||
if (ResType == eAnimSet)
|
||||
mCurrentAnimSetID = CAssetID::InvalidID(mGame);
|
||||
}
|
||||
|
||||
void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntry, IDependencyNode *pNode, std::list<CAssetID>& rOut)
|
||||
@@ -262,6 +267,15 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||
AddDependency(pCurEntry, pDep->ID(), rOut);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_AnimEvent)
|
||||
{
|
||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||
u32 CharIndex = pDep->CharIndex();
|
||||
|
||||
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
||||
AddDependency(pCurEntry, pDep->ID(), rOut);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (Type == eDNT_ScriptInstance)
|
||||
@@ -372,6 +386,8 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
// For animsets, only add used character indices
|
||||
if (ResType == eAnimSet && mGame <= eEchoes)
|
||||
{
|
||||
mCurrentAnimSetID = rkID;
|
||||
|
||||
// Add base dependencies first, then character-specific ones
|
||||
CAnimSetDependencyTree *pTree = static_cast<CAnimSetDependencyTree*>(pEntry->Dependencies());
|
||||
u32 BaseEndIdx = (pTree->NumCharacters() > 0 ? pTree->CharacterOffset(0) : pTree->NumChildren());
|
||||
@@ -379,8 +395,20 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
for (u32 iDep = 0; iDep < BaseEndIdx; iDep++)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||
ASSERT(pDep->Type() == eDNT_ResourceDependency);
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
EDependencyNodeType Type = pDep->Type();
|
||||
ASSERT(Type == eDNT_ResourceDependency || Type == eDNT_AnimEvent);
|
||||
|
||||
if (Type == eDNT_ResourceDependency)
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
|
||||
else
|
||||
{
|
||||
CAnimEventDependency *pEvent = static_cast<CAnimEventDependency*>(pDep);
|
||||
u32 CharIdx = pEvent->CharIndex();
|
||||
|
||||
if (CharIdx == -1 || mCharacterUsageMap.IsCharacterUsed(rkID, CharIdx))
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 iChar = 0; iChar < pTree->NumCharacters(); iChar++)
|
||||
@@ -400,6 +428,24 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
}
|
||||
|
||||
mCurrentAnimSetID = CAssetID::InvalidID(mGame);
|
||||
}
|
||||
|
||||
// For EVNT, only add events for used character indices
|
||||
else if (ResType == eAnimEventData)
|
||||
{
|
||||
CDependencyTree *pTree = pEntry->Dependencies();
|
||||
|
||||
for (u32 iDep = 0; iDep < pTree->NumChildren(); iDep++)
|
||||
{
|
||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pTree->ChildByIndex(iDep));
|
||||
ASSERT(pDep->Type() == eDNT_AnimEvent);
|
||||
u32 CharIdx = pDep->CharIndex();
|
||||
|
||||
if (CharIdx == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIdx))
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
}
|
||||
|
||||
// For other resource types (except SCAN and DGRP), evaluate all sub-dependencies
|
||||
|
||||
@@ -34,6 +34,7 @@ class CPackageDependencyListBuilder
|
||||
CPackage *mpPackage;
|
||||
EGame mGame;
|
||||
TResPtr<CWorld> mpWorld;
|
||||
CAssetID mCurrentAnimSetID;
|
||||
CCharacterUsageMap mCharacterUsageMap;
|
||||
std::set<CAssetID> mPackageUsedAssets;
|
||||
std::set<CAssetID> mAreaUsedAssets;
|
||||
@@ -59,6 +60,7 @@ class CAreaDependencyListBuilder
|
||||
{
|
||||
CResourceEntry *mpAreaEntry;
|
||||
EGame mGame;
|
||||
CAssetID mCurrentAnimSetID;
|
||||
CCharacterUsageMap mCharacterUsageMap;
|
||||
std::set<CAssetID> mBaseUsedAssets;
|
||||
std::set<CAssetID> mLayerUsedAssets;
|
||||
|
||||
Reference in New Issue
Block a user