CDependencyTree: Tidying up
- Convert for loops to ranged for loops. - Collapse loop into an any_of.
This commit is contained in:
parent
7d4ce7e909
commit
e2190793fd
|
@ -5,6 +5,8 @@
|
||||||
#include "Core/Resource/Script/CScriptLayer.h"
|
#include "Core/Resource/Script/CScriptLayer.h"
|
||||||
#include "Core/Resource/Script/CScriptObject.h"
|
#include "Core/Resource/Script/CScriptObject.h"
|
||||||
#include "Core/Resource/Script/NGameList.h"
|
#include "Core/Resource/Script/NGameList.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
// ************ IDependencyNode ************
|
// ************ IDependencyNode ************
|
||||||
IDependencyNode::~IDependencyNode()
|
IDependencyNode::~IDependencyNode()
|
||||||
|
@ -13,21 +15,16 @@ IDependencyNode::~IDependencyNode()
|
||||||
delete mChildren[iChild];
|
delete mChildren[iChild];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDependencyNode::HasDependency(const CAssetID& rkID) const
|
bool IDependencyNode::HasDependency(const CAssetID& id) const
|
||||||
{
|
{
|
||||||
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
|
return std::any_of(mChildren.cbegin(), mChildren.cend(),
|
||||||
{
|
[&id](const auto& entry) { return entry->HasDependency(id); });
|
||||||
if (mChildren[iChild]->HasDependency(rkID))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDependencyNode::GetAllResourceReferences(std::set<CAssetID>& rOutSet) const
|
void IDependencyNode::GetAllResourceReferences(std::set<CAssetID>& rOutSet) const
|
||||||
{
|
{
|
||||||
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
|
for (const auto& child : mChildren)
|
||||||
mChildren[iChild]->GetAllResourceReferences(rOutSet);
|
child->GetAllResourceReferences(rOutSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDependencyNode::ParseProperties(CResourceEntry* pParentEntry, CStructProperty* pProperties, void* pData)
|
void IDependencyNode::ParseProperties(CResourceEntry* pParentEntry, CStructProperty* pProperties, void* pData)
|
||||||
|
@ -47,7 +44,7 @@ void IDependencyNode::ParseProperties(CResourceEntry* pParentEntry, CStructPrope
|
||||||
{
|
{
|
||||||
uint32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pData);
|
uint32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pData);
|
||||||
|
|
||||||
if (SoundID != -1)
|
if (SoundID != UINT32_MAX)
|
||||||
{
|
{
|
||||||
CGameProject* pProj = pParentEntry->Project();
|
CGameProject* pProj = pParentEntry->Project();
|
||||||
SSoundInfo Info = pProj->AudioManager()->GetSoundInfo(SoundID);
|
SSoundInfo Info = pProj->AudioManager()->GetSoundInfo(SoundID);
|
||||||
|
@ -146,7 +143,9 @@ void CDependencyTree::AddCharacterDependency(const CAnimationParameters& rkAnimP
|
||||||
{
|
{
|
||||||
// This is for formats other than MREA that use AnimationParameters (such as SCAN).
|
// This is for formats other than MREA that use AnimationParameters (such as SCAN).
|
||||||
CAnimSet *pSet = rkAnimParams.AnimSet();
|
CAnimSet *pSet = rkAnimParams.AnimSet();
|
||||||
if (!pSet || rkAnimParams.CharacterIndex() == -1) return;
|
if (!pSet || rkAnimParams.CharacterIndex() == UINT32_MAX)
|
||||||
|
return;
|
||||||
|
|
||||||
CCharPropertyDependency *pChar = new CCharPropertyDependency("NULL", pSet->ID(), rkAnimParams.CharacterIndex());
|
CCharPropertyDependency *pChar = new CCharPropertyDependency("NULL", pSet->ID(), rkAnimParams.CharacterIndex());
|
||||||
mChildren.push_back(pChar);
|
mChildren.push_back(pChar);
|
||||||
}
|
}
|
||||||
|
@ -238,27 +237,25 @@ CSetCharacterDependency* CSetCharacterDependency::BuildTree(const SSetCharacter&
|
||||||
pTree->AddDependency(rkChar.AnimDataID);
|
pTree->AddDependency(rkChar.AnimDataID);
|
||||||
pTree->AddDependency(rkChar.CollisionPrimitivesID);
|
pTree->AddDependency(rkChar.CollisionPrimitivesID);
|
||||||
|
|
||||||
const std::vector<CAssetID> *pkParticleVectors[5] = {
|
const std::array<const std::vector<CAssetID>*, 5> particleVectors{
|
||||||
&rkChar.GenericParticles, &rkChar.ElectricParticles,
|
&rkChar.GenericParticles, &rkChar.ElectricParticles,
|
||||||
&rkChar.SwooshParticles, &rkChar.SpawnParticles,
|
&rkChar.SwooshParticles, &rkChar.SpawnParticles,
|
||||||
&rkChar.EffectParticles
|
&rkChar.EffectParticles
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint32 iVec = 0; iVec < 5; iVec++)
|
for (const auto& vec : particleVectors)
|
||||||
{
|
{
|
||||||
for (uint32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++)
|
for (uint32 iPart = 0; iPart < vec->size(); iPart++)
|
||||||
pTree->AddDependency(pkParticleVectors[iVec]->at(iPart));
|
pTree->AddDependency(vec->at(iPart));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++)
|
for (const SOverlayModel& overlay : rkChar.OverlayModels)
|
||||||
{
|
{
|
||||||
const SOverlayModel& rkOverlay = rkChar.OverlayModels[iOverlay];
|
pTree->AddDependency(overlay.ModelID);
|
||||||
pTree->AddDependency(rkOverlay.ModelID);
|
pTree->AddDependency(overlay.SkinID);
|
||||||
pTree->AddDependency(rkOverlay.SkinID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pTree->AddDependency(rkChar.SpatialPrimitives);
|
pTree->AddDependency(rkChar.SpatialPrimitives);
|
||||||
|
|
||||||
return pTree;
|
return pTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,14 +289,13 @@ CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOw
|
||||||
std::set<CAnimPrimitive> UsedPrimitives;
|
std::set<CAnimPrimitive> UsedPrimitives;
|
||||||
pkAnim->pMetaAnim->GetUniquePrimitives(UsedPrimitives);
|
pkAnim->pMetaAnim->GetUniquePrimitives(UsedPrimitives);
|
||||||
|
|
||||||
for (auto Iter = UsedPrimitives.begin(); Iter != UsedPrimitives.end(); Iter++)
|
for (const CAnimPrimitive& prim : UsedPrimitives)
|
||||||
{
|
{
|
||||||
const CAnimPrimitive& rkPrim = *Iter;
|
pTree->AddDependency(prim.Animation());
|
||||||
pTree->AddDependency(rkPrim.Animation());
|
|
||||||
|
|
||||||
if (pkOwnerSet->Game() >= EGame::EchoesDemo)
|
if (pkOwnerSet->Game() >= EGame::EchoesDemo)
|
||||||
{
|
{
|
||||||
CAnimEventData *pEvents = pkOwnerSet->AnimationEventData(rkPrim.ID());
|
CAnimEventData *pEvents = pkOwnerSet->AnimationEventData(prim.ID());
|
||||||
ASSERT(pEvents && !pEvents->Entry());
|
ASSERT(pEvents && !pEvents->Entry());
|
||||||
pEvents->AddDependenciesToTree(pTree);
|
pEvents->AddDependenciesToTree(pTree);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
virtual EDependencyNodeType Type() const = 0;
|
virtual EDependencyNodeType Type() const = 0;
|
||||||
virtual void Serialize(IArchive& rArc) = 0;
|
virtual void Serialize(IArchive& rArc) = 0;
|
||||||
virtual void GetAllResourceReferences(std::set<CAssetID>& rOutSet) const;
|
virtual void GetAllResourceReferences(std::set<CAssetID>& rOutSet) const;
|
||||||
virtual bool HasDependency(const CAssetID& rkID) const;
|
virtual bool HasDependency(const CAssetID& id) const;
|
||||||
void ParseProperties(CResourceEntry* pParentEntry, CStructProperty* pProperties, void* pData);
|
void ParseProperties(CResourceEntry* pParentEntry, CStructProperty* pProperties, void* pData);
|
||||||
|
|
||||||
// Serialization constructor
|
// Serialization constructor
|
||||||
|
|
Loading…
Reference in New Issue