|
|
|
|
@@ -9,18 +9,18 @@
|
|
|
|
|
#include "GameFramework/PlayerController.h"
|
|
|
|
|
#include "Kismet/GameplayStatics.h"
|
|
|
|
|
|
|
|
|
|
ASS_PlanarCaptureManager::ASS_PlanarCaptureManager()
|
|
|
|
|
USS_PlanarCaptureManager::USS_PlanarCaptureManager()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::Initialize(FSubsystemCollectionBase& Collection)
|
|
|
|
|
void USS_PlanarCaptureManager::Initialize(FSubsystemCollectionBase& Collection)
|
|
|
|
|
{
|
|
|
|
|
Super::Initialize(Collection);
|
|
|
|
|
|
|
|
|
|
UE_LOG(LogTemp, Log, TEXT("SS_PlanarCaptureManager: Initialized for world."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::Deinitialize()
|
|
|
|
|
void USS_PlanarCaptureManager::Deinitialize()
|
|
|
|
|
{
|
|
|
|
|
// Release all render targets
|
|
|
|
|
for (FPlanarCaptureRenderTargetEntry& Entry : RenderTargetPool)
|
|
|
|
|
@@ -37,7 +37,7 @@ void ASS_PlanarCaptureManager::Deinitialize()
|
|
|
|
|
Super::Deinitialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::Tick(float DeltaTime)
|
|
|
|
|
void USS_PlanarCaptureManager::Tick(float DeltaTime)
|
|
|
|
|
{
|
|
|
|
|
Super::Tick(DeltaTime);
|
|
|
|
|
|
|
|
|
|
@@ -50,16 +50,16 @@ void ASS_PlanarCaptureManager::Tick(float DeltaTime)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TStatId ASS_PlanarCaptureManager::GetStatId() const
|
|
|
|
|
TStatId USS_PlanarCaptureManager::GetStatId() const
|
|
|
|
|
{
|
|
|
|
|
RETURN_QUICK_DECLARE_CYCLE_STAT(ASS_PlanarCaptureManager, STATGROUP_Tickables);
|
|
|
|
|
RETURN_QUICK_DECLARE_CYCLE_STAT(USS_PlanarCaptureManager, STATGROUP_Tickables);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
|
// Surface Registry
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::RegisterSurface(ABP_PlanarCaptureActor* Surface)
|
|
|
|
|
void USS_PlanarCaptureManager::RegisterSurface(ABP_PlanarCaptureActor* Surface)
|
|
|
|
|
{
|
|
|
|
|
if (!Surface)
|
|
|
|
|
{
|
|
|
|
|
@@ -87,7 +87,7 @@ void ASS_PlanarCaptureManager::RegisterSurface(ABP_PlanarCaptureActor* Surface)
|
|
|
|
|
EvaluateAllSurfaces();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::UnregisterSurface(ABP_PlanarCaptureActor* Surface)
|
|
|
|
|
void USS_PlanarCaptureManager::UnregisterSurface(ABP_PlanarCaptureActor* Surface)
|
|
|
|
|
{
|
|
|
|
|
if (!Surface)
|
|
|
|
|
{
|
|
|
|
|
@@ -105,7 +105,7 @@ void ASS_PlanarCaptureManager::UnregisterSurface(ABP_PlanarCaptureActor* Surface
|
|
|
|
|
OnSurfaceUnregistered.Broadcast(Surface, RegisteredSurfaces.Num());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<ABP_PlanarCaptureActor*> ASS_PlanarCaptureManager::GetRegisteredSurfaces() const
|
|
|
|
|
TArray<ABP_PlanarCaptureActor*> USS_PlanarCaptureManager::GetRegisteredSurfaces() const
|
|
|
|
|
{
|
|
|
|
|
TArray<ABP_PlanarCaptureActor*> Result;
|
|
|
|
|
for (const TWeakObjectPtr<ABP_PlanarCaptureActor>& Entry : RegisteredSurfaces)
|
|
|
|
|
@@ -122,7 +122,7 @@ TArray<ABP_PlanarCaptureActor*> ASS_PlanarCaptureManager::GetRegisteredSurfaces(
|
|
|
|
|
// Quality Budget Management
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::ForceAllSurfacesToTier(EPlanarCaptureQualityTier Tier)
|
|
|
|
|
void USS_PlanarCaptureManager::ForceAllSurfacesToTier(EPlanarCaptureQualityTier Tier)
|
|
|
|
|
{
|
|
|
|
|
ForceTierOverride = Tier;
|
|
|
|
|
|
|
|
|
|
@@ -138,7 +138,7 @@ void ASS_PlanarCaptureManager::ForceAllSurfacesToTier(EPlanarCaptureQualityTier
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::ReleaseForceTier()
|
|
|
|
|
void USS_PlanarCaptureManager::ReleaseForceTier()
|
|
|
|
|
{
|
|
|
|
|
ForceTierOverride.Reset();
|
|
|
|
|
EvaluateAllSurfaces();
|
|
|
|
|
@@ -148,7 +148,7 @@ void ASS_PlanarCaptureManager::ReleaseForceTier()
|
|
|
|
|
// Render Target Pool
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
UTextureRenderTarget2D* ASS_PlanarCaptureManager::RequestRenderTarget(int32 Size)
|
|
|
|
|
UTextureRenderTarget2D* USS_PlanarCaptureManager::RequestRenderTarget(int32 Size)
|
|
|
|
|
{
|
|
|
|
|
// Check pool for an available RT of the right size
|
|
|
|
|
for (FPlanarCaptureRenderTargetEntry& Entry : RenderTargetPool)
|
|
|
|
|
@@ -164,7 +164,7 @@ UTextureRenderTarget2D* ASS_PlanarCaptureManager::RequestRenderTarget(int32 Size
|
|
|
|
|
return CreateRenderTarget(Size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::ReleaseRenderTarget(UTextureRenderTarget2D* RenderTarget)
|
|
|
|
|
void USS_PlanarCaptureManager::ReleaseRenderTarget(UTextureRenderTarget2D* RenderTarget)
|
|
|
|
|
{
|
|
|
|
|
if (!RenderTarget)
|
|
|
|
|
{
|
|
|
|
|
@@ -190,7 +190,7 @@ void ASS_PlanarCaptureManager::ReleaseRenderTarget(UTextureRenderTarget2D* Rende
|
|
|
|
|
RenderTargetPool.Add(NewEntry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float ASS_PlanarCaptureManager::GetPoolMemoryUsageMB() const
|
|
|
|
|
float USS_PlanarCaptureManager::GetPoolMemoryUsageMB() const
|
|
|
|
|
{
|
|
|
|
|
float TotalBytes = 0.0f;
|
|
|
|
|
for (const FPlanarCaptureRenderTargetEntry& Entry : RenderTargetPool)
|
|
|
|
|
@@ -208,7 +208,7 @@ float ASS_PlanarCaptureManager::GetPoolMemoryUsageMB() const
|
|
|
|
|
// Query
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
ABP_PlanarCaptureActor* ASS_PlanarCaptureManager::GetNearestSurfaceOfMode(
|
|
|
|
|
ABP_PlanarCaptureActor* USS_PlanarCaptureManager::GetNearestSurfaceOfMode(
|
|
|
|
|
EPlanarCaptureMode Mode, FVector WorldLocation, float MaxDistance) const
|
|
|
|
|
{
|
|
|
|
|
ABP_PlanarCaptureActor* Nearest = nullptr;
|
|
|
|
|
@@ -239,7 +239,7 @@ ABP_PlanarCaptureActor* ASS_PlanarCaptureManager::GetNearestSurfaceOfMode(
|
|
|
|
|
// Internal Methods
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::EvaluateAllSurfaces()
|
|
|
|
|
void USS_PlanarCaptureManager::EvaluateAllSurfaces()
|
|
|
|
|
{
|
|
|
|
|
// Reset tier counts
|
|
|
|
|
TierAssignmentCounts.Empty();
|
|
|
|
|
@@ -300,7 +300,7 @@ void ASS_PlanarCaptureManager::EvaluateAllSurfaces()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EPlanarCaptureQualityTier ASS_PlanarCaptureManager::ScoreAndAssignTier(UBPC_PlanarCapture* Capture)
|
|
|
|
|
EPlanarCaptureQualityTier USS_PlanarCaptureManager::ScoreAndAssignTier(UBPC_PlanarCapture* Capture)
|
|
|
|
|
{
|
|
|
|
|
if (!Capture)
|
|
|
|
|
{
|
|
|
|
|
@@ -380,7 +380,7 @@ EPlanarCaptureQualityTier ASS_PlanarCaptureManager::ScoreAndAssignTier(UBPC_Plan
|
|
|
|
|
return NaturalTier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ASS_PlanarCaptureManager::EnforceBudgetLimits()
|
|
|
|
|
void USS_PlanarCaptureManager::EnforceBudgetLimits()
|
|
|
|
|
{
|
|
|
|
|
// Additional enforcement for total memory budget
|
|
|
|
|
float TotalMemoryMB = GetPoolMemoryUsageMB();
|
|
|
|
|
@@ -395,7 +395,7 @@ void ASS_PlanarCaptureManager::EnforceBudgetLimits()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UTextureRenderTarget2D* ASS_PlanarCaptureManager::CreateRenderTarget(int32 Size)
|
|
|
|
|
UTextureRenderTarget2D* USS_PlanarCaptureManager::CreateRenderTarget(int32 Size)
|
|
|
|
|
{
|
|
|
|
|
UTextureRenderTarget2D* RT = NewObject<UTextureRenderTarget2D>(this);
|
|
|
|
|
if (!RT)
|
|
|
|
|
@@ -418,7 +418,7 @@ UTextureRenderTarget2D* ASS_PlanarCaptureManager::CreateRenderTarget(int32 Size)
|
|
|
|
|
return RT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UTextureRenderTarget2D* ASS_PlanarCaptureManager::GetOrCreateRenderTarget(int32 Size)
|
|
|
|
|
UTextureRenderTarget2D* USS_PlanarCaptureManager::GetOrCreateRenderTarget(int32 Size)
|
|
|
|
|
{
|
|
|
|
|
// Check pool first
|
|
|
|
|
for (FPlanarCaptureRenderTargetEntry& Entry : RenderTargetPool)
|
|
|
|
|
|