Files
UnrealEngineUWP/Engine/Source/Editor/StatsViewer/Private/StatsPages/LightingBuildInfoStatsPage.cpp
ryan durand 627baf970a Updating copyright for Engine Editor.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869241 via CL 10869527 via CL 10869904
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870586 by ryan durand in Main branch]
2019-12-26 15:33:43 -05:00

80 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "StatsPages/LightingBuildInfoStatsPage.h"
#define LOCTEXT_NAMESPACE "Editor.StatsViewer.LightingBuildInfo"
FLightingBuildInfoStatsPage& FLightingBuildInfoStatsPage::Get()
{
static FLightingBuildInfoStatsPage* Instance = NULL;
if( Instance == NULL )
{
Instance = new FLightingBuildInfoStatsPage;
}
return *Instance;
}
void FLightingBuildInfoStatsPage::Clear()
{
for( auto It = Entries.CreateIterator(); It; ++It )
{
TWeakObjectPtr<ULightingBuildInfo> Entry = *It;
if(Entry.IsValid())
{
Entry->RemoveFromRoot();
}
}
Entries.Empty();
}
void FLightingBuildInfoStatsPage::AddEntry( UObject* InEntry )
{
if( InEntry->IsA( ULightingBuildInfo::StaticClass() ) )
{
ULightingBuildInfo* LightingBuildInfo = Cast<ULightingBuildInfo>(InEntry);
LightingBuildInfo->AddToRoot();
Entries.Add( LightingBuildInfo );
}
}
void FLightingBuildInfoStatsPage::Generate( TArray< TWeakObjectPtr<UObject> >& OutObjects ) const
{
if(Entries.Num())
{
for( auto It = Entries.CreateConstIterator(); It; ++It )
{
TWeakObjectPtr<ULightingBuildInfo> Entry = *It;
if(Entry.IsValid())
{
ULightingBuildInfo* NewObject = DuplicateObject<ULightingBuildInfo>(Entry.Get(), Entry->GetOuter());
NewObject->AddToRoot();
OutObjects.Add( NewObject );
}
}
}
}
void FLightingBuildInfoStatsPage::GenerateTotals( const TArray< TWeakObjectPtr<UObject> >& InObjects, TMap<FString, FText>& OutTotals ) const
{
if(InObjects.Num())
{
ULightingBuildInfo* TotalEntry = NewObject<ULightingBuildInfo>();
for( auto It = InObjects.CreateConstIterator(); It; ++It )
{
ULightingBuildInfo* Entry = Cast<ULightingBuildInfo>( It->Get() );
TotalEntry->LightingTime += Entry->LightingTime;
TotalEntry->UnmappedTexelsPercentage += Entry->UnmappedTexelsPercentage;
TotalEntry->UnmappedTexelsMemory += Entry->UnmappedTexelsMemory;
TotalEntry->TotalTexelMemory += Entry->TotalTexelMemory;
}
OutTotals.Add( TEXT("LightingTime"), FText::AsNumber( TotalEntry->LightingTime ) );
OutTotals.Add( TEXT("UnmappedTexelsPercentage"), FText::AsNumber( TotalEntry->UnmappedTexelsPercentage ) );
OutTotals.Add( TEXT("UnmappedTexelsMemory"), FText::AsNumber( TotalEntry->UnmappedTexelsMemory ) );
OutTotals.Add( TEXT("TotalTexelMemory"), FText::AsNumber( TotalEntry->TotalTexelMemory ) );
}
}
#undef LOCTEXT_NAMESPACE