CSourceAnimData: Make use of ranged for where applicable

This commit is contained in:
Lioncash 2020-06-16 14:17:26 -04:00
parent 84a42cd3c2
commit c980df5188
1 changed files with 16 additions and 18 deletions

View File

@ -46,11 +46,11 @@ public:
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
{ {
for (uint32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++) for (const auto& transition : mTransitions)
mTransitions[TransIdx].pTransition->GetUniquePrimitives(rPrimSet); transition.pTransition->GetUniquePrimitives(rPrimSet);
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++) for (const auto& halfTrans : mHalfTransitions)
mHalfTransitions[HalfIdx].pTransition->GetUniquePrimitives(rPrimSet); halfTrans.pTransition->GetUniquePrimitives(rPrimSet);
if (mpDefaultTransition) if (mpDefaultTransition)
mpDefaultTransition->GetUniquePrimitives(rPrimSet); mpDefaultTransition->GetUniquePrimitives(rPrimSet);
@ -66,33 +66,31 @@ public:
// Find all relevant primitives // Find all relevant primitives
std::set<CAnimPrimitive> PrimSet; std::set<CAnimPrimitive> PrimSet;
if (UsedTransitions.find(mpDefaultTransition.get()) == UsedTransitions.end()) if (UsedTransitions.find(mpDefaultTransition.get()) == UsedTransitions.cend())
{ {
mpDefaultTransition->GetUniquePrimitives(PrimSet); mpDefaultTransition->GetUniquePrimitives(PrimSet);
UsedTransitions.insert(mpDefaultTransition.get()); UsedTransitions.insert(mpDefaultTransition.get());
} }
for (uint32 TransitionIdx = 0; TransitionIdx < mTransitions.size(); TransitionIdx++) for (const STransition& transition : mTransitions)
{ {
const STransition& rkTransition = mTransitions[TransitionIdx]; IMetaTransition *pTransition = transition.pTransition.get();
IMetaTransition *pTransition = rkTransition.pTransition.get();
if ( pTree->HasDependency(rkTransition.AnimA) && if (pTree->HasDependency(transition.AnimA) &&
pTree->HasDependency(rkTransition.AnimB) && pTree->HasDependency(transition.AnimB) &&
UsedTransitions.find(pTransition) == UsedTransitions.end() ) UsedTransitions.find(pTransition) == UsedTransitions.cend())
{ {
pTransition->GetUniquePrimitives(PrimSet); pTransition->GetUniquePrimitives(PrimSet);
UsedTransitions.insert(pTransition); UsedTransitions.insert(pTransition);
} }
} }
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++) for (const SHalfTransition& halfTrans : mHalfTransitions)
{ {
const SHalfTransition& rkHalfTrans = mHalfTransitions[HalfIdx]; IMetaTransition *pTransition = halfTrans.pTransition.get();
IMetaTransition *pTransition = rkHalfTrans.pTransition.get();
if ( pTree->HasDependency(rkHalfTrans.Anim) && if (pTree->HasDependency(halfTrans.Anim) &&
UsedTransitions.find(pTransition) == UsedTransitions.end() ) UsedTransitions.find(pTransition) == UsedTransitions.cend())
{ {
pTransition->GetUniquePrimitives(PrimSet); pTransition->GetUniquePrimitives(PrimSet);
UsedTransitions.insert(pTransition); UsedTransitions.insert(pTransition);
@ -104,8 +102,8 @@ public:
break; break;
// Add all transition primitives to the tree // Add all transition primitives to the tree
for (auto Iter = PrimSet.begin(); Iter != PrimSet.end(); Iter++) for (auto& primitive : PrimSet)
pTree->AddDependency(Iter->Animation()); pTree->AddDependency(primitive.Animation());
} }
} }
}; };