RealtimeStyleTransferRuntime/Source/LyraGame/Camera/LyraPlayerCameraManager.cpp

70 lines
2.1 KiB
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraPlayerCameraManager.h"
2022-09-13 07:18:28 +00:00
#include "Containers/UnrealString.h"
2022-05-23 18:41:30 +00:00
#include "Engine/Canvas.h"
2022-09-13 07:18:28 +00:00
#include "Engine/Engine.h"
#include "GameFramework/Pawn.h"
2022-05-23 18:41:30 +00:00
#include "GameFramework/PlayerController.h"
2022-09-13 07:18:28 +00:00
#include "HAL/Platform.h"
#include "LyraCameraComponent.h"
#include "LyraUICameraManagerComponent.h"
#include "Math/Color.h"
#include "Misc/AssertionMacros.h"
#include "UObject/NameTypes.h"
#include "UObject/ObjectPtr.h"
#include "UObject/UObjectBaseUtility.h"
class FDebugDisplayInfo;
2022-05-23 18:41:30 +00:00
static FName UICameraComponentName(TEXT("UICamera"));
ALyraPlayerCameraManager::ALyraPlayerCameraManager(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
DefaultFOV = LYRA_CAMERA_DEFAULT_FOV;
ViewPitchMin = LYRA_CAMERA_DEFAULT_PITCH_MIN;
ViewPitchMax = LYRA_CAMERA_DEFAULT_PITCH_MAX;
UICamera = CreateDefaultSubobject<ULyraUICameraManagerComponent>(UICameraComponentName);
}
ULyraUICameraManagerComponent* ALyraPlayerCameraManager::GetUICameraComponent() const
{
return UICamera;
}
void ALyraPlayerCameraManager::UpdateViewTarget(FTViewTarget& OutVT, float DeltaTime)
{
// If the UI Camera is looking at something, let it have priority.
if (UICamera->NeedsToUpdateViewTarget())
{
Super::UpdateViewTarget(OutVT, DeltaTime);
UICamera->UpdateViewTarget(OutVT, DeltaTime);
return;
}
Super::UpdateViewTarget(OutVT, DeltaTime);
}
void ALyraPlayerCameraManager::DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos)
{
check(Canvas);
FDisplayDebugManager& DisplayDebugManager = Canvas->DisplayDebugManager;
DisplayDebugManager.SetFont(GEngine->GetSmallFont());
DisplayDebugManager.SetDrawColor(FColor::Yellow);
DisplayDebugManager.DrawString(FString::Printf(TEXT("LyraPlayerCameraManager: %s"), *GetNameSafe(this)));
Super::DisplayDebug(Canvas, DebugDisplay, YL, YPos);
const APawn* Pawn = (PCOwner ? PCOwner->GetPawn() : nullptr);
if (const ULyraCameraComponent* CameraComponent = ULyraCameraComponent::FindCameraComponent(Pawn))
{
CameraComponent->DrawDebug(Canvas);
}
}