You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This represents UE4/Main @18073326, Release-5.0 @18081140 and Dev-PerfTest @18045971 [CL 18081471 by aurel cordonnier in ue5-release-engine-test branch]
100 lines
2.4 KiB
C++
100 lines
2.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "EntitySystem/EntityAllocationIterator.h"
|
|
#include "EntitySystem/MovieSceneEntitySystemTypes.h"
|
|
#include "EntitySystem/MovieSceneEntityManager.h"
|
|
|
|
|
|
namespace UE
|
|
{
|
|
namespace MovieScene
|
|
{
|
|
|
|
FEntityAllocationIterator::FEntityAllocationIterator(const FEntityManager* InManager)
|
|
: Filter(nullptr)
|
|
, Manager(InManager)
|
|
, AllocationIndex(Manager->EntityAllocationMasks.GetMaxIndex())
|
|
{}
|
|
|
|
FEntityAllocationIterator::FEntityAllocationIterator(const FEntityManager* InManager, const FEntityComponentFilter* InFilter)
|
|
: Filter(InFilter)
|
|
, Manager(InManager)
|
|
{
|
|
Manager->EnterIteration();
|
|
AllocationIndex = FindMatchingAllocationStartingAt(0);
|
|
}
|
|
|
|
FEntityAllocationIterator::FEntityAllocationIterator(FEntityAllocationIterator&& RHS)
|
|
{
|
|
*this = MoveTemp(RHS);
|
|
}
|
|
|
|
FEntityAllocationIterator& FEntityAllocationIterator::operator=(FEntityAllocationIterator&& RHS)
|
|
{
|
|
Manager = RHS.Manager;
|
|
Filter = RHS.Filter;
|
|
AllocationIndex = RHS.AllocationIndex;
|
|
|
|
// Wipe out the filter so it doesn't decrement the iteration count on destruction
|
|
RHS.Filter= nullptr;
|
|
return *this;
|
|
}
|
|
|
|
FEntityAllocationIterator::~FEntityAllocationIterator()
|
|
{
|
|
if (Filter)
|
|
{
|
|
Manager->ExitIteration();
|
|
}
|
|
}
|
|
|
|
bool FEntityAllocationIterator::operator!=(const FEntityAllocationIterator& Other) const
|
|
{
|
|
return AllocationIndex != Other.AllocationIndex;
|
|
}
|
|
|
|
FEntityAllocationIterator& FEntityAllocationIterator::operator++()
|
|
{
|
|
AllocationIndex = FindMatchingAllocationStartingAt(AllocationIndex + 1);
|
|
return *this;
|
|
}
|
|
|
|
|
|
FEntityAllocationIteratorItem FEntityAllocationIterator::operator*() const
|
|
{
|
|
return FEntityAllocationIteratorItem(Manager, AllocationIndex);
|
|
}
|
|
|
|
|
|
int32 FEntityAllocationIterator::FindMatchingAllocationStartingAt(int32 Index) const
|
|
{
|
|
const FEntityComponentFilter& GlobalIterationFilter = Manager->GetGlobalIterationFilter();
|
|
const bool bHasGlobalFilter = GlobalIterationFilter.IsValid();
|
|
for ( ; Index < Manager->EntityAllocationMasks.GetMaxIndex(); ++Index)
|
|
{
|
|
if (!Manager->EntityAllocationMasks.IsAllocated(Index))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (bHasGlobalFilter == true)
|
|
{
|
|
if (!GlobalIterationFilter.Match(Manager->EntityAllocationMasks[Index]))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (Filter->Match(Manager->EntityAllocationMasks[Index]) && Manager->EntityAllocations[Index]->Num() > 0)
|
|
{
|
|
return Index;
|
|
}
|
|
}
|
|
|
|
return Index;
|
|
}
|
|
|
|
|
|
} // namespace MovieScene
|
|
} // namespace UE
|